Blame view

src/InputOutput/IHMImpl/Params/PlotImpl/IHMInputOutputParamsPlotClass.php 65 KB
26a23052   Benjamin Renard   Add Interval Tick...
1
2
3
4
5
6
7
8
9
10
11
12
13
<?php

define ("PLOT_RESULT_FILE_KEY","plot");

/**
 * @class IHMInputOutputParamsPlotClass
 * @brief Implementation of IHMInputOutputParamsAbstractClass to treat plot request
 * @details
*/
class IHMInputOutputParamsPlotClass extends IHMInputOutputParamsAbstractClass
{
	private $isInteractiveRequest = false;
	
02abc780   Benjamin Renard   Support request f...
14
15
	private $isFromWS = false;
	
40624062   Elena.Budnik   no total_2D if in...
16
17
	private $isInstantPlot = false;
	
26a23052   Benjamin Renard   Add Interval Tick...
18
19
	private $interactiveTimeSelectionState = array();
	private $interactiveCrtTTFileIndex = -1;
05da1b4d   Benjamin Renard   Draw instant plot...
20
	private $interactivePreview = false;
26a23052   Benjamin Renard   Add Interval Tick...
21
22
23
24
25
26
	
	/*
	 * @brief method to unmarshall a plot request
	*/
	protected function unmarshallRequest($input)
	{
97a69b20   Benjamin Renard   Fix most of error...
27
		$forceTimeZoomReset = false;
d3c3608d   Benjamin Renard   Add undo zoom
28
		
26a23052   Benjamin Renard   Add Interval Tick...
29
		if (isset($input->{'action'}))
d3c3608d   Benjamin Renard   Add undo zoom
30
		{
26a23052   Benjamin Renard   Add Interval Tick...
31
			$input = $this->unmarshallActionRequest($input);
d3c3608d   Benjamin Renard   Add undo zoom
32
33
			$forceTimeZoomReset = isset($input->{'force-time-zoom-reset'}) ? $input->{'force-time-zoom-reset'} : false;
		}
26a23052   Benjamin Renard   Add Interval Tick...
34
		else
d3c3608d   Benjamin Renard   Add undo zoom
35
36
		{
			$resetZoom = true;
26a23052   Benjamin Renard   Add Interval Tick...
37
38
			//save request
			$this->saveIHMRequest($input);
d3c3608d   Benjamin Renard   Add undo zoom
39
40
		}
			
26a23052   Benjamin Renard   Add Interval Tick...
41
		//Request
26a23052   Benjamin Renard   Add Interval Tick...
42
		$this->isInteractiveRequest = ($input->{'file-output'} == 'INTERACTIVE');
02abc780   Benjamin Renard   Support request f...
43
		$this->isFromWS = ($input->{'file-output'} == 'WS');
26a23052   Benjamin Renard   Add Interval Tick...
44
		$postProcessCmd = "";
7d84634e   Benjamin Renard   Fix plot request ...
45
46
47

		if ($forceTimeZoomReset)
			$this->resetZoomListForTab($input->{'id'}, $forceTimeZoomReset);
26a23052   Benjamin Renard   Add Interval Tick...
48
			
7d84634e   Benjamin Renard   Fix plot request ...
49
50
51
		$requestNode = $this->paramsData->addRequestNode();
		$outputsNode = $requestNode->getOutputsNode();
		$paramsNode  = $requestNode->getParamsNode();
26a23052   Benjamin Renard   Add Interval Tick...
52
			
7d84634e   Benjamin Renard   Fix plot request ...
53
54
55
56
57
58
59
60
61
62
		//unmarshall time definition
		$isIntervalRequest = ($input->timesrc == 'Interval');
		$ttFileIndex = -1;
		$ttIntIndex  = -1;
		if ($this->isInteractiveRequest && !$isIntervalRequest && !$input->{'page-superpose-mode'})
		{
			$ttFileIndex = !isset($input->{'ttFileIndex'}) ? 0 : $input->{'ttFileIndex'};
			$ttIntIndex = !isset($input->{'intIndex'}) ? 0 : $input->{'intIndex'};
		}
		$this->unmarshallTimeDefinition($input, 0, $ttFileIndex, $ttIntIndex);
26a23052   Benjamin Renard   Add Interval Tick...
63
			
7d84634e   Benjamin Renard   Fix plot request ...
64
		$this->interactiveCrtTTFileIndex = $ttFileIndex;
26a23052   Benjamin Renard   Add Interval Tick...
65
			
7d84634e   Benjamin Renard   Fix plot request ...
66
		$plotOutputNode = $outputsNode->addNewOutput(RequestOutputTypeEnum::PLOT);
26a23052   Benjamin Renard   Add Interval Tick...
67
			
7d84634e   Benjamin Renard   Fix plot request ...
68
		$plotOutputNode->setWriteContextFile($this->isInteractiveRequest ? "true" : "false");
26a23052   Benjamin Renard   Add Interval Tick...
69
			
7d84634e   Benjamin Renard   Fix plot request ...
70
71
72
73
		$compression = "";
		if (!$this->isInteractiveRequest && !$this->isFromWS)
		{
			switch ($input->{'file-output'})
26a23052   Benjamin Renard   Add Interval Tick...
74
			{
7d84634e   Benjamin Renard   Fix plot request ...
75
76
77
78
79
80
81
82
83
84
85
				case 'TGZ' :
					$plotOutputNode->addPostProcessing(RequestOutputPostProcessingEnumClass::TAR);
					$plotOutputNode->addPostProcessing(RequestOutputPostProcessingEnumClass::GZIP);
					$compression = ".tar.gz";
					break;
				case 'ZIP' :
					$plotOutputNode->addPostProcessing(RequestOutputPostProcessingEnumClass::ZIP);
					$compression = ".zip";
					break;
				default:
					throw new Exception('Compression not implemented.');
26a23052   Benjamin Renard   Add Interval Tick...
86
			}
7d84634e   Benjamin Renard   Fix plot request ...
87
		}
26a23052   Benjamin Renard   Add Interval Tick...
88
			
7d84634e   Benjamin Renard   Fix plot request ...
89
90
91
92
		if ($input->{'one-file-per-interval'})
			$plotOutputNode->setStructure(RequestOutputPlotStructureEnum::ONE_FILE_PER_INTERVAL);
		else
			$plotOutputNode->setStructure(RequestOutputPlotStructureEnum::ONE_FILE);
26a23052   Benjamin Renard   Add Interval Tick...
93
			
7d84634e   Benjamin Renard   Fix plot request ...
94
95
96
97
98
		//prefix
		$filePrefix = "plot_";
		if ($input->{'file-prefix'} && ($input->{'file-prefix'} != ""))
			$filePrefix = $input->{'file-prefix'};
		$filePrefix .= $input->{'id'};
26a23052   Benjamin Renard   Add Interval Tick...
99
			
7d84634e   Benjamin Renard   Fix plot request ...
100
		$plotOutputNode->setFilePrefix($filePrefix);
26a23052   Benjamin Renard   Add Interval Tick...
101
			
7d84634e   Benjamin Renard   Fix plot request ...
102
103
		//page
		$pageNode = $plotOutputNode->getPage();
26a23052   Benjamin Renard   Add Interval Tick...
104
			
7d84634e   Benjamin Renard   Fix plot request ...
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
		$fileFormat = RequestOutputPlotPageFormatEnum::PNG;
		$extension = ".png";
		switch ($input->{'file-format'})
		{
			case 'PNG' :
				$fileFormat = RequestOutputPlotPageFormatEnum::PNG;
				$extension = ".png";
				break;
			case 'PDF' :
				$fileFormat = RequestOutputPlotPageFormatEnum::PDF;
				$extension = ".pdf";
				break;
			case 'PS' :
				$fileFormat = RequestOutputPlotPageFormatEnum::PS;
				$extension = ".ps";
				break;
			case 'SVG' :
				$fileFormat = RequestOutputPlotPageFormatEnum::SVG;
				$extension = ".svg";
				break;
			default:
				throw new Exception('File format not implemented.');
		}
26a23052   Benjamin Renard   Add Interval Tick...
128
			
7d84634e   Benjamin Renard   Fix plot request ...
129
		$pageNode->setFormat($fileFormat);
26a23052   Benjamin Renard   Add Interval Tick...
130
			
7d84634e   Benjamin Renard   Fix plot request ...
131
		$this->unmarshallTitle($input, 'page-title', $pageNode->getTitle());
26a23052   Benjamin Renard   Add Interval Tick...
132
			
7d84634e   Benjamin Renard   Fix plot request ...
133
134
135
136
137
138
139
140
141
142
143
		$isPortrait = false;
		switch ($input->{'page-orientation'})
		{
			case 'landscape' :
				$pageNode->setOrientation(RequestOutputPlotPageOrientationEnum::LANDSCAPE);
				break;
			case 'portrait' :
				$pageNode->setOrientation(RequestOutputPlotPageOrientationEnum::PORTRAIT);
				$isPortrait = true;
				break;
		}
26a23052   Benjamin Renard   Add Interval Tick...
144
			
7d84634e   Benjamin Renard   Fix plot request ...
145
146
147
148
149
150
151
152
153
154
155
		switch ($input->{'page-dimension'})
		{
			case 'ISO A4' :
				$pageNode->setDimension(RequestOutputPlotPageDimensionEnum::ISO_A4);
				break;
			case 'US letter' :
				$pageNode->setDimension(RequestOutputPlotPageDimensionEnum::US_LETTER);
				break;
			default:
				throw new Exception('Page dimension not implemented.');
		}
26a23052   Benjamin Renard   Add Interval Tick...
156
			
7d84634e   Benjamin Renard   Fix plot request ...
157
158
		switch ($input->{'page-mode'})
		{
05da1b4d   Benjamin Renard   Draw instant plot...
159
				
7d84634e   Benjamin Renard   Fix plot request ...
160
161
162
163
164
165
166
167
			case 'grayscale' :
				$pageNode->setMode(RequestOutputPlotPageModeEnum::GRAYSCALE);
				break;
			case 'color' :
			default:
				$pageNode->setMode(RequestOutputPlotPageModeEnum::COLOR);
				break;
		}
26a23052   Benjamin Renard   Add Interval Tick...
168
			
7d84634e   Benjamin Renard   Fix plot request ...
169
170
171
172
173
		if ($input->{'page-margins-activated'})
		{
			$pageNode->getMargins()->setHorizontal($input->{'page-margin-x'});
			$pageNode->getMargins()->setVertical($input->{'page-margin-y'});
		}
26a23052   Benjamin Renard   Add Interval Tick...
174
			
7d84634e   Benjamin Renard   Fix plot request ...
175
176
		if ($input->{'page-font-activated'})
			$this->unmarshallFont($input, 'page-font', $pageNode->getFont());
26a23052   Benjamin Renard   Add Interval Tick...
177
			
7d84634e   Benjamin Renard   Fix plot request ...
178
179
		//Superpose mode
		$pageNode->setSuperposeMode($input->{'page-superpose-mode'} ? "true": "false");
26a23052   Benjamin Renard   Add Interval Tick...
180
			
7d84634e   Benjamin Renard   Fix plot request ...
181
182
		//Layout
		$this->unmarshallLayout($input, $pageNode);
26a23052   Benjamin Renard   Add Interval Tick...
183
			
7d84634e   Benjamin Renard   Fix plot request ...
184
185
		foreach ($input->{'panels'} as $panelData)
			$this->unmarshallPanel($panelData, $pageNode, $paramsNode);
26a23052   Benjamin Renard   Add Interval Tick...
186
			
7d84634e   Benjamin Renard   Fix plot request ...
187
188
189
190
191
192
193
194
195
196
		if ($this->isInteractiveRequest || $this->isFromWS)
		{
			$resultFile = $filePrefix."_*".$extension;
			$waitingResultFile = $filePrefix.$extension;
		}
		else
		{
			$resultFile = $filePrefix."_*".$compression;
			$waitingResultFile = $filePrefix.$compression;
		}
26a23052   Benjamin Renard   Add Interval Tick...
197
			
7d84634e   Benjamin Renard   Fix plot request ...
198
199
200
201
202
203
204
205
		if ($this->isInteractiveRequest)
		{
			$this->interactiveTimeSelectionState[PLOT_RESULT_FILE_KEY."_".$input->{'id'}] = $isIntervalRequest;
			$this->interactivePreview = isset($input->{'interactive-preview'}) && ($input->{'interactive-preview'});
			$this->paramsData->addWaitingResult(PLOT_RESULT_FILE_KEY."_".$input->{'id'}, $waitingResultFile);
		}
		else
			$this->paramsData->addWaitingResult(PLOT_RESULT_FILE_KEY, $waitingResultFile);
26a23052   Benjamin Renard   Add Interval Tick...
206
			
7d84634e   Benjamin Renard   Fix plot request ...
207
208
209
210
		//Remove old result files
		foreach (glob($this->paramsData->getWorkingPath().$resultFile) as $oldFile) {
			unlink($oldFile);
		}
26a23052   Benjamin Renard   Add Interval Tick...
211
			
7d84634e   Benjamin Renard   Fix plot request ...
212
213
214
215
		//Post process command to apply to the result file
		if ($postProcessCmd != "")
			$postProcessCmd .= " | ";
		$postProcessCmd .= "mv ".$resultFile." ".$waitingResultFile;
26a23052   Benjamin Renard   Add Interval Tick...
216
			
7d84634e   Benjamin Renard   Fix plot request ...
217
218
219
220
221
222
223
224
		if (($this->isInteractiveRequest) && $isPortrait)
			$postProcessCmd .= " | convert ".$waitingResultFile." -rotate -90 ".$waitingResultFile;
		else if ($this->isFromWS)
		{
			if ($isPortrait)
				$postProcessCmd .= " | convert ".$waitingResultFile." -rotate -90 ".$input->{"ws-result-file"};
			else
				$postProcessCmd .= " | mv ".$waitingResultFile." ".$input->{"ws-result-file"};
26a23052   Benjamin Renard   Add Interval Tick...
225
226
227
228
229
230
231
232
		}
		
		$this->paramsData->setBatchEnable(!(($fileFormat == RequestOutputPlotPageFormatEnum::PNG) && $this->isInteractiveRequest));
		$this->paramsData->setPostCmd($postProcessCmd);
		
		return $this->paramsData;
	}
	
7d84634e   Benjamin Renard   Fix plot request ...
233
	protected function unmarshallLayout($request, $pageNode)
26a23052   Benjamin Renard   Add Interval Tick...
234
	{
7d84634e   Benjamin Renard   Fix plot request ...
235
		switch ($request->{'page-layout-type'})
26a23052   Benjamin Renard   Add Interval Tick...
236
237
238
		{
			case 'vertical' :
				$pageNode->getLayout()->setType(RequestOutputPlotLayoutTypeEnum::VERTICAL);
7d84634e   Benjamin Renard   Fix plot request ...
239
240
241
242
243
244
245
246
247
248
249
250
				$pageNode->getLayout()->setPanelHeight($request->{'page-layout-object'}->{'layout-panel-height'});
				$pageNode->getLayout()->setPanelSpacing($request->{'page-layout-object'}->{'layout-panel-spacing'});
				$pageNode->getLayout()->setExpand($request->{'page-layout-object'}->{'layout-expand'} ? "true" : "false");
				$pageNode->getLayout()->setOnlyLowerTimeAxesLegend($request->{'page-layout-object'}->{'layout-timeaxes-legend-lowerone'} ? "true" : "false");
				//if ($request->{'page-layout-object'}->{'layout-timeplot-width'} > 0)
				//	$pageNode->setDefaultTimePlotWidth($request->{'page-layout-object'}->{'layout-timeplot-width'});
				if ($request->{'page-layout-object'}->{'layout-timeplot-height'} > 0)
					$pageNode->setDefaultTimePlotHeight($request->{'page-layout-object'}->{'layout-timeplot-height'});
				if ($request->{'page-layout-object'}->{'layout-xyplot-width'} > 0)
					$pageNode->setDefaultXYPlotWidth($request->{'page-layout-object'}->{'layout-xyplot-width'});
				if ($request->{'page-layout-object'}->{'layout-xyplot-height'} > 0)
					$pageNode->setDefaultXYPlotHeight($request->{'page-layout-object'}->{'layout-xyplot-height'});
26a23052   Benjamin Renard   Add Interval Tick...
251
252
253
				break;
			case 'auto' :
				$pageNode->getLayout()->setType(RequestOutputPlotLayoutTypeEnum::AUTO);
7d84634e   Benjamin Renard   Fix plot request ...
254
255
256
257
				$pageNode->getLayout()->setPanelHeight($request->{'page-layout-object'}->{'layout-panel-height'});
				$pageNode->getLayout()->setPanelSpacing($request->{'page-layout-object'}->{'layout-panel-spacing'});
				$pageNode->getLayout()->setExpand($request->{'page-layout-object'}->{'layout-expand'} ? "true" : "false");
				$pageNode->getLayout()->setOnlyLowerTimeAxesLegend($request->{'page-layout-object'}->{'layout-timeaxes-legend-lowerone'} ? "true" : "false");
26a23052   Benjamin Renard   Add Interval Tick...
258
259
260
				break;
			case 'manual' :
				$pageNode->getLayout()->setType(RequestOutputPlotLayoutTypeEnum::MANUAL);
7d84634e   Benjamin Renard   Fix plot request ...
261
262
				$timePlotLeftMargin = $request->{'page-layout-object'}->{'layout-timeplot-margin-left'} ? $request->{'page-layout-object'}->{'layout-timeplot-margin-left'} : -1;
				$timePlotRightMargin = $request->{'page-layout-object'}->{'layout-timeplot-margin-right'} ? $request->{'page-layout-object'}->{'layout-timeplot-margin-right'} : -1;
26a23052   Benjamin Renard   Add Interval Tick...
263
				$pageNode->setDefaultTimePlotXMargin($timePlotLeftMargin, $timePlotRightMargin);
7d84634e   Benjamin Renard   Fix plot request ...
264
265
				$xyPlotLeftMargin = $request->{'page-layout-object'}->{'layout-xyplot-margin-left'} ? $request->{'page-layout-object'}->{'layout-xyplot-margin-left'} : -1;
				$xyPlotRightMargin = $request->{'page-layout-object'}->{'layout-xyplot-margin-right'} ? $request->{'page-layout-object'}->{'layout-xyplot-margin-right'} : -1;
26a23052   Benjamin Renard   Add Interval Tick...
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
				$pageNode->setDefaultXYPlotXMargin($xyPlotLeftMargin, $xyPlotRightMargin);
				break;
			default:
				throw new Exception('Layout type not implemented.');
		}
		
	}
		
