Blame view

src/InputOutput/IHMImpl/Params/PlotImpl/IHMInputOutputParamsPlotClass.php 67.3 KB
26a23052   Benjamin Renard   Add Interval Tick...
1
2
<?php

95ab3cf6   Menouard AZIB   Prise en compte d...
3
define("PLOT_RESULT_FILE_KEY", "plot");
26a23052   Benjamin Renard   Add Interval Tick...
4
5
6
7
8

/**
 * @class IHMInputOutputParamsPlotClass
 * @brief Implementation of IHMInputOutputParamsAbstractClass to treat plot request
 * @details
95ab3cf6   Menouard AZIB   Prise en compte d...
9
 */
26a23052   Benjamin Renard   Add Interval Tick...
10
11
12
class IHMInputOutputParamsPlotClass extends IHMInputOutputParamsAbstractClass
{
	private $isInteractiveRequest = false;
95ab3cf6   Menouard AZIB   Prise en compte d...
13

02abc780   Benjamin Renard   Support request f...
14
	private $isFromWS = false;
95ab3cf6   Menouard AZIB   Prise en compte d...
15

40624062   Elena.Budnik   no total_2D if in...
16
	private $isInstantPlot = false;
95ab3cf6   Menouard AZIB   Prise en compte d...
17

26a23052   Benjamin Renard   Add Interval Tick...
18
	private $interactiveTimeSelectionState = array();
95ab3cf6   Menouard AZIB   Prise en compte d...
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;
95ab3cf6   Menouard AZIB   Prise en compte d...
25

26a23052   Benjamin Renard   Add Interval Tick...
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;
95ab3cf6   Menouard AZIB   Prise en compte d...
33
34

		if (isset($input->{'action'})) {
26a23052   Benjamin Renard   Add Interval Tick...
35
			$input = $this->unmarshallActionRequest($input);
d3c3608d   Benjamin Renard   Add undo zoom
36
			$forceTimeZoomReset = isset($input->{'force-time-zoom-reset'}) ? $input->{'force-time-zoom-reset'} : false;
95ab3cf6   Menouard AZIB   Prise en compte d...
37
		} else {
d3c3608d   Benjamin Renard   Add undo zoom
38
			$resetZoom = true;
26a23052   Benjamin Renard   Add Interval Tick...
39
			//save request
95ab3cf6   Menouard AZIB   Prise en compte d...
40
			$this->saveIHMRequest(PLOT_RESULT_FILE_KEY . "_" . $input->{'tab-index'}, $input);
d3c3608d   Benjamin Renard   Add undo zoom
41
		}
95ab3cf6   Menouard AZIB   Prise en compte d...
42

26a23052   Benjamin Renard   Add Interval Tick...
43
		//Request
26a23052   Benjamin Renard   Add Interval Tick...
44
		$this->isInteractiveRequest = ($input->{'file-output'} == 'INTERACTIVE');
02abc780   Benjamin Renard   Support request f...
45
		$this->isFromWS = ($input->{'file-output'} == 'WS');
7d84634e   Benjamin Renard   Fix plot request ...
46

22253da3   Benjamin Renard   Fix zoom reset
47
		if ($resetZoom || $forceTimeZoomReset)
95ab3cf6   Menouard AZIB   Prise en compte d...
48
49
			$this->resetZoomList(PLOT_RESULT_FILE_KEY . "_" . $input->{'tab-index'}, $forceTimeZoomReset);

7d14181a   Benjamin Renard   Fix multi-request...
50
		$requestNode = $this->paramsData->addRequestNode($input->{'tab-index'});
7d84634e   Benjamin Renard   Fix plot request ...
51
52
		$outputsNode = $requestNode->getOutputsNode();
		$paramsNode  = $requestNode->getParamsNode();
95ab3cf6   Menouard AZIB   Prise en compte d...
53

7d84634e   Benjamin Renard   Fix plot request ...
54
55
56
57
		//unmarshall time definition
		$isIntervalRequest = ($input->timesrc == 'Interval');
		$ttFileIndex = -1;
		$ttIntIndex  = -1;
95ab3cf6   Menouard AZIB   Prise en compte d...
58
		if ($this->isInteractiveRequest && !$isIntervalRequest && !$input->{'page-superpose-mode'}) {
7d84634e   Benjamin Renard   Fix plot request ...
59
60
61
			$ttFileIndex = !isset($input->{'ttFileIndex'}) ? 0 : $input->{'ttFileIndex'};
			$ttIntIndex = !isset($input->{'intIndex'}) ? 0 : $input->{'intIndex'};
		}
7d14181a   Benjamin Renard   Fix multi-request...
62
		$this->unmarshallTimeDefinition($input, $input->{'tab-index'}, $ttFileIndex, $ttIntIndex);
95ab3cf6   Menouard AZIB   Prise en compte d...
63

7d84634e   Benjamin Renard   Fix plot request ...
64
		$this->interactiveCrtTTFileIndex = $ttFileIndex;
95ab3cf6   Menouard AZIB   Prise en compte d...
65

7d84634e   Benjamin Renard   Fix plot request ...
66
		$plotOutputNode = $outputsNode->addNewOutput(RequestOutputTypeEnum::PLOT);
95ab3cf6   Menouard AZIB   Prise en compte d...
67

7d84634e   Benjamin Renard   Fix plot request ...
68
		$plotOutputNode->setWriteContextFile($this->isInteractiveRequest ? "true" : "false");
95ab3cf6   Menouard AZIB   Prise en compte d...
69

7d84634e   Benjamin Renard   Fix plot request ...
70
		$compression = "";
95ab3cf6   Menouard AZIB   Prise en compte d...
71
72
73
		if (!$this->isInteractiveRequest && !$this->isFromWS) {
			switch ($input->{'file-output'}) {
				case 'TGZ':
7d84634e   Benjamin Renard   Fix plot request ...
74
75
76
77
					$plotOutputNode->addPostProcessing(RequestOutputPostProcessingEnumClass::TAR);
					$plotOutputNode->addPostProcessing(RequestOutputPostProcessingEnumClass::GZIP);
					$compression = ".tar.gz";
					break;
95ab3cf6   Menouard AZIB   Prise en compte d...
78
				case 'ZIP':
7d84634e   Benjamin Renard   Fix plot request ...
79
80
81
82
83
					$plotOutputNode->addPostProcessing(RequestOutputPostProcessingEnumClass::ZIP);
					$compression = ".zip";
					break;
				default:
					throw new Exception('Compression not implemented.');
26a23052   Benjamin Renard   Add Interval Tick...
84
			}
7d84634e   Benjamin Renard   Fix plot request ...
85
		}
95ab3cf6   Menouard AZIB   Prise en compte d...
86

7d84634e   Benjamin Renard   Fix plot request ...
87
88
89
90
		if ($input->{'one-file-per-interval'})
			$plotOutputNode->setStructure(RequestOutputPlotStructureEnum::ONE_FILE_PER_INTERVAL);
		else
			$plotOutputNode->setStructure(RequestOutputPlotStructureEnum::ONE_FILE);
95ab3cf6   Menouard AZIB   Prise en compte d...
91

7d84634e   Benjamin Renard   Fix plot request ...
92
93
94
95
		//prefix
		$filePrefix = "plot_";
		if ($input->{'file-prefix'} && ($input->{'file-prefix'} != ""))
			$filePrefix = $input->{'file-prefix'};
70e82c1f   Benjamin Renard   Fix doPlot
96
		$filePrefix .= $input->{'tab-index'};
95ab3cf6   Menouard AZIB   Prise en compte d...
97

7d84634e   Benjamin Renard   Fix plot request ...
98
		$plotOutputNode->setFilePrefix($filePrefix);
95ab3cf6   Menouard AZIB   Prise en compte d...
99

7d84634e   Benjamin Renard   Fix plot request ...
100
101
		//page
		$pageNode = $plotOutputNode->getPage();
95ab3cf6   Menouard AZIB   Prise en compte d...
102

7d84634e   Benjamin Renard   Fix plot request ...
103
104
		$fileFormat = RequestOutputPlotPageFormatEnum::PNG;
		$extension = ".png";
95ab3cf6   Menouard AZIB   Prise en compte d...
105
106
		switch ($input->{'file-format'}) {
			case 'PNG':
7d84634e   Benjamin Renard   Fix plot request ...
107
108
109
				$fileFormat = RequestOutputPlotPageFormatEnum::PNG;
				$extension = ".png";
				break;
95ab3cf6   Menouard AZIB   Prise en compte d...
110
			case 'PDF':
7d84634e   Benjamin Renard   Fix plot request ...
111
112
113
				$fileFormat = RequestOutputPlotPageFormatEnum::PDF;
				$extension = ".pdf";
				break;
95ab3cf6   Menouard AZIB   Prise en compte d...
114
			case 'PS':
7d84634e   Benjamin Renard   Fix plot request ...
115
116
117
				$fileFormat = RequestOutputPlotPageFormatEnum::PS;
				$extension = ".ps";
				break;
95ab3cf6   Menouard AZIB   Prise en compte d...
118
			case 'SVG':
7d84634e   Benjamin Renard   Fix plot request ...
119
120
121
122
123
124
				$fileFormat = RequestOutputPlotPageFormatEnum::SVG;
				$extension = ".svg";
				break;
			default:
				throw new Exception('File format not implemented.');
		}
95ab3cf6   Menouard AZIB   Prise en compte d...
125

7d84634e   Benjamin Renard   Fix plot request ...
126
		$pageNode->setFormat($fileFormat);
95ab3cf6   Menouard AZIB   Prise en compte d...
127

7d84634e   Benjamin Renard   Fix plot request ...
128
		$this->unmarshallTitle($input, 'page-title', $pageNode->getTitle());
95ab3cf6   Menouard AZIB   Prise en compte d...
129

7d84634e   Benjamin Renard   Fix plot request ...
130
		$isPortrait = false;
95ab3cf6   Menouard AZIB   Prise en compte d...
131
132
		switch ($input->{'page-orientation'}) {
			case 'landscape':
7d84634e   Benjamin Renard   Fix plot request ...
133
134
				$pageNode->setOrientation(RequestOutputPlotPageOrientationEnum::LANDSCAPE);
				break;
95ab3cf6   Menouard AZIB   Prise en compte d...
135
			case 'portrait':
7d84634e   Benjamin Renard   Fix plot request ...
136
137
138
139
				$pageNode->setOrientation(RequestOutputPlotPageOrientationEnum::PORTRAIT);
				$isPortrait = true;
				break;
		}
95ab3cf6   Menouard AZIB   Prise en compte d...
140
141
142

		switch ($input->{'page-dimension'}) {
			case 'ISO A4':
7d84634e   Benjamin Renard   Fix plot request ...
143
144
				$pageNode->setDimension(RequestOutputPlotPageDimensionEnum::ISO_A4);
				break;
95ab3cf6   Menouard AZIB   Prise en compte d...
145
			case 'US letter':
7d84634e   Benjamin Renard   Fix plot request ...
146
147
148
149
150
				$pageNode->setDimension(RequestOutputPlotPageDimensionEnum::US_LETTER);
				break;
			default:
				throw new Exception('Page dimension not implemented.');
		}
95ab3cf6   Menouard AZIB   Prise en compte d...
151
152
153
154

		switch ($input->{'page-mode'}) {

			case 'grayscale':
7d84634e   Benjamin Renard   Fix plot request ...
155
156
				$pageNode->setMode(RequestOutputPlotPageModeEnum::GRAYSCALE);
				break;
95ab3cf6   Menouard AZIB   Prise en compte d...
157
			case 'color':
7d84634e   Benjamin Renard   Fix plot request ...
158
159
160
161
			default:
				$pageNode->setMode(RequestOutputPlotPageModeEnum::COLOR);
				break;
		}
95ab3cf6   Menouard AZIB   Prise en compte d...
162
163

		if ($input->{'page-margins-activated'}) {
7d84634e   Benjamin Renard   Fix plot request ...
164
165
166
			$pageNode->getMargins()->setHorizontal($input->{'page-margin-x'});
			$pageNode->getMargins()->setVertical($input->{'page-margin-y'});
		}
95ab3cf6   Menouard AZIB   Prise en compte d...
167

7d84634e   Benjamin Renard   Fix plot request ...
168
169
		if ($input->{'page-font-activated'})
			$this->unmarshallFont($input, 'page-font', $pageNode->getFont());
95ab3cf6   Menouard AZIB   Prise en compte d...
170

7d84634e   Benjamin Renard   Fix plot request ...
171
		//Superpose mode
95ab3cf6   Menouard AZIB   Prise en compte d...
172
173
		$pageNode->setSuperposeMode($input->{'page-superpose-mode'} ? "true" : "false");

7d84634e   Benjamin Renard   Fix plot request ...
174
175
		//Layout
		$this->unmarshallLayout($input, $pageNode);
95ab3cf6   Menouard AZIB   Prise en compte d...
176

7d84634e   Benjamin Renard   Fix plot request ...
177
178
		foreach ($input->{'panels'} as $panelData)
			$this->unmarshallPanel($panelData, $pageNode, $paramsNode);
95ab3cf6   Menouard AZIB   Prise en compte d...
179
180
181
182
183
184
185

		if ($this->isInteractiveRequest || $this->isFromWS) {
			$resultFile = $filePrefix . "_*" . $extension;
			$waitingResultFile = $filePrefix . $extension;
		} else {
			$resultFile = $filePrefix . "_*" . $compression;
			$waitingResultFile = $filePrefix . $compression;
7d84634e   Benjamin Renard   Fix plot request ...
186
		}
95ab3cf6   Menouard AZIB   Prise en compte d...
187
188
189
190
191

		if ($this->isInteractiveRequest) {
			$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 ...
192
			$this->interactivePreview = isset($input->{'interactive-preview'}) && ($input->{'interactive-preview'});
95ab3cf6   Menouard AZIB   Prise en compte d...
193
194
			$this->paramsData->addWaitingResult(PLOT_RESULT_FILE_KEY . "_" . $input->{'tab-index'}, $waitingResultFile);
		} else
7d84634e   Benjamin Renard   Fix plot request ...
195
			$this->paramsData->addWaitingResult(PLOT_RESULT_FILE_KEY, $waitingResultFile);
95ab3cf6   Menouard AZIB   Prise en compte d...
196

7d84634e   Benjamin Renard   Fix plot request ...
197
		//Remove old result files
95ab3cf6   Menouard AZIB   Prise en compte d...
198
		foreach (glob($this->paramsData->getWorkingPath() . $resultFile) as $oldFile) {
7d84634e   Benjamin Renard   Fix plot request ...
199
200
			unlink($oldFile);
		}
95ab3cf6   Menouard AZIB   Prise en compte d...
201

7d84634e   Benjamin Renard   Fix plot request ...
202
		//Post process command to apply to the result file
ec574794   Benjamin Renard   Implements multip...
203
		$postProcessCmd = $this->paramsData->getPostCmd();
7d84634e   Benjamin Renard   Fix plot request ...
204
205
		if ($postProcessCmd != "")
			$postProcessCmd .= " | ";
95ab3cf6   Menouard AZIB   Prise en compte d...
206
207
		$postProcessCmd .= "mv " . $resultFile . " " . $waitingResultFile;

7d84634e   Benjamin Renard   Fix plot request ...
208
		if (($this->isInteractiveRequest) && $isPortrait)
95ab3cf6   Menouard AZIB   Prise en compte d...
209
210
			$postProcessCmd .= " | convert " . $waitingResultFile . " -rotate -90 " . $waitingResultFile;
		else if ($this->isFromWS) {
7d84634e   Benjamin Renard   Fix plot request ...
211
			if ($isPortrait)
95ab3cf6   Menouard AZIB   Prise en compte d...
212
				$postProcessCmd .= " | convert " . $waitingResultFile . " -rotate -90 " . $input->{"ws-result-file"};
7d84634e   Benjamin Renard   Fix plot request ...
213
			else
95ab3cf6   Menouard AZIB   Prise en compte d...
214
				$postProcessCmd .= " | mv " . $waitingResultFile . " " . $input->{"ws-result-file"};
26a23052   Benjamin Renard   Add Interval Tick...
215
		}
95ab3cf6   Menouard AZIB   Prise en compte d...
216

26a23052   Benjamin Renard   Add Interval Tick...
217
218
		$this->paramsData->setBatchEnable(!(($fileFormat == RequestOutputPlotPageFormatEnum::PNG) && $this->isInteractiveRequest));
		$this->paramsData->setPostCmd($postProcessCmd);
26a23052   Benjamin Renard   Add Interval Tick...
219
220
		return $this->paramsData;
	}
