Blame view

src/InputOutput/IHMImpl/Params/PlotImpl/IHMInputOutputParamsPlotClass.php 65.7 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;
ec574794   Benjamin Renard   Implements multip...
23
24

	protected $isMultiPlot = FALSE;
26a23052   Benjamin Renard   Add Interval Tick...
25
26
27
28
29
30
	
	/*
	 * @brief method to unmarshall a plot request
	*/
	protected function unmarshallRequest($input)
	{
97a69b20   Benjamin Renard   Fix most of error...
31
		$forceTimeZoomReset = false;
22253da3   Benjamin Renard   Fix zoom reset
32
		$resetZoom = false;
d3c3608d   Benjamin Renard   Add undo zoom
33
		
26a23052   Benjamin Renard   Add Interval Tick...
34
		if (isset($input->{'action'}))
d3c3608d   Benjamin Renard   Add undo zoom
35
		{
26a23052   Benjamin Renard   Add Interval Tick...
36
			$input = $this->unmarshallActionRequest($input);
d3c3608d   Benjamin Renard   Add undo zoom
37
38
			$forceTimeZoomReset = isset($input->{'force-time-zoom-reset'}) ? $input->{'force-time-zoom-reset'} : false;
		}
26a23052   Benjamin Renard   Add Interval Tick...
39
		else
d3c3608d   Benjamin Renard   Add undo zoom
40
41
		{
			$resetZoom = true;
26a23052   Benjamin Renard   Add Interval Tick...
42
			//save request
4a7023e8   Benjamin Renard   Fix interactive n...
43
			$this->saveIHMRequest(PLOT_RESULT_FILE_KEY."_".$input->{'tab-index'}, $input);
d3c3608d   Benjamin Renard   Add undo zoom
44
45
		}
			
26a23052   Benjamin Renard   Add Interval Tick...
46
		//Request
26a23052   Benjamin Renard   Add Interval Tick...
47
		$this->isInteractiveRequest = ($input->{'file-output'} == 'INTERACTIVE');
02abc780   Benjamin Renard   Support request f...
48
		$this->isFromWS = ($input->{'file-output'} == 'WS');
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
			
7d14181a   Benjamin Renard   Fix multi-request...
53
		$requestNode = $this->paramsData->addRequestNode($input->{'tab-index'});
7d84634e   Benjamin Renard   Fix plot request ...
54
55
		$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
		//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'};
		}
7d14181a   Benjamin Renard   Fix multi-request...
66
		$this->unmarshallTimeDefinition($input, $input->{'tab-index'}, $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
		//Post process command to apply to the result file
ec574794   Benjamin Renard   Implements multip...
219
		$postProcessCmd = $this->paramsData->getPostCmd();
7d84634e   Benjamin Renard   Fix plot request ...
220
221
222
		if ($postProcessCmd != "")
			$postProcessCmd .= " | ";
		$postProcessCmd .= "mv ".$resultFile." ".$waitingResultFile;
26a23052   Benjamin Renard   Add Interval Tick...
223
			
7d84634e   Benjamin Renard   Fix plot request ...
224
225
226
227
228
229
230
231
		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...
232
233
234
235
		}
		
		$this->paramsData->setBatchEnable(!(($fileFormat == RequestOutputPlotPageFormatEnum::PNG) && $this->isInteractiveRequest));
		$this->paramsData->setPostCmd($postProcessCmd);
26a23052   Benjamin Renard   Add Interval Tick...
236
237
238
		return $this->paramsData;
	}
	
7d84634e   Benjamin Renard   Fix plot request ...
239
	protected function unmarshallLayout($request, $pageNode)