	protected function unmarshallPanel($panelData, $pageNode, $paramsNode)
	{
		$panelNode = $pageNode->addPanel();
		
		
		switch ($pageNode->getLayout()->getType())
		{
			case RequestOutputPlotLayoutTypeEnum::MANUAL :
				//Panel bounds
				$panelNode->getBounds()->setX($panelData->{'panel-bounds-x'});
				$panelNode->getBounds()->setY($panelData->{'panel-bounds-y'});
				$panelNode->getBounds()->setWidth($panelData->{'panel-bounds-width'});
				$panelNode->getBounds()->setHeight($panelData->{'panel-bounds-height'});
				//Panel margins
				$leftMargin = $panelData->{'panel-margin-left'} ? $panelData->{'panel-margin-left'} : -1;
				$rightMargin = $panelData->{'panel-margin-right'} ? $panelData->{'panel-margin-right'} : -1;
				$panelNode->setXMargin($leftMargin, $rightMargin);
				break;
			case RequestOutputPlotLayoutTypeEnum::VERTICAL :
				//Panel prefered dimensions
				if ($panelData->{'panel-prefered-width'} > 0)
					$panelNode->setPreferedWidth($panelData->{'panel-prefered-width'});
				if ($panelData->{'panel-prefered-height'} > 0)
					$panelNode->setPreferedHeight($panelData->{'panel-prefered-height'});
				break;
			default :
				//Nothing to do
		}
		
		//Panel id
02abc780   Benjamin Renard   Support request f...
304
305
		if (isset($panelData->{'id'}))
			$panelNode->setId($panelData->{'id'});
26a23052   Benjamin Renard   Add Interval Tick...
306
		
a88159f7   Benjamin Renard   Add panel index s...
307
308
309
		if (isset($panelData->{'panel-index'}))
			$panelNode->setIndex($panelData->{'panel-index'});
		
26a23052   Benjamin Renard   Add Interval Tick...
310
311
312
		//Panel background color
		if (($panelData->{'panel-background-color'} != 'none') && ($panelData->{'panel-background-color'} != ''))
			$panelNode->setBackgroundColor($this->hexColor2KernelColor($panelData->{'panel-background-color'}));
60a1a563   Benjamin Renard   Add the possibili...
313

26a23052   Benjamin Renard   Add Interval Tick...
314
315
316
317
318
319
320
		//Panel font
		$this->unmarshallFont($panelData, 'panel-font', $panelNode->getFont());
		
		//Panel title
		$this->unmarshallTitle($panelData, 'panel-title', $panelNode->getTitle());
		
		//Plot type
40624062   Elena.Budnik   no total_2D if in...
321
		$this->isInstantPlot = false;
26a23052   Benjamin Renard   Add Interval Tick...
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
		$plotNode = $this->unmarshallPlotType($panelData, $panelNode);
		
		$isTimePlot = ($plotNode->getName() == REQUESTOUTPUTPLOTELEMENTTIME_NAME);
		
		//Tick plot
		$tickPlotNode = NULL;
		if ($isTimePlot)
		{
			if ($this->hasTickBar($panelData->{'params'}))
			{
				$tickPlotNode = $panelNode->addPlotElement(RequestOutputPlotElementTypeEnum::TICKPLOT,true);
				if ($panelData->{'panel-tick-format'} != '')
					$tickPlotNode->setFormat($panelData->{'panel-tick-format'});
			}
		}
		
		//Status plot
		$statusPlotNode = NULL;
		if ($isTimePlot)
		{
			if ($this->hasStatusBar($panelData->{'params'}))
			{
				$statusPlotNode = $panelNode->addPlotElement(RequestOutputPlotElementTypeEnum::STATUSPLOT,true);
				switch ($panelData->{'panel-status-position'})
				{
					case 'top' :
						$statusPlotNode->setPosition(RequestOutputPlotElementStatusPosition::TOP);
						break;
					case 'bottom' :
						$statusPlotNode->setPosition(RequestOutputPlotElementStatusPosition::BOTTOM);
						break;
				}
				$statusPlotNode->setColorMap($panelData->{'panel-status-colormap'});
			}
		}
		
		//Axes
		foreach ($panelData->{'axes'} as $axisData)
			$this->unmarshallAxis($axisData, $panelData->{'constants'}, $plotNode);
		
		//Params
		$this->unmarshallParams($panelData->{'params'}, $paramsNode, $plotNode, $panelNode, $statusPlotNode, $tickPlotNode);
		
		//Additional objects
		if ($plotNode->getAdditionalObjects() != NULL)
			$this->unmarshallAdditionalObjects($panelData, $plotNode->getAdditionalObjects(), $isTimePlot);
		
		//Fills
		if ($plotNode->getFills() != NULL)
			$this->unmarshallFills($panelData, $plotNode->getFills());
		
		return $panelNode;
	}
	