95ab3cf6   Menouard AZIB   Prise en compte d...
221

7d84634e   Benjamin Renard   Fix plot request ...
222
	protected function unmarshallLayout($request, $pageNode)
26a23052   Benjamin Renard   Add Interval Tick...
223
	{
95ab3cf6   Menouard AZIB   Prise en compte d...
224
225
		switch ($request->{'page-layout-type'}) {
			case 'vertical':
26a23052   Benjamin Renard   Add Interval Tick...
226
				$pageNode->getLayout()->setType(RequestOutputPlotLayoutTypeEnum::VERTICAL);
7d84634e   Benjamin Renard   Fix plot request ...
227
228
229
230
231
232
233
234
235
236
237
238
				$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...
239
				break;
95ab3cf6   Menouard AZIB   Prise en compte d...
240
			case 'auto':
26a23052   Benjamin Renard   Add Interval Tick...
241
				$pageNode->getLayout()->setType(RequestOutputPlotLayoutTypeEnum::AUTO);
7d84634e   Benjamin Renard   Fix plot request ...
242
243
244
245
				$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...
246
				break;
95ab3cf6   Menouard AZIB   Prise en compte d...
247
			case 'manual':
26a23052   Benjamin Renard   Add Interval Tick...
248
				$pageNode->getLayout()->setType(RequestOutputPlotLayoutTypeEnum::MANUAL);
7d84634e   Benjamin Renard   Fix plot request ...
249
250
				$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...
251
				$pageNode->setDefaultTimePlotXMargin($timePlotLeftMargin, $timePlotRightMargin);
7d84634e   Benjamin Renard   Fix plot request ...
252
253
				$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...
254
255
256
257
258
				$pageNode->setDefaultXYPlotXMargin($xyPlotLeftMargin, $xyPlotRightMargin);
				break;
			default:
				throw new Exception('Layout type not implemented.');
		}
26a23052   Benjamin Renard   Add Interval Tick...
259
	}
95ab3cf6   Menouard AZIB   Prise en compte d...
260

26a23052   Benjamin Renard   Add Interval Tick...
261
262
263
	protected function unmarshallPanel($panelData, $pageNode, $paramsNode)
	{
		$panelNode = $pageNode->addPanel();
95ab3cf6   Menouard AZIB   Prise en compte d...
264
265
266
267


		switch ($pageNode->getLayout()->getType()) {
			case RequestOutputPlotLayoutTypeEnum::MANUAL:
26a23052   Benjamin Renard   Add Interval Tick...
268
269
270
271
272
273
274
275
276
277
				//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;
95ab3cf6   Menouard AZIB   Prise en compte d...
278
			case RequestOutputPlotLayoutTypeEnum::VERTICAL:
26a23052   Benjamin Renard   Add Interval Tick...
279
280
281
282
283
284
				//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;
95ab3cf6   Menouard AZIB   Prise en compte d...
285
			default:
26a23052   Benjamin Renard   Add Interval Tick...
286
287
				//Nothing to do
		}
95ab3cf6   Menouard AZIB   Prise en compte d...
288

26a23052   Benjamin Renard   Add Interval Tick...
289
		//Panel id
02abc780   Benjamin Renard   Support request f...
290
291
		if (isset($panelData->{'id'}))
			$panelNode->setId($panelData->{'id'});
0a87e436   Hacene SI HADJ MOHAND   parameters resolue
292

95ab3cf6   Menouard AZIB   Prise en compte d...
293
294
295
296
297
		//Panel id
		if (isset($panelData->{'panel-index'}))
			$panelNode->setIndex($panelData->{'panel-index'});


26a23052   Benjamin Renard   Add Interval Tick...
298
299
300
		//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...
301

26a23052   Benjamin Renard   Add Interval Tick...
302
303
		//Panel font
		$this->unmarshallFont($panelData, 'panel-font', $panelNode->getFont());
95ab3cf6   Menouard AZIB   Prise en compte d...
304

26a23052   Benjamin Renard   Add Interval Tick...
305
306
		//Panel title
		$this->unmarshallTitle($panelData, 'panel-title', $panelNode->getTitle());
95ab3cf6   Menouard AZIB   Prise en compte d...
307

26a23052   Benjamin Renard   Add Interval Tick...
308
		//Plot type
40624062   Elena.Budnik   no total_2D if in...
309
		$this->isInstantPlot = false;
26a23052   Benjamin Renard   Add Interval Tick...
310
		$plotNode = $this->unmarshallPlotType($panelData, $panelNode);
95ab3cf6   Menouard AZIB   Prise en compte d...
311

26a23052   Benjamin Renard   Add Interval Tick...
312
		$isTimePlot = ($plotNode->getName() == REQUESTOUTPUTPLOTELEMENTTIME_NAME);
95ab3cf6   Menouard AZIB   Prise en compte d...
313

26a23052   Benjamin Renard   Add Interval Tick...
314
315
		//Tick plot
		$tickPlotNode = NULL;
95ab3cf6   Menouard AZIB   Prise en compte d...
316
317
318
		if ($isTimePlot) {
			if ($this->hasTickBar($panelData->{'params'})) {
				$tickPlotNode = $panelNode->addPlotElement(RequestOutputPlotElementTypeEnum::TICKPLOT, true);
26a23052   Benjamin Renard   Add Interval Tick...
319
320
321
322
				if ($panelData->{'panel-tick-format'} != '')
					$tickPlotNode->setFormat($panelData->{'panel-tick-format'});
			}
		}
95ab3cf6   Menouard AZIB   Prise en compte d...
323

26a23052   Benjamin Renard   Add Interval Tick...
324
325
		//Status plot
		$statusPlotNode = NULL;
95ab3cf6   Menouard AZIB   Prise en compte d...
326
327
328
329
330
		if ($isTimePlot) {
			if ($this->hasStatusBar($panelData->{'params'})) {
				$statusPlotNode = $panelNode->addPlotElement(RequestOutputPlotElementTypeEnum::STATUSPLOT, true);
				switch ($panelData->{'panel-status-position'}) {
					case 'top':
26a23052   Benjamin Renard   Add Interval Tick...
331
332
						$statusPlotNode->setPosition(RequestOutputPlotElementStatusPosition::TOP);
						break;
95ab3cf6   Menouard AZIB   Prise en compte d...
333
					case 'bottom':
26a23052   Benjamin Renard   Add Interval Tick...
334
335
336
337
338
339
						$statusPlotNode->setPosition(RequestOutputPlotElementStatusPosition::BOTTOM);
						break;
				}
				$statusPlotNode->setColorMap($panelData->{'panel-status-colormap'});
			}
		}
95ab3cf6   Menouard AZIB   Prise en compte d...
340

26a23052   Benjamin Renard   Add Interval Tick...
341
342
343
		//Axes
		foreach ($panelData->{'axes'} as $axisData)
			$this->unmarshallAxis($axisData, $panelData->{'constants'}, $plotNode);
95ab3cf6   Menouard AZIB   Prise en compte d...
344

26a23052   Benjamin Renard   Add Interval Tick...
345
346
		//Params
		$this->unmarshallParams($panelData->{'params'}, $paramsNode, $plotNode, $panelNode, $statusPlotNode, $tickPlotNode);
95ab3cf6   Menouard AZIB   Prise en compte d...
347

26a23052   Benjamin Renard   Add Interval Tick...
348
349
350
		//Additional objects
		if ($plotNode->getAdditionalObjects() != NULL)
			$this->unmarshallAdditionalObjects($panelData, $plotNode->getAdditionalObjects(), $isTimePlot);
95ab3cf6   Menouard AZIB   Prise en compte d...
351

26a23052   Benjamin Renard   Add Interval Tick...
352
353
354
		//Fills
		if ($plotNode->getFills() != NULL)
			$this->unmarshallFills($panelData, $plotNode->getFills());
95ab3cf6   Menouard AZIB   Prise en compte d...
355

26a23052   Benjamin Renard   Add Interval Tick...
356
357
		return $panelNode;
	}
95ab3cf6   Menouard AZIB   Prise en compte d...
358

26a23052   Benjamin Renard   Add Interval Tick...
359
360
	protected function unmarshallPlotType($panelData, $panelNode)
	{
95ab3cf6   Menouard AZIB   Prise en compte d...
361
362
		switch ($panelData->{'panel-plot-type'}) {
			case 'timePlot':
26a23052   Benjamin Renard   Add Interval Tick...
363
364
				$plotNode = $panelNode->addPlotElement(RequestOutputPlotElementTypeEnum::TIMEPLOT);
				break;
95ab3cf6   Menouard AZIB   Prise en compte d...
365
			case 'xyPlot':
26a23052   Benjamin Renard   Add Interval Tick...
366
367
368
				$plotNode = $panelNode->addPlotElement(RequestOutputPlotElementTypeEnum::XYPLOT);
				$plotNode->setIsIsotropic($panelData->{'panel-scatter-isotropic'});
				break;
95ab3cf6   Menouard AZIB   Prise en compte d...
369
			case 'statusPlot':
26a23052   Benjamin Renard   Add Interval Tick...
370
				$plotNode = $panelNode->addPlotElement(RequestOutputPlotElementTypeEnum::STATUSPLOT);
95ab3cf6   Menouard AZIB   Prise en compte d...
371
372
				switch ($panelData->{'panel-status-position'}) {
					case 'top':
26a23052   Benjamin Renard   Add Interval Tick...
373
374
						$plotNode->setPosition(RequestOutputPlotElementStatusPosition::TOP);
						break;
95ab3cf6   Menouard AZIB   Prise en compte d...
375
					case 'bottom':
26a23052   Benjamin Renard   Add Interval Tick...
376
377
378
379
380
						$plotNode->setPosition(RequestOutputPlotElementStatusPosition::BOTTOM);
						break;
				}
				$plotNode->setColorMap($panelData->{'panel-status-colormap'});
				break;
95ab3cf6   Menouard AZIB   Prise en compte d...
381
			case 'tickPlot':
26a23052   Benjamin Renard   Add Interval Tick...
382
383
384
385
				$plotNode = $panelNode->addPlotElement(RequestOutputPlotElementTypeEnum::TICKPLOT);
				if ($panelData->{'panel-tick-format'} != '')
					$plotNode->setFormat($panelData->{'panel-tick-format'});
				break;
95ab3cf6   Menouard AZIB   Prise en compte d...
386
			case 'epochPlot':
26a23052   Benjamin Renard   Add Interval Tick...
387
				$plotNode = $panelNode->addPlotElement(RequestOutputPlotElementTypeEnum::EPOCHPLOT);
d6bf6ef5   Benjamin Renard   Get the possibili...
388
389
				if ($panelData->{'panel-epoch-centertimeid'} != '')
					$plotNode->setCenterTimeId($panelData->{'panel-epoch-centertimeid'});
26a23052   Benjamin Renard   Add Interval Tick...
390
				break;
95ab3cf6   Menouard AZIB   Prise en compte d...
391
			case 'instantPlot':
26a23052   Benjamin Renard   Add Interval Tick...
392
393
				$plotNode = $panelNode->addPlotElement(RequestOutputPlotElementTypeEnum::INSTANTPLOT);
				date_default_timezone_set('UTC');
74fd500a   Hacene SI HADJ MOHAND   us #9874 ms zoo...
394
				$time = CommonClass::strTimeToDDTime($panelData->{'panel-instant-time'});
26a23052   Benjamin Renard   Add Interval Tick...
395
				$plotNode->setTime($time);
40624062   Elena.Budnik   no total_2D if in...
396
				$this->isInstantPlot = true;
26a23052   Benjamin Renard   Add Interval Tick...
397
398
399
400
				break;
			default:
				throw new Exception('Plot type not implemented.');
		}
95ab3cf6   Menouard AZIB   Prise en compte d...
401

26a23052   Benjamin Renard   Add Interval Tick...
402
403
404
		//Params Legend
		if (isset($panelData->{'panel-series-legend'}) && $panelData->{'panel-series-legend'}->{'legend-series-activated'})
			$this->unmarshallParamsLegend($panelData->{'panel-series-legend'}, $plotNode->getLegends()->getParamsLegend());
95ab3cf6   Menouard AZIB   Prise en compte d...
405

26a23052   Benjamin Renard   Add Interval Tick...
406
407
408
		//Text Legends
		foreach ($panelData->{'text-legends'} as $textLegendData)
			$this->unmarshallTextLegend($textLegendData, $plotNode->getLegends());
95ab3cf6   Menouard AZIB   Prise en compte d...
409

26a23052   Benjamin Renard   Add Interval Tick...
410
411
		return $plotNode;
	}
95ab3cf6   Menouard AZIB   Prise en compte d...
412

