Blame view

src/InputOutput/IHMImpl/Params/PlotImpl/IHMInputOutputParamsPlotClass.php 64.6 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
	private $interactiveTimeSelectionState = array();
70e82c1f   Benjamin Renard   Fix doPlot
19
20
        private $interactivePlotTitle = array();
        private $interactivePlotIndex = array();
26a23052   Benjamin Renard   Add Interval Tick...
21
	private $interactiveCrtTTFileIndex = -1;
05da1b4d   Benjamin Renard   Draw instant plot...
22
	private $interactivePreview = false;
26a23052   Benjamin Renard   Add Interval Tick...
23
24
25
26
27
28
	
	/*
	 * @brief method to unmarshall a plot request
	*/
	protected function unmarshallRequest($input)
	{
97a69b20   Benjamin Renard   Fix most of error...
29
		$forceTimeZoomReset = false;
22253da3   Benjamin Renard   Fix zoom reset
30
		$resetZoom = false;
d3c3608d   Benjamin Renard   Add undo zoom
31
		
26a23052   Benjamin Renard   Add Interval Tick...
32
		if (isset($input->{'action'}))
d3c3608d   Benjamin Renard   Add undo zoom
33
		{
26a23052   Benjamin Renard   Add Interval Tick...
34
			$input = $this->unmarshallActionRequest($input);
d3c3608d   Benjamin Renard   Add undo zoom
35
36
			$forceTimeZoomReset = isset($input->{'force-time-zoom-reset'}) ? $input->{'force-time-zoom-reset'} : false;
		}
26a23052   Benjamin Renard   Add Interval Tick...
37
		else
d3c3608d   Benjamin Renard   Add undo zoom
38
39
		{
			$resetZoom = true;
26a23052   Benjamin Renard   Add Interval Tick...
40
			//save request
4a7023e8   Benjamin Renard   Fix interactive n...
41
			$this->saveIHMRequest(PLOT_RESULT_FILE_KEY."_".$input->{'tab-index'}, $input);
d3c3608d   Benjamin Renard   Add undo zoom
42
43
		}
			
26a23052   Benjamin Renard   Add Interval Tick...
44
		//Request
26a23052   Benjamin Renard   Add Interval Tick...
45
		$this->isInteractiveRequest = ($input->{'file-output'} == 'INTERACTIVE');
02abc780   Benjamin Renard   Support request f...
46
		$this->isFromWS = ($input->{'file-output'} == 'WS');
70e82c1f   Benjamin Renard   Fix doPlot
47
		$this->paramsData->setRequestIndex($input->{'tab-index'});
26a23052   Benjamin Renard   Add Interval Tick...
48
		$postProcessCmd = "";
7d84634e   Benjamin Renard   Fix plot request ...
49

22253da3   Benjamin Renard   Fix zoom reset
50
		if ($resetZoom || $forceTimeZoomReset)
a9d86eaa   Benjamin Renard   Fix zoom / unzoom
51
			$this->resetZoomList(PLOT_RESULT_FILE_KEY."_".$input->{'tab-index'}, $forceTimeZoomReset);
26a23052   Benjamin Renard   Add Interval Tick...
52
			
7d84634e   Benjamin Renard   Fix plot request ...
53
54
55
		$requestNode = $this->paramsData->addRequestNode();
		$outputsNode = $requestNode->getOutputsNode();
		$paramsNode  = $requestNode->getParamsNode();
26a23052   Benjamin Renard   Add Interval Tick...
56
			
7d84634e   Benjamin Renard   Fix plot request ...
57
58
59
60
61
62
63
64
65
66
		//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...
67
			
7d84634e   Benjamin Renard   Fix plot request ...
68
		$this->interactiveCrtTTFileIndex = $ttFileIndex;
26a23052   Benjamin Renard   Add Interval Tick...
69
			
7d84634e   Benjamin Renard   Fix plot request ...
70
		$plotOutputNode = $outputsNode->addNewOutput(RequestOutputTypeEnum::PLOT);
26a23052   Benjamin Renard   Add Interval Tick...
71
			
7d84634e   Benjamin Renard   Fix plot request ...
72
		$plotOutputNode->setWriteContextFile($this->isInteractiveRequest ? "true" : "false");
26a23052   Benjamin Renard   Add Interval Tick...
73
			
7d84634e   Benjamin Renard   Fix plot request ...
74
75
76
77
		$compression = "";
		if (!$this->isInteractiveRequest && !$this->isFromWS)
		{
			switch ($input->{'file-output'})
26a23052   Benjamin Renard   Add Interval Tick...
78
			{
7d84634e   Benjamin Renard   Fix plot request ...
79
80
81
82
83
84
85
86
87
88
89
				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...
90
			}
7d84634e   Benjamin Renard   Fix plot request ...
91
		}
26a23052   Benjamin Renard   Add Interval Tick...
92
			
7d84634e   Benjamin Renard   Fix plot request ...
93
94
95
96
		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...
97
			
7d84634e   Benjamin Renard   Fix plot request ...
98
99
100
101
		//prefix
		$filePrefix = "plot_";
		if ($input->{'file-prefix'} && ($input->{'file-prefix'} != ""))
			$filePrefix = $input->{'file-prefix'};
70e82c1f   Benjamin Renard   Fix doPlot
102
		$filePrefix .= $input->{'tab-index'};
26a23052   Benjamin Renard   Add Interval Tick...
103
			
7d84634e   Benjamin Renard   Fix plot request ...
104
		$plotOutputNode->setFilePrefix($filePrefix);
26a23052   Benjamin Renard   Add Interval Tick...
105
			
7d84634e   Benjamin Renard   Fix plot request ...
106
107
		//page
		$pageNode = $plotOutputNode->getPage();
26a23052   Benjamin Renard   Add Interval Tick...
108
			
7d84634e   Benjamin Renard   Fix plot request ...
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
		$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...
132
			
7d84634e   Benjamin Renard   Fix plot request ...
133
		$pageNode->setFormat($fileFormat);
26a23052   Benjamin Renard   Add Interval Tick...
134
			
7d84634e   Benjamin Renard   Fix plot request ...
135
		$this->unmarshallTitle($input, 'page-title', $pageNode->getTitle());
26a23052   Benjamin Renard   Add Interval Tick...
136
			
7d84634e   Benjamin Renard   Fix plot request ...
137
138
139
140
141
142
143
144
145
146
147
		$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...
148
			
7d84634e   Benjamin Renard   Fix plot request ...
149
150
151
152
153
154
155
156
157
158
159
		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...
160
			
7d84634e   Benjamin Renard   Fix plot request ...
161
162
		switch ($input->{'page-mode'})
		{
05da1b4d   Benjamin Renard   Draw instant plot...
163
				
7d84634e   Benjamin Renard   Fix plot request ...
164
165
166
167
168
169
170
171
			case 'grayscale' :
				$pageNode->setMode(RequestOutputPlotPageModeEnum::GRAYSCALE);
				break;
			case 'color' :
			default:
				$pageNode->setMode(RequestOutputPlotPageModeEnum::COLOR);
				break;
		}
26a23052   Benjamin Renard   Add Interval Tick...
172
			
7d84634e   Benjamin Renard   Fix plot request ...
173
174
175
176
177
		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...
178
			
7d84634e   Benjamin Renard   Fix plot request ...
179
180
		if ($input->{'page-font-activated'})
			$this->unmarshallFont($input, 'page-font', $pageNode->getFont());
26a23052   Benjamin Renard   Add Interval Tick...
181
			
7d84634e   Benjamin Renard   Fix plot request ...
182
183
		//Superpose mode
		$pageNode->setSuperposeMode($input->{'page-superpose-mode'} ? "true": "false");
26a23052   Benjamin Renard   Add Interval Tick...
184
			
7d84634e   Benjamin Renard   Fix plot request ...
185
186
		//Layout
		$this->unmarshallLayout($input, $pageNode);
26a23052   Benjamin Renard   Add Interval Tick...
187
			
7d84634e   Benjamin Renard   Fix plot request ...
188
189
		foreach ($input->{'panels'} as $panelData)
			$this->unmarshallPanel($panelData, $pageNode, $paramsNode);
26a23052   Benjamin Renard   Add Interval Tick...
190
			
7d84634e   Benjamin Renard   Fix plot request ...
191
192
193
194
195
196
197
198
199
200
		if ($this->isInteractiveRequest || $this->isFromWS)
		{
			$resultFile = $filePrefix."_*".$extension;
			$waitingResultFile = $filePrefix.$extension;
		}
		else
		{
			$resultFile = $filePrefix."_*".$compression;
			$waitingResultFile = $filePrefix.$compression;
		}
26a23052   Benjamin Renard   Add Interval Tick...
201
			
7d84634e   Benjamin Renard   Fix plot request ...
202
203
		if ($this->isInteractiveRequest)
		{
70e82c1f   Benjamin Renard   Fix doPlot
204
205
206
			$this->interactiveTimeSelectionState[PLOT_RESULT_FILE_KEY."_".$input->{'tab-index'}] = $isIntervalRequest;
                        $this->interactivePlotTitle[PLOT_RESULT_FILE_KEY."_".$input->{'tab-index'}] = $input->{'tab-title'};
			$this->interactivePlotIndex[PLOT_RESULT_FILE_KEY."_".$input->{'tab-index'}] = $input->{'tab-index'};
7d84634e   Benjamin Renard   Fix plot request ...
207
			$this->interactivePreview = isset($input->{'interactive-preview'}) && ($input->{'interactive-preview'});
70e82c1f   Benjamin Renard   Fix doPlot
208
			$this->paramsData->addWaitingResult(PLOT_RESULT_FILE_KEY."_".$input->{'tab-index'}, $waitingResultFile);
7d84634e   Benjamin Renard   Fix plot request ...
209
210
211
		}
		else
			$this->paramsData->addWaitingResult(PLOT_RESULT_FILE_KEY, $waitingResultFile);
26a23052   Benjamin Renard   Add Interval Tick...
212
			
7d84634e   Benjamin Renard   Fix plot request ...
213
214
215
216
		//Remove old result files
		foreach (glob($this->paramsData->getWorkingPath().$resultFile) as $oldFile) {
			unlink($oldFile);
		}
26a23052   Benjamin Renard   Add Interval Tick...
217
			
7d84634e   Benjamin Renard   Fix plot request ...
218
219
220
221
		//Post process command to apply to the result file
		if ($postProcessCmd != "")
			$postProcessCmd .= " | ";
		$postProcessCmd .= "mv ".$resultFile." ".$waitingResultFile;
26a23052   Benjamin Renard   Add Interval Tick...
222
			
7d84634e   Benjamin Renard   Fix plot request ...
223
224
225
226
227
228
229
230
		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...
231
232
233
234
		}
		
		$this->paramsData->setBatchEnable(!(($fileFormat == RequestOutputPlotPageFormatEnum::PNG) && $this->isInteractiveRequest));
		$this->paramsData->setPostCmd($postProcessCmd);