	protected function unmarshallPlotType($panelData, $panelNode)
	{
		switch ($panelData->{'panel-plot-type'})
		{
			case 'timePlot' :
				$plotNode = $panelNode->addPlotElement(RequestOutputPlotElementTypeEnum::TIMEPLOT);
				break;
			case 'xyPlot' :
				$plotNode = $panelNode->addPlotElement(RequestOutputPlotElementTypeEnum::XYPLOT);
				$plotNode->setIsIsotropic($panelData->{'panel-scatter-isotropic'});
				break;
			case 'statusPlot' :
				$plotNode = $panelNode->addPlotElement(RequestOutputPlotElementTypeEnum::STATUSPLOT);
				switch ($panelData->{'panel-status-position'})
				{
					case 'top' :
						$plotNode->setPosition(RequestOutputPlotElementStatusPosition::TOP);
						break;
					case 'bottom' :
						$plotNode->setPosition(RequestOutputPlotElementStatusPosition::BOTTOM);
						break;
				}
				$plotNode->setColorMap($panelData->{'panel-status-colormap'});
				break;
			case 'tickPlot' :
				$plotNode = $panelNode->addPlotElement(RequestOutputPlotElementTypeEnum::TICKPLOT);
				if ($panelData->{'panel-tick-format'} != '')
					$plotNode->setFormat($panelData->{'panel-tick-format'});
				break;
			case 'epochPlot' :
				$plotNode = $panelNode->addPlotElement(RequestOutputPlotElementTypeEnum::EPOCHPLOT);
d6bf6ef5   Benjamin Renard   Get the possibili...
407
408
				if ($panelData->{'panel-epoch-centertimeid'} != '')
					$plotNode->setCenterTimeId($panelData->{'panel-epoch-centertimeid'});
26a23052   Benjamin Renard   Add Interval Tick...
409
410
411
412
413
414
415
				break;
			case 'instantPlot' :
				$plotNode = $panelNode->addPlotElement(RequestOutputPlotElementTypeEnum::INSTANTPLOT);
				date_default_timezone_set('UTC');
				$timeStamp = strtotime($panelData->{'panel-instant-time'});
				$time = CommonClass::timeStampToDDTime($timeStamp);
				$plotNode->setTime($time);
40624062   Elena.Budnik   no total_2D if in...
416
				$this->isInstantPlot = true;
26a23052   Benjamin Renard   Add Interval Tick...
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
				break;
			default:
				throw new Exception('Plot type not implemented.');
		}
		
		//Params Legend
		if (isset($panelData->{'panel-series-legend'}) && $panelData->{'panel-series-legend'}->{'legend-series-activated'})
			$this->unmarshallParamsLegend($panelData->{'panel-series-legend'}, $plotNode->getLegends()->getParamsLegend());
		
		//Text Legends
		foreach ($panelData->{'text-legends'} as $textLegendData)
			$this->unmarshallTextLegend($textLegendData, $plotNode->getLegends());
		
		return $plotNode;
	}
	
	protected function unmarshallAxis($axisData, $constantsData, $plotNode)
	{
		//axis type
		$constantAxisId = '';
		switch ($axisData->{'axis-type'})
		{
			case 'time' :
				$axisNode = $plotNode->getTimeAxis();
				$axisNode->setFormat($axisData->{'axis-time-format'});
				$constantAxisId = 'x';
				break;
			case 'epoch' :
				$axisNode = $plotNode->getEpochAxis();
				$axisNode->setNormalized($axisData->{'axis-epoch-normalized'} ? "true" : "false");
				$constantAxisId = 'x';
				break;
			case 'x' :
				$axisNode = $plotNode->getXAxis();
				$constantAxisId = 'x';
				break;
			case 'y-left' :
				$axisNode = $plotNode->addYAxis('y-left');
				$constantAxisId = 'y-left';
				break;
			case 'y-right' :
				$axisNode = $plotNode->addYAxis('y-right');
				$axisNode->setPosition(RequestOutputPlotAxisElementPosition::RIGHT);
				$constantAxisId = 'y-right';
				break;
			case 'color' :
				$axisNode = $plotNode->getZAxis();
				$axisNode->setColorMapIndex($axisData->{'axis-color-map'});
				if ($axisData->{'axis-color-minval'} != 'none')
					$axisNode->setMinValColor($this->hexColor2KernelColor($axisData->{'axis-color-minval'}));
				if ($axisData->{'axis-color-maxval'} != 'none')
					$axisNode->setMaxValColor($this->hexColor2KernelColor($axisData->{'axis-color-maxval'}));
				break;
			default:
				throw new Exception('Axis type not implemented.');
		}
		
		//reverse axis
05da1b4d   Benjamin Renard   Draw instant plot...
475
476
		if (isset($axisData->{'axis-reverse'}))
			$axisNode->setReverse($axisData->{'axis-reverse'} ? "true" : "false");
26a23052   Benjamin Renard   Add Interval Tick...
477
478
479
480
481
482
483
484
485
486
487
488
489
490
		
		//axis scale
		switch ($axisData->{'axis-scale'})
		{
			case 'logarithmic' :
				$axisNode->setScale(RequestOutputPlotAxisElementScale::LOGARITHMIC);
				break;
			default:
				$axisNode->setScale(RequestOutputPlotAxisElementScale::LINEAR);
		}
		
		//axis range
		if ($axisData->{'axis-range-min'} < $axisData->{'axis-range-max'})
			$axisNode->getRange()->setMinMax($axisData->{'axis-range-min'}, $axisData->{'axis-range-max'});
05da1b4d   Benjamin Renard   Draw instant plot...
491
492
		if (isset($axisData->{'axis-range-extend'}))
			$axisNode->getRange()->setExtend($axisData->{'axis-range-extend'} ? "true" : "false");
26a23052   Benjamin Renard   Add Interval Tick...
493
494
		
		//axis color
02abc780   Benjamin Renard   Support request f...
495
496
		if (isset($axisData->{'axis-color'}))
			$axisNode->setColor($this->hexColor2KernelColor($axisData->{'axis-color'}));
26a23052   Benjamin Renard   Add Interval Tick...
497
498
		
		//axis thickness
02abc780   Benjamin Renard   Support request f...
499
500
		if (isset($axisData->{'axis-thickness'}))
			$axisNode->setThickness($axisData->{'axis-thickness'});
26a23052   Benjamin Renard   Add Interval Tick...
501
502
503
504
505
506
507
508
509
510
511
512
		
		//axis ticks position
		switch ($axisData->{'axis-tick-position'})
		{
			case 'inwards' :
				$axisNode->getTick()->setPosition(RequestOutputPlotAxisElementTickPosition::INWARDS);
				break;
			default :
				$axisNode->getTick()->setPosition(RequestOutputPlotAxisElementTickPosition::OUTWARDS);
		}
		
		//axis minor and major grid
05da1b4d   Benjamin Renard   Draw instant plot...
513
514
		if (isset($axisData->{'axis-grid-minor'}))
			$axisNode->getTick()->setMinorGrid($axisData->{'axis-grid-minor'} ? "true" : "false");
3741e4bb   Hacene SI HADJ MOHAND   6954 ok
515

05da1b4d   Benjamin Renard   Draw instant plot...
516
517
		if (isset($axisData->{'axis-grid-major'}))
			$axisNode->getTick()->setMajorGrid($axisData->{'axis-grid-major'} ? "true" : "false");
6e8d82dc   Hacene SI HADJ MOHAND   us Ok
518
519
520
                if ( $axisData->{'axis-grid-specify-ticks-number'}){
                  
                   if (isset($axisData->{'axis-grid-minor-number'}) && $axisData->{'axis-grid-minor-number'} != 0)
3741e4bb   Hacene SI HADJ MOHAND   6954 ok
521
522
                        $axisNode->getTick()->setMinorGridNumber($axisData->{'axis-grid-minor-number'});
	
6e8d82dc   Hacene SI HADJ MOHAND   us Ok
523
		   if (isset($axisData->{'axis-grid-major-number'}) && $axisData->{'axis-grid-major-number'} != 0)
3741e4bb   Hacene SI HADJ MOHAND   6954 ok
524
                        $axisNode->getTick()->setMajorGridNumber($axisData->{'axis-grid-major-number'});
6e8d82dc   Hacene SI HADJ MOHAND   us Ok
525
                }elseif($axisData->{'axis-grid-specify-ticks-spacing'}){
3741e4bb   Hacene SI HADJ MOHAND   6954 ok
526

6e8d82dc   Hacene SI HADJ MOHAND   us Ok
527
		   if (isset($axisData->{'axis-grid-major-space'}) && $axisData->{'axis-grid-major-space'} != 0)
3741e4bb   Hacene SI HADJ MOHAND   6954 ok
528
529
                        $axisNode->getTick()->setMajorGridSpace($axisData->{'axis-grid-major-space'});
               
6e8d82dc   Hacene SI HADJ MOHAND   us Ok
530
                   if (isset($axisData->{'axis-grid-minor-space'}) && $axisData->{'axis-grid-minor-space'} != 0)
3741e4bb   Hacene SI HADJ MOHAND   6954 ok
531
                        $axisNode->getTick()->setMinorGridSpace($axisData->{'axis-grid-minor-space'});
6e8d82dc   Hacene SI HADJ MOHAND   us Ok
532
                }
3741e4bb   Hacene SI HADJ MOHAND   6954 ok
533
534
535


                //legend
05da1b4d   Benjamin Renard   Draw instant plot...
536
537
		if (isset($axisData->{'axis-legend-text'}) && $axisData->{'axis-legend-text'} != '')
		{
26a23052   Benjamin Renard   Add Interval Tick...
538
			$axisNode->getLegend()->setText($axisData->{'axis-legend-text'});
05da1b4d   Benjamin Renard   Draw instant plot...
539
540
541
			$axisNode->getLegend()->setColor($this->hexColor2KernelColor($axisData->{'axis-legend-color'}));
			$this->unmarshallLabel($axisData, "axis-legend", $axisNode->getLegend());
		}
26a23052   Benjamin Renard   Add Interval Tick...
542
543
		
		//Show legend
05da1b4d   Benjamin Renard   Draw instant plot...
544
545
		if (isset($axisData->{'axis-legend-activated'}))
			$axisNode->setShowLegend($axisData->{'axis-legend-activated'} ? "true" : "false");
26a23052   Benjamin Renard   Add Interval Tick...
546
547
		
		//Show tick marks
05da1b4d   Benjamin Renard   Draw instant plot...
548
549
		if (isset($axisData->{'axis-tick-showmarks'}))
			$axisNode->setShowTickMarks($axisData->{'axis-tick-showmarks'} ? "true" : "false");
26a23052   Benjamin Renard   Add Interval Tick...
550
551
552
553
554
555
556
557
558
559
560
561
562
563
		
		//Add constants
		if ($constantAxisId != '')
		{
			foreach ($constantsData as $constantData)
				if ($constantData->{'constant-axis-id'} == $constantAxisId)
					$this->unmarshallConstant($constantData,$axisNode);
		}
	}
	