26a23052   Benjamin Renard   Add Interval Tick...
413
414
415
416
	protected function unmarshallAxis($axisData, $constantsData, $plotNode)
	{
		//axis type
		$constantAxisId = '';
95ab3cf6   Menouard AZIB   Prise en compte d...
417
418
		switch ($axisData->{'axis-type'}) {
			case 'time':
26a23052   Benjamin Renard   Add Interval Tick...
419
420
421
422
				$axisNode = $plotNode->getTimeAxis();
				$axisNode->setFormat($axisData->{'axis-time-format'});
				$constantAxisId = 'x';
				break;
95ab3cf6   Menouard AZIB   Prise en compte d...
423
			case 'epoch':
26a23052   Benjamin Renard   Add Interval Tick...
424
425
426
427
				$axisNode = $plotNode->getEpochAxis();
				$axisNode->setNormalized($axisData->{'axis-epoch-normalized'} ? "true" : "false");
				$constantAxisId = 'x';
				break;
95ab3cf6   Menouard AZIB   Prise en compte d...
428
			case 'x':
26a23052   Benjamin Renard   Add Interval Tick...
429
430
431
				$axisNode = $plotNode->getXAxis();
				$constantAxisId = 'x';
				break;
95ab3cf6   Menouard AZIB   Prise en compte d...
432
			case 'y-left':
26a23052   Benjamin Renard   Add Interval Tick...
433
434
435
				$axisNode = $plotNode->addYAxis('y-left');
				$constantAxisId = 'y-left';
				break;
95ab3cf6   Menouard AZIB   Prise en compte d...
436
			case 'y-right':
26a23052   Benjamin Renard   Add Interval Tick...
437
438
439
440
				$axisNode = $plotNode->addYAxis('y-right');
				$axisNode->setPosition(RequestOutputPlotAxisElementPosition::RIGHT);
				$constantAxisId = 'y-right';
				break;
95ab3cf6   Menouard AZIB   Prise en compte d...
441
			case 'color':
26a23052   Benjamin Renard   Add Interval Tick...
442
443
444
445
446
447
448
449
450
451
				$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.');
		}
95ab3cf6   Menouard AZIB   Prise en compte d...
452

26a23052   Benjamin Renard   Add Interval Tick...
453
		//reverse axis
05da1b4d   Benjamin Renard   Draw instant plot...
454
455
		if (isset($axisData->{'axis-reverse'}))
			$axisNode->setReverse($axisData->{'axis-reverse'} ? "true" : "false");
95ab3cf6   Menouard AZIB   Prise en compte d...
456

26a23052   Benjamin Renard   Add Interval Tick...
457
		//axis scale
95ab3cf6   Menouard AZIB   Prise en compte d...
458
459
		switch ($axisData->{'axis-scale'}) {
			case 'logarithmic':
26a23052   Benjamin Renard   Add Interval Tick...
460
461
462
463
464
				$axisNode->setScale(RequestOutputPlotAxisElementScale::LOGARITHMIC);
				break;
			default:
				$axisNode->setScale(RequestOutputPlotAxisElementScale::LINEAR);
		}
95ab3cf6   Menouard AZIB   Prise en compte d...
465

26a23052   Benjamin Renard   Add Interval Tick...
466
467
468
		//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...
469
470
		if (isset($axisData->{'axis-range-extend'}))
			$axisNode->getRange()->setExtend($axisData->{'axis-range-extend'} ? "true" : "false");
95ab3cf6   Menouard AZIB   Prise en compte d...
471

26a23052   Benjamin Renard   Add Interval Tick...
472
		//axis color
02abc780   Benjamin Renard   Support request f...
473
474
		if (isset($axisData->{'axis-color'}))
			$axisNode->setColor($this->hexColor2KernelColor($axisData->{'axis-color'}));
95ab3cf6   Menouard AZIB   Prise en compte d...
475

26a23052   Benjamin Renard   Add Interval Tick...
476
		//axis thickness
02abc780   Benjamin Renard   Support request f...
477
478
		if (isset($axisData->{'axis-thickness'}))
			$axisNode->setThickness($axisData->{'axis-thickness'});
95ab3cf6   Menouard AZIB   Prise en compte d...
479

26a23052   Benjamin Renard   Add Interval Tick...
480
		//axis ticks position
95ab3cf6   Menouard AZIB   Prise en compte d...
481
482
		switch ($axisData->{'axis-tick-position'}) {
			case 'inwards':
26a23052   Benjamin Renard   Add Interval Tick...
483
484
				$axisNode->getTick()->setPosition(RequestOutputPlotAxisElementTickPosition::INWARDS);
				break;
95ab3cf6   Menouard AZIB   Prise en compte d...
485
			default:
26a23052   Benjamin Renard   Add Interval Tick...
486
487
				$axisNode->getTick()->setPosition(RequestOutputPlotAxisElementTickPosition::OUTWARDS);
		}
95ab3cf6   Menouard AZIB   Prise en compte d...
488

26a23052   Benjamin Renard   Add Interval Tick...
489
		//axis minor and major grid
05da1b4d   Benjamin Renard   Draw instant plot...
490
491
		if (isset($axisData->{'axis-grid-minor'}))
			$axisNode->getTick()->setMinorGrid($axisData->{'axis-grid-minor'} ? "true" : "false");
3741e4bb   Hacene SI HADJ MOHAND   6954 ok
492

05da1b4d   Benjamin Renard   Draw instant plot...
493
494
		if (isset($axisData->{'axis-grid-major'}))
			$axisNode->getTick()->setMajorGrid($axisData->{'axis-grid-major'} ? "true" : "false");
95ab3cf6   Menouard AZIB   Prise en compte d...
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
		if ($axisData->{'axis-grid-specify-ticks-number'}) {

			if (isset($axisData->{'axis-grid-minor-number'}) && $axisData->{'axis-grid-minor-number'} != 0)
				$axisNode->getTick()->setMinorGridNumber($axisData->{'axis-grid-minor-number'});

			if (isset($axisData->{'axis-grid-major-number'}) && $axisData->{'axis-grid-major-number'} != 0)
				$axisNode->getTick()->setMajorGridNumber($axisData->{'axis-grid-major-number'});
		} elseif ($axisData->{'axis-grid-specify-ticks-spacing'}) {

			if (isset($axisData->{'axis-grid-major-space'}) && $axisData->{'axis-grid-major-space'} != 0)
				$axisNode->getTick()->setMajorGridSpace($axisData->{'axis-grid-major-space'});

			if (isset($axisData->{'axis-grid-minor-space'}) && $axisData->{'axis-grid-minor-space'} != 0)
				$axisNode->getTick()->setMinorGridSpace($axisData->{'axis-grid-minor-space'});
		}


		//legend
		if (isset($axisData->{'axis-legend-text'}) && $axisData->{'axis-legend-text'} != '') {
26a23052   Benjamin Renard   Add Interval Tick...
514
			$axisNode->getLegend()->setText($axisData->{'axis-legend-text'});
05da1b4d   Benjamin Renard   Draw instant plot...
515
		}
d62f9945   Benjamin Renard   Improve instant c...
516
517
518
                $axisNode->getLegend()->setColor($this->hexColor2KernelColor($axisData->{'axis-legend-color'}));
                $this->unmarshallLabel($axisData, "axis-legend", $axisNode->getLegend());

26a23052   Benjamin Renard   Add Interval Tick...
519
		//Show legend
05da1b4d   Benjamin Renard   Draw instant plot...
520
521
		if (isset($axisData->{'axis-legend-activated'}))
			$axisNode->setShowLegend($axisData->{'axis-legend-activated'} ? "true" : "false");
95ab3cf6   Menouard AZIB   Prise en compte d...
522

26a23052   Benjamin Renard   Add Interval Tick...
523
		//Show tick marks
05da1b4d   Benjamin Renard   Draw instant plot...
524
525
		if (isset($axisData->{'axis-tick-showmarks'}))
			$axisNode->setShowTickMarks($axisData->{'axis-tick-showmarks'} ? "true" : "false");
95ab3cf6   Menouard AZIB   Prise en compte d...
526

26a23052   Benjamin Renard   Add Interval Tick...
527
		//Add constants
95ab3cf6   Menouard AZIB   Prise en compte d...
528
		if ($constantAxisId != '') {
26a23052   Benjamin Renard   Add Interval Tick...
529
530
			foreach ($constantsData as $constantData)
				if ($constantData->{'constant-axis-id'} == $constantAxisId)
95ab3cf6   Menouard AZIB   Prise en compte d...
531
					$this->unmarshallConstant($constantData, $axisNode);
26a23052   Benjamin Renard   Add Interval Tick...
532
533
		}
	}
95ab3cf6   Menouard AZIB   Prise en compte d...
534

26a23052   Benjamin Renard   Add Interval Tick...
535
536
537
538
	protected function unmarshallParams($paramsData, $requestParamsNode, $plotNode, $panelNode, $statusPlotNode, $tickPlotNode)
	{
		//X parameters
		$isScatter = ($plotNode->getName() == REQUESTOUTPUTPLOTELEMENTXY_NAME);
f822811a   Benjamin Renard   Implements multi ...
539
		$xIds = array();
95ab3cf6   Menouard AZIB   Prise en compte d...
540
		if ($isScatter) {
f822811a   Benjamin Renard   Implements multi ...
541
			$crtXId = 0;
95ab3cf6   Menouard AZIB   Prise en compte d...
542
			foreach ($paramsData as $paramData) {
26a23052   Benjamin Renard   Add Interval Tick...
543
544
				if ($paramData->{'param-drawing-object'}->{'serie-xaxis-param'} == '')
					continue;
f822811a   Benjamin Renard   Implements multi ...
545
546
547
548
				if (array_key_exists($paramData->{'param-drawing-object'}->{'serie-xaxis-param'}, $xIds)) {
					//x param already exists
					continue;
				}
95ab3cf6   Menouard AZIB   Prise en compte d...
549

bf27ba04   Benjamin Renard   Add templated par...
550
				$paramXInfo = $this->paramManager->addExistingParam($paramData->{'param-drawing-object'}->{'serie-xaxis-param'}, $this->paramsData);
26a23052   Benjamin Renard   Add Interval Tick...
551
552
553
554
				if ($paramXInfo['id'] == '')
					throw new Exception('Cannot retrieve X parameter.');
				$requestParamsNode->addParam($paramXInfo['id']);
				$xParamNode = $plotNode->getParams()->getParamById($paramXInfo['id']);
95ab3cf6   Menouard AZIB   Prise en compte d...
555
556
				switch ($paramData->{'param-drawing-type'}) {
					case 'serie':
26a23052   Benjamin Renard   Add Interval Tick...
557
558
						//Unmarshall x serie
						if (count($paramXInfo['indexes']) == 0)
f822811a   Benjamin Renard   Implements multi ...
559
							$xParamNode->addXSerie(-1, $crtXId, $paramData->{'param-drawing-object'}->{'serie-xvalue-min'}, $paramData->{'param-drawing-object'}->{'serie-xvalue-max'});
26a23052   Benjamin Renard   Add Interval Tick...
560
						else if (count($paramXInfo['indexes']) == 1)
f822811a   Benjamin Renard   Implements multi ...
561
							$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...
562
563
564
						else
							throw new Exception('X parameter for serie must be a component.');
						break;
95ab3cf6   Menouard AZIB   Prise en compte d...
565
					default:
26a23052   Benjamin Renard   Add Interval Tick...
566
567
						throw new Exception('X parameter not allowed for this drawing type. ');
				}
f822811a   Benjamin Renard   Implements multi ...
568
569
				$xIds[$paramData->{'param-drawing-object'}->{'serie-xaxis-param'}] = $crtXId;
				++$crtXId;
26a23052   Benjamin Renard   Add Interval Tick...
570
571
			}
		}
95ab3cf6   Menouard AZIB   Prise en compte d...
572

26a23052   Benjamin Renard   Add Interval Tick...
573
574
		//Main drawing element parameter
		$drawingEltIndex = 0;
95ab3cf6   Menouard AZIB   Prise en compte d...
575
		foreach ($paramsData as $paramData) {
52c1e291   Benjamin Renard   Generate TT and c...
576
577
			$isTTCat = ($paramData->{'param-type'} == 'ttcat');

26a23052   Benjamin Renard   Add Interval Tick...
578
			//Param
52c1e291   Benjamin Renard   Generate TT and c...
579
580
			if (!$isTTCat) {
				$paramInfo = $this->paramManager->addExistingParam($paramData->{'paramid'}, $this->paramsData, isset($paramData->{'template_args'}) ? $paramData->{'template_args'} : NULL);
95ab3cf6   Menouard AZIB   Prise en compte d...
581
			} else {
52c1e291   Benjamin Renard   Generate TT and c...
582
583
				$paramInfo = $this->paramManager->addTTCatParam($paramData->{'paramid'}, $this->paramsData);
			}
95ab3cf6   Menouard AZIB   Prise en compte d...
584

3182799a   Benjamin Renard   Use param indexes...
585
			$paramInfo['indexes'] = array();
3dcf7710   Hacene SI HADJ MOHAND   us ok
586
587
588
589
590
                                                            if($paramData->{'param-drawing-type'} == 'sauvaud'){
                                                                    $this->paramManager->applyRangesAndIndexes($this->paramsData, $paramData, false, $paramInfo);
                                                            } else {
                                                                    $this->paramManager->applyRangesAndIndexes($this->paramsData, $paramData, !$this->isInstantPlot, $paramInfo);
                                                            }
95ab3cf6   Menouard AZIB   Prise en compte d...
591
592
			$this->paramManager->applyFilter($this->paramsData, $paramData, $paramInfo);

26a23052   Benjamin Renard   Add Interval Tick...
593
			$requestParamsNode->addParam($paramInfo['id']);
95ab3cf6   Menouard AZIB   Prise en compte d...
594

26a23052   Benjamin Renard   Add Interval Tick...
595
			$colorSerieId = -1;
8ade06fe   Benjamin Renard   Improve config load
596
			if (!empty($paramData->{'param-drawing-object'}->{'serie-colored-param'}))
26a23052   Benjamin Renard   Add Interval Tick...
597
598
				$colorSerieId = $drawingEltIndex;

f822811a   Benjamin Renard   Implements multi ...
599
			$xId = ($isScatter && !empty($paramData->{'param-drawing-object'}->{'serie-xaxis-param'})) ? $xIds[$paramData->{'param-drawing-object'}->{'serie-xaxis-param'}] : -1;
95ab3cf6   Menouard AZIB   Prise en compte d...
600
601
602

			switch ($paramData->{'param-drawing-type'}) {
				case 'serie':
26a23052   Benjamin Renard   Add Interval Tick...
603
					$paramNode = $plotNode->getParams()->getParamById($paramInfo['id']);
f822811a   Benjamin Renard   Implements multi ...
604
					$this->unmarshallSerie($paramData, $requestParamsNode, $plotNode, $paramNode, $paramInfo['indexes'], $xId, $colorSerieId, false);
26a23052   Benjamin Renard   Add Interval Tick...
605
					break;
95ab3cf6   Menouard AZIB   Prise en compte d...
606
				case 'orbit-serie':
26a23052   Benjamin Renard   Add Interval Tick...
607
					$paramNode = $plotNode->getParams()->getParamById($paramInfo['id']);
f822811a   Benjamin Renard   Implements multi ...
608
					$this->unmarshallSerie($paramData, $requestParamsNode, $plotNode, $paramNode, -1, $xId, $colorSerieId, true);
26a23052   Benjamin Renard   Add Interval Tick...
609
					break;
95ab3cf6   Menouard AZIB   Prise en compte d...
610
				case 'spectro':
26a23052   Benjamin Renard   Add Interval Tick...
611
612
613
					$paramNode = $plotNode->getParams()->getParamById($paramInfo['id']);
					$this->unmarshallSpectro($paramData->{'param-drawing-object'}, $plotNode, $paramNode, $paramInfo['indexes']);
					break;
3dcf7710   Hacene SI HADJ MOHAND   us ok
614
615
616
617
                                                                                case 'sauvaud':
                                                                                                    $paramNode = $plotNode->getParams()->getParamById($paramInfo['id']);
                                                                                                    $this->unmarshallSauvaud($paramData->{'param-drawing-object'}, $plotNode, $paramNode, $paramInfo['indexes']);
					break;
95ab3cf6   Menouard AZIB   Prise en compte d...
618
				case 'status-bar':
26a23052   Benjamin Renard   Add Interval Tick...
619
620
621
622
623
624
					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;
95ab3cf6   Menouard AZIB   Prise en compte d...
625
				case 'tick-bar':
26a23052   Benjamin Renard   Add Interval Tick...
626
627
628
629
					if (($plotNode->getName() == REQUESTOUTPUTPLOTELEMENTTICK_NAME) && !isset($tickPlotNode))
						$paramNode = $plotNode->getParams()->getParamById($paramInfo['id']);
					else
						$paramNode = $tickPlotNode->getParams()->getParamById($paramInfo['id']);
95ab3cf6   Menouard AZIB   Prise en compte d...
630

26a23052   Benjamin Renard   Add Interval Tick...
631
632
					$this->unmarshallTickBar($paramData->{'param-drawing-object'}, $paramNode, $paramInfo['indexes']);
					break;
95ab3cf6   Menouard AZIB   Prise en compte d...
633
				case 'iserie':
26a23052   Benjamin Renard   Add Interval Tick...
634
635
636
					$paramNode = $plotNode->getParams()->getParamById($paramInfo['id']);
					$this->unmarshallInstantSerie($paramData->{'param-drawing-object'}, $plotNode, $paramNode);
					break;
95ab3cf6   Menouard AZIB   Prise en compte d...
637
				case 'ispectro':
fc153c1c   Elena.Budnik   ispectro added
638
639
					$paramNode = $plotNode->getParams()->getParamById($paramInfo['id']);
					$this->unmarshallInstantSpectro($paramData->{'param-drawing-object'}, $plotNode, $paramNode, $paramInfo['indexes']);
044a9305   Benjamin Renard   Add intervals dra...
640
					break;
95ab3cf6   Menouard AZIB   Prise en compte d...
641
				case 'intervals':
044a9305   Benjamin Renard   Add intervals dra...
642
643
644
					$paramNode = $plotNode->getParams()->getParamById($paramInfo['id']);
					$this->unmarshallIntervals($paramData->{'param-drawing-object'}, $paramNode);
					break;
95ab3cf6   Menouard AZIB   Prise en compte d...
645
				default:
26a23052   Benjamin Renard   Add Interval Tick...
646
647
648
649
					throw new Exception('Drawing type not implemented.');
			}
			++$drawingEltIndex;
		}
95ab3cf6   Menouard AZIB   Prise en compte d...
650

26a23052   Benjamin Renard   Add Interval Tick...
651
652
		//Colored parameter
		$drawingEltIndex = 0;
95ab3cf6   Menouard AZIB   Prise en compte d...
653
654
		foreach ($paramsData as $paramData) {
			if (empty($paramData->{'param-drawing-object'}->{'serie-colored-param'})) {
26a23052   Benjamin Renard   Add Interval Tick...
655
656
657
				++$drawingEltIndex;
				continue;
			}
95ab3cf6   Menouard AZIB   Prise en compte d...
658

bf27ba04   Benjamin Renard   Add templated par...
659
			$paramColoredInfo = $this->paramManager->addExistingParam($paramData->{'param-drawing-object'}->{'serie-colored-param'}, $this->paramsData);
26a23052   Benjamin Renard   Add Interval Tick...
660
661
662
663
			if ($paramColoredInfo['id'] == '')
				throw new Exception('Cannot retrieve colored parameter.');
			$requestParamsNode->addParam($paramColoredInfo['id']);
			$coloredParamNode = $plotNode->getParams()->getParamById($paramColoredInfo['id']);
95ab3cf6   Menouard AZIB   Prise en compte d...
664

26a23052   Benjamin Renard   Add Interval Tick...
665
			$colorSerieId = $drawingEltIndex;
95ab3cf6   Menouard AZIB   Prise en compte d...
666
667
668
669

			switch ($paramData->{'param-drawing-type'}) {
				case 'serie':
				case 'orbit-serie':
26a23052   Benjamin Renard   Add Interval Tick...
670
671
672
673
674
675
676
677
					//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;
95ab3cf6   Menouard AZIB   Prise en compte d...
678
				default:
26a23052   Benjamin Renard   Add Interval Tick...
679
680
681
682
683
					throw new Exception('Colored parameter not allowed for this drawing type. ');
			}
			++$drawingEltIndex;
		}
	}