26a23052   Benjamin Renard   Add Interval Tick...
235
236
237
		return $this->paramsData;
	}
	
7d84634e   Benjamin Renard   Fix plot request ...
238
	protected function unmarshallLayout($request, $pageNode)
26a23052   Benjamin Renard   Add Interval Tick...
239
	{
7d84634e   Benjamin Renard   Fix plot request ...
240
		switch ($request->{'page-layout-type'})
26a23052   Benjamin Renard   Add Interval Tick...
241
242
243
		{
			case 'vertical' :
				$pageNode->getLayout()->setType(RequestOutputPlotLayoutTypeEnum::VERTICAL);
7d84634e   Benjamin Renard   Fix plot request ...
244
245
246
247
248
249
250
251
252
253
254
255
				$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...
256
257
258
				break;
			case 'auto' :
				$pageNode->getLayout()->setType(RequestOutputPlotLayoutTypeEnum::AUTO);
7d84634e   Benjamin Renard   Fix plot request ...
259
260
261
262
				$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...
263
264
265
				break;
			case 'manual' :
				$pageNode->getLayout()->setType(RequestOutputPlotLayoutTypeEnum::MANUAL);
7d84634e   Benjamin Renard   Fix plot request ...
266
267
				$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...
268
				$pageNode->setDefaultTimePlotXMargin($timePlotLeftMargin, $timePlotRightMargin);
7d84634e   Benjamin Renard   Fix plot request ...
269
270
				$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...
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
304
305
306
307
308
				$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...
309
310
		if (isset($panelData->{'id'}))
			$panelNode->setId($panelData->{'id'});
0a87e436   Hacene SI HADJ MOHAND   parameters resolue
311
312
313
314
315

                //Panel id
        	if (isset($panelData->{'panel-index'}))
                       $panelNode->setIndex($panelData->{'panel-index'});
	
a88159f7   Benjamin Renard   Add panel index s...
316
		
26a23052   Benjamin Renard   Add Interval Tick...
317
318
319
		//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...
320

26a23052   Benjamin Renard   Add Interval Tick...
321
322
323
324
325
326
327
		//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...
328
		$this->isInstantPlot = false;
26a23052   Benjamin Renard   Add Interval Tick...
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
407
408
409
410
411
412
413
		$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...
414
415
				if ($panelData->{'panel-epoch-centertimeid'} != '')
					$plotNode->setCenterTimeId($panelData->{'panel-epoch-centertimeid'});
26a23052   Benjamin Renard   Add Interval Tick...
416
417
418
419
420
421
422
				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...
423
				$this->isInstantPlot = true;
26a23052   Benjamin Renard   Add Interval Tick...
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
475
476
477
478
479
480
481
				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...
482
483
		if (isset($axisData->{'axis-reverse'}))
			$axisNode->setReverse($axisData->{'axis-reverse'} ? "true" : "false");
26a23052   Benjamin Renard   Add Interval Tick...
484
485
486
487
488
489
490
491
492
493
494
495
496
497
		
		//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...
498
499
		if (isset($axisData->{'axis-range-extend'}))
			$axisNode->getRange()->setExtend($axisData->{'axis-range-extend'} ? "true" : "false");
26a23052   Benjamin Renard   Add Interval Tick...
500
501
		
		//axis color
02abc780   Benjamin Renard   Support request f...
502
503
		if (isset($axisData->{'axis-color'}))
			$axisNode->setColor($this->hexColor2KernelColor($axisData->{'axis-color'}));
26a23052   Benjamin Renard   Add Interval Tick...
504
505
		
		//axis thickness
02abc780   Benjamin Renard   Support request f...
506
507
		if (isset($axisData->{'axis-thickness'}))
			$axisNode->setThickness($axisData->{'axis-thickness'});
26a23052   Benjamin Renard   Add Interval Tick...
508
509
510
511
512
513
514
515
516
517
518
519
		
		//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...
520
521
		if (isset($axisData->{'axis-grid-minor'}))
			$axisNode->getTick()->setMinorGrid($axisData->{'axis-grid-minor'} ? "true" : "false");
3741e4bb   Hacene SI HADJ MOHAND   6954 ok
522

05da1b4d   Benjamin Renard   Draw instant plot...
523
524
		if (isset($axisData->{'axis-grid-major'}))
			$axisNode->getTick()->setMajorGrid($axisData->{'axis-grid-major'} ? "true" : "false");
6e8d82dc   Hacene SI HADJ MOHAND   us Ok
525
526
527
                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
528
529
                        $axisNode->getTick()->setMinorGridNumber($axisData->{'axis-grid-minor-number'});
	
6e8d82dc   Hacene SI HADJ MOHAND   us Ok
530
		   if (isset($axisData->{'axis-grid-major-number'}) && $axisData->{'axis-grid-major-number'} != 0)
3741e4bb   Hacene SI HADJ MOHAND   6954 ok
531
                        $axisNode->getTick()->setMajorGridNumber($axisData->{'axis-grid-major-number'});
6e8d82dc   Hacene SI HADJ MOHAND   us Ok
532
                }elseif($axisData->{'axis-grid-specify-ticks-spacing'}){
3741e4bb   Hacene SI HADJ MOHAND   6954 ok
533

6e8d82dc   Hacene SI HADJ MOHAND   us Ok
534
		   if (isset($axisData->{'axis-grid-major-space'}) && $axisData->{'axis-grid-major-space'} != 0)
3741e4bb   Hacene SI HADJ MOHAND   6954 ok
535
536
                        $axisNode->getTick()->setMajorGridSpace($axisData->{'axis-grid-major-space'});
               
6e8d82dc   Hacene SI HADJ MOHAND   us Ok
537
                   if (isset($axisData->{'axis-grid-minor-space'}) && $axisData->{'axis-grid-minor-space'} != 0)
3741e4bb   Hacene SI HADJ MOHAND   6954 ok
538
                        $axisNode->getTick()->setMinorGridSpace($axisData->{'axis-grid-minor-space'});
6e8d82dc   Hacene SI HADJ MOHAND   us Ok
539
                }
3741e4bb   Hacene SI HADJ MOHAND   6954 ok
540
541
542


                //legend
05da1b4d   Benjamin Renard   Draw instant plot...
543
544
		if (isset($axisData->{'axis-legend-text'}) && $axisData->{'axis-legend-text'} != '')
		{
26a23052   Benjamin Renard   Add Interval Tick...
545
			$axisNode->getLegend()->setText($axisData->{'axis-legend-text'});
05da1b4d   Benjamin Renard   Draw instant plot...
546
547
548
			$axisNode->getLegend()->setColor($this->hexColor2KernelColor($axisData->{'axis-legend-color'}));
			$this->unmarshallLabel($axisData, "axis-legend", $axisNode->getLegend());
		}
26a23052   Benjamin Renard   Add Interval Tick...
549
550
		
		//Show legend
05da1b4d   Benjamin Renard   Draw instant plot...
551
552
		if (isset($axisData->{'axis-legend-activated'}))
			$axisNode->setShowLegend($axisData->{'axis-legend-activated'} ? "true" : "false");
26a23052   Benjamin Renard   Add Interval Tick...
553
554
		
		//Show tick marks
05da1b4d   Benjamin Renard   Draw instant plot...
555
556
		if (isset($axisData->{'axis-tick-showmarks'}))
			$axisNode->setShowTickMarks($axisData->{'axis-tick-showmarks'} ? "true" : "false");
26a23052   Benjamin Renard   Add Interval Tick...
557
558
559
560
561
562
563
564
565
566
567
568
569
570
		
		//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 ...
571
		$xIds = array();
26a23052   Benjamin Renard   Add Interval Tick...
572
573
		if ($isScatter)
		{
f822811a   Benjamin Renard   Implements multi ...
574
			$crtXId = 0;
26a23052   Benjamin Renard   Add Interval Tick...
575
576
577
578
			foreach ($paramsData as $paramData)
			{
				if ($paramData->{'param-drawing-object'}->{'serie-xaxis-param'} == '')
					continue;
f822811a   Benjamin Renard   Implements multi ...
579
580
581
582
				if (array_key_exists($paramData->{'param-drawing-object'}->{'serie-xaxis-param'}, $xIds)) {
					//x param already exists
					continue;
				}
26a23052   Benjamin Renard   Add Interval Tick...
583
				
bf27ba04   Benjamin Renard   Add templated par...
584
				$paramXInfo = $this->paramManager->addExistingParam($paramData->{'param-drawing-object'}->{'serie-xaxis-param'}, $this->paramsData);
26a23052   Benjamin Renard   Add Interval Tick...
585
586
587
588
589
590
591
592
593
				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 ...
594
							$xParamNode->addXSerie(-1, $crtXId, $paramData->{'param-drawing-object'}->{'serie-xvalue-min'}, $paramData->{'param-drawing-object'}->{'serie-xvalue-max'});
26a23052   Benjamin Renard   Add Interval Tick...
595
						else if (count($paramXInfo['indexes']) == 1)
f822811a   Benjamin Renard   Implements multi ...
596
							$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...
597
598
599
600
601
602
						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 ...
603
604
				$xIds[$paramData->{'param-drawing-object'}->{'serie-xaxis-param'}] = $crtXId;
				++$crtXId;
26a23052   Benjamin Renard   Add Interval Tick...
605
606
607
608
609
610
611
			}
		}
		
		//Main drawing element parameter
		$drawingEltIndex = 0;
		foreach ($paramsData as $paramData)
		{
52c1e291   Benjamin Renard   Generate TT and c...
612
613
			$isTTCat = ($paramData->{'param-type'} == 'ttcat');

26a23052   Benjamin Renard   Add Interval Tick...
614
			//Param
52c1e291   Benjamin Renard   Generate TT and c...
615
616
617
618
619
620
			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...
621
622
			
			$paramInfo['indexes'] = array();
93c50989   Benjamin Renard   Support Tab2D par...
623
624

			$this->paramManager->applyRangesAndIndexes($this->paramsData, $paramData, !$this->isInstantPlot, $paramInfo);
0a87e436   Hacene SI HADJ MOHAND   parameters resolue
625
626
		
	
26a23052   Benjamin Renard   Add Interval Tick...
627
			$requestParamsNode->addParam($paramInfo['id']);
0a87e436   Hacene SI HADJ MOHAND   parameters resolue
628
		       	
26a23052   Benjamin Renard   Add Interval Tick...
629
			$colorSerieId = -1;
8ade06fe   Benjamin Renard   Improve config load
630
			if (!empty($paramData->{'param-drawing-object'}->{'serie-colored-param'}))
26a23052   Benjamin Renard   Add Interval Tick...
631
632
				$colorSerieId = $drawingEltIndex;

f822811a   Benjamin Renard   Implements multi ...
633
634
			$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...
635
636
637
638
			switch ($paramData->{'param-drawing-type'})
			{
				case 'serie' :
					$paramNode = $plotNode->getParams()->getParamById($paramInfo['id']);
f822811a   Benjamin Renard   Implements multi ...
639
					$this->unmarshallSerie($paramData, $requestParamsNode, $plotNode, $paramNode, $paramInfo['indexes'], $xId, $colorSerieId, false);
26a23052   Benjamin Renard   Add Interval Tick...
640
641
642
					break;
				case 'orbit-serie' :
					$paramNode = $plotNode->getParams()->getParamById($paramInfo['id']);
f822811a   Benjamin Renard   Implements multi ...
643
					$this->unmarshallSerie($paramData, $requestParamsNode, $plotNode, $paramNode, -1, $xId, $colorSerieId, true);
26a23052   Benjamin Renard   Add Interval Tick...
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
					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
668
669
670
				case 'ispectro' :
					$paramNode = $plotNode->getParams()->getParamById($paramInfo['id']);
					$this->unmarshallInstantSpectro($paramData->{'param-drawing-object'}, $plotNode, $paramNode, $paramInfo['indexes']);
044a9305   Benjamin Renard   Add intervals dra...
671
672
673
674
675
					break;
				case 'intervals' :
					$paramNode = $plotNode->getParams()->getParamById($paramInfo['id']);
					$this->unmarshallIntervals($paramData->{'param-drawing-object'}, $paramNode);
					break;
26a23052   Benjamin Renard   Add Interval Tick...
676
677
678
679
680
681
682
683
684
685
				default :
					throw new Exception('Drawing type not implemented.');
			}
			++$drawingEltIndex;
		}
		
		//Colored parameter
		$drawingEltIndex = 0;
		foreach ($paramsData as $paramData)
		{
8ade06fe   Benjamin Renard   Improve config load
686
			if (empty($paramData->{'param-drawing-object'}->{'serie-colored-param'}))
26a23052   Benjamin Renard   Add Interval Tick...
687
688
689
690
691
			{
				++$drawingEltIndex;
				continue;
			}
			
bf27ba04   Benjamin Renard   Add templated par...
692
			$paramColoredInfo = $this->paramManager->addExistingParam($paramData->{'param-drawing-object'}->{'serie-colored-param'}, $this->paramsData);
26a23052   Benjamin Renard   Add Interval Tick...
693
694
695
696
697
698
699
700
701
702
			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...
703
				case 'orbit-serie' :
26a23052   Benjamin Renard   Add Interval Tick...
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
					//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 ...
719
	protected function unmarshallSerie($paramData, $requestParamsNode, $plotNode, $paramNode, $indexes, $xId, $colorSerieId, $isOrbitSerie)
26a23052   Benjamin Renard   Add Interval Tick...
720
721
722
723
724
725
726
	{
		$serieNodes = array();
		
		if (!$isOrbitSerie)
		{
			if (count($indexes) == 0)
			{
f822811a   Benjamin Renard   Implements multi ...
727
				$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...
728
				$serieNode->setId($paramData->{'id'});
60a1a563   Benjamin Renard   Add the possibili...
729
730
				if (!empty($paramData->{'param-drawing-object'}->{'serie-resolution'}))
					$serieNode->setResolution($paramData->{'param-drawing-object'}->{'serie-resolution'});
26a23052   Benjamin Renard   Add Interval Tick...
731
732
733
734
				$serieNodes[] = $serieNode;
			}
			foreach ($indexes as $index)
			{
f822811a   Benjamin Renard   Implements multi ...
735
				$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...
736
737
				if (count($indexes) == 1)
					$serieNode->setId($paramData->{'id'});
60a1a563   Benjamin Renard   Add the possibili...
738
739
				if (!empty($paramData->{'param-drawing-object'}->{'serie-resolution'}))
					$serieNode->setResolution($paramData->{'param-drawing-object'}->{'serie-resolution'});
26a23052   Benjamin Renard   Add Interval Tick...
740
741
742
743
744
				$serieNodes[] = $serieNode;
			}
		}
		else
		{
cb46dfbf   Benjamin Renard   Fix orbit serie a...
745
			$orbitSerie = $paramNode->addOrbitSerie($paramData->{'param-drawing-object'}->{'serie-yaxis'}, $colorSerieId);
26a23052   Benjamin Renard   Add Interval Tick...
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
848
849
850
851
852
853
854
855
			$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...
856
				$intervalTickNode->setMode(RequestOutputPlotSerieIntervalTicksModeEnum::SYMBOLONLY);
26a23052   Benjamin Renard   Add Interval Tick...
857
858
				break;
			case 'interval-index':
4f9a8e36   Benjamin Renard   Min/Max value def...
859
				$intervalTickNode->setMode(RequestOutputPlotSerieIntervalTicksModeEnum::INTERVALINDEX);
26a23052   Benjamin Renard   Add Interval Tick...
860
861
				break;
			case 'start-stop-time':
4f9a8e36   Benjamin Renard   Min/Max value def...
862
				$intervalTickNode->setMode(RequestOutputPlotSerieIntervalTicksModeEnum::STARTSTOPTIME);
26a23052   Benjamin Renard   Add Interval Tick...
863
864
865
				break;
			case 'start-time':
			default :
4f9a8e36   Benjamin Renard   Min/Max value def...
866
				$intervalTickNode->setMode(RequestOutputPlotSerieIntervalTicksModeEnum::STARTTIME);
26a23052   Benjamin Renard   Add Interval Tick...
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
		}
		
		//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...
888
				$minParamInfo = $this->paramManager->addExistingParam($serieData->{'serie-errorbar-minparam'}, $this->paramsData);
26a23052   Benjamin Renard   Add Interval Tick...
889
890
891
892
893
894
895
896
897
898
				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...
899
				$maxParamInfo = $this->paramManager->addExistingParam($serieData->{'serie-errorbar-maxparam'}, $this->paramsData);
26a23052   Benjamin Renard   Add Interval Tick...
900
901
902
903
904
905
906
907
908
909
910
911
912
				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...
913
				$deltaParamInfo = $this->paramManager->addExistingParam($serieData->{'serie-errorbar-deltaparam'}, $this->paramsData);
26a23052   Benjamin Renard   Add Interval Tick...
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
				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...
934
		$iserieNode = $paramNode->addInstantSerie('y-left');
26a23052   Benjamin Renard   Add Interval Tick...
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
		
		//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...
951
		$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...
952
953
	}
	
fc153c1c   Elena.Budnik   ispectro added
954
955
956
	protected function unmarshallInstantSpectro($paramDrawingData, $plotNode, $paramNode, $indexes)
	{
	//TBD how to process inexes if they are defined ? 
cb46dfbf   Benjamin Renard   Fix orbit serie a...
957
		$spectroNode = $paramNode->addInstantSpectro('y-left', $paramDrawingData->{'ispectro-dimonxaxis'});
fc153c1c   Elena.Budnik   ispectro added
958
959
	}
	
26a23052   Benjamin Renard   Add Interval Tick...
960
961
962
963
964
965
966
	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...
967
968
969
970
971

	protected function unmarshallIntervals($paramDrawingData, $paramNode)
	{
		$paramNode->addIntervals();
	}
26a23052   Benjamin Renard   Add Interval Tick...
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
1254
1255
1256
1257
1258
1259
1260
1261
	
	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...
1262
1263
			if ($inputData->{$keyPrefix.'-font-bold'})
			{
20e36076   Benjamin Renard   Update interface ...
1264
				$labelNode->setFontWeight("bold");
26a23052   Benjamin Renard   Add Interval Tick...
1265
1266
1267
			}
			if ($inputData->{$keyPrefix.'-font-italic'})
			{
20e36076   Benjamin Renard   Update interface ...
1268
				 $labelNode->setFontStyle("italic");
26a23052   Benjamin Renard   Add Interval Tick...
1269
			}
26a23052   Benjamin Renard   Add Interval Tick...
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
		}
		
	}
	
	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...