	protected function unmarshallParams($paramsData, $requestParamsNode, $plotNode, $panelNode, $statusPlotNode, $tickPlotNode)
	{
		//X parameters
		$isScatter = ($plotNode->getName() == REQUESTOUTPUTPLOTELEMENTXY_NAME);
f822811a   Benjamin Renard   Implements multi ...
564
		$xIds = array();
26a23052   Benjamin Renard   Add Interval Tick...
565
566
		if ($isScatter)
		{
f822811a   Benjamin Renard   Implements multi ...
567
			$crtXId = 0;
26a23052   Benjamin Renard   Add Interval Tick...
568
569
570
571
			foreach ($paramsData as $paramData)
			{
				if ($paramData->{'param-drawing-object'}->{'serie-xaxis-param'} == '')
					continue;
f822811a   Benjamin Renard   Implements multi ...
572
573
574
575
				if (array_key_exists($paramData->{'param-drawing-object'}->{'serie-xaxis-param'}, $xIds)) {
					//x param already exists
					continue;
				}
26a23052   Benjamin Renard   Add Interval Tick...
576
				
bf27ba04   Benjamin Renard   Add templated par...
577
				$paramXInfo = $this->paramManager->addExistingParam($paramData->{'param-drawing-object'}->{'serie-xaxis-param'}, $this->paramsData);
26a23052   Benjamin Renard   Add Interval Tick...
578
579
580
581
582
583
584
585
586
				if ($paramXInfo['id'] == '')
					throw new Exception('Cannot retrieve X parameter.');
				$requestParamsNode->addParam($paramXInfo['id']);
				$xParamNode = $plotNode->getParams()->getParamById($paramXInfo['id']);
				switch ($paramData->{'param-drawing-type'})
				{
					case 'serie' :
						//Unmarshall x serie
						if (count($paramXInfo['indexes']) == 0)
f822811a   Benjamin Renard   Implements multi ...
587
							$xParamNode->addXSerie(-1, $crtXId, $paramData->{'param-drawing-object'}->{'serie-xvalue-min'}, $paramData->{'param-drawing-object'}->{'serie-xvalue-max'});
26a23052   Benjamin Renard   Add Interval Tick...
588
						else if (count($paramXInfo['indexes']) == 1)
f822811a   Benjamin Renard   Implements multi ...
589
							$xParamNode->addXSerie($paramXInfo['indexes'][0], $crtXId, $paramData->{'param-drawing-object'}->{'serie-xvalue-min'}, $paramData->{'param-drawing-object'}->{'serie-xvalue-max'});
26a23052   Benjamin Renard   Add Interval Tick...
590
591
592
593
594
595
						else
							throw new Exception('X parameter for serie must be a component.');
						break;
					default :
						throw new Exception('X parameter not allowed for this drawing type. ');
				}
f822811a   Benjamin Renard   Implements multi ...
596
597
				$xIds[$paramData->{'param-drawing-object'}->{'serie-xaxis-param'}] = $crtXId;
				++$crtXId;
26a23052   Benjamin Renard   Add Interval Tick...
598
599
600
601
602
603
604
			}
		}
		
		//Main drawing element parameter
		$drawingEltIndex = 0;
		foreach ($paramsData as $paramData)
		{
52c1e291   Benjamin Renard   Generate TT and c...
605
606
			$isTTCat = ($paramData->{'param-type'} == 'ttcat');

26a23052   Benjamin Renard   Add Interval Tick...
607
			//Param
52c1e291   Benjamin Renard   Generate TT and c...
608
609
610
611
612
613
			if (!$isTTCat) {
				$paramInfo = $this->paramManager->addExistingParam($paramData->{'paramid'}, $this->paramsData, isset($paramData->{'template_args'}) ? $paramData->{'template_args'} : NULL);
			}
			else {
				$paramInfo = $this->paramManager->addTTCatParam($paramData->{'paramid'}, $this->paramsData);
			}
3182799a   Benjamin Renard   Use param indexes...
614
615
			
			$paramInfo['indexes'] = array();
93c50989   Benjamin Renard   Support Tab2D par...
616
617

			$this->paramManager->applyRangesAndIndexes($this->paramsData, $paramData, !$this->isInstantPlot, $paramInfo);
3182799a   Benjamin Renard   Use param indexes...
618
			
26a23052   Benjamin Renard   Add Interval Tick...
619
620
			$requestParamsNode->addParam($paramInfo['id']);
			
26a23052   Benjamin Renard   Add Interval Tick...
621
			$colorSerieId = -1;
8ade06fe   Benjamin Renard   Improve config load
622
			if (!empty($paramData->{'param-drawing-object'}->{'serie-colored-param'}))
26a23052   Benjamin Renard   Add Interval Tick...
623
624
				$colorSerieId = $drawingEltIndex;

f822811a   Benjamin Renard   Implements multi ...
625
626
			$xId = ($isScatter && !empty($paramData->{'param-drawing-object'}->{'serie-xaxis-param'})) ? $xIds[$paramData->{'param-drawing-object'}->{'serie-xaxis-param'}] : -1;
 
26a23052   Benjamin Renard   Add Interval Tick...
627
628
629
630
			switch ($paramData->{'param-drawing-type'})
			{
				case 'serie' :
					$paramNode = $plotNode->getParams()->getParamById($paramInfo['id']);
f822811a   Benjamin Renard   Implements multi ...
631
					$this->unmarshallSerie($paramData, $requestParamsNode, $plotNode, $paramNode, $paramInfo['indexes'], $xId, $colorSerieId, false);
26a23052   Benjamin Renard   Add Interval Tick...
632
633
634
					break;
				case 'orbit-serie' :
					$paramNode = $plotNode->getParams()->getParamById($paramInfo['id']);
f822811a   Benjamin Renard   Implements multi ...
635
					$this->unmarshallSerie($paramData, $requestParamsNode, $plotNode, $paramNode, -1, $xId, $colorSerieId, true);
26a23052   Benjamin Renard   Add Interval Tick...
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
					break;
				case 'spectro' :
					$paramNode = $plotNode->getParams()->getParamById($paramInfo['id']);
					$this->unmarshallSpectro($paramData->{'param-drawing-object'}, $plotNode, $paramNode, $paramInfo['indexes']);
					break;
				case 'status-bar' :
					if (($plotNode->getName() == REQUESTOUTPUTPLOTELEMENTSTATUS_NAME) && !isset($statusPlotNode))
						$paramNode = $plotNode->getParams()->getParamById($paramInfo['id']);
					else
						$paramNode = $statusPlotNode->getParams()->getParamById($paramInfo['id']);
					$this->unmarshallStatusBar($paramData->{'param-drawing-object'}, $paramNode, $paramInfo['indexes']);
					break;
				case 'tick-bar' :
					if (($plotNode->getName() == REQUESTOUTPUTPLOTELEMENTTICK_NAME) && !isset($tickPlotNode))
						$paramNode = $plotNode->getParams()->getParamById($paramInfo['id']);
					else
						$paramNode = $tickPlotNode->getParams()->getParamById($paramInfo['id']);
					
					$this->unmarshallTickBar($paramData->{'param-drawing-object'}, $paramNode, $paramInfo['indexes']);
					break;
				case 'iserie' :
					$paramNode = $plotNode->getParams()->getParamById($paramInfo['id']);
					$this->unmarshallInstantSerie($paramData->{'param-drawing-object'}, $plotNode, $paramNode);
					break;
fc153c1c   Elena.Budnik   ispectro added
660
661
662
				case 'ispectro' :
					$paramNode = $plotNode->getParams()->getParamById($paramInfo['id']);
					$this->unmarshallInstantSpectro($paramData->{'param-drawing-object'}, $plotNode, $paramNode, $paramInfo['indexes']);
044a9305   Benjamin Renard   Add intervals dra...
663
664
665
666
667
					break;
				case 'intervals' :
					$paramNode = $plotNode->getParams()->getParamById($paramInfo['id']);
					$this->unmarshallIntervals($paramData->{'param-drawing-object'}, $paramNode);
					break;
26a23052   Benjamin Renard   Add Interval Tick...
668
669
670
671
672
673
674
675
676
677
				default :
					throw new Exception('Drawing type not implemented.');
			}
			++$drawingEltIndex;
		}
		
		//Colored parameter
		$drawingEltIndex = 0;
		foreach ($paramsData as $paramData)
		{
8ade06fe   Benjamin Renard   Improve config load
678
			if (empty($paramData->{'param-drawing-object'}->{'serie-colored-param'}))
26a23052   Benjamin Renard   Add Interval Tick...
679
680
681
682
683
			{
				++$drawingEltIndex;
				continue;
			}
			
bf27ba04   Benjamin Renard   Add templated par...
684
			$paramColoredInfo = $this->paramManager->addExistingParam($paramData->{'param-drawing-object'}->{'serie-colored-param'}, $this->paramsData);
26a23052   Benjamin Renard   Add Interval Tick...
685
686
687
688
689
690
691
692
693
694
			if ($paramColoredInfo['id'] == '')
				throw new Exception('Cannot retrieve colored parameter.');
			$requestParamsNode->addParam($paramColoredInfo['id']);
			$coloredParamNode = $plotNode->getParams()->getParamById($paramColoredInfo['id']);
			
			$colorSerieId = $drawingEltIndex;
			
			switch ($paramData->{'param-drawing-type'})
			{
				case 'serie' :
516495e8   Benjamin Renard   Colored parameter...
695
				case 'orbit-serie' :
26a23052   Benjamin Renard   Add Interval Tick...
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
					//Unmarshall colored serie
					if (count($paramColoredInfo['indexes']) == 0)
						$coloredParamNode->addColorSerie($colorSerieId, -1);
					else if (count($paramColoredInfo['indexes']) == 1)
						$coloredParamNode->addColorSerie($colorSerieId, $paramColoredInfo['indexes'][0]);
					else
						throw new Exception('Colored parameter for serie must be a component.');
					break;
				default :
					throw new Exception('Colored parameter not allowed for this drawing type. ');
			}
			++$drawingEltIndex;
		}
	}
	
f822811a   Benjamin Renard   Implements multi ...
711
	protected function unmarshallSerie($paramData, $requestParamsNode, $plotNode, $paramNode, $indexes, $xId, $colorSerieId, $isOrbitSerie)
26a23052   Benjamin Renard   Add Interval Tick...
712
713
714
715
716
717
718
	{
		$serieNodes = array();
		
		if (!$isOrbitSerie)
		{
			if (count($indexes) == 0)
			{
f822811a   Benjamin Renard   Implements multi ...
719
				$serieNode = $paramNode->addYSerie($paramData->{'param-drawing-object'}->{'serie-yaxis'}, -1, $xId, $colorSerieId, $paramData->{'param-drawing-object'}->{'serie-value-min'}, $paramData->{'param-drawing-object'}->{'serie-value-max'});
26a23052   Benjamin Renard   Add Interval Tick...
720
				$serieNode->setId($paramData->{'id'});
60a1a563   Benjamin Renard   Add the possibili...
721
722
				if (!empty($paramData->{'param-drawing-object'}->{'serie-resolution'}))
					$serieNode->setResolution($paramData->{'param-drawing-object'}->{'serie-resolution'});
26a23052   Benjamin Renard   Add Interval Tick...
723
724
725
726
				$serieNodes[] = $serieNode;
			}
			foreach ($indexes as $index)
			{
f822811a   Benjamin Renard   Implements multi ...
727
				$serieNode = $paramNode->addYSerie($paramData->{'param-drawing-object'}->{'serie-yaxis'}, $index, $xId, $colorSerieId, $paramData->{'param-drawing-object'}->{'serie-value-min'}, $paramData->{'param-drawing-object'}->{'serie-value-max'});
26a23052   Benjamin Renard   Add Interval Tick...
728
729
				if (count($indexes) == 1)
					$serieNode->setId($paramData->{'id'});
60a1a563   Benjamin Renard   Add the possibili...
730
731
				if (!empty($paramData->{'param-drawing-object'}->{'serie-resolution'}))
					$serieNode->setResolution($paramData->{'param-drawing-object'}->{'serie-resolution'});
26a23052   Benjamin Renard   Add Interval Tick...
732
733
734
735
736
				$serieNodes[] = $serieNode;
			}
		}
		else
		{
cb46dfbf   Benjamin Renard   Fix orbit serie a...
737
			$orbitSerie = $paramNode->addOrbitSerie($paramData->{'param-drawing-object'}->{'serie-yaxis'}, $colorSerieId);
26a23052   Benjamin Renard   Add Interval Tick...
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
			$orbitSerie->setId($paramData->{'id'});
			$serieNodes[] = $orbitSerie;
		}
			
		foreach ($serieNodes as $serieNode)
		{
			if (!$isOrbitSerie)
			{
				//Resampling
				if ($plotNode->getName() == REQUESTOUTPUTPLOTELEMENTXY_NAME)
				{
					switch ($paramData->{'param-drawing-object'}->{'serie-resampling-mode'})
					{
						case 'yparam' :
							$serieNode->getResampling()->setType(RequestOutputPlotResamplingTypeEnum::YPARAM);
							break;
						case 'xparam' :
						default :
							$serieNode->getResampling()->setType(RequestOutputPlotResamplingTypeEnum::XPARAM);
					}
				}
			}
			else
			{
				//Projection
				switch ($paramData->{'param-drawing-object'}->{'serie-projection'})
				{
					case 'XY' :
						$serieNode->setProjection(RequestOutputPlotOrbitSerieProjectionEnum::XY);
						break;
					case 'XZ' :
						$serieNode->setProjection(RequestOutputPlotOrbitSerieProjectionEnum::XZ);
						break;
					case 'YZ' :
						$serieNode->setProjection(RequestOutputPlotOrbitSerieProjectionEnum::YZ);
						break;
					case 'XR' :
						$serieNode->setProjection(RequestOutputPlotOrbitSerieProjectionEnum::XR);
						break;
					case 'YR' :
						$serieNode->setProjection(RequestOutputPlotOrbitSerieProjectionEnum::YR);
						break;
					case 'ZR' :
						$serieNode->setProjection(RequestOutputPlotOrbitSerieProjectionEnum::ZR);
						break;
					default :
						throw new Exception('Projection not allowed for the orbit serie');
				}
			}
			
			//Line
			$this->unmarshallLine($paramData->{'param-drawing-object'}, 'serie', $serieNode->getLine(), $paramData->{'param-drawing-object'}->{"serie-lines-activated"} ? RequestOutputPlotLineTypeEnum::LINE : RequestOutputPlotLineTypeEnum::NO);
			//Symbol
			if (!$paramData->{'param-drawing-object'}->{"serie-symbols-activated"})
				$serieNode->getSymbol()->setType(RequestOutputPlotSymbolTypeEnum::NO);
			else
				$this->unmarshallSymbol($paramData->{'param-drawing-object'}, 'serie-symbols', $serieNode->getSymbol());
			//Time tick
			if ($paramData->{'param-drawing-object'}->{'serie-timetick-activated'})
				$this->unmarshallTimeTick($paramData->{'param-drawing-object'}, $serieNode->getTimeTicks());
			//Interval tick
			if ($paramData->{'param-drawing-object'}->{'serie-intervaltick-activated'})
				$this->unmarshallIntervalTick($paramData->{'param-drawing-object'}, $serieNode->getIntervalTicks());
			if (!$isOrbitSerie)
			{
				//Error bar
				if ($paramData->{'param-drawing-object'}->{'serie-errorbar-activated'})
					$this->unmarshallErrorBar($paramData->{'param-drawing-object'}, $requestParamsNode, $serieNode->getErrorBar());
			}
		}
	}
	
