Blame view

src/InputOutput/IHMImpl/Params/PlotImpl/IHMInputOutputParamsPlotClass.php 79.8 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

aba3bf57   Menouard AZIB   Handle the adding...
70
71
		$plotOutputNode->setWriteDataFile($this->isInteractiveRequest ? "true" : "false");

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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


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

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

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


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

1514ed12   Erdogan Furkan   #5390 - Integrati...
304
305
306
307
308
		//Plot Area background color
		if (($panelData->{'panel-plotareabackground-color'} != 'none') && ($panelData->{'panel-plotareabackground-color'} != '')) {
			$panelNode->setPlotAreaBackgroundColor($this->hexColor2KernelColor($panelData->{'panel-plotareabackground-color'}));
		}

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

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

26a23052   Benjamin Renard   Add Interval Tick...
315
		//Plot type
40624062   Elena.Budnik   no total_2D if in...
316
		$this->isInstantPlot = false;
26a23052   Benjamin Renard   Add Interval Tick...
317
		$plotNode = $this->unmarshallPlotType($panelData, $panelNode);
26a23052   Benjamin Renard   Add Interval Tick...
318
		$isTimePlot = ($plotNode->getName() == REQUESTOUTPUTPLOTELEMENTTIME_NAME);
95ab3cf6   Menouard AZIB   Prise en compte d...
319

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

26a23052   Benjamin Renard   Add Interval Tick...
330
331
		//Status plot
		$statusPlotNode = NULL;
95ab3cf6   Menouard AZIB   Prise en compte d...
332
333
334
335
336
		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...
337
338
						$statusPlotNode->setPosition(RequestOutputPlotElementStatusPosition::TOP);
						break;
95ab3cf6   Menouard AZIB   Prise en compte d...
339
					case 'bottom':
26a23052   Benjamin Renard   Add Interval Tick...
340
341
342
343
344
345
						$statusPlotNode->setPosition(RequestOutputPlotElementStatusPosition::BOTTOM);
						break;
				}
				$statusPlotNode->setColorMap($panelData->{'panel-status-colormap'});
			}
		}
95ab3cf6   Menouard AZIB   Prise en compte d...
346

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

26a23052   Benjamin Renard   Add Interval Tick...
351
		//Params
c4213719   Erdogan Furkan   Done.
352
		$this->unmarshallParams($panelData->{'params'}, $paramsNode, $plotNode, $panelNode, $statusPlotNode, $tickPlotNode, $panelData->{'axes'});
95ab3cf6   Menouard AZIB   Prise en compte d...
353

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

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

26a23052   Benjamin Renard   Add Interval Tick...
362
363
		return $panelNode;
	}
95ab3cf6   Menouard AZIB   Prise en compte d...
364

26a23052   Benjamin Renard   Add Interval Tick...
365
366
	protected function unmarshallPlotType($panelData, $panelNode)
	{
95ab3cf6   Menouard AZIB   Prise en compte d...
367
368
		switch ($panelData->{'panel-plot-type'}) {
			case 'timePlot':
26a23052   Benjamin Renard   Add Interval Tick...
369
370
				$plotNode = $panelNode->addPlotElement(RequestOutputPlotElementTypeEnum::TIMEPLOT);
				break;
95ab3cf6   Menouard AZIB   Prise en compte d...
371
			case 'xyPlot':
26a23052   Benjamin Renard   Add Interval Tick...
372
373
374
				$plotNode = $panelNode->addPlotElement(RequestOutputPlotElementTypeEnum::XYPLOT);
				$plotNode->setIsIsotropic($panelData->{'panel-scatter-isotropic'});
				break;
61e60608   Erdogan Furkan   For now, histo1D ...
375
376
377
			case 'histoPlot':
				$plotNode = $panelNode->addPlotElement(RequestOutputPlotElementTypeEnum::HISTOPLOT);
				break;
95ab3cf6   Menouard AZIB   Prise en compte d...
378
			case 'statusPlot':
26a23052   Benjamin Renard   Add Interval Tick...
379
				$plotNode = $panelNode->addPlotElement(RequestOutputPlotElementTypeEnum::STATUSPLOT);
95ab3cf6   Menouard AZIB   Prise en compte d...
380
381
				switch ($panelData->{'panel-status-position'}) {
					case 'top':
26a23052   Benjamin Renard   Add Interval Tick...
382
383
						$plotNode->setPosition(RequestOutputPlotElementStatusPosition::TOP);
						break;
95ab3cf6   Menouard AZIB   Prise en compte d...
384
					case 'bottom':
26a23052   Benjamin Renard   Add Interval Tick...
385
386
387
388
389
						$plotNode->setPosition(RequestOutputPlotElementStatusPosition::BOTTOM);
						break;
				}
				$plotNode->setColorMap($panelData->{'panel-status-colormap'});
				break;
95ab3cf6   Menouard AZIB   Prise en compte d...
390
			case 'tickPlot':
26a23052   Benjamin Renard   Add Interval Tick...
391
392
393
394
				$plotNode = $panelNode->addPlotElement(RequestOutputPlotElementTypeEnum::TICKPLOT);
				if ($panelData->{'panel-tick-format'} != '')
					$plotNode->setFormat($panelData->{'panel-tick-format'});
				break;
95ab3cf6   Menouard AZIB   Prise en compte d...
395
			case 'epochPlot':
26a23052   Benjamin Renard   Add Interval Tick...
396
				$plotNode = $panelNode->addPlotElement(RequestOutputPlotElementTypeEnum::EPOCHPLOT);
d6bf6ef5   Benjamin Renard   Get the possibili...
397
398
				if ($panelData->{'panel-epoch-centertimeid'} != '')
					$plotNode->setCenterTimeId($panelData->{'panel-epoch-centertimeid'});
26a23052   Benjamin Renard   Add Interval Tick...
399
				break;
95ab3cf6   Menouard AZIB   Prise en compte d...
400
			case 'instantPlot':
26a23052   Benjamin Renard   Add Interval Tick...
401
402
				$plotNode = $panelNode->addPlotElement(RequestOutputPlotElementTypeEnum::INSTANTPLOT);
				date_default_timezone_set('UTC');
74fd500a   Hacene SI HADJ MOHAND   us #9874 ms zoo...
403
				$time = CommonClass::strTimeToDDTime($panelData->{'panel-instant-time'});
26a23052   Benjamin Renard   Add Interval Tick...
404
				$plotNode->setTime($time);
40624062   Elena.Budnik   no total_2D if in...
405
				$this->isInstantPlot = true;
26a23052   Benjamin Renard   Add Interval Tick...
406
				break;
80f24b8c   Menouard AZIB   Ajouter à la méth...
407
408
409
410
411
412
			case RequestOutPutPlotElementPlotFunctionNodeClass::REQUESTOUTPUTPLOTELEMENT_PLOTFUNCTION_NAME:
				$plotNode = $panelNode->addPlotElement(RequestOutputPlotElementTypeEnum::PLOTFUNCTION);
				$plotNode->setAbscisse($panelData->{RequestOutPutPlotElementPlotFunctionNodeClass::PLOT_FUNCTION_ABSCISSE});
				$plotNode->setType($panelData->{RequestOutPutPlotElementPlotFunctionNodeClass::PLOT_FUNCTION_TYPE});
				$plotNode->setScaleAbscisse($panelData->{RequestOutPutPlotElementPlotFunctionNodeClass::PLOT_FUNCTION_SCALE_ABSCISSE});
				$plotNode->setScaleOrdonnee($panelData->{RequestOutPutPlotElementPlotFunctionNodeClass::PLOT_FUNCTION_SCALE_ORDONNEE});
328140af   Benjamin Renard   Restore FFT
413
				//$plotNode->setParamsNbPoints($panelData->{RequestOutPutPlotElementPlotFunctionNodeClass::PLOT_FUNCTION_PARAMS_NB_POINTS});
80f24b8c   Menouard AZIB   Ajouter à la méth...
414
				break;
26a23052   Benjamin Renard   Add Interval Tick...
415
416
417
			default:
				throw new Exception('Plot type not implemented.');
		}
95ab3cf6   Menouard AZIB   Prise en compte d...
418

26a23052   Benjamin Renard   Add Interval Tick...
419
420
421
		//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...
422

26a23052   Benjamin Renard   Add Interval Tick...
423
		//Text Legends
fe1a8ddd   Erdogan Furkan   Modifications for...
424
425
426
427
		foreach ($panelData->{'text-legends'} as $textLegendData) {
			$legendNode = $plotNode->getLegends()->addTextLegend();
			$this->unmarshallTextLegend($textLegendData, $legendNode);
		}
95ab3cf6   Menouard AZIB   Prise en compte d...
428

26a23052   Benjamin Renard   Add Interval Tick...
429
430
		return $plotNode;
	}
95ab3cf6   Menouard AZIB   Prise en compte d...
431

26a23052   Benjamin Renard   Add Interval Tick...
432
433
434
435
	protected function unmarshallAxis($axisData, $constantsData, $plotNode)
	{
		//axis type
		$constantAxisId = '';
95ab3cf6   Menouard AZIB   Prise en compte d...
436
437
		switch ($axisData->{'axis-type'}) {
			case 'time':
26a23052   Benjamin Renard   Add Interval Tick...
438
439
440
441
				$axisNode = $plotNode->getTimeAxis();
				$axisNode->setFormat($axisData->{'axis-time-format'});
				$constantAxisId = 'x';
				break;
95ab3cf6   Menouard AZIB   Prise en compte d...
442
			case 'epoch':
26a23052   Benjamin Renard   Add Interval Tick...
443
444
445
446
				$axisNode = $plotNode->getEpochAxis();
				$axisNode->setNormalized($axisData->{'axis-epoch-normalized'} ? "true" : "false");
				$constantAxisId = 'x';
				break;
95ab3cf6   Menouard AZIB   Prise en compte d...
447
			case 'x':
26a23052   Benjamin Renard   Add Interval Tick...
448
449
450
				$axisNode = $plotNode->getXAxis();
				$constantAxisId = 'x';
				break;
95ab3cf6   Menouard AZIB   Prise en compte d...
451
			case 'y-left':
26a23052   Benjamin Renard   Add Interval Tick...
452
453
454
				$axisNode = $plotNode->addYAxis('y-left');
				$constantAxisId = 'y-left';
				break;
95ab3cf6   Menouard AZIB   Prise en compte d...
455
			case 'y-right':
26a23052   Benjamin Renard   Add Interval Tick...
456
457
458
459
				$axisNode = $plotNode->addYAxis('y-right');
				$axisNode->setPosition(RequestOutputPlotAxisElementPosition::RIGHT);
				$constantAxisId = 'y-right';
				break;
95ab3cf6   Menouard AZIB   Prise en compte d...
460
			case 'color':
26a23052   Benjamin Renard   Add Interval Tick...
461
462
463
464
465
466
467
468
469
470
				$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...
471

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

26a23052   Benjamin Renard   Add Interval Tick...
476
		//axis scale
95ab3cf6   Menouard AZIB   Prise en compte d...
477
478
		switch ($axisData->{'axis-scale'}) {
			case 'logarithmic':
26a23052   Benjamin Renard   Add Interval Tick...
479
480
481
482
483
				$axisNode->setScale(RequestOutputPlotAxisElementScale::LOGARITHMIC);
				break;
			default:
				$axisNode->setScale(RequestOutputPlotAxisElementScale::LINEAR);
		}
95ab3cf6   Menouard AZIB   Prise en compte d...
484

26a23052   Benjamin Renard   Add Interval Tick...
485
486
487
		//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...
488
489
		if (isset($axisData->{'axis-range-extend'}))
			$axisNode->getRange()->setExtend($axisData->{'axis-range-extend'} ? "true" : "false");
95ab3cf6   Menouard AZIB   Prise en compte d...
490

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

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

26a23052   Benjamin Renard   Add Interval Tick...
499
		//axis ticks position
95ab3cf6   Menouard AZIB   Prise en compte d...
500
501
		switch ($axisData->{'axis-tick-position'}) {
			case 'inwards':
26a23052   Benjamin Renard   Add Interval Tick...
502
503
				$axisNode->getTick()->setPosition(RequestOutputPlotAxisElementTickPosition::INWARDS);
				break;
95ab3cf6   Menouard AZIB   Prise en compte d...
504
			default:
26a23052   Benjamin Renard   Add Interval Tick...
505
506
				$axisNode->getTick()->setPosition(RequestOutputPlotAxisElementTickPosition::OUTWARDS);
		}
95ab3cf6   Menouard AZIB   Prise en compte d...
507

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

05da1b4d   Benjamin Renard   Draw instant plot...
512
513
		if (isset($axisData->{'axis-grid-major'}))
			$axisNode->getTick()->setMajorGrid($axisData->{'axis-grid-major'} ? "true" : "false");
95ab3cf6   Menouard AZIB   Prise en compte d...
514
515
516
517
518
519
520
521
		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'}) {
bf41f58a   Erdogan Furkan   Integration part ...
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
			$timeMultiplier = 1;
			if(isset($axisData->{'axis-tick-time-unit'}) && ($axisData->{'axis-type'} == "time" || $axisData->{'axis-type'} == "epoch" )){
				switch ($axisData->{'axis-tick-time-unit'}) {
					case 'default':
						$timeMultiplier = 1;
						break;
					case 'min':
						$timeMultiplier = 60;
						break;
					case "hour":
						$timeMultiplier = 3600;
						break;
					case "day":
						$timeMultiplier = 86400;
						break;
				}	
			}
95ab3cf6   Menouard AZIB   Prise en compte d...
539
540

			if (isset($axisData->{'axis-grid-major-space'}) && $axisData->{'axis-grid-major-space'} != 0)
bf41f58a   Erdogan Furkan   Integration part ...
541
				$axisNode->getTick()->setMajorGridSpace($axisData->{'axis-grid-major-space'}*$timeMultiplier);
95ab3cf6   Menouard AZIB   Prise en compte d...
542
543

			if (isset($axisData->{'axis-grid-minor-space'}) && $axisData->{'axis-grid-minor-space'} != 0)
bf41f58a   Erdogan Furkan   Integration part ...
544
545
				$axisNode->getTick()->setMinorGridSpace($axisData->{'axis-grid-minor-space'}*$timeMultiplier);
			
95ab3cf6   Menouard AZIB   Prise en compte d...
546
547
548
549
550
		}


		//legend
		if (isset($axisData->{'axis-legend-text'}) && $axisData->{'axis-legend-text'} != '') {
26a23052   Benjamin Renard   Add Interval Tick...
551
			$axisNode->getLegend()->setText($axisData->{'axis-legend-text'});
05da1b4d   Benjamin Renard   Draw instant plot...
552
		}
27317777   Menouard AZIB   J'ai ajouté la fo...
553
554
		$axisNode->getLegend()->setColor($this->hexColor2KernelColor($axisData->{'axis-legend-color'}));
		$this->unmarshallLabel($axisData, "axis-legend", $axisNode->getLegend());
d62f9945   Benjamin Renard   Improve instant c...
555

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

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

26a23052   Benjamin Renard   Add Interval Tick...
564
		//Add constants
95ab3cf6   Menouard AZIB   Prise en compte d...
565
		if ($constantAxisId != '') {
26a23052   Benjamin Renard   Add Interval Tick...
566
567
			foreach ($constantsData as $constantData)
				if ($constantData->{'constant-axis-id'} == $constantAxisId)
95ab3cf6   Menouard AZIB   Prise en compte d...
568
					$this->unmarshallConstant($constantData, $axisNode);
26a23052   Benjamin Renard   Add Interval Tick...
569
570
		}
	}
