Blame view

src/InputOutput/IHMImpl/Params/PlotImpl/IHMInputOutputParamsPlotClass.php 77.5 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);
95ab3cf6   Menouard AZIB   Prise en compte d...
318

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

05da1b4d   Benjamin Renard   Draw instant plot...
510
511
		if (isset($axisData->{'axis-grid-major'}))
			$axisNode->getTick()->setMajorGrid($axisData->{'axis-grid-major'} ? "true" : "false");
95ab3cf6   Menouard AZIB   Prise en compte d...
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
		if ($axisData->{'axis-grid-specify-ticks-number'}) {

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

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

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

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


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

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

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

26a23052   Benjamin Renard   Add Interval Tick...
544
		//Add constants
95ab3cf6   Menouard AZIB   Prise en compte d...
545
		if ($constantAxisId != '') {
26a23052   Benjamin Renard   Add Interval Tick...
546
547
			foreach ($constantsData as $constantData)
				if ($constantData->{'constant-axis-id'} == $constantAxisId)
95ab3cf6   Menouard AZIB   Prise en compte d...
548
					$this->unmarshallConstant($constantData, $axisNode);
26a23052   Benjamin Renard   Add Interval Tick...
549
550
		}
	}
95ab3cf6   Menouard AZIB   Prise en compte d...
551

c4213719   Erdogan Furkan   Done.
552
	protected function unmarshallParams($paramsData, $requestParamsNode, $plotNode, $panelNode, $statusPlotNode, $tickPlotNode, $axesData)
26a23052   Benjamin Renard   Add Interval Tick...
553
554
555
	{
		//X parameters
		$isScatter = ($plotNode->getName() == REQUESTOUTPUTPLOTELEMENTXY_NAME);
f822811a   Benjamin Renard   Implements multi ...
556
		$xIds = array();
95ab3cf6   Menouard AZIB   Prise en compte d...
557
		if ($isScatter) {
f822811a   Benjamin Renard   Implements multi ...
558
			$crtXId = 0;
95ab3cf6   Menouard AZIB   Prise en compte d...
559
			foreach ($paramsData as $paramData) {
26a23052   Benjamin Renard   Add Interval Tick...
560
561
				if ($paramData->{'param-drawing-object'}->{'serie-xaxis-param'} == '')
					continue;
f822811a   Benjamin Renard   Implements multi ...
562
563
564
565
				if (array_key_exists($paramData->{'param-drawing-object'}->{'serie-xaxis-param'}, $xIds)) {
					//x param already exists
					continue;
				}
95ab3cf6   Menouard AZIB   Prise en compte d...
566

bf27ba04   Benjamin Renard   Add templated par...
567
				$paramXInfo = $this->paramManager->addExistingParam($paramData->{'param-drawing-object'}->{'serie-xaxis-param'}, $this->paramsData);
26a23052   Benjamin Renard   Add Interval Tick...
568
569
570
571
				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...
572
				switch ($paramData->{'param-drawing-type'}) {
c4213719   Erdogan Furkan   Done.
573
					case 'histogram2d':
95ab3cf6   Menouard AZIB   Prise en compte d...
574
					case 'serie':
26a23052   Benjamin Renard   Add Interval Tick...
575
576
						//Unmarshall x serie
						if (count($paramXInfo['indexes']) == 0)
f822811a   Benjamin Renard   Implements multi ...
577
							$xParamNode->addXSerie(-1, $crtXId, $paramData->{'param-drawing-object'}->{'serie-xvalue-min'}, $paramData->{'param-drawing-object'}->{'serie-xvalue-max'});
26a23052   Benjamin Renard   Add Interval Tick...
578
						else if (count($paramXInfo['indexes']) == 1)
f822811a   Benjamin Renard   Implements multi ...
579
							$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...
580
581
582
						else
							throw new Exception('X parameter for serie must be a component.');
						break;
95ab3cf6   Menouard AZIB   Prise en compte d...
583
					default:
26a23052   Benjamin Renard   Add Interval Tick...
584
585
						throw new Exception('X parameter not allowed for this drawing type. ');
				}
f822811a   Benjamin Renard   Implements multi ...
586
587
				$xIds[$paramData->{'param-drawing-object'}->{'serie-xaxis-param'}] = $crtXId;
				++$crtXId;
26a23052   Benjamin Renard   Add Interval Tick...
588
589
			}
		}
95ab3cf6   Menouard AZIB   Prise en compte d...
590

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

26a23052   Benjamin Renard   Add Interval Tick...
596
			//Param
52c1e291   Benjamin Renard   Generate TT and c...
597
598
			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...
599
			} else {
52c1e291   Benjamin Renard   Generate TT and c...
600
601
				$paramInfo = $this->paramManager->addTTCatParam($paramData->{'paramid'}, $this->paramsData);
			}
95ab3cf6   Menouard AZIB   Prise en compte d...
602

3182799a   Benjamin Renard   Use param indexes...
603
			$paramInfo['indexes'] = array();
27317777   Menouard AZIB   J'ai ajouté la fo...
604
605
606
607
608
			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...
609
610
			$this->paramManager->applyFilter($this->paramsData, $paramData, $paramInfo);

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

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

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

			switch ($paramData->{'param-drawing-type'}) {
				case 'serie':
26a23052   Benjamin Renard   Add Interval Tick...
621
					$paramNode = $plotNode->getParams()->getParamById($paramInfo['id']);
f822811a   Benjamin Renard   Implements multi ...
622
					$this->unmarshallSerie($paramData, $requestParamsNode, $plotNode, $paramNode, $paramInfo['indexes'], $xId, $colorSerieId, false);
26a23052   Benjamin Renard   Add Interval Tick...
623
					break;
c4213719   Erdogan Furkan   Done.
624
625
				case 'histogram2d':
					$paramNode = $plotNode->getParams()->getParamById($paramInfo['id']);
2c99863f   Erdogan Furkan   Minor fix
626
627
628
629
					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.
630
631
					$this->unmarshallHistogram2D($paramData, $requestParamsNode, $plotNode, $paramNode, $paramInfo['indexes'], $xId, $paramZInfo,$axesData);
					break;	
95ab3cf6   Menouard AZIB   Prise en compte d...
632
				case 'orbit-serie':
26a23052   Benjamin Renard   Add Interval Tick...
633
					$paramNode = $plotNode->getParams()->getParamById($paramInfo['id']);
f822811a   Benjamin Renard   Implements multi ...
634
					$this->unmarshallSerie($paramData, $requestParamsNode, $plotNode, $paramNode, -1, $xId, $colorSerieId, true);
26a23052   Benjamin Renard   Add Interval Tick...
635
					break;
95ab3cf6   Menouard AZIB   Prise en compte d...
636
				case 'spectro':
26a23052   Benjamin Renard   Add Interval Tick...
637
638
639
					$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...
640
641
642
				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
643
					break;
95ab3cf6   Menouard AZIB   Prise en compte d...
644
				case 'status-bar':
26a23052   Benjamin Renard   Add Interval Tick...
645
646
647
648
649
650
					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...
651
				case 'tick-bar':
26a23052   Benjamin Renard   Add Interval Tick...
652
653
654
655
					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...
656

26a23052   Benjamin Renard   Add Interval Tick...
657
658
					$this->unmarshallTickBar($paramData->{'param-drawing-object'}, $paramNode, $paramInfo['indexes']);
					break;
95ab3cf6   Menouard AZIB   Prise en compte d...
659
				case 'iserie':
26a23052   Benjamin Renard   Add Interval Tick...
660
661
662
					$paramNode = $plotNode->getParams()->getParamById($paramInfo['id']);
					$this->unmarshallInstantSerie($paramData->{'param-drawing-object'}, $plotNode, $paramNode);
					break;
95ab3cf6   Menouard AZIB   Prise en compte d...
663
				case 'ispectro':
fc153c1c   Elena.Budnik   ispectro added
664
665
					$paramNode = $plotNode->getParams()->getParamById($paramInfo['id']);
					$this->unmarshallInstantSpectro($paramData->{'param-drawing-object'}, $plotNode, $paramNode, $paramInfo['indexes']);
044a9305   Benjamin Renard   Add intervals dra...
666
					break;
95ab3cf6   Menouard AZIB   Prise en compte d...
667
				case 'intervals':
044a9305   Benjamin Renard   Add intervals dra...
668
669
670
					$paramNode = $plotNode->getParams()->getParamById($paramInfo['id']);
					$this->unmarshallIntervals($paramData->{'param-drawing-object'}, $paramNode);
					break;
95ab3cf6   Menouard AZIB   Prise en compte d...
671
				default:
26a23052   Benjamin Renard   Add Interval Tick...
672
673
674
675
					throw new Exception('Drawing type not implemented.');
			}
			++$drawingEltIndex;
		}
95ab3cf6   Menouard AZIB   Prise en compte d...
676

26a23052   Benjamin Renard   Add Interval Tick...
677
678
		//Colored parameter
		$drawingEltIndex = 0;
95ab3cf6   Menouard AZIB   Prise en compte d...
679
680
		foreach ($paramsData as $paramData) {
			if (empty($paramData->{'param-drawing-object'}->{'serie-colored-param'})) {
26a23052   Benjamin Renard   Add Interval Tick...
681
682
683
				++$drawingEltIndex;
				continue;
			}
95ab3cf6   Menouard AZIB   Prise en compte d...
684

bf27ba04   Benjamin Renard   Add templated par...
685
			$paramColoredInfo = $this->paramManager->addExistingParam($paramData->{'param-drawing-object'}->{'serie-colored-param'}, $this->paramsData);
26a23052   Benjamin Renard   Add Interval Tick...
686
687
688
689
			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...
690

26a23052   Benjamin Renard   Add Interval Tick...
691
			$colorSerieId = $drawingEltIndex;
95ab3cf6   Menouard AZIB   Prise en compte d...
692
693
694
695

			switch ($paramData->{'param-drawing-type'}) {
				case 'serie':
				case 'orbit-serie':
26a23052   Benjamin Renard   Add Interval Tick...
696
697
698
699
700
701
702
703
					//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...
704
				default:
26a23052   Benjamin Renard   Add Interval Tick...
705
706
707
708
709
					throw new Exception('Colored parameter not allowed for this drawing type. ');
			}
			++$drawingEltIndex;
		}
	}