95ab3cf6   Menouard AZIB   Prise en compte d...
684

f822811a   Benjamin Renard   Implements multi ...
685
	protected function unmarshallSerie($paramData, $requestParamsNode, $plotNode, $paramNode, $indexes, $xId, $colorSerieId, $isOrbitSerie)
26a23052   Benjamin Renard   Add Interval Tick...
686
687
	{
		$serieNodes = array();
95ab3cf6   Menouard AZIB   Prise en compte d...
688
689
690

		if (!$isOrbitSerie) {
			if (count($indexes) == 0) {
f822811a   Benjamin Renard   Implements multi ...
691
				$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...
692
				$serieNode->setId($paramData->{'id'});
60a1a563   Benjamin Renard   Add the possibili...
693
694
				if (!empty($paramData->{'param-drawing-object'}->{'serie-resolution'}))
					$serieNode->setResolution($paramData->{'param-drawing-object'}->{'serie-resolution'});
26a23052   Benjamin Renard   Add Interval Tick...
695
696
				$serieNodes[] = $serieNode;
			}
95ab3cf6   Menouard AZIB   Prise en compte d...
697
			foreach ($indexes as $index) {
f822811a   Benjamin Renard   Implements multi ...
698
				$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...
699
700
				if (count($indexes) == 1)
					$serieNode->setId($paramData->{'id'});
60a1a563   Benjamin Renard   Add the possibili...
701
702
				if (!empty($paramData->{'param-drawing-object'}->{'serie-resolution'}))
					$serieNode->setResolution($paramData->{'param-drawing-object'}->{'serie-resolution'});
26a23052   Benjamin Renard   Add Interval Tick...
703
704
				$serieNodes[] = $serieNode;
			}
95ab3cf6   Menouard AZIB   Prise en compte d...
705
		} else {
cb46dfbf   Benjamin Renard   Fix orbit serie a...
706
			$orbitSerie = $paramNode->addOrbitSerie($paramData->{'param-drawing-object'}->{'serie-yaxis'}, $colorSerieId);
26a23052   Benjamin Renard   Add Interval Tick...
707
708
709
			$orbitSerie->setId($paramData->{'id'});
			$serieNodes[] = $orbitSerie;
		}
95ab3cf6   Menouard AZIB   Prise en compte d...
710
711
712

		foreach ($serieNodes as $serieNode) {
			if (!$isOrbitSerie) {
26a23052   Benjamin Renard   Add Interval Tick...
713
				//Resampling
95ab3cf6   Menouard AZIB   Prise en compte d...
714
715
716
				if ($plotNode->getName() == REQUESTOUTPUTPLOTELEMENTXY_NAME) {
					switch ($paramData->{'param-drawing-object'}->{'serie-resampling-mode'}) {
						case 'yparam':
26a23052   Benjamin Renard   Add Interval Tick...
717
718
							$serieNode->getResampling()->setType(RequestOutputPlotResamplingTypeEnum::YPARAM);
							break;
95ab3cf6   Menouard AZIB   Prise en compte d...
719
720
						case 'xparam':
						default:
26a23052   Benjamin Renard   Add Interval Tick...
721
722
723
							$serieNode->getResampling()->setType(RequestOutputPlotResamplingTypeEnum::XPARAM);
					}
				}
95ab3cf6   Menouard AZIB   Prise en compte d...
724
			} else {
26a23052   Benjamin Renard   Add Interval Tick...
725
				//Projection
95ab3cf6   Menouard AZIB   Prise en compte d...
726
727
				switch ($paramData->{'param-drawing-object'}->{'serie-projection'}) {
					case 'XY':
26a23052   Benjamin Renard   Add Interval Tick...
728
729
						$serieNode->setProjection(RequestOutputPlotOrbitSerieProjectionEnum::XY);
						break;
95ab3cf6   Menouard AZIB   Prise en compte d...
730
					case 'XZ':
26a23052   Benjamin Renard   Add Interval Tick...
731
732
						$serieNode->setProjection(RequestOutputPlotOrbitSerieProjectionEnum::XZ);
						break;
95ab3cf6   Menouard AZIB   Prise en compte d...
733
					case 'YZ':
26a23052   Benjamin Renard   Add Interval Tick...
734
735
						$serieNode->setProjection(RequestOutputPlotOrbitSerieProjectionEnum::YZ);
						break;
95ab3cf6   Menouard AZIB   Prise en compte d...
736
					case 'XR':
26a23052   Benjamin Renard   Add Interval Tick...
737
738
						$serieNode->setProjection(RequestOutputPlotOrbitSerieProjectionEnum::XR);
						break;
95ab3cf6   Menouard AZIB   Prise en compte d...
739
					case 'YR':
26a23052   Benjamin Renard   Add Interval Tick...
740
741
						$serieNode->setProjection(RequestOutputPlotOrbitSerieProjectionEnum::YR);
						break;
95ab3cf6   Menouard AZIB   Prise en compte d...
742
					case 'ZR':
26a23052   Benjamin Renard   Add Interval Tick...
743
744
						$serieNode->setProjection(RequestOutputPlotOrbitSerieProjectionEnum::ZR);
						break;
95ab3cf6   Menouard AZIB   Prise en compte d...
745
					default:
26a23052   Benjamin Renard   Add Interval Tick...
746
747
748
						throw new Exception('Projection not allowed for the orbit serie');
				}
			}
95ab3cf6   Menouard AZIB   Prise en compte d...
749

26a23052   Benjamin Renard   Add Interval Tick...
750
751
752
753
754
755
756
757
758
759
760
761
762
			//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());
95ab3cf6   Menouard AZIB   Prise en compte d...
763
			if (!$isOrbitSerie) {
26a23052   Benjamin Renard   Add Interval Tick...
764
765
766
767
768
769
				//Error bar
				if ($paramData->{'param-drawing-object'}->{'serie-errorbar-activated'})
					$this->unmarshallErrorBar($paramData->{'param-drawing-object'}, $requestParamsNode, $serieNode->getErrorBar());
			}
		}
	}
95ab3cf6   Menouard AZIB   Prise en compte d...
770

26a23052   Benjamin Renard   Add Interval Tick...
771
772
773
774
775
776
777
778
779
780
781
	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
95ab3cf6   Menouard AZIB   Prise en compte d...
782
783
		switch ($serieData->{'serie-timetick-type'}) {
			case 'time-step':
26a23052   Benjamin Renard   Add Interval Tick...
784
785
786
				$timeTickNode->setStep(CommonClass::timeStampToDDTime($serieData->{'serie-timetick-step'}));
				$timeTickNode->setNumber(0);
				break;
95ab3cf6   Menouard AZIB   Prise en compte d...
787
			case 'nb-major':
26a23052   Benjamin Renard   Add Interval Tick...
788
789
790
				$timeTickNode->setStep(0);
				$timeTickNode->setNumber($serieData->{'serie-timetick-nbmajor'});
				break;
95ab3cf6   Menouard AZIB   Prise en compte d...
791
792
			case 'auto':
			default:
26a23052   Benjamin Renard   Add Interval Tick...
793
794
795
796
797
798
799
800
				$timeTickNode->setStep('auto');
				$timeTickNode->setNumber(0);
		}
		//Minor
		$timeTickNode->setMinor($serieData->{'serie-timetick-nbminor'});
		//Color
		$timeTickNode->setColor($this->hexColor2KernelColor($serieData->{'serie-timetick-color'}));
	}
95ab3cf6   Menouard AZIB   Prise en compte d...
801

26a23052   Benjamin Renard   Add Interval Tick...
802
803
804
	protected function unmarshallIntervalTick($serieData, $intervalTickNode)
	{
		//Mode
95ab3cf6   Menouard AZIB   Prise en compte d...
805
		switch ($serieData->{'serie-intervaltick-mode'}) {
26a23052   Benjamin Renard   Add Interval Tick...
806
			case 'symbol-only':
4f9a8e36   Benjamin Renard   Min/Max value def...
807
				$intervalTickNode->setMode(RequestOutputPlotSerieIntervalTicksModeEnum::SYMBOLONLY);
26a23052   Benjamin Renard   Add Interval Tick...
808
809
				break;
			case 'interval-index':
4f9a8e36   Benjamin Renard   Min/Max value def...
810
				$intervalTickNode->setMode(RequestOutputPlotSerieIntervalTicksModeEnum::INTERVALINDEX);
26a23052   Benjamin Renard   Add Interval Tick...
811
812
				break;
			case 'start-stop-time':
4f9a8e36   Benjamin Renard   Min/Max value def...
813
				$intervalTickNode->setMode(RequestOutputPlotSerieIntervalTicksModeEnum::STARTSTOPTIME);
26a23052   Benjamin Renard   Add Interval Tick...
814
815
				break;
			case 'start-time':
95ab3cf6   Menouard AZIB   Prise en compte d...
816
			default:
4f9a8e36   Benjamin Renard   Min/Max value def...
817
				$intervalTickNode->setMode(RequestOutputPlotSerieIntervalTicksModeEnum::STARTTIME);
26a23052   Benjamin Renard   Add Interval Tick...
818
		}
95ab3cf6   Menouard AZIB   Prise en compte d...
819

26a23052   Benjamin Renard   Add Interval Tick...
820
821
		//Color
		$intervalTickNode->setColor($this->hexColor2KernelColor($serieData->{'serie-intervaltick-color'}));
95ab3cf6   Menouard AZIB   Prise en compte d...
822

26a23052   Benjamin Renard   Add Interval Tick...
823
824
		//Symbol
		$this->unmarshallSymbol($serieData, 'serie-intervaltick-symbols', $intervalTickNode->getSymbol());
95ab3cf6   Menouard AZIB   Prise en compte d...
825

26a23052   Benjamin Renard   Add Interval Tick...
826
827
828
829
		//Font
		if ($serieData->{'serie-intervaltick-font-activated'})
			$this->unmarshallFont($serieData, 'serie-intervaltick-font', $intervalTickNode->getFont());
	}
95ab3cf6   Menouard AZIB   Prise en compte d...
830

26a23052   Benjamin Renard   Add Interval Tick...
831
832
833
	protected function unmarshallErrorBar($serieData, $requestParamsNode, $errorBarNode)
	{
		//Type
95ab3cf6   Menouard AZIB   Prise en compte d...
834
		switch ($serieData->{'serie-errorbar-type'}) {
26a23052   Benjamin Renard   Add Interval Tick...
835
836
			case 'min-max':
				$errorBarTypeNode = $errorBarNode->getBarByType(RequestOutputPlotYSerieErrorBarTypeEnum::MINMAX);
95ab3cf6   Menouard AZIB   Prise en compte d...
837

bf27ba04   Benjamin Renard   Add templated par...
838
				$minParamInfo = $this->paramManager->addExistingParam($serieData->{'serie-errorbar-minparam'}, $this->paramsData);
26a23052   Benjamin Renard   Add Interval Tick...
839
840
841
842
843
844
845
846
847
				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.');
95ab3cf6   Menouard AZIB   Prise en compte d...
848

bf27ba04   Benjamin Renard   Add templated par...
849
				$maxParamInfo = $this->paramManager->addExistingParam($serieData->{'serie-errorbar-maxparam'}, $this->paramsData);
26a23052   Benjamin Renard   Add Interval Tick...
850
851
852
853
854
855
856
857
858
859
860
861
				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);
95ab3cf6   Menouard AZIB   Prise en compte d...
862

bf27ba04   Benjamin Renard   Add templated par...
863
				$deltaParamInfo = $this->paramManager->addExistingParam($serieData->{'serie-errorbar-deltaparam'}, $this->paramsData);
26a23052   Benjamin Renard   Add Interval Tick...
864
865
866
867
868
869
870
871
872
873
				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;
95ab3cf6   Menouard AZIB   Prise en compte d...
874
			default:
26a23052   Benjamin Renard   Add Interval Tick...
875
876
				throw new Exception('Unknown error bar type.');
		}
95ab3cf6   Menouard AZIB   Prise en compte d...
877

26a23052   Benjamin Renard   Add Interval Tick...
878
879
880
		//Line
		$this->unmarshallLine($serieData, 'serie-errorbar', $errorBarNode->getLine(), RequestOutputPlotLineTypeEnum::LINE);
	}
95ab3cf6   Menouard AZIB   Prise en compte d...
881

26a23052   Benjamin Renard   Add Interval Tick...
882
883
	protected function unmarshallInstantSerie($paramDrawingData, $plotNode, $paramNode)
	{
cb46dfbf   Benjamin Renard   Fix orbit serie a...
884
		$iserieNode = $paramNode->addInstantSerie('y-left');
95ab3cf6   Menouard AZIB   Prise en compte d...
885

26a23052   Benjamin Renard   Add Interval Tick...
886
887
		//Table on X Axis
		$iserieNode->setTableOnXAxis($paramDrawingData->{'iserie-tableonx'} ? "true" : "false");
95ab3cf6   Menouard AZIB   Prise en compte d...
888

26a23052   Benjamin Renard   Add Interval Tick...
889
890
891
892
893
894
895
896
897
		//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());
	}
95ab3cf6   Menouard AZIB   Prise en compte d...
898

26a23052   Benjamin Renard   Add Interval Tick...
899
900
	protected function unmarshallSpectro($paramDrawingData, $plotNode, $paramNode, $indexes)
	{
95ab3cf6   Menouard AZIB   Prise en compte d...
901
902
903
904
905
906
907
908
909
910
911
912
		$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'},
			empty($paramDrawingData->{REQUESTOUTPUTPLOTSPECTRO_BGS_TYPE}) ? NULL : $paramDrawingData->{REQUESTOUTPUTPLOTSPECTRO_BGS_TYPE},
			!isset($paramDrawingData->{REQUESTOUTPUTPLOTSPECTRO_BGS_VALUE}) ? NULL : $paramDrawingData->{REQUESTOUTPUTPLOTSPECTRO_BGS_VALUE},
			!isset($paramDrawingData->{REQUESTOUTPUTPLOTSPECTRO_BGS_DIM}) ? NULL : $paramDrawingData->{REQUESTOUTPUTPLOTSPECTRO_BGS_DIM}
		);
26a23052   Benjamin Renard   Add Interval Tick...
913
	}
3dcf7710   Hacene SI HADJ MOHAND   us ok
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
        	protected function unmarshallSauvaud($paramDrawingData, $plotNode, $paramNode, $indexes)
	{
		$spectroNode = $paramNode->addSauvaud(
			$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'},
			empty($paramDrawingData->{REQUESTOUTPUTPLOTSPECTRO_BGS_TYPE}) ? NULL : $paramDrawingData->{REQUESTOUTPUTPLOTSPECTRO_BGS_TYPE},
			!isset($paramDrawingData->{REQUESTOUTPUTPLOTSPECTRO_BGS_VALUE}) ? NULL : $paramDrawingData->{REQUESTOUTPUTPLOTSPECTRO_BGS_VALUE},
			!isset($paramDrawingData->{REQUESTOUTPUTPLOTSPECTRO_BGS_DIM}) ? NULL : $paramDrawingData->{REQUESTOUTPUTPLOTSPECTRO_BGS_DIM}, 
                                                            $paramDrawingData->{'right_dim'}
		);
	}
95ab3cf6   Menouard AZIB   Prise en compte d...
930