26a23052   Benjamin Renard   Add Interval Tick...
240
	{
7d84634e   Benjamin Renard   Fix plot request ...
241
		switch ($request->{'page-layout-type'})
26a23052   Benjamin Renard   Add Interval Tick...
242
243
244
		{
			case 'vertical' :
				$pageNode->getLayout()->setType(RequestOutputPlotLayoutTypeEnum::VERTICAL);
7d84634e   Benjamin Renard   Fix plot request ...
245
246
247
248
249
250
251
252
253
254
255
256
				$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...
257
258
259
				break;
			case 'auto' :
				$pageNode->getLayout()->setType(RequestOutputPlotLayoutTypeEnum::AUTO);
7d84634e   Benjamin Renard   Fix plot request ...
260
261
262
263
				$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...
264
265
266
				break;
			case 'manual' :
				$pageNode->getLayout()->setType(RequestOutputPlotLayoutTypeEnum::MANUAL);
7d84634e   Benjamin Renard   Fix plot request ...
267
268
				$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...
269
				$pageNode->setDefaultTimePlotXMargin($timePlotLeftMargin, $timePlotRightMargin);
7d84634e   Benjamin Renard   Fix plot request ...
270
271
				$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...
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
309
				$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...
310
311
		if (isset($panelData->{'id'}))
			$panelNode->setId($panelData->{'id'});
0a87e436   Hacene SI HADJ MOHAND   parameters resolue
312
313
314
315
316

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

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

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

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


                //legend
05da1b4d   Benjamin Renard   Draw instant plot...
544
545
		if (isset($axisData->{'axis-legend-text'}) && $axisData->{'axis-legend-text'} != '')
		{
26a23052   Benjamin Renard   Add Interval Tick...
546
			$axisNode->getLegend()->setText($axisData->{'axis-legend-text'});
05da1b4d   Benjamin Renard   Draw instant plot...
547
		}
d62f9945   Benjamin Renard   Improve instant c...
548
549
550
                $axisNode->getLegend()->setColor($this->hexColor2KernelColor($axisData->{'axis-legend-color'}));
                $this->unmarshallLabel($axisData, "axis-legend", $axisNode->getLegend());

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

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

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

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

	protected function unmarshallIntervals($paramDrawingData, $paramNode)
	{
		$paramNode->addIntervals();
	}
26a23052   Benjamin Renard   Add Interval Tick...
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
	
	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'});
d62f9945   Benjamin Renard   Improve instant c...
1227
		}
26a23052   Benjamin Renard   Add Interval Tick...
1228
		
d62f9945   Benjamin Renard   Improve instant c...
1229
1230
1231
1232
1233
1234
1235
1236
1237
		switch ($inputData->{$keyPrefix.'-position'})
		{
			case 'top' :
				$titleNode->setPosition(RequestOutputPlotTitlePosition::TOP);
				break;
			case 'bottom' :
				$titleNode->setPosition(RequestOutputPlotTitlePosition::BOTTOM);
				break;
		}
26a23052   Benjamin Renard   Add Interval Tick...
1238
		
d62f9945   Benjamin Renard   Improve instant c...
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
		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;
26a23052   Benjamin Renard   Add Interval Tick...
1250
		}
d62f9945   Benjamin Renard   Improve instant c...
1251
1252
1253
1254
1255
			
		if ($inputData->{$keyPrefix.'-color'} != '')
			$titleNode->setColor($this->hexColor2KernelColor($inputData->{$keyPrefix.'-color'}));

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

	

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

		$this->saveZoomList($interactiveId, $zoomList);
