From ac88645baebc2c8d3e14c0827304d1604f251247 Mon Sep 17 00:00:00 2001 From: Benjamin Renard Date: Thu, 10 Sep 2015 17:31:07 +0200 Subject: [PATCH] Plot navigation --- src/InputOutput/IHMImpl/Params/PlotImpl/IHMInputOutputParamsPlotClass.php | 92 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 92 insertions(+), 0 deletions(-) diff --git a/src/InputOutput/IHMImpl/Params/PlotImpl/IHMInputOutputParamsPlotClass.php b/src/InputOutput/IHMImpl/Params/PlotImpl/IHMInputOutputParamsPlotClass.php index 45603da..bef986a 100644 --- a/src/InputOutput/IHMImpl/Params/PlotImpl/IHMInputOutputParamsPlotClass.php +++ b/src/InputOutput/IHMImpl/Params/PlotImpl/IHMInputOutputParamsPlotClass.php @@ -1223,6 +1223,11 @@ class IHMInputOutputParamsPlotClass extends IHMInputOutputParamsAbstractClass { case 'zoom' : return $this->unmarshallZoom($input, $plotInput); + case 'forward' : + case 'halfforward' : + case 'backward' : + case 'halfbackward' : + return $this->unmarshallNavigation($input, $plotInput); default : throw new Exception('Interactive action not implemented.'); } @@ -1307,5 +1312,92 @@ class IHMInputOutputParamsPlotClass extends IHMInputOutputParamsAbstractClass } throw new Exception('Cannot retrieve plot tab for zoom action.'); } + + private function unmarshallNavigation($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 ($crtTab->{'multi-plot-linked'}) + { + $startTime = $plotInput->{'startDate'}; + $stopTime = $plotInput->{'stopDate'}; + } + else + { + $startTime = $crtTab->{'startDate'}; + $stopTime = $crtTab->{'stopDate'}; + } + + //Compute new start / stop time + date_default_timezone_set('UTC'); + $startTimeStamp = strtotime($startTime); + $stopTimeStamp = strtotime($stopTime); + $duration = $stopTimeStamp - $startTimeStamp; + + switch ($input->{'action'}) + { + case 'forward' : + $startTimeStamp += $duration; + $stopTimeStamp += $duration; + break; + case 'halfforward' : + $startTimeStamp += ($duration/2); + $stopTimeStamp += ($duration/2); + break; + case 'backward' : + $startTimeStamp -= $duration; + $stopTimeStamp -= $duration; + break; + case 'halfbackward' : + $startTimeStamp -= ($duration/2); + $stopTimeStamp -= ($duration/2); + break; + } + + $startTime = date("Y-m-d\TH:i:s",$startTimeStamp); + $stopTime = date("Y-m-d\TH:i:s",$stopTimeStamp); + + //Update request + if ($crtTab->{'multi-plot-linked'}) + { + $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; + } + } } ?> \ No newline at end of file -- libgit2 0.21.2