95ab3cf6   Menouard AZIB   Prise en compte d...
571

c4213719   Erdogan Furkan   Done.
572
	protected function unmarshallParams($paramsData, $requestParamsNode, $plotNode, $panelNode, $statusPlotNode, $tickPlotNode, $axesData)
26a23052   Benjamin Renard   Add Interval Tick...
573
574
575
	{
		//X parameters
		$isScatter = ($plotNode->getName() == REQUESTOUTPUTPLOTELEMENTXY_NAME);
1ce37eda   Erdogan Furkan   Histo 1D&2D working
576
		$isHisto = ($plotNode->getName() == REQUESTOUTPUTPLOTELEMENTHISTO_NAME);	
f822811a   Benjamin Renard   Implements multi ...
577
		$xIds = array();
1ce37eda   Erdogan Furkan   Histo 1D&2D working
578
		if ($isScatter || $isHisto) {
f822811a   Benjamin Renard   Implements multi ...
579
			$crtXId = 0;
95ab3cf6   Menouard AZIB   Prise en compte d...
580
			foreach ($paramsData as $paramData) {
26a23052   Benjamin Renard   Add Interval Tick...
581
582
				if ($paramData->{'param-drawing-object'}->{'serie-xaxis-param'} == '')
					continue;
f822811a   Benjamin Renard   Implements multi ...
583
584
585
586
				if (array_key_exists($paramData->{'param-drawing-object'}->{'serie-xaxis-param'}, $xIds)) {
					//x param already exists
					continue;
				}
95ab3cf6   Menouard AZIB   Prise en compte d...
587

bf27ba04   Benjamin Renard   Add templated par...
588
				$paramXInfo = $this->paramManager->addExistingParam($paramData->{'param-drawing-object'}->{'serie-xaxis-param'}, $this->paramsData);
26a23052   Benjamin Renard   Add Interval Tick...
589
590
591
592
				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...
593
				switch ($paramData->{'param-drawing-type'}) {
c4213719   Erdogan Furkan   Done.
594
					case 'histogram2d':
95ab3cf6   Menouard AZIB   Prise en compte d...
595
					case 'serie':
26a23052   Benjamin Renard   Add Interval Tick...
596
597
						//Unmarshall x serie
						if (count($paramXInfo['indexes']) == 0)
f822811a   Benjamin Renard   Implements multi ...
598
							$xParamNode->addXSerie(-1, $crtXId, $paramData->{'param-drawing-object'}->{'serie-xvalue-min'}, $paramData->{'param-drawing-object'}->{'serie-xvalue-max'});
26a23052   Benjamin Renard   Add Interval Tick...
599
						else if (count($paramXInfo['indexes']) == 1)
f822811a   Benjamin Renard   Implements multi ...
600
							$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...
601
602
603
						else
							throw new Exception('X parameter for serie must be a component.');
						break;
95ab3cf6   Menouard AZIB   Prise en compte d...
604
					default:
26a23052   Benjamin Renard   Add Interval Tick...
605
606
						throw new Exception('X parameter not allowed for this drawing type. ');
				}
f822811a   Benjamin Renard   Implements multi ...
607
608
				$xIds[$paramData->{'param-drawing-object'}->{'serie-xaxis-param'}] = $crtXId;
				++$crtXId;
26a23052   Benjamin Renard   Add Interval Tick...
609
610
			}
		}
95ab3cf6   Menouard AZIB   Prise en compte d...
611

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

26a23052   Benjamin Renard   Add Interval Tick...
617
			//Param
52c1e291   Benjamin Renard   Generate TT and c...
618
619
			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...
620
			} else {
52c1e291   Benjamin Renard   Generate TT and c...
621
622
				$paramInfo = $this->paramManager->addTTCatParam($paramData->{'paramid'}, $this->paramsData);
			}
95ab3cf6   Menouard AZIB   Prise en compte d...
623

3182799a   Benjamin Renard   Use param indexes...
624
			$paramInfo['indexes'] = array();
27317777   Menouard AZIB   J'ai ajouté la fo...
625
626
627
628
629
			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...
630
631
			$this->paramManager->applyFilter($this->paramsData, $paramData, $paramInfo);

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

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

e8002665   Erdogan Furkan   Minor fix
638
			$xId = (($isScatter || $isHisto) && !empty($paramData->{'param-drawing-object'}->{'serie-xaxis-param'})) ? $xIds[$paramData->{'param-drawing-object'}->{'serie-xaxis-param'}] : -1;
95ab3cf6   Menouard AZIB   Prise en compte d...
639
640
641

			switch ($paramData->{'param-drawing-type'}) {
				case 'serie':
26a23052   Benjamin Renard   Add Interval Tick...
642
					$paramNode = $plotNode->getParams()->getParamById($paramInfo['id']);
f822811a   Benjamin Renard   Implements multi ...
643
					$this->unmarshallSerie($paramData, $requestParamsNode, $plotNode, $paramNode, $paramInfo['indexes'], $xId, $colorSerieId, false);
26a23052   Benjamin Renard   Add Interval Tick...
644
					break;
c4213719   Erdogan Furkan   Done.
645
646
				case 'histogram2d':
					$paramNode = $plotNode->getParams()->getParamById($paramInfo['id']);
2c99863f   Erdogan Furkan   Minor fix
647
648
649
650
					if(!empty($paramData->{'param-drawing-object'}->{'histotype-param'}))
						$paramZInfo = $this->paramManager->addExistingParam($paramData->{'param-drawing-object'}->{'histotype-param'}, $this->paramsData);
					else
						$paramZInfo = NULL;
c4213719   Erdogan Furkan   Done.
651
652
					$this->unmarshallHistogram2D($paramData, $requestParamsNode, $plotNode, $paramNode, $paramInfo['indexes'], $xId, $paramZInfo,$axesData);
					break;	
61e60608   Erdogan Furkan   For now, histo1D ...
653
654
655
656
				case 'histogram1d':
					$paramNode = $plotNode->getParams()->getParamById($paramInfo['id']);
					$this->unmarshallHistogram1D($paramData, $requestParamsNode, $plotNode, $paramNode, $paramInfo['indexes']);
					break;
95ab3cf6   Menouard AZIB   Prise en compte d...
657
				case 'orbit-serie':
26a23052   Benjamin Renard   Add Interval Tick...
658
					$paramNode = $plotNode->getParams()->getParamById($paramInfo['id']);
f822811a   Benjamin Renard   Implements multi ...
659
					$this->unmarshallSerie($paramData, $requestParamsNode, $plotNode, $paramNode, -1, $xId, $colorSerieId, true);
26a23052   Benjamin Renard   Add Interval Tick...
660
					break;
95ab3cf6   Menouard AZIB   Prise en compte d...
661
				case 'spectro':
26a23052   Benjamin Renard   Add Interval Tick...
662
663
664
					$paramNode = $plotNode->getParams()->getParamById($paramInfo['id']);
					$this->unmarshallSpectro($paramData->{'param-drawing-object'}, $plotNode, $paramNode, $paramInfo['indexes']);
					break;
27317777   Menouard AZIB   J'ai ajouté la fo...
665
666
667
				case 'sauvaud':
					$paramNode = $plotNode->getParams()->getParamById($paramInfo['id']);
					$this->unmarshallSauvaud($paramData->{'param-drawing-object'}, $plotNode, $paramNode, $paramInfo['indexes']);
3dcf7710   Hacene SI HADJ MOHAND   us ok
668
					break;
95ab3cf6   Menouard AZIB   Prise en compte d...
669
				case 'status-bar':
26a23052   Benjamin Renard   Add Interval Tick...
670
671
672
673
674
675
					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...
676
				case 'tick-bar':
26a23052   Benjamin Renard   Add Interval Tick...
677
678
679
680
					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...
681

26a23052   Benjamin Renard   Add Interval Tick...
682
683
					$this->unmarshallTickBar($paramData->{'param-drawing-object'}, $paramNode, $paramInfo['indexes']);
					break;
95ab3cf6   Menouard AZIB   Prise en compte d...
684
				case 'iserie':
26a23052   Benjamin Renard   Add Interval Tick...
685
686
687
					$paramNode = $plotNode->getParams()->getParamById($paramInfo['id']);
					$this->unmarshallInstantSerie($paramData->{'param-drawing-object'}, $plotNode, $paramNode);
					break;
95ab3cf6   Menouard AZIB   Prise en compte d...
688
				case 'ispectro':
fc153c1c   Elena.Budnik   ispectro added
689
690
					$paramNode = $plotNode->getParams()->getParamById($paramInfo['id']);
					$this->unmarshallInstantSpectro($paramData->{'param-drawing-object'}, $plotNode, $paramNode, $paramInfo['indexes']);
044a9305   Benjamin Renard   Add intervals dra...
691
					break;
95ab3cf6   Menouard AZIB   Prise en compte d...
692
				case 'intervals':
044a9305   Benjamin Renard   Add intervals dra...
693
694
695
					$paramNode = $plotNode->getParams()->getParamById($paramInfo['id']);
					$this->unmarshallIntervals($paramData->{'param-drawing-object'}, $paramNode);
					break;
95ab3cf6   Menouard AZIB   Prise en compte d...
696
				default:
26a23052   Benjamin Renard   Add Interval Tick...
697
698
699
700
					throw new Exception('Drawing type not implemented.');
			}
			++$drawingEltIndex;
		}
95ab3cf6   Menouard AZIB   Prise en compte d...
701

26a23052   Benjamin Renard   Add Interval Tick...
702
703
		//Colored parameter
		$drawingEltIndex = 0;
95ab3cf6   Menouard AZIB   Prise en compte d...
704
705
		foreach ($paramsData as $paramData) {
			if (empty($paramData->{'param-drawing-object'}->{'serie-colored-param'})) {
26a23052   Benjamin Renard   Add Interval Tick...
706
707
708
				++$drawingEltIndex;
				continue;
			}
95ab3cf6   Menouard AZIB   Prise en compte d...
709

bf27ba04   Benjamin Renard   Add templated par...
710
			$paramColoredInfo = $this->paramManager->addExistingParam($paramData->{'param-drawing-object'}->{'serie-colored-param'}, $this->paramsData);
26a23052   Benjamin Renard   Add Interval Tick...
711
712
713
714
			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...
715

26a23052   Benjamin Renard   Add Interval Tick...
716
			$colorSerieId = $drawingEltIndex;
95ab3cf6   Menouard AZIB   Prise en compte d...
717
718
719
720

			switch ($paramData->{'param-drawing-type'}) {
				case 'serie':
				case 'orbit-serie':
26a23052   Benjamin Renard   Add Interval Tick...
721
722
723
724
725
726
727
728
					//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...
729
				default:
26a23052   Benjamin Renard   Add Interval Tick...
730
731
732
733
734
					throw new Exception('Colored parameter not allowed for this drawing type. ');
			}
			++$drawingEltIndex;
		}
	}
95ab3cf6   Menouard AZIB   Prise en compte d...
735