fc153c1c   Elena.Budnik   ispectro added
931
932
	protected function unmarshallInstantSpectro($paramDrawingData, $plotNode, $paramNode, $indexes)
	{
95ab3cf6   Menouard AZIB   Prise en compte d...
933
		//TBD how to process inexes if they are defined ? 
cb46dfbf   Benjamin Renard   Fix orbit serie a...
934
		$spectroNode = $paramNode->addInstantSpectro('y-left', $paramDrawingData->{'ispectro-dimonxaxis'});
fc153c1c   Elena.Budnik   ispectro added
935
	}
95ab3cf6   Menouard AZIB   Prise en compte d...
936

26a23052   Benjamin Renard   Add Interval Tick...
937
938
	protected function unmarshallStatusBar($paramDrawingData, $paramNode, $indexes)
	{
25a38537   Erdogan Furkan   7616 - Adding col...
939
940
941
942
943
		if ($paramDrawingData->{'statusbar-color'} == "none") {
			$color = NULL;
		} else {
			$color = $this->hexColor2KernelColor($paramDrawingData->{'statusbar-color'});
		}
26a23052   Benjamin Renard   Add Interval Tick...
944
		if (count($indexes) == 0)
25a38537   Erdogan Furkan   7616 - Adding col...
945
946
947
948
949
950
			$paramNode->addStatusBar(-1, $color);
		else {
			foreach ($indexes as $index)
				$paramNode->addStatusBar($index, $color);
		}

26a23052   Benjamin Renard   Add Interval Tick...
951
	}
044a9305   Benjamin Renard   Add intervals dra...
952
953
954

	protected function unmarshallIntervals($paramDrawingData, $paramNode)
	{
25a38537   Erdogan Furkan   7616 - Adding col...
955
956
957
958
959
960
		if ($paramDrawingData->{'intervals-color'} == "none") {
			$color = NULL;
		} else {
			$color = $this->hexColor2KernelColor($paramDrawingData->{'intervals-color'});
		}
		$paramNode->addIntervals($color);
044a9305   Benjamin Renard   Add intervals dra...
961
	}
95ab3cf6   Menouard AZIB   Prise en compte d...
962

26a23052   Benjamin Renard   Add Interval Tick...
963
964
965
966
967
968
969
	protected function unmarshallTickBar($paramDrawingData, $paramNode, $indexes)
	{
		if (count($indexes) == 0)
			$paramNode->addTickBar(-1);
		foreach ($indexes as $index)
			$paramNode->addTickBar($index);
	}
95ab3cf6   Menouard AZIB   Prise en compte d...
970

26a23052   Benjamin Renard   Add Interval Tick...
971
972
973
974
975
976
977
	protected function hasStatusBar($paramsData)
	{
		foreach ($paramsData as $paramData)
			if ($paramData->{'param-drawing-type'} == 'status-bar')
				return true;
		return false;
	}
95ab3cf6   Menouard AZIB   Prise en compte d...
978

26a23052   Benjamin Renard   Add Interval Tick...
979
980
981
982
983
984
985
	protected function hasTickBar($paramsData)
	{
		foreach ($paramsData as $paramData)
			if ($paramData->{'param-drawing-type'} == 'tick-bar')
				return true;
		return false;
	}
95ab3cf6   Menouard AZIB   Prise en compte d...
986

26a23052   Benjamin Renard   Add Interval Tick...
987
988
989
	protected function unmarshallParamsLegend($paramsLegendData, $paramsLegendNode)
	{
		//Legend type
95ab3cf6   Menouard AZIB   Prise en compte d...
990
991
		switch ($paramsLegendData->{'legend-series-type'}) {
			case 'text-line-symbol':
26a23052   Benjamin Renard   Add Interval Tick...
992
993
				$paramsLegendNode->setType(RequestOutputPlotParamsLegendTypeEnum::TEXTLINESYMBOL);
				break;
95ab3cf6   Menouard AZIB   Prise en compte d...
994
995
			case 'text-only':
			default:
26a23052   Benjamin Renard   Add Interval Tick...
996
997
				$paramsLegendNode->setType(RequestOutputPlotParamsLegendTypeEnum::TEXTONLY);
		}
95ab3cf6   Menouard AZIB   Prise en compte d...
998

26a23052   Benjamin Renard   Add Interval Tick...
999
1000
		//Show param legend
		$paramsLegendNode->setShowParamInfo($paramsLegendData->{'legend-series-showparaminfo'} ? "true" : "false");
95ab3cf6   Menouard AZIB   Prise en compte d...
1001

26a23052   Benjamin Renard   Add Interval Tick...
1002
1003
		//Show interval legend
		$paramsLegendNode->setShowIntervalInfo($paramsLegendData->{'legend-series-intervalinfo-activated'} ? "true" : "false");
95ab3cf6   Menouard AZIB   Prise en compte d...
1004

26a23052   Benjamin Renard   Add Interval Tick...
1005
		//Interval info type
95ab3cf6   Menouard AZIB   Prise en compte d...
1006
1007
		switch ($paramsLegendData->{'legend-series-intervalinfo-type'}) {
			case 'start-stop':
26a23052   Benjamin Renard   Add Interval Tick...
1008
1009
				$paramsLegendNode->setIntervalInfoType(RequestOutputPlotParamsLegendIntervalInfoTypeEnum::STARTSTOP);
				break;
95ab3cf6   Menouard AZIB   Prise en compte d...
1010
1011
			case 'index':
			default:
26a23052   Benjamin Renard   Add Interval Tick...
1012
1013
				$paramsLegendNode->setIntervalInfoType(RequestOutputPlotParamsLegendIntervalInfoTypeEnum::INDEX);
		}
95ab3cf6   Menouard AZIB   Prise en compte d...
1014

26a23052   Benjamin Renard   Add Interval Tick...
1015
		//Position
95ab3cf6   Menouard AZIB   Prise en compte d...
1016
1017
		switch ($paramsLegendData->{'legend-series-position'}) {
			case 'inside':
26a23052   Benjamin Renard   Add Interval Tick...
1018
1019
				$paramsLegendNode->setPosition(RequestOutputPlotParamsLegendPositionEnum::INSIDE);
				break;
95ab3cf6   Menouard AZIB   Prise en compte d...
1020
1021
			case 'outside':
			default:
26a23052   Benjamin Renard   Add Interval Tick...
1022
1023
				$paramsLegendNode->setPosition(RequestOutputPlotParamsLegendPositionEnum::OUTSIDE);
		}
95ab3cf6   Menouard AZIB   Prise en compte d...
1024

26a23052   Benjamin Renard   Add Interval Tick...
1025
1026
		//Default text color
		$paramsLegendNode->setDefaultTextColor($this->hexColor2KernelColor($paramsLegendData->{'legend-series-defaulttextcolor'}));
95ab3cf6   Menouard AZIB   Prise en compte d...
1027

26a23052   Benjamin Renard   Add Interval Tick...
1028
1029
		//Border visible
		$paramsLegendNode->setBorderVisible($paramsLegendData->{'legend-series-border-activated'} ? "true" : "false");
95ab3cf6   Menouard AZIB   Prise en compte d...
1030

26a23052   Benjamin Renard   Add Interval Tick...
1031
1032
		//Border color
		$paramsLegendNode->setBorderColor($this->hexColor2KernelColor($paramsLegendData->{'legend-series-border-color'}));
95ab3cf6   Menouard AZIB   Prise en compte d...
1033

26a23052   Benjamin Renard   Add Interval Tick...
1034
1035
1036
1037
		//Font
		if ($paramsLegendData->{'legend-series-font-activated'})
			$this->unmarshallFont($paramsLegendData, 'legend-series-font', $paramsLegendNode->getFont());
	}
95ab3cf6   Menouard AZIB   Prise en compte d...
1038

26a23052   Benjamin Renard   Add Interval Tick...
1039
1040
1041
	protected function unmarshallTextLegend($textLegendData, $legendsNode)
	{
		$legendNode = $legendsNode->addTextLegend();
95ab3cf6   Menouard AZIB   Prise en compte d...
1042

26a23052   Benjamin Renard   Add Interval Tick...
1043
1044
		//Legend text
		$legendNode->setText($textLegendData->{'legend-text-value'});
95ab3cf6   Menouard AZIB   Prise en compte d...
1045

26a23052   Benjamin Renard   Add Interval Tick...
1046
		//Legend position
95ab3cf6   Menouard AZIB   Prise en compte d...
1047
1048
		switch ($textLegendData->{'legend-text-position'}) {
			case 'top':
26a23052   Benjamin Renard   Add Interval Tick...
1049
1050
				$legendNode->setPosition(RequestOutputPlotTextLegendPositionEnum::TOP);
				break;
95ab3cf6   Menouard AZIB   Prise en compte d...
1051
			case 'bottom':
26a23052   Benjamin Renard   Add Interval Tick...
1052
1053
				$legendNode->setPosition(RequestOutputPlotTextLegendPositionEnum::BOTTOM);
				break;
95ab3cf6   Menouard AZIB   Prise en compte d...
1054
			case 'left':
26a23052   Benjamin Renard   Add Interval Tick...
1055
1056
				$legendNode->setPosition(RequestOutputPlotTextLegendPositionEnum::LEFT);
				break;
95ab3cf6   Menouard AZIB   Prise en compte d...
1057
1058
			case 'right':
			default:
26a23052   Benjamin Renard   Add Interval Tick...
1059
1060
				$legendNode->setPosition(RequestOutputPlotTextLegendPositionEnum::RIGHT);
		}
95ab3cf6   Menouard AZIB   Prise en compte d...
1061

26a23052   Benjamin Renard   Add Interval Tick...
1062
1063
		//Legend text color
		$legendNode->setColor($this->hexColor2KernelColor($textLegendData->{'legend-text-color'}));
95ab3cf6   Menouard AZIB   Prise en compte d...
1064

26a23052   Benjamin Renard   Add Interval Tick...
1065
1066
1067
1068
		//Font
		if ($textLegendData->{'legend-text-font-activated'})
			$this->unmarshallFont($textLegendData, 'legend-text-font', $legendNode->getFont());
	}
95ab3cf6   Menouard AZIB   Prise en compte d...
1069
1070

	protected function unmarshallConstant($constantData, $axisNode)
26a23052   Benjamin Renard   Add Interval Tick...
1071
1072
1073
	{
		$constantNode = $axisNode->addConstant();
		$constantNode->setId($constantData->{'id'});
95ab3cf6   Menouard AZIB   Prise en compte d...
1074

26a23052   Benjamin Renard   Add Interval Tick...
1075
		//Constant value
95ab3cf6   Menouard AZIB   Prise en compte d...
1076
1077
		switch ($axisNode->getName()) {
			case REQUESTOUTPUTPLOTTIMEAXIS_NAME:
26a23052   Benjamin Renard   Add Interval Tick...
1078
				date_default_timezone_set('UTC');
74fd500a   Hacene SI HADJ MOHAND   us #9874 ms zoo...
1079
				$time = CommonClass::strTimeToDDTime($constantData->{'constant-time-value'});
26a23052   Benjamin Renard   Add Interval Tick...
1080
1081
				$constantNode->setConstantValue($time);
				break;
95ab3cf6   Menouard AZIB   Prise en compte d...
1082
			default:
26a23052   Benjamin Renard   Add Interval Tick...
1083
1084
				$constantNode->setConstantValue($constantData->{'constant-float-value'});
		}
95ab3cf6   Menouard AZIB   Prise en compte d...
1085

26a23052   Benjamin Renard   Add Interval Tick...
1086
1087
1088
		//Curve options
		$this->unmarshallCurve($constantData, "constant-line", $constantNode);
	}
95ab3cf6   Menouard AZIB   Prise en compte d...
1089

26a23052   Benjamin Renard   Add Interval Tick...
1090
1091
1092
1093
1094
1095
1096
	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);
	}
95ab3cf6   Menouard AZIB   Prise en compte d...
1097

26a23052   Benjamin Renard   Add Interval Tick...
1098
1099
1100
	protected function unmarshallTextObject($textData, $addObjectsNode, $isTimePlot)
	{
		$textNode = $addObjectsNode->addTextObject();
95ab3cf6   Menouard AZIB   Prise en compte d...
1101

26a23052   Benjamin Renard   Add Interval Tick...
1102
		$textNode->setText($textData->{'text-value'});
95ab3cf6   Menouard AZIB   Prise en compte d...
1103
1104
1105

		switch ($textData->{'text-y-axis'}) {
			case 'y-right':
26a23052   Benjamin Renard   Add Interval Tick...
1106
1107
				$textNode->setYAxis('y-right');
				break;
95ab3cf6   Menouard AZIB   Prise en compte d...
1108
			case 'y-left':
26a23052   Benjamin Renard   Add Interval Tick...
1109
1110
1111
				$textNode->setYAxis('y-left');
				break;
		}
95ab3cf6   Menouard AZIB   Prise en compte d...
1112
1113

		if ($isTimePlot && !$textData->{'text-x-relative'}) {
26a23052   Benjamin Renard   Add Interval Tick...
1114
			date_default_timezone_set('UTC');
74fd500a   Hacene SI HADJ MOHAND   us #9874 ms zoo...
1115
			$time = CommonClass::strTimeToDDTime($textData->{'text-x-timevalue'});
26a23052   Benjamin Renard   Add Interval Tick...
1116
			$textNode->setX($time);
95ab3cf6   Menouard AZIB   Prise en compte d...
1117
1118
		} else if ($textData->{'text-x-relative'})
			$textNode->setX(($textData->{'text-x-floatvalue'} * 100) . "%");
26a23052   Benjamin Renard   Add Interval Tick...
1119
1120
		else
			$textNode->setX($textData->{'text-x-floatvalue'});
95ab3cf6   Menouard AZIB   Prise en compte d...
1121

26a23052   Benjamin Renard   Add Interval Tick...
1122
		if ($textData->{'text-y-relative'})
95ab3cf6   Menouard AZIB   Prise en compte d...
1123
			$textNode->setY(($textData->{'text-y-value'} * 100) . "%");
26a23052   Benjamin Renard   Add Interval Tick...
1124
1125
		else
			$textNode->setY($textData->{'text-y-value'});
95ab3cf6   Menouard AZIB   Prise en compte d...
1126

26a23052   Benjamin Renard   Add Interval Tick...
1127
		$textNode->setAngle($textData->{'text-angle'});
95ab3cf6   Menouard AZIB   Prise en compte d...
1128

26a23052   Benjamin Renard   Add Interval Tick...
1129
		$textNode->setColor($this->hexColor2KernelColor($textData->{'text-color'}));
95ab3cf6   Menouard AZIB   Prise en compte d...
1130
1131
1132

		switch ($textData->{'text-align'}) {
			case 'center':
26a23052   Benjamin Renard   Add Interval Tick...
1133
1134
				$textNode->setAlign(RequestOutputPlotTextAlign::CENTER);
				break;
95ab3cf6   Menouard AZIB   Prise en compte d...
1135
			case 'right':
26a23052   Benjamin Renard   Add Interval Tick...
1136
1137
				$textNode->setAlign(RequestOutputPlotTextAlign::RIGHT);
				break;
95ab3cf6   Menouard AZIB   Prise en compte d...
1138
			case 'left':
26a23052   Benjamin Renard   Add Interval Tick...
1139
1140
1141
			default:
				$textNode->setAlign(RequestOutputPlotTextAlign::LEFT);
		}
95ab3cf6   Menouard AZIB   Prise en compte d...
1142

26a23052   Benjamin Renard   Add Interval Tick...
1143
1144
1145
1146
		//Font
		if ($textData->{'text-font-activated'})
			$this->unmarshallFont($textData, 'text-font', $textNode->getFont());
	}
95ab3cf6   Menouard AZIB   Prise en compte d...
1147

26a23052   Benjamin Renard   Add Interval Tick...
1148
1149
1150
1151
	protected function unmarshallCurveObject($curveData, $addObjectsNode)
	{
		if (($curveData->{'curve-name'} == '') || !isset($curveData->{'curve-serie-id'}))
			return;
95ab3cf6   Menouard AZIB   Prise en compte d...
1152

26a23052   Benjamin Renard   Add Interval Tick...
1153
		$curveNode = $addObjectsNode->addCurveObject();
95ab3cf6   Menouard AZIB   Prise en compte d...
1154

26a23052   Benjamin Renard   Add Interval Tick...
1155
		$curveNode->setSerieId($curveData->{'curve-serie-id'});
95ab3cf6   Menouard AZIB   Prise en compte d...
1156

26a23052   Benjamin Renard   Add Interval Tick...
1157
		$curveNode->getFunction()->setFunctionName($curveData->{'curve-name'});
95ab3cf6   Menouard AZIB   Prise en compte d...
1158

26a23052   Benjamin Renard   Add Interval Tick...
1159
1160
		foreach ($curveData->{'params'} as $paramData)
			$curveNode->getFunction()->addAttribute($paramData->{'curve-param-name'}, $paramData->{'curve-param-value'});
95ab3cf6   Menouard AZIB   Prise en compte d...
1161

26a23052   Benjamin Renard   Add Interval Tick...
1162
1163
1164
		//Curve options
		$this->unmarshallCurve($curveData, "curve-line", $curveNode);
	}
