Blame view

src/InputOutput/IHMImpl/Params/PlotImpl/IHMInputOutputParamsPlotClass.php 66.9 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
939
940
941
942
943
	protected function unmarshallStatusBar($paramDrawingData, $paramNode, $indexes)
	{
		if (count($indexes) == 0)
			$paramNode->addStatusBar(-1);
		foreach ($indexes as $index)
			$paramNode->addStatusBar($index);
	}
044a9305   Benjamin Renard   Add intervals dra...
944
945
946
947
948

	protected function unmarshallIntervals($paramDrawingData, $paramNode)
	{
		$paramNode->addIntervals();
	}
95ab3cf6   Menouard AZIB   Prise en compte d...
949

26a23052   Benjamin Renard   Add Interval Tick...
950
951
952
953
954
955
956
	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...
957

26a23052   Benjamin Renard   Add Interval Tick...
958
959
960
961
962
963
964
	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...
965

26a23052   Benjamin Renard   Add Interval Tick...
966
967
968
969
970
971
972
	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...
973

26a23052   Benjamin Renard   Add Interval Tick...
974
975
976
	protected function unmarshallParamsLegend($paramsLegendData, $paramsLegendNode)
	{
		//Legend type
95ab3cf6   Menouard AZIB   Prise en compte d...
977
978
		switch ($paramsLegendData->{'legend-series-type'}) {
			case 'text-line-symbol':
26a23052   Benjamin Renard   Add Interval Tick...
979
980
				$paramsLegendNode->setType(RequestOutputPlotParamsLegendTypeEnum::TEXTLINESYMBOL);
				break;
95ab3cf6   Menouard AZIB   Prise en compte d...
981
982
			case 'text-only':
			default:
26a23052   Benjamin Renard   Add Interval Tick...
983
984
				$paramsLegendNode->setType(RequestOutputPlotParamsLegendTypeEnum::TEXTONLY);
		}
95ab3cf6   Menouard AZIB   Prise en compte d...
985

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

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

26a23052   Benjamin Renard   Add Interval Tick...
992
		//Interval info type
95ab3cf6   Menouard AZIB   Prise en compte d...
993
994
		switch ($paramsLegendData->{'legend-series-intervalinfo-type'}) {
			case 'start-stop':
26a23052   Benjamin Renard   Add Interval Tick...
995
996
				$paramsLegendNode->setIntervalInfoType(RequestOutputPlotParamsLegendIntervalInfoTypeEnum::STARTSTOP);
				break;
95ab3cf6   Menouard AZIB   Prise en compte d...
997
998
			case 'index':
			default:
26a23052   Benjamin Renard   Add Interval Tick...
999
1000
				$paramsLegendNode->setIntervalInfoType(RequestOutputPlotParamsLegendIntervalInfoTypeEnum::INDEX);
		}
95ab3cf6   Menouard AZIB   Prise en compte d...
1001

26a23052   Benjamin Renard   Add Interval Tick...
1002
		//Position
95ab3cf6   Menouard AZIB   Prise en compte d...
1003
1004
		switch ($paramsLegendData->{'legend-series-position'}) {
			case 'inside':
26a23052   Benjamin Renard   Add Interval Tick...
1005
1006
				$paramsLegendNode->setPosition(RequestOutputPlotParamsLegendPositionEnum::INSIDE);
				break;
95ab3cf6   Menouard AZIB   Prise en compte d...
1007
1008
			case 'outside':
			default:
26a23052   Benjamin Renard   Add Interval Tick...
1009
1010
				$paramsLegendNode->setPosition(RequestOutputPlotParamsLegendPositionEnum::OUTSIDE);
		}
95ab3cf6   Menouard AZIB   Prise en compte d...
1011

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

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

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

26a23052   Benjamin Renard   Add Interval Tick...
1021
1022
1023
1024
		//Font
		if ($paramsLegendData->{'legend-series-font-activated'})
			$this->unmarshallFont($paramsLegendData, 'legend-series-font', $paramsLegendNode->getFont());
	}
95ab3cf6   Menouard AZIB   Prise en compte d...
1025

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

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

26a23052   Benjamin Renard   Add Interval Tick...
1033
		//Legend position
95ab3cf6   Menouard AZIB   Prise en compte d...
1034
1035
		switch ($textLegendData->{'legend-text-position'}) {
			case 'top':
26a23052   Benjamin Renard   Add Interval Tick...
1036
1037
				$legendNode->setPosition(RequestOutputPlotTextLegendPositionEnum::TOP);
				break;
95ab3cf6   Menouard AZIB   Prise en compte d...
1038
			case 'bottom':
26a23052   Benjamin Renard   Add Interval Tick...
1039
1040
				$legendNode->setPosition(RequestOutputPlotTextLegendPositionEnum::BOTTOM);
				break;
95ab3cf6   Menouard AZIB   Prise en compte d...
1041
			case 'left':
26a23052   Benjamin Renard   Add Interval Tick...
1042
1043
				$legendNode->setPosition(RequestOutputPlotTextLegendPositionEnum::LEFT);
				break;
95ab3cf6   Menouard AZIB   Prise en compte d...
1044
1045
			case 'right':
			default:
26a23052   Benjamin Renard   Add Interval Tick...
1046
1047
				$legendNode->setPosition(RequestOutputPlotTextLegendPositionEnum::RIGHT);
		}