c4213719   Erdogan Furkan   Done.
736
737
738
739
740
	protected function unmarshallHistogram2D($paramData, $requestParamsNode, $plotNode, $paramNode, $indexes, $xId, $paramZInfo,$axesData)
	{
		$histogram2DNodes = array();
		if (count($indexes) == 0) {
			$histogram2DNode = $paramNode->addHistogram2DSerie($paramData->{'param-drawing-object'}->{'serie-yaxis'}, -1, $xId);
f84b7023   Benjamin Renard   Prevent exception...
741
742
743
744
			if (isset($histogram2DNode)) {
				$histogram2DNode->setId($paramData->{'id'});
				$histogram2DNodes[] = $histogram2DNode;
			}
c4213719   Erdogan Furkan   Done.
745
746
747
		}
		foreach ($indexes as $index) {
			$histogram2DNode = $paramNode->addHistogram2DSerie($paramData->{'param-drawing-object'}->{'serie-yaxis'}, $index, $xId);
f84b7023   Benjamin Renard   Prevent exception...
748
749
750
751
752
			if (isset($histogram2DNode)) {
				if (count($indexes) == 1)
					$histogram2DNode->setId($paramData->{'id'});
				$histogram2DNodes[] = $histogram2DNode;
			}
c4213719   Erdogan Furkan   Done.
753
754
		}

c4213719   Erdogan Furkan   Done.
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
		foreach ($histogram2DNodes as $histogram2DNode) {
			// resampling
			
			switch ($paramData->{'param-drawing-object'}->{'serie-resampling-mode'}) {
				case 'yparam':
					$histogram2DNode->getResampling()->setType(RequestOutputPlotResamplingTypeEnum::YPARAM);
					break;
				case 'xparam':
				default:
					$histogram2DNode->getResampling()->setType(RequestOutputPlotResamplingTypeEnum::XPARAM);
			}
			// xBinNumber & yBinNumber
			$histogram2DNode->getBins()->addManualBins($paramData->{'param-drawing-object'}->{'histo2d-xbinnumber'},$paramData->{'param-drawing-object'}->{'histo2d-ybinnumber'});

			// histotype, function
			$histogram2DNode->getHistotype()->setFunction($paramData->{'param-drawing-object'}->{'histo2d-function'});
			//smoothfactor
			$histogram2DNode->getHistotype()->setSmoothFactor($paramData->{'param-drawing-object'}->{'histo2d-smoothfactor'});
2c99863f   Erdogan Furkan   Minor fix
773

4f5b34a4   Benjamin Renard   Add normalized de...
774
775
			if(($paramData->{'param-drawing-object'}->{'histo2d-function'} != "density") && 
				($paramData->{'param-drawing-object'}->{'histo2d-function'} != "normdensity")){
c4213719   Erdogan Furkan   Done.
776
				// paramId
43b2304e   Benjamin Renard   Throw exception i...
777
778
779
				if (empty($paramZInfo['id'])) {
					throw new Exception('Z parameter must be defined to apply function.');
				}
c4213719   Erdogan Furkan   Done.
780
781
782
783
784
785
786
787
788
789
790
791
792
793
				$requestParamsNode->addParam($paramZInfo['id']);
				$histogram2DNode->getHistotype()->setParamId($paramZInfo['id']);

				// index
				if (count($paramZInfo['indexes']) == 0)
					$histogram2DNode->getHistotype()->setIndex(-1);
				else if (count($paramZInfo['indexes']) == 1)
					$histogram2DNode->getHistotype()->setIndex($paramZInfo['indexes'][0]);
				else
					throw new Exception('Z parameter for serie must be a component.');
			}
		}
	}

61e60608   Erdogan Furkan   For now, histo1D ...
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
	protected function unmarshallHistogram1D($paramData, $requestParamsNode, $plotNode, $paramNode, $indexes)
	{
		$histogram1DNodes = array();
		if ($paramData->{'param-drawing-object'}->{'histo1d-color'} == "none") {
			$color = NULL;
		} else {
			$color = $this->hexColor2KernelColor($paramData->{'param-drawing-object'}->{'histo1d-color'});
		}
		
		if (count($indexes) == 0) {
			$histogram1DNode = $paramNode->addHistogram1DSerie($paramData->{'param-drawing-object'}->{'serie-yaxis'}, -1, $color);
			if (isset($histogram1DNode)) {
				$histogram1DNode->setId($paramData->{'id'});
				$histogram1DNodes[] = $histogram1DNode;
			}
		}
		foreach ($indexes as $index) {
			$histogram1DNode = $paramNode->addHistogram1DSerie($paramData->{'param-drawing-object'}->{'serie-yaxis'}, $index, $color);
			if (isset($histogram1DNode)) {
				if (count($indexes) == 1)
					$histogram1DNode->setId($paramData->{'id'});
				$histogram1DNodes[] = $histogram1DNode;
			}
		}

		foreach ($histogram1DNodes as $histogram1DNode) {

			// xBinNumber 
			$histogram1DNode->getBins()->addManual1DBins($paramData->{'param-drawing-object'}->{'histo1d-xbinnumber'});

			// histotype, function
			$histogram1DNode->getHistotype()->set1DFunction($paramData->{'param-drawing-object'}->{'histo1d-function'});

		}
	}

f822811a   Benjamin Renard   Implements multi ...
830
	protected function unmarshallSerie($paramData, $requestParamsNode, $plotNode, $paramNode, $indexes, $xId, $colorSerieId, $isOrbitSerie)