95ab3cf6   Menouard AZIB   Prise en compte d...
710

c4213719   Erdogan Furkan   Done.
711
712
713
714
715
	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...
716
717
718
719
			if (isset($histogram2DNode)) {
				$histogram2DNode->setId($paramData->{'id'});
				$histogram2DNodes[] = $histogram2DNode;
			}
c4213719   Erdogan Furkan   Done.
720
721
722
		}
		foreach ($indexes as $index) {
			$histogram2DNode = $paramNode->addHistogram2DSerie($paramData->{'param-drawing-object'}->{'serie-yaxis'}, $index, $xId);
f84b7023   Benjamin Renard   Prevent exception...
723
724
725
726
727
			if (isset($histogram2DNode)) {
				if (count($indexes) == 1)
					$histogram2DNode->setId($paramData->{'id'});
				$histogram2DNodes[] = $histogram2DNode;
			}
c4213719   Erdogan Furkan   Done.
728
729
		}

c4213719   Erdogan Furkan   Done.
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
		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
748

c4213719   Erdogan Furkan   Done.
749
750
			if($paramData->{'param-drawing-object'}->{'histo2d-function'} != "density"){
				// paramId
43b2304e   Benjamin Renard   Throw exception i...
751
752
753
				if (empty($paramZInfo['id'])) {
					throw new Exception('Z parameter must be defined to apply function.');
				}
c4213719   Erdogan Furkan   Done.
754
755
756
757
758
759
760
761
762
763
764
765
766
767
				$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.');
			}
		}
	}

f822811a   Benjamin Renard   Implements multi ...
768
	protected function unmarshallSerie($paramData, $requestParamsNode, $plotNode, $paramNode, $indexes, $xId, $colorSerieId, $isOrbitSerie)