95ab3cf6   Menouard AZIB   Prise en compte d...
1048

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

26a23052   Benjamin Renard   Add Interval Tick...
1052
1053
1054
1055
		//Font
		if ($textLegendData->{'legend-text-font-activated'})
			$this->unmarshallFont($textLegendData, 'legend-text-font', $legendNode->getFont());
	}
95ab3cf6   Menouard AZIB   Prise en compte d...
1056
1057

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

26a23052   Benjamin Renard   Add Interval Tick...
1062
		//Constant value
95ab3cf6   Menouard AZIB   Prise en compte d...
1063
1064
		switch ($axisNode->getName()) {
			case REQUESTOUTPUTPLOTTIMEAXIS_NAME:
26a23052   Benjamin Renard   Add Interval Tick...
1065
				date_default_timezone_set('UTC');
74fd500a   Hacene SI HADJ MOHAND   us #9874 ms zoo...
1066
				$time = CommonClass::strTimeToDDTime($constantData->{'constant-time-value'});
26a23052   Benjamin Renard   Add Interval Tick...
1067
1068
				$constantNode->setConstantValue($time);
				break;
95ab3cf6   Menouard AZIB   Prise en compte d...
1069
			default:
26a23052   Benjamin Renard   Add Interval Tick...
1070
1071
				$constantNode->setConstantValue($constantData->{'constant-float-value'});
		}
95ab3cf6   Menouard AZIB   Prise en compte d...
1072

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

26a23052   Benjamin Renard   Add Interval Tick...
1077
1078
1079
1080
1081
1082
1083
	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...
1084

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

26a23052   Benjamin Renard   Add Interval Tick...
1089
		$textNode->setText($textData->{'text-value'});
95ab3cf6   Menouard AZIB   Prise en compte d...
1090
1091
1092

		switch ($textData->{'text-y-axis'}) {
			case 'y-right':
26a23052   Benjamin Renard   Add Interval Tick...
1093
1094
				$textNode->setYAxis('y-right');
				break;
95ab3cf6   Menouard AZIB   Prise en compte d...
1095
			case 'y-left':
26a23052   Benjamin Renard   Add Interval Tick...
1096
1097
1098
				$textNode->setYAxis('y-left');
				break;
		}
95ab3cf6   Menouard AZIB   Prise en compte d...
1099
1100

		if ($isTimePlot && !$textData->{'text-x-relative'}) {
26a23052   Benjamin Renard   Add Interval Tick...
1101
			date_default_timezone_set('UTC');
74fd500a   Hacene SI HADJ MOHAND   us #9874 ms zoo...
1102
			$time = CommonClass::strTimeToDDTime($textData->{'text-x-timevalue'});
26a23052   Benjamin Renard   Add Interval Tick...
1103
			$textNode->setX($time);
95ab3cf6   Menouard AZIB   Prise en compte d...
1104
1105
		} else if ($textData->{'text-x-relative'})
			$textNode->setX(($textData->{'text-x-floatvalue'} * 100) . "%");
26a23052   Benjamin Renard   Add Interval Tick...
1106
1107
		else
			$textNode->setX($textData->{'text-x-floatvalue'});
95ab3cf6   Menouard AZIB   Prise en compte d...
1108

26a23052   Benjamin Renard   Add Interval Tick...
1109
		if ($textData->{'text-y-relative'})
95ab3cf6   Menouard AZIB   Prise en compte d...
1110
			$textNode->setY(($textData->{'text-y-value'} * 100) . "%");
26a23052   Benjamin Renard   Add Interval Tick...
1111
1112
		else
			$textNode->setY($textData->{'text-y-value'});
95ab3cf6   Menouard AZIB   Prise en compte d...
1113

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

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

		switch ($textData->{'text-align'}) {
			case 'center':
26a23052   Benjamin Renard   Add Interval Tick...
1120
1121
				$textNode->setAlign(RequestOutputPlotTextAlign::CENTER);
				break;
95ab3cf6   Menouard AZIB   Prise en compte d...
1122
			case 'right':
26a23052   Benjamin Renard   Add Interval Tick...
1123
1124
				$textNode->setAlign(RequestOutputPlotTextAlign::RIGHT);
				break;
95ab3cf6   Menouard AZIB   Prise en compte d...
1125
			case 'left':
26a23052   Benjamin Renard   Add Interval Tick...
1126
1127
1128
			default:
				$textNode->setAlign(RequestOutputPlotTextAlign::LEFT);
		}
95ab3cf6   Menouard AZIB   Prise en compte d...
1129

26a23052   Benjamin Renard   Add Interval Tick...
1130
1131
1132
1133
		//Font
		if ($textData->{'text-font-activated'})
			$this->unmarshallFont($textData, 'text-font', $textNode->getFont());
	}
95ab3cf6   Menouard AZIB   Prise en compte d...
1134

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

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

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

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

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

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