26a23052   Benjamin Renard   Add Interval Tick...
831
832
	{
		$serieNodes = array();
95ab3cf6   Menouard AZIB   Prise en compte d...
833
834
835

		if (!$isOrbitSerie) {
			if (count($indexes) == 0) {
f822811a   Benjamin Renard   Implements multi ...
836
				$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...
837
				$serieNode->setId($paramData->{'id'});
60a1a563   Benjamin Renard   Add the possibili...
838
839
				if (!empty($paramData->{'param-drawing-object'}->{'serie-resolution'}))
					$serieNode->setResolution($paramData->{'param-drawing-object'}->{'serie-resolution'});
26a23052   Benjamin Renard   Add Interval Tick...
840
841
				$serieNodes[] = $serieNode;
			}
95ab3cf6   Menouard AZIB   Prise en compte d...
842
			foreach ($indexes as $index) {
f822811a   Benjamin Renard   Implements multi ...
843
				$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...
844
845
				if (count($indexes) == 1)
					$serieNode->setId($paramData->{'id'});
60a1a563   Benjamin Renard   Add the possibili...
846
847
				if (!empty($paramData->{'param-drawing-object'}->{'serie-resolution'}))
					$serieNode->setResolution($paramData->{'param-drawing-object'}->{'serie-resolution'});
26a23052   Benjamin Renard   Add Interval Tick...
848
849
				$serieNodes[] = $serieNode;
			}
95ab3cf6   Menouard AZIB   Prise en compte d...
850
		} else {
cb46dfbf   Benjamin Renard   Fix orbit serie a...
851
			$orbitSerie = $paramNode->addOrbitSerie($paramData->{'param-drawing-object'}->{'serie-yaxis'}, $colorSerieId);
26a23052   Benjamin Renard   Add Interval Tick...
852
853
854
			$orbitSerie->setId($paramData->{'id'});
			$serieNodes[] = $orbitSerie;
		}
95ab3cf6   Menouard AZIB   Prise en compte d...
855
856
857

		foreach ($serieNodes as $serieNode) {
			if (!$isOrbitSerie) {
26a23052   Benjamin Renard   Add Interval Tick...
858
				//Resampling
95ab3cf6   Menouard AZIB   Prise en compte d...
859
860
861
				if ($plotNode->getName() == REQUESTOUTPUTPLOTELEMENTXY_NAME) {
					switch ($paramData->{'param-drawing-object'}->{'serie-resampling-mode'}) {
						case 'yparam':
26a23052   Benjamin Renard   Add Interval Tick...
862
863
							$serieNode->getResampling()->setType(RequestOutputPlotResamplingTypeEnum::YPARAM);
							break;
95ab3cf6   Menouard AZIB   Prise en compte d...
864
865
						case 'xparam':
						default:
26a23052   Benjamin Renard   Add Interval Tick...
866
867
868
							$serieNode->getResampling()->setType(RequestOutputPlotResamplingTypeEnum::XPARAM);
					}
				}
95ab3cf6   Menouard AZIB   Prise en compte d...
869
			} else {
26a23052   Benjamin Renard   Add Interval Tick...
870
				//Projection
95ab3cf6   Menouard AZIB   Prise en compte d...
871
872
				switch ($paramData->{'param-drawing-object'}->{'serie-projection'}) {
					case 'XY':
26a23052   Benjamin Renard   Add Interval Tick...
873
874
						$serieNode->setProjection(RequestOutputPlotOrbitSerieProjectionEnum::XY);
						break;
95ab3cf6   Menouard AZIB   Prise en compte d...
875
					case 'XZ':
26a23052   Benjamin Renard   Add Interval Tick...
876
877
						$serieNode->setProjection(RequestOutputPlotOrbitSerieProjectionEnum::XZ);
						break;
95ab3cf6   Menouard AZIB   Prise en compte d...
878
					case 'YZ':
26a23052   Benjamin Renard   Add Interval Tick...
879
880
						$serieNode->setProjection(RequestOutputPlotOrbitSerieProjectionEnum::YZ);
						break;
95ab3cf6   Menouard AZIB   Prise en compte d...
881
					case 'XR':
26a23052   Benjamin Renard   Add Interval Tick...
882
883
						$serieNode->setProjection(RequestOutputPlotOrbitSerieProjectionEnum::XR);
						break;
95ab3cf6   Menouard AZIB   Prise en compte d...
884
					case 'YR':
26a23052   Benjamin Renard   Add Interval Tick...
885
886
						$serieNode->setProjection(RequestOutputPlotOrbitSerieProjectionEnum::YR);
						break;
95ab3cf6   Menouard AZIB   Prise en compte d...
887
					case 'ZR':
26a23052   Benjamin Renard   Add Interval Tick...
888
889
						$serieNode->setProjection(RequestOutputPlotOrbitSerieProjectionEnum::ZR);
						break;
95ab3cf6   Menouard AZIB   Prise en compte d...
890
					default:
26a23052   Benjamin Renard   Add Interval Tick...
891
892
893
						throw new Exception('Projection not allowed for the orbit serie');
				}
			}
95ab3cf6   Menouard AZIB   Prise en compte d...
894

26a23052   Benjamin Renard   Add Interval Tick...
895
896
897
898
899
900
901
902
903
904
905
906
907
			//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...
908
			if (!$isOrbitSerie) {
26a23052   Benjamin Renard   Add Interval Tick...
909
910
911
912
913
914
				//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...
915

26a23052   Benjamin Renard   Add Interval Tick...
916
917
918
919
920
921
922
923
924
925
926
	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...
927
928
		switch ($serieData->{'serie-timetick-type'}) {
			case 'time-step':
26a23052   Benjamin Renard   Add Interval Tick...
929
930
931
				$timeTickNode->setStep(CommonClass::timeStampToDDTime($serieData->{'serie-timetick-step'}));
				$timeTickNode->setNumber(0);
				break;
95ab3cf6   Menouard AZIB   Prise en compte d...
932
			case 'nb-major':
26a23052   Benjamin Renard   Add Interval Tick...
933
934
935
				$timeTickNode->setStep(0);
				$timeTickNode->setNumber($serieData->{'serie-timetick-nbmajor'});
				break;
95ab3cf6   Menouard AZIB   Prise en compte d...
936
937
			case 'auto':
			default:
26a23052   Benjamin Renard   Add Interval Tick...
938
939
940
941
942
943
944
945
				$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...
946

26a23052   Benjamin Renard   Add Interval Tick...
947
948
949
	protected function unmarshallIntervalTick($serieData, $intervalTickNode)
	{
		//Mode
95ab3cf6   Menouard AZIB   Prise en compte d...
950
		switch ($serieData->{'serie-intervaltick-mode'}) {
26a23052   Benjamin Renard   Add Interval Tick...
951
			case 'symbol-only':
4f9a8e36   Benjamin Renard   Min/Max value def...
952
				$intervalTickNode->setMode(RequestOutputPlotSerieIntervalTicksModeEnum::SYMBOLONLY);
26a23052   Benjamin Renard   Add Interval Tick...
953
954
				break;
			case 'interval-index':
4f9a8e36   Benjamin Renard   Min/Max value def...
955
				$intervalTickNode->setMode(RequestOutputPlotSerieIntervalTicksModeEnum::INTERVALINDEX);
26a23052   Benjamin Renard   Add Interval Tick...
956
957
				break;
			case 'start-stop-time':
4f9a8e36   Benjamin Renard   Min/Max value def...
958
				$intervalTickNode->setMode(RequestOutputPlotSerieIntervalTicksModeEnum::STARTSTOPTIME);
26a23052   Benjamin Renard   Add Interval Tick...
959
960
				break;
			case 'start-time':
95ab3cf6   Menouard AZIB   Prise en compte d...
961
			default:
4f9a8e36   Benjamin Renard   Min/Max value def...
962
				$intervalTickNode->setMode(RequestOutputPlotSerieIntervalTicksModeEnum::STARTTIME);
26a23052   Benjamin Renard   Add Interval Tick...
963
		}
95ab3cf6   Menouard AZIB   Prise en compte d...
964

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

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

26a23052   Benjamin Renard   Add Interval Tick...
971
972
973
974
		//Font
		if ($serieData->{'serie-intervaltick-font-activated'})
			$this->unmarshallFont($serieData, 'serie-intervaltick-font', $intervalTickNode->getFont());
	}
95ab3cf6   Menouard AZIB   Prise en compte d...
975

26a23052   Benjamin Renard   Add Interval Tick...
976
977
978
	protected function unmarshallErrorBar($serieData, $requestParamsNode, $errorBarNode)
	{
		//Type
95ab3cf6   Menouard AZIB   Prise en compte d...
979
		switch ($serieData->{'serie-errorbar-type'}) {
26a23052   Benjamin Renard   Add Interval Tick...
980
981
			case 'min-max':
				$errorBarTypeNode = $errorBarNode->getBarByType(RequestOutputPlotYSerieErrorBarTypeEnum::MINMAX);
95ab3cf6   Menouard AZIB   Prise en compte d...
982

bf27ba04   Benjamin Renard   Add templated par...
983
				$minParamInfo = $this->paramManager->addExistingParam($serieData->{'serie-errorbar-minparam'}, $this->paramsData);
26a23052   Benjamin Renard   Add Interval Tick...
984
985
986
987
988
989
990
991
992
				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...
993

bf27ba04   Benjamin Renard   Add templated par...
994
				$maxParamInfo = $this->paramManager->addExistingParam($serieData->{'serie-errorbar-maxparam'}, $this->paramsData);
26a23052   Benjamin Renard   Add Interval Tick...
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
				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...
1007

bf27ba04   Benjamin Renard   Add templated par...
1008
				$deltaParamInfo = $this->paramManager->addExistingParam($serieData->{'serie-errorbar-deltaparam'}, $this->paramsData);
26a23052   Benjamin Renard   Add Interval Tick...
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
				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...
1019
			default:
26a23052   Benjamin Renard   Add Interval Tick...
1020
1021
				throw new Exception('Unknown error bar type.');
		}
95ab3cf6   Menouard AZIB   Prise en compte d...
1022

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

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

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

26a23052   Benjamin Renard   Add Interval Tick...
1034
1035
1036
1037
1038
1039
1040
1041
1042
		//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...
1043

26a23052   Benjamin Renard   Add Interval Tick...
1044
1045
	protected function unmarshallSpectro($paramDrawingData, $plotNode, $paramNode, $indexes)
	{
95ab3cf6   Menouard AZIB   Prise en compte d...
1046
1047
1048
		$spectroNode = $paramNode->addSpectro(
			$paramDrawingData->{'spectro-yaxis'},
			empty($paramDrawingData->{'spectro-resolution'}) ? NULL : $paramDrawingData->{'spectro-resolution'},
85c7d958   Erdogan Furkan   Integration part ...
1049
1050
			isset($paramDrawingData->{'spectro-usetfcat'}) ? $paramDrawingData->{'spectro-usetfcat'} : false,
			(isset($paramDrawingData->{'spectro-tfcat-file'}) && isset($paramDrawingData->{'spectro-usetfcat'})) ? $paramDrawingData->{'spectro-tfcat-file'} : NULL,
95ab3cf6   Menouard AZIB   Prise en compte d...
1051
1052
1053
1054
1055
1056
1057
			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},
7c2e29e9   Myriam Bouchemit   Fix
1058
			!isset($paramDrawingData->{REQUESTOUTPUTPLOTSPECTRO_BGS_DIM}) || ($paramDrawingData->{REQUESTOUTPUTPLOTSPECTRO_BGS_DIM} == "") ? NULL : $paramDrawingData->{REQUESTOUTPUTPLOTSPECTRO_BGS_DIM}
95ab3cf6   Menouard AZIB   Prise en compte d...
1059
		);
26a23052   Benjamin Renard   Add Interval Tick...
1060
	}
27317777   Menouard AZIB   J'ai ajouté la fo...
1061
	protected function unmarshallSauvaud($paramDrawingData, $plotNode, $paramNode, $indexes)
3dcf7710   Hacene SI HADJ MOHAND   us ok
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
	{
		$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},
27317777   Menouard AZIB   J'ai ajouté la fo...
1073
1074
			!isset($paramDrawingData->{REQUESTOUTPUTPLOTSPECTRO_BGS_DIM}) ? NULL : $paramDrawingData->{REQUESTOUTPUTPLOTSPECTRO_BGS_DIM},
			$paramDrawingData->{'right_dim'}
3dcf7710   Hacene SI HADJ MOHAND   us ok
1075
1076
		);
	}
95ab3cf6   Menouard AZIB   Prise en compte d...
1077

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

26a23052   Benjamin Renard   Add Interval Tick...
1084
1085
	protected function unmarshallStatusBar($paramDrawingData, $paramNode, $indexes)
	{
25a38537   Erdogan Furkan   7616 - Adding col...
1086
1087
1088
1089
1090
		if ($paramDrawingData->{'statusbar-color'} == "none") {
			$color = NULL;
		} else {
			$color = $this->hexColor2KernelColor($paramDrawingData->{'statusbar-color'});
		}
26a23052   Benjamin Renard   Add Interval Tick...
1091
		if (count($indexes) == 0)
25a38537   Erdogan Furkan   7616 - Adding col...
1092
1093
1094
1095
1096
			$paramNode->addStatusBar(-1, $color);
		else {
			foreach ($indexes as $index)
				$paramNode->addStatusBar($index, $color);
		}
26a23052   Benjamin Renard   Add Interval Tick...
1097
	}
044a9305   Benjamin Renard   Add intervals dra...
1098
1099
1100

	protected function unmarshallIntervals($paramDrawingData, $paramNode)
	{
25a38537   Erdogan Furkan   7616 - Adding col...
1101
1102
1103
1104
1105
		if ($paramDrawingData->{'intervals-color'} == "none") {
			$color = NULL;
		} else {
			$color = $this->hexColor2KernelColor($paramDrawingData->{'intervals-color'});
		}
fe1a8ddd   Erdogan Furkan   Modifications for...
1106
1107

		$intervalsNode = $paramNode->addIntervals($color);
fe1a8ddd   Erdogan Furkan   Modifications for...
1108

c54497a2   Benjamin Renard   Give the possibil...
1109
1110
1111
1112
1113
		if ($paramDrawingData->{'legend-text-activated'}) {
			$textLegendNode = $intervalsNode->addTextLegend();

			$this->unmarshallTextLegend($paramDrawingData, $textLegendNode);
		}
044a9305   Benjamin Renard   Add intervals dra...
1114
	}
95ab3cf6   Menouard AZIB   Prise en compte d...
1115

26a23052   Benjamin Renard   Add Interval Tick...
1116
1117
1118
1119
1120
1121
1122
	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...
1123

26a23052   Benjamin Renard   Add Interval Tick...
1124
1125
1126
1127
1128
1129
1130
	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...
1131

26a23052   Benjamin Renard   Add Interval Tick...
1132
1133
1134
1135
1136
1137
1138
	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...
1139

26a23052   Benjamin Renard   Add Interval Tick...
1140
1141
1142
	protected function unmarshallParamsLegend($paramsLegendData, $paramsLegendNode)
	{
		//Legend type
95ab3cf6   Menouard AZIB   Prise en compte d...
1143
1144
		switch ($paramsLegendData->{'legend-series-type'}) {
			case 'text-line-symbol':
26a23052   Benjamin Renard   Add Interval Tick...
1145
1146
				$paramsLegendNode->setType(RequestOutputPlotParamsLegendTypeEnum::TEXTLINESYMBOL);
				break;
95ab3cf6   Menouard AZIB   Prise en compte d...
1147
1148
			case 'text-only':
			default:
26a23052   Benjamin Renard   Add Interval Tick...
1149
1150
				$paramsLegendNode->setType(RequestOutputPlotParamsLegendTypeEnum::TEXTONLY);
		}
95ab3cf6   Menouard AZIB   Prise en compte d...
1151

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

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

26a23052   Benjamin Renard   Add Interval Tick...
1158
		//Interval info type
95ab3cf6   Menouard AZIB   Prise en compte d...
1159
1160
		switch ($paramsLegendData->{'legend-series-intervalinfo-type'}) {
			case 'start-stop':
26a23052   Benjamin Renard   Add Interval Tick...
1161
1162
				$paramsLegendNode->setIntervalInfoType(RequestOutputPlotParamsLegendIntervalInfoTypeEnum::STARTSTOP);
				break;
95ab3cf6   Menouard AZIB   Prise en compte d...
1163
1164
			case 'index':
			default:
26a23052   Benjamin Renard   Add Interval Tick...
1165
1166
				$paramsLegendNode->setIntervalInfoType(RequestOutputPlotParamsLegendIntervalInfoTypeEnum::INDEX);
		}
95ab3cf6   Menouard AZIB   Prise en compte d...
1167

26a23052   Benjamin Renard   Add Interval Tick...
1168
		//Position
95ab3cf6   Menouard AZIB   Prise en compte d...
1169
1170
		switch ($paramsLegendData->{'legend-series-position'}) {
			case 'inside':
26a23052   Benjamin Renard   Add Interval Tick...
1171
1172
				$paramsLegendNode->setPosition(RequestOutputPlotParamsLegendPositionEnum::INSIDE);
				break;
95ab3cf6   Menouard AZIB   Prise en compte d...
1173
1174
			case 'outside':
			default:
26a23052   Benjamin Renard   Add Interval Tick...
1175
1176
				$paramsLegendNode->setPosition(RequestOutputPlotParamsLegendPositionEnum::OUTSIDE);
		}
95ab3cf6   Menouard AZIB   Prise en compte d...
1177

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

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

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

26a23052   Benjamin Renard   Add Interval Tick...
1187
1188
1189
1190
		//Font
		if ($paramsLegendData->{'legend-series-font-activated'})
			$this->unmarshallFont($paramsLegendData, 'legend-series-font', $paramsLegendNode->getFont());
	}
95ab3cf6   Menouard AZIB   Prise en compte d...
1191

fe1a8ddd   Erdogan Furkan   Modifications for...
1192
	protected function unmarshallTextLegend($textLegendData, $parentNode)
26a23052   Benjamin Renard   Add Interval Tick...
1193
	{
95ab3cf6   Menouard AZIB   Prise en compte d...
1194

26a23052   Benjamin Renard   Add Interval Tick...
1195
		//Legend text
fe1a8ddd   Erdogan Furkan   Modifications for...
1196
		$parentNode->setText($textLegendData->{'legend-text-value'});
95ab3cf6   Menouard AZIB   Prise en compte d...
1197

26a23052   Benjamin Renard   Add Interval Tick...
1198
		//Legend position
95ab3cf6   Menouard AZIB   Prise en compte d...
1199
1200
		switch ($textLegendData->{'legend-text-position'}) {
			case 'top':
fe1a8ddd   Erdogan Furkan   Modifications for...
1201
				$parentNode->setPosition(RequestOutputPlotTextLegendPositionEnum::TOP);
26a23052   Benjamin Renard   Add Interval Tick...
1202
				break;
95ab3cf6   Menouard AZIB   Prise en compte d...
1203
			case 'bottom':
fe1a8ddd   Erdogan Furkan   Modifications for...
1204
				$parentNode->setPosition(RequestOutputPlotTextLegendPositionEnum::BOTTOM);
26a23052   Benjamin Renard   Add Interval Tick...
1205
				break;
95ab3cf6   Menouard AZIB   Prise en compte d...
1206
			case 'left':
fe1a8ddd   Erdogan Furkan   Modifications for...
1207
				$parentNode->setPosition(RequestOutputPlotTextLegendPositionEnum::LEFT);
26a23052   Benjamin Renard   Add Interval Tick...
1208
				break;
95ab3cf6   Menouard AZIB   Prise en compte d...
1209
1210
			case 'right':
			default:
fe1a8ddd   Erdogan Furkan   Modifications for...
1211
				$parentNode->setPosition(RequestOutputPlotTextLegendPositionEnum::RIGHT);
26a23052   Benjamin Renard   Add Interval Tick...
1212
		}
95ab3cf6   Menouard AZIB   Prise en compte d...
1213

26a23052   Benjamin Renard   Add Interval Tick...
1214
		//Legend text color
fe1a8ddd   Erdogan Furkan   Modifications for...
1215
		$parentNode->setColor($this->hexColor2KernelColor($textLegendData->{'legend-text-color'}));
95ab3cf6   Menouard AZIB   Prise en compte d...
1216

26a23052   Benjamin Renard   Add Interval Tick...
1217
		//Font
fe1a8ddd   Erdogan Furkan   Modifications for...
1218
1219
1220
		if ($textLegendData->{'legend-text-font-activated'}) {
			$this->unmarshallFont($textLegendData, 'legend-text-font', $parentNode->getFont());
		}
26a23052   Benjamin Renard   Add Interval Tick...
1221
	}
95ab3cf6   Menouard AZIB   Prise en compte d...
1222
1223

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

26a23052   Benjamin Renard   Add Interval Tick...
1228
		//Constant value
95ab3cf6   Menouard AZIB   Prise en compte d...
1229
1230
		switch ($axisNode->getName()) {
			case REQUESTOUTPUTPLOTTIMEAXIS_NAME:
26a23052   Benjamin Renard   Add Interval Tick...
1231
				date_default_timezone_set('UTC');
74fd500a   Hacene SI HADJ MOHAND   us #9874 ms zoo...
1232
				$time = CommonClass::strTimeToDDTime($constantData->{'constant-time-value'});
26a23052   Benjamin Renard   Add Interval Tick...
1233
1234
				$constantNode->setConstantValue($time);
				break;
95ab3cf6   Menouard AZIB   Prise en compte d...
1235
			default:
26a23052   Benjamin Renard   Add Interval Tick...
1236
1237
				$constantNode->setConstantValue($constantData->{'constant-float-value'});
		}
95ab3cf6   Menouard AZIB   Prise en compte d...
1238

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

26a23052   Benjamin Renard   Add Interval Tick...
1243
1244
1245
1246
1247
1248
1249
	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...
1250

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

26a23052   Benjamin Renard   Add Interval Tick...
1255
		$textNode->setText($textData->{'text-value'});
95ab3cf6   Menouard AZIB   Prise en compte d...
1256
1257
1258

		switch ($textData->{'text-y-axis'}) {
			case 'y-right':
26a23052   Benjamin Renard   Add Interval Tick...
1259
1260
				$textNode->setYAxis('y-right');
				break;
95ab3cf6   Menouard AZIB   Prise en compte d...
1261
			case 'y-left':
26a23052   Benjamin Renard   Add Interval Tick...
1262
1263
1264
				$textNode->setYAxis('y-left');
				break;
		}
95ab3cf6   Menouard AZIB   Prise en compte d...
1265
1266

		if ($isTimePlot && !$textData->{'text-x-relative'}) {
26a23052   Benjamin Renard   Add Interval Tick...
1267
			date_default_timezone_set('UTC');
74fd500a   Hacene SI HADJ MOHAND   us #9874 ms zoo...
1268
			$time = CommonClass::strTimeToDDTime($textData->{'text-x-timevalue'});
26a23052   Benjamin Renard   Add Interval Tick...
1269
			$textNode->setX($time);
95ab3cf6   Menouard AZIB   Prise en compte d...
1270
1271
		} else if ($textData->{'text-x-relative'})
			$textNode->setX(($textData->{'text-x-floatvalue'} * 100) . "%");
26a23052   Benjamin Renard   Add Interval Tick...
1272
1273
		else
			$textNode->setX($textData->{'text-x-floatvalue'});
95ab3cf6   Menouard AZIB   Prise en compte d...
1274

26a23052   Benjamin Renard   Add Interval Tick...
1275
		if ($textData->{'text-y-relative'})
95ab3cf6   Menouard AZIB   Prise en compte d...
1276
			$textNode->setY(($textData->{'text-y-value'} * 100) . "%");
26a23052   Benjamin Renard   Add Interval Tick...
1277
1278
		else
			$textNode->setY($textData->{'text-y-value'});
95ab3cf6   Menouard AZIB   Prise en compte d...
1279

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

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

		switch ($textData->{'text-align'}) {
			case 'center':
26a23052   Benjamin Renard   Add Interval Tick...
1286
1287
				$textNode->setAlign(RequestOutputPlotTextAlign::CENTER);
				break;
95ab3cf6   Menouard AZIB   Prise en compte d...
1288
			case 'right':
26a23052   Benjamin Renard   Add Interval Tick...
1289
1290
				$textNode->setAlign(RequestOutputPlotTextAlign::RIGHT);
				break;
95ab3cf6   Menouard AZIB   Prise en compte d...
1291
			case 'left':
26a23052   Benjamin Renard   Add Interval Tick...
1292
1293
1294
			default:
				$textNode->setAlign(RequestOutputPlotTextAlign::LEFT);
		}
95ab3cf6   Menouard AZIB   Prise en compte d...
1295

26a23052   Benjamin Renard   Add Interval Tick...
1296
1297
1298
1299
		//Font
		if ($textData->{'text-font-activated'})
			$this->unmarshallFont($textData, 'text-font', $textNode->getFont());
	}
95ab3cf6   Menouard AZIB   Prise en compte d...
1300

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

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

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

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

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

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

26a23052   Benjamin Renard   Add Interval Tick...
1319
1320
	protected function unmarshallFills($panelData, $fillsNode)
	{
95ab3cf6   Menouard AZIB   Prise en compte d...
1321
		foreach ($panelData->{'fills'} as $fillData) {
26a23052   Benjamin Renard   Add Interval Tick...
1322
			//Serie / Constant
95ab3cf6   Menouard AZIB   Prise en compte d...
1323
			if ($fillData->{'fill-type'} == 'serie-constant') {
26a23052   Benjamin Renard   Add Interval Tick...
1324
1325
1326
1327
1328
1329
1330
1331
1332
				$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...
1333
1334

		foreach ($panelData->{'fills'} as $fillData) {
26a23052   Benjamin Renard   Add Interval Tick...
1335
			//Serie / Serie
95ab3cf6   Menouard AZIB   Prise en compte d...
1336
			if ($fillData->{'fill-type'} == 'serie-serie') {
26a23052   Benjamin Renard   Add Interval Tick...
1337
1338
1339
1340
1341
1342
1343
1344
				$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...
1345
		}
26a23052   Benjamin Renard   Add Interval Tick...
1346
	}
95ab3cf6   Menouard AZIB   Prise en compte d...
1347

26a23052   Benjamin Renard   Add Interval Tick...
1348
1349
	protected function unmarshallTitle($inputData, $keyPrefix, $titleNode)
	{
27317777   Menouard AZIB   J'ai ajouté la fo...
1350
1351
1352
1353
1354
1355
		if ($inputData->{$keyPrefix . '-text'} != '') {
			$titleNode->setText($inputData->{$keyPrefix . '-text'});
		}

		switch ($inputData->{$keyPrefix . '-position'}) {
			case 'top':
d62f9945   Benjamin Renard   Improve instant c...
1356
1357
				$titleNode->setPosition(RequestOutputPlotTitlePosition::TOP);
				break;
27317777   Menouard AZIB   J'ai ajouté la fo...
1358
			case 'bottom':
d62f9945   Benjamin Renard   Improve instant c...
1359
1360
1361
				$titleNode->setPosition(RequestOutputPlotTitlePosition::BOTTOM);
				break;
		}
27317777   Menouard AZIB   J'ai ajouté la fo...
1362
1363
1364

		switch ($inputData->{$keyPrefix . '-alignment'}) {
			case 'center':
d62f9945   Benjamin Renard   Improve instant c...
1365
1366
				$titleNode->setAlign(RequestOutputPlotTitleAlign::CENTER);
				break;
27317777   Menouard AZIB   J'ai ajouté la fo...
1367
			case 'left':
d62f9945   Benjamin Renard   Improve instant c...
1368
1369
				$titleNode->setAlign(RequestOutputPlotTitleAlign::LEFT);
				break;
27317777   Menouard AZIB   J'ai ajouté la fo...
1370
			case 'right':
d62f9945   Benjamin Renard   Improve instant c...
1371
1372
				$titleNode->setAlign(RequestOutputPlotTitleAlign::RIGHT);
				break;
26a23052   Benjamin Renard   Add Interval Tick...
1373
		}
27317777   Menouard AZIB   J'ai ajouté la fo...
1374
1375
1376

		if ($inputData->{$keyPrefix . '-color'} != '')
			$titleNode->setColor($this->hexColor2KernelColor($inputData->{$keyPrefix . '-color'}));
d62f9945   Benjamin Renard   Improve instant c...
1377
1378

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

26a23052   Benjamin Renard   Add Interval Tick...
1381
1382
	protected function unmarshallLabel($inputData, $keyPrefix, $labelNode)
	{
95ab3cf6   Menouard AZIB   Prise en compte d...
1383
1384
1385
1386
		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 ...
1387
				$labelNode->setFontWeight("bold");
26a23052   Benjamin Renard   Add Interval Tick...
1388
			}
95ab3cf6   Menouard AZIB   Prise en compte d...
1389
1390
			if ($inputData->{$keyPrefix . '-font-italic'}) {
				$labelNode->setFontStyle("italic");
26a23052   Benjamin Renard   Add Interval Tick...
1391
			}
26a23052   Benjamin Renard   Add Interval Tick...
1392
		}
26a23052   Benjamin Renard   Add Interval Tick...
1393
	}
95ab3cf6   Menouard AZIB   Prise en compte d...
1394

26a23052   Benjamin Renard   Add Interval Tick...
1395
1396
	protected function unmarshallFont($inputData, $keyPrefix, $fontNode)
	{
95ab3cf6   Menouard AZIB   Prise en compte d...
1397
1398
1399
1400
1401
		if ($inputData->{$keyPrefix . '-activated'}) {
			$fontNode->setFontName($inputData->{$keyPrefix . '-name'});
			$fontNode->setSize($inputData->{$keyPrefix . '-size'});

			if ($inputData->{$keyPrefix . '-italic'})
26a23052   Benjamin Renard   Add Interval Tick...
1402
1403
1404
				$fontNode->setStyle(RequestOutputPlotFontStyle::ITALIC);
			else
				$fontNode->setStyle(RequestOutputPlotFontStyle::UPRIGHT);
95ab3cf6   Menouard AZIB   Prise en compte d...
1405
1406

			if ($inputData->{$keyPrefix . '-bold'})
26a23052   Benjamin Renard   Add Interval Tick...
1407
1408
1409
1410
1411
				$fontNode->setWeight(RequestOutputPlotFontWeight::BOLD);
			else
				$fontNode->setWeight(RequestOutputPlotFontWeight::MEDIUM);
		}
	}
95ab3cf6   Menouard AZIB   Prise en compte d...
1412

26a23052   Benjamin Renard   Add Interval Tick...
1413
1414
	protected function unmarshallCurve($inputData, $keyPrefix, $curveNode)
	{
95ab3cf6   Menouard AZIB   Prise en compte d...
1415
1416
1417
		switch ($inputData->{$keyPrefix . '-style'}) {

			case 'dot':
26a23052   Benjamin Renard   Add Interval Tick...
1418
1419
				$curveNode->setStyle(RequestOutputPlotCurveStyleEnum::DOT);
				break;
95ab3cf6   Menouard AZIB   Prise en compte d...
1420
			case 'long-spaced-dot':
26a23052   Benjamin Renard   Add Interval Tick...
1421
1422
				$curveNode->setStyle(RequestOutputPlotCurveStyleEnum::LONGSPACEDDOT);
				break;
95ab3cf6   Menouard AZIB   Prise en compte d...
1423
			case 'long-short-dot':
26a23052   Benjamin Renard   Add Interval Tick...
1424
1425
				$curveNode->setStyle(RequestOutputPlotCurveStyleEnum::LONGSHORTDOT);
				break;
95ab3cf6   Menouard AZIB   Prise en compte d...
1426
1427
			case 'plain':
			default:
02abc780   Benjamin Renard   Support request f...
1428
1429
				$curveNode->setStyle(RequestOutputPlotCurveStyleEnum::PLAIN);
				break;
26a23052   Benjamin Renard   Add Interval Tick...
1430
		}
95ab3cf6   Menouard AZIB   Prise en compte d...
1431
1432
1433
1434
1435
1436

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

26a23052   Benjamin Renard   Add Interval Tick...
1439
1440
1441
	protected function unmarshallLine($inputData, $keyPrefix, $lineNode, $lineType)
	{
		$lineNode->setType($lineType);
95ab3cf6   Menouard AZIB   Prise en compte d...
1442
		$this->unmarshallCurve($inputData, $keyPrefix . "-lines", $lineNode);
26a23052   Benjamin Renard   Add Interval Tick...
1443
	}
95ab3cf6   Menouard AZIB   Prise en compte d...
1444

26a23052   Benjamin Renard   Add Interval Tick...
1445
1446
	protected function unmarshallSymbol($inputData, $keyPrefix, $symbolNode)
	{
95ab3cf6   Menouard AZIB   Prise en compte d...
1447
1448
		switch ($inputData->{$keyPrefix . '-type'}) {
			case 'dot':
26a23052   Benjamin Renard   Add Interval Tick...
1449
1450
				$symbolNode->setType(RequestOutputPlotSymbolTypeEnum::DOT);
				break;
95ab3cf6   Menouard AZIB   Prise en compte d...
1451
			case 'plus':
26a23052   Benjamin Renard   Add Interval Tick...
1452
1453
				$symbolNode->setType(RequestOutputPlotSymbolTypeEnum::PLUS);
				break;
95ab3cf6   Menouard AZIB   Prise en compte d...
1454
			case 'wildcard':
26a23052   Benjamin Renard   Add Interval Tick...
1455
1456
				$symbolNode->setType(RequestOutputPlotSymbolTypeEnum::WILDCARD);
				break;
95ab3cf6   Menouard AZIB   Prise en compte d...
1457
			case 'circle':
26a23052   Benjamin Renard   Add Interval Tick...
1458
1459
				$symbolNode->setType(RequestOutputPlotSymbolTypeEnum::CIRCLE);
				break;
95ab3cf6   Menouard AZIB   Prise en compte d...
1460
			case 'crux':
26a23052   Benjamin Renard   Add Interval Tick...
1461
1462
				$symbolNode->setType(RequestOutputPlotSymbolTypeEnum::CRUX);
				break;
95ab3cf6   Menouard AZIB   Prise en compte d...
1463
			case 'square':
26a23052   Benjamin Renard   Add Interval Tick...
1464
1465
				$symbolNode->setType(RequestOutputPlotSymbolTypeEnum::SQUARE);
				break;
95ab3cf6   Menouard AZIB   Prise en compte d...
1466
			case 'triangle':
26a23052   Benjamin Renard   Add Interval Tick...
1467
1468
				$symbolNode->setType(RequestOutputPlotSymbolTypeEnum::TRIANGLE);
				break;
95ab3cf6   Menouard AZIB   Prise en compte d...
1469
			case 'crux-in-circle':
26a23052   Benjamin Renard   Add Interval Tick...
1470
1471
				$symbolNode->setType(RequestOutputPlotSymbolTypeEnum::CRUXINCIRCLE);
				break;
95ab3cf6   Menouard AZIB   Prise en compte d...
1472
			case 'dot-in-circle':
26a23052   Benjamin Renard   Add Interval Tick...
1473
1474
				$symbolNode->setType(RequestOutputPlotSymbolTypeEnum::DOTINCIRCLE);
				break;
95ab3cf6   Menouard AZIB   Prise en compte d...
1475
			case 'diamond':
26a23052   Benjamin Renard   Add Interval Tick...
1476
1477
				$symbolNode->setType(RequestOutputPlotSymbolTypeEnum::DIAMOND);
				break;
95ab3cf6   Menouard AZIB   Prise en compte d...
1478
			case 'star':
26a23052   Benjamin Renard   Add Interval Tick...
1479
1480
				$symbolNode->setType(RequestOutputPlotSymbolTypeEnum::STAR);
				break;
95ab3cf6   Menouard AZIB   Prise en compte d...
1481
			case 'david-star':
26a23052   Benjamin Renard   Add Interval Tick...
1482
1483
				$symbolNode->setType(RequestOutputPlotSymbolTypeEnum::DAVIDSTAR);
				break;
95ab3cf6   Menouard AZIB   Prise en compte d...
1484
			case 'full-square':
26a23052   Benjamin Renard   Add Interval Tick...
1485
1486
				$symbolNode->setType(RequestOutputPlotSymbolTypeEnum::FULLSQUARE);
				break;
95ab3cf6   Menouard AZIB   Prise en compte d...
1487
			case 'full-circle':
26a23052   Benjamin Renard   Add Interval Tick...
1488
1489
				$symbolNode->setType(RequestOutputPlotSymbolTypeEnum::FULLCIRCLE);
				break;
95ab3cf6   Menouard AZIB   Prise en compte d...
1490
			case 'full-star':
26a23052   Benjamin Renard   Add Interval Tick...
1491
1492
				$symbolNode->setType(RequestOutputPlotSymbolTypeEnum::FULLSTAR);
				break;
95ab3cf6   Menouard AZIB   Prise en compte d...
1493
			default:
26a23052   Benjamin Renard   Add Interval Tick...
1494
1495
				throw new Exception('Symbol type not implemented.');
		}
95ab3cf6   Menouard AZIB   Prise en compte d...
1496
1497
1498
1499
1500

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

		if ($inputData->{$keyPrefix . '-color'} != 'auto')
			$symbolNode->setColor($this->hexColor2KernelColor($inputData->{$keyPrefix . '-color'}));
26a23052   Benjamin Renard   Add Interval Tick...
1501
1502
1503
1504
1505
1506
1507
	}

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

26a23052   Benjamin Renard   Add Interval Tick...
1512
1513
			return $commonRes;
		}
95ab3cf6   Menouard AZIB   Prise en compte d...
1514

26a23052   Benjamin Renard   Add Interval Tick...
1515
		//Interactive request
22521f1c   Benjamin Renard   First commit
1516
1517
		if (!$data->getSuccess())
			return array(
95ab3cf6   Menouard AZIB   Prise en compte d...
1518
1519
1520
1521
1522
1523
1524
				'success' => false,
				'message' => $data->getLastErrorMessage()
			);

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

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

26a23052   Benjamin Renard   Add Interval Tick...
1529
1530
					$result[] = array(
						"id" => $key,
70e82c1f   Benjamin Renard   Fix doPlot
1531
						"title" => $this->interactivePlotTitle[$key],
05da1b4d   Benjamin Renard   Draw instant plot...
1532
						"preview" => $this->interactivePreview,
26a23052   Benjamin Renard   Add Interval Tick...
1533
						"isInterval" => $this->interactiveTimeSelectionState[$key],
70e82c1f   Benjamin Renard   Fix doPlot
1534
						"index" => $this->interactivePlotIndex[$key],
26a23052   Benjamin Renard   Add Interval Tick...
1535
						"ttFileIndex" => $this->interactiveCrtTTFileIndex,
95ab3cf6   Menouard AZIB   Prise en compte d...
1536
						"context" => IHMPlotContextFileClass::parse($this->getWorkingPath() . $contextResult),
ba82a624   Benjamin Renard   Get kernel execut...
1537
1538
						"plot" => $waitingResult,
						"exectime" => $data->getExecTime(),
ec574794   Benjamin Renard   Implements multip...
1539
						"multiplot" => $this->isMultiPlot,
26a23052   Benjamin Renard   Add Interval Tick...
1540
1541
					);
				}
95ab3cf6   Menouard AZIB   Prise en compte d...
1542

26a23052   Benjamin Renard   Add Interval Tick...
1543
1544
1545
1546
1547
1548
				return array(
					'success'     => true,
					'id'          => $data->getId(),
					'folder'      => $this->getWorkingDirName(),
					'result'      => $result
				);
95ab3cf6   Menouard AZIB   Prise en compte d...
1549
			case ProcessStatusEnumClass::KILLED:
26a23052   Benjamin Renard   Add Interval Tick...
1550
				return array(
95ab3cf6   Menouard AZIB   Prise en compte d...
1551
1552
1553
1554
					'success'     => true,
					'killed'      => true
				);
			default:
e4eba677   Benjamin Renard   Get error message...
1555
				$errorMsg = $data->getErrorMsg();
22521f1c   Benjamin Renard   First commit
1556
				return array(
95ab3cf6   Menouard AZIB   Prise en compte d...
1557
1558
1559
					'success' => false,
					'message'   => 'Request processing error' . (!empty($errorMsg) ? "<br>(" . $errorMsg . ")" : "")
				);
26a23052   Benjamin Renard   Add Interval Tick...
1560
1561
		}
	}