	protected function unmarshallTimeTick($serieData, $timeTickNode)
	{
		//Font
		if ($serieData->{'serie-timetick-font-activated'})
			$this->unmarshallFont($serieData, 'serie-timetick-font', $timeTickNode->getFont());
		//First Symbol
		if ($serieData->{'serie-timetick-firstsymbols-activated'})
			$this->unmarshallSymbol($serieData, 'serie-timetick-firstsymbols', $timeTickNode->getFirstSymbol());
		//Symbol
		$this->unmarshallSymbol($serieData, 'serie-timetick-symbols', $timeTickNode->getSymbol());
		//Set options by type
		switch ($serieData->{'serie-timetick-type'})
		{
			case 'time-step' :
				$timeTickNode->setStep(CommonClass::timeStampToDDTime($serieData->{'serie-timetick-step'}));
				$timeTickNode->setNumber(0);
				break;
			case 'nb-major' :
				$timeTickNode->setStep(0);
				$timeTickNode->setNumber($serieData->{'serie-timetick-nbmajor'});
				break;
			case 'auto' :
			default :
				$timeTickNode->setStep('auto');
				$timeTickNode->setNumber(0);
		}
		//Minor
		$timeTickNode->setMinor($serieData->{'serie-timetick-nbminor'});
		//Color
		$timeTickNode->setColor($this->hexColor2KernelColor($serieData->{'serie-timetick-color'}));
	}
	
	protected function unmarshallIntervalTick($serieData, $intervalTickNode)
	{
		//Mode
		switch ($serieData->{'serie-intervaltick-mode'})
		{
			case 'symbol-only':
4f9a8e36   Benjamin Renard   Min/Max value def...
848
				$intervalTickNode->setMode(RequestOutputPlotSerieIntervalTicksModeEnum::SYMBOLONLY);
26a23052   Benjamin Renard   Add Interval Tick...
849
850
				break;
			case 'interval-index':
4f9a8e36   Benjamin Renard   Min/Max value def...
851
				$intervalTickNode->setMode(RequestOutputPlotSerieIntervalTicksModeEnum::INTERVALINDEX);
26a23052   Benjamin Renard   Add Interval Tick...
852
853
				break;
			case 'start-stop-time':
4f9a8e36   Benjamin Renard   Min/Max value def...
854
				$intervalTickNode->setMode(RequestOutputPlotSerieIntervalTicksModeEnum::STARTSTOPTIME);
26a23052   Benjamin Renard   Add Interval Tick...
855
856
857
				break;
			case 'start-time':
			default :
4f9a8e36   Benjamin Renard   Min/Max value def...
858
				$intervalTickNode->setMode(RequestOutputPlotSerieIntervalTicksModeEnum::STARTTIME);
26a23052   Benjamin Renard   Add Interval Tick...
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
		}
		
		//Color
		$intervalTickNode->setColor($this->hexColor2KernelColor($serieData->{'serie-intervaltick-color'}));
		
		//Symbol
		$this->unmarshallSymbol($serieData, 'serie-intervaltick-symbols', $intervalTickNode->getSymbol());
		
		//Font
		if ($serieData->{'serie-intervaltick-font-activated'})
			$this->unmarshallFont($serieData, 'serie-intervaltick-font', $intervalTickNode->getFont());
	}
	
	protected function unmarshallErrorBar($serieData, $requestParamsNode, $errorBarNode)
	{
		//Type
		switch ($serieData->{'serie-errorbar-type'})
		{
			case 'min-max':
				$errorBarTypeNode = $errorBarNode->getBarByType(RequestOutputPlotYSerieErrorBarTypeEnum::MINMAX);
				
bf27ba04   Benjamin Renard   Add templated par...
880
				$minParamInfo = $this->paramManager->addExistingParam($serieData->{'serie-errorbar-minparam'}, $this->paramsData);
26a23052   Benjamin Renard   Add Interval Tick...
881
882
883
884
885
886
887
888
889
890
				if ($minParamInfo['id'] == '')
					throw new Exception('Cannot retrieve min. error parameter.');
				$requestParamsNode->addParam($minParamInfo['id']);
				if (count($minParamInfo['indexes']) == 0)
					$errorBarTypeNode->setMinParam($minParamInfo['id'], -1);
				else if (count($minParamInfo['indexes']) == 1)
					$errorBarTypeNode->setMinParam($minParamInfo['id'], $minParamInfo['indexes'][0]);
				else
					throw new Exception('Min parameter for error bar must be a component.');
				
bf27ba04   Benjamin Renard   Add templated par...
891
				$maxParamInfo = $this->paramManager->addExistingParam($serieData->{'serie-errorbar-maxparam'}, $this->paramsData);
26a23052   Benjamin Renard   Add Interval Tick...
892
893
894
895
896
897
898
899
900
901
902
903
904
				if ($maxParamInfo['id'] == '')
					throw new Exception('Cannot retrieve max. error parameter.');
				$requestParamsNode->addParam($maxParamInfo['id']);
				if (count($maxParamInfo['indexes']) == 0)
					$errorBarTypeNode->setMaxParam($maxParamInfo['id'], -1);
				else if (count($maxParamInfo['indexes']) == 1)
					$errorBarTypeNode->setMaxParam($maxParamInfo['id'], $maxParamInfo['indexes'][0]);
				else
					throw new Exception('Max parameter for error bar must be a component.');
				break;
			case 'delta':
				$errorBarTypeNode = $errorBarNode->getBarByType(RequestOutputPlotYSerieErrorBarTypeEnum::DELTA);
				
bf27ba04   Benjamin Renard   Add templated par...
905
				$deltaParamInfo = $this->paramManager->addExistingParam($serieData->{'serie-errorbar-deltaparam'}, $this->paramsData);
26a23052   Benjamin Renard   Add Interval Tick...
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
				if ($deltaParamInfo['id'] == '')
					throw new Exception('Cannot retrieve delta error parameter.');
				$requestParamsNode->addParam($deltaParamInfo['id']);
				if (count($deltaParamInfo['indexes']) == 0)
					$errorBarTypeNode->setDeltaParam($deltaParamInfo['id'], -1);
				else if (count($deltaParamInfo['indexes']) == 1)
					$errorBarTypeNode->setDeltaParam($deltaParamInfo['id'], $deltaParamInfo['indexes'][0]);
				else
					throw new Exception('Delta parameter for error bar must be a component.');
				break;
			default :
				throw new Exception('Unknown error bar type.');
		}
		
		//Line
		$this->unmarshallLine($serieData, 'serie-errorbar', $errorBarNode->getLine(), RequestOutputPlotLineTypeEnum::LINE);
	}
	
	protected function unmarshallInstantSerie($paramDrawingData, $plotNode, $paramNode)
	{
cb46dfbf   Benjamin Renard   Fix orbit serie a...
926
		$iserieNode = $paramNode->addInstantSerie('y-left');
26a23052   Benjamin Renard   Add Interval Tick...
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
		
		//Table on X Axis
		$iserieNode->setTableOnXAxis($paramDrawingData->{'iserie-tableonx'} ? "true" : "false");
		
		//Line
		$this->unmarshallLine($paramDrawingData, 'iserie', $iserieNode->getLine(), $paramDrawingData->{"iserie-lines-activated"} ? RequestOutputPlotLineTypeEnum::LINE : RequestOutputPlotLineTypeEnum::NO);

		//Symbol
		if (!$paramDrawingData->{"iserie-symbols-activated"})
			$iserieNode->getSymbol()->setType(RequestOutputPlotSymbolTypeEnum::NO);
		else
			$this->unmarshallSymbol($paramDrawingData, 'iserie-symbols', $iserieNode->getSymbol());
	}
	
	protected function unmarshallSpectro($paramDrawingData, $plotNode, $paramNode, $indexes)
	{
0a56ad20   Benjamin Renard   Give the possibil...
943
		$spectroNode = $paramNode->addSpectro($paramDrawingData->{'spectro-yaxis'}, empty($paramDrawingData->{'spectro-resolution'}) ? NULL : $paramDrawingData->{'spectro-resolution'}, count($indexes) > 0 ? $indexes[0] : NULL, $paramDrawingData->{'spectro-value-min'}, $paramDrawingData->{'spectro-value-max'}, isset($paramDrawingData->{'spectro-log0-as-min'}) ? $paramDrawingData->{'spectro-log0-as-min'} : false);
26a23052   Benjamin Renard   Add Interval Tick...
944
945
	}
	
fc153c1c   Elena.Budnik   ispectro added
946
947
948
	protected function unmarshallInstantSpectro($paramDrawingData, $plotNode, $paramNode, $indexes)
	{
	//TBD how to process inexes if they are defined ? 
cb46dfbf   Benjamin Renard   Fix orbit serie a...
949
		$spectroNode = $paramNode->addInstantSpectro('y-left', $paramDrawingData->{'ispectro-dimonxaxis'});
fc153c1c   Elena.Budnik   ispectro added
950
951
	}
	
26a23052   Benjamin Renard   Add Interval Tick...
952
953
954
955
956
957
958
	protected function unmarshallStatusBar($paramDrawingData, $paramNode, $indexes)
	{
		if (count($indexes) == 0)
			$paramNode->addStatusBar(-1);
		foreach ($indexes as $index)
			$paramNode->addStatusBar($index);
	}
044a9305   Benjamin Renard   Add intervals dra...
959
960
961
962
963

	protected function unmarshallIntervals($paramDrawingData, $paramNode)
	{
		$paramNode->addIntervals();
	}
26a23052   Benjamin Renard   Add Interval Tick...
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
	
	protected function unmarshallTickBar($paramDrawingData, $paramNode, $indexes)
	{
		if (count($indexes) == 0)
			$paramNode->addTickBar(-1);
		foreach ($indexes as $index)
			$paramNode->addTickBar($index);
	}
	
	protected function hasStatusBar($paramsData)
	{
		foreach ($paramsData as $paramData)
			if ($paramData->{'param-drawing-type'} == 'status-bar')
				return true;
		return false;
	}
	
	protected function hasTickBar($paramsData)
	{
		foreach ($paramsData as $paramData)
			if ($paramData->{'param-drawing-type'} == 'tick-bar')
				return true;
		return false;
	}
	