26a23052   Benjamin Renard   Add Interval Tick...
1153
1154
	protected function unmarshallFills($panelData, $fillsNode)
	{
95ab3cf6   Menouard AZIB   Prise en compte d...
1155
		foreach ($panelData->{'fills'} as $fillData) {
26a23052   Benjamin Renard   Add Interval Tick...
1156
			//Serie / Constant
95ab3cf6   Menouard AZIB   Prise en compte d...
1157
			if ($fillData->{'fill-type'} == 'serie-constant') {
26a23052   Benjamin Renard   Add Interval Tick...
1158
1159
1160
1161
1162
1163
1164
1165
1166
				$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...
1167
1168

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

26a23052   Benjamin Renard   Add Interval Tick...
1182
1183
1184
1185
1186
	protected function unmarshallTitle($inputData, $keyPrefix, $titleNode)
	{
		if ($inputData->{$keyPrefix.'-text'} != '')
		{
			$titleNode->setText($inputData->{$keyPrefix.'-text'});
d62f9945   Benjamin Renard   Improve instant c...
1187
		}
26a23052   Benjamin Renard   Add Interval Tick...
1188
		
d62f9945   Benjamin Renard   Improve instant c...
1189
1190
1191
1192
1193
1194
1195
1196
1197
		switch ($inputData->{$keyPrefix.'-position'})
		{
			case 'top' :
				$titleNode->setPosition(RequestOutputPlotTitlePosition::TOP);
				break;
			case 'bottom' :
				$titleNode->setPosition(RequestOutputPlotTitlePosition::BOTTOM);
				break;
		}
26a23052   Benjamin Renard   Add Interval Tick...
1198
		
d62f9945   Benjamin Renard   Improve instant c...
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
		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...
1210
		}
d62f9945   Benjamin Renard   Improve instant c...
1211
1212
1213
1214
1215
			
		if ($inputData->{$keyPrefix.'-color'} != '')
			$titleNode->setColor($this->hexColor2KernelColor($inputData->{$keyPrefix.'-color'}));

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

26a23052   Benjamin Renard   Add Interval Tick...
1218
1219
	protected function unmarshallLabel($inputData, $keyPrefix, $labelNode)
	{
95ab3cf6   Menouard AZIB   Prise en compte d...
1220
1221
1222
1223
		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 ...
1224
				$labelNode->setFontWeight("bold");
26a23052   Benjamin Renard   Add Interval Tick...
1225
			}
95ab3cf6   Menouard AZIB   Prise en compte d...
1226
1227
			if ($inputData->{$keyPrefix . '-font-italic'}) {
				$labelNode->setFontStyle("italic");
26a23052   Benjamin Renard   Add Interval Tick...
1228
			}
26a23052   Benjamin Renard   Add Interval Tick...
1229
		}
26a23052   Benjamin Renard   Add Interval Tick...
1230
	}
95ab3cf6   Menouard AZIB   Prise en compte d...
1231

26a23052   Benjamin Renard   Add Interval Tick...
1232
1233
	protected function unmarshallFont($inputData, $keyPrefix, $fontNode)
	{
95ab3cf6   Menouard AZIB   Prise en compte d...
1234
1235
1236
1237
1238
		if ($inputData->{$keyPrefix . '-activated'}) {
			$fontNode->setFontName($inputData->{$keyPrefix . '-name'});
			$fontNode->setSize($inputData->{$keyPrefix . '-size'});

			if ($inputData->{$keyPrefix . '-italic'})
26a23052   Benjamin Renard   Add Interval Tick...
1239
1240
1241
				$fontNode->setStyle(RequestOutputPlotFontStyle::ITALIC);
			else
				$fontNode->setStyle(RequestOutputPlotFontStyle::UPRIGHT);
95ab3cf6   Menouard AZIB   Prise en compte d...
1242
1243

			if ($inputData->{$keyPrefix . '-bold'})
26a23052   Benjamin Renard   Add Interval Tick...
1244
1245
1246
1247
1248
				$fontNode->setWeight(RequestOutputPlotFontWeight::BOLD);
			else
				$fontNode->setWeight(RequestOutputPlotFontWeight::MEDIUM);
		}
	}
95ab3cf6   Menouard AZIB   Prise en compte d...
1249

26a23052   Benjamin Renard   Add Interval Tick...
1250
1251
	protected function unmarshallCurve($inputData, $keyPrefix, $curveNode)
	{
95ab3cf6   Menouard AZIB   Prise en compte d...
1252
1253
1254
		switch ($inputData->{$keyPrefix . '-style'}) {

			case 'dot':
26a23052   Benjamin Renard   Add Interval Tick...
1255
1256
				$curveNode->setStyle(RequestOutputPlotCurveStyleEnum::DOT);
				break;
95ab3cf6   Menouard AZIB   Prise en compte d...
1257
			case 'long-spaced-dot':
26a23052   Benjamin Renard   Add Interval Tick...
1258
1259
				$curveNode->setStyle(RequestOutputPlotCurveStyleEnum::LONGSPACEDDOT);
				break;
95ab3cf6   Menouard AZIB   Prise en compte d...
1260
			case 'long-short-dot':
26a23052   Benjamin Renard   Add Interval Tick...
1261
1262
				$curveNode->setStyle(RequestOutputPlotCurveStyleEnum::LONGSHORTDOT);
				break;
95ab3cf6   Menouard AZIB   Prise en compte d...
1263
1264
			case 'plain':
			default:
02abc780   Benjamin Renard   Support request f...
1265
1266
				$curveNode->setStyle(RequestOutputPlotCurveStyleEnum::PLAIN);
				break;
26a23052   Benjamin Renard   Add Interval Tick...
1267
		}
95ab3cf6   Menouard AZIB   Prise en compte d...
1268
1269
1270
1271
1272
1273

		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...
1274
	}
95ab3cf6   Menouard AZIB   Prise en compte d...
1275

26a23052   Benjamin Renard   Add Interval Tick...
1276
1277
1278
	protected function unmarshallLine($inputData, $keyPrefix, $lineNode, $lineType)
	{
		$lineNode->setType($lineType);
95ab3cf6   Menouard AZIB   Prise en compte d...
1279
		$this->unmarshallCurve($inputData, $keyPrefix . "-lines", $lineNode);
26a23052   Benjamin Renard   Add Interval Tick...
1280
	}
95ab3cf6   Menouard AZIB   Prise en compte d...
1281

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

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

		if ($inputData->{$keyPrefix . '-color'} != 'auto')
			$symbolNode->setColor($this->hexColor2KernelColor($inputData->{$keyPrefix . '-color'}));
26a23052   Benjamin Renard   Add Interval Tick...
1338
1339
1340
1341
1342
1343
1344
	}

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