95ab3cf6   Menouard AZIB   Prise en compte d...
1165

26a23052   Benjamin Renard   Add Interval Tick...
1166
1167
	protected function unmarshallFills($panelData, $fillsNode)
	{
95ab3cf6   Menouard AZIB   Prise en compte d...
1168
		foreach ($panelData->{'fills'} as $fillData) {
26a23052   Benjamin Renard   Add Interval Tick...
1169
			//Serie / Constant
95ab3cf6   Menouard AZIB   Prise en compte d...
1170
			if ($fillData->{'fill-type'} == 'serie-constant') {
26a23052   Benjamin Renard   Add Interval Tick...
1171
1172
1173
1174
1175
1176
1177
1178
1179
				$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'}));
			}
		}
95ab3cf6   Menouard AZIB   Prise en compte d...
1180
1181

		foreach ($panelData->{'fills'} as $fillData) {
26a23052   Benjamin Renard   Add Interval Tick...
1182
			//Serie / Serie
95ab3cf6   Menouard AZIB   Prise en compte d...
1183
			if ($fillData->{'fill-type'} == 'serie-serie') {
26a23052   Benjamin Renard   Add Interval Tick...
1184
1185
1186
1187
1188
1189
1190
1191
				$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'}));
			}
95ab3cf6   Menouard AZIB   Prise en compte d...
1192
		}
26a23052   Benjamin Renard   Add Interval Tick...
1193
	}
95ab3cf6   Menouard AZIB   Prise en compte d...
1194

26a23052   Benjamin Renard   Add Interval Tick...
1195
1196
1197
1198
1199
	protected function unmarshallTitle($inputData, $keyPrefix, $titleNode)
	{
		if ($inputData->{$keyPrefix.'-text'} != '')
		{
			$titleNode->setText($inputData->{$keyPrefix.'-text'});
d62f9945   Benjamin Renard   Improve instant c...
1200
		}
26a23052   Benjamin Renard   Add Interval Tick...
1201
		
d62f9945   Benjamin Renard   Improve instant c...
1202
1203
1204
1205
1206
1207
1208
1209
1210
		switch ($inputData->{$keyPrefix.'-position'})
		{
			case 'top' :
				$titleNode->setPosition(RequestOutputPlotTitlePosition::TOP);
				break;
			case 'bottom' :
				$titleNode->setPosition(RequestOutputPlotTitlePosition::BOTTOM);
				break;
		}
26a23052   Benjamin Renard   Add Interval Tick...
1211
		
d62f9945   Benjamin Renard   Improve instant c...
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
		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...
1223
		}
d62f9945   Benjamin Renard   Improve instant c...
1224
1225
1226
1227
1228
			
		if ($inputData->{$keyPrefix.'-color'} != '')
			$titleNode->setColor($this->hexColor2KernelColor($inputData->{$keyPrefix.'-color'}));

		$this->unmarshallLabel($inputData, $keyPrefix, $titleNode);
26a23052   Benjamin Renard   Add Interval Tick...
1229
	}
95ab3cf6   Menouard AZIB   Prise en compte d...
1230

26a23052   Benjamin Renard   Add Interval Tick...
1231
1232
	protected function unmarshallLabel($inputData, $keyPrefix, $labelNode)
	{
95ab3cf6   Menouard AZIB   Prise en compte d...
1233
1234
1235
1236
		if ($inputData->{$keyPrefix . '-font-activated'}) {
			$labelNode->setFontName($inputData->{$keyPrefix . '-font-name'});
			$labelNode->setFontSize($inputData->{$keyPrefix . '-font-size'});
			if ($inputData->{$keyPrefix . '-font-bold'}) {
20e36076   Benjamin Renard   Update interface ...
1237
				$labelNode->setFontWeight("bold");
26a23052   Benjamin Renard   Add Interval Tick...
1238
			}
95ab3cf6   Menouard AZIB   Prise en compte d...
1239
1240
			if ($inputData->{$keyPrefix . '-font-italic'}) {
				$labelNode->setFontStyle("italic");
26a23052   Benjamin Renard   Add Interval Tick...
1241
			}
26a23052   Benjamin Renard   Add Interval Tick...
1242
		}
26a23052   Benjamin Renard   Add Interval Tick...
1243
	}
95ab3cf6   Menouard AZIB   Prise en compte d...
1244

26a23052   Benjamin Renard   Add Interval Tick...
1245
1246
	protected function unmarshallFont($inputData, $keyPrefix, $fontNode)
	{
95ab3cf6   Menouard AZIB   Prise en compte d...
1247
1248
1249
1250
1251
		if ($inputData->{$keyPrefix . '-activated'}) {
			$fontNode->setFontName($inputData->{$keyPrefix . '-name'});
			$fontNode->setSize($inputData->{$keyPrefix . '-size'});

			if ($inputData->{$keyPrefix . '-italic'})
26a23052   Benjamin Renard   Add Interval Tick...
1252
1253
1254
				$fontNode->setStyle(RequestOutputPlotFontStyle::ITALIC);
			else
				$fontNode->setStyle(RequestOutputPlotFontStyle::UPRIGHT);
95ab3cf6   Menouard AZIB   Prise en compte d...
1255
1256

			if ($inputData->{$keyPrefix . '-bold'})
26a23052   Benjamin Renard   Add Interval Tick...
1257
1258
1259
1260
1261
				$fontNode->setWeight(RequestOutputPlotFontWeight::BOLD);
			else
				$fontNode->setWeight(RequestOutputPlotFontWeight::MEDIUM);
		}
	}
95ab3cf6   Menouard AZIB   Prise en compte d...
1262

26a23052   Benjamin Renard   Add Interval Tick...
1263
1264
	protected function unmarshallCurve($inputData, $keyPrefix, $curveNode)
	{
95ab3cf6   Menouard AZIB   Prise en compte d...
1265
1266
1267
		switch ($inputData->{$keyPrefix . '-style'}) {

			case 'dot':
26a23052   Benjamin Renard   Add Interval Tick...
1268
1269
				$curveNode->setStyle(RequestOutputPlotCurveStyleEnum::DOT);
				break;
95ab3cf6   Menouard AZIB   Prise en compte d...
1270
			case 'long-spaced-dot':
26a23052   Benjamin Renard   Add Interval Tick...
1271
1272
				$curveNode->setStyle(RequestOutputPlotCurveStyleEnum::LONGSPACEDDOT);
				break;
95ab3cf6   Menouard AZIB   Prise en compte d...
1273
			case 'long-short-dot':
26a23052   Benjamin Renard   Add Interval Tick...
1274
1275
				$curveNode->setStyle(RequestOutputPlotCurveStyleEnum::LONGSHORTDOT);
				break;
95ab3cf6   Menouard AZIB   Prise en compte d...
1276
1277
			case 'plain':
			default:
02abc780   Benjamin Renard   Support request f...
1278
1279
				$curveNode->setStyle(RequestOutputPlotCurveStyleEnum::PLAIN);
				break;
26a23052   Benjamin Renard   Add Interval Tick...
1280
		}
95ab3cf6   Menouard AZIB   Prise en compte d...
1281
1282
1283
1284
1285
1286

		if (isset($inputData->{$keyPrefix . '-width'}))
			$curveNode->setWidth($inputData->{$keyPrefix . '-width'});

		if (isset($inputData->{$keyPrefix . '-color'}) && ($inputData->{$keyPrefix . '-color'} != 'auto'))
			$curveNode->setColor($this->hexColor2KernelColor($inputData->{$keyPrefix . '-color'}));
26a23052   Benjamin Renard   Add Interval Tick...
1287
	}
95ab3cf6   Menouard AZIB   Prise en compte d...
1288

26a23052   Benjamin Renard   Add Interval Tick...
1289
1290
1291
	protected function unmarshallLine($inputData, $keyPrefix, $lineNode, $lineType)
	{
		$lineNode->setType($lineType);
95ab3cf6   Menouard AZIB   Prise en compte d...
1292
		$this->unmarshallCurve($inputData, $keyPrefix . "-lines", $lineNode);
26a23052   Benjamin Renard   Add Interval Tick...
1293
	}
95ab3cf6   Menouard AZIB   Prise en compte d...
1294

26a23052   Benjamin Renard   Add Interval Tick...
1295
1296
	protected function unmarshallSymbol($inputData, $keyPrefix, $symbolNode)
	{
95ab3cf6   Menouard AZIB   Prise en compte d...
1297
1298
		switch ($inputData->{$keyPrefix . '-type'}) {
			case 'dot':
26a23052   Benjamin Renard   Add Interval Tick...
1299
1300
				$symbolNode->setType(RequestOutputPlotSymbolTypeEnum::DOT);
				break;
95ab3cf6   Menouard AZIB   Prise en compte d...
1301
			case 'plus':
26a23052   Benjamin Renard   Add Interval Tick...
1302
1303
				$symbolNode->setType(RequestOutputPlotSymbolTypeEnum::PLUS);
				break;
95ab3cf6   Menouard AZIB   Prise en compte d...
1304
			case 'wildcard':
26a23052   Benjamin Renard   Add Interval Tick...
1305
1306
				$symbolNode->setType(RequestOutputPlotSymbolTypeEnum::WILDCARD);
				break;
95ab3cf6   Menouard AZIB   Prise en compte d...
1307
			case 'circle':
26a23052   Benjamin Renard   Add Interval Tick...
1308
1309
				$symbolNode->setType(RequestOutputPlotSymbolTypeEnum::CIRCLE);
				break;
95ab3cf6   Menouard AZIB   Prise en compte d...
1310
			case 'crux':
26a23052   Benjamin Renard   Add Interval Tick...
1311
1312
				$symbolNode->setType(RequestOutputPlotSymbolTypeEnum::CRUX);
				break;
95ab3cf6   Menouard AZIB   Prise en compte d...
1313
			case 'square':
26a23052   Benjamin Renard   Add Interval Tick...
1314
1315
				$symbolNode->setType(RequestOutputPlotSymbolTypeEnum::SQUARE);
				break;
95ab3cf6   Menouard AZIB   Prise en compte d...
1316
			case 'triangle':
26a23052   Benjamin Renard   Add Interval Tick...
1317
1318
				$symbolNode->setType(RequestOutputPlotSymbolTypeEnum::TRIANGLE);
				break;
95ab3cf6   Menouard AZIB   Prise en compte d...
1319
			case 'crux-in-circle':
26a23052   Benjamin Renard   Add Interval Tick...
1320
1321
				$symbolNode->setType(RequestOutputPlotSymbolTypeEnum::CRUXINCIRCLE);
				break;
95ab3cf6   Menouard AZIB   Prise en compte d...
1322
			case 'dot-in-circle':
26a23052   Benjamin Renard   Add Interval Tick...
1323
1324
				$symbolNode->setType(RequestOutputPlotSymbolTypeEnum::DOTINCIRCLE);
				break;
95ab3cf6   Menouard AZIB   Prise en compte d...
1325
			case 'diamond':
26a23052   Benjamin Renard   Add Interval Tick...
1326
1327
				$symbolNode->setType(RequestOutputPlotSymbolTypeEnum::DIAMOND);
				break;
95ab3cf6   Menouard AZIB   Prise en compte d...
1328
			case 'star':
26a23052   Benjamin Renard   Add Interval Tick...
1329
1330
				$symbolNode->setType(RequestOutputPlotSymbolTypeEnum::STAR);
				break;
95ab3cf6   Menouard AZIB   Prise en compte d...
1331
			case 'david-star':
26a23052   Benjamin Renard   Add Interval Tick...
1332
1333
				$symbolNode->setType(RequestOutputPlotSymbolTypeEnum::DAVIDSTAR);
				break;
95ab3cf6   Menouard AZIB   Prise en compte d...
1334
			case 'full-square':
26a23052   Benjamin Renard   Add Interval Tick...
1335
1336
				$symbolNode->setType(RequestOutputPlotSymbolTypeEnum::FULLSQUARE);
				break;
95ab3cf6   Menouard AZIB   Prise en compte d...
1337
			case 'full-circle':
26a23052   Benjamin Renard   Add Interval Tick...
1338
1339
				$symbolNode->setType(RequestOutputPlotSymbolTypeEnum::FULLCIRCLE);
				break;
95ab3cf6   Menouard AZIB   Prise en compte d...
1340
			case 'full-star':
26a23052   Benjamin Renard   Add Interval Tick...
1341
1342
				$symbolNode->setType(RequestOutputPlotSymbolTypeEnum::FULLSTAR);
				break;
95ab3cf6   Menouard AZIB   Prise en compte d...
1343
			default:
26a23052   Benjamin Renard   Add Interval Tick...
1344
1345
				throw new Exception('Symbol type not implemented.');
		}
95ab3cf6   Menouard AZIB   Prise en compte d...
1346
1347
1348
1349
1350

		$symbolNode->setSize($inputData->{$keyPrefix . '-size'});

		if ($inputData->{$keyPrefix . '-color'} != 'auto')
			$symbolNode->setColor($this->hexColor2KernelColor($inputData->{$keyPrefix . '-color'}));
26a23052   Benjamin Renard   Add Interval Tick...
1351
1352
1353
1354
1355
1356
1357
	}

	/*
	 * @brief method to marshall the result of a download request
	*/
	protected function marshallResult($data)
	{
95ab3cf6   Menouard AZIB   Prise en compte d...
1358
		if (!$this->isInteractiveRequest) {
26a23052   Benjamin Renard   Add Interval Tick...
1359
			//add to job
95ab3cf6   Menouard AZIB   Prise en compte d...
1360
1361
			$commonRes = $this->commonMarshallResult($data, PLOT_RESULT_FILE_KEY);

26a23052   Benjamin Renard   Add Interval Tick...
1362
1363
			return $commonRes;
		}
95ab3cf6   Menouard AZIB   Prise en compte d...
1364

26a23052   Benjamin Renard   Add Interval Tick...
1365
		//Interactive request
22521f1c   Benjamin Renard   First commit
1366
1367
		if (!$data->getSuccess())
			return array(
95ab3cf6   Menouard AZIB   Prise en compte d...
1368
1369
1370
1371
1372
1373
1374
				'success' => false,
				'message' => $data->getLastErrorMessage()
			);

		switch ($data->getStatus()) {
			case ProcessStatusEnumClass::DONE:

26a23052   Benjamin Renard   Add Interval Tick...
1375
				$result = array();
95ab3cf6   Menouard AZIB   Prise en compte d...
1376
1377
1378
				foreach ($data->getWaitingResults() as $key => $waitingResult) {
					$contextResult = str_replace(".png", "_context.xml", $waitingResult);

26a23052   Benjamin Renard   Add Interval Tick...
1379
1380
					$result[] = array(
						"id" => $key,
70e82c1f   Benjamin Renard   Fix doPlot
1381
						"title" => $this->interactivePlotTitle[$key],
05da1b4d   Benjamin Renard   Draw instant plot...
1382
						"preview" => $this->interactivePreview,
26a23052   Benjamin Renard   Add Interval Tick...
1383
						"isInterval" => $this->interactiveTimeSelectionState[$key],
70e82c1f   Benjamin Renard   Fix doPlot
1384
						"index" => $this->interactivePlotIndex[$key],
26a23052   Benjamin Renard   Add Interval Tick...
1385
						"ttFileIndex" => $this->interactiveCrtTTFileIndex,
95ab3cf6   Menouard AZIB   Prise en compte d...
1386
						"context" => IHMPlotContextFileClass::parse($this->getWorkingPath() . $contextResult),
ba82a624   Benjamin Renard   Get kernel execut...
1387
1388
						"plot" => $waitingResult,
						"exectime" => $data->getExecTime(),
ec574794   Benjamin Renard   Implements multip...
1389
						"multiplot" => $this->isMultiPlot,
26a23052   Benjamin Renard   Add Interval Tick...
1390
1391
					);
				}
95ab3cf6   Menouard AZIB   Prise en compte d...
1392

26a23052   Benjamin Renard   Add Interval Tick...
1393
1394
1395
1396
1397
1398
				return array(
					'success'     => true,
					'id'          => $data->getId(),
					'folder'      => $this->getWorkingDirName(),
					'result'      => $result
				);
95ab3cf6   Menouard AZIB   Prise en compte d...
1399
			case ProcessStatusEnumClass::KILLED:
26a23052   Benjamin Renard   Add Interval Tick...
1400
				return array(
95ab3cf6   Menouard AZIB   Prise en compte d...
1401
1402
1403
1404
					'success'     => true,
					'killed'      => true
				);
			default:
e4eba677   Benjamin Renard   Get error message...
1405
				$errorMsg = $data->getErrorMsg();
22521f1c   Benjamin Renard   First commit
1406
				return array(
95ab3cf6   Menouard AZIB   Prise en compte d...
1407
1408
1409
					'success' => false,
					'message'   => 'Request processing error' . (!empty($errorMsg) ? "<br>(" . $errorMsg . ")" : "")
				);
26a23052   Benjamin Renard   Add Interval Tick...
1410
1411
		}
	}