	protected function unmarshallParamsLegend($paramsLegendData, $paramsLegendNode)
	{
		//Legend type
		switch ($paramsLegendData->{'legend-series-type'})
		{
			case 'text-line-symbol' :
				$paramsLegendNode->setType(RequestOutputPlotParamsLegendTypeEnum::TEXTLINESYMBOL);
				break;
			case 'text-only' :
			default :
				$paramsLegendNode->setType(RequestOutputPlotParamsLegendTypeEnum::TEXTONLY);
		}
		
		//Show param legend
		$paramsLegendNode->setShowParamInfo($paramsLegendData->{'legend-series-showparaminfo'} ? "true" : "false");
		
		//Show interval legend
		$paramsLegendNode->setShowIntervalInfo($paramsLegendData->{'legend-series-intervalinfo-activated'} ? "true" : "false");
		
		//Interval info type
		switch ($paramsLegendData->{'legend-series-intervalinfo-type'})
		{
			case 'start-stop' :
				$paramsLegendNode->setIntervalInfoType(RequestOutputPlotParamsLegendIntervalInfoTypeEnum::STARTSTOP);
				break;
			case 'index' :
			default :
				$paramsLegendNode->setIntervalInfoType(RequestOutputPlotParamsLegendIntervalInfoTypeEnum::INDEX);
		}
		
		//Position
		switch ($paramsLegendData->{'legend-series-position'})
		{
			case 'inside' :
				$paramsLegendNode->setPosition(RequestOutputPlotParamsLegendPositionEnum::INSIDE);
				break;
			case 'outside' :
			default :
				$paramsLegendNode->setPosition(RequestOutputPlotParamsLegendPositionEnum::OUTSIDE);
		}
		
		//Default text color
		$paramsLegendNode->setDefaultTextColor($this->hexColor2KernelColor($paramsLegendData->{'legend-series-defaulttextcolor'}));
		
		//Border visible
		$paramsLegendNode->setBorderVisible($paramsLegendData->{'legend-series-border-activated'} ? "true" : "false");
		
		//Border color
		$paramsLegendNode->setBorderColor($this->hexColor2KernelColor($paramsLegendData->{'legend-series-border-color'}));
		
		//Font
		if ($paramsLegendData->{'legend-series-font-activated'})
			$this->unmarshallFont($paramsLegendData, 'legend-series-font', $paramsLegendNode->getFont());
	}
	
	protected function unmarshallTextLegend($textLegendData, $legendsNode)
	{
		$legendNode = $legendsNode->addTextLegend();
		
		//Legend text
		$legendNode->setText($textLegendData->{'legend-text-value'});
		
		//Legend position
		switch ($textLegendData->{'legend-text-position'})
		{
			case 'top' :
				$legendNode->setPosition(RequestOutputPlotTextLegendPositionEnum::TOP);
				break;
			case 'bottom' :
				$legendNode->setPosition(RequestOutputPlotTextLegendPositionEnum::BOTTOM);
				break;
			case 'left' :
				$legendNode->setPosition(RequestOutputPlotTextLegendPositionEnum::LEFT);
				break;
			case 'right' :
			default :
				$legendNode->setPosition(RequestOutputPlotTextLegendPositionEnum::RIGHT);
		}
		
		//Legend text color
		$legendNode->setColor($this->hexColor2KernelColor($textLegendData->{'legend-text-color'}));
	
		//Font
		if ($textLegendData->{'legend-text-font-activated'})
			$this->unmarshallFont($textLegendData, 'legend-text-font', $legendNode->getFont());
	}
	
	protected function unmarshallConstant($constantData,$axisNode)
	{
		$constantNode = $axisNode->addConstant();
		$constantNode->setId($constantData->{'id'});
		
		//Constant value
		switch ($axisNode->getName())
		{
			case REQUESTOUTPUTPLOTTIMEAXIS_NAME :
				date_default_timezone_set('UTC');
				$timeStamp = strtotime($constantData->{'constant-time-value'});
				$time = CommonClass::timeStampToDDTime($timeStamp);
				$constantNode->setConstantValue($time);
				break;
			default :
				$constantNode->setConstantValue($constantData->{'constant-float-value'});
		}
		
		//Curve options
		$this->unmarshallCurve($constantData, "constant-line", $constantNode);
	}
	
	protected function unmarshallAdditionalObjects($panelData, $addObjectsNode, $isTimePlot)
	{
		foreach ($panelData->{'textObjs'} as $textData)
			$this->unmarshallTextObject($textData, $addObjectsNode, $isTimePlot);
		foreach ($panelData->{'curves'} as $curveData)
			$this->unmarshallCurveObject($curveData, $addObjectsNode);
	}
	
	protected function unmarshallTextObject($textData, $addObjectsNode, $isTimePlot)
	{
		$textNode = $addObjectsNode->addTextObject();
		
		$textNode->setText($textData->{'text-value'});
		
		switch ($textData->{'text-y-axis'})
		{
			case 'y-right' :
				$textNode->setYAxis('y-right');
				break;
			case 'y-left' :
				$textNode->setYAxis('y-left');
				break;
		}
		
		if ($isTimePlot && !$textData->{'text-x-relative'})
		{
			date_default_timezone_set('UTC');
			$timeStamp = strtotime($textData->{'text-x-timevalue'});
			$time = CommonClass::timeStampToDDTime($timeStamp);
			$textNode->setX($time);
		}
		else if ($textData->{'text-x-relative'})
			$textNode->setX(($textData->{'text-x-floatvalue'}*100)."%");
		else
			$textNode->setX($textData->{'text-x-floatvalue'});
		
		if ($textData->{'text-y-relative'})
			$textNode->setY(($textData->{'text-y-value'}*100)."%");
		else
			$textNode->setY($textData->{'text-y-value'});
		
		$textNode->setAngle($textData->{'text-angle'});
		
		$textNode->setColor($this->hexColor2KernelColor($textData->{'text-color'}));
		
		switch ($textData->{'text-align'})
		{
			case 'center' :
				$textNode->setAlign(RequestOutputPlotTextAlign::CENTER);
				break;
			case 'right' :
				$textNode->setAlign(RequestOutputPlotTextAlign::RIGHT);
				break;
			case 'left' :
			default:
				$textNode->setAlign(RequestOutputPlotTextAlign::LEFT);
		}
		
		//Font
		if ($textData->{'text-font-activated'})
			$this->unmarshallFont($textData, 'text-font', $textNode->getFont());
	}
	
	protected function unmarshallCurveObject($curveData, $addObjectsNode)
	{
		if (($curveData->{'curve-name'} == '') || !isset($curveData->{'curve-serie-id'}))
			return;
		
		$curveNode = $addObjectsNode->addCurveObject();
		
		$curveNode->setSerieId($curveData->{'curve-serie-id'});
		
		$curveNode->getFunction()->setFunctionName($curveData->{'curve-name'});
		
		foreach ($curveData->{'params'} as $paramData)
			$curveNode->getFunction()->addAttribute($paramData->{'curve-param-name'}, $paramData->{'curve-param-value'});
		
		//Curve options
		$this->unmarshallCurve($curveData, "curve-line", $curveNode);
	}
	
	protected function unmarshallFills($panelData, $fillsNode)
	{
		foreach ($panelData->{'fills'} as $fillData)
		{
			//Serie / Constant
			if ($fillData->{'fill-type'} == 'serie-constant')
			{
				$fillNode = $fillsNode->addFill(RequestOutputPlotFillTypeEnum::SERIECONSTANT);
				$fillNode->setSerieId($fillData->{'fill-firstserie-id'});
				$fillNode->setConstantId($fillData->{'fill-constant-id'});
				if ($fillData->{'fill-greater-color'} != 'none')
					$fillNode->setGreaterColor($this->hexColor2KernelColor($fillData->{'fill-greater-color'}));
				if ($fillData->{'fill-less-color'} != 'none')
					$fillNode->setLessColor($this->hexColor2KernelColor($fillData->{'fill-less-color'}));
			}
		}
		
		foreach ($panelData->{'fills'} as $fillData)
		{
			//Serie / Serie
			if ($fillData->{'fill-type'} == 'serie-serie')
			{
				$fillNode = $fillsNode->addFill(RequestOutputPlotFillTypeEnum::SERIESERIE);
				$fillNode->setFirstSerieId($fillData->{'fill-firstserie-id'});
				$fillNode->setSecondSerieId($fillData->{'fill-secondserie-id'});
				if ($fillData->{'fill-greater-color'} != 'none')
					$fillNode->setGreaterColor($this->hexColor2KernelColor($fillData->{'fill-greater-color'}));
				if ($fillData->{'fill-less-color'} != 'none')
					$fillNode->setLessColor($this->hexColor2KernelColor($fillData->{'fill-less-color'}));
			}
		}		
	}
	
	protected function unmarshallTitle($inputData, $keyPrefix, $titleNode)
	{
		if ($inputData->{$keyPrefix.'-text'} != '')
		{
			$titleNode->setText($inputData->{$keyPrefix.'-text'});
		
			switch ($inputData->{$keyPrefix.'-position'})
			{
				case 'top' :
					$titleNode->setPosition(RequestOutputPlotTitlePosition::TOP);
					break;
				case 'bottom' :
					$titleNode->setPosition(RequestOutputPlotTitlePosition::BOTTOM);
					break;
			}
		
			switch ($inputData->{$keyPrefix.'-alignment'})
			{
				case 'center' :
					$titleNode->setAlign(RequestOutputPlotTitleAlign::CENTER);
					break;
				case 'left' :
					$titleNode->setAlign(RequestOutputPlotTitleAlign::LEFT);
					break;
				case 'right' :
					$titleNode->setAlign(RequestOutputPlotTitleAlign::RIGHT);
					break;
			}
			
			if ($inputData->{$keyPrefix.'-color'} != '')
				$titleNode->setColor($this->hexColor2KernelColor($inputData->{$keyPrefix.'-color'}));
		
			$this->unmarshallLabel($inputData, $keyPrefix, $titleNode);
		}
	}
	
	protected function unmarshallLabel($inputData, $keyPrefix, $labelNode)
	{
		if ($inputData->{$keyPrefix.'-font-activated'})
		{
			$labelNode->setFontName($inputData->{$keyPrefix.'-font-name'});
			$labelNode->setFontSize($inputData->{$keyPrefix.'-font-size'});
26a23052   Benjamin Renard   Add Interval Tick...
1254
1255
			if ($inputData->{$keyPrefix.'-font-bold'})
			{
20e36076   Benjamin Renard   Update interface ...
1256
				$labelNode->setFontWeight("bold");
26a23052   Benjamin Renard   Add Interval Tick...
1257
1258
1259
			}
			if ($inputData->{$keyPrefix.'-font-italic'})
			{
20e36076   Benjamin Renard   Update interface ...
1260
				 $labelNode->setFontStyle("italic");
26a23052   Benjamin Renard   Add Interval Tick...
1261
			}
26a23052   Benjamin Renard   Add Interval Tick...
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
		}
		
	}
	
	protected function unmarshallFont($inputData, $keyPrefix, $fontNode)
	{
		if ($inputData->{$keyPrefix.'-activated'})
		{
			$fontNode->setFontName($inputData->{$keyPrefix.'-name'});
			$fontNode->setSize($inputData->{$keyPrefix.'-size'});
			
			if ($inputData->{$keyPrefix.'-italic'})
				$fontNode->setStyle(RequestOutputPlotFontStyle::ITALIC);
			else
				$fontNode->setStyle(RequestOutputPlotFontStyle::UPRIGHT);
			
			if ($inputData->{$keyPrefix.'-bold'})
				$fontNode->setWeight(RequestOutputPlotFontWeight::BOLD);
			else
				$fontNode->setWeight(RequestOutputPlotFontWeight::MEDIUM);
		}
	}
	