1297
			
26a23052   Benjamin Renard   Add Interval Tick...
1298
1299
1300
1301
1302
1303
1304
1305
1306
			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...
1307
1308
1309
1310
			case 'plain'           :
			default                :
				$curveNode->setStyle(RequestOutputPlotCurveStyleEnum::PLAIN);
				break;
26a23052   Benjamin Renard   Add Interval Tick...
1311
		}
02abc780   Benjamin Renard   Support request f...
1312
1313
1314
		
		if (isset($inputData->{$keyPrefix.'-width'}))
			$curveNode->setWidth($inputData->{$keyPrefix.'-width'});
26a23052   Benjamin Renard   Add Interval Tick...
1315
				
02abc780   Benjamin Renard   Support request f...
1316
		if (isset($inputData->{$keyPrefix.'-color'}) && ($inputData->{$keyPrefix.'-color'} != 'auto'))
26a23052   Benjamin Renard   Add Interval Tick...
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
1391
1392
1393
1394
1395
1396
1397
1398
			$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
1399
1400
1401
1402
1403
1404
1405
		if (!$data->getSuccess())
			return array(
					'success' => false,
					'message' => $data->getLastErrorMessage());
		
		switch ($data->getStatus())
		{
26a23052   Benjamin Renard   Add Interval Tick...
1406
1407
1408
1409
1410
1411
1412
1413
1414
			case ProcessStatusEnumClass::DONE :
				
				$result = array();
				foreach ($data->getWaitingResults() as $key => $waitingResult)
				{
					$contextResult = str_replace(".png","_context.xml",$waitingResult);
					
					$result[] = array(
						"id" => $key,
70e82c1f   Benjamin Renard   Fix doPlot
1415
						"title" => $this->interactivePlotTitle[$key],
05da1b4d   Benjamin Renard   Draw instant plot...
1416
						"preview" => $this->interactivePreview,
26a23052   Benjamin Renard   Add Interval Tick...
1417
						"isInterval" => $this->interactiveTimeSelectionState[$key],
70e82c1f   Benjamin Renard   Fix doPlot
1418
						"index" => $this->interactivePlotIndex[$key],
26a23052   Benjamin Renard   Add Interval Tick...
1419
1420
						"ttFileIndex" => $this->interactiveCrtTTFileIndex,
						"context" => IHMPlotContextFileClass::parse($this->getWorkingPath().$contextResult),
ba82a624   Benjamin Renard   Get kernel execut...
1421
1422
						"plot" => $waitingResult,
						"exectime" => $data->getExecTime(),
26a23052   Benjamin Renard   Add Interval Tick...
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
					);
				}
				
				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...
1435
						'killed'      => true);