26a23052   Benjamin Renard   Add Interval Tick...
1349
1350
			return $commonRes;
		}
95ab3cf6   Menouard AZIB   Prise en compte d...
1351

26a23052   Benjamin Renard   Add Interval Tick...
1352
		//Interactive request
22521f1c   Benjamin Renard   First commit
1353
1354
		if (!$data->getSuccess())
			return array(
95ab3cf6   Menouard AZIB   Prise en compte d...
1355
1356
1357
1358
1359
1360
1361
				'success' => false,
				'message' => $data->getLastErrorMessage()
			);

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

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

26a23052   Benjamin Renard   Add Interval Tick...
1366
1367
					$result[] = array(
						"id" => $key,
70e82c1f   Benjamin Renard   Fix doPlot
1368
						"title" => $this->interactivePlotTitle[$key],
05da1b4d   Benjamin Renard   Draw instant plot...
1369
						"preview" => $this->interactivePreview,
26a23052   Benjamin Renard   Add Interval Tick...
1370
						"isInterval" => $this->interactiveTimeSelectionState[$key],
70e82c1f   Benjamin Renard   Fix doPlot
1371
						"index" => $this->interactivePlotIndex[$key],
26a23052   Benjamin Renard   Add Interval Tick...
1372
						"ttFileIndex" => $this->interactiveCrtTTFileIndex,
95ab3cf6   Menouard AZIB   Prise en compte d...
1373
						"context" => IHMPlotContextFileClass::parse($this->getWorkingPath() . $contextResult),
ba82a624   Benjamin Renard   Get kernel execut...
1374
1375
						"plot" => $waitingResult,
						"exectime" => $data->getExecTime(),
ec574794   Benjamin Renard   Implements multip...
1376
						"multiplot" => $this->isMultiPlot,
26a23052   Benjamin Renard   Add Interval Tick...
1377
1378
					);
				}
95ab3cf6   Menouard AZIB   Prise en compte d...
1379

26a23052   Benjamin Renard   Add Interval Tick...
1380
1381
1382
1383
1384
1385
				return array(
					'success'     => true,
					'id'          => $data->getId(),
					'folder'      => $this->getWorkingDirName(),
					'result'      => $result
				);
95ab3cf6   Menouard AZIB   Prise en compte d...
1386
			case ProcessStatusEnumClass::KILLED:
26a23052   Benjamin Renard   Add Interval Tick...
1387
				return array(
95ab3cf6   Menouard AZIB   Prise en compte d...
1388
1389
1390
1391
					'success'     => true,
					'killed'      => true
				);
			default:
e4eba677   Benjamin Renard   Get error message...
1392
				$errorMsg = $data->getErrorMsg();
22521f1c   Benjamin Renard   First commit
1393
				return array(
95ab3cf6   Menouard AZIB   Prise en compte d...
1394
1395
1396
					'success' => false,
					'message'   => 'Request processing error' . (!empty($errorMsg) ? "<br>(" . $errorMsg . ")" : "")
				);
26a23052   Benjamin Renard   Add Interval Tick...
1397
1398
		}
	}
95ab3cf6   Menouard AZIB   Prise en compte d...
1399
1400
1401

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

95ab3cf6   Menouard AZIB   Prise en compte d...
1404
1405
1406
		$r = hexdec(substr($hex, 0, 2));
		$g = hexdec(substr($hex, 2, 2));
		$b = hexdec(substr($hex, 4, 2));
26a23052   Benjamin Renard   Add Interval Tick...
1407

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

ec574794   Benjamin Renard   Implements multip...
1411
	protected function saveIHMRequest($interactiveId, $input)
26a23052   Benjamin Renard   Add Interval Tick...
1412
	{
95ab3cf6   Menouard AZIB   Prise en compte d...
1413
		$path = $this->getWorkingPath() . "ihm.request." . $interactiveId;
26a23052   Benjamin Renard   Add Interval Tick...
1414
		if (!is_dir($this->getWorkingPath()))
95ab3cf6   Menouard AZIB   Prise en compte d...
1415
			mkdir($this->getWorkingPath(), 0777);
22521f1c   Benjamin Renard   First commit
1416
1417
		$file = fopen($path, 'w');
		fwrite($file, json_encode($input));
26a23052   Benjamin Renard   Add Interval Tick...
1418
1419
		fclose($file);
	}
95ab3cf6   Menouard AZIB   Prise en compte d...
1420

ec574794   Benjamin Renard   Implements multip...
1421
	protected function loadIHMRequest($interactiveId)