95ab3cf6   Menouard AZIB   Prise en compte d...
1562
1563
1564

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

95ab3cf6   Menouard AZIB   Prise en compte d...
1567
1568
1569
		$r = hexdec(substr($hex, 0, 2));
		$g = hexdec(substr($hex, 2, 2));
		$b = hexdec(substr($hex, 4, 2));
26a23052   Benjamin Renard   Add Interval Tick...
1570

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

ec574794   Benjamin Renard   Implements multip...
1574
	protected function saveIHMRequest($interactiveId, $input)
26a23052   Benjamin Renard   Add Interval Tick...
1575
	{
95ab3cf6   Menouard AZIB   Prise en compte d...
1576
		$path = $this->getWorkingPath() . "ihm.request." . $interactiveId;
26a23052   Benjamin Renard   Add Interval Tick...
1577
		if (!is_dir($this->getWorkingPath()))
95ab3cf6   Menouard AZIB   Prise en compte d...
1578
			mkdir($this->getWorkingPath(), 0777);
22521f1c   Benjamin Renard   First commit
1579
1580
		$file = fopen($path, 'w');
		fwrite($file, json_encode($input));
26a23052   Benjamin Renard   Add Interval Tick...
1581
1582
		fclose($file);
	}
95ab3cf6   Menouard AZIB   Prise en compte d...
1583