95ab3cf6   Menouard AZIB   Prise en compte d...
1412
1413
1414

	private function hexColor2KernelColor($hex)
	{
26a23052   Benjamin Renard   Add Interval Tick...
1415
1416
		$hex = str_replace("#", "", $hex);

95ab3cf6   Menouard AZIB   Prise en compte d...
1417
1418
1419
		$r = hexdec(substr($hex, 0, 2));
		$g = hexdec(substr($hex, 2, 2));
		$b = hexdec(substr($hex, 4, 2));
26a23052   Benjamin Renard   Add Interval Tick...
1420

95ab3cf6   Menouard AZIB   Prise en compte d...
1421
		return "[" . $r . "," . $g . "," . $b . "]";
26a23052   Benjamin Renard   Add Interval Tick...
1422
	}
95ab3cf6   Menouard AZIB   Prise en compte d...
1423

ec574794   Benjamin Renard   Implements multip...
1424
	protected function saveIHMRequest($interactiveId, $input)
26a23052   Benjamin Renard   Add Interval Tick...
1425
	{
95ab3cf6   Menouard AZIB   Prise en compte d...
1426
		$path = $this->getWorkingPath() . "ihm.request." . $interactiveId;
26a23052   Benjamin Renard   Add Interval Tick...
1427
		if (!is_dir($this->getWorkingPath()))
95ab3cf6   Menouard AZIB   Prise en compte d...
1428
			mkdir($this->getWorkingPath(), 0777);
22521f1c   Benjamin Renard   First commit
1429
1430
		$file = fopen($path, 'w');
		fwrite($file, json_encode($input));
26a23052   Benjamin Renard   Add Interval Tick...
1431
1432
		fclose($file);
	}
95ab3cf6   Menouard AZIB   Prise en compte d...
1433

ec574794   Benjamin Renard   Implements multip...
1434
	protected function loadIHMRequest($interactiveId)
26a23052   Benjamin Renard   Add Interval Tick...
1435
	{
95ab3cf6   Menouard AZIB   Prise en compte d...
1436
		$path = $this->getWorkingPath() . "ihm.request." . $interactiveId;
22521f1c   Benjamin Renard   First commit
1437
		if (!file_exists($path))
26a23052   Benjamin Renard   Add Interval Tick...
1438
1439
1440
			return NULL;
		return json_decode(file_get_contents($path));
	}
a9d86eaa   Benjamin Renard   Fix zoom / unzoom
1441

95ab3cf6   Menouard AZIB   Prise en compte d...
1442

a9d86eaa   Benjamin Renard   Fix zoom / unzoom
1443
1444
1445

	private function loadZoomList($interactiveId)
	{
95ab3cf6   Menouard AZIB   Prise en compte d...
1446
		$path = $this->getWorkingPath() . "zoom.list." . $interactiveId;
a9d86eaa   Benjamin Renard   Fix zoom / unzoom
1447
1448
1449
1450
1451
1452
1453
		if (!file_exists($path))
			return NULL;
		return json_decode(file_get_contents($path));
	}

	private function saveZoomList($interactiveId, $zoomList)
	{
95ab3cf6   Menouard AZIB   Prise en compte d...
1454
		$path = $this->getWorkingPath() . "zoom.list." . $interactiveId;
a9d86eaa   Benjamin Renard   Fix zoom / unzoom
1455
		if (!is_dir($this->getWorkingPath()))
95ab3cf6   Menouard AZIB   Prise en compte d...
1456
			mkdir($this->getWorkingPath(), 0777);
a9d86eaa   Benjamin Renard   Fix zoom / unzoom
1457
1458
1459
1460
		$file = fopen($path, 'w');
		fwrite($file, json_encode($zoomList));
		fclose($file);
	}
95ab3cf6   Menouard AZIB   Prise en compte d...
1461

26a23052   Benjamin Renard   Add Interval Tick...
1462
1463
	private function unmarshallActionRequest($input)
	{
e8cefd97   Benjamin Renard   Interactive attac...
1464
		$actionInput    = $input->{'action'};
95ab3cf6   Menouard AZIB   Prise en compte d...
1465

4a7023e8   Benjamin Renard   Fix interactive n...
1466
		$plotInput = $this->loadIHMRequest($actionInput->{'interactiveId'});
95ab3cf6   Menouard AZIB   Prise en compte d...
1467

26a23052   Benjamin Renard   Add Interval Tick...
1468
		if (!isset($plotInput))
86756f46   Benjamin Renard   Remove multi plot...
1469
			throw new Exception('Cannot retrieve request input for interactive action.');
95ab3cf6   Menouard AZIB   Prise en compte d...
1470
1471
1472

		switch ($actionInput->{'action'}) {
			case 'zoom':
e8cefd97   Benjamin Renard   Interactive attac...
1473
				return $this->unmarshallZoom($actionInput, $plotInput);
95ab3cf6   Menouard AZIB   Prise en compte d...
1474
1475
			case 'forward':
			case 'halfforward':
2366956c   Erdogan Furkan   10312 - Navigatio...
1476
			case 'quarterforward':
95ab3cf6   Menouard AZIB   Prise en compte d...
1477
1478
			case 'backward':
			case 'halfbackward':
2366956c   Erdogan Furkan   10312 - Navigatio...
1479
			case 'quarterbackward':
95ab3cf6   Menouard AZIB   Prise en compte d...
1480
1481
			case 'extend':
			case 'shift':
e8cefd97   Benjamin Renard   Interactive attac...
1482
				return $this->unmarshallNavigation($actionInput, $plotInput);
95ab3cf6   Menouard AZIB   Prise en compte d...
1483
			case 'goto':
e8cefd97   Benjamin Renard   Interactive attac...
1484
				return $this->unmarshallTTGoto($actionInput, $plotInput);
95ab3cf6   Menouard AZIB   Prise en compte d...
1485
			case 'instant':
05da1b4d   Benjamin Renard   Draw instant plot...
1486
				return $this->unmarshallInstant($actionInput, $plotInput);
95ab3cf6   Menouard AZIB   Prise en compte d...
1487
			case 'undozoom':
d3c3608d   Benjamin Renard   Add undo zoom
1488
				return $this->unmarshallUndoZoom($actionInput, $plotInput);
95ab3cf6   Menouard AZIB   Prise en compte d...
1489
			default:
26a23052   Benjamin Renard   Add Interval Tick...
1490
1491
1492
				throw new Exception('Interactive action not implemented.');
		}
	}
95ab3cf6   Menouard AZIB   Prise en compte d...
1493

d3c3608d   Benjamin Renard   Add undo zoom
1494
1495
1496
1497
	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
95ab3cf6   Menouard AZIB   Prise en compte d...
1498

a9d86eaa   Benjamin Renard   Fix zoom / unzoom
1499
		$zoomList = $this->loadZoomList($input->interactiveId);
95ab3cf6   Menouard AZIB   Prise en compte d...
1500
1501

		if (!isset($zoomList)) {
d3c3608d   Benjamin Renard   Add undo zoom
1502
			//Init zoom list
95ab3cf6   Menouard AZIB   Prise en compte d...
1503
			$zoomList = (object)array(
a9d86eaa   Benjamin Renard   Fix zoom / unzoom
1504
				'times' => array(),
95ab3cf6   Menouard AZIB   Prise en compte d...
1505
				'panels' => (object)array()
d3c3608d   Benjamin Renard   Add undo zoom
1506
1507
			);
		}
95ab3cf6   Menouard AZIB   Prise en compte d...
1508
1509

		if ($input->{'axeId'} == 'timeAxis') {
d3c3608d   Benjamin Renard   Add undo zoom
1510
			if ($isInterval)
95ab3cf6   Menouard AZIB   Prise en compte d...
1511
				array_push($zoomList->times, (object)array(
d3c3608d   Benjamin Renard   Add undo zoom
1512
1513
1514
1515
1516
					'isInterval' => true,
					'min' => $minOrFileIndex,
					'max'  => $maxOrIntervalIndex
				));
			else
95ab3cf6   Menouard AZIB   Prise en compte d...
1517
1518
1519
1520
				array_push($zoomList->times, (object)array(
					'isInterval' => false,
					'ttFileIndex' => $minOrFileIndex,
					'intIndex'  => $maxOrIntervalIndex
d3c3608d   Benjamin Renard   Add undo zoom
1521
				));
95ab3cf6   Menouard AZIB   Prise en compte d...
1522
1523
1524
1525
		} else {
			if (!isset($zoomList->panels->{$input->{'panelId'}})) {
				$zoomList->panels->{$input->{'panelId'}} = (object) array(
					'axes' => (object)array()
d3c3608d   Benjamin Renard   Add undo zoom
1526
1527
				);
			}
95ab3cf6   Menouard AZIB   Prise en compte d...
1528
1529

			if (!isset($zoomList->panels->{$input->{'panelId'}}->axes->{$input->{'axeId'}})) {
a9d86eaa   Benjamin Renard   Fix zoom / unzoom
1530
				$zoomList->panels->{$input->{'panelId'}}->axes->{$input->{'axeId'}} = array();
d3c3608d   Benjamin Renard   Add undo zoom
1531
			}
95ab3cf6   Menouard AZIB   Prise en compte d...
1532
1533
1534
1535

			array_push($zoomList->panels->{$input->{'panelId'}}->axes->{$input->{'axeId'}}, (object)array(
				'min' => $minOrFileIndex,
				'max'  => $maxOrIntervalIndex
d3c3608d   Benjamin Renard   Add undo zoom
1536
1537
			));
		}
95ab3cf6   Menouard AZIB   Prise en compte d...
1538

a9d86eaa   Benjamin Renard   Fix zoom / unzoom
1539
		$this->saveZoomList($input->interactiveId, $zoomList);
d3c3608d   Benjamin Renard   Add undo zoom
1540
	}
95ab3cf6   Menouard AZIB   Prise en compte d...
1541

a9d86eaa   Benjamin Renard   Fix zoom / unzoom
1542
	private function resetZoomList($interactiveId, $resetOnlyTimeZoom = false)
d3c3608d   Benjamin Renard   Add undo zoom
1543
	{
a9d86eaa   Benjamin Renard   Fix zoom / unzoom
1544
		if (!$resetOnlyTimeZoom) {
95ab3cf6   Menouard AZIB   Prise en compte d...
1545
			$zoomList = (object)array(
a9d86eaa   Benjamin Renard   Fix zoom / unzoom
1546
				'times' => array(),
95ab3cf6   Menouard AZIB   Prise en compte d...
1547
				'panels' => (object)array()
a9d86eaa   Benjamin Renard   Fix zoom / unzoom
1548
			);
95ab3cf6   Menouard AZIB   Prise en compte d...
1549
		} else {
a9d86eaa   Benjamin Renard   Fix zoom / unzoom
1550
1551
1552
1553
1554
			$zoomList = $this->loadZoomList($interactiveId);
			$zoomList->times = array();
		}

		$this->saveZoomList($interactiveId, $zoomList);
d3c3608d   Benjamin Renard   Add undo zoom
1555
	}
95ab3cf6   Menouard AZIB   Prise en compte d...
1556

d3c3608d   Benjamin Renard   Add undo zoom
1557
1558
	private function undoZoomInList($input)
	{
a9d86eaa   Benjamin Renard   Fix zoom / unzoom
1559
		$zoomList = $this->loadZoomList($input->interactiveId);
95ab3cf6   Menouard AZIB   Prise en compte d...
1560

d3c3608d   Benjamin Renard   Add undo zoom
1561
		$result = NULL;
95ab3cf6   Menouard AZIB   Prise en compte d...
1562
1563
		if ($zoomList) {
			if ($input->{'axeId'} == 'timeAxis') {
a9d86eaa   Benjamin Renard   Fix zoom / unzoom
1564
				if (count($zoomList->times) <= 0)
d3c3608d   Benjamin Renard   Add undo zoom
1565
					return NULL;
95ab3cf6   Menouard AZIB   Prise en compte d...
1566
1567
				$result = array_pop($zoomList->times);
			} else {
a9d86eaa   Benjamin Renard   Fix zoom / unzoom
1568
				if (!isset($zoomList->panels->{$input->{'panelId'}}))
d3c3608d   Benjamin Renard   Add undo zoom
1569
					return NULL;
95ab3cf6   Menouard AZIB   Prise en compte d...
1570

a9d86eaa   Benjamin Renard   Fix zoom / unzoom
1571
				if (!isset($zoomList->panels->{$input->{'panelId'}}->axes->{$input->{'axeId'}}))
d3c3608d   Benjamin Renard   Add undo zoom
1572
					return NULL;
95ab3cf6   Menouard AZIB   Prise en compte d...
1573

a9d86eaa   Benjamin Renard   Fix zoom / unzoom
1574
				$result = array_pop($zoomList->panels->{$input->{'panelId'}}->axes->{$input->{'axeId'}});
d3c3608d   Benjamin Renard   Add undo zoom
1575
			}
95ab3cf6   Menouard AZIB   Prise en compte d...
1576
		} else
d3c3608d   Benjamin Renard   Add undo zoom
1577
			return NULL;
95ab3cf6   Menouard AZIB   Prise en compte d...
1578

a9d86eaa   Benjamin Renard   Fix zoom / unzoom
1579
		$this->saveZoomList($input->interactiveId, $zoomList);
95ab3cf6   Menouard AZIB   Prise en compte d...
1580

d3c3608d   Benjamin Renard   Add undo zoom
1581
1582
		return $result;
	}
95ab3cf6   Menouard AZIB   Prise en compte d...
1583

d3c3608d   Benjamin Renard   Add undo zoom
1584
	private function unmarshallZoom($input, $plotInput, $isUndo = false)