26a23052   Benjamin Renard   Add Interval Tick...
1422
	{
95ab3cf6   Menouard AZIB   Prise en compte d...
1423
		$path = $this->getWorkingPath() . "ihm.request." . $interactiveId;
22521f1c   Benjamin Renard   First commit
1424
		if (!file_exists($path))
26a23052   Benjamin Renard   Add Interval Tick...
1425
1426
1427
			return NULL;
		return json_decode(file_get_contents($path));
	}
a9d86eaa   Benjamin Renard   Fix zoom / unzoom
1428

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

a9d86eaa   Benjamin Renard   Fix zoom / unzoom
1430
1431
1432

	private function loadZoomList($interactiveId)
	{
95ab3cf6   Menouard AZIB   Prise en compte d...
1433
		$path = $this->getWorkingPath() . "zoom.list." . $interactiveId;
a9d86eaa   Benjamin Renard   Fix zoom / unzoom
1434
1435
1436
1437
1438
1439
1440
		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...
1441
		$path = $this->getWorkingPath() . "zoom.list." . $interactiveId;
a9d86eaa   Benjamin Renard   Fix zoom / unzoom
1442
		if (!is_dir($this->getWorkingPath()))
95ab3cf6   Menouard AZIB   Prise en compte d...
1443
			mkdir($this->getWorkingPath(), 0777);
a9d86eaa   Benjamin Renard   Fix zoom / unzoom
1444
1445
1446
1447
		$file = fopen($path, 'w');
		fwrite($file, json_encode($zoomList));
		fclose($file);
	}
95ab3cf6   Menouard AZIB   Prise en compte d...
1448

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

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

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

		switch ($actionInput->{'action'}) {
			case 'zoom':
e8cefd97   Benjamin Renard   Interactive attac...
1460
				return $this->unmarshallZoom($actionInput, $plotInput);
95ab3cf6   Menouard AZIB   Prise en compte d...
1461
1462
			case 'forward':
			case 'halfforward':
2366956c   Erdogan Furkan   10312 - Navigatio...
1463
			case 'quarterforward':
95ab3cf6   Menouard AZIB   Prise en compte d...
1464
1465
			case 'backward':
			case 'halfbackward':
2366956c   Erdogan Furkan   10312 - Navigatio...
1466
			case 'quarterbackward':
95ab3cf6   Menouard AZIB   Prise en compte d...
1467
1468
			case 'extend':
			case 'shift':
e8cefd97   Benjamin Renard   Interactive attac...
1469
				return $this->unmarshallNavigation($actionInput, $plotInput);
95ab3cf6   Menouard AZIB   Prise en compte d...
1470
			case 'goto':
e8cefd97   Benjamin Renard   Interactive attac...
1471
				return $this->unmarshallTTGoto($actionInput, $plotInput);
95ab3cf6   Menouard AZIB   Prise en compte d...
1472
			case 'instant':
05da1b4d   Benjamin Renard   Draw instant plot...
1473
				return $this->unmarshallInstant($actionInput, $plotInput);
95ab3cf6   Menouard AZIB   Prise en compte d...
1474
			case 'undozoom':
d3c3608d   Benjamin Renard   Add undo zoom
1475
				return $this->unmarshallUndoZoom($actionInput, $plotInput);
95ab3cf6   Menouard AZIB   Prise en compte d...
1476
			default:
26a23052   Benjamin Renard   Add Interval Tick...
1477
1478
1479
				throw new Exception('Interactive action not implemented.');
		}
	}
95ab3cf6   Menouard AZIB   Prise en compte d...
1480

d3c3608d   Benjamin Renard   Add undo zoom
1481
1482
1483
1484
	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...
1485

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

		if (!isset($zoomList)) {
d3c3608d   Benjamin Renard   Add undo zoom
1489
			//Init zoom list
95ab3cf6   Menouard AZIB   Prise en compte d...
1490
			$zoomList = (object)array(
a9d86eaa   Benjamin Renard   Fix zoom / unzoom
1491
				'times' => array(),
95ab3cf6   Menouard AZIB   Prise en compte d...
1492
				'panels' => (object)array()
d3c3608d   Benjamin Renard   Add undo zoom
1493
1494
			);
		}