	protected function unmarshallCurve($inputData, $keyPrefix, $curveNode)
	{
		switch ($inputData->{$keyPrefix.'-style'})
		{
02abc780   Benjamin Renard   Support request f...
1289
			
26a23052   Benjamin Renard   Add Interval Tick...
1290
1291
1292
1293
1294
1295
1296
1297
1298
			case 'dot'             :
				$curveNode->setStyle(RequestOutputPlotCurveStyleEnum::DOT);
				break;
			case 'long-spaced-dot' :
				$curveNode->setStyle(RequestOutputPlotCurveStyleEnum::LONGSPACEDDOT);
				break;
			case 'long-short-dot'  :
				$curveNode->setStyle(RequestOutputPlotCurveStyleEnum::LONGSHORTDOT);
				break;
02abc780   Benjamin Renard   Support request f...
1299
1300
1301
1302
			case 'plain'           :
			default                :
				$curveNode->setStyle(RequestOutputPlotCurveStyleEnum::PLAIN);
				break;
26a23052   Benjamin Renard   Add Interval Tick...
1303
		}
02abc780   Benjamin Renard   Support request f...
1304
1305
1306
		
		if (isset($inputData->{$keyPrefix.'-width'}))
			$curveNode->setWidth($inputData->{$keyPrefix.'-width'});
26a23052   Benjamin Renard   Add Interval Tick...
1307
				
02abc780   Benjamin Renard   Support request f...
1308
		if (isset($inputData->{$keyPrefix.'-color'}) && ($inputData->{$keyPrefix.'-color'} != 'auto'))
26a23052   Benjamin Renard   Add Interval Tick...
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
			$curveNode->setColor($this->hexColor2KernelColor($inputData->{$keyPrefix.'-color'}));
	}
	
	protected function unmarshallLine($inputData, $keyPrefix, $lineNode, $lineType)
	{
		$lineNode->setType($lineType);
		$this->unmarshallCurve($inputData, $keyPrefix."-lines", $lineNode);
	}
	
	protected function unmarshallSymbol($inputData, $keyPrefix, $symbolNode)
	{
		switch ($inputData->{$keyPrefix.'-type'})
		{
			case 'dot' :
				$symbolNode->setType(RequestOutputPlotSymbolTypeEnum::DOT);
				break;
			case 'plus' :
				$symbolNode->setType(RequestOutputPlotSymbolTypeEnum::PLUS);
				break;
			case 'wildcard' :
				$symbolNode->setType(RequestOutputPlotSymbolTypeEnum::WILDCARD);
				break;
			case 'circle' :
				$symbolNode->setType(RequestOutputPlotSymbolTypeEnum::CIRCLE);
				break;
			case 'crux' :
				$symbolNode->setType(RequestOutputPlotSymbolTypeEnum::CRUX);
				break;
			case 'square' :
				$symbolNode->setType(RequestOutputPlotSymbolTypeEnum::SQUARE);
				break;
			case 'triangle' :
				$symbolNode->setType(RequestOutputPlotSymbolTypeEnum::TRIANGLE);
				break;
			case 'crux-in-circle' :
				$symbolNode->setType(RequestOutputPlotSymbolTypeEnum::CRUXINCIRCLE);
				break;
			case 'dot-in-circle' :
				$symbolNode->setType(RequestOutputPlotSymbolTypeEnum::DOTINCIRCLE);
				break;
			case 'diamond' :
				$symbolNode->setType(RequestOutputPlotSymbolTypeEnum::DIAMOND);
				break;
			case 'star' :
				$symbolNode->setType(RequestOutputPlotSymbolTypeEnum::STAR);
				break;
			case 'david-star' :
				$symbolNode->setType(RequestOutputPlotSymbolTypeEnum::DAVIDSTAR);
				break;
			case 'full-square' :
				$symbolNode->setType(RequestOutputPlotSymbolTypeEnum::FULLSQUARE);
				break;
			case 'full-circle' :
				$symbolNode->setType(RequestOutputPlotSymbolTypeEnum::FULLCIRCLE);
				break;
			case 'full-star' :
				$symbolNode->setType(RequestOutputPlotSymbolTypeEnum::FULLSTAR);
				break;
			default :
				throw new Exception('Symbol type not implemented.');
		}
			
		$symbolNode->setSize($inputData->{$keyPrefix.'-size'});
				
		if ($inputData->{$keyPrefix.'-color'} != 'auto')
			$symbolNode->setColor($this->hexColor2KernelColor($inputData->{$keyPrefix.'-color'}));
	}

	/*
	 * @brief method to marshall the result of a download request
	*/
	protected function marshallResult($data)
	{
		if (!$this->isInteractiveRequest)
		{
			//add to job
			$commonRes = $this->commonMarshallResult($data,PLOT_RESULT_FILE_KEY);
		
			return $commonRes;
		}
		
		//Interactive request
22521f1c   Benjamin Renard   First commit
1391
1392
1393
1394
1395
1396
1397
		if (!$data->getSuccess())
			return array(
					'success' => false,
					'message' => $data->getLastErrorMessage());
		
		switch ($data->getStatus())
		{
26a23052   Benjamin Renard   Add Interval Tick...
1398
1399
1400
1401
1402
1403
1404
1405
1406
			case ProcessStatusEnumClass::DONE :
				
				$result = array();
				foreach ($data->getWaitingResults() as $key => $waitingResult)
				{
					$contextResult = str_replace(".png","_context.xml",$waitingResult);
					
					$result[] = array(
						"id" => $key,
05da1b4d   Benjamin Renard   Draw instant plot...
1407
						"preview" => $this->interactivePreview,
26a23052   Benjamin Renard   Add Interval Tick...
1408
1409
1410
						"isInterval" => $this->interactiveTimeSelectionState[$key],
						"ttFileIndex" => $this->interactiveCrtTTFileIndex,
						"context" => IHMPlotContextFileClass::parse($this->getWorkingPath().$contextResult),
ba82a624   Benjamin Renard   Get kernel execut...
1411
1412
						"plot" => $waitingResult,
						"exectime" => $data->getExecTime(),
26a23052   Benjamin Renard   Add Interval Tick...
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
					);
				}
				
				return array(
					'success'     => true,
					'id'          => $data->getId(),
					'folder'      => $this->getWorkingDirName(),
					'result'      => $result
				);
			case ProcessStatusEnumClass::KILLED :
				return array(
						'success'     => true,
bda99a72   Benjamin Renard   Add kill plot req...
1425
						'killed'      => true);
22521f1c   Benjamin Renard   First commit
1426
			default :
e4eba677   Benjamin Renard   Get error message...
1427
				$errorMsg = $data->getErrorMsg();
22521f1c   Benjamin Renard   First commit
1428
1429
				return array(
				'success' => false,
e4eba677   Benjamin Renard   Get error message...
1430
				'message'   => 'Request processing error'.(!empty($errorMsg) ? "<br>(".$errorMsg.")" : ""));
26a23052   Benjamin Renard   Add Interval Tick...
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
		}
	}
	
	private function hexColor2KernelColor($hex) {
		$hex = str_replace("#", "", $hex);

		$r = hexdec(substr($hex,0,2));
		$g = hexdec(substr($hex,2,2));
		$b = hexdec(substr($hex,4,2));

		return "[".$r.",".$g.",".$b."]";
	}
	
	private function saveIHMRequest($input)
	{
		$path = $this->getWorkingPath()."ihm.request";
		if (!is_dir($this->getWorkingPath()))
			mkdir($this->getWorkingPath(),0777);
22521f1c   Benjamin Renard   First commit
1449
1450
		$file = fopen($path, 'w');
		fwrite($file, json_encode($input));
26a23052   Benjamin Renard   Add Interval Tick...
1451
1452
1453
1454
1455
1456
		fclose($file);
	}
	
	private function loadIHMRequest()
	{
		$path = $this->getWorkingPath()."ihm.request";
22521f1c   Benjamin Renard   First commit
1457
		if (!file_exists($path))
26a23052   Benjamin Renard   Add Interval Tick...
1458
1459
1460
1461
1462
1463
			return NULL;
		return json_decode(file_get_contents($path));
	}
	
	private function unmarshallActionRequest($input)
	{
e8cefd97   Benjamin Renard   Interactive attac...
1464
		$actionInput    = $input->{'action'};
e8cefd97   Benjamin Renard   Interactive attac...
1465
		
26a23052   Benjamin Renard   Add Interval Tick...
1466
1467
1468
		$plotInput = $this->loadIHMRequest();
		
		if (!isset($plotInput))
86756f46   Benjamin Renard   Remove multi plot...
1469
			throw new Exception('Cannot retrieve request input for interactive action.');
e8cefd97   Benjamin Renard   Interactive attac...
1470
1471
		
		switch ($actionInput->{'action'})
26a23052   Benjamin Renard   Add Interval Tick...
1472
1473
		{
			case 'zoom' :
e8cefd97   Benjamin Renard   Interactive attac...
1474
				return $this->unmarshallZoom($actionInput, $plotInput);
26a23052   Benjamin Renard   Add Interval Tick...
1475
1476
1477
1478
1479
1480
			case 'forward' :
			case 'halfforward' :
			case 'backward' :
			case 'halfbackward' :
			case 'extend' :
			case 'shift' :
e8cefd97   Benjamin Renard   Interactive attac...
1481
				return $this->unmarshallNavigation($actionInput, $plotInput);
26a23052   Benjamin Renard   Add Interval Tick...
1482
			case 'goto' :
e8cefd97   Benjamin Renard   Interactive attac...
1483
				return $this->unmarshallTTGoto($actionInput, $plotInput);
05da1b4d   Benjamin Renard   Draw instant plot...
1484
1485
			case 'instant' :
				return $this->unmarshallInstant($actionInput, $plotInput);
d3c3608d   Benjamin Renard   Add undo zoom
1486
1487
			case 'undozoom' :
				return $this->unmarshallUndoZoom($actionInput, $plotInput);
26a23052   Benjamin Renard   Add Interval Tick...
1488
1489
1490
1491
1492
			default :
				throw new Exception('Interactive action not implemented.');
		}
	}
	
d3c3608d   Benjamin Renard   Add undo zoom
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
	private function addZoomInList($input, $isInterval, $minOrFileIndex, $maxOrIntervalIndex)
	{
		//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();
		
		if (!isset($zoomList->tabs))
		{
			//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()
			);
		}
		