26a23052   Benjamin Renard   Add Interval Tick...
1585
	{
95ab3cf6   Menouard AZIB   Prise en compte d...
1586
		if ($input->{'axeId'} == 'timeAxis') {
26a23052   Benjamin Renard   Add Interval Tick...
1587
			//Zoom on Time Axis
95ab3cf6   Menouard AZIB   Prise en compte d...
1588
			if ($plotInput->{'timesrc'} != 'Interval') {
a9d86eaa   Benjamin Renard   Fix zoom / unzoom
1589
				$plotInput->{'timesrc'} = 'Interval';
7d84634e   Benjamin Renard   Fix plot request ...
1590
				if (!$isUndo)
95ab3cf6   Menouard AZIB   Prise en compte d...
1591
1592
1593
1594
1595
1596
1597
					$this->addZoomInList(
						$input,
						false,
						isset($plotInput->{'ttFileIndex'}) ? $plotInput->{'ttFileIndex'} : 0,
						isset($plotInput->{'intIndex'}) ? $plotInput->{'intIndex'} : 0
					);
			} else {
7d84634e   Benjamin Renard   Fix plot request ...
1598
				if (!$isUndo)
95ab3cf6   Menouard AZIB   Prise en compte d...
1599
					$this->addZoomInList($input, true, $plotInput->{'startDate'}, $plotInput->{'stopDate'});
26a23052   Benjamin Renard   Add Interval Tick...
1600
			}
a9d86eaa   Benjamin Renard   Fix zoom / unzoom
1601
1602
			$plotInput->{'startDate'} = $input->{'min'};
			$plotInput->{'stopDate'} = $input->{'max'};
95ab3cf6   Menouard AZIB   Prise en compte d...
1603

d3c3608d   Benjamin Renard   Add undo zoom
1604
			$plotInput->{'force-time-zoom-reset'} = false;
a9d86eaa   Benjamin Renard   Fix zoom / unzoom
1605
			$this->saveIHMRequest($input->interactiveId, $plotInput);
26a23052   Benjamin Renard   Add Interval Tick...
1606
1607
			return $plotInput;
		}
95ab3cf6   Menouard AZIB   Prise en compte d...
1608

26a23052   Benjamin Renard   Add Interval Tick...
1609
		//Digital axis zoom
95ab3cf6   Menouard AZIB   Prise en compte d...
1610
1611
1612
1613
		foreach ($plotInput->{'panels'} as $panel) {
			if ($input->{'panelId'} == $panel->{'id'}) {
				foreach ($panel->{'axes'} as $axis) {
					if ($input->{'axeId'} == $axis->{'id'}) {
26a23052   Benjamin Renard   Add Interval Tick...
1614
						$axis->{'axis-range-extend'} = false;
d3c3608d   Benjamin Renard   Add undo zoom
1615
1616
						$oldMin = $axis->{'axis-range-min'};
						$oldMax = $axis->{'axis-range-max'};
26a23052   Benjamin Renard   Add Interval Tick...
1617
1618
						$axis->{'axis-range-min'} = $input->{'min'};
						$axis->{'axis-range-max'} = $input->{'max'};
a9d86eaa   Benjamin Renard   Fix zoom / unzoom
1619
						$this->saveIHMRequest($input->interactiveId, $plotInput);
26a23052   Benjamin Renard   Add Interval Tick...
1620
1621
						//Do not save 'force-single-replot' in request file!
						$plotInput->{'force-single-replot'} = true;
d3c3608d   Benjamin Renard   Add undo zoom
1622
1623
						$plotInput->{'force-time-zoom-reset'} = false;
						if (!$isUndo)
95ab3cf6   Menouard AZIB   Prise en compte d...
1624
							$this->addZoomInList($input, true, $oldMin, $oldMax);
26a23052   Benjamin Renard   Add Interval Tick...
1625
1626
1627
1628
1629
1630
1631
1632
						return $plotInput;
					}
				}
				throw new Exception('Cannot retrieve axis for zoom action.');
			}
		}
		throw new Exception('Cannot retrieve plot panel for zoom action.');
	}
95ab3cf6   Menouard AZIB   Prise en compte d...
1633

d3c3608d   Benjamin Renard   Add undo zoom
1634
1635
1636
	private function unmarshallUndoZoom($input, $plotInput)
	{
		$result = $this->undoZoomInList($input);
95ab3cf6   Menouard AZIB   Prise en compte d...
1637
1638
1639
		if ($result != NULL) {
			if (isset($result->isInterval)) {
				if (!$result->isInterval) {
d3c3608d   Benjamin Renard   Add undo zoom
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
					$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.');
	}
95ab3cf6   Menouard AZIB   Prise en compte d...
1651

26a23052   Benjamin Renard   Add Interval Tick...
1652
1653
	private function unmarshallNavigation($input, $plotInput)
	{
4a7023e8   Benjamin Renard   Fix interactive n...
1654
1655
		$startTime = $plotInput->{'startDate'};
		$stopTime = $plotInput->{'stopDate'};
95ab3cf6   Menouard AZIB   Prise en compte d...
1656

26a23052   Benjamin Renard   Add Interval Tick...
1657
1658
1659
1660
1661
		//Compute new start / stop time
		date_default_timezone_set('UTC');
		$startTimeStamp = strtotime($startTime);
		$stopTimeStamp  = strtotime($stopTime);
		$duration = $stopTimeStamp - $startTimeStamp;
95ab3cf6   Menouard AZIB   Prise en compte d...
1662
1663
1664

		switch ($input->{'action'}) {
			case 'forward':
26a23052   Benjamin Renard   Add Interval Tick...
1665
1666
1667
				$startTimeStamp += $duration;
				$stopTimeStamp  += $duration;
				break;
95ab3cf6   Menouard AZIB   Prise en compte d...
1668
1669
1670
			case 'halfforward':
				$startTimeStamp += ($duration / 2);
				$stopTimeStamp  += ($duration / 2);
26a23052   Benjamin Renard   Add Interval Tick...
1671
				break;
2366956c   Erdogan Furkan   10312 - Navigatio...
1672
1673
1674
1675
			case 'quarterforward':
				$startTimeStamp += ($duration / 4);
				$stopTimeStamp  += ($duration / 4);
				break;
95ab3cf6   Menouard AZIB   Prise en compte d...
1676
			case 'backward':
26a23052   Benjamin Renard   Add Interval Tick...
1677
1678
1679
				$startTimeStamp -= $duration;
				$stopTimeStamp  -= $duration;
				break;
95ab3cf6   Menouard AZIB   Prise en compte d...
1680
1681
1682
			case 'halfbackward':
				$startTimeStamp -= ($duration / 2);
				$stopTimeStamp  -= ($duration / 2);
26a23052   Benjamin Renard   Add Interval Tick...
1683
				break;
2366956c   Erdogan Furkan   10312 - Navigatio...
1684
1685
1686
1687
			case 'quarterbackward':
				$startTimeStamp -= ($duration / 4);
				$stopTimeStamp  -= ($duration / 4);
				break;
95ab3cf6   Menouard AZIB   Prise en compte d...
1688
			case 'extend':
26a23052   Benjamin Renard   Add Interval Tick...
1689
1690
1691
				$startTimeStamp -= $input->{'duration'};
				$stopTimeStamp  += $input->{'duration'};
				break;
95ab3cf6   Menouard AZIB   Prise en compte d...
1692
			case 'shift':
26a23052   Benjamin Renard   Add Interval Tick...
1693
1694
1695
1696
				$startTimeStamp += $input->{'duration'};
				$stopTimeStamp  += $input->{'duration'};
				break;
		}
95ab3cf6   Menouard AZIB   Prise en compte d...
1697

26a23052   Benjamin Renard   Add Interval Tick...
1698
1699
		if ($stopTimeStamp - $startTimeStamp <= 0)
			throw new Exception('New duration is lower than 0.');
95ab3cf6   Menouard AZIB   Prise en compte d...
1700
1701
1702
1703

		$startTime = date("Y-m-d\TH:i:s", $startTimeStamp);
		$stopTime = date("Y-m-d\TH:i:s", $stopTimeStamp);

26a23052   Benjamin Renard   Add Interval Tick...
1704
		//Update request
4a7023e8   Benjamin Renard   Fix interactive n...
1705
1706
		$plotInput->{'startDate'} = $startTime;
		$plotInput->{'stopDate'} = $stopTime;
95ab3cf6   Menouard AZIB   Prise en compte d...
1707

d3c3608d   Benjamin Renard   Add undo zoom
1708
		$plotInput->{'force-time-zoom-reset'} = true;
4a7023e8   Benjamin Renard   Fix interactive n...
1709
		$this->saveIHMRequest($input->interactiveId, $plotInput);
26a23052   Benjamin Renard   Add Interval Tick...
1710
1711
		return $plotInput;
	}
95ab3cf6   Menouard AZIB   Prise en compte d...
1712

26a23052   Benjamin Renard   Add Interval Tick...
1713
1714
	private function unmarshallTTGoto($input, $plotInput)
	{
419a700b   Benjamin Renard   Fix TT goto
1715
1716
1717
		$plotInput->{'timesrc'} = 'TimeTable';
		$plotInput->{'ttFileIndex'} = $input->{'ttFileIndex'};
		$plotInput->{'intIndex'} = $input->{'intIndex'};
95ab3cf6   Menouard AZIB   Prise en compte d...
1718

d3c3608d   Benjamin Renard   Add undo zoom
1719
		$plotInput->{'force-time-zoom-reset'} = true;
419a700b   Benjamin Renard   Fix TT goto
1720
		$this->saveIHMRequest($input->interactiveId, $plotInput);
e8cefd97   Benjamin Renard   Interactive attac...
1721
1722
		return $plotInput;
	}
95ab3cf6   Menouard AZIB   Prise en compte d...
1723

05da1b4d   Benjamin Renard   Draw instant plot...
1724
1725
	private function unmarshallInstant($input, $plotInput)
	{
05da1b4d   Benjamin Renard   Draw instant plot...
1726
1727
		//Find current panel
		$crtPanel = NULL;
95ab3cf6   Menouard AZIB   Prise en compte d...
1728
1729
		foreach ($plotInput->{'panels'} as $panel) {
			if ($input->{'panelId'} == $panel->{'id'}) {
05da1b4d   Benjamin Renard   Draw instant plot...
1730
1731
1732
1733
				$crtPanel = $panel;
				break;
			}
		}
95ab3cf6   Menouard AZIB   Prise en compte d...
1734

05da1b4d   Benjamin Renard   Draw instant plot...
1735
1736
		if (!$crtPanel)
			throw new Exception('Cannot retrieve plot panel for instant plot.');
95ab3cf6   Menouard AZIB   Prise en compte d...
1737

05da1b4d   Benjamin Renard   Draw instant plot...
1738
1739
		if ($crtPanel->{'panel-plot-type'} != 'timePlot')
			throw new Exception('Instant plot action only available for Time plot.');
95ab3cf6   Menouard AZIB   Prise en compte d...
1740

05da1b4d   Benjamin Renard   Draw instant plot...
1741
1742
		//Find spectra parameter
		$crtParam = NULL;
95ab3cf6   Menouard AZIB   Prise en compte d...
1743
1744
1745
		foreach ($crtPanel->{'params'} as $param) {
			if ($param->{'param-drawing-type'} == 'spectro') {
				$crtParam = $param;
05da1b4d   Benjamin Renard   Draw instant plot...
1746
1747
1748
				break;
			}
		}
95ab3cf6   Menouard AZIB   Prise en compte d...
1749

05da1b4d   Benjamin Renard   Draw instant plot...
1750
1751
		if (!$crtParam)
			throw new Exception('Cannot retrieve plot param for instant plot.');
95ab3cf6   Menouard AZIB   Prise en compte d...
1752

05da1b4d   Benjamin Renard   Draw instant plot...
1753
1754
		//Find table Y-axis
		$crtYAxis = NULL;
95ab3cf6   Menouard AZIB   Prise en compte d...
1755
1756
		foreach ($crtPanel->{'axes'} as $axis) {
			if ($crtParam->{'param-drawing-object'}->{'spectro-yaxis'} == $axis->{'id'}) {
05da1b4d   Benjamin Renard   Draw instant plot...
1757
1758
1759
1760
				$crtYAxis = $axis;
				break;
			}
		}
95ab3cf6   Menouard AZIB   Prise en compte d...
1761

05da1b4d   Benjamin Renard   Draw instant plot...
1762
1763
		if (!$crtYAxis)
			throw new Exception('Cannot retrieve plot y Axis for instant plot.');
95ab3cf6   Menouard AZIB   Prise en compte d...
1764

05da1b4d   Benjamin Renard   Draw instant plot...
1765
1766
		//Find color Z-axis
		$crtColorAxis = NULL;
95ab3cf6   Menouard AZIB   Prise en compte d...
1767
1768
		foreach ($crtPanel->{'axes'} as $axis) {
			if ($axis->{'id'} == 'color') {
05da1b4d   Benjamin Renard   Draw instant plot...
1769
1770
1771
1772
				$crtColorAxis = $axis;
				break;
			}
		}
95ab3cf6   Menouard AZIB   Prise en compte d...
1773

05da1b4d   Benjamin Renard   Draw instant plot...
1774
1775
		if (!$crtColorAxis)
			throw new Exception('Cannot retrieve plot color Axis for instant plot.');
95ab3cf6   Menouard AZIB   Prise en compte d...
1776

05da1b4d   Benjamin Renard   Draw instant plot...
1777
1778
		date_default_timezone_set('UTC');
		$timeStamp = strtotime($input->time);
95ab3cf6   Menouard AZIB   Prise en compte d...
1779
1780

		$instantPlotInput = (object)array(
05da1b4d   Benjamin Renard   Draw instant plot...
1781
1782
1783
1784
			"interactive-preview" => true,
			"file-format" => "PNG",
			"file-output" => "INTERACTIVE",
			"file-prefix" => "instant",
05da1b4d   Benjamin Renard   Draw instant plot...
1785
1786
1787
			"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...
1788
			"id" => 1,
c2d88cc5   Benjamin Renard   Fix instant plot
1789
1790
1791
1792
1793
			"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...
1794
			"page-layout-type" => "vertical",
95ab3cf6   Menouard AZIB   Prise en compte d...
1795
			"page-layout-object" => (object)array(
05da1b4d   Benjamin Renard   Draw instant plot...
1796
				"layout-expand" => true,
95ab3cf6   Menouard AZIB   Prise en compte d...
1797
				"layout-panel-height" => 0.5,
05da1b4d   Benjamin Renard   Draw instant plot...
1798
1799
1800
1801
1802
1803
1804
1805
1806
				"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...
1807
1808
1809
				"panel-title-font-activated" => TRUE,
				"panel-title-font-size" => 12,
				"panel-title-font-bold" => TRUE,
05da1b4d   Benjamin Renard   Draw instant plot...
1810
				"axes" => array(),
0a87e436   Hacene SI HADJ MOHAND   parameters resolue
1811
1812
				"params" => array(),

05da1b4d   Benjamin Renard   Draw instant plot...
1813
1814
1815
1816
1817
1818
	    );
		
		$instantXAxis = (Object)array(
				"id"         => "xaxis_id",
				"axis-type"  => "x",
				"axis-scale" => $crtYAxis->{"axis-scale"},
d62f9945   Benjamin Renard   Improve instant c...
1819
1820
1821
1822
1823
1824
1825
				"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...
1826
1827
1828
1829
1830
1831
		);
		
		$instantYAxis = (Object)array(
				"id"         => "y-left",
				"axis-type"  => "y-left",
				"axis-scale" => $crtColorAxis->{"axis-scale"},
d62f9945   Benjamin Renard   Improve instant c...
1832
1833
1834
1835
1836
1837
1838
				"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...
1839
1840
1841
		);
		$instantPanel->{"axes"}[] = $instantXAxis;
		$instantPanel->{"axes"}[] = $instantYAxis;
95ab3cf6   Menouard AZIB   Prise en compte d...
1842
1843

		$instantParam = (object)array(
05da1b4d   Benjamin Renard   Draw instant plot...
1844
			"id" => 1,
e4545ed5   Benjamin Renard   Implement templat...
1845
			"paramid" => $crtParam->{'paramid'},
8d780912   Benjamin Renard   Keep template arg...
1846
			"template_args" => $crtParam->{'template_args'},
05da1b4d   Benjamin Renard   Draw instant plot...
1847
1848
1849
1850
1851
			"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...
1852
1853
					"iserie-lines-width" => 3,
					"iserie-lines-color" => "#0000ff"
0a87e436   Hacene SI HADJ MOHAND   parameters resolue
1854
			),
95ab3cf6   Menouard AZIB   Prise en compte d...
1855
1856
1857
1858
1859
1860
1861
1862
1863
1864
1865
1866
1867
1868
1869
			"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'}
0a87e436   Hacene SI HADJ MOHAND   parameters resolue
1870

05da1b4d   Benjamin Renard   Draw instant plot...
1871
		);
95ab3cf6   Menouard AZIB   Prise en compte d...
1872
1873
		$instantPanel->{"params"}[] = $instantParam;

0a87e436   Hacene SI HADJ MOHAND   parameters resolue
1874

c2d88cc5   Benjamin Renard   Fix instant plot
1875
		$instantPlotInput->{"panels"}[] = $instantPanel;
95ab3cf6   Menouard AZIB   Prise en compte d...
1876
1877


05da1b4d   Benjamin Renard   Draw instant plot...
1878
1879
		return $instantPlotInput;
	}
26a23052   Benjamin Renard   Add Interval Tick...
1880
}