95ab3cf6   Menouard AZIB   Prise en compte d...
1495
1496

		if ($input->{'axeId'} == 'timeAxis') {
d3c3608d   Benjamin Renard   Add undo zoom
1497
			if ($isInterval)
95ab3cf6   Menouard AZIB   Prise en compte d...
1498
				array_push($zoomList->times, (object)array(
d3c3608d   Benjamin Renard   Add undo zoom
1499
1500
1501
1502
1503
					'isInterval' => true,
					'min' => $minOrFileIndex,
					'max'  => $maxOrIntervalIndex
				));
			else
95ab3cf6   Menouard AZIB   Prise en compte d...
1504
1505
1506
1507
				array_push($zoomList->times, (object)array(
					'isInterval' => false,
					'ttFileIndex' => $minOrFileIndex,
					'intIndex'  => $maxOrIntervalIndex
d3c3608d   Benjamin Renard   Add undo zoom
1508
				));
95ab3cf6   Menouard AZIB   Prise en compte d...
1509
1510
1511
1512
		} else {
			if (!isset($zoomList->panels->{$input->{'panelId'}})) {
				$zoomList->panels->{$input->{'panelId'}} = (object) array(
					'axes' => (object)array()
d3c3608d   Benjamin Renard   Add undo zoom
1513
1514
				);
			}
95ab3cf6   Menouard AZIB   Prise en compte d...
1515
1516

			if (!isset($zoomList->panels->{$input->{'panelId'}}->axes->{$input->{'axeId'}})) {
a9d86eaa   Benjamin Renard   Fix zoom / unzoom
1517
				$zoomList->panels->{$input->{'panelId'}}->axes->{$input->{'axeId'}} = array();
d3c3608d   Benjamin Renard   Add undo zoom
1518
			}
95ab3cf6   Menouard AZIB   Prise en compte d...
1519
1520
1521
1522

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

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

a9d86eaa   Benjamin Renard   Fix zoom / unzoom
1529
	private function resetZoomList($interactiveId, $resetOnlyTimeZoom = false)
d3c3608d   Benjamin Renard   Add undo zoom
1530
	{
a9d86eaa   Benjamin Renard   Fix zoom / unzoom
1531
		if (!$resetOnlyTimeZoom) {
95ab3cf6   Menouard AZIB   Prise en compte d...
1532
			$zoomList = (object)array(
a9d86eaa   Benjamin Renard   Fix zoom / unzoom
1533
				'times' => array(),
95ab3cf6   Menouard AZIB   Prise en compte d...
1534
				'panels' => (object)array()
a9d86eaa   Benjamin Renard   Fix zoom / unzoom
1535
			);
95ab3cf6   Menouard AZIB   Prise en compte d...
1536
		} else {
a9d86eaa   Benjamin Renard   Fix zoom / unzoom
1537
1538
1539
1540
1541
			$zoomList = $this->loadZoomList($interactiveId);
			$zoomList->times = array();
		}

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

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

d3c3608d   Benjamin Renard   Add undo zoom
1548
		$result = NULL;
95ab3cf6   Menouard AZIB   Prise en compte d...
1549
1550
		if ($zoomList) {
			if ($input->{'axeId'} == 'timeAxis') {
a9d86eaa   Benjamin Renard   Fix zoom / unzoom
1551
				if (count($zoomList->times) <= 0)
d3c3608d   Benjamin Renard   Add undo zoom
1552
					return NULL;
95ab3cf6   Menouard AZIB   Prise en compte d...
1553
1554
				$result = array_pop($zoomList->times);
			} else {
a9d86eaa   Benjamin Renard   Fix zoom / unzoom
1555
				if (!isset($zoomList->panels->{$input->{'panelId'}}))
d3c3608d   Benjamin Renard   Add undo zoom
1556
					return NULL;
95ab3cf6   Menouard AZIB   Prise en compte d...
1557

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

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

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

d3c3608d   Benjamin Renard   Add undo zoom
1568
1569
		return $result;
	}
95ab3cf6   Menouard AZIB   Prise en compte d...
1570

d3c3608d   Benjamin Renard   Add undo zoom
1571
	private function unmarshallZoom($input, $plotInput, $isUndo = false)
26a23052   Benjamin Renard   Add Interval Tick...
1572
	{
95ab3cf6   Menouard AZIB   Prise en compte d...
1573
		if ($input->{'axeId'} == 'timeAxis') {
26a23052   Benjamin Renard   Add Interval Tick...
1574
			//Zoom on Time Axis
95ab3cf6   Menouard AZIB   Prise en compte d...
1575
			if ($plotInput->{'timesrc'} != 'Interval') {
a9d86eaa   Benjamin Renard   Fix zoom / unzoom
1576
				$plotInput->{'timesrc'} = 'Interval';
7d84634e   Benjamin Renard   Fix plot request ...
1577
				if (!$isUndo)
95ab3cf6   Menouard AZIB   Prise en compte d...
1578
1579
1580
1581
1582
1583
1584
					$this->addZoomInList(
						$input,
						false,
						isset($plotInput->{'ttFileIndex'}) ? $plotInput->{'ttFileIndex'} : 0,
						isset($plotInput->{'intIndex'}) ? $plotInput->{'intIndex'} : 0
					);
			} else {
7d84634e   Benjamin Renard   Fix plot request ...
1585
				if (!$isUndo)
95ab3cf6   Menouard AZIB   Prise en compte d...
1586
					$this->addZoomInList($input, true, $plotInput->{'startDate'}, $plotInput->{'stopDate'});
26a23052   Benjamin Renard   Add Interval Tick...
1587
			}
a9d86eaa   Benjamin Renard   Fix zoom / unzoom
1588
1589
			$plotInput->{'startDate'} = $input->{'min'};
			$plotInput->{'stopDate'} = $input->{'max'};
95ab3cf6   Menouard AZIB   Prise en compte d...
1590

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

26a23052   Benjamin Renard   Add Interval Tick...
1596
		//Digital axis zoom
95ab3cf6   Menouard AZIB   Prise en compte d...
1597
1598
1599
1600
		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...
1601
						$axis->{'axis-range-extend'} = false;
d3c3608d   Benjamin Renard   Add undo zoom
1602
1603
						$oldMin = $axis->{'axis-range-min'};
						$oldMax = $axis->{'axis-range-max'};
26a23052   Benjamin Renard   Add Interval Tick...
1604
1605
						$axis->{'axis-range-min'} = $input->{'min'};
						$axis->{'axis-range-max'} = $input->{'max'};
a9d86eaa   Benjamin Renard   Fix zoom / unzoom
1606
						$this->saveIHMRequest($input->interactiveId, $plotInput);
26a23052   Benjamin Renard   Add Interval Tick...
1607
1608
						//Do not save 'force-single-replot' in request file!
						$plotInput->{'force-single-replot'} = true;
d3c3608d   Benjamin Renard   Add undo zoom
1609
1610
						$plotInput->{'force-time-zoom-reset'} = false;
						if (!$isUndo)
95ab3cf6   Menouard AZIB   Prise en compte d...
1611
							$this->addZoomInList($input, true, $oldMin, $oldMax);
26a23052   Benjamin Renard   Add Interval Tick...
1612
1613
1614
1615
1616
1617
1618
1619
						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...
1620

d3c3608d   Benjamin Renard   Add undo zoom
1621
1622
1623
	private function unmarshallUndoZoom($input, $plotInput)
	{
		$result = $this->undoZoomInList($input);
95ab3cf6   Menouard AZIB   Prise en compte d...
1624
1625
1626
		if ($result != NULL) {
			if (isset($result->isInterval)) {
				if (!$result->isInterval) {
d3c3608d   Benjamin Renard   Add undo zoom
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
					$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...
1638

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

26a23052   Benjamin Renard   Add Interval Tick...
1644
1645
1646
1647
1648
		//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...
1649
1650
1651

		switch ($input->{'action'}) {
			case 'forward':
26a23052   Benjamin Renard   Add Interval Tick...
1652
1653
1654
				$startTimeStamp += $duration;
				$stopTimeStamp  += $duration;
				break;
95ab3cf6   Menouard AZIB   Prise en compte d...
1655
1656
1657
			case 'halfforward':
				$startTimeStamp += ($duration / 2);
				$stopTimeStamp  += ($duration / 2);
26a23052   Benjamin Renard   Add Interval Tick...
1658
				break;
2366956c   Erdogan Furkan   10312 - Navigatio...
1659
1660
1661
1662
			case 'quarterforward':
				$startTimeStamp += ($duration / 4);
				$stopTimeStamp  += ($duration / 4);
				break;
95ab3cf6   Menouard AZIB   Prise en compte d...
1663
			case 'backward':
26a23052   Benjamin Renard   Add Interval Tick...
1664
1665
1666
				$startTimeStamp -= $duration;
				$stopTimeStamp  -= $duration;
				break;
95ab3cf6   Menouard AZIB   Prise en compte d...
1667
1668
1669
			case 'halfbackward':
				$startTimeStamp -= ($duration / 2);
				$stopTimeStamp  -= ($duration / 2);
26a23052   Benjamin Renard   Add Interval Tick...
1670
				break;
2366956c   Erdogan Furkan   10312 - Navigatio...
1671
1672
1673
1674
			case 'quarterbackward':
				$startTimeStamp -= ($duration / 4);
				$stopTimeStamp  -= ($duration / 4);
				break;
95ab3cf6   Menouard AZIB   Prise en compte d...
1675
			case 'extend':
26a23052   Benjamin Renard   Add Interval Tick...
1676
1677
1678
				$startTimeStamp -= $input->{'duration'};
				$stopTimeStamp  += $input->{'duration'};
				break;
95ab3cf6   Menouard AZIB   Prise en compte d...
1679
			case 'shift':
26a23052   Benjamin Renard   Add Interval Tick...
1680
1681
1682
1683
				$startTimeStamp += $input->{'duration'};
				$stopTimeStamp  += $input->{'duration'};
				break;
		}
95ab3cf6   Menouard AZIB   Prise en compte d...
1684

26a23052   Benjamin Renard   Add Interval Tick...
1685
1686
		if ($stopTimeStamp - $startTimeStamp <= 0)
			throw new Exception('New duration is lower than 0.');
95ab3cf6   Menouard AZIB   Prise en compte d...
1687
1688
1689
1690

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

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

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

26a23052   Benjamin Renard   Add Interval Tick...
1700
1701
	private function unmarshallTTGoto($input, $plotInput)
	{
419a700b   Benjamin Renard   Fix TT goto
1702
1703
1704
		$plotInput->{'timesrc'} = 'TimeTable';
		$plotInput->{'ttFileIndex'} = $input->{'ttFileIndex'};
		$plotInput->{'intIndex'} = $input->{'intIndex'};
95ab3cf6   Menouard AZIB   Prise en compte d...
1705

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

05da1b4d   Benjamin Renard   Draw instant plot...
1711
1712
	private function unmarshallInstant($input, $plotInput)
	{
05da1b4d   Benjamin Renard   Draw instant plot...
1713
1714
		//Find current panel
		$crtPanel = NULL;
95ab3cf6   Menouard AZIB   Prise en compte d...
1715
1716
		foreach ($plotInput->{'panels'} as $panel) {
			if ($input->{'panelId'} == $panel->{'id'}) {
05da1b4d   Benjamin Renard   Draw instant plot...
1717
1718
1719
1720
				$crtPanel = $panel;
				break;
			}
		}
95ab3cf6   Menouard AZIB   Prise en compte d...
1721

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

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

05da1b4d   Benjamin Renard   Draw instant plot...
1728
1729
		//Find spectra parameter
		$crtParam = NULL;
95ab3cf6   Menouard AZIB   Prise en compte d...
1730
1731
1732
		foreach ($crtPanel->{'params'} as $param) {
			if ($param->{'param-drawing-type'} == 'spectro') {
				$crtParam = $param;
05da1b4d   Benjamin Renard   Draw instant plot...
1733
1734
1735
				break;
			}
		}
95ab3cf6   Menouard AZIB   Prise en compte d...
1736

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

05da1b4d   Benjamin Renard   Draw instant plot...
1740
1741
		//Find table Y-axis
		$crtYAxis = NULL;
95ab3cf6   Menouard AZIB   Prise en compte d...
1742
1743
		foreach ($crtPanel->{'axes'} as $axis) {
			if ($crtParam->{'param-drawing-object'}->{'spectro-yaxis'} == $axis->{'id'}) {
05da1b4d   Benjamin Renard   Draw instant plot...
1744
1745
1746
1747
				$crtYAxis = $axis;
				break;
			}
		}
95ab3cf6   Menouard AZIB   Prise en compte d...
1748

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

05da1b4d   Benjamin Renard   Draw instant plot...
1752
1753
		//Find color Z-axis
		$crtColorAxis = NULL;
95ab3cf6   Menouard AZIB   Prise en compte d...
1754
1755
		foreach ($crtPanel->{'axes'} as $axis) {
			if ($axis->{'id'} == 'color') {
05da1b4d   Benjamin Renard   Draw instant plot...
1756
1757
1758
1759
				$crtColorAxis = $axis;
				break;
			}
		}
95ab3cf6   Menouard AZIB   Prise en compte d...
1760

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

05da1b4d   Benjamin Renard   Draw instant plot...
1764
1765
		date_default_timezone_set('UTC');
		$timeStamp = strtotime($input->time);
95ab3cf6   Menouard AZIB   Prise en compte d...
1766
1767

		$instantPlotInput = (object)array(
05da1b4d   Benjamin Renard   Draw instant plot...
1768
1769
1770
1771
			"interactive-preview" => true,
			"file-format" => "PNG",
			"file-output" => "INTERACTIVE",
			"file-prefix" => "instant",
05da1b4d   Benjamin Renard   Draw instant plot...
1772
1773
1774
			"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...
1775
			"id" => 1,
c2d88cc5   Benjamin Renard   Fix instant plot
1776
1777
1778
1779
1780
			"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...
1781
			"page-layout-type" => "vertical",
95ab3cf6   Menouard AZIB   Prise en compte d...
1782
			"page-layout-object" => (object)array(
05da1b4d   Benjamin Renard   Draw instant plot...
1783
				"layout-expand" => true,
95ab3cf6   Menouard AZIB   Prise en compte d...
1784
				"layout-panel-height" => 0.5,
05da1b4d   Benjamin Renard   Draw instant plot...
1785
1786
1787
1788
1789
1790
1791
1792
1793
				"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...
1794
1795
1796
				"panel-title-font-activated" => TRUE,
				"panel-title-font-size" => 12,
				"panel-title-font-bold" => TRUE,
05da1b4d   Benjamin Renard   Draw instant plot...
1797
				"axes" => array(),
0a87e436   Hacene SI HADJ MOHAND   parameters resolue
1798
1799
				"params" => array(),

05da1b4d   Benjamin Renard   Draw instant plot...
1800
1801
1802
1803
1804
1805
	    );
		
		$instantXAxis = (Object)array(
				"id"         => "xaxis_id",
				"axis-type"  => "x",
				"axis-scale" => $crtYAxis->{"axis-scale"},
d62f9945   Benjamin Renard   Improve instant c...
1806
1807
1808
1809
1810
1811
1812
				"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...
1813
1814
1815
1816
1817
1818
		);
		
		$instantYAxis = (Object)array(
				"id"         => "y-left",
				"axis-type"  => "y-left",
				"axis-scale" => $crtColorAxis->{"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" => $crtColorAxis->{"axis-range-min"},
				"axis-range-max" => $crtColorAxis->{"axis-range-max"},
				"axis-reverse" => $crtColorAxis->{"axis-reverse"},
05da1b4d   Benjamin Renard   Draw instant plot...
1826
1827
1828
		);
		$instantPanel->{"axes"}[] = $instantXAxis;
		$instantPanel->{"axes"}[] = $instantYAxis;
95ab3cf6   Menouard AZIB   Prise en compte d...
1829
1830

		$instantParam = (object)array(
05da1b4d   Benjamin Renard   Draw instant plot...
1831
			"id" => 1,
e4545ed5   Benjamin Renard   Implement templat...
1832
			"paramid" => $crtParam->{'paramid'},
8d780912   Benjamin Renard   Keep template arg...
1833
			"template_args" => $crtParam->{'template_args'},
05da1b4d   Benjamin Renard   Draw instant plot...
1834
1835
1836
1837
1838
			"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...
1839
1840
					"iserie-lines-width" => 3,
					"iserie-lines-color" => "#0000ff"
0a87e436   Hacene SI HADJ MOHAND   parameters resolue
1841
			),
95ab3cf6   Menouard AZIB   Prise en compte d...
1842
1843
1844
1845
1846
1847
1848
1849
1850
1851
1852
1853
1854
1855
1856
			"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
1857

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

0a87e436   Hacene SI HADJ MOHAND   parameters resolue
1861

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


05da1b4d   Benjamin Renard   Draw instant plot...
1865
1866
		return $instantPlotInput;
	}
26a23052   Benjamin Renard   Add Interval Tick...
1867
}