		if ($input->{'axeId'} == 'timeAxis')
		{
			if ($isInterval)
				array_push ($zoomList->tabs->{$input->{'tabId'}}->times, (Object)array(
					'isInterval' => true,
					'min' => $minOrFileIndex,
					'max'  => $maxOrIntervalIndex
				));
			else
				array_push ($zoomList->tabs->{$input->{'tabId'}}->times, (Object)array(
						'isInterval' => false,
						'ttFileIndex' => $minOrFileIndex,
						'intIndex'  => $maxOrIntervalIndex
				));
		}
		else
		{
			if (!isset($zoomList->tabs->{$input->{'tabId'}}->panels->{$input->{'panelId'}}))
			{
				$zoomList->tabs->{$input->{'tabId'}}->panels->{$input->{'panelId'}} = (Object) array(
						'axes' => (Object)array()
				);
			}
			
			if (!isset($zoomList->tabs->{$input->{'tabId'}}->panels->{$input->{'panelId'}}->axes->{$input->{'axeId'}}))
			{
				$zoomList->tabs->{$input->{'tabId'}}->panels->{$input->{'panelId'}}->axes->{$input->{'axeId'}} = array();
			}
			
			array_push ($zoomList->tabs->{$input->{'tabId'}}->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));
	}
	
	private function resetZoomListForTab($tabId, $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();
		}
		
		$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 undoZoomInList($input)
	{
		$zoomList = $this->loadZoomList();
		
		$result = NULL;
		if (isset($zoomList->tabs) && isset($zoomList->tabs->{$input->{'tabId'}}))
		{
			if ($input->{'axeId'} == 'timeAxis')
			{
				if (count($zoomList->tabs->{$input->{'tabId'}}->times) <= 0)
					return NULL;
				$result = array_pop($zoomList->tabs->{$input->{'tabId'}}->times);		
			}
			else
			{
				if (!isset($zoomList->tabs->{$input->{'tabId'}}->panels->{$input->{'panelId'}}))
					return NULL;
				
				if (!isset($zoomList->tabs->{$input->{'tabId'}}->panels->{$input->{'panelId'}}->axes->{$input->{'axeId'}}))
					return NULL;
				
				$result = array_pop($zoomList->tabs->{$input->{'tabId'}}->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);
		
		return $result;
	}
	
	private function unmarshallZoom($input, $plotInput, $isUndo = false)
26a23052   Benjamin Renard   Add Interval Tick...
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
	{
		//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
7d84634e   Benjamin Renard   Fix plot request ...
1644
			if ($crtTab->{'timesrc'} != 'Interval')
26a23052   Benjamin Renard   Add Interval Tick...
1645
			{
7d84634e   Benjamin Renard   Fix plot request ...
1646
1647
1648
1649
1650
				$crtTab->{'timesrc'} = 'Interval';
				if (!$isUndo)
					$this->addZoomInList($input,false,
							isset($crtTab->{'ttFileIndex'}) ? $crtTab->{'ttFileIndex'} : 0,
							isset($crtTab->{'intIndex'}) ? $crtTab->{'intIndex'} : 0);
26a23052   Benjamin Renard   Add Interval Tick...
1651
1652
1653
			}
			else
			{
7d84634e   Benjamin Renard   Fix plot request ...
1654
1655
				if (!$isUndo)
					$this->addZoomInList($input,true,$crtTab->{'startDate'},$crtTab->{'stopDate'});
26a23052   Benjamin Renard   Add Interval Tick...
1656
			}
7d84634e   Benjamin Renard   Fix plot request ...
1657
1658
			$crtTab->{'startDate'} = $input->{'min'};
			$crtTab->{'stopDate'} = $input->{'max'};
e8cefd97   Benjamin Renard   Interactive attac...
1659
				
26a23052   Benjamin Renard   Add Interval Tick...
1660
			$plotInput->{'last-plotted-tab'} = $crtTab->{'id'};
d3c3608d   Benjamin Renard   Add undo zoom
1661
			$plotInput->{'force-time-zoom-reset'} = false;
26a23052   Benjamin Renard   Add Interval Tick...
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
			$this->saveIHMRequest($plotInput);
			return $plotInput;
		}
		
		//Digital axis zoom
		foreach ($crtTab->{'panels'} as $panel)
		{
			if ($input->{'panelId'} == $panel->{'id'})
			{
				foreach ($panel->{'axes'} as $axis)
				{
					if ($input->{'axeId'} == $axis->{'id'})
					{
						$axis->{'axis-range-extend'} = false;
d3c3608d   Benjamin Renard   Add undo zoom
1676
1677
						$oldMin = $axis->{'axis-range-min'};
						$oldMax = $axis->{'axis-range-max'};
26a23052   Benjamin Renard   Add Interval Tick...
1678
1679
1680
1681
1682
1683
						$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;
d3c3608d   Benjamin Renard   Add undo zoom
1684
1685
1686
						$plotInput->{'force-time-zoom-reset'} = false;
						if (!$isUndo)
							$this->addZoomInList($input,true,$oldMin,$oldMax);
26a23052   Benjamin Renard   Add Interval Tick...
1687
1688
1689
1690
1691
1692
1693
1694
1695
						return $plotInput;
					}
				}
				throw new Exception('Cannot retrieve axis for zoom action.');
			}
		}
		throw new Exception('Cannot retrieve plot panel for zoom action.');
	}
	
d3c3608d   Benjamin Renard   Add undo zoom
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
	private function unmarshallUndoZoom($input, $plotInput)
	{
		$result = $this->undoZoomInList($input);
		if ($result != NULL)
		{
			if (isset($result->isInterval))
			{
				if (!$result->isInterval)
				{
					$input->ttFileIndex = $result->ttFileIndex;
					$input->intIndex = $result->intIndex;
					return $this->unmarshallTTGoto($input, $plotInput);
				}
			}
			$input->min = $result->min;
			$input->max = $result->max;
			return $this->unmarshallZoom($input, $plotInput, true);
		}
		throw new Exception('No undo zoom to apply.');
	}
	
26a23052   Benjamin Renard   Add Interval Tick...
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
	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.');
		
7d84634e   Benjamin Renard   Fix plot request ...
1733
1734
		$startTime = $crtTab->{'startDate'};
		$stopTime = $crtTab->{'stopDate'};
26a23052   Benjamin Renard   Add Interval Tick...
1735
1736
1737
1738
1739
1740
1741
1742
1743
1744
1745
1746
1747
1748
1749
1750
1751
1752
1753
1754
1755
1756
1757
1758
1759
1760
1761
1762
1763
1764
1765
1766
1767
1768
1769
1770
1771
1772
1773
1774
1775
1776
		
		//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;
			case 'extend' :
				$startTimeStamp -= $input->{'duration'};
				$stopTimeStamp  += $input->{'duration'};
				break;
			case 'shift' :
				$startTimeStamp += $input->{'duration'};
				$stopTimeStamp  += $input->{'duration'};
				break;
		}
		
		if ($stopTimeStamp - $startTimeStamp <= 0)
			throw new Exception('New duration is lower than 0.');
		
		$startTime = date("Y-m-d\TH:i:s",$startTimeStamp);
		$stopTime = date("Y-m-d\TH:i:s",$stopTimeStamp);
		
		//Update request
7d84634e   Benjamin Renard   Fix plot request ...
1777
1778
		$crtTab->{'startDate'} = $startTime;
		$crtTab->{'stopDate'} = $stopTime;
26a23052   Benjamin Renard   Add Interval Tick...
1779
1780
		
		$plotInput->{'last-plotted-tab'} = $crtTab->{'id'};
d3c3608d   Benjamin Renard   Add undo zoom
1781
		$plotInput->{'force-time-zoom-reset'} = true;
26a23052   Benjamin Renard   Add Interval Tick...
1782
1783
1784
1785
1786
1787
1788
1789
1790
1791
1792
1793
1794
1795
1796
1797
1798
1799
1800
1801
		$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.');
		
854ad953   Benjamin Renard   Change prefix of ...
1802
		$plotInput->{'last-plotted-tab'} = $crtTab->{'id'};
e8cefd97   Benjamin Renard   Interactive attac...
1803
		
7d84634e   Benjamin Renard   Fix plot request ...
1804
1805
1806
		$crtTab->{'timesrc'} = 'TimeTable';
		$crtTab->{'ttFileIndex'} = $input->{'ttFileIndex'};
		$crtTab->{'intIndex'} = $input->{'intIndex'};
e8cefd97   Benjamin Renard   Interactive attac...
1807
		
d3c3608d   Benjamin Renard   Add undo zoom
1808
		$plotInput->{'force-time-zoom-reset'} = true;
e8cefd97   Benjamin Renard   Interactive attac...
1809
1810
1811
1812
		$this->saveIHMRequest($plotInput);
		return $plotInput;
	}
	
05da1b4d   Benjamin Renard   Draw instant plot...
1813
1814
1815
1816
1817
1818
1819
1820
1821
1822
1823
1824
1825
1826
1827
1828
1829
1830
1831
1832
1833
1834
1835
1836
1837
1838
1839
1840
1841
1842
1843
1844
1845
1846
1847
1848
1849
1850
1851
1852
1853
1854
1855
1856
1857
1858
1859
1860
1861
1862
1863
1864
1865
1866
1867
1868
1869
1870
1871
1872
1873
1874
1875
1876
1877
1878
1879
1880
1881
1882
1883
1884
1885
1886
1887
1888
1889
1890
1891
1892
1893
1894
1895
1896
1897
1898
1899
1900
1901
1902
1903
1904
	private function unmarshallInstant($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 instant plot.');
	
		//Find current panel
		$crtPanel = NULL;
		foreach ($crtTab->{'panels'} as $panel)
		{
			if ($input->{'panelId'} == $panel->{'id'})
			{
				$crtPanel = $panel;
				break;
			}
		}
		
		if (!$crtPanel)
			throw new Exception('Cannot retrieve plot panel for instant plot.');
		
		if ($crtPanel->{'panel-plot-type'} != 'timePlot')
			throw new Exception('Instant plot action only available for Time plot.');
		
		//Find spectra parameter
		$crtParam = NULL;
		foreach ($crtPanel->{'params'} as $param)
		{
			if ($param->{'param-drawing-type'} == 'spectro')
			{
				$crtParam = $param;
				break;
			}
		}
		
		if (!$crtParam)
			throw new Exception('Cannot retrieve plot param for instant plot.');
		
		//Find table Y-axis
		$crtYAxis = NULL;
		foreach ($crtPanel->{'axes'} as $axis)
		{
			if ($crtParam->{'param-drawing-object'}->{'spectro-yaxis'} == $axis->{'id'})
			{
				$crtYAxis = $axis;
				break;
			}
		}
		
		if (!$crtYAxis)
			throw new Exception('Cannot retrieve plot y Axis for instant plot.');
		
		//Find color Z-axis
		$crtColorAxis = NULL;
		foreach ($crtPanel->{'axes'} as $axis)
		{
			if ($axis->{'id'} == 'color')
			{
				$crtColorAxis = $axis;
				break;
			}
		}
		
		if (!$crtColorAxis)
			throw new Exception('Cannot retrieve plot color Axis for instant plot.');
		
		date_default_timezone_set('UTC');
		$timeStamp = strtotime($input->time);
		
		$instantPlotInput = (Object)array(
			"interactive-preview" => true,
			"file-format" => "PNG",
			"file-output" => "INTERACTIVE",
			"file-prefix" => "instant",
			"last-plotted-tab"=> 1,
			"timesrc" => "Interval",
			"startDate" => date("Y-m-dTH:i:s", $timeStamp - 3600),
			"stopDate" => date("Y-m-dTH:i:s", $timeStamp + 3600),
			"tabs" => array()
		);
		
		$instantTab = (Object)array(
			"id" => 1,
05da1b4d   Benjamin Renard   Draw instant plot...
1905
1906
1907
1908
1909
1910
1911
1912
1913
1914
1915
1916
1917
1918
1919
1920
1921
1922
1923
1924
1925
1926
1927
1928
1929
1930
1931
1932
1933
1934
1935
1936
1937
1938
1939
1940
1941
1942
1943
1944
			"page-margins-activated" => $crtTab->{"page-margins-activated"},
			"page-margin-x" => $crtTab->{"page-margin-x"},
			"page-margin-y" => $crtTab->{"page-margin-y"},
			"page-orientation" => $crtTab->{"page-orientation"},
			"page-dimension" => $crtTab->{"page-dimension"},
			"page-layout-type" => "vertical",
			"page-layout-object" => (Object)array(
				"layout-expand" => true,
			    "layout-panel-height" => 0.5,
				"layout-panel-spacing" => 0.05
			),
			"panels" => array()
		);
		
		$instantPanel = (Object)array(
				"id" => "1",
				"panel-plot-type" => "instantPlot",
				"panel-instant-time" => $input->time,
				"axes" => array(),
				"params" => array()
	    );
		
		$instantXAxis = (Object)array(
				"id"         => "xaxis_id",
				"axis-type"  => "x",
				"axis-scale" => $crtYAxis->{"axis-scale"},
				"axis-thickness" => 1
		);
		
		$instantYAxis = (Object)array(
				"id"         => "y-left",
				"axis-type"  => "y-left",
				"axis-scale" => $crtColorAxis->{"axis-scale"},
				"axis-thickness" => 1
		);
		$instantPanel->{"axes"}[] = $instantXAxis;
		$instantPanel->{"axes"}[] = $instantYAxis;
		
		$instantParam = (Object)array(
			"id" => 1,
e4545ed5   Benjamin Renard   Implement templat...
1945
			"paramid" => $crtParam->{'paramid'},
8d780912   Benjamin Renard   Keep template arg...
1946
			"template_args" => $crtParam->{'template_args'},
05da1b4d   Benjamin Renard   Draw instant plot...
1947
1948
1949
1950
1951
1952
1953
1954
1955
1956
1957
1958
1959
1960
1961
1962
1963
1964
			"param-drawing-type" => "iserie",
			"param-drawing-object" => (Object)array(
					"iserie-tableonx" => true,
					"iserie-lines-activated" => true,
					"iserie-lines-style" => "plain",
					"iserie-lines-width" => 1,
					"iserie-lines-color" => "auto"
			)
		);
		$instantPanel->{"params"}[] = $instantParam;
		
		$instantTab->{"panels"}[] = $instantPanel;
		
		$instantPlotInput->{"tabs"}[] = $instantTab;
		
		
		return $instantPlotInput;
	}
26a23052   Benjamin Renard   Add Interval Tick...
1965
}
8d780912   Benjamin Renard   Keep template arg...
1966
?>