ec574794   Benjamin Renard   Implements multip...
1584
	protected function loadIHMRequest($interactiveId)
26a23052   Benjamin Renard   Add Interval Tick...
1585
	{
95ab3cf6   Menouard AZIB   Prise en compte d...
1586
		$path = $this->getWorkingPath() . "ihm.request." . $interactiveId;
22521f1c   Benjamin Renard   First commit
1587
		if (!file_exists($path))
26a23052   Benjamin Renard   Add Interval Tick...
1588
1589
1590
			return NULL;
		return json_decode(file_get_contents($path));
	}
a9d86eaa   Benjamin Renard   Fix zoom / unzoom
1591

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

a9d86eaa   Benjamin Renard   Fix zoom / unzoom
1593
1594
1595

	private function loadZoomList($interactiveId)
	{
95ab3cf6   Menouard AZIB   Prise en compte d...
1596
		$path = $this->getWorkingPath() . "zoom.list." . $interactiveId;
a9d86eaa   Benjamin Renard   Fix zoom / unzoom
1597
1598
1599
1600
1601
1602
1603
		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...
1604
		$path = $this->getWorkingPath() . "zoom.list." . $interactiveId;
a9d86eaa   Benjamin Renard   Fix zoom / unzoom
1605
		if (!is_dir($this->getWorkingPath()))
95ab3cf6   Menouard AZIB   Prise en compte d...
1606
			mkdir($this->getWorkingPath(), 0777);
a9d86eaa   Benjamin Renard   Fix zoom / unzoom
1607
1608
1609
1610
		$file = fopen($path, 'w');
		fwrite($file, json_encode($zoomList));
		fclose($file);
	}
95ab3cf6   Menouard AZIB   Prise en compte d...
1611

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

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

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

		switch ($actionInput->{'action'}) {
			case 'zoom':
e8cefd97   Benjamin Renard   Interactive attac...
1623
				return $this->unmarshallZoom($actionInput, $plotInput);
95ab3cf6   Menouard AZIB   Prise en compte d...
1624
1625
			case 'forward':
			case 'halfforward':
2366956c   Erdogan Furkan   10312 - Navigatio...
1626
			case 'quarterforward':
95ab3cf6   Menouard AZIB   Prise en compte d...
1627
1628
			case 'backward':
			case 'halfbackward':
2366956c   Erdogan Furkan   10312 - Navigatio...
1629
			case 'quarterbackward':
95ab3cf6   Menouard AZIB   Prise en compte d...
1630
1631
			case 'extend':
			case 'shift':
e8cefd97   Benjamin Renard   Interactive attac...
1632
				return $this->unmarshallNavigation($actionInput, $plotInput);
95ab3cf6   Menouard AZIB   Prise en compte d...
1633
			case 'goto':
e8cefd97   Benjamin Renard   Interactive attac...
1634
				return $this->unmarshallTTGoto($actionInput, $plotInput);
95ab3cf6   Menouard AZIB   Prise en compte d...
1635
			case 'instant':
05da1b4d   Benjamin Renard   Draw instant plot...
1636
				return $this->unmarshallInstant($actionInput, $plotInput);
95ab3cf6   Menouard AZIB   Prise en compte d...
1637
			case 'undozoom':
d3c3608d   Benjamin Renard   Add undo zoom
1638
				return $this->unmarshallUndoZoom($actionInput, $plotInput);
ff8f5cff   Menouard AZIB   Une petite refact...
1639
			case RequestOutPutPlotElementPlotFunctionNodeClass::REQUESTOUTPUTPLOTELEMENT_PLOTFUNCTION_NAME:
27317777   Menouard AZIB   J'ai ajouté la fo...
1640
				return $this->unmarshallPlotFunction($actionInput, $plotInput);
95ab3cf6   Menouard AZIB   Prise en compte d...
1641
			default:
26a23052   Benjamin Renard   Add Interval Tick...
1642
1643
1644
				throw new Exception('Interactive action not implemented.');
		}
	}
95ab3cf6   Menouard AZIB   Prise en compte d...
1645

d3c3608d   Benjamin Renard   Add undo zoom
1646
1647
1648
1649
	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...
1650

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

		if (!isset($zoomList)) {
d3c3608d   Benjamin Renard   Add undo zoom
1654
			//Init zoom list
95ab3cf6   Menouard AZIB   Prise en compte d...
1655
			$zoomList = (object)array(
a9d86eaa   Benjamin Renard   Fix zoom / unzoom
1656
				'times' => array(),
95ab3cf6   Menouard AZIB   Prise en compte d...
1657
				'panels' => (object)array()
d3c3608d   Benjamin Renard   Add undo zoom
1658
1659
			);
		}