22521f1c   Benjamin Renard   First commit
1436
			default :
e4eba677   Benjamin Renard   Get error message...
1437
				$errorMsg = $data->getErrorMsg();
22521f1c   Benjamin Renard   First commit
1438
1439
				return array(
				'success' => false,
e4eba677   Benjamin Renard   Get error message...
1440
				'message'   => 'Request processing error'.(!empty($errorMsg) ? "<br>(".$errorMsg.")" : ""));
26a23052   Benjamin Renard   Add Interval Tick...
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
		}
	}
	
	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."]";
	}
	
4a7023e8   Benjamin Renard   Fix interactive n...
1454
	private function saveIHMRequest($interactiveId, $input)
26a23052   Benjamin Renard   Add Interval Tick...
1455
	{
4a7023e8   Benjamin Renard   Fix interactive n...
1456
		$path = $this->getWorkingPath()."ihm.request.".$interactiveId;
26a23052   Benjamin Renard   Add Interval Tick...
1457
1458
		if (!is_dir($this->getWorkingPath()))
			mkdir($this->getWorkingPath(),0777);
22521f1c   Benjamin Renard   First commit
1459
1460
		$file = fopen($path, 'w');
		fwrite($file, json_encode($input));
26a23052   Benjamin Renard   Add Interval Tick...
1461
1462
1463
		fclose($file);
	}
	
