Commit 83c8df630915389b1c452d29dc966f5fc7386328

Authored by elena
2 parents ecdabbec eebc2bb6

merge branch with plot'master' of https://gitlab.irap.omp.eu/CDPP/AMDA_Integration

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