26a23052   Benjamin Renard   Add Interval Tick...
769
770
	{
		$serieNodes = array();
95ab3cf6   Menouard AZIB   Prise en compte d...
771
772
773

		if (!$isOrbitSerie) {
			if (count($indexes) == 0) {
f822811a   Benjamin Renard   Implements multi ...
774
				$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...
775
				$serieNode->setId($paramData->{'id'});
60a1a563   Benjamin Renard   Add the possibili...
776
777
				if (!empty($paramData->{'param-drawing-object'}->{'serie-resolution'}))
					$serieNode->setResolution($paramData->{'param-drawing-object'}->{'serie-resolution'});
26a23052   Benjamin Renard   Add Interval Tick...
778
779
				$serieNodes[] = $serieNode;
			}
95ab3cf6   Menouard AZIB   Prise en compte d...
780
			foreach ($indexes as $index) {
f822811a   Benjamin Renard   Implements multi ...
781
				$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...
782
783
				if (count($indexes) == 1)
					$serieNode->setId($paramData->{'id'});
60a1a563   Benjamin Renard   Add the possibili...
784
785
				if (!empty($paramData->{'param-drawing-object'}->{'serie-resolution'}))
					$serieNode->setResolution($paramData->{'param-drawing-object'}->{'serie-resolution'});
26a23052   Benjamin Renard   Add Interval Tick...
786
787
				$serieNodes[] = $serieNode;
			}
95ab3cf6   Menouard AZIB   Prise en compte d...
788
		} else {
cb46dfbf   Benjamin Renard   Fix orbit serie a...
789
			$orbitSerie = $paramNode->addOrbitSerie($paramData->{'param-drawing-object'}->{'serie-yaxis'}, $colorSerieId);
26a23052   Benjamin Renard   Add Interval Tick...
790
791
792
			$orbitSerie->setId($paramData->{'id'});
			$serieNodes[] = $orbitSerie;
		}
95ab3cf6   Menouard AZIB   Prise en compte d...
793
794
795

		foreach ($serieNodes as $serieNode) {
			if (!$isOrbitSerie) {
26a23052   Benjamin Renard   Add Interval Tick...
796
				//Resampling
95ab3cf6   Menouard AZIB   Prise en compte d...
797
798
799
				if ($plotNode->getName() == REQUESTOUTPUTPLOTELEMENTXY_NAME) {
					switch ($paramData->{'param-drawing-object'}->{'serie-resampling-mode'}) {
						case 'yparam':
26a23052   Benjamin Renard   Add Interval Tick...
800
801
							$serieNode->getResampling()->setType(RequestOutputPlotResamplingTypeEnum::YPARAM);
							break;
95ab3cf6   Menouard AZIB   Prise en compte d...
802
803
						case 'xparam':
						default:
26a23052   Benjamin Renard   Add Interval Tick...
804
805
806
							$serieNode->getResampling()->setType(RequestOutputPlotResamplingTypeEnum::XPARAM);
					}
				}
95ab3cf6   Menouard AZIB   Prise en compte d...
807
			} else {
26a23052   Benjamin Renard   Add Interval Tick...
808
				//Projection
95ab3cf6   Menouard AZIB   Prise en compte d...
809
810
				switch ($paramData->{'param-drawing-object'}->{'serie-projection'}) {
					case 'XY':
26a23052   Benjamin Renard   Add Interval Tick...
811
812
						$serieNode->setProjection(RequestOutputPlotOrbitSerieProjectionEnum::XY);
						break;
95ab3cf6   Menouard AZIB   Prise en compte d...
813
					case 'XZ':
26a23052   Benjamin Renard   Add Interval Tick...
814
815
						$serieNode->setProjection(RequestOutputPlotOrbitSerieProjectionEnum::XZ);
						break;
95ab3cf6   Menouard AZIB   Prise en compte d...
816
					case 'YZ':
26a23052   Benjamin Renard   Add Interval Tick...
817
818
						$serieNode->setProjection(RequestOutputPlotOrbitSerieProjectionEnum::YZ);
						break;
95ab3cf6   Menouard AZIB   Prise en compte d...
819
					case 'XR':
26a23052   Benjamin Renard   Add Interval Tick...
820
821
						$serieNode->setProjection(RequestOutputPlotOrbitSerieProjectionEnum::XR);
						break;
95ab3cf6   Menouard AZIB   Prise en compte d...
822
					case 'YR':
26a23052   Benjamin Renard   Add Interval Tick...
823
824
						$serieNode->setProjection(RequestOutputPlotOrbitSerieProjectionEnum::YR);
						break;
95ab3cf6   Menouard AZIB   Prise en compte d...
825
					case 'ZR':
26a23052   Benjamin Renard   Add Interval Tick...
826
827
						$serieNode->setProjection(RequestOutputPlotOrbitSerieProjectionEnum::ZR);
						break;
95ab3cf6   Menouard AZIB   Prise en compte d...
828
					default:
26a23052   Benjamin Renard   Add Interval Tick...
829
830
831
						throw new Exception('Projection not allowed for the orbit serie');
				}
			}
95ab3cf6   Menouard AZIB   Prise en compte d...
832

26a23052   Benjamin Renard   Add Interval Tick...
833
834
835
836
837
838
839
840
841
842
843
844
845
			//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...
846
			if (!$isOrbitSerie) {
26a23052   Benjamin Renard   Add Interval Tick...
847
848
849
850
851
852
				//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...
853

26a23052   Benjamin Renard   Add Interval Tick...
854
855
856
857
858
859
860
861
862
863
864
	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...
865
866
		switch ($serieData->{'serie-timetick-type'}) {
			case 'time-step':
26a23052   Benjamin Renard   Add Interval Tick...
867
868
869
				$timeTickNode->setStep(CommonClass::timeStampToDDTime($serieData->{'serie-timetick-step'}));
				$timeTickNode->setNumber(0);
				break;
95ab3cf6   Menouard AZIB   Prise en compte d...
870
			case 'nb-major':
26a23052   Benjamin Renard   Add Interval Tick...
871
872
873
				$timeTickNode->setStep(0);
				$timeTickNode->setNumber($serieData->{'serie-timetick-nbmajor'});
				break;
95ab3cf6   Menouard AZIB   Prise en compte d...
874
875
			case 'auto':
			default:
26a23052   Benjamin Renard   Add Interval Tick...
876
877
878
879
880
881
882
883
				$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...
884

26a23052   Benjamin Renard   Add Interval Tick...
885
886
887
	protected function unmarshallIntervalTick($serieData, $intervalTickNode)
	{
		//Mode
95ab3cf6   Menouard AZIB   Prise en compte d...
888
		switch ($serieData->{'serie-intervaltick-mode'}) {
26a23052   Benjamin Renard   Add Interval Tick...
889
			case 'symbol-only':
4f9a8e36   Benjamin Renard   Min/Max value def...
890
				$intervalTickNode->setMode(RequestOutputPlotSerieIntervalTicksModeEnum::SYMBOLONLY);
26a23052   Benjamin Renard   Add Interval Tick...
891
892
				break;
			case 'interval-index':
4f9a8e36   Benjamin Renard   Min/Max value def...
893
				$intervalTickNode->setMode(RequestOutputPlotSerieIntervalTicksModeEnum::INTERVALINDEX);
26a23052   Benjamin Renard   Add Interval Tick...
894
895
				break;
			case 'start-stop-time':
4f9a8e36   Benjamin Renard   Min/Max value def...
896
				$intervalTickNode->setMode(RequestOutputPlotSerieIntervalTicksModeEnum::STARTSTOPTIME);
26a23052   Benjamin Renard   Add Interval Tick...
897
898
				break;
			case 'start-time':
95ab3cf6   Menouard AZIB   Prise en compte d...
899
			default:
4f9a8e36   Benjamin Renard   Min/Max value def...
900
				$intervalTickNode->setMode(RequestOutputPlotSerieIntervalTicksModeEnum::STARTTIME);
26a23052   Benjamin Renard   Add Interval Tick...
901
		}
95ab3cf6   Menouard AZIB   Prise en compte d...
902

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

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

26a23052   Benjamin Renard   Add Interval Tick...
909
910
911
912
		//Font
		if ($serieData->{'serie-intervaltick-font-activated'})
			$this->unmarshallFont($serieData, 'serie-intervaltick-font', $intervalTickNode->getFont());
	}
95ab3cf6   Menouard AZIB   Prise en compte d...
913

26a23052   Benjamin Renard   Add Interval Tick...
914
915
916
	protected function unmarshallErrorBar($serieData, $requestParamsNode, $errorBarNode)
	{
		//Type
95ab3cf6   Menouard AZIB   Prise en compte d...
917
		switch ($serieData->{'serie-errorbar-type'}) {
26a23052   Benjamin Renard   Add Interval Tick...
918
919
			case 'min-max':
				$errorBarTypeNode = $errorBarNode->getBarByType(RequestOutputPlotYSerieErrorBarTypeEnum::MINMAX);
95ab3cf6   Menouard AZIB   Prise en compte d...
920

bf27ba04   Benjamin Renard   Add templated par...
921
				$minParamInfo = $this->paramManager->addExistingParam($serieData->{'serie-errorbar-minparam'}, $this->paramsData);
26a23052   Benjamin Renard   Add Interval Tick...
922
923
924
925
926
927
928
929
930
				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...
931

bf27ba04   Benjamin Renard   Add templated par...
932
				$maxParamInfo = $this->paramManager->addExistingParam($serieData->{'serie-errorbar-maxparam'}, $this->paramsData);
26a23052   Benjamin Renard   Add Interval Tick...
933
934
935
936
937
938
939
940
941
942
943
944
				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...
945

bf27ba04   Benjamin Renard   Add templated par...
946
				$deltaParamInfo = $this->paramManager->addExistingParam($serieData->{'serie-errorbar-deltaparam'}, $this->paramsData);
26a23052   Benjamin Renard   Add Interval Tick...
947
948
949
950
951
952
953
954
955
956
				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...
957
			default:
26a23052   Benjamin Renard   Add Interval Tick...
958
959
				throw new Exception('Unknown error bar type.');
		}
95ab3cf6   Menouard AZIB   Prise en compte d...
960

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

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

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

26a23052   Benjamin Renard   Add Interval Tick...
972
973
974
975
976
977
978
979
980
		//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...
981

26a23052   Benjamin Renard   Add Interval Tick...
982
983
	protected function unmarshallSpectro($paramDrawingData, $plotNode, $paramNode, $indexes)
	{
95ab3cf6   Menouard AZIB   Prise en compte d...
984
985
986
987
988
989
990
991
992
993
		$spectroNode = $paramNode->addSpectro(
			$paramDrawingData->{'spectro-yaxis'},
			empty($paramDrawingData->{'spectro-resolution'}) ? NULL : $paramDrawingData->{'spectro-resolution'},
			count($indexes) > 0 ? $indexes[0] : NULL,
			$paramDrawingData->{'spectro-value-min'},
			$paramDrawingData->{'spectro-value-max'},
			isset($paramDrawingData->{'spectro-log0-as-min'}) ? $paramDrawingData->{'spectro-log0-as-min'} : false,
			empty($paramDrawingData->{'spectro-normalization'}) ? NULL : $paramDrawingData->{'spectro-normalization'},
			empty($paramDrawingData->{REQUESTOUTPUTPLOTSPECTRO_BGS_TYPE}) ? NULL : $paramDrawingData->{REQUESTOUTPUTPLOTSPECTRO_BGS_TYPE},
			!isset($paramDrawingData->{REQUESTOUTPUTPLOTSPECTRO_BGS_VALUE}) ? NULL : $paramDrawingData->{REQUESTOUTPUTPLOTSPECTRO_BGS_VALUE},
7c2e29e9   Myriam Bouchemit   Fix
994
			!isset($paramDrawingData->{REQUESTOUTPUTPLOTSPECTRO_BGS_DIM}) || ($paramDrawingData->{REQUESTOUTPUTPLOTSPECTRO_BGS_DIM} == "") ? NULL : $paramDrawingData->{REQUESTOUTPUTPLOTSPECTRO_BGS_DIM}
95ab3cf6   Menouard AZIB   Prise en compte d...
995
		);
26a23052   Benjamin Renard   Add Interval Tick...
996
	}
27317777   Menouard AZIB   J'ai ajouté la fo...
997
	protected function unmarshallSauvaud($paramDrawingData, $plotNode, $paramNode, $indexes)
3dcf7710   Hacene SI HADJ MOHAND   us ok
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
	{
		$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...
1009
1010
			!isset($paramDrawingData->{REQUESTOUTPUTPLOTSPECTRO_BGS_DIM}) ? NULL : $paramDrawingData->{REQUESTOUTPUTPLOTSPECTRO_BGS_DIM},
			$paramDrawingData->{'right_dim'}
3dcf7710   Hacene SI HADJ MOHAND   us ok
1011
1012
		);
	}
95ab3cf6   Menouard AZIB   Prise en compte d...
1013

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

26a23052   Benjamin Renard   Add Interval Tick...
1020
1021
	protected function unmarshallStatusBar($paramDrawingData, $paramNode, $indexes)
	{
25a38537   Erdogan Furkan   7616 - Adding col...
1022
1023
1024
1025
1026
		if ($paramDrawingData->{'statusbar-color'} == "none") {
			$color = NULL;
		} else {
			$color = $this->hexColor2KernelColor($paramDrawingData->{'statusbar-color'});
		}
26a23052   Benjamin Renard   Add Interval Tick...
1027
		if (count($indexes) == 0)
25a38537   Erdogan Furkan   7616 - Adding col...
1028
1029
1030
1031
1032
			$paramNode->addStatusBar(-1, $color);
		else {
			foreach ($indexes as $index)
				$paramNode->addStatusBar($index, $color);
		}
26a23052   Benjamin Renard   Add Interval Tick...
1033
	}
044a9305   Benjamin Renard   Add intervals dra...
1034
1035
1036

	protected function unmarshallIntervals($paramDrawingData, $paramNode)
	{
25a38537   Erdogan Furkan   7616 - Adding col...
1037
1038
1039
1040
1041
		if ($paramDrawingData->{'intervals-color'} == "none") {
			$color = NULL;
		} else {
			$color = $this->hexColor2KernelColor($paramDrawingData->{'intervals-color'});
		}
fe1a8ddd   Erdogan Furkan   Modifications for...
1042
1043

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

c54497a2   Benjamin Renard   Give the possibil...
1045
1046
1047
1048
1049
		if ($paramDrawingData->{'legend-text-activated'}) {
			$textLegendNode = $intervalsNode->addTextLegend();

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

26a23052   Benjamin Renard   Add Interval Tick...
1052
1053
1054
1055
1056
1057
1058
	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...
1059

26a23052   Benjamin Renard   Add Interval Tick...
1060
1061
1062
1063
1064
1065
1066
	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...
1067

26a23052   Benjamin Renard   Add Interval Tick...
1068
1069
1070
1071
1072
1073
1074
	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...
1075

26a23052   Benjamin Renard   Add Interval Tick...
1076
1077
1078
	protected function unmarshallParamsLegend($paramsLegendData, $paramsLegendNode)
	{
		//Legend type
95ab3cf6   Menouard AZIB   Prise en compte d...
1079
1080
		switch ($paramsLegendData->{'legend-series-type'}) {
			case 'text-line-symbol':
26a23052   Benjamin Renard   Add Interval Tick...
1081
1082
				$paramsLegendNode->setType(RequestOutputPlotParamsLegendTypeEnum::TEXTLINESYMBOL);
				break;
95ab3cf6   Menouard AZIB   Prise en compte d...
1083
1084
			case 'text-only':
			default:
26a23052   Benjamin Renard   Add Interval Tick...
1085
1086
				$paramsLegendNode->setType(RequestOutputPlotParamsLegendTypeEnum::TEXTONLY);
		}
95ab3cf6   Menouard AZIB   Prise en compte d...
1087

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

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

26a23052   Benjamin Renard   Add Interval Tick...
1094
		//Interval info type
95ab3cf6   Menouard AZIB   Prise en compte d...
1095
1096
		switch ($paramsLegendData->{'legend-series-intervalinfo-type'}) {
			case 'start-stop':
26a23052   Benjamin Renard   Add Interval Tick...
1097
1098
				$paramsLegendNode->setIntervalInfoType(RequestOutputPlotParamsLegendIntervalInfoTypeEnum::STARTSTOP);
				break;
95ab3cf6   Menouard AZIB   Prise en compte d...
1099
1100
			case 'index':
			default:
26a23052   Benjamin Renard   Add Interval Tick...
1101
1102
				$paramsLegendNode->setIntervalInfoType(RequestOutputPlotParamsLegendIntervalInfoTypeEnum::INDEX);
		}
95ab3cf6   Menouard AZIB   Prise en compte d...
1103

26a23052   Benjamin Renard   Add Interval Tick...
1104
		//Position
95ab3cf6   Menouard AZIB   Prise en compte d...
1105
1106
		switch ($paramsLegendData->{'legend-series-position'}) {
			case 'inside':
26a23052   Benjamin Renard   Add Interval Tick...
1107
1108
				$paramsLegendNode->setPosition(RequestOutputPlotParamsLegendPositionEnum::INSIDE);
				break;
95ab3cf6   Menouard AZIB   Prise en compte d...
1109
1110
			case 'outside':
			default:
26a23052   Benjamin Renard   Add Interval Tick...
1111
1112
				$paramsLegendNode->setPosition(RequestOutputPlotParamsLegendPositionEnum::OUTSIDE);
		}
95ab3cf6   Menouard AZIB   Prise en compte d...
1113

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

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

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

26a23052   Benjamin Renard   Add Interval Tick...
1123
1124
1125
1126
		//Font
		if ($paramsLegendData->{'legend-series-font-activated'})
			$this->unmarshallFont($paramsLegendData, 'legend-series-font', $paramsLegendNode->getFont());
	}
95ab3cf6   Menouard AZIB   Prise en compte d...
1127

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

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

26a23052   Benjamin Renard   Add Interval Tick...
1134
		//Legend position
95ab3cf6   Menouard AZIB   Prise en compte d...
1135
1136
		switch ($textLegendData->{'legend-text-position'}) {
			case 'top':
fe1a8ddd   Erdogan Furkan   Modifications for...
1137
				$parentNode->setPosition(RequestOutputPlotTextLegendPositionEnum::TOP);
26a23052   Benjamin Renard   Add Interval Tick...
1138
				break;
95ab3cf6   Menouard AZIB   Prise en compte d...
1139
			case 'bottom':
fe1a8ddd   Erdogan Furkan   Modifications for...
1140
				$parentNode->setPosition(RequestOutputPlotTextLegendPositionEnum::BOTTOM);
26a23052   Benjamin Renard   Add Interval Tick...
1141
				break;
95ab3cf6   Menouard AZIB   Prise en compte d...
1142
			case 'left':
fe1a8ddd   Erdogan Furkan   Modifications for...
1143
				$parentNode->setPosition(RequestOutputPlotTextLegendPositionEnum::LEFT);
26a23052   Benjamin Renard   Add Interval Tick...
1144
				break;
95ab3cf6   Menouard AZIB   Prise en compte d...
1145
1146
			case 'right':
			default:
fe1a8ddd   Erdogan Furkan   Modifications for...
1147
				$parentNode->setPosition(RequestOutputPlotTextLegendPositionEnum::RIGHT);
26a23052   Benjamin Renard   Add Interval Tick...
1148
		}
95ab3cf6   Menouard AZIB   Prise en compte d...
1149

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

26a23052   Benjamin Renard   Add Interval Tick...
1153
		//Font
fe1a8ddd   Erdogan Furkan   Modifications for...
1154
1155
1156
		if ($textLegendData->{'legend-text-font-activated'}) {
			$this->unmarshallFont($textLegendData, 'legend-text-font', $parentNode->getFont());
		}
26a23052   Benjamin Renard   Add Interval Tick...
1157
	}
95ab3cf6   Menouard AZIB   Prise en compte d...
1158
1159

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

26a23052   Benjamin Renard   Add Interval Tick...
1164
		//Constant value
95ab3cf6   Menouard AZIB   Prise en compte d...
1165
1166
		switch ($axisNode->getName()) {
			case REQUESTOUTPUTPLOTTIMEAXIS_NAME:
26a23052   Benjamin Renard   Add Interval Tick...
1167
				date_default_timezone_set('UTC');
74fd500a   Hacene SI HADJ MOHAND   us #9874 ms zoo...
1168
				$time = CommonClass::strTimeToDDTime($constantData->{'constant-time-value'});
26a23052   Benjamin Renard   Add Interval Tick...
1169
1170
				$constantNode->setConstantValue($time);
				break;
95ab3cf6   Menouard AZIB   Prise en compte d...
1171
			default:
26a23052   Benjamin Renard   Add Interval Tick...
1172
1173
				$constantNode->setConstantValue($constantData->{'constant-float-value'});
		}
95ab3cf6   Menouard AZIB   Prise en compte d...
1174

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

26a23052   Benjamin Renard   Add Interval Tick...
1179
1180
1181
1182
1183
1184
1185
	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...
1186

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

26a23052   Benjamin Renard   Add Interval Tick...
1191
		$textNode->setText($textData->{'text-value'});
95ab3cf6   Menouard AZIB   Prise en compte d...
1192
1193
1194

		switch ($textData->{'text-y-axis'}) {
			case 'y-right':
26a23052   Benjamin Renard   Add Interval Tick...
1195
1196
				$textNode->setYAxis('y-right');
				break;
95ab3cf6   Menouard AZIB   Prise en compte d...
1197
			case 'y-left':
26a23052   Benjamin Renard   Add Interval Tick...
1198
1199
1200
				$textNode->setYAxis('y-left');
				break;
		}
95ab3cf6   Menouard AZIB   Prise en compte d...
1201
1202

		if ($isTimePlot && !$textData->{'text-x-relative'}) {
26a23052   Benjamin Renard   Add Interval Tick...
1203
			date_default_timezone_set('UTC');
74fd500a   Hacene SI HADJ MOHAND   us #9874 ms zoo...
1204
			$time = CommonClass::strTimeToDDTime($textData->{'text-x-timevalue'});
26a23052   Benjamin Renard   Add Interval Tick...
1205
			$textNode->setX($time);
95ab3cf6   Menouard AZIB   Prise en compte d...
1206
1207
		} else if ($textData->{'text-x-relative'})
			$textNode->setX(($textData->{'text-x-floatvalue'} * 100) . "%");
26a23052   Benjamin Renard   Add Interval Tick...
1208
1209
		else
			$textNode->setX($textData->{'text-x-floatvalue'});
95ab3cf6   Menouard AZIB   Prise en compte d...
1210

26a23052   Benjamin Renard   Add Interval Tick...
1211
		if ($textData->{'text-y-relative'})
95ab3cf6   Menouard AZIB   Prise en compte d...
1212
			$textNode->setY(($textData->{'text-y-value'} * 100) . "%");
26a23052   Benjamin Renard   Add Interval Tick...
1213
1214
		else
			$textNode->setY($textData->{'text-y-value'});
95ab3cf6   Menouard AZIB   Prise en compte d...
1215

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

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

		switch ($textData->{'text-align'}) {
			case 'center':
26a23052   Benjamin Renard   Add Interval Tick...
1222
1223
				$textNode->setAlign(RequestOutputPlotTextAlign::CENTER);
				break;
95ab3cf6   Menouard AZIB   Prise en compte d...
1224
			case 'right':
26a23052   Benjamin Renard   Add Interval Tick...
1225
1226
				$textNode->setAlign(RequestOutputPlotTextAlign::RIGHT);
				break;
95ab3cf6   Menouard AZIB   Prise en compte d...
1227
			case 'left':
26a23052   Benjamin Renard   Add Interval Tick...
1228
1229
1230
			default:
				$textNode->setAlign(RequestOutputPlotTextAlign::LEFT);
		}
95ab3cf6   Menouard AZIB   Prise en compte d...
1231

26a23052   Benjamin Renard   Add Interval Tick...
1232
1233
1234
1235
		//Font
		if ($textData->{'text-font-activated'})
			$this->unmarshallFont($textData, 'text-font', $textNode->getFont());
	}
95ab3cf6   Menouard AZIB   Prise en compte d...
1236

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

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

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

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

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

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

26a23052   Benjamin Renard   Add Interval Tick...
1255
1256
	protected function unmarshallFills($panelData, $fillsNode)
	{
95ab3cf6   Menouard AZIB   Prise en compte d...
1257
		foreach ($panelData->{'fills'} as $fillData) {
26a23052   Benjamin Renard   Add Interval Tick...
1258
			//Serie / Constant
95ab3cf6   Menouard AZIB   Prise en compte d...
1259
			if ($fillData->{'fill-type'} == 'serie-constant') {
26a23052   Benjamin Renard   Add Interval Tick...
1260
1261
1262
1263
1264
1265
1266
1267
1268
				$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...
1269
1270

		foreach ($panelData->{'fills'} as $fillData) {
26a23052   Benjamin Renard   Add Interval Tick...
1271
			//Serie / Serie
95ab3cf6   Menouard AZIB   Prise en compte d...
1272
			if ($fillData->{'fill-type'} == 'serie-serie') {
26a23052   Benjamin Renard   Add Interval Tick...
1273
1274
1275
1276
1277
1278
1279
1280
				$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...
1281
		}
26a23052   Benjamin Renard   Add Interval Tick...
1282
	}
95ab3cf6   Menouard AZIB   Prise en compte d...
1283

26a23052   Benjamin Renard   Add Interval Tick...
1284
1285
	protected function unmarshallTitle($inputData, $keyPrefix, $titleNode)
	{
27317777   Menouard AZIB   J'ai ajouté la fo...
1286
1287
1288
1289
1290
1291
		if ($inputData->{$keyPrefix . '-text'} != '') {
			$titleNode->setText($inputData->{$keyPrefix . '-text'});
		}

		switch ($inputData->{$keyPrefix . '-position'}) {
			case 'top':
d62f9945   Benjamin Renard   Improve instant c...
1292
1293
				$titleNode->setPosition(RequestOutputPlotTitlePosition::TOP);
				break;
27317777   Menouard AZIB   J'ai ajouté la fo...
1294
			case 'bottom':
d62f9945   Benjamin Renard   Improve instant c...
1295
1296
1297
				$titleNode->setPosition(RequestOutputPlotTitlePosition::BOTTOM);
				break;
		}
27317777   Menouard AZIB   J'ai ajouté la fo...
1298
1299
1300

		switch ($inputData->{$keyPrefix . '-alignment'}) {
			case 'center':
d62f9945   Benjamin Renard   Improve instant c...
1301
1302
				$titleNode->setAlign(RequestOutputPlotTitleAlign::CENTER);
				break;
27317777   Menouard AZIB   J'ai ajouté la fo...
1303
			case 'left':
d62f9945   Benjamin Renard   Improve instant c...
1304
1305
				$titleNode->setAlign(RequestOutputPlotTitleAlign::LEFT);
				break;
27317777   Menouard AZIB   J'ai ajouté la fo...
1306
			case 'right':
d62f9945   Benjamin Renard   Improve instant c...
1307
1308
				$titleNode->setAlign(RequestOutputPlotTitleAlign::RIGHT);
				break;
26a23052   Benjamin Renard   Add Interval Tick...
1309
		}
27317777   Menouard AZIB   J'ai ajouté la fo...
1310
1311
1312

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

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

26a23052   Benjamin Renard   Add Interval Tick...
1317
1318
	protected function unmarshallLabel($inputData, $keyPrefix, $labelNode)
	{
95ab3cf6   Menouard AZIB   Prise en compte d...
1319
1320
1321
1322
		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 ...
1323
				$labelNode->setFontWeight("bold");
26a23052   Benjamin Renard   Add Interval Tick...
1324
			}
95ab3cf6   Menouard AZIB   Prise en compte d...
1325
1326
			if ($inputData->{$keyPrefix . '-font-italic'}) {
				$labelNode->setFontStyle("italic");
26a23052   Benjamin Renard   Add Interval Tick...
1327
			}
26a23052   Benjamin Renard   Add Interval Tick...
1328
		}
26a23052   Benjamin Renard   Add Interval Tick...
1329
	}
95ab3cf6   Menouard AZIB   Prise en compte d...
1330

26a23052   Benjamin Renard   Add Interval Tick...
1331
1332
	protected function unmarshallFont($inputData, $keyPrefix, $fontNode)
	{
95ab3cf6   Menouard AZIB   Prise en compte d...
1333
1334
1335
1336
1337
		if ($inputData->{$keyPrefix . '-activated'}) {
			$fontNode->setFontName($inputData->{$keyPrefix . '-name'});
			$fontNode->setSize($inputData->{$keyPrefix . '-size'});

			if ($inputData->{$keyPrefix . '-italic'})
26a23052   Benjamin Renard   Add Interval Tick...
1338
1339
1340
				$fontNode->setStyle(RequestOutputPlotFontStyle::ITALIC);
			else
				$fontNode->setStyle(RequestOutputPlotFontStyle::UPRIGHT);
95ab3cf6   Menouard AZIB   Prise en compte d...
1341
1342

			if ($inputData->{$keyPrefix . '-bold'})
26a23052   Benjamin Renard   Add Interval Tick...
1343
1344
1345
1346
1347
				$fontNode->setWeight(RequestOutputPlotFontWeight::BOLD);
			else
				$fontNode->setWeight(RequestOutputPlotFontWeight::MEDIUM);
		}
	}
95ab3cf6   Menouard AZIB   Prise en compte d...
1348

26a23052   Benjamin Renard   Add Interval Tick...
1349
1350
	protected function unmarshallCurve($inputData, $keyPrefix, $curveNode)
	{
95ab3cf6   Menouard AZIB   Prise en compte d...
1351
1352
1353
		switch ($inputData->{$keyPrefix . '-style'}) {

			case 'dot':
26a23052   Benjamin Renard   Add Interval Tick...
1354
1355
				$curveNode->setStyle(RequestOutputPlotCurveStyleEnum::DOT);
				break;
95ab3cf6   Menouard AZIB   Prise en compte d...
1356
			case 'long-spaced-dot':
26a23052   Benjamin Renard   Add Interval Tick...
1357
1358
				$curveNode->setStyle(RequestOutputPlotCurveStyleEnum::LONGSPACEDDOT);
				break;
95ab3cf6   Menouard AZIB   Prise en compte d...
1359
			case 'long-short-dot':
26a23052   Benjamin Renard   Add Interval Tick...
1360
1361
				$curveNode->setStyle(RequestOutputPlotCurveStyleEnum::LONGSHORTDOT);
				break;
95ab3cf6   Menouard AZIB   Prise en compte d...
1362
1363
			case 'plain':
			default:
02abc780   Benjamin Renard   Support request f...
1364
1365
				$curveNode->setStyle(RequestOutputPlotCurveStyleEnum::PLAIN);
				break;
26a23052   Benjamin Renard   Add Interval Tick...
1366
		}
95ab3cf6   Menouard AZIB   Prise en compte d...
1367
1368
1369
1370
1371
1372

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

26a23052   Benjamin Renard   Add Interval Tick...
1375
1376
1377
	protected function unmarshallLine($inputData, $keyPrefix, $lineNode, $lineType)
	{
		$lineNode->setType($lineType);
95ab3cf6   Menouard AZIB   Prise en compte d...
1378
		$this->unmarshallCurve($inputData, $keyPrefix . "-lines", $lineNode);
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 unmarshallSymbol($inputData, $keyPrefix, $symbolNode)
	{
95ab3cf6   Menouard AZIB   Prise en compte d...
1383
1384
		switch ($inputData->{$keyPrefix . '-type'}) {
			case 'dot':
26a23052   Benjamin Renard   Add Interval Tick...
1385
1386
				$symbolNode->setType(RequestOutputPlotSymbolTypeEnum::DOT);
				break;
95ab3cf6   Menouard AZIB   Prise en compte d...
1387
			case 'plus':
26a23052   Benjamin Renard   Add Interval Tick...
1388
1389
				$symbolNode->setType(RequestOutputPlotSymbolTypeEnum::PLUS);
				break;
95ab3cf6   Menouard AZIB   Prise en compte d...
1390
			case 'wildcard':
26a23052   Benjamin Renard   Add Interval Tick...
1391
1392
				$symbolNode->setType(RequestOutputPlotSymbolTypeEnum::WILDCARD);
				break;
95ab3cf6   Menouard AZIB   Prise en compte d...
1393
			case 'circle':
26a23052   Benjamin Renard   Add Interval Tick...
1394
1395
				$symbolNode->setType(RequestOutputPlotSymbolTypeEnum::CIRCLE);
				break;
95ab3cf6   Menouard AZIB   Prise en compte d...
1396
			case 'crux':
26a23052   Benjamin Renard   Add Interval Tick...
1397
1398
				$symbolNode->setType(RequestOutputPlotSymbolTypeEnum::CRUX);
				break;
95ab3cf6   Menouard AZIB   Prise en compte d...
1399
			case 'square':
26a23052   Benjamin Renard   Add Interval Tick...
1400
1401
				$symbolNode->setType(RequestOutputPlotSymbolTypeEnum::SQUARE);
				break;
95ab3cf6   Menouard AZIB   Prise en compte d...
1402
			case 'triangle':
26a23052   Benjamin Renard   Add Interval Tick...
1403
1404
				$symbolNode->setType(RequestOutputPlotSymbolTypeEnum::TRIANGLE);
				break;
95ab3cf6   Menouard AZIB   Prise en compte d...
1405
			case 'crux-in-circle':
26a23052   Benjamin Renard   Add Interval Tick...
1406
1407
				$symbolNode->setType(RequestOutputPlotSymbolTypeEnum::CRUXINCIRCLE);
				break;
95ab3cf6   Menouard AZIB   Prise en compte d...
1408
			case 'dot-in-circle':
26a23052   Benjamin Renard   Add Interval Tick...
1409
1410
				$symbolNode->setType(RequestOutputPlotSymbolTypeEnum::DOTINCIRCLE);
				break;
95ab3cf6   Menouard AZIB   Prise en compte d...
1411
			case 'diamond':
26a23052   Benjamin Renard   Add Interval Tick...
1412
1413
				$symbolNode->setType(RequestOutputPlotSymbolTypeEnum::DIAMOND);
				break;
95ab3cf6   Menouard AZIB   Prise en compte d...
1414
			case 'star':
26a23052   Benjamin Renard   Add Interval Tick...
1415
1416
				$symbolNode->setType(RequestOutputPlotSymbolTypeEnum::STAR);
				break;
95ab3cf6   Menouard AZIB   Prise en compte d...
1417
			case 'david-star':
26a23052   Benjamin Renard   Add Interval Tick...
1418
1419
				$symbolNode->setType(RequestOutputPlotSymbolTypeEnum::DAVIDSTAR);
				break;
95ab3cf6   Menouard AZIB   Prise en compte d...
1420
			case 'full-square':
26a23052   Benjamin Renard   Add Interval Tick...
1421
1422
				$symbolNode->setType(RequestOutputPlotSymbolTypeEnum::FULLSQUARE);
				break;
95ab3cf6   Menouard AZIB   Prise en compte d...
1423
			case 'full-circle':
26a23052   Benjamin Renard   Add Interval Tick...
1424
1425
				$symbolNode->setType(RequestOutputPlotSymbolTypeEnum::FULLCIRCLE);
				break;
95ab3cf6   Menouard AZIB   Prise en compte d...
1426
			case 'full-star':
26a23052   Benjamin Renard   Add Interval Tick...
1427
1428
				$symbolNode->setType(RequestOutputPlotSymbolTypeEnum::FULLSTAR);
				break;
95ab3cf6   Menouard AZIB   Prise en compte d...
1429
			default:
26a23052   Benjamin Renard   Add Interval Tick...
1430
1431
				throw new Exception('Symbol type not implemented.');
		}
95ab3cf6   Menouard AZIB   Prise en compte d...
1432
1433
1434
1435
1436

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

		if ($inputData->{$keyPrefix . '-color'} != 'auto')
			$symbolNode->setColor($this->hexColor2KernelColor($inputData->{$keyPrefix . '-color'}));
26a23052   Benjamin Renard   Add Interval Tick...
1437
1438
1439
1440
1441
1442
1443
	}

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

26a23052   Benjamin Renard   Add Interval Tick...
1448
1449
			return $commonRes;
		}
95ab3cf6   Menouard AZIB   Prise en compte d...
1450

26a23052   Benjamin Renard   Add Interval Tick...
1451
		//Interactive request
22521f1c   Benjamin Renard   First commit
1452
1453
		if (!$data->getSuccess())
			return array(
95ab3cf6   Menouard AZIB   Prise en compte d...
1454
1455
1456
1457
1458
1459
1460
				'success' => false,
				'message' => $data->getLastErrorMessage()
			);

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

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

26a23052   Benjamin Renard   Add Interval Tick...
1465
1466
					$result[] = array(
						"id" => $key,
70e82c1f   Benjamin Renard   Fix doPlot
1467
						"title" => $this->interactivePlotTitle[$key],
05da1b4d   Benjamin Renard   Draw instant plot...
1468
						"preview" => $this->interactivePreview,
26a23052   Benjamin Renard   Add Interval Tick...
1469
						"isInterval" => $this->interactiveTimeSelectionState[$key],
70e82c1f   Benjamin Renard   Fix doPlot
1470
						"index" => $this->interactivePlotIndex[$key],
26a23052   Benjamin Renard   Add Interval Tick...
1471
						"ttFileIndex" => $this->interactiveCrtTTFileIndex,
95ab3cf6   Menouard AZIB   Prise en compte d...
1472
						"context" => IHMPlotContextFileClass::parse($this->getWorkingPath() . $contextResult),
ba82a624   Benjamin Renard   Get kernel execut...
1473
1474
						"plot" => $waitingResult,
						"exectime" => $data->getExecTime(),
ec574794   Benjamin Renard   Implements multip...
1475
						"multiplot" => $this->isMultiPlot,
26a23052   Benjamin Renard   Add Interval Tick...
1476
1477
					);
				}
95ab3cf6   Menouard AZIB   Prise en compte d...
1478

26a23052   Benjamin Renard   Add Interval Tick...
1479
1480
1481
1482
1483
1484
				return array(
					'success'     => true,
					'id'          => $data->getId(),
					'folder'      => $this->getWorkingDirName(),
					'result'      => $result
				);
95ab3cf6   Menouard AZIB   Prise en compte d...
1485
			case ProcessStatusEnumClass::KILLED:
26a23052   Benjamin Renard   Add Interval Tick...
1486
				return array(
95ab3cf6   Menouard AZIB   Prise en compte d...
1487
1488
1489
1490
					'success'     => true,
					'killed'      => true
				);
			default:
e4eba677   Benjamin Renard   Get error message...
1491
				$errorMsg = $data->getErrorMsg();
22521f1c   Benjamin Renard   First commit
1492
				return array(
95ab3cf6   Menouard AZIB   Prise en compte d...
1493
1494
1495
					'success' => false,
					'message'   => 'Request processing error' . (!empty($errorMsg) ? "<br>(" . $errorMsg . ")" : "")
				);
26a23052   Benjamin Renard   Add Interval Tick...
1496
1497
		}
	}
95ab3cf6   Menouard AZIB   Prise en compte d...
1498
1499
1500

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

95ab3cf6   Menouard AZIB   Prise en compte d...
1503
1504
1505
		$r = hexdec(substr($hex, 0, 2));
		$g = hexdec(substr($hex, 2, 2));
		$b = hexdec(substr($hex, 4, 2));
26a23052   Benjamin Renard   Add Interval Tick...
1506

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

ec574794   Benjamin Renard   Implements multip...
1510
	protected function saveIHMRequest($interactiveId, $input)
26a23052   Benjamin Renard   Add Interval Tick...
1511
	{
95ab3cf6   Menouard AZIB   Prise en compte d...
1512
		$path = $this->getWorkingPath() . "ihm.request." . $interactiveId;
26a23052   Benjamin Renard   Add Interval Tick...
1513
		if (!is_dir($this->getWorkingPath()))
95ab3cf6   Menouard AZIB   Prise en compte d...
1514
			mkdir($this->getWorkingPath(), 0777);
22521f1c   Benjamin Renard   First commit
1515
1516
		$file = fopen($path, 'w');
		fwrite($file, json_encode($input));
26a23052   Benjamin Renard   Add Interval Tick...
1517
1518
		fclose($file);
	}
95ab3cf6   Menouard AZIB   Prise en compte d...
1519

ec574794   Benjamin Renard   Implements multip...
1520
	protected function loadIHMRequest($interactiveId)
26a23052   Benjamin Renard   Add Interval Tick...
1521
	{
95ab3cf6   Menouard AZIB   Prise en compte d...
1522
		$path = $this->getWorkingPath() . "ihm.request." . $interactiveId;
22521f1c   Benjamin Renard   First commit
1523
		if (!file_exists($path))
26a23052   Benjamin Renard   Add Interval Tick...
1524
1525
1526
			return NULL;
		return json_decode(file_get_contents($path));
	}
a9d86eaa   Benjamin Renard   Fix zoom / unzoom
1527

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

a9d86eaa   Benjamin Renard   Fix zoom / unzoom
1529
1530
1531

	private function loadZoomList($interactiveId)
	{
95ab3cf6   Menouard AZIB   Prise en compte d...
1532
		$path = $this->getWorkingPath() . "zoom.list." . $interactiveId;
a9d86eaa   Benjamin Renard   Fix zoom / unzoom
1533
1534
1535
1536
1537
1538
1539
		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...
1540
		$path = $this->getWorkingPath() . "zoom.list." . $interactiveId;
a9d86eaa   Benjamin Renard   Fix zoom / unzoom
1541
		if (!is_dir($this->getWorkingPath()))
95ab3cf6   Menouard AZIB   Prise en compte d...
1542
			mkdir($this->getWorkingPath(), 0777);
a9d86eaa   Benjamin Renard   Fix zoom / unzoom
1543
1544
1545
1546
		$file = fopen($path, 'w');
		fwrite($file, json_encode($zoomList));
		fclose($file);
	}
95ab3cf6   Menouard AZIB   Prise en compte d...
1547

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

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

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

		switch ($actionInput->{'action'}) {
			case 'zoom':
e8cefd97   Benjamin Renard   Interactive attac...
1559
				return $this->unmarshallZoom($actionInput, $plotInput);
95ab3cf6   Menouard AZIB   Prise en compte d...
1560
1561
			case 'forward':
			case 'halfforward':
2366956c   Erdogan Furkan   10312 - Navigatio...
1562
			case 'quarterforward':
95ab3cf6   Menouard AZIB   Prise en compte d...
1563
1564
			case 'backward':
			case 'halfbackward':
2366956c   Erdogan Furkan   10312 - Navigatio...
1565
			case 'quarterbackward':
95ab3cf6   Menouard AZIB   Prise en compte d...
1566
1567
			case 'extend':
			case 'shift':
e8cefd97   Benjamin Renard   Interactive attac...
1568
				return $this->unmarshallNavigation($actionInput, $plotInput);
95ab3cf6   Menouard AZIB   Prise en compte d...
1569
			case 'goto':
e8cefd97   Benjamin Renard   Interactive attac...
1570
				return $this->unmarshallTTGoto($actionInput, $plotInput);
95ab3cf6   Menouard AZIB   Prise en compte d...
1571
			case 'instant':
05da1b4d   Benjamin Renard   Draw instant plot...
1572
				return $this->unmarshallInstant($actionInput, $plotInput);
95ab3cf6   Menouard AZIB   Prise en compte d...
1573
			case 'undozoom':
d3c3608d   Benjamin Renard   Add undo zoom
1574
				return $this->unmarshallUndoZoom($actionInput, $plotInput);
ff8f5cff   Menouard AZIB   Une petite refact...
1575
			case RequestOutPutPlotElementPlotFunctionNodeClass::REQUESTOUTPUTPLOTELEMENT_PLOTFUNCTION_NAME:
27317777   Menouard AZIB   J'ai ajouté la fo...
1576
				return $this->unmarshallPlotFunction($actionInput, $plotInput);
95ab3cf6   Menouard AZIB   Prise en compte d...
1577
			default:
26a23052   Benjamin Renard   Add Interval Tick...
1578
1579
1580
				throw new Exception('Interactive action not implemented.');
		}
	}
95ab3cf6   Menouard AZIB   Prise en compte d...
1581

d3c3608d   Benjamin Renard   Add undo zoom
1582
1583
1584
1585
	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...
1586

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

		if (!isset($zoomList)) {
d3c3608d   Benjamin Renard   Add undo zoom
1590
			//Init zoom list
95ab3cf6   Menouard AZIB   Prise en compte d...
1591
			$zoomList = (object)array(
a9d86eaa   Benjamin Renard   Fix zoom / unzoom
1592
				'times' => array(),
95ab3cf6   Menouard AZIB   Prise en compte d...
1593
				'panels' => (object)array()
d3c3608d   Benjamin Renard   Add undo zoom
1594
1595
			);
		}
95ab3cf6   Menouard AZIB   Prise en compte d...
1596
1597

		if ($input->{'axeId'} == 'timeAxis') {
d3c3608d   Benjamin Renard   Add undo zoom
1598
			if ($isInterval)
95ab3cf6   Menouard AZIB   Prise en compte d...
1599
				array_push($zoomList->times, (object)array(
d3c3608d   Benjamin Renard   Add undo zoom
1600
1601
1602
1603
1604
					'isInterval' => true,
					'min' => $minOrFileIndex,
					'max'  => $maxOrIntervalIndex
				));
			else
95ab3cf6   Menouard AZIB   Prise en compte d...
1605
1606
1607
1608
				array_push($zoomList->times, (object)array(
					'isInterval' => false,
					'ttFileIndex' => $minOrFileIndex,
					'intIndex'  => $maxOrIntervalIndex
d3c3608d   Benjamin Renard   Add undo zoom
1609
				));
95ab3cf6   Menouard AZIB   Prise en compte d...
1610
1611
1612
1613
		} else {
			if (!isset($zoomList->panels->{$input->{'panelId'}})) {
				$zoomList->panels->{$input->{'panelId'}} = (object) array(
					'axes' => (object)array()
d3c3608d   Benjamin Renard   Add undo zoom
1614
1615
				);
			}
95ab3cf6   Menouard AZIB   Prise en compte d...
1616
1617

			if (!isset($zoomList->panels->{$input->{'panelId'}}->axes->{$input->{'axeId'}})) {
a9d86eaa   Benjamin Renard   Fix zoom / unzoom
1618
				$zoomList->panels->{$input->{'panelId'}}->axes->{$input->{'axeId'}} = array();
d3c3608d   Benjamin Renard   Add undo zoom
1619
			}
95ab3cf6   Menouard AZIB   Prise en compte d...
1620
1621
1622
1623

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

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

a9d86eaa   Benjamin Renard   Fix zoom / unzoom
1630
	private function resetZoomList($interactiveId, $resetOnlyTimeZoom = false)
d3c3608d   Benjamin Renard   Add undo zoom
1631
	{
a9d86eaa   Benjamin Renard   Fix zoom / unzoom
1632
		if (!$resetOnlyTimeZoom) {
95ab3cf6   Menouard AZIB   Prise en compte d...
1633
			$zoomList = (object)array(
a9d86eaa   Benjamin Renard   Fix zoom / unzoom
1634
				'times' => array(),
95ab3cf6   Menouard AZIB   Prise en compte d...
1635
				'panels' => (object)array()
a9d86eaa   Benjamin Renard   Fix zoom / unzoom
1636
			);
95ab3cf6   Menouard AZIB   Prise en compte d...
1637
		} else {
a9d86eaa   Benjamin Renard   Fix zoom / unzoom
1638
1639
1640
1641
1642
			$zoomList = $this->loadZoomList($interactiveId);
			$zoomList->times = array();
		}

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

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

d3c3608d   Benjamin Renard   Add undo zoom
1649
		$result = NULL;
95ab3cf6   Menouard AZIB   Prise en compte d...
1650
1651
		if ($zoomList) {
			if ($input->{'axeId'} == 'timeAxis') {
a9d86eaa   Benjamin Renard   Fix zoom / unzoom
1652
				if (count($zoomList->times) <= 0)
d3c3608d   Benjamin Renard   Add undo zoom
1653
					return NULL;
95ab3cf6   Menouard AZIB   Prise en compte d...
1654
1655
				$result = array_pop($zoomList->times);
			} else {
a9d86eaa   Benjamin Renard   Fix zoom / unzoom
1656
				if (!isset($zoomList->panels->{$input->{'panelId'}}))
d3c3608d   Benjamin Renard   Add undo zoom
1657
					return NULL;
95ab3cf6   Menouard AZIB   Prise en compte d...
1658

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

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

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

d3c3608d   Benjamin Renard   Add undo zoom
1669
1670
		return $result;
	}
95ab3cf6   Menouard AZIB   Prise en compte d...
1671

d3c3608d   Benjamin Renard   Add undo zoom
1672
	private function unmarshallZoom($input, $plotInput, $isUndo = false)
26a23052   Benjamin Renard   Add Interval Tick...
1673
	{
95ab3cf6   Menouard AZIB   Prise en compte d...
1674
		if ($input->{'axeId'} == 'timeAxis') {
26a23052   Benjamin Renard   Add Interval Tick...
1675
			//Zoom on Time Axis
95ab3cf6   Menouard AZIB   Prise en compte d...
1676
			if ($plotInput->{'timesrc'} != 'Interval') {
a9d86eaa   Benjamin Renard   Fix zoom / unzoom
1677
				$plotInput->{'timesrc'} = 'Interval';
7d84634e   Benjamin Renard   Fix plot request ...
1678
				if (!$isUndo)
95ab3cf6   Menouard AZIB   Prise en compte d...
1679
1680
1681
1682
1683
1684
1685
					$this->addZoomInList(
						$input,
						false,
						isset($plotInput->{'ttFileIndex'}) ? $plotInput->{'ttFileIndex'} : 0,
						isset($plotInput->{'intIndex'}) ? $plotInput->{'intIndex'} : 0
					);
			} else {
7d84634e   Benjamin Renard   Fix plot request ...
1686
				if (!$isUndo)
95ab3cf6   Menouard AZIB   Prise en compte d...
1687
					$this->addZoomInList($input, true, $plotInput->{'startDate'}, $plotInput->{'stopDate'});
26a23052   Benjamin Renard   Add Interval Tick...
1688
			}
a9d86eaa   Benjamin Renard   Fix zoom / unzoom
1689
1690
			$plotInput->{'startDate'} = $input->{'min'};
			$plotInput->{'stopDate'} = $input->{'max'};
95ab3cf6   Menouard AZIB   Prise en compte d...
1691

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

26a23052   Benjamin Renard   Add Interval Tick...
1697
		//Digital axis zoom
95ab3cf6   Menouard AZIB   Prise en compte d...
1698
1699
1700
1701
		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...
1702
						$axis->{'axis-range-extend'} = false;
d3c3608d   Benjamin Renard   Add undo zoom
1703
1704
						$oldMin = $axis->{'axis-range-min'};
						$oldMax = $axis->{'axis-range-max'};
26a23052   Benjamin Renard   Add Interval Tick...
1705
1706
						$axis->{'axis-range-min'} = $input->{'min'};
						$axis->{'axis-range-max'} = $input->{'max'};
a9d86eaa   Benjamin Renard   Fix zoom / unzoom
1707
						$this->saveIHMRequest($input->interactiveId, $plotInput);
26a23052   Benjamin Renard   Add Interval Tick...
1708
1709
						//Do not save 'force-single-replot' in request file!
						$plotInput->{'force-single-replot'} = true;
d3c3608d   Benjamin Renard   Add undo zoom
1710
1711
						$plotInput->{'force-time-zoom-reset'} = false;
						if (!$isUndo)
95ab3cf6   Menouard AZIB   Prise en compte d...
1712
							$this->addZoomInList($input, true, $oldMin, $oldMax);
26a23052   Benjamin Renard   Add Interval Tick...
1713
1714
1715
1716
1717
1718
1719
1720
						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...
1721

d3c3608d   Benjamin Renard   Add undo zoom
1722
1723
1724
	private function unmarshallUndoZoom($input, $plotInput)
	{
		$result = $this->undoZoomInList($input);
95ab3cf6   Menouard AZIB   Prise en compte d...
1725
1726
1727
		if ($result != NULL) {
			if (isset($result->isInterval)) {
				if (!$result->isInterval) {
d3c3608d   Benjamin Renard   Add undo zoom
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
					$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...
1739

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

26a23052   Benjamin Renard   Add Interval Tick...
1745
1746
1747
1748
1749
		//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...
1750
1751
1752

		switch ($input->{'action'}) {
			case 'forward':
26a23052   Benjamin Renard   Add Interval Tick...
1753
1754
1755
				$startTimeStamp += $duration;
				$stopTimeStamp  += $duration;
				break;
95ab3cf6   Menouard AZIB   Prise en compte d...
1756
1757
1758
			case 'halfforward':
				$startTimeStamp += ($duration / 2);
				$stopTimeStamp  += ($duration / 2);
26a23052   Benjamin Renard   Add Interval Tick...
1759
				break;
2366956c   Erdogan Furkan   10312 - Navigatio...
1760
1761
1762
1763
			case 'quarterforward':
				$startTimeStamp += ($duration / 4);
				$stopTimeStamp  += ($duration / 4);
				break;
95ab3cf6   Menouard AZIB   Prise en compte d...
1764
			case 'backward':
26a23052   Benjamin Renard   Add Interval Tick...
1765
1766
1767
				$startTimeStamp -= $duration;
				$stopTimeStamp  -= $duration;
				break;
95ab3cf6   Menouard AZIB   Prise en compte d...
1768
1769
1770
			case 'halfbackward':
				$startTimeStamp -= ($duration / 2);
				$stopTimeStamp  -= ($duration / 2);
26a23052   Benjamin Renard   Add Interval Tick...
1771
				break;
2366956c   Erdogan Furkan   10312 - Navigatio...
1772
1773
1774
1775
			case 'quarterbackward':
				$startTimeStamp -= ($duration / 4);
				$stopTimeStamp  -= ($duration / 4);
				break;
95ab3cf6   Menouard AZIB   Prise en compte d...
1776
			case 'extend':
26a23052   Benjamin Renard   Add Interval Tick...
1777
1778
1779
				$startTimeStamp -= $input->{'duration'};
				$stopTimeStamp  += $input->{'duration'};
				break;
95ab3cf6   Menouard AZIB   Prise en compte d...
1780
			case 'shift':
26a23052   Benjamin Renard   Add Interval Tick...
1781
1782
1783
1784
				$startTimeStamp += $input->{'duration'};
				$stopTimeStamp  += $input->{'duration'};
				break;
		}
95ab3cf6   Menouard AZIB   Prise en compte d...
1785

26a23052   Benjamin Renard   Add Interval Tick...
1786
1787
		if ($stopTimeStamp - $startTimeStamp <= 0)
			throw new Exception('New duration is lower than 0.');
95ab3cf6   Menouard AZIB   Prise en compte d...
1788
1789
1790
1791

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

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

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

26a23052   Benjamin Renard   Add Interval Tick...
1801
1802
	private function unmarshallTTGoto($input, $plotInput)
	{
419a700b   Benjamin Renard   Fix TT goto
1803
1804
1805
		$plotInput->{'timesrc'} = 'TimeTable';
		$plotInput->{'ttFileIndex'} = $input->{'ttFileIndex'};
		$plotInput->{'intIndex'} = $input->{'intIndex'};
95ab3cf6   Menouard AZIB   Prise en compte d...
1806

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

05da1b4d   Benjamin Renard   Draw instant plot...
1812
1813
	private function unmarshallInstant($input, $plotInput)
	{
05da1b4d   Benjamin Renard   Draw instant plot...
1814
1815
		//Find current panel
		$crtPanel = NULL;
95ab3cf6   Menouard AZIB   Prise en compte d...
1816
1817
		foreach ($plotInput->{'panels'} as $panel) {
			if ($input->{'panelId'} == $panel->{'id'}) {
05da1b4d   Benjamin Renard   Draw instant plot...
1818
1819
1820
1821
				$crtPanel = $panel;
				break;
			}
		}
95ab3cf6   Menouard AZIB   Prise en compte d...
1822

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

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

05da1b4d   Benjamin Renard   Draw instant plot...
1829
1830
		//Find spectra parameter
		$crtParam = NULL;
95ab3cf6   Menouard AZIB   Prise en compte d...
1831
1832
1833
		foreach ($crtPanel->{'params'} as $param) {
			if ($param->{'param-drawing-type'} == 'spectro') {
				$crtParam = $param;
05da1b4d   Benjamin Renard   Draw instant plot...
1834
1835
1836
				break;
			}
		}
95ab3cf6   Menouard AZIB   Prise en compte d...
1837

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

05da1b4d   Benjamin Renard   Draw instant plot...
1841
1842
		//Find table Y-axis
		$crtYAxis = NULL;
95ab3cf6   Menouard AZIB   Prise en compte d...
1843
1844
		foreach ($crtPanel->{'axes'} as $axis) {
			if ($crtParam->{'param-drawing-object'}->{'spectro-yaxis'} == $axis->{'id'}) {
05da1b4d   Benjamin Renard   Draw instant plot...
1845
1846
1847
1848
				$crtYAxis = $axis;
				break;
			}
		}
95ab3cf6   Menouard AZIB   Prise en compte d...
1849

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

05da1b4d   Benjamin Renard   Draw instant plot...
1853
1854
		//Find color Z-axis
		$crtColorAxis = NULL;
95ab3cf6   Menouard AZIB   Prise en compte d...
1855
1856
		foreach ($crtPanel->{'axes'} as $axis) {
			if ($axis->{'id'} == 'color') {
05da1b4d   Benjamin Renard   Draw instant plot...
1857
1858
1859
1860
				$crtColorAxis = $axis;
				break;
			}
		}
95ab3cf6   Menouard AZIB   Prise en compte d...
1861

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

05da1b4d   Benjamin Renard   Draw instant plot...
1865
1866
		date_default_timezone_set('UTC');
		$timeStamp = strtotime($input->time);
95ab3cf6   Menouard AZIB   Prise en compte d...
1867
1868

		$instantPlotInput = (object)array(
05da1b4d   Benjamin Renard   Draw instant plot...
1869
1870
1871
1872
			"interactive-preview" => true,
			"file-format" => "PNG",
			"file-output" => "INTERACTIVE",
			"file-prefix" => "instant",
05da1b4d   Benjamin Renard   Draw instant plot...
1873
			"timesrc" => "Interval",
703f403f   Benjamin Renard   Fix some bugs wit...
1874
1875
			"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...
1876
			"id" => 1,
c2d88cc5   Benjamin Renard   Fix instant plot
1877
1878
1879
1880
1881
			"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...
1882
			"page-layout-type" => "vertical",
95ab3cf6   Menouard AZIB   Prise en compte d...
1883
			"page-layout-object" => (object)array(
05da1b4d   Benjamin Renard   Draw instant plot...
1884
				"layout-expand" => true,
95ab3cf6   Menouard AZIB   Prise en compte d...
1885
				"layout-panel-height" => 0.5,
05da1b4d   Benjamin Renard   Draw instant plot...
1886
1887
1888
1889
				"layout-panel-spacing" => 0.05
			),
			"panels" => array()
		);
27317777   Menouard AZIB   J'ai ajouté la fo...
1890
1891
1892
1893
1894
1895
1896
1897
1898
1899
1900
1901
1902
1903
1904
1905
1906
1907
1908
1909
1910
1911
1912
1913

		$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...
1914
		);
27317777   Menouard AZIB   J'ai ajouté la fo...
1915
1916
1917
1918
1919
1920
1921
1922
1923
1924
1925
1926

		$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...
1927
1928
1929
		);
		$instantPanel->{"axes"}[] = $instantXAxis;
		$instantPanel->{"axes"}[] = $instantYAxis;
95ab3cf6   Menouard AZIB   Prise en compte d...
1930
1931

		$instantParam = (object)array(
05da1b4d   Benjamin Renard   Draw instant plot...
1932
			"id" => 1,
e4545ed5   Benjamin Renard   Implement templat...
1933
			"paramid" => $crtParam->{'paramid'},
8d780912   Benjamin Renard   Keep template arg...
1934
			"template_args" => $crtParam->{'template_args'},
05da1b4d   Benjamin Renard   Draw instant plot...
1935
			"param-drawing-type" => "iserie",
27317777   Menouard AZIB   J'ai ajouté la fo...
1936
1937
1938
1939
1940
1941
			"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
1942
			),
95ab3cf6   Menouard AZIB   Prise en compte d...
1943
1944
1945
1946
1947
1948
1949
1950
1951
1952
1953
1954
1955
1956
1957
			"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
1958

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

0a87e436   Hacene SI HADJ MOHAND   parameters resolue
1962

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


05da1b4d   Benjamin Renard   Draw instant plot...
1966
1967
		return $instantPlotInput;
	}
27317777   Menouard AZIB   J'ai ajouté la fo...
1968

0cea6b06   Menouard AZIB   Set preview font ...
1969
1970
1971
1972
1973
1974
1975
1976
1977
	/**
	 * 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...
1978
1979
	private function unmarshallPlotFunction($input, $plotInput)
	{
27317777   Menouard AZIB   J'ai ajouté la fo...
1980
1981
		date_default_timezone_set('UTC');
		$timeStamp = strtotime($input->starttime);
703f403f   Benjamin Renard   Fix some bugs wit...
1982
		$DATE_TYPE = "Y-m-d\TH:i:s";
27317777   Menouard AZIB   J'ai ajouté la fo...
1983
1984
1985
		$start_time_plotfunction = date($DATE_TYPE, $timeStamp);
		$timestamp_stop_plotfunction  = strtotime($input->stoptime);
		$stop_time_plotfunction = date($DATE_TYPE, $timestamp_stop_plotfunction);
d22a300e   Menouard AZIB   It's Hard IHMInpu...
1986
1987
1988
1989
1990
1991
		$plotInput->{"startDate"} = $start_time_plotfunction;
		$plotInput->{"stopDate"} = $stop_time_plotfunction;
		$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 ...
1992
1993
1994
1995
1996
1997
1998
1999
		$plotInput->{"page-layout-type"} = "vertical";
		$plotInput->{"page-layout-object"} =  (object)array(
			"layout-expand" => true,
			"layout-panel-height" => 0.5,
			"layout-panel-spacing" => 0.05
		);

		
27317777   Menouard AZIB   J'ai ajouté la fo...
2000

d22a300e   Menouard AZIB   It's Hard IHMInpu...
2001
2002
2003
2004
		foreach ($plotInput->{'panels'} as $panel) {
			if ($input->{'panelId'} == $panel->{'id'}) {
				if ($panel->{'panel-plot-type'} !== 'timePlot')
					throw new Exception('Plot Function action only available for Time plot.');
ed439757   Menouard AZIB   change unmarshall...
2005

d22a300e   Menouard AZIB   It's Hard IHMInpu...
2006
2007
				$panel->{RequestOutPutPlotElementPlotFunctionNodeClass::PLOT_FUNCTION_ABSCISSE} = $input->abscisse;
				$panel->{RequestOutPutPlotElementPlotFunctionNodeClass::PLOT_FUNCTION_TYPE} = $input->type;
328140af   Benjamin Renard   Restore FFT
2008
2009
				$scale_abscisse = $input->scale_abscisse;
				$scale_ordonnee = $input->scale_ordonnee;
d22a300e   Menouard AZIB   It's Hard IHMInpu...
2010
				$panel->{'panel-plot-type'} = RequestOutPutPlotElementPlotFunctionNodeClass::REQUESTOUTPUTPLOTELEMENT_PLOTFUNCTION_NAME;
0cea6b06   Menouard AZIB   Set preview font ...
2011
2012
2013
				$panel->{"panel-title-font-activated"} = TRUE;
				$panel->{"panel-title-font-size"} = 12;
				$panel->{"panel-title-font-bold"} = TRUE;
328140af   Benjamin Renard   Restore FFT
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
2027
2028
2029
2030
2031
2032
2033
2034
2035
2036
2037
2038
2039
2040
2041
2042
2043
2044
2045
2046
2047
2048
2049
2050
2051
2052
2053
2054
2055
2056
2057
2058
2059
2060
2061
2062
2063
2064
2065
2066
2067
2068
2069
2070
2071
2072
2073
2074
2075
2076

				/**
				 * @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...
2077
				$panel->{"axes"} = [];
328140af   Benjamin Renard   Restore FFT
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
				/**
				 * @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 ...
2119
2120
2121
2122
				$this->setPlotPreviewFont($plotFctXAxisDigital);
				$this->setPlotPreviewFont($plotFctYAxis);
				$this->setPlotPreviewFont($plotFctXAxisTime);

328140af   Benjamin Renard   Restore FFT
2123
2124
2125
2126
2127
2128
2129
2130
2131
2132
2133
2134
2135
2136
2137
2138
2139
				/**
				 * 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;

d22a300e   Menouard AZIB   It's Hard IHMInpu...
2140
				break;
28c6d6c5   Menouard AZIB   Enable plot fucnt...
2141
			} 
27317777   Menouard AZIB   J'ai ajouté la fo...
2142
2143
		}

d22a300e   Menouard AZIB   It's Hard IHMInpu...
2144
		return $plotInput;
27317777   Menouard AZIB   J'ai ajouté la fo...
2145
	}
0cea6b06   Menouard AZIB   Set preview font ...
2146

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