Commit ac88645baebc2c8d3e14c0827304d1604f251247

Authored by Benjamin Renard
1 parent 30a70818

Plot navigation

src/InputOutput/IHMImpl/Params/PlotImpl/IHMInputOutputParamsPlotClass.php
... ... @@ -1223,6 +1223,11 @@ class IHMInputOutputParamsPlotClass extends IHMInputOutputParamsAbstractClass
1223 1223 {
1224 1224 case 'zoom' :
1225 1225 return $this->unmarshallZoom($input, $plotInput);
  1226 + case 'forward' :
  1227 + case 'halfforward' :
  1228 + case 'backward' :
  1229 + case 'halfbackward' :
  1230 + return $this->unmarshallNavigation($input, $plotInput);
1226 1231 default :
1227 1232 throw new Exception('Interactive action not implemented.');
1228 1233 }
... ... @@ -1307,5 +1312,92 @@ class IHMInputOutputParamsPlotClass extends IHMInputOutputParamsAbstractClass
1307 1312 }
1308 1313 throw new Exception('Cannot retrieve plot tab for zoom action.');
1309 1314 }
  1315 +
  1316 + private function unmarshallNavigation($input, $plotInput)
  1317 + {
  1318 + //Find current tab
  1319 + $crtTab = NULL;
  1320 + foreach ($plotInput->{'tabs'} as $tab)
  1321 + {
  1322 + if ($input->{'tabId'} == PLOT_RESULT_FILE_KEY."_".$tab->{'id'})
  1323 + {
  1324 + $crtTab = $tab;
  1325 + break;
  1326 + }
  1327 + }
  1328 +
  1329 + if (!$crtTab)
  1330 + throw new Exception('Cannot retrieve plot tab for navigation action.');
  1331 +
  1332 + if ($crtTab->{'multi-plot-linked'})
  1333 + {
  1334 + $startTime = $plotInput->{'startDate'};
  1335 + $stopTime = $plotInput->{'stopDate'};
  1336 + }
  1337 + else
  1338 + {
  1339 + $startTime = $crtTab->{'startDate'};
  1340 + $stopTime = $crtTab->{'stopDate'};
  1341 + }
  1342 +
  1343 + //Compute new start / stop time
  1344 + date_default_timezone_set('UTC');
  1345 + $startTimeStamp = strtotime($startTime);
  1346 + $stopTimeStamp = strtotime($stopTime);
  1347 + $duration = $stopTimeStamp - $startTimeStamp;
  1348 +
  1349 + switch ($input->{'action'})
  1350 + {
  1351 + case 'forward' :
  1352 + $startTimeStamp += $duration;
  1353 + $stopTimeStamp += $duration;
  1354 + break;
  1355 + case 'halfforward' :
  1356 + $startTimeStamp += ($duration/2);
  1357 + $stopTimeStamp += ($duration/2);
  1358 + break;
  1359 + case 'backward' :
  1360 + $startTimeStamp -= $duration;
  1361 + $stopTimeStamp -= $duration;
  1362 + break;
  1363 + case 'halfbackward' :
  1364 + $startTimeStamp -= ($duration/2);
  1365 + $stopTimeStamp -= ($duration/2);
  1366 + break;
  1367 + }
  1368 +
  1369 + $startTime = date("Y-m-d\TH:i:s",$startTimeStamp);
  1370 + $stopTime = date("Y-m-d\TH:i:s",$stopTimeStamp);
  1371 +
  1372 + //Update request
  1373 + if ($crtTab->{'multi-plot-linked'})
  1374 + {
  1375 + $plotInput->{'startDate'} = $startTime;
  1376 + $plotInput->{'stopDate'} = $stopTime;
  1377 +
  1378 + $interactiveInput = clone $plotInput;
  1379 + $interactiveInput->{'tabs'} = array();
  1380 + //Execute only tabs linked to the multi plot mode
  1381 + foreach ($plotInput->{'tabs'} as $tab)
  1382 + {
  1383 + if ($tab->{'multi-plot-linked'})
  1384 + $interactiveInput->{'tabs'}[] = $tab;
  1385 + }
  1386 + $this->saveIHMRequest($plotInput);
  1387 + return $interactiveInput;
  1388 + }
  1389 + else
  1390 + {
  1391 + $crtTab->{'startDate'} = $startTime;
  1392 + $crtTab->{'stopDate'} = $stopTime;
  1393 +
  1394 + $interactiveInput = clone $plotInput;
  1395 + $interactiveInput->{'tabs'} = array();
  1396 + //Execute only concerning plot tabs
  1397 + $interactiveInput->{'tabs'}[] = $crtTab;
  1398 + $this->saveIHMRequest($plotInput);
  1399 + return $interactiveInput;
  1400 + }
  1401 + }
1310 1402 }
1311 1403 ?>
1312 1404 \ No newline at end of file
... ...