d3c3608d   Benjamin Renard   Add undo zoom
1594
1595
1596
1597
	}
	
	private function undoZoomInList($input)
	{
a9d86eaa   Benjamin Renard   Fix zoom / unzoom
1598
		$zoomList = $this->loadZoomList($input->interactiveId);
d3c3608d   Benjamin Renard   Add undo zoom
1599
1600
		
		$result = NULL;
a9d86eaa   Benjamin Renard   Fix zoom / unzoom
1601
		if ($zoomList)
d3c3608d   Benjamin Renard   Add undo zoom
1602
1603
1604
		{
			if ($input->{'axeId'} == 'timeAxis')
			{
a9d86eaa   Benjamin Renard   Fix zoom / unzoom
1605
				if (count($zoomList->times) <= 0)
d3c3608d   Benjamin Renard   Add undo zoom
1606
					return NULL;
a9d86eaa   Benjamin Renard   Fix zoom / unzoom
1607
				$result = array_pop($zoomList->times);		
d3c3608d   Benjamin Renard   Add undo zoom
1608
1609
1610
			}
			else
			{
a9d86eaa   Benjamin Renard   Fix zoom / unzoom
1611
				if (!isset($zoomList->panels->{$input->{'panelId'}}))
d3c3608d   Benjamin Renard   Add undo zoom
1612
1613
					return NULL;
				
a9d86eaa   Benjamin Renard   Fix zoom / unzoom
1614
				if (!isset($zoomList->panels->{$input->{'panelId'}}->axes->{$input->{'axeId'}}))
d3c3608d   Benjamin Renard   Add undo zoom
1615
1616
					return NULL;
				
a9d86eaa   Benjamin Renard   Fix zoom / unzoom
1617
				$result = array_pop($zoomList->panels->{$input->{'panelId'}}->axes->{$input->{'axeId'}});
d3c3608d   Benjamin Renard   Add undo zoom
1618
1619
1620
1621
1622
			}
		}
		else
			return NULL;
		
a9d86eaa   Benjamin Renard   Fix zoom / unzoom
1623
		$this->saveZoomList($input->interactiveId, $zoomList);
d3c3608d   Benjamin Renard   Add undo zoom
1624
1625
1626
1627
1628
		
		return $result;
	}
	
	private function unmarshallZoom($input, $plotInput, $isUndo = false)
