diff --git a/src/InputOutput/IHMImpl/Params/PlotImpl/IHMInputOutputParamsPlotClass.php b/src/InputOutput/IHMImpl/Params/PlotImpl/IHMInputOutputParamsPlotClass.php index 69fb2e7..3240618 100644 --- a/src/InputOutput/IHMImpl/Params/PlotImpl/IHMInputOutputParamsPlotClass.php +++ b/src/InputOutput/IHMImpl/Params/PlotImpl/IHMInputOutputParamsPlotClass.php @@ -47,7 +47,7 @@ class IHMInputOutputParamsPlotClass extends IHMInputOutputParamsAbstractClass $postProcessCmd = ""; if ($forceTimeZoomReset) - $this->resetZoomListForTab($input->{'tab-index'}, $forceTimeZoomReset); + $this->resetZoomList(PLOT_RESULT_FILE_KEY."_".$input->{'tab-index'}, $forceTimeZoomReset); $requestNode = $this->paramsData->addRequestNode(); $outputsNode = $requestNode->getOutputsNode(); @@ -1465,6 +1465,26 @@ class IHMInputOutputParamsPlotClass extends IHMInputOutputParamsAbstractClass return NULL; return json_decode(file_get_contents($path)); } + + + + private function loadZoomList($interactiveId) + { + $path = $this->getWorkingPath()."zoom.list.".$interactiveId; + if (!file_exists($path)) + return NULL; + return json_decode(file_get_contents($path)); + } + + private function saveZoomList($interactiveId, $zoomList) + { + $path = $this->getWorkingPath()."zoom.list.".$interactiveId; + if (!is_dir($this->getWorkingPath())) + mkdir($this->getWorkingPath(),0777); + $file = fopen($path, 'w'); + fwrite($file, json_encode($zoomList)); + fclose($file); + } private function unmarshallActionRequest($input) { @@ -1502,34 +1522,27 @@ class IHMInputOutputParamsPlotClass extends IHMInputOutputParamsAbstractClass //if $isInterval == true, $minOrFileIndex is the min and $maxOrInetrvalIndex is the max //if $isInterval == false, $minOrFileIndex is the fileIndex and $maxOrInetrvalIndex is the intervalIndex - $zoomList = $this->loadZoomList(); + $zoomList = $this->loadZoomList($input->interactiveId); - if (!isset($zoomList->tabs)) + if (!isset($zoomList)) { //Init zoom list $zoomList = (Object)array( - 'tabs' => (Object)array() - ); - } - - if (!isset($zoomList->tabs->{$input->{'tabId'}})) - { - $zoomList->tabs->{$input->{'tabId'}} = (Object)array( - 'times' => array(), - 'panels' => (Object)array() + 'times' => array(), + 'panels' => (Object)array() ); } if ($input->{'axeId'} == 'timeAxis') { if ($isInterval) - array_push ($zoomList->tabs->{$input->{'tabId'}}->times, (Object)array( + array_push ($zoomList->times, (Object)array( 'isInterval' => true, 'min' => $minOrFileIndex, 'max' => $maxOrIntervalIndex )); else - array_push ($zoomList->tabs->{$input->{'tabId'}}->times, (Object)array( + array_push ($zoomList->times, (Object)array( 'isInterval' => false, 'ttFileIndex' => $minOrFileIndex, 'intIndex' => $maxOrIntervalIndex @@ -1537,141 +1550,103 @@ class IHMInputOutputParamsPlotClass extends IHMInputOutputParamsAbstractClass } else { - if (!isset($zoomList->tabs->{$input->{'tabId'}}->panels->{$input->{'panelId'}})) + if (!isset($zoomList->panels->{$input->{'panelId'}})) { - $zoomList->tabs->{$input->{'tabId'}}->panels->{$input->{'panelId'}} = (Object) array( + $zoomList->panels->{$input->{'panelId'}} = (Object) array( 'axes' => (Object)array() ); } - if (!isset($zoomList->tabs->{$input->{'tabId'}}->panels->{$input->{'panelId'}}->axes->{$input->{'axeId'}})) + if (!isset($zoomList->panels->{$input->{'panelId'}}->axes->{$input->{'axeId'}})) { - $zoomList->tabs->{$input->{'tabId'}}->panels->{$input->{'panelId'}}->axes->{$input->{'axeId'}} = array(); + $zoomList->panels->{$input->{'panelId'}}->axes->{$input->{'axeId'}} = array(); } - array_push ($zoomList->tabs->{$input->{'tabId'}}->panels->{$input->{'panelId'}}->axes->{$input->{'axeId'}}, (Object)array( + array_push ($zoomList->panels->{$input->{'panelId'}}->axes->{$input->{'axeId'}}, (Object)array( 'min' => $minOrFileIndex, 'max' => $maxOrIntervalIndex )); } - //save zoom list - $path = $this->getWorkingPath()."zoom.list"; - if (!is_dir($this->getWorkingPath())) - mkdir($this->getWorkingPath(),0777); - $file = fopen($path, 'w'); - fwrite($file, json_encode($zoomList)); - fclose($file); - } - - private function loadZoomList() - { - $path = $this->getWorkingPath()."zoom.list"; - if (!file_exists($path)) - return NULL; - return json_decode(file_get_contents($path)); + $this->saveZoomList($input->interactiveId, $zoomList); } - private function resetZoomListForTab($tabId, $resetOnlyTimeZoom = false) + private function resetZoomList($interactiveId, $resetOnlyTimeZoom = false) { - $zoomList = $this->loadZoomList(); - - if (isset($zoomList->tabs) && isset($zoomList->tabs->{PLOT_RESULT_FILE_KEY."_".$tabId})) - { - if (!$resetOnlyTimeZoom) - unset($zoomList->tabs->{PLOT_RESULT_FILE_KEY."_".$tabId}); - else - $zoomList->tabs->{PLOT_RESULT_FILE_KEY."_".$tabId}->times = array(); + if (!$resetOnlyTimeZoom) { + $zoomList = (Object)array( + 'times' => array(), + 'panels' => (Object)array() + ); } - - $path = $this->getWorkingPath()."zoom.list"; - if (!is_dir($this->getWorkingPath())) - mkdir($this->getWorkingPath(),0777); - $file = fopen($path, 'w'); - fwrite($file, json_encode($zoomList)); - fclose($file); + else { + $zoomList = $this->loadZoomList($interactiveId); + $zoomList->times = array(); + } + + $this->saveZoomList($interactiveId, $zoomList); } private function undoZoomInList($input) { - $zoomList = $this->loadZoomList(); + $zoomList = $this->loadZoomList($input->interactiveId); $result = NULL; - if (isset($zoomList->tabs) && isset($zoomList->tabs->{$input->{'tabId'}})) + if ($zoomList) { if ($input->{'axeId'} == 'timeAxis') { - if (count($zoomList->tabs->{$input->{'tabId'}}->times) <= 0) + if (count($zoomList->times) <= 0) return NULL; - $result = array_pop($zoomList->tabs->{$input->{'tabId'}}->times); + $result = array_pop($zoomList->times); } else { - if (!isset($zoomList->tabs->{$input->{'tabId'}}->panels->{$input->{'panelId'}})) + if (!isset($zoomList->panels->{$input->{'panelId'}})) return NULL; - if (!isset($zoomList->tabs->{$input->{'tabId'}}->panels->{$input->{'panelId'}}->axes->{$input->{'axeId'}})) + if (!isset($zoomList->panels->{$input->{'panelId'}}->axes->{$input->{'axeId'}})) return NULL; - $result = array_pop($zoomList->tabs->{$input->{'tabId'}}->panels->{$input->{'panelId'}}->axes->{$input->{'axeId'}}); + $result = array_pop($zoomList->panels->{$input->{'panelId'}}->axes->{$input->{'axeId'}}); } } else return NULL; - $path = $this->getWorkingPath()."zoom.list"; - if (!is_dir($this->getWorkingPath())) - mkdir($this->getWorkingPath(),0777); - $file = fopen($path, 'w'); - fwrite($file, json_encode($zoomList)); - fclose($file); + $this->saveZoomList($input->interactiveId, $zoomList); return $result; } private function unmarshallZoom($input, $plotInput, $isUndo = false) { - //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') { //Zoom on Time Axis - if ($crtTab->{'timesrc'} != 'Interval') + if ($plotInput->{'timesrc'} != 'Interval') { - $crtTab->{'timesrc'} = 'Interval'; + $plotInput->{'timesrc'} = 'Interval'; if (!$isUndo) $this->addZoomInList($input,false, - isset($crtTab->{'ttFileIndex'}) ? $crtTab->{'ttFileIndex'} : 0, - isset($crtTab->{'intIndex'}) ? $crtTab->{'intIndex'} : 0); + isset($plotInput->{'ttFileIndex'}) ? $plotInput->{'ttFileIndex'} : 0, + isset($plotInput->{'intIndex'}) ? $plotInput->{'intIndex'} : 0); } else { if (!$isUndo) - $this->addZoomInList($input,true,$crtTab->{'startDate'},$crtTab->{'stopDate'}); + $this->addZoomInList($input,true,$plotInput->{'startDate'},$plotInput->{'stopDate'}); } - $crtTab->{'startDate'} = $input->{'min'}; - $crtTab->{'stopDate'} = $input->{'max'}; + $plotInput->{'startDate'} = $input->{'min'}; + $plotInput->{'stopDate'} = $input->{'max'}; - $plotInput->{'last-plotted-tab'} = $crtTab->{'id'}; $plotInput->{'force-time-zoom-reset'} = false; - $this->saveIHMRequest($plotInput); + $this->saveIHMRequest($input->interactiveId, $plotInput); return $plotInput; } //Digital axis zoom - foreach ($crtTab->{'panels'} as $panel) + foreach ($plotInput->{'panels'} as $panel) { if ($input->{'panelId'} == $panel->{'id'}) { @@ -1684,8 +1659,7 @@ class IHMInputOutputParamsPlotClass extends IHMInputOutputParamsAbstractClass $oldMax = $axis->{'axis-range-max'}; $axis->{'axis-range-min'} = $input->{'min'}; $axis->{'axis-range-max'} = $input->{'max'}; - $plotInput->{'last-plotted-tab'} = $crtTab->{'id'}; - $this->saveIHMRequest($plotInput); + $this->saveIHMRequest($input->interactiveId, $plotInput); //Do not save 'force-single-replot' in request file! $plotInput->{'force-single-replot'} = true; $plotInput->{'force-time-zoom-reset'} = false; -- libgit2 0.21.2