From 00a22067dff6a9af74cef8f1e242aba547be8cae Mon Sep 17 00:00:00 2001 From: Benjamin Renard Date: Fri, 11 Sep 2015 18:16:36 +0200 Subject: [PATCH] TT navigation --- src/InputOutput/IHMImpl/Params/IHMInputOutputParamsAbstractClass.php | 18 +++++++++++++++--- src/InputOutput/IHMImpl/Params/PlotImpl/IHMInputOutputParamsPlotClass.php | 236 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++------------------------------------------------------------------------------------ src/InputOutput/IHMImpl/Tools/IHMPlotContextFileClass.php | 4 ++++ src/Request/ParamsRequestImpl/Nodes/Requests/RequestNodeClass.php | 12 ++++++++++++ src/Request/ParamsRequestImpl/Nodes/Requests/RequestTimesNodeClass.php | 30 ++++++++++++++++++++++++++++-- src/Request/ParamsRequestImpl/ParamsRequestClass.php | 15 +++++---------- 6 files changed, 216 insertions(+), 99 deletions(-) diff --git a/src/InputOutput/IHMImpl/Params/IHMInputOutputParamsAbstractClass.php b/src/InputOutput/IHMImpl/Params/IHMInputOutputParamsAbstractClass.php index e71a512..be3d888 100644 --- a/src/InputOutput/IHMImpl/Params/IHMInputOutputParamsAbstractClass.php +++ b/src/InputOutput/IHMImpl/Params/IHMInputOutputParamsAbstractClass.php @@ -52,24 +52,36 @@ abstract class IHMInputOutputParamsAbstractClass implements InputOutputInterface /* * @brief Unmarshall the time definition from the IHM request */ - protected function unmarshallTimeDefinition($input, $requestIndex, $initTTIndex = false) + protected function unmarshallTimeDefinition($input, $requestIndex, $ttFileIndex = -1, $ttIntIndex = -1) { $timesNode = $this->paramsData->getRequestNodes()[$requestIndex]->getTimesNode(); switch ($input->timesrc) { case "TimeTable" : + if (($ttFileIndex >= 0) && ($ttFileIndex >= count($input->timeTables))) + throw new Exception('Try to use a non-existing Time table index in the request.'); + + $crtIndex = 0; foreach ($input->timeTables as $tt) { + if (($ttFileIndex >= 0 ) && ($ttFileIndex != $crtIndex)) + { + // Do not plot this TT + ++$crtIndex; + continue; + } + if (strpos($tt->id, "sharedtt_") === 0) $ttPath = IHMConfigClass::getSharedTTPath(); else $ttPath = IHMConfigClass::getUserTTPath(); $ttPath .= ($tt->id.".xml"); if (strpos($tt->id, "cat_") === 0) - $timesNode->addCatalog($ttPath,$initTTIndex ? 0 : -1); + $timesNode->addCatalog($ttPath, $tt->{'timeTableName'}, $ttIntIndex); else - $timesNode->addTimeTable($ttPath,$initTTIndex ? 0 : -1); + $timesNode->addTimeTable($ttPath, $tt->{'timeTableName'}, $ttIntIndex); + ++$crtIndex; } break; case "Interval" : diff --git a/src/InputOutput/IHMImpl/Params/PlotImpl/IHMInputOutputParamsPlotClass.php b/src/InputOutput/IHMImpl/Params/PlotImpl/IHMInputOutputParamsPlotClass.php index af08125..be98494 100644 --- a/src/InputOutput/IHMImpl/Params/PlotImpl/IHMInputOutputParamsPlotClass.php +++ b/src/InputOutput/IHMImpl/Params/PlotImpl/IHMInputOutputParamsPlotClass.php @@ -11,32 +11,95 @@ class IHMInputOutputParamsPlotClass extends IHMInputOutputParamsAbstractClass { private $isInteractiveRequest = false; + private $interactiveRequestRealIndexes = array(); + private $interactiveMultiPlotState = array(); + private $interactiveTimeSelectionState = array(); + private $interactiveCrtTTFileIndex = -1; + /* * @brief method to unmarshall a plot request */ protected function unmarshallRequest($input) { + $this->interactiveRequestRealIndexes = array(); + if (isset($input->{'action'})) $input = $this->unmarshallActionRequest($input); else //save request $this->saveIHMRequest($input); + //Get active tab + $activeTab = NULL; + foreach ($input->tabs as $tab) + { + if ($tab->{'id'} == $input->{'last-plotted-tab'}) + { + $activeTab = $tab; + } + } + //Request - $requestIndex = 0; + $requestIndexInParamData = 0; + $tabRequestIndex = 0; $this->isInteractiveRequest = ($input->{'file-output'} == 'INTERACTIVE'); $postProcessCmd = ""; foreach ($input->tabs as $tab) { + if (isset($activeTab)) + { + if ($activeTab->{'multi-plot-linked'} && !$tab->{'multi-plot-linked'}) + { + ++$tabRequestIndex; + //Tab is not linked to the Multi Plot Mode + continue; + } + else if (!$activeTab->{'multi-plot-linked'} && ($tab->{'id'} != $activeTab->{'id'})) + { + ++$tabRequestIndex; + //Plot only current active tab + continue; + } + else if (isset($input->{'force-single-replot'}) && $input->{'force-single-replot'} && ($tab->{'id'} != $activeTab->{'id'})) + { + ++$tabRequestIndex; + //Plot only current active tab when 'force-single-replot' is active + continue; + } + } + $requestNode = $this->paramsData->addRequestNode(); + $requestNode->setRealIndex($tabRequestIndex); $outputsNode = $requestNode->getOutputsNode(); $paramsNode = $requestNode->getParamsNode(); //unmarshall time definition if ($tab->{'multi-plot-linked'}) - $this->unmarshallTimeDefinition($input, $requestIndex, $this->isInteractiveRequest && !$tab->{'page-superpose-mode'}); + { + $isIntervalRequest = ($input->timesrc == 'Interval'); + $ttFileIndex = -1; + $ttIntIndex = -1; + if ($this->isInteractiveRequest && !$isIntervalRequest && !$tab->{'page-superpose-mode'}) + { + $ttFileIndex = !isset($activeTab->{'ttFileIndex'}) ? 0 : $activeTab->{'ttFileIndex'}; + $ttIntIndex = !isset($activeTab->{'intIndex'}) ? 0 : $activeTab->{'intIndex'}; + } + $this->unmarshallTimeDefinition($input, $requestIndexInParamData, $ttFileIndex, $ttIntIndex); + } else - $this->unmarshallTimeDefinition($tab, $requestIndex, $this->isInteractiveRequest && !$tab->{'page-superpose-mode'}); + { + $isIntervalRequest = ($tab->timesrc == 'Interval'); + $ttFileIndex = -1; + $ttIntIndex = -1; + if ($this->isInteractiveRequest && !$isIntervalRequest && !$tab->{'page-superpose-mode'}) + { + $ttFileIndex = !isset($activeTab->{'ttFileIndex'}) ? 0 : $activeTab->{'ttFileIndex'}; + $ttIntIndex = !isset($activeTab->{'intIndex'}) ? 0 : $activeTab->{'intIndex'}; + } + $this->unmarshallTimeDefinition($tab, $requestIndexInParamData, $ttFileIndex, $ttIntIndex); + } + + $this->interactiveCrtTTFileIndex = $ttFileIndex; $plotOutputNode = $outputsNode->addNewOutput(RequestOutputTypeEnum::PLOT); @@ -171,7 +234,12 @@ class IHMInputOutputParamsPlotClass extends IHMInputOutputParamsAbstractClass } if ($this->isInteractiveRequest) + { + $this->interactiveRequestRealIndexes[PLOT_RESULT_FILE_KEY."_".$tab->{'id'}] = $tabRequestIndex; + $this->interactiveMultiPlotState[PLOT_RESULT_FILE_KEY."_".$tab->{'id'}] = $tab->{'multi-plot-linked'}; + $this->interactiveTimeSelectionState[PLOT_RESULT_FILE_KEY."_".$tab->{'id'}] = $isIntervalRequest; $this->paramsData->addWaitingResult(PLOT_RESULT_FILE_KEY."_".$tab->{'id'}, $waitingResultFile); + } else $this->paramsData->addWaitingResult(PLOT_RESULT_FILE_KEY, $waitingResultFile); @@ -188,7 +256,8 @@ class IHMInputOutputParamsPlotClass extends IHMInputOutputParamsAbstractClass if ($this->isInteractiveRequest && $isPortrait) $postProcessCmd .= " | convert ".$waitingResultFile." -rotate -90 ".$waitingResultFile; - ++$requestIndex; + ++$tabRequestIndex; + ++$requestIndexInParamData; } $this->paramsData->setBatchEnable(!(($fileFormat == RequestOutputPlotPageFormatEnum::PNG) && $this->isInteractiveRequest)); @@ -1146,6 +1215,7 @@ class IHMInputOutputParamsPlotClass extends IHMInputOutputParamsAbstractClass return $commonRes; } + //Interactive request if (!$data->getSuccess()) return array( 'success' => false, @@ -1162,6 +1232,10 @@ class IHMInputOutputParamsPlotClass extends IHMInputOutputParamsAbstractClass $result[] = array( "id" => $key, + "index" => $this->interactiveRequestRealIndexes[$key], + "multiplot" => $this->interactiveMultiPlotState[$key], + "isInterval" => $this->interactiveTimeSelectionState[$key], + "ttFileIndex" => $this->interactiveCrtTTFileIndex, "context" => IHMPlotContextFileClass::parse($this->getWorkingPath().$contextResult), "plot" => $waitingResult ); @@ -1230,6 +1304,8 @@ class IHMInputOutputParamsPlotClass extends IHMInputOutputParamsAbstractClass case 'extend' : case 'shift' : return $this->unmarshallNavigation($input, $plotInput); + case 'goto' : + return $this->unmarshallTTGoto($input, $plotInput); default : throw new Exception('Interactive action not implemented.'); } @@ -1237,82 +1313,65 @@ class IHMInputOutputParamsPlotClass extends IHMInputOutputParamsAbstractClass private function unmarshallZoom($input, $plotInput) { + //Find current tab + $crtTab = NULL; + foreach ($plotInput->{'tabs'} as $tab) + { + if ($input->{'tabId'} == PLOT_RESULT_FILE_KEY."_".$tab->{'id'}) + { + $crtTab = $tab; + break; + } + } + + if (!$crtTab) + throw new Exception('Cannot retrieve plot tab for navigation action.'); + if ($input->{'axeId'} == 'timeAxis') { - //Time Axis - foreach ($plotInput->{'tabs'} as $tab) + //Zoom on Time Axis + if ($crtTab->{'multi-plot-linked'}) { - if ($input->{'tabId'} == PLOT_RESULT_FILE_KEY."_".$tab->{'id'}) - { - if ($tab->{'multi-plot-linked'}) - { - //Update multi plot time definition - $plotInput = $plotInput; - $plotInput->{'timesrc'} = 'Interval'; - $plotInput->{'startDate'} = $input->{'min'}; - $plotInput->{'stopDate'} = $input->{'max'}; - - $interactiveInput = clone $plotInput; - $interactiveInput->{'tabs'} = array(); - //Execute only tabs linked to the multi plot mode - foreach ($plotInput->{'tabs'} as $tab2) - { - if ($tab2->{'multi-plot-linked'}) - $interactiveInput->{'tabs'}[] = $tab2; - } - - $this->saveIHMRequest($plotInput); - return $interactiveInput; - } - else - { - //Update tab time definition - $tab->{'timesrc'} = 'Interval'; - $tab->{'startDate'} = $input->{'min'}; - $tab->{'stopDate'} = $input->{'max'}; - //Execute only concerning plot tabs - $interactiveInput = clone $plotInput; - $interactiveInput->{'tabs'} = array(); - $interactiveInput->{'tabs'}[] = $tab; - $this->saveIHMRequest($plotInput); - return $interactiveInput; - } - } + //Update multi plot time definition + $plotInput->{'timesrc'} = 'Interval'; + $plotInput->{'startDate'} = $input->{'min'}; + $plotInput->{'stopDate'} = $input->{'max'}; } - throw new Exception('Cannot retrieve plot tab for zoom action.'); + else + { + $crtTab->{'timesrc'} = 'Interval'; + $crtTab->{'startDate'} = $input->{'min'}; + $crtTab->{'stopDate'} = $input->{'max'}; + } + + $plotInput->{'last-plotted-tab'} = $crtTab->{'id'}; + $this->saveIHMRequest($plotInput); + return $plotInput; } - //Execute only concerning plot tabs - $interactiveInput = clone $plotInput; - $interactiveInput->{'tabs'} = array(); - foreach ($plotInput->{'tabs'} as $tab) + //Digital axis zoom + foreach ($crtTab->{'panels'} as $panel) { - if ($input->{'tabId'} == PLOT_RESULT_FILE_KEY."_".$tab->{'id'}) + if ($input->{'panelId'} == $panel->{'id'}) { - //Add current tab to interactive input - $interactiveInput->{'tabs'}[] = $tab; - foreach ($interactiveInput->{'tabs'}[0]->{'panels'} as $panel) + foreach ($panel->{'axes'} as $axis) { - if ($input->{'panelId'} == $panel->{'id'}) + if ($input->{'axeId'} == $axis->{'id'}) { - foreach ($panel->{'axes'} as $axis) - { - if ($input->{'axeId'} == $axis->{'id'}) - { - $axis->{'axis-range-extend'} = false; - $axis->{'axis-range-min'} = $input->{'min'}; - $axis->{'axis-range-max'} = $input->{'max'}; - $this->saveIHMRequest($plotInput); - return $interactiveInput; - } - } - throw new Exception('Cannot retrieve axis for zoom action.'); + $axis->{'axis-range-extend'} = false; + $axis->{'axis-range-min'} = $input->{'min'}; + $axis->{'axis-range-max'} = $input->{'max'}; + $plotInput->{'last-plotted-tab'} = $crtTab->{'id'}; + $this->saveIHMRequest($plotInput); + //Do not save 'force-single-replot' in request file! + $plotInput->{'force-single-replot'} = true; + return $plotInput; } } - throw new Exception('Cannot retrieve plot panel for zoom action.'); + throw new Exception('Cannot retrieve axis for zoom action.'); } } - throw new Exception('Cannot retrieve plot tab for zoom action.'); + throw new Exception('Cannot retrieve plot panel for zoom action.'); } private function unmarshallNavigation($input, $plotInput) @@ -1387,30 +1446,39 @@ class IHMInputOutputParamsPlotClass extends IHMInputOutputParamsAbstractClass { $plotInput->{'startDate'} = $startTime; $plotInput->{'stopDate'} = $stopTime; - - $interactiveInput = clone $plotInput; - $interactiveInput->{'tabs'} = array(); - //Execute only tabs linked to the multi plot mode - foreach ($plotInput->{'tabs'} as $tab) - { - if ($tab->{'multi-plot-linked'}) - $interactiveInput->{'tabs'}[] = $tab; - } - $this->saveIHMRequest($plotInput); - return $interactiveInput; } else { $crtTab->{'startDate'} = $startTime; $crtTab->{'stopDate'} = $stopTime; - - $interactiveInput = clone $plotInput; - $interactiveInput->{'tabs'} = array(); - //Execute only concerning plot tabs - $interactiveInput->{'tabs'}[] = $crtTab; - $this->saveIHMRequest($plotInput); - return $interactiveInput; } + + $plotInput->{'last-plotted-tab'} = $crtTab->{'id'}; + $this->saveIHMRequest($plotInput); + return $plotInput; + } + + private function unmarshallTTGoto($input, $plotInput) + { + //Find current tab + $crtTab = NULL; + foreach ($plotInput->{'tabs'} as $tab) + { + if ($input->{'tabId'} == PLOT_RESULT_FILE_KEY."_".$tab->{'id'}) + { + $crtTab = $tab; + break; + } + } + + if (!$crtTab) + throw new Exception('Cannot retrieve plot tab for navigation action.'); + + $crtTab->{'ttFileIndex'} = $input->{'ttFileIndex'}; + $crtTab->{'intIndex'} = $input->{'intIndex'}; + + $this->saveIHMRequest($plotInput); + return $plotInput; } } ?> \ No newline at end of file diff --git a/src/InputOutput/IHMImpl/Tools/IHMPlotContextFileClass.php b/src/InputOutput/IHMImpl/Tools/IHMPlotContextFileClass.php index 247921e..bdfd0a9 100644 --- a/src/InputOutput/IHMImpl/Tools/IHMPlotContextFileClass.php +++ b/src/InputOutput/IHMImpl/Tools/IHMPlotContextFileClass.php @@ -25,6 +25,10 @@ class IHMPlotContextFileClass { $pageContext = array( 'startTime' => $pageNode->getAttribute('startTime'), 'stopTime' => $pageNode->getAttribute('stopTime'), + 'superposeMode' => ($pageNode->getAttribute('stopTime') == "true"), + 'ttName' => $pageNode->getAttribute('ttName'), + 'ttIndex' => ($pageNode->getAttribute('ttIndex') == '') ? 0 : intval($pageNode->getAttribute('ttIndex')), + 'ttNbIntervals' => ($pageNode->getAttribute('ttNbIntervals') == '') ? 0 : intval($pageNode->getAttribute('ttNbIntervals')), 'portrait' => $isPortrait, //An image rotation of 90 deg. is done after request execution if a page is in "portrait" mode 'width' => ($isPortrait ? intval($pageNode->getAttribute('height')) : intval($pageNode->getAttribute('width'))), diff --git a/src/Request/ParamsRequestImpl/Nodes/Requests/RequestNodeClass.php b/src/Request/ParamsRequestImpl/Nodes/Requests/RequestNodeClass.php index e62a1a6..d59943c 100644 --- a/src/Request/ParamsRequestImpl/Nodes/Requests/RequestNodeClass.php +++ b/src/Request/ParamsRequestImpl/Nodes/Requests/RequestNodeClass.php @@ -65,6 +65,8 @@ define ("REQUEST_NAME", "request"); */ class RequestNodeClass extends NodeClass { + private $realIndex = 0; + public function __construct() { parent::__construct(REQUEST_NAME); @@ -88,6 +90,16 @@ class RequestNodeClass extends NodeClass { return $this->getFirstChildByName(REQUESTOUTPUTS_NAME); } + + public function setRealIndex($index) + { + $this->realIndex = $index; + } + + public function getRealIndex() + { + return $this->realIndex; + } } ?> \ No newline at end of file diff --git a/src/Request/ParamsRequestImpl/Nodes/Requests/RequestTimesNodeClass.php b/src/Request/ParamsRequestImpl/Nodes/Requests/RequestTimesNodeClass.php index 21dc721..a07671b 100644 --- a/src/Request/ParamsRequestImpl/Nodes/Requests/RequestTimesNodeClass.php +++ b/src/Request/ParamsRequestImpl/Nodes/Requests/RequestTimesNodeClass.php @@ -43,6 +43,7 @@ class RequestTimesIntervalNodeClass extends NodeClass define ("REQUESTTIMETABLE_NAME", "timetable"); define ("REQUESTTIMETABLE_ID", "id"); +define ("REQUESTTIMETABLE_TTNAME", "name"); define ("REQUESTTIMETABLE_INDEX", "index"); /** @@ -67,6 +68,16 @@ class RequestTimesTimeTableNodeClass extends NodeClass return $this->getAttribute(REQUESTTIMETABLE_ID); } + public function setTTName($name) + { + $this->setAttribute(REQUESTTIMETABLE_TTNAME, $name); + } + + public function getTTName() + { + return $this->getAttribute(REQUESTTIMETABLE_TTNAME); + } + public function setIndex($index) { $this->setAttribute(REQUESTTIMETABLE_INDEX, $index); @@ -80,6 +91,7 @@ class RequestTimesTimeTableNodeClass extends NodeClass define ("REQUESTCATALOG_NAME", "catalog"); define ("REQUESTCATALOG_ID", "id"); +define ("REQUESTCATALOG_TTNAME", "name"); define ("REQUESTCATALOG_INDEX", "index"); /** @@ -103,6 +115,16 @@ class RequestCatalogNodeClass extends NodeClass { return $this->getAttribute(REQUESTCATALOG_ID); } + + public function setCatalogName($name) + { + $this->setAttribute(REQUESTCATALOG_TTNAME, $name); + } + + public function getCatalogName() + { + return $this->getAttribute(REQUESTCATALOG_TTNAME); + } public function setIndex($index) { @@ -141,19 +163,23 @@ class RequestTimesNodeClass extends NodeClass return $this->getChildrenByName(REQUESTTIMEINTERVAL_NAME); } - public function addTimeTable($id, $index = -1) + public function addTimeTable($id, $name, $index = -1) { $timeTable = new RequestTimesTimeTableNodeClass(); $timeTable->setId($id); + if ($name != '') + $timeTable->setTTName($name); if ($index >= 0) $timeTable->setIndex($index); $this->addChild($timeTable); } - public function addCatalog($id, $index = -1) + public function addCatalog($id, $name, $index = -1) { $catalogNode = new RequestCatalogNodeClass(); $catalogNode->setId($id); + if ($name != '') + $catalogNode->setCatalogName($name); if ($index >= 0) $catalogNode->setIndex($index); $this->addChild($catalogNode); diff --git a/src/Request/ParamsRequestImpl/ParamsRequestClass.php b/src/Request/ParamsRequestImpl/ParamsRequestClass.php index f9ac1c9..4480159 100644 --- a/src/Request/ParamsRequestImpl/ParamsRequestClass.php +++ b/src/Request/ParamsRequestImpl/ParamsRequestClass.php @@ -23,13 +23,11 @@ class ParamsRequestClass extends ProcessRequestClass { case ParamsRequestTypeEnumClass::XMLREQUEST : $cmd = ""; - $requestIndex = 0; foreach ($this->requestData->getRequestNodes() as $requestNode) { if ($cmd != "") $cmd .= " && "; - $cmd .= KernelConfigClass::getKernelBinPath()."amdaXMLRequestorTool ".$this->getRequestFilePath($requestIndex); - ++$requestIndex; + $cmd .= KernelConfigClass::getKernelBinPath()."amdaXMLRequestorTool ".$this->getRequestFilePath($requestNode->getRealIndex()); } $this->requestData->setCmd($cmd); break; @@ -62,7 +60,6 @@ class ParamsRequestClass extends ProcessRequestClass if ($this->requestData->getRequestType() == ParamsRequestTypeEnumClass::XMLREQUEST) { - $requestIndex = 0; foreach ($this->requestData->getRequestNodes() as $requestNode) { //create XML request file @@ -72,25 +69,23 @@ class ParamsRequestClass extends ProcessRequestClass if (!$xmlNode = $requestNode->toXMLNode($doc)) { - $this->requestData->setLastErrorMessage('Cannot create params request XML file for request '.$requestIndex); + $this->requestData->setLastErrorMessage('Cannot create params request XML file for request '.$requestNode->getRealIndex()); return false; } $doc->appendChild($xmlNode); - if (!$doc->save($this->getRequestFilePath($requestIndex))) + if (!$doc->save($this->getRequestFilePath($requestNode->getRealIndex()))) { - $this->requestData->setLastErrorMessage('Cannot save params request XML file for request '.$requestIndex); + $this->requestData->setLastErrorMessage('Cannot save params request XML file for request '.$requestNode->getRealIndex()); return false; } if (!$doc->schemaValidate(KernelConfigClass::getXSDRequestFilePath())) { - $this->requestData->setLastErrorMessage('Params request XML file not valid for request '.$requestIndex); + $this->requestData->setLastErrorMessage('Params request XML file not valid for request '.$requestNode->getRealIndex()); return false; } - - ++$requestIndex; } } -- libgit2 0.21.2