4a7023e8   Benjamin Renard   Fix interactive n...
1464
	private function loadIHMRequest($interactiveId)
26a23052   Benjamin Renard   Add Interval Tick...
1465
	{
4a7023e8   Benjamin Renard   Fix interactive n...
1466
		$path = $this->getWorkingPath()."ihm.request.".$interactiveId;
22521f1c   Benjamin Renard   First commit
1467
		if (!file_exists($path))
26a23052   Benjamin Renard   Add Interval Tick...
1468
1469
1470
			return NULL;
		return json_decode(file_get_contents($path));
	}
a9d86eaa   Benjamin Renard   Fix zoom / unzoom
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490

	

	private function loadZoomList($interactiveId)
	{
		$path = $this->getWorkingPath()."zoom.list.".$interactiveId;
		if (!file_exists($path))
			return NULL;
		return json_decode(file_get_contents($path));
	}

	private function saveZoomList($interactiveId, $zoomList)
	{
		$path = $this->getWorkingPath()."zoom.list.".$interactiveId;
		if (!is_dir($this->getWorkingPath()))
			mkdir($this->getWorkingPath(),0777);
		$file = fopen($path, 'w');
		fwrite($file, json_encode($zoomList));
		fclose($file);
	}
26a23052   Benjamin Renard   Add Interval Tick...
1491
1492
1493
	
	private function unmarshallActionRequest($input)
	{
e8cefd97   Benjamin Renard   Interactive attac...
1494
		$actionInput    = $input->{'action'};
e8cefd97   Benjamin Renard   Interactive attac...
1495
		
4a7023e8   Benjamin Renard   Fix interactive n...
1496
		$plotInput = $this->loadIHMRequest($actionInput->{'interactiveId'});
26a23052   Benjamin Renard   Add Interval Tick...
1497
1498
		
		if (!isset($plotInput))
86756f46   Benjamin Renard   Remove multi plot...
1499
			throw new Exception('Cannot retrieve request input for interactive action.');
e8cefd97   Benjamin Renard   Interactive attac...
1500
1501
		
		switch ($actionInput->{'action'})
26a23052   Benjamin Renard   Add Interval Tick...
1502
1503
		{
			case 'zoom' :
e8cefd97   Benjamin Renard   Interactive attac...
1504
				return $this->unmarshallZoom($actionInput, $plotInput);
26a23052   Benjamin Renard   Add Interval Tick...
1505
1506
1507
1508
1509
1510
			case 'forward' :
			case 'halfforward' :
			case 'backward' :
			case 'halfbackward' :
			case 'extend' :
			case 'shift' :
e8cefd97   Benjamin Renard   Interactive attac...
1511
				return $this->unmarshallNavigation($actionInput, $plotInput);
26a23052   Benjamin Renard   Add Interval Tick...
1512
			case 'goto' :
e8cefd97   Benjamin Renard   Interactive attac...
1513
				return $this->unmarshallTTGoto($actionInput, $plotInput);
05da1b4d   Benjamin Renard   Draw instant plot...
1514
1515
			case 'instant' :
				return $this->unmarshallInstant($actionInput, $plotInput);
d3c3608d   Benjamin Renard   Add undo zoom
1516
1517
			case 'undozoom' :
				return $this->unmarshallUndoZoom($actionInput, $plotInput);
26a23052   Benjamin Renard   Add Interval Tick...
1518
1519
1520
1521
1522
			default :
				throw new Exception('Interactive action not implemented.');
		}
	}
	