26a23052   Benjamin Renard   Add Interval Tick...
1629
	{
26a23052   Benjamin Renard   Add Interval Tick...
1630
1631
1632
		if ($input->{'axeId'} == 'timeAxis')
		{
			//Zoom on Time Axis
a9d86eaa   Benjamin Renard   Fix zoom / unzoom
1633
			if ($plotInput->{'timesrc'} != 'Interval')
26a23052   Benjamin Renard   Add Interval Tick...
1634
			{
a9d86eaa   Benjamin Renard   Fix zoom / unzoom
1635
				$plotInput->{'timesrc'} = 'Interval';
7d84634e   Benjamin Renard   Fix plot request ...
1636
1637
				if (!$isUndo)
					$this->addZoomInList($input,false,
a9d86eaa   Benjamin Renard   Fix zoom / unzoom
1638
1639
							isset($plotInput->{'ttFileIndex'}) ? $plotInput->{'ttFileIndex'} : 0,
							isset($plotInput->{'intIndex'}) ? $plotInput->{'intIndex'} : 0);
26a23052   Benjamin Renard   Add Interval Tick...
1640
1641
1642
			}
			else
			{
7d84634e   Benjamin Renard   Fix plot request ...
1643
				if (!$isUndo)
a9d86eaa   Benjamin Renard   Fix zoom / unzoom
1644
					$this->addZoomInList($input,true,$plotInput->{'startDate'},$plotInput->{'stopDate'});
26a23052   Benjamin Renard   Add Interval Tick...
1645
			}
a9d86eaa   Benjamin Renard   Fix zoom / unzoom
1646
1647
			$plotInput->{'startDate'} = $input->{'min'};
			$plotInput->{'stopDate'} = $input->{'max'};
e8cefd97   Benjamin Renard   Interactive attac...
1648
				
d3c3608d   Benjamin Renard   Add undo zoom
1649
			$plotInput->{'force-time-zoom-reset'} = false;
a9d86eaa   Benjamin Renard   Fix zoom / unzoom
1650
			$this->saveIHMRequest($input->interactiveId, $plotInput);
26a23052   Benjamin Renard   Add Interval Tick...
1651
1652
1653
1654
			return $plotInput;
		}
		
		//Digital axis zoom
a9d86eaa   Benjamin Renard   Fix zoom / unzoom
1655
		foreach ($plotInput->{'panels'} as $panel)
26a23052   Benjamin Renard   Add Interval Tick...
1656
1657
1658
1659
1660
1661
1662
1663
		{
			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
1664
1665
						$oldMin = $axis->{'axis-range-min'};
						$oldMax = $axis->{'axis-range-max'};
26a23052   Benjamin Renard   Add Interval Tick...
1666
1667
						$axis->{'axis-range-min'} = $input->{'min'};
						$axis->{'axis-range-max'} = $input->{'max'};
a9d86eaa   Benjamin Renard   Fix zoom / unzoom
1668
						$this->saveIHMRequest($input->interactiveId, $plotInput);
26a23052   Benjamin Renard   Add Interval Tick...
1669
1670
						//Do not save 'force-single-replot' in request file!
						$plotInput->{'force-single-replot'} = true;
d3c3608d   Benjamin Renard   Add undo zoom
1671
1672
1673
						$plotInput->{'force-time-zoom-reset'} = false;
						if (!$isUndo)
							$this->addZoomInList($input,true,$oldMin,$oldMax);
26a23052   Benjamin Renard   Add Interval Tick...
1674
1675
1676
1677
1678
1679
1680
1681
1682
						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
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
	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...
1704
1705
	private function unmarshallNavigation($input, $plotInput)
	{
4a7023e8   Benjamin Renard   Fix interactive n...
1706
1707
		$startTime = $plotInput->{'startDate'};
		$stopTime = $plotInput->{'stopDate'};
26a23052   Benjamin Renard   Add Interval Tick...
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
1747
1748
1749
		
		//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...
1750
1751
		$plotInput->{'startDate'} = $startTime;
		$plotInput->{'stopDate'} = $stopTime;
26a23052   Benjamin Renard   Add Interval Tick...
1752
		
d3c3608d   Benjamin Renard   Add undo zoom
1753
		$plotInput->{'force-time-zoom-reset'} = true;
4a7023e8   Benjamin Renard   Fix interactive n...
1754
		$this->saveIHMRequest($input->interactiveId, $plotInput);
26a23052   Benjamin Renard   Add Interval Tick...
1755
1756
1757
1758
1759
		return $plotInput;
	}
	
	private function unmarshallTTGoto($input, $plotInput)
	{
419a700b   Benjamin Renard   Fix TT goto
1760
1761
1762
		$plotInput->{'timesrc'} = 'TimeTable';
		$plotInput->{'ttFileIndex'} = $input->{'ttFileIndex'};
		$plotInput->{'intIndex'} = $input->{'intIndex'};
e8cefd97   Benjamin Renard   Interactive attac...
1763
		
d3c3608d   Benjamin Renard   Add undo zoom
1764
		$plotInput->{'force-time-zoom-reset'} = true;
419a700b   Benjamin Renard   Fix TT goto
1765
		$this->saveIHMRequest($input->interactiveId, $plotInput);
e8cefd97   Benjamin Renard   Interactive attac...
1766
1767
1768
		return $plotInput;
	}
	
05da1b4d   Benjamin Renard   Draw instant plot...
1769
1770
	private function unmarshallInstant($input, $plotInput)
	{
05da1b4d   Benjamin Renard   Draw instant plot...
1771
1772
		//Find current panel
		$crtPanel = NULL;
c2d88cc5   Benjamin Renard   Fix instant plot
1773
		foreach ($plotInput->{'panels'} as $panel)
05da1b4d   Benjamin Renard   Draw instant plot...
1774
1775
1776
1777
1778
1779
1780
1781
1782
1783
1784
1785
1786
1787
1788
1789
1790
1791
1792
1793
		{
			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
1794
				$crtParam = $param;                                
05da1b4d   Benjamin Renard   Draw instant plot...
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
1835
1836
1837
				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...
1838
1839
1840
			"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...
1841
			"id" => 1,
c2d88cc5   Benjamin Renard   Fix instant plot
1842
1843
1844
1845
1846
			"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...
1847
1848
1849
1850
1851
1852
1853
1854
1855
1856
1857
1858
1859
			"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,
d62f9945   Benjamin Renard   Improve instant c...
1860
1861
1862
				"panel-title-font-activated" => TRUE,
				"panel-title-font-size" => 12,
				"panel-title-font-bold" => TRUE,
05da1b4d   Benjamin Renard   Draw instant plot...
1863
				"axes" => array(),
0a87e436   Hacene SI HADJ MOHAND   parameters resolue
1864
1865
				"params" => array(),

05da1b4d   Benjamin Renard   Draw instant plot...
1866
1867
1868
1869
1870
1871
	    );
		
		$instantXAxis = (Object)array(
				"id"         => "xaxis_id",
				"axis-type"  => "x",
				"axis-scale" => $crtYAxis->{"axis-scale"},
d62f9945   Benjamin Renard   Improve instant c...
1872
1873
1874
1875
1876
1877
1878
				"axis-thickness" => 1,
				"axis-legend-font-activated" => TRUE,
				"axis-legend-font-size" => 12,
				"axis-legend-font-bold" => TRUE,
				"axis-range-min" => $crtYAxis->{"axis-range-min"},
				"axis-range-max" => $crtYAxis->{"axis-range-max"},
				"axis-reverse" => $crtYAxis->{"axis-reverse"},
05da1b4d   Benjamin Renard   Draw instant plot...
1879
1880
1881
1882
1883
1884
		);
		
		$instantYAxis = (Object)array(
				"id"         => "y-left",
				"axis-type"  => "y-left",
				"axis-scale" => $crtColorAxis->{"axis-scale"},
d62f9945   Benjamin Renard   Improve instant c...
1885
1886
1887
1888
1889
1890
1891
				"axis-thickness" => 1,
                                "axis-legend-font-activated" => TRUE,
				"axis-legend-font-size" => 12,
				"axis-legend-font-bold" => TRUE,
				"axis-range-min" => $crtColorAxis->{"axis-range-min"},
				"axis-range-max" => $crtColorAxis->{"axis-range-max"},
				"axis-reverse" => $crtColorAxis->{"axis-reverse"},
05da1b4d   Benjamin Renard   Draw instant plot...
1892
1893
1894
1895
1896
1897
		);
		$instantPanel->{"axes"}[] = $instantXAxis;
		$instantPanel->{"axes"}[] = $instantYAxis;
		
		$instantParam = (Object)array(
			"id" => 1,
e4545ed5   Benjamin Renard   Implement templat...
1898
			"paramid" => $crtParam->{'paramid'},
8d780912   Benjamin Renard   Keep template arg...
1899
			"template_args" => $crtParam->{'template_args'},
05da1b4d   Benjamin Renard   Draw instant plot...
1900
1901
1902
1903
1904
			"param-drawing-type" => "iserie",
			"param-drawing-object" => (Object)array(
					"iserie-tableonx" => true,
					"iserie-lines-activated" => true,
					"iserie-lines-style" => "plain",
d62f9945   Benjamin Renard   Improve instant c...
1905
1906
					"iserie-lines-width" => 3,
					"iserie-lines-color" => "#0000ff"
0a87e436   Hacene SI HADJ MOHAND   parameters resolue
1907
1908
1909
1910
1911
1912
1913
1914
1915
1916
1917
1918
1919
1920
1921
1922
1923
			),
                        "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...
1924
		);
0a87e436   Hacene SI HADJ MOHAND   parameters resolue
1925
1926
                $instantPanel->{"params"}[] = $instantParam;

05da1b4d   Benjamin Renard   Draw instant plot...
1927
		
c2d88cc5   Benjamin Renard   Fix instant plot
1928
		$instantPlotInput->{"panels"}[] = $instantPanel;
0a87e436   Hacene SI HADJ MOHAND   parameters resolue
1929
1930
	        
                	
05da1b4d   Benjamin Renard   Draw instant plot...
1931
1932
		return $instantPlotInput;
	}
26a23052   Benjamin Renard   Add Interval Tick...
1933
}
8d780912   Benjamin Renard   Keep template arg...
1934
?>