95ab3cf6   Menouard AZIB   Prise en compte d...
1660
1661

		if ($input->{'axeId'} == 'timeAxis') {
d3c3608d   Benjamin Renard   Add undo zoom
1662
			if ($isInterval)
95ab3cf6   Menouard AZIB   Prise en compte d...
1663
				array_push($zoomList->times, (object)array(
d3c3608d   Benjamin Renard   Add undo zoom
1664
1665
1666
1667
1668
					'isInterval' => true,
					'min' => $minOrFileIndex,
					'max'  => $maxOrIntervalIndex
				));
			else
95ab3cf6   Menouard AZIB   Prise en compte d...
1669
1670
1671
1672
				array_push($zoomList->times, (object)array(
					'isInterval' => false,
					'ttFileIndex' => $minOrFileIndex,
					'intIndex'  => $maxOrIntervalIndex
d3c3608d   Benjamin Renard   Add undo zoom
1673
				));
95ab3cf6   Menouard AZIB   Prise en compte d...
1674
1675
1676
1677
		} else {
			if (!isset($zoomList->panels->{$input->{'panelId'}})) {
				$zoomList->panels->{$input->{'panelId'}} = (object) array(
					'axes' => (object)array()
d3c3608d   Benjamin Renard   Add undo zoom
1678
1679
				);
			}
95ab3cf6   Menouard AZIB   Prise en compte d...
1680
1681

			if (!isset($zoomList->panels->{$input->{'panelId'}}->axes->{$input->{'axeId'}})) {
a9d86eaa   Benjamin Renard   Fix zoom / unzoom
1682
				$zoomList->panels->{$input->{'panelId'}}->axes->{$input->{'axeId'}} = array();
d3c3608d   Benjamin Renard   Add undo zoom
1683
			}
95ab3cf6   Menouard AZIB   Prise en compte d...
1684
1685
1686
1687

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

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

a9d86eaa   Benjamin Renard   Fix zoom / unzoom
1694
	private function resetZoomList($interactiveId, $resetOnlyTimeZoom = false)
d3c3608d   Benjamin Renard   Add undo zoom
1695
	{
a9d86eaa   Benjamin Renard   Fix zoom / unzoom
1696
		if (!$resetOnlyTimeZoom) {
95ab3cf6   Menouard AZIB   Prise en compte d...
1697
			$zoomList = (object)array(
a9d86eaa   Benjamin Renard   Fix zoom / unzoom
1698
				'times' => array(),
95ab3cf6   Menouard AZIB   Prise en compte d...
1699
				'panels' => (object)array()
a9d86eaa   Benjamin Renard   Fix zoom / unzoom
1700
			);
95ab3cf6   Menouard AZIB   Prise en compte d...
1701
		} else {
a9d86eaa   Benjamin Renard   Fix zoom / unzoom
1702
1703
1704
1705
1706
			$zoomList = $this->loadZoomList($interactiveId);
			$zoomList->times = array();
		}

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

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

d3c3608d   Benjamin Renard   Add undo zoom
1713
		$result = NULL;
95ab3cf6   Menouard AZIB   Prise en compte d...
1714
1715
		if ($zoomList) {
			if ($input->{'axeId'} == 'timeAxis') {
a9d86eaa   Benjamin Renard   Fix zoom / unzoom
1716
				if (count($zoomList->times) <= 0)
d3c3608d   Benjamin Renard   Add undo zoom
1717
					return NULL;
95ab3cf6   Menouard AZIB   Prise en compte d...
1718
1719
				$result = array_pop($zoomList->times);
			} else {
a9d86eaa   Benjamin Renard   Fix zoom / unzoom
1720
				if (!isset($zoomList->panels->{$input->{'panelId'}}))
d3c3608d   Benjamin Renard   Add undo zoom
1721
					return NULL;
95ab3cf6   Menouard AZIB   Prise en compte d...
1722

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

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

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

d3c3608d   Benjamin Renard   Add undo zoom
1733
1734
		return $result;
	}
95ab3cf6   Menouard AZIB   Prise en compte d...
1735

d3c3608d   Benjamin Renard   Add undo zoom
1736
	private function unmarshallZoom($input, $plotInput, $isUndo = false)
26a23052   Benjamin Renard   Add Interval Tick...
1737
	{
95ab3cf6   Menouard AZIB   Prise en compte d...
1738
		if ($input->{'axeId'} == 'timeAxis') {
26a23052   Benjamin Renard   Add Interval Tick...
1739
			//Zoom on Time Axis
95ab3cf6   Menouard AZIB   Prise en compte d...
1740
			if ($plotInput->{'timesrc'} != 'Interval') {
a9d86eaa   Benjamin Renard   Fix zoom / unzoom
1741
				$plotInput->{'timesrc'} = 'Interval';
7d84634e   Benjamin Renard   Fix plot request ...
1742
				if (!$isUndo)
95ab3cf6   Menouard AZIB   Prise en compte d...
1743
1744
1745
1746
1747
1748
1749
					$this->addZoomInList(
						$input,
						false,
						isset($plotInput->{'ttFileIndex'}) ? $plotInput->{'ttFileIndex'} : 0,
						isset($plotInput->{'intIndex'}) ? $plotInput->{'intIndex'} : 0
					);
			} else {
7d84634e   Benjamin Renard   Fix plot request ...
1750
				if (!$isUndo)
95ab3cf6   Menouard AZIB   Prise en compte d...
1751
					$this->addZoomInList($input, true, $plotInput->{'startDate'}, $plotInput->{'stopDate'});
26a23052   Benjamin Renard   Add Interval Tick...
1752
			}
a9d86eaa   Benjamin Renard   Fix zoom / unzoom
1753
1754
			$plotInput->{'startDate'} = $input->{'min'};
			$plotInput->{'stopDate'} = $input->{'max'};
95ab3cf6   Menouard AZIB   Prise en compte d...
1755

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

26a23052   Benjamin Renard   Add Interval Tick...
1761
		//Digital axis zoom
95ab3cf6   Menouard AZIB   Prise en compte d...
1762
1763
1764
1765
		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...
1766
						$axis->{'axis-range-extend'} = false;
d3c3608d   Benjamin Renard   Add undo zoom
1767
1768
						$oldMin = $axis->{'axis-range-min'};
						$oldMax = $axis->{'axis-range-max'};
26a23052   Benjamin Renard   Add Interval Tick...
1769
1770
						$axis->{'axis-range-min'} = $input->{'min'};
						$axis->{'axis-range-max'} = $input->{'max'};
a9d86eaa   Benjamin Renard   Fix zoom / unzoom
1771
						$this->saveIHMRequest($input->interactiveId, $plotInput);
26a23052   Benjamin Renard   Add Interval Tick...
1772
1773
						//Do not save 'force-single-replot' in request file!
						$plotInput->{'force-single-replot'} = true;
d3c3608d   Benjamin Renard   Add undo zoom
1774
1775
						$plotInput->{'force-time-zoom-reset'} = false;
						if (!$isUndo)
95ab3cf6   Menouard AZIB   Prise en compte d...
1776
							$this->addZoomInList($input, true, $oldMin, $oldMax);
26a23052   Benjamin Renard   Add Interval Tick...
1777
1778
1779
1780
1781
1782
1783
1784
						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...
1785

d3c3608d   Benjamin Renard   Add undo zoom
1786
1787
1788
	private function unmarshallUndoZoom($input, $plotInput)
	{
		$result = $this->undoZoomInList($input);
95ab3cf6   Menouard AZIB   Prise en compte d...
1789
1790
1791
		if ($result != NULL) {
			if (isset($result->isInterval)) {
				if (!$result->isInterval) {
d3c3608d   Benjamin Renard   Add undo zoom
1792
1793
1794
1795
1796
1797
1798
1799
1800
1801
1802
					$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...
1803

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

26a23052   Benjamin Renard   Add Interval Tick...
1809
1810
1811
1812
1813
		//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...
1814
1815
1816

		switch ($input->{'action'}) {
			case 'forward':
26a23052   Benjamin Renard   Add Interval Tick...
1817
1818
1819
				$startTimeStamp += $duration;
				$stopTimeStamp  += $duration;
				break;
95ab3cf6   Menouard AZIB   Prise en compte d...
1820
1821
1822
			case 'halfforward':
				$startTimeStamp += ($duration / 2);
				$stopTimeStamp  += ($duration / 2);
26a23052   Benjamin Renard   Add Interval Tick...
1823
				break;
2366956c   Erdogan Furkan   10312 - Navigatio...
1824
1825
1826
1827
			case 'quarterforward':
				$startTimeStamp += ($duration / 4);
				$stopTimeStamp  += ($duration / 4);
				break;
95ab3cf6   Menouard AZIB   Prise en compte d...
1828
			case 'backward':
26a23052   Benjamin Renard   Add Interval Tick...
1829
1830
1831
				$startTimeStamp -= $duration;
				$stopTimeStamp  -= $duration;
				break;
95ab3cf6   Menouard AZIB   Prise en compte d...
1832
1833
1834
			case 'halfbackward':
				$startTimeStamp -= ($duration / 2);
				$stopTimeStamp  -= ($duration / 2);
26a23052   Benjamin Renard   Add Interval Tick...
1835
				break;
2366956c   Erdogan Furkan   10312 - Navigatio...
1836
1837
1838
1839
			case 'quarterbackward':
				$startTimeStamp -= ($duration / 4);
				$stopTimeStamp  -= ($duration / 4);
				break;
95ab3cf6   Menouard AZIB   Prise en compte d...
1840
			case 'extend':
26a23052   Benjamin Renard   Add Interval Tick...
1841
1842
1843
				$startTimeStamp -= $input->{'duration'};
				$stopTimeStamp  += $input->{'duration'};
				break;
95ab3cf6   Menouard AZIB   Prise en compte d...
1844
			case 'shift':
26a23052   Benjamin Renard   Add Interval Tick...
1845
1846
1847
1848
				$startTimeStamp += $input->{'duration'};
				$stopTimeStamp  += $input->{'duration'};
				break;
		}
95ab3cf6   Menouard AZIB   Prise en compte d...
1849

26a23052   Benjamin Renard   Add Interval Tick...
1850
1851
		if ($stopTimeStamp - $startTimeStamp <= 0)
			throw new Exception('New duration is lower than 0.');
95ab3cf6   Menouard AZIB   Prise en compte d...
1852
1853
1854
1855

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

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

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

26a23052   Benjamin Renard   Add Interval Tick...
1865
1866
	private function unmarshallTTGoto($input, $plotInput)
	{
419a700b   Benjamin Renard   Fix TT goto
1867
1868
1869
		$plotInput->{'timesrc'} = 'TimeTable';
		$plotInput->{'ttFileIndex'} = $input->{'ttFileIndex'};
		$plotInput->{'intIndex'} = $input->{'intIndex'};
95ab3cf6   Menouard AZIB   Prise en compte d...
1870

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

05da1b4d   Benjamin Renard   Draw instant plot...
1876
1877
	private function unmarshallInstant($input, $plotInput)
	{
05da1b4d   Benjamin Renard   Draw instant plot...
1878
1879
		//Find current panel
		$crtPanel = NULL;
95ab3cf6   Menouard AZIB   Prise en compte d...
1880
1881
		foreach ($plotInput->{'panels'} as $panel) {
			if ($input->{'panelId'} == $panel->{'id'}) {
05da1b4d   Benjamin Renard   Draw instant plot...
1882
1883
1884
1885
				$crtPanel = $panel;
				break;
			}
		}
95ab3cf6   Menouard AZIB   Prise en compte d...
1886

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

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

05da1b4d   Benjamin Renard   Draw instant plot...
1893
1894
		//Find spectra parameter
		$crtParam = NULL;
95ab3cf6   Menouard AZIB   Prise en compte d...
1895
1896
1897
		foreach ($crtPanel->{'params'} as $param) {
			if ($param->{'param-drawing-type'} == 'spectro') {
				$crtParam = $param;
05da1b4d   Benjamin Renard   Draw instant plot...
1898
1899
1900
				break;
			}
		}
95ab3cf6   Menouard AZIB   Prise en compte d...
1901

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

05da1b4d   Benjamin Renard   Draw instant plot...
1905
1906
		//Find table Y-axis
		$crtYAxis = NULL;
95ab3cf6   Menouard AZIB   Prise en compte d...
1907
1908
		foreach ($crtPanel->{'axes'} as $axis) {
			if ($crtParam->{'param-drawing-object'}->{'spectro-yaxis'} == $axis->{'id'}) {
05da1b4d   Benjamin Renard   Draw instant plot...
1909
1910
1911
1912
				$crtYAxis = $axis;
				break;
			}
		}
95ab3cf6   Menouard AZIB   Prise en compte d...
1913

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

05da1b4d   Benjamin Renard   Draw instant plot...
1917
1918
		//Find color Z-axis
		$crtColorAxis = NULL;
95ab3cf6   Menouard AZIB   Prise en compte d...
1919
1920
		foreach ($crtPanel->{'axes'} as $axis) {
			if ($axis->{'id'} == 'color') {
05da1b4d   Benjamin Renard   Draw instant plot...
1921
1922
1923
1924
				$crtColorAxis = $axis;
				break;
			}
		}
95ab3cf6   Menouard AZIB   Prise en compte d...
1925

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

05da1b4d   Benjamin Renard   Draw instant plot...
1929
1930
		date_default_timezone_set('UTC');
		$timeStamp = strtotime($input->time);
95ab3cf6   Menouard AZIB   Prise en compte d...
1931
1932

		$instantPlotInput = (object)array(
05da1b4d   Benjamin Renard   Draw instant plot...
1933
1934
1935
1936
			"interactive-preview" => true,
			"file-format" => "PNG",
			"file-output" => "INTERACTIVE",
			"file-prefix" => "instant",
05da1b4d   Benjamin Renard   Draw instant plot...
1937
			"timesrc" => "Interval",
703f403f   Benjamin Renard   Fix some bugs wit...
1938
1939
			"startDate" => date("Y-m-d\TH:i:s", $timeStamp - 3600),
			"stopDate" => date("Y-m-d\TH:i:s", $timeStamp + 3600),
05da1b4d   Benjamin Renard   Draw instant plot...
1940
			"id" => 1,
c2d88cc5   Benjamin Renard   Fix instant plot
1941
1942
1943
1944
1945
			"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...
1946
			"page-layout-type" => "vertical",
95ab3cf6   Menouard AZIB   Prise en compte d...
1947
			"page-layout-object" => (object)array(
05da1b4d   Benjamin Renard   Draw instant plot...
1948
				"layout-expand" => true,
95ab3cf6   Menouard AZIB   Prise en compte d...
1949
				"layout-panel-height" => 0.5,
05da1b4d   Benjamin Renard   Draw instant plot...
1950
1951
1952
1953
				"layout-panel-spacing" => 0.05
			),
			"panels" => array()
		);
27317777   Menouard AZIB   J'ai ajouté la fo...
1954
1955
1956
1957
1958
1959
1960
1961
1962
1963
1964
1965
1966
1967
1968
1969
1970
1971
1972
1973
1974
1975
1976
1977

		$instantPanel = (object)array(
			"id" => "1",
			"panel-plot-type" => "instantPlot",
			"panel-instant-time" => $input->time,
			"panel-title-font-activated" => TRUE,
			"panel-title-font-size" => 12,
			"panel-title-font-bold" => TRUE,
			"axes" => array(),
			"params" => array(),

		);

		$instantXAxis = (object)array(
			"id"         => "xaxis_id",
			"axis-type"  => "x",
			"axis-scale" => $crtYAxis->{"axis-scale"},
			"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...
1978
		);
27317777   Menouard AZIB   J'ai ajouté la fo...
1979
1980
1981
1982
1983
1984
1985
1986
1987
1988
1989
1990

		$instantYAxis = (object)array(
			"id"         => "y-left",
			"axis-type"  => "y-left",
			"axis-scale" => $crtColorAxis->{"axis-scale"},
			"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...
1991
1992
1993
		);
		$instantPanel->{"axes"}[] = $instantXAxis;
		$instantPanel->{"axes"}[] = $instantYAxis;
95ab3cf6   Menouard AZIB   Prise en compte d...
1994
1995

		$instantParam = (object)array(
05da1b4d   Benjamin Renard   Draw instant plot...
1996
			"id" => 1,
e4545ed5   Benjamin Renard   Implement templat...
1997
			"paramid" => $crtParam->{'paramid'},
8d780912   Benjamin Renard   Keep template arg...
1998
			"template_args" => $crtParam->{'template_args'},
05da1b4d   Benjamin Renard   Draw instant plot...
1999
			"param-drawing-type" => "iserie",
27317777   Menouard AZIB   J'ai ajouté la fo...
2000
2001
2002
2003
2004
2005
			"param-drawing-object" => (object)array(
				"iserie-tableonx" => true,
				"iserie-lines-activated" => true,
				"iserie-lines-style" => "plain",
				"iserie-lines-width" => 3,
				"iserie-lines-color" => "#0000ff"
0a87e436   Hacene SI HADJ MOHAND   parameters resolue
2006
			),
95ab3cf6   Menouard AZIB   Prise en compte d...
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
			"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
2022

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

0a87e436   Hacene SI HADJ MOHAND   parameters resolue
2026

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


05da1b4d   Benjamin Renard   Draw instant plot...
2030
2031
		return $instantPlotInput;
	}
27317777   Menouard AZIB   J'ai ajouté la fo...
2032

0cea6b06   Menouard AZIB   Set preview font ...
2033
2034
2035
2036
2037
2038
2039
2040
2041
	/**
	 * Set preview font style to given axis 
	 */
	private function setPlotPreviewFont($axis){
		$axis->{"axis-legend-font-activated"} = TRUE;
		$axis->{"axis-legend-font-size"} = 12;
		$axis->{"axis-legend-font-bold"} = TRUE;
	}

27317777   Menouard AZIB   J'ai ajouté la fo...
2042
2043
	private function unmarshallPlotFunction($input, $plotInput)
	{
27317777   Menouard AZIB   J'ai ajouté la fo...
2044
		date_default_timezone_set('UTC');
7fc87ded   Menouard AZIB   Corriger le multi...
2045
2046
		$plotInput->{"startDate"} =$input->starttime;
		$plotInput->{"stopDate"} = $input->stoptime;
d22a300e   Menouard AZIB   It's Hard IHMInpu...
2047
2048
2049
2050
		$plotInput->{"file-prefix"}  = RequestOutPutPlotElementPlotFunctionNodeClass::REQUESTOUTPUTPLOTELEMENT_PLOTFUNCTION_NAME;
		$plotInput->{"interactive-preview"} = true;
		$plotInput->{"file-format"} = "PNG";
		$plotInput->{"file-output"} = "INTERACTIVE";
0cea6b06   Menouard AZIB   Set preview font ...
2051
2052
2053
2054
2055
2056
2057
		$plotInput->{"page-layout-type"} = "vertical";
		$plotInput->{"page-layout-object"} =  (object)array(
			"layout-expand" => true,
			"layout-panel-height" => 0.5,
			"layout-panel-spacing" => 0.05
		);

7fc87ded   Menouard AZIB   Corriger le multi...
2058
		$panels = 	[];	
27317777   Menouard AZIB   J'ai ajouté la fo...
2059

7fc87ded   Menouard AZIB   Corriger le multi...
2060
2061
2062
		foreach ($plotInput->{'panels'} as $input_panel) {
			if ($input->{'panelId'} == $input_panel->{'id'}) {
				$panel = $input_panel;
d22a300e   Menouard AZIB   It's Hard IHMInpu...
2063
2064
				if ($panel->{'panel-plot-type'} !== 'timePlot')
					throw new Exception('Plot Function action only available for Time plot.');
ed439757   Menouard AZIB   change unmarshall...
2065

d22a300e   Menouard AZIB   It's Hard IHMInpu...
2066
2067
				$panel->{RequestOutPutPlotElementPlotFunctionNodeClass::PLOT_FUNCTION_ABSCISSE} = $input->abscisse;
				$panel->{RequestOutPutPlotElementPlotFunctionNodeClass::PLOT_FUNCTION_TYPE} = $input->type;
328140af   Benjamin Renard   Restore FFT
2068
2069
				$scale_abscisse = $input->scale_abscisse;
				$scale_ordonnee = $input->scale_ordonnee;
d22a300e   Menouard AZIB   It's Hard IHMInpu...
2070
				$panel->{'panel-plot-type'} = RequestOutPutPlotElementPlotFunctionNodeClass::REQUESTOUTPUTPLOTELEMENT_PLOTFUNCTION_NAME;
0cea6b06   Menouard AZIB   Set preview font ...
2071
2072
2073
				$panel->{"panel-title-font-activated"} = TRUE;
				$panel->{"panel-title-font-size"} = 12;
				$panel->{"panel-title-font-bold"} = TRUE;
328140af   Benjamin Renard   Restore FFT
2074
2075
2076
2077
2078
2079
2080
2081
2082
2083
2084
2085
2086
2087
2088
2089
2090
2091
2092
2093
2094
2095
2096
2097
2098
2099
2100
2101
2102
2103
2104
2105
2106
2107
2108
2109
2110
2111
2112
2113
2114
2115
2116
2117
2118
2119
2120
2121
2122
2123
2124
2125
2126
2127
2128
2129
2130
2131
2132
2133
2134
2135
2136

				/**
				 * @var object $crtParam
				 */
				$crtParam = NULL;
				$isSpectro = false;
				//Find serie/spectra parameter
				foreach ($panel->{'params'} as $param) {
					if ($param->{'param-drawing-type'} == 'spectro') {
						$crtParam = $param;
						$isSpectro = true;
						break;
					}
					if ($param->{'param-drawing-type'} == 'serie') {
						$crtParam = $param;
						break;
					}
				}

				if ($isSpectro && RequestOutPutPlotElementPlotFunctionNodeClass::isFourier($input->type))
					throw new Exception('Cannot apply FFT/DFT on Spectro.');

				if (!$crtParam)
					throw new Exception('Cannot retrieve panel parameters for Plot function.');

				//Find X-axis
				$crtXAxis = NULL;
				foreach ($panel->{'axes'} as $axis) {
					if ("time" == $axis->{'id'}) {
						$crtXAxis = $axis;
						break;
					}
				}

				//Find Y-axis
				$crtYAxis = NULL;
				foreach ($panel->{'axes'} as $axis) {
					if ($crtParam->{'param-drawing-object'}->{'spectro-yaxis'} == $axis->{'id'}) {
						$crtYAxis = $axis;
						break;
					}

					if ($crtParam->{'param-drawing-object'}->{'serie-yaxis'} == $axis->{'id'}) {
						$crtYAxis = $axis;
						break;
					}
				}

				if (!$crtYAxis)
					throw new Exception('Cannot retrieve y Axis for Plot Function.');

				//Find color Z-axis
				$crtColorAxis = NULL;
				foreach ($panel->{'axes'} as $axis) {
					if ($axis->{'id'} == 'color') {
						$crtColorAxis = $axis;
						break;
					}
				}

				if ($isSpectro && !$crtColorAxis)
					throw new Exception('Cannot retrieve color Axis for Plot function.');

d22a300e   Menouard AZIB   It's Hard IHMInpu...
2137
				$panel->{"axes"} = [];
328140af   Benjamin Renard   Restore FFT
2138
2139
2140
2141
2142
2143
2144
2145
2146
2147
2148
2149
2150
2151
2152
2153
2154
2155
2156
2157
2158
2159
2160
2161
2162
2163
2164
2165
2166
2167
2168
2169
2170
2171
2172
2173
2174
2175
2176
2177
2178
				/**
				 * @var object $plotFctXAxisDigital, digital x axis for plot function, used for spectro and Fourier
				 */
				$plotFctXAxisDigital = NULL;
				/**
				 * @var object $plotFctXAxisTime, this axis is used only for Series
				 */
				$plotFctXAxisTime = clone ($crtXAxis);
				$plotFctXAxisTime->{"id"} = RequestOutPutPlotElementPlotFunctionNodeClass::PLOT_FUNCTION_TIMEAXIS_ID;
				/**
				 * @var object $plotFctYAxis, y axis for plot fucntion
				 */
				$plotFctYAxis = clone ($crtYAxis);

				if ($isSpectro) {
					$plotFctXAxisDigital = clone ($crtYAxis);
					$plotFctXAxisDigital->{"id"} = RequestOutPutPlotElementPlotFunctionNodeClass::PLOT_FUNCTION_DIGITALAXIS_ID;
					$plotFctXAxisDigital->{"axis-type"} = "x";
					if (RequestOutPutPlotElementPlotFunctionNodeClass::isFourier($input->type))
						$plotFctXAxisDigital->{'axis-legend-text'} = RequestOutPutPlotElementPlotFunctionNodeClass::getTextLegend($input->abscisse);

					$plotFctYAxis = clone ($crtColorAxis);
					$plotFctYAxis->{"id"} = RequestOutPutPlotElementPlotFunctionNodeClass::PLOT_FUNCTION_YAXIS_ID;
					$plotFctYAxis->{"axis-type"} =  RequestOutPutPlotElementPlotFunctionNodeClass::PLOT_FUNCTION_YAXIS_ID;

					$panel->{"axes"}[] = $plotFctXAxisDigital;
					$panel->{"axes"}[] = $plotFctYAxis;
					$panel->{"axes"}[] = $plotFctXAxisTime;
				} else {
					$panel->{"axes"}[] = $plotFctXAxisTime;
					$panel->{"axes"}[] = $plotFctYAxis;
					if (RequestOutPutPlotElementPlotFunctionNodeClass::isFourier($input->type)) {
						$plotFctXAxisDigital = clone ($crtXAxis);
						$plotFctXAxisDigital->{"id"} = RequestOutPutPlotElementPlotFunctionNodeClass::PLOT_FUNCTION_DIGITALAXIS_ID;
						$plotFctXAxisDigital->{"axis-type"} = "x";
						$plotFctXAxisDigital->{'axis-legend-text'} = RequestOutPutPlotElementPlotFunctionNodeClass::getTextLegend($input->abscisse);
						$plotFctYAxis->{'axis-legend-text'} = "";
						$panel->{"axes"}[] = $plotFctXAxisDigital;
					}
				}

0cea6b06   Menouard AZIB   Set preview font ...
2179
2180
2181
2182
				$this->setPlotPreviewFont($plotFctXAxisDigital);
				$this->setPlotPreviewFont($plotFctYAxis);
				$this->setPlotPreviewFont($plotFctXAxisTime);

328140af   Benjamin Renard   Restore FFT
2183
2184
2185
2186
2187
2188
2189
2190
2191
2192
2193
2194
2195
2196
2197
2198
2199
				/**
				 * In this block, I will update the axis scale depending on the user choice hosted in thess variables $scale_abscisse and scale_ordonnee. 
				 * If 'Inherites' is selected then the scale of axis of the current time plot are used.
				 */
				if ($scale_abscisse == RequestOutPutPlotElementPlotFunctionNodeClass::PLOT_FUNCTION_IHERITS)
					$scale_abscisse = $plotFctXAxisDigital->{"axis-scale"};
				else
					$plotFctXAxisDigital->{"axis-scale"} = $scale_abscisse;

				if ($scale_ordonnee == RequestOutPutPlotElementPlotFunctionNodeClass::PLOT_FUNCTION_IHERITS)
					$scale_ordonnee = $plotFctYAxis->{"axis-scale"};
				else
					$plotFctYAxis->{"axis-scale"} = $scale_ordonnee;

				$panel->{RequestOutPutPlotElementPlotFunctionNodeClass::PLOT_FUNCTION_SCALE_ABSCISSE} = $scale_abscisse;
				$panel->{RequestOutPutPlotElementPlotFunctionNodeClass::PLOT_FUNCTION_SCALE_ORDONNEE} = $scale_ordonnee;

7fc87ded   Menouard AZIB   Corriger le multi...
2200
				$panels[]= $panel;
d22a300e   Menouard AZIB   It's Hard IHMInpu...
2201
				break;
28c6d6c5   Menouard AZIB   Enable plot fucnt...
2202
			} 
27317777   Menouard AZIB   J'ai ajouté la fo...
2203
		}
7fc87ded   Menouard AZIB   Corriger le multi...
2204
		$plotInput->{'panels'} = $panels;
d22a300e   Menouard AZIB   It's Hard IHMInpu...
2205
		return $plotInput;
27317777   Menouard AZIB   J'ai ajouté la fo...
2206
	}
0cea6b06   Menouard AZIB   Set preview font ...
2207

26a23052   Benjamin Renard   Add Interval Tick...
2208
}