d3c3608d   Benjamin Renard   Add undo zoom
1523
1524
1525
1526
1527
	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
		
a9d86eaa   Benjamin Renard   Fix zoom / unzoom
1528
		$zoomList = $this->loadZoomList($input->interactiveId);
d3c3608d   Benjamin Renard   Add undo zoom
1529
		
a9d86eaa   Benjamin Renard   Fix zoom / unzoom
1530
		if (!isset($zoomList))
d3c3608d   Benjamin Renard   Add undo zoom
1531
1532
1533
		{
			//Init zoom list
			$zoomList = (Object)array(
a9d86eaa   Benjamin Renard   Fix zoom / unzoom
1534
1535
				'times' => array(),
				'panels' => (Object)array()
d3c3608d   Benjamin Renard   Add undo zoom
1536
1537
1538
1539
1540
1541
			);
		}
		
		if ($input->{'axeId'} == 'timeAxis')
		{
			if ($isInterval)
a9d86eaa   Benjamin Renard   Fix zoom / unzoom
1542
				array_push ($zoomList->times, (Object)array(
d3c3608d   Benjamin Renard   Add undo zoom
1543
1544
1545
1546
1547
					'isInterval' => true,
					'min' => $minOrFileIndex,
					'max'  => $maxOrIntervalIndex
				));
			else
a9d86eaa   Benjamin Renard   Fix zoom / unzoom
1548
				array_push ($zoomList->times, (Object)array(
d3c3608d   Benjamin Renard   Add undo zoom
1549
1550
1551
1552
1553
1554
1555
						'isInterval' => false,
						'ttFileIndex' => $minOrFileIndex,
						'intIndex'  => $maxOrIntervalIndex
				));
		}
		else
		{
a9d86eaa   Benjamin Renard   Fix zoom / unzoom
1556
			if (!isset($zoomList->panels->{$input->{'panelId'}}))
d3c3608d   Benjamin Renard   Add undo zoom
1557
			{
a9d86eaa   Benjamin Renard   Fix zoom / unzoom
1558
				$zoomList->panels->{$input->{'panelId'}} = (Object) array(
d3c3608d   Benjamin Renard   Add undo zoom
1559
1560
1561
1562
						'axes' => (Object)array()
				);
			}
			
a9d86eaa   Benjamin Renard   Fix zoom / unzoom
1563
			if (!isset($zoomList->panels->{$input->{'panelId'}}->axes->{$input->{'axeId'}}))
d3c3608d   Benjamin Renard   Add undo zoom
1564
			{
a9d86eaa   Benjamin Renard   Fix zoom / unzoom
1565
				$zoomList->panels->{$input->{'panelId'}}->axes->{$input->{'axeId'}} = array();
d3c3608d   Benjamin Renard   Add undo zoom
1566
1567
			}
			
a9d86eaa   Benjamin Renard   Fix zoom / unzoom
1568
			array_push ($zoomList->panels->{$input->{'panelId'}}->axes->{$input->{'axeId'}}, (Object)array(
d3c3608d   Benjamin Renard   Add undo zoom
1569
1570
1571
1572
1573
					'min' => $minOrFileIndex,
					'max'  => $maxOrIntervalIndex
			));
		}
		
a9d86eaa   Benjamin Renard   Fix zoom / unzoom
1574
		$this->saveZoomList($input->interactiveId, $zoomList);
d3c3608d   Benjamin Renard   Add undo zoom
1575
1576
	}
	
a9d86eaa   Benjamin Renard   Fix zoom / unzoom
1577
	private function resetZoomList($interactiveId, $resetOnlyTimeZoom = false)
d3c3608d   Benjamin Renard   Add undo zoom
1578
	{
a9d86eaa   Benjamin Renard   Fix zoom / unzoom
1579
1580
1581
1582
1583
		if (!$resetOnlyTimeZoom) {
			$zoomList = (Object)array(
				'times' => array(),
				'panels' => (Object)array()
			);
d3c3608d   Benjamin Renard   Add undo zoom
1584
		}
a9d86eaa   Benjamin Renard   Fix zoom / unzoom
1585
1586
1587
1588
1589
1590
		else {
			$zoomList = $this->loadZoomList($interactiveId);
			$zoomList->times = array();
		}

		$this->saveZoomList($interactiveId, $zoomList);
d3c3608d   Benjamin Renard   Add undo zoom
1591
1592
1593
1594
	}
	
	private function undoZoomInList($input)
	{
a9d86eaa   Benjamin Renard   Fix zoom / unzoom
1595
		$zoomList = $this->loadZoomList($input->interactiveId);
d3c3608d   Benjamin Renard   Add undo zoom
1596
1597
		
		$result = NULL;
a9d86eaa   Benjamin Renard   Fix zoom / unzoom
1598
		if ($zoomList)
d3c3608d   Benjamin Renard   Add undo zoom
1599
1600
1601
		{
			if ($input->{'axeId'} == 'timeAxis')
			{
a9d86eaa   Benjamin Renard   Fix zoom / unzoom
1602
				if (count($zoomList->times) <= 0)
d3c3608d   Benjamin Renard   Add undo zoom
1603
					return NULL;
a9d86eaa   Benjamin Renard   Fix zoom / unzoom
1604
				$result = array_pop($zoomList->times);		
d3c3608d   Benjamin Renard   Add undo zoom
1605
1606
1607
			}
			else
			{
a9d86eaa   Benjamin Renard   Fix zoom / unzoom
1608
				if (!isset($zoomList->panels->{$input->{'panelId'}}))
d3c3608d   Benjamin Renard   Add undo zoom
1609
1610
					return NULL;
				
a9d86eaa   Benjamin Renard   Fix zoom / unzoom
1611
				if (!isset($zoomList->panels->{$input->{'panelId'}}->axes->{$input->{'axeId'}}))
d3c3608d   Benjamin Renard   Add undo zoom
1612
1613
					return NULL;
				
a9d86eaa   Benjamin Renard   Fix zoom / unzoom
1614
				$result = array_pop($zoomList->panels->{$input->{'panelId'}}->axes->{$input->{'axeId'}});
d3c3608d   Benjamin Renard   Add undo zoom
1615
1616
1617
1618
1619
			}
		}
		else
			return NULL;
		
a9d86eaa   Benjamin Renard   Fix zoom / unzoom
1620
		$this->saveZoomList($input->interactiveId, $zoomList);
d3c3608d   Benjamin Renard   Add undo zoom
1621
1622
1623
1624
1625
		
		return $result;
	}
	
	private function unmarshallZoom($input, $plotInput, $isUndo = false)
26a23052   Benjamin Renard   Add Interval Tick...
1626
	{
26a23052   Benjamin Renard   Add Interval Tick...
1627
1628
1629
		if ($input->{'axeId'} == 'timeAxis')
		{
			//Zoom on Time Axis
a9d86eaa   Benjamin Renard   Fix zoom / unzoom
1630
			if ($plotInput->{'timesrc'} != 'Interval')
26a23052   Benjamin Renard   Add Interval Tick...
1631
			{
a9d86eaa   Benjamin Renard   Fix zoom / unzoom
1632
				$plotInput->{'timesrc'} = 'Interval';
7d84634e   Benjamin Renard   Fix plot request ...
1633
1634
				if (!$isUndo)
					$this->addZoomInList($input,false,
a9d86eaa   Benjamin Renard   Fix zoom / unzoom
1635
1636
							isset($plotInput->{'ttFileIndex'}) ? $plotInput->{'ttFileIndex'} : 0,
							isset($plotInput->{'intIndex'}) ? $plotInput->{'intIndex'} : 0);
26a23052   Benjamin Renard   Add Interval Tick...
1637
1638
1639
			}
			else
			{
7d84634e   Benjamin Renard   Fix plot request ...
1640
				if (!$isUndo)
a9d86eaa   Benjamin Renard   Fix zoom / unzoom
1641
					$this->addZoomInList($input,true,$plotInput->{'startDate'},$plotInput->{'stopDate'});
26a23052   Benjamin Renard   Add Interval Tick...
1642
			}
a9d86eaa   Benjamin Renard   Fix zoom / unzoom
1643
1644
			$plotInput->{'startDate'} = $input->{'min'};
			$plotInput->{'stopDate'} = $input->{'max'};
e8cefd97   Benjamin Renard   Interactive attac...
1645
				
d3c3608d   Benjamin Renard   Add undo zoom
1646
			$plotInput->{'force-time-zoom-reset'} = false;
a9d86eaa   Benjamin Renard   Fix zoom / unzoom
1647
			$this->saveIHMRequest($input->interactiveId, $plotInput);
26a23052   Benjamin Renard   Add Interval Tick...
1648
1649
1650
1651
			return $plotInput;
		}
		
		//Digital axis zoom
a9d86eaa   Benjamin Renard   Fix zoom / unzoom
1652
		foreach ($plotInput->{'panels'} as $panel)
26a23052   Benjamin Renard   Add Interval Tick...
1653
1654
1655
1656
1657
1658
1659
1660
		{
			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
1661
1662
						$oldMin = $axis->{'axis-range-min'};
						$oldMax = $axis->{'axis-range-max'};
26a23052   Benjamin Renard   Add Interval Tick...
1663
1664
						$axis->{'axis-range-min'} = $input->{'min'};
						$axis->{'axis-range-max'} = $input->{'max'};
a9d86eaa   Benjamin Renard   Fix zoom / unzoom
1665
						$this->saveIHMRequest($input->interactiveId, $plotInput);
26a23052   Benjamin Renard   Add Interval Tick...
1666
1667
						//Do not save 'force-single-replot' in request file!
						$plotInput->{'force-single-replot'} = true;
d3c3608d   Benjamin Renard   Add undo zoom
1668
1669
1670
						$plotInput->{'force-time-zoom-reset'} = false;
						if (!$isUndo)
							$this->addZoomInList($input,true,$oldMin,$oldMax);
26a23052   Benjamin Renard   Add Interval Tick...
1671
1672
1673
1674
1675
1676
1677
1678
1679
						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
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
	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...
1701
1702
	private function unmarshallNavigation($input, $plotInput)
	{
4a7023e8   Benjamin Renard   Fix interactive n...
1703
1704
		$startTime = $plotInput->{'startDate'};
		$stopTime = $plotInput->{'stopDate'};
26a23052   Benjamin Renard   Add Interval Tick...
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
1739
1740
1741
1742
1743
1744
1745
1746
		
		//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
4a7023e8   Benjamin Renard   Fix interactive n...
1747
1748
		$plotInput->{'startDate'} = $startTime;
		$plotInput->{'stopDate'} = $stopTime;
26a23052   Benjamin Renard   Add Interval Tick...
1749
		
d3c3608d   Benjamin Renard   Add undo zoom
1750
		$plotInput->{'force-time-zoom-reset'} = true;
4a7023e8   Benjamin Renard   Fix interactive n...
1751
		$this->saveIHMRequest($input->interactiveId, $plotInput);
26a23052   Benjamin Renard   Add Interval Tick...
1752
1753
1754
1755
1756
		return $plotInput;
	}
	
	private function unmarshallTTGoto($input, $plotInput)
	{
419a700b   Benjamin Renard   Fix TT goto
1757
1758
1759
		$plotInput->{'timesrc'} = 'TimeTable';
		$plotInput->{'ttFileIndex'} = $input->{'ttFileIndex'};
		$plotInput->{'intIndex'} = $input->{'intIndex'};
e8cefd97   Benjamin Renard   Interactive attac...
1760
		
d3c3608d   Benjamin Renard   Add undo zoom
1761
		$plotInput->{'force-time-zoom-reset'} = true;
419a700b   Benjamin Renard   Fix TT goto
1762
		$this->saveIHMRequest($input->interactiveId, $plotInput);
e8cefd97   Benjamin Renard   Interactive attac...
1763
1764
1765
		return $plotInput;
	}
	
05da1b4d   Benjamin Renard   Draw instant plot...
1766
1767
	private function unmarshallInstant($input, $plotInput)
	{
05da1b4d   Benjamin Renard   Draw instant plot...
1768
1769
		//Find current panel
		$crtPanel = NULL;
c2d88cc5   Benjamin Renard   Fix instant plot
1770
		foreach ($plotInput->{'panels'} as $panel)
05da1b4d   Benjamin Renard   Draw instant plot...
1771
1772
1773
1774
1775
1776
1777
1778
1779
1780
1781
1782
1783
1784
1785
1786
1787
1788
1789
1790
		{
			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')
			{
0a87e436   Hacene SI HADJ MOHAND   parameters resolue
1791
				$crtParam = $param;                                
05da1b4d   Benjamin Renard   Draw instant plot...
1792
1793
1794
1795
1796
1797
1798
1799
1800
1801
1802
1803
1804
1805
1806
1807
1808
1809
1810
1811
1812
1813
1814
1815
1816
1817
1818
1819
1820
1821
1822
1823
1824
1825
1826
1827
1828
1829
1830
1831
1832
1833
1834
				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",
05da1b4d   Benjamin Renard   Draw instant plot...
1835
1836
1837
			"timesrc" => "Interval",
			"startDate" => date("Y-m-dTH:i:s", $timeStamp - 3600),
			"stopDate" => date("Y-m-dTH:i:s", $timeStamp + 3600),
05da1b4d   Benjamin Renard   Draw instant plot...
1838
			"id" => 1,
c2d88cc5   Benjamin Renard   Fix instant plot
1839
1840
1841
1842
1843
			"page-margins-activated" => $plotInput->{"page-margins-activated"},
			"page-margin-x" => $plotInput->{"page-margin-x"},
			"page-margin-y" => $plotInput->{"page-margin-y"},
			"page-orientation" => $plotInput->{"page-orientation"},
			"page-dimension" => $plotInput->{"page-dimension"},
05da1b4d   Benjamin Renard   Draw instant plot...
1844
1845
1846
1847
1848
1849
1850
1851
1852
1853
1854
1855
1856
1857
			"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(),
0a87e436   Hacene SI HADJ MOHAND   parameters resolue
1858
1859
				"params" => array(),

05da1b4d   Benjamin Renard   Draw instant plot...
1860
1861
1862
1863
1864
1865
1866
1867
1868
1869
1870
1871
1872
1873
1874
1875
1876
1877
1878
1879
	    );
		
		$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...
1880
			"paramid" => $crtParam->{'paramid'},
8d780912   Benjamin Renard   Keep template arg...
1881
			"template_args" => $crtParam->{'template_args'},
05da1b4d   Benjamin Renard   Draw instant plot...
1882
1883
1884
1885
1886
1887
1888
			"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"
0a87e436   Hacene SI HADJ MOHAND   parameters resolue
1889
1890
1891
1892
1893
1894
1895
1896
1897
1898
1899
1900
1901
1902
1903
1904
1905
			),
                        "dim1-index"     => $crtParam->{'dim1-index'},
                        "dim1-sum-type"  => $crtParam->{'dim1-sum-type'},
                        "dim1-min-value" => $crtParam->{'dim1-min-value'},
                        "dim1-max-value" => $crtParam->{'dim1-max-value'},
                        "dim1-min-index" => $crtParam->{'dim1-min-index'},
                        "dim1-max-index" => $crtParam->{'dim1-max-index'},

                        "dim2-index"     => $crtParam->{'dim2-index'},
                        "dim2-sum-type"  => $crtParam->{'dim2-sum-type'},
                        "dim2-min-value" => $crtParam->{'dim2-min-value'},
                        "dim2-max-value" => $crtParam->{'dim2-max-value'},
                        "dim2-min-index" => $crtParam->{'dim2-min-index'},
                        "dim2-max-index" => $crtParam->{'dim2-max-index'},

                        "type" => $crtParam->{'type'}

05da1b4d   Benjamin Renard   Draw instant plot...
1906
		);
0a87e436   Hacene SI HADJ MOHAND   parameters resolue
1907
1908
                $instantPanel->{"params"}[] = $instantParam;

05da1b4d   Benjamin Renard   Draw instant plot...
1909
		
c2d88cc5   Benjamin Renard   Fix instant plot
1910
		$instantPlotInput->{"panels"}[] = $instantPanel;
0a87e436   Hacene SI HADJ MOHAND   parameters resolue
1911
1912
	        
                	
05da1b4d   Benjamin Renard   Draw instant plot...
1913
1914
		return $instantPlotInput;
	}
26a23052   Benjamin Renard   Add Interval Tick...
1915
}
8d780912   Benjamin Renard   Keep template arg...
1916
?>