Blame view

src/ParamOutputImpl/Plot/PanelPlotOutput.cc 135 KB
fbe3c2bb   Benjamin Renard   First commit
1
2
3
4
5
6
7
8
/*
 * PanelPlotOutput.cc
 *
 *  Created on: 29 oct. 2013
 *      Author: CS
 */

#include "PanelPlotOutput.hh"
ba6124b0   Menouard AZIB   Add parameter id ...
9
#include "Catalog.hh"
fbe3c2bb   Benjamin Renard   First commit
10
#include "ColorAxis.hh"
ba6124b0   Menouard AZIB   Add parameter id ...
11
12
#include "ColormapManager.hh"
#include "DecoratorPlot.hh"
fbe3c2bb   Benjamin Renard   First commit
13
#include "Page.hh"
f43341e7   Menouard AZIB   Improve the conte...
14
#include "DataSetMgr.hh"
fbe3c2bb   Benjamin Renard   First commit
15
#include "ParamMgr.hh"
ba6124b0   Menouard AZIB   Add parameter id ...
16
#include "ParameterManager.hh"
f6eaec4e   Benjamin Renard   Optimize plot ele...
17
#include "PlPlotUtil.hh"
ba6124b0   Menouard AZIB   Add parameter id ...
18
19
#include "PlotLogger.hh"
#include "ShadesTools.hh"
eddfb311   Erdogan Furkan   9326 - Modificita...
20
#include "TimeTableCatalogFactory.hh"
ba6124b0   Menouard AZIB   Add parameter id ...
21
#include "TimeUtil.hh"
d78eca08   Menouard AZIB   Fill AMDA_... cor...
22
23
#include "AMDA-Kernel_Config.hh"
#include "Properties.hh"
8bb0f02b   Benjamin Renard   Set colors in axi...
24
#include <boost/range/adaptor/reversed.hpp>
f43341e7   Menouard AZIB   Improve the conte...
25
#include <boost/algorithm/string/replace.hpp>
ba6124b0   Menouard AZIB   Add parameter id ...
26
#include <string>
7fb3da6b   Menouard AZIB   Add Request time ...
27
#include <ctime>
4c184d91   Menouard AZIB   Delete data file ...
28
#include<stdio.h>
fbe3c2bb   Benjamin Renard   First commit
29
30
31
32

using namespace AMDA::Parameters;
using namespace AMDA::Info;

d78eca08   Menouard AZIB   Fill AMDA_... cor...
33

ba6124b0   Menouard AZIB   Add parameter id ...
34
namespace plot
fbe3c2bb   Benjamin Renard   First commit
35
{
ba6124b0   Menouard AZIB   Add parameter id ...
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50

	/**
	 * Width character proportion is approximatively 0.83 times smaller than height.
	 */
	const float PanelPlotOutput::CHAR_RATIO = 5. / 6.;

	const float PanelPlotOutput::DEFAULT_TICK_LENGTH_FACTOR = 0.75;

	// Vertical is for Y axis.
	const float PanelPlotOutput::VERTICAL_TICK_LENGTH_LIMIT = 0.5;
	// Horizontal is for X axis.
	const float PanelPlotOutput::HORIZONTAL_TICK_LENGTH_LIMIT = 0.75;
	// margin in case of constante curve
	const float YAXISMARGIN = 0.05;

1d1a3b8a   Erdogan Furkan   Done for tickPlot...
51
52
53
54
55
56
57
58
59
60
	PanelPlotOutput::PanelPlotOutput(AMDA::Parameters::ParameterManager &manager, boost::shared_ptr<Panel> panel, bool isStandalone) : 
									_panel(panel),
									_parameterManager(manager),
									_pParameterValues(NULL),
									_timeIntervalListPtr(NULL),
									_panelPlotXYRatio(1),
									_leftAxisTickMarkWidth(0),
									_automaticSerieColorCursor(0),
									_isStandalone(isStandalone),
									_isHeightFixed(false)
fbe3c2bb   Benjamin Renard   First commit
61
	{
ba6124b0   Menouard AZIB   Add parameter id ...
62
63
64
65
66
	}

	PanelPlotOutput::~PanelPlotOutput()
	{
	}
fbe3c2bb   Benjamin Renard   First commit
67

ba6124b0   Menouard AZIB   Add parameter id ...
68
69
70
71
72
	double getVerticalTickLength(Axis *pAxis, double charHeight)
	{
		float horizontalTickLengthLimit = PanelPlotOutput::HORIZONTAL_TICK_LENGTH_LIMIT;
		float defaultTickLengthFactor = PanelPlotOutput::DEFAULT_TICK_LENGTH_FACTOR;
		double tickLengthFactor = pAxis->_tick._lengthFactor;
fbe3c2bb   Benjamin Renard   First commit
73

d78eca08   Menouard AZIB   Fill AMDA_... cor...
74
		if ((!isNAN(tickLengthFactor)) && (tickLengthFactor > horizontalTickLengthLimit))
ba6124b0   Menouard AZIB   Add parameter id ...
75
76
77
78
		{
			// 1 character size is equal to 0.75 tick length.
			return charHeight + (((tickLengthFactor - horizontalTickLengthLimit) * charHeight) / (defaultTickLengthFactor));
		}
d78eca08   Menouard AZIB   Fill AMDA_... cor...
79
		else if ((isNAN(tickLengthFactor)) && (defaultTickLengthFactor > horizontalTickLengthLimit))
ba6124b0   Menouard AZIB   Add parameter id ...
80
81
82
83
84
85
86
87
		{
			// 1 character size is equal to 0.75 tick length.
			return charHeight + (((defaultTickLengthFactor - horizontalTickLengthLimit) * charHeight) / (defaultTickLengthFactor));
		}
		else
		{
			return charHeight;
		}
fbe3c2bb   Benjamin Renard   First commit
88
89
	}

ba6124b0   Menouard AZIB   Add parameter id ...
90
91
92
93
94
	double getHorizontalTickLength(Axis *pAxis, double charHeight)
	{
		float verticalTickLengthLimit = PanelPlotOutput::VERTICAL_TICK_LENGTH_LIMIT;
		float defaultTickLengthFactor = PanelPlotOutput::DEFAULT_TICK_LENGTH_FACTOR;
		double tickLengthFactor = pAxis->_tick._lengthFactor;
fbe3c2bb   Benjamin Renard   First commit
95

d78eca08   Menouard AZIB   Fill AMDA_... cor...
96
		if ((!isNAN(tickLengthFactor)) && (tickLengthFactor > verticalTickLengthLimit))
ba6124b0   Menouard AZIB   Add parameter id ...
97
98
99
100
		{
			// 1 character size is equal to 0.75 tick length.
			return charHeight + (((tickLengthFactor - verticalTickLengthLimit) * charHeight * PanelPlotOutput::CHAR_RATIO) / (defaultTickLengthFactor));
		}
d78eca08   Menouard AZIB   Fill AMDA_... cor...
101
		else if ((isNAN(tickLengthFactor)) && (defaultTickLengthFactor > verticalTickLengthLimit))
ba6124b0   Menouard AZIB   Add parameter id ...
102
103
104
105
106
107
108
109
110
		{
			// 1 character size is equal to 0.75 tick length.
			return charHeight + (((defaultTickLengthFactor - verticalTickLengthLimit) * charHeight * PanelPlotOutput::CHAR_RATIO) / (defaultTickLengthFactor));
		}
		else
		{
			return charHeight;
		}
	}
fbe3c2bb   Benjamin Renard   First commit
111

ba6124b0   Menouard AZIB   Add parameter id ...
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
	void PanelPlotOutput::calculatePlotArea(const Bounds & /*panelBounds_*/, Bounds &bounds_)
	{
		double topSpace = 0;
		double bottomSpace = 0;
		double leftSpace = 0;
		double rightSpace = 0;

		// Init
		_plotAreaSideSet[PlotCommon::Position::POS_TOP] = false;
		_plotAreaSideSet[PlotCommon::Position::POS_BOTTOM] = false;
		_plotAreaSideSet[PlotCommon::Position::POS_RIGHT] = false;
		_plotAreaSideSet[PlotCommon::Position::POS_LEFT] = false;
		_plotAreaSideSet[PlotCommon::Position::POS_CENTER] = false;

		// Reserve space for title
		double titleHeight = 0;
		_panel->reserveSpaceForTitle(topSpace, bottomSpace, titleHeight);

		// Reserve space for axes

		//
		std::map<PlotCommon::Position, int> nbAxesBySide;
		nbAxesBySide[PlotCommon::Position::POS_TOP] = 0;
		nbAxesBySide[PlotCommon::Position::POS_BOTTOM] = 0;
		nbAxesBySide[PlotCommon::Position::POS_RIGHT] = 0;
		nbAxesBySide[PlotCommon::Position::POS_LEFT] = 0;
		for (Axes::iterator it = _panel->_axes.begin(); it != _panel->_axes.end(); ++it)
		{
			boost::shared_ptr<Axis> lAxis = it->second;
			if ((lAxis == nullptr) || (lAxis->_isZAxis) || (!lAxis->_used) || (!lAxis->_visible) || (lAxis->_position == PlotCommon::Position::POS_CENTER))
				continue;
			++nbAxesBySide[lAxis->_position];
		}
62024e03   Erdogan Furkan   Some modifications
145

ba6124b0   Menouard AZIB   Add parameter id ...
146
147
148
149
150
151
152
153
154
		// ZAxis must be drawn at last!
		for (Axes::iterator it = _panel->_axes.begin(); it != _panel->_axes.end(); ++it)
		{
			// Add X and Y axis
			boost::shared_ptr<Axis> lAxis = it->second;
			if ((lAxis == nullptr) || (lAxis->_isZAxis))
				continue;
			reserveSpaceForAxis(lAxis, titleHeight, nbAxesBySide, topSpace, bottomSpace, leftSpace, rightSpace);
		}
f6eaec4e   Benjamin Renard   Optimize plot ele...
155

ba6124b0   Menouard AZIB   Add parameter id ...
156
157
158
159
160
161
162
163
		for (Axes::iterator it = _panel->_axes.begin(); it != _panel->_axes.end(); ++it)
		{
			// Add Z axis
			boost::shared_ptr<Axis> lAxis = it->second;
			if ((lAxis == nullptr) || (!lAxis->_isZAxis))
				continue;
			reserveSpaceForAxis(lAxis, titleHeight, nbAxesBySide, topSpace, bottomSpace, leftSpace, rightSpace);
		}
fbe3c2bb   Benjamin Renard   First commit
164

ba6124b0   Menouard AZIB   Add parameter id ...
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
		// Get character size for panel.
		PlPlotUtil::setPlFont(_panel->getFont());
		CharSize lCharSizePanel = PlPlotUtil::getCharacterSizeInPlPage(_panel->_page);
		double panelCharWidth = lCharSizePanel.first;
		double panelCharHeight = lCharSizePanel.second;

		// add params legend right space when outside
		if (!_panel->_paramsLegendProperties.getLegendLines().empty() &&
			_panel->_paramsLegendProperties.isVisible() &&
			(_panel->_paramsLegendProperties.getPosition() == ParamsLegendPosition::POS_OUTSIDE))
		{
			PlPlotUtil::setPlFont(_panel->_paramsLegendProperties.getFont());
			CharSize lCharSizeLegend = PlPlotUtil::getCharacterSizeInPlPage(_panel->_page);
			double legendCharWidth = lCharSizeLegend.first;

			// set offset
			_panel->_paramsLegendProperties.setLeftOffset(rightSpace);

			// reserve place for legend
			rightSpace += _panel->_paramsLegendProperties.getEstimateWidth(legendCharWidth);
		}

		// Reserve space for text legend ( maximum 1 text legend by position
		/*bool	leftTextLegendFound		= false;
		bool	rightTextLegendFound 	= false;
		bool	topTextLegendFound 		= false;
		bool	bottomTextLegendFound 	= false; */

		for (auto textLegendProp : _panel->_textLegendPropertiesList)
		{
			bool toDraw = true;

			/*	switch (textLegendProp->getPosition()) {
				case TextLegendPosition::POS_LEFT :
					if (leftTextLegendFound)
						toDraw = false;
					leftTextLegendFound = true;
					break;
				case TextLegendPosition::POS_RIGHT :
					if (rightTextLegendFound)
						toDraw = false;
					rightTextLegendFound = true;
					break;
				case TextLegendPosition::POS_TOP :
					if (topTextLegendFound)
						toDraw = false;
					topTextLegendFound = true;
					break;
				case TextLegendPosition::POS_BOTTOM :
					if (bottomTextLegendFound)
						toDraw = false;
					bottomTextLegendFound = true;
					break;

			}*/

			if (toDraw)
				reserveSpaceForTextLegend(textLegendProp, titleHeight, topSpace, bottomSpace, leftSpace, rightSpace);
		}

		// Set specified left, right, top and bottom margins and display a warning
		// message if computed margins are bigger than specified ones
		if (_panel->_leftMargin != -1)
		{
			if ((_panel->_leftMargin * panelCharWidth) < leftSpace)
				LOG4CXX_WARN(gLogger, "Left margin for the panel was forced beyond computed size");
			leftSpace = _panel->_leftMargin * panelCharWidth;
		}
		if (_panel->_rightMargin != -1)
		{
			if ((_panel->_rightMargin * panelCharWidth) < rightSpace)
				LOG4CXX_WARN(gLogger, "Right margin for the panel was forced beyond computed size");
			rightSpace = _panel->_rightMargin * panelCharWidth;
		}
		if (_panel->_topMargin != -1)
		{
			if ((_panel->_topMargin * panelCharHeight) < topSpace)
				LOG4CXX_WARN(gLogger, "Top margin for the panel was forced beyond computed size");
			topSpace = _panel->_topMargin * panelCharHeight;
		}
		if (_panel->_bottomMargin != -1)
		{
			if ((_panel->_bottomMargin * panelCharHeight) < bottomSpace)
				LOG4CXX_WARN(gLogger, "Bottom margin for the panel was forced beyond computed size");
			bottomSpace = _panel->_bottomMargin * panelCharHeight;
		}
fbe3c2bb   Benjamin Renard   First commit
251

ba6124b0   Menouard AZIB   Add parameter id ...
252
253
254
255
256
257
		// Update plot area bounds
		bounds_._x += leftSpace;
		bounds_._y += bottomSpace;
		bounds_._width -= (leftSpace + rightSpace);
		bounds_._height -= (bottomSpace + topSpace);
	}
fbe3c2bb   Benjamin Renard   First commit
258

ba6124b0   Menouard AZIB   Add parameter id ...
259
260
261
262
263
	void PanelPlotOutput::reserveSpaceForAxis(boost::shared_ptr<Axis> &pAxis, double titleHeight, std::map<PlotCommon::Position, int> nbAxesBySide,
											  double &topSpace, double &bottomSpace, double &leftSpace, double &rightSpace)
	{
		if (pAxis == nullptr || !pAxis->_used || !pAxis->_visible)
			return;
f6eaec4e   Benjamin Renard   Optimize plot ele...
264

ba6124b0   Menouard AZIB   Add parameter id ...
265
266
267
268
		// Get number of line to draw for legend.
		int nbLegendRows = pAxis->_legend.getNbLines();
		if ((nbLegendRows == 0) && pAxis->_showLegend)
			nbLegendRows = 1;
f6eaec4e   Benjamin Renard   Optimize plot ele...
269

ba6124b0   Menouard AZIB   Add parameter id ...
270
271
272
273
		// Compute legend character size
		Font legendFont(pAxis->getLegendFont(this->_panel.get()));
		PlPlotUtil::setPlFont(legendFont);
		CharSize legendCharSizePanel = PlPlotUtil::getCharacterSizeInPlPage(_panel->_page);
f6eaec4e   Benjamin Renard   Optimize plot ele...
274

ba6124b0   Menouard AZIB   Add parameter id ...
275
		std::tuple<float, float> pageSize = _panel->_page->getSizeInMm();
f6eaec4e   Benjamin Renard   Optimize plot ele...
276

ba6124b0   Menouard AZIB   Add parameter id ...
277
278
279
		// Reserve place in relation with the axis position
		switch (pAxis->_position)
		{
f6eaec4e   Benjamin Renard   Optimize plot ele...
280
281
282
283
284
285
286
287
288
		case PlotCommon::Position::POS_BOTTOM:
			if (pAxis->isZAxis())
				LOG4CXX_WARN(gLogger, "PanelPlotOutput::calculatePlotArea: Unrecognized position for z axis '" << pAxis->_position << "'");

			// This attribute is used later (in function PanelPlotOutput::drawSeries).
			if (!pAxis->isZAxis())
				_plotAreaSideSet[pAxis->_position] = true;

			// Reserve space for ticks
ba6124b0   Menouard AZIB   Add parameter id ...
289
290
			if (pAxis->_tick._position == Tick::TickPosition::OUTWARDS)
			{
f6eaec4e   Benjamin Renard   Optimize plot ele...
291
292
				double tickSize = getVerticalTickLength(pAxis.get(), legendCharSizePanel.second);
				bottomSpace += tickSize;
bdc50075   Benjamin Renard   Fix bug for posit...
293
				if (nbAxesBySide[PlotCommon::Position::POS_TOP] == 0)
ba6124b0   Menouard AZIB   Add parameter id ...
294
					// add space for oposite axis
bdc50075   Benjamin Renard   Fix bug for posit...
295
					topSpace += tickSize;
f6eaec4e   Benjamin Renard   Optimize plot ele...
296
297
			}

ba6124b0   Menouard AZIB   Add parameter id ...
298
			// Reserve space for ticks labels
f6eaec4e   Benjamin Renard   Optimize plot ele...
299
300
301
302
			if (pAxis->_showTickMark == true)
				bottomSpace += legendCharSizePanel.second * (1 + 0.25);

			// Reserve space for legend
ba6124b0   Menouard AZIB   Add parameter id ...
303
304
			if ((pAxis->_showLegend == true) && (nbLegendRows != 0))
			{
f6eaec4e   Benjamin Renard   Optimize plot ele...
305
				bottomSpace += PlPlotUtil::LINE_SPACE_TITLE * legendCharSizePanel.second;
58b353d5   Benjamin Renard   Set to version 3.4.0
306
307
308
309
				double legendOffset = bottomSpace + 0.5 * legendCharSizePanel.second;
				if (!_panel->getTitle()->_text.empty() && (_panel->_titlePosition == PlotCommon::Position::POS_BOTTOM))
					legendOffset -= titleHeight;
				pAxis->setLegendOffset(legendOffset);
8bb0f02b   Benjamin Renard   Set colors in axi...
310
				bottomSpace += (nbLegendRows + PlPlotUtil::LINE_SPACE_TITLE * (nbLegendRows + 1)) * legendCharSizePanel.second;
f6eaec4e   Benjamin Renard   Optimize plot ele...
311
312
313
314
315
316
317
318
319
320
321
322
			}

			break;
		case PlotCommon::Position::POS_TOP:
			if (pAxis->isZAxis())
				LOG4CXX_WARN(gLogger, "PanelPlotOutput::calculatePlotArea: Unrecognized position for z axis '" << pAxis->_position << "'");

			// This attribute is used later (in function PanelPlotOutput::drawSeries).
			if (!pAxis->isZAxis())
				_plotAreaSideSet[pAxis->_position] = true;

			// Reserve space for ticks
ba6124b0   Menouard AZIB   Add parameter id ...
323
324
			if (pAxis->_tick._position == Tick::TickPosition::OUTWARDS)
			{
f6eaec4e   Benjamin Renard   Optimize plot ele...
325
326
				double tickSize = getVerticalTickLength(pAxis.get(), legendCharSizePanel.second);
				topSpace += tickSize;
bdc50075   Benjamin Renard   Fix bug for posit...
327
				if (nbAxesBySide[PlotCommon::Position::POS_BOTTOM] == 0)
ba6124b0   Menouard AZIB   Add parameter id ...
328
					// add space for oposite axis
bdc50075   Benjamin Renard   Fix bug for posit...
329
					bottomSpace += tickSize;
f6eaec4e   Benjamin Renard   Optimize plot ele...
330
331
			}

ba6124b0   Menouard AZIB   Add parameter id ...
332
			// Reserve space for ticks labels
f6eaec4e   Benjamin Renard   Optimize plot ele...
333
334
335
336
			if (pAxis->_showTickMark == true)
				topSpace += legendCharSizePanel.second * (1 + 0.25);

			// Reserve space for legend
ba6124b0   Menouard AZIB   Add parameter id ...
337
338
			if ((pAxis->_showLegend == true) && (nbLegendRows != 0))
			{
f6eaec4e   Benjamin Renard   Optimize plot ele...
339
				topSpace += PlPlotUtil::LINE_SPACE_TITLE * legendCharSizePanel.second;
58b353d5   Benjamin Renard   Set to version 3.4.0
340
341
342
343
				double legendOffset = topSpace - 0.5 * legendCharSizePanel.second;
				if (!_panel->getTitle()->_text.empty() && (_panel->_titlePosition == PlotCommon::Position::POS_TOP))
					legendOffset += titleHeight;
				pAxis->setLegendOffset(legendOffset);
f6eaec4e   Benjamin Renard   Optimize plot ele...
344
345
346
347
348
349
				topSpace += (nbLegendRows + PlPlotUtil::LINE_SPACE_TITLE * (nbLegendRows + 1)) * legendCharSizePanel.second;
			}

			break;
		case PlotCommon::Position::POS_LEFT:
			// Record axis offset used for multi-axes
ba6124b0   Menouard AZIB   Add parameter id ...
350
			pAxis->setAxisOffset(leftSpace);
f6eaec4e   Benjamin Renard   Optimize plot ele...
351

ba6124b0   Menouard AZIB   Add parameter id ...
352
353
			if (pAxis->isZAxis())
			{
f6eaec4e   Benjamin Renard   Optimize plot ele...
354
355
356
357
358
359
360
				leftSpace += estimateZAxisWidth(pAxis);
				break;
			}

			// This attribute is used later (in function PanelPlotOutput::drawSeries).
			_plotAreaSideSet[pAxis->_position] = true;

ba6124b0   Menouard AZIB   Add parameter id ...
361
			// Reserve space for ticks labels
f6eaec4e   Benjamin Renard   Optimize plot ele...
362
363
364
365
			if (pAxis->_showTickMark == true)
				leftSpace += legendCharSizePanel.first * (pAxis->getTickMarkSize().first + 2 * PlPlotUtil::LINE_SPACE_TITLE + 0.25);

			// Reserve space for ticks
ba6124b0   Menouard AZIB   Add parameter id ...
366
367
			if (pAxis->_tick._position == Tick::TickPosition::OUTWARDS)
			{
f6eaec4e   Benjamin Renard   Optimize plot ele...
368
369
				double tickSize = getHorizontalTickLength(pAxis.get(), legendCharSizePanel.second);
				leftSpace += tickSize;
bdc50075   Benjamin Renard   Fix bug for posit...
370
				if (nbAxesBySide[PlotCommon::Position::POS_RIGHT] == 0)
ba6124b0   Menouard AZIB   Add parameter id ...
371
					// add space for oposite axis
bdc50075   Benjamin Renard   Fix bug for posit...
372
					rightSpace += tickSize;
f6eaec4e   Benjamin Renard   Optimize plot ele...
373
374
375
			}

			// Reserve space for legend
ba6124b0   Menouard AZIB   Add parameter id ...
376
377
			if ((pAxis->_showLegend == true) && (nbLegendRows != 0))
			{
f6eaec4e   Benjamin Renard   Optimize plot ele...
378
379
				leftSpace += PlPlotUtil::LINE_SPACE_TITLE * legendCharSizePanel.second * std::get<1>(pageSize) / std::get<0>(pageSize);
				pAxis->setLegendOffset(leftSpace + 0.5 * legendCharSizePanel.second * std::get<1>(pageSize) / std::get<0>(pageSize));
ba6124b0   Menouard AZIB   Add parameter id ...
380
				leftSpace += (nbLegendRows + PlPlotUtil::LINE_SPACE_TITLE * (nbLegendRows + 1)) * legendCharSizePanel.second * std::get<1>(pageSize) / std::get<0>(pageSize);
f6eaec4e   Benjamin Renard   Optimize plot ele...
381
382
383
384
385
			}

			break;
		case PlotCommon::Position::POS_RIGHT:
			// Record axis offset used for multi-axes
b76d3cfc   Benjamin Renard   Fix color axis po...
386
			pAxis->setAxisOffset(rightSpace);
f6eaec4e   Benjamin Renard   Optimize plot ele...
387

ba6124b0   Menouard AZIB   Add parameter id ...
388
389
			if (pAxis->isZAxis())
			{
f6eaec4e   Benjamin Renard   Optimize plot ele...
390
391
392
393
394
395
396
				rightSpace += estimateZAxisWidth(pAxis);
				break;
			}

			// This attribute is used later (in function PanelPlotOutput::drawSeries).
			_plotAreaSideSet[pAxis->_position] = true;

ba6124b0   Menouard AZIB   Add parameter id ...
397
			// Reserve space for ticks labels
f6eaec4e   Benjamin Renard   Optimize plot ele...
398
399
400
401
			if (pAxis->_showTickMark == true)
				rightSpace += legendCharSizePanel.first * (pAxis->getTickMarkSize().first + 2 * PlPlotUtil::LINE_SPACE_TITLE + 0.25);

			// Reserve space for ticks
ba6124b0   Menouard AZIB   Add parameter id ...
402
403
			if (pAxis->_tick._position == Tick::TickPosition::OUTWARDS)
			{
f6eaec4e   Benjamin Renard   Optimize plot ele...
404
405
				double tickSize = getHorizontalTickLength(pAxis.get(), legendCharSizePanel.second);
				rightSpace += tickSize;
bdc50075   Benjamin Renard   Fix bug for posit...
406
				if (nbAxesBySide[PlotCommon::Position::POS_LEFT] == 0)
ba6124b0   Menouard AZIB   Add parameter id ...
407
					// add space for oposite axis
bdc50075   Benjamin Renard   Fix bug for posit...
408
					leftSpace += tickSize;
f6eaec4e   Benjamin Renard   Optimize plot ele...
409
410
			}

ba6124b0   Menouard AZIB   Add parameter id ...
411
412
413
			// Reserve space for legend
			if ((pAxis->_showLegend == true) && (nbLegendRows != 0))
			{
f6eaec4e   Benjamin Renard   Optimize plot ele...
414
				rightSpace += PlPlotUtil::LINE_SPACE_TITLE * legendCharSizePanel.second * std::get<1>(pageSize) / std::get<0>(pageSize);
bdc50075   Benjamin Renard   Fix bug for posit...
415
				pAxis->setLegendOffset(rightSpace + 0.5 * legendCharSizePanel.second * std::get<1>(pageSize) / std::get<0>(pageSize));
ba6124b0   Menouard AZIB   Add parameter id ...
416
				rightSpace += (nbLegendRows + PlPlotUtil::LINE_SPACE_TITLE * (nbLegendRows + 1)) * legendCharSizePanel.second * std::get<1>(pageSize) / std::get<0>(pageSize);
f6eaec4e   Benjamin Renard   Optimize plot ele...
417
418
			}

f6eaec4e   Benjamin Renard   Optimize plot ele...
419
420
421
422
			break;
		case PlotCommon::Position::POS_CENTER:
		default:
			LOG4CXX_WARN(gLogger, "PanelPlotOutput::drawPlotArea: Unrecognized position for axis '" << pAxis->_position << "'");
ba6124b0   Menouard AZIB   Add parameter id ...
423
		}
f6eaec4e   Benjamin Renard   Optimize plot ele...
424
	}
f6eaec4e   Benjamin Renard   Optimize plot ele...
425

ba6124b0   Menouard AZIB   Add parameter id ...
426
427
428
	void PanelPlotOutput::reserveSpaceForTextLegend(boost::shared_ptr<TextLegendProperties> &pTextLegendProp, double titleHeight, double &topSpace, double &bottomSpace, double &leftSpace, double &rightSpace)
	{
		int textLegendLinesNb = pTextLegendProp->getTextLinesNb();
f6eaec4e   Benjamin Renard   Optimize plot ele...
429

ba6124b0   Menouard AZIB   Add parameter id ...
430
431
		if (textLegendLinesNb == 0)
			return;
f6eaec4e   Benjamin Renard   Optimize plot ele...
432

ba6124b0   Menouard AZIB   Add parameter id ...
433
434
		PlPlotUtil::setPlFont(pTextLegendProp->getFont());
		CharSize lCharSizeLegend = PlPlotUtil::getCharacterSizeInPlPage(_panel->_page);
f6eaec4e   Benjamin Renard   Optimize plot ele...
435

ba6124b0   Menouard AZIB   Add parameter id ...
436
		std::tuple<float, float> pageSize = _panel->_page->getSizeInMm();
f6eaec4e   Benjamin Renard   Optimize plot ele...
437

ba6124b0   Menouard AZIB   Add parameter id ...
438
439
440
441
		switch (pTextLegendProp->getPosition())
		{
		case TextLegendPosition::POS_LEFT:
			pTextLegendProp->setOffset(leftSpace);
f6eaec4e   Benjamin Renard   Optimize plot ele...
442
443
			leftSpace += (textLegendLinesNb + PlPlotUtil::LINE_SPACE_TITLE * (textLegendLinesNb + 1)) * lCharSizeLegend.second * std::get<1>(pageSize) / std::get<0>(pageSize);
			break;
ba6124b0   Menouard AZIB   Add parameter id ...
444
445
		case TextLegendPosition::POS_RIGHT:
			pTextLegendProp->setOffset(rightSpace);
f6eaec4e   Benjamin Renard   Optimize plot ele...
446
447
			rightSpace += (textLegendLinesNb + PlPlotUtil::LINE_SPACE_TITLE * (textLegendLinesNb + 1)) * lCharSizeLegend.second * std::get<1>(pageSize) / std::get<0>(pageSize);
			break;
ba6124b0   Menouard AZIB   Add parameter id ...
448
		case TextLegendPosition::POS_TOP:
f6eaec4e   Benjamin Renard   Optimize plot ele...
449
			if (_panel->_titlePosition == PlotCommon::Position::POS_TOP)
ba6124b0   Menouard AZIB   Add parameter id ...
450
				pTextLegendProp->setOffset(topSpace - titleHeight);
f6eaec4e   Benjamin Renard   Optimize plot ele...
451
			else
ba6124b0   Menouard AZIB   Add parameter id ...
452
				pTextLegendProp->setOffset(topSpace);
f6eaec4e   Benjamin Renard   Optimize plot ele...
453
454
			topSpace += (textLegendLinesNb + PlPlotUtil::LINE_SPACE_TITLE * (textLegendLinesNb + 1)) * lCharSizeLegend.second;
			break;
ba6124b0   Menouard AZIB   Add parameter id ...
455
		case TextLegendPosition::POS_BOTTOM:
f6eaec4e   Benjamin Renard   Optimize plot ele...
456
			if (_panel->_titlePosition == PlotCommon::Position::POS_BOTTOM)
ba6124b0   Menouard AZIB   Add parameter id ...
457
				pTextLegendProp->setOffset(bottomSpace - titleHeight);
f6eaec4e   Benjamin Renard   Optimize plot ele...
458
			else
ba6124b0   Menouard AZIB   Add parameter id ...
459
				pTextLegendProp->setOffset(bottomSpace);
f6eaec4e   Benjamin Renard   Optimize plot ele...
460
461
			bottomSpace += (textLegendLinesNb + PlPlotUtil::LINE_SPACE_TITLE * (textLegendLinesNb + 1)) * lCharSizeLegend.second;
			break;
ba6124b0   Menouard AZIB   Add parameter id ...
462
		}
f6eaec4e   Benjamin Renard   Optimize plot ele...
463
	}
f6eaec4e   Benjamin Renard   Optimize plot ele...
464

ba6124b0   Menouard AZIB   Add parameter id ...
465
466
467
468
469
470
471
472
	/**
	 * @brief Compute panel XY ratio used for angular conversions
	 */
	void PanelPlotOutput::computePanelPlotXYRatio(void)
	{
		// panel plot XY ratio = page ratio * plot area bound size ratio
		_panelPlotXYRatio = (std::get<0>(_panel->_page->getSize()) / std::get<1>(_panel->_page->getSize())) * (_plotAreaBounds._width / _plotAreaBounds._height);
	}
fbe3c2bb   Benjamin Renard   First commit
473

ba6124b0   Menouard AZIB   Add parameter id ...
474
475
476
477
478
479
	/**
	 * @brief Draw legend for each axis.
	 */
	void PanelPlotOutput::drawLegends(boost::shared_ptr<Axis> &pAxis, PlWindow &pPlWindow, Bounds &pPlotAreaSize)
	{
		LOG4CXX_DEBUG(gLogger, "Drawing legend for axis " << pAxis->_id << " : " << pAxis->_legend.getText());
fbe3c2bb   Benjamin Renard   First commit
480

ba6124b0   Menouard AZIB   Add parameter id ...
481
482
483
		// Set legend font
		Font legendFont(pAxis->getLegendFont(this->_panel.get()));
		PlPlotUtil::setPlFont(legendFont);
fbe3c2bb   Benjamin Renard   First commit
484

ba6124b0   Menouard AZIB   Add parameter id ...
485
486
		// Get legend row info
		std::list<std::pair<std::string, Color>> lines = pAxis->_legend.getLines();
fbe3c2bb   Benjamin Renard   First commit
487

ba6124b0   Menouard AZIB   Add parameter id ...
488
489
490
491
492
		// Check if there is something to draw !
		if ((pAxis->_visible == true) &&
			(pAxis->_showLegend == true) &&
			(lines.size() != 0))
		{
f6eaec4e   Benjamin Renard   Optimize plot ele...
493

ba6124b0   Menouard AZIB   Add parameter id ...
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
			Color lInitialColor;
			// If legend has not it's own color set axis color.
			if ((pAxis->_legend.getColor()._colorIndex == -1) && ((pAxis->_legend.getColor()._red == -1) && (pAxis->_legend.getColor()._green == -1) && (pAxis->_legend.getColor()._blue == -1)))
			{
				lInitialColor = changeColor(_pls, pAxis->_color,
											_panel->_page->_mode);
			}
			else
			{
				Color legendColor = pAxis->_legend.getColor();
				lInitialColor = changeColor(_pls, legendColor,
											_panel->_page->_mode);
			}

			// Init position
			double lPosition = PlPlotUtil::LINE_SPACE_TITLE;
			unsigned int lineIndex = 0;
fbe3c2bb   Benjamin Renard   First commit
511

ba6124b0   Menouard AZIB   Add parameter id ...
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
			// Depending on the way to draw legend, for BOTTOM position we have to draw from first legend line to last.
			switch (pAxis->_position)
			{
			case PlotCommon::Position::POS_BOTTOM:

				_pls->vpor(pPlotAreaSize._x,
						   pPlotAreaSize._x + pPlotAreaSize._width,
						   pPlotAreaSize._y - pAxis->getLegendOffset(),
						   pPlotAreaSize._y - pAxis->getLegendOffset() + pPlotAreaSize._height);

				_pls->wind(std::get<0>(pPlWindow), std::get<1>(pPlWindow),
						   std::get<2>(pPlWindow), std::get<3>(pPlWindow));

				// Draw lines, beginning by the first one
				for (auto line : lines)
fbe3c2bb   Benjamin Renard   First commit
527
				{
ba6124b0   Menouard AZIB   Add parameter id ...
528
529
					std::string lineToDraw = line.first;
					if (lineIndex == lines.size() - 1)
fbe3c2bb   Benjamin Renard   First commit
530
					{
ba6124b0   Menouard AZIB   Add parameter id ...
531
532
533
534
535
536
537
						// add unit if defined
						if (!pAxis->getAxisUnits().empty())
						{
							lineToDraw += " (";
							lineToDraw += pAxis->getAxisUnits();
							lineToDraw += ")";
						}
fbe3c2bb   Benjamin Renard   First commit
538
					}
ba6124b0   Menouard AZIB   Add parameter id ...
539
540
541
542
543
544
					Color lSavedColor;
					if (line.second.isSet())
					{
						lSavedColor = changeColor(_pls, line.second, _panel->_page->_mode);
					}
					_pls->mtex(getPlSide(pAxis->_position).c_str(), lPosition, 0.5, 0.5, lineToDraw.c_str());
f4f4fdcc   Erdogan Furkan   Done
545
546
547
					// Adding more height if needed
					addSpaceForExInd(lineToDraw, lPosition);

ba6124b0   Menouard AZIB   Add parameter id ...
548
549
550
551
552
553
					lPosition += (1 + PlPlotUtil::LINE_SPACE_TITLE);
					if (line.second.isSet())
					{
						restoreColor(_pls, lSavedColor, _panel->_page->_mode);
					}
					++lineIndex;
fbe3c2bb   Benjamin Renard   First commit
554
				}
ba6124b0   Menouard AZIB   Add parameter id ...
555
				break;
fbe3c2bb   Benjamin Renard   First commit
556

ba6124b0   Menouard AZIB   Add parameter id ...
557
558
559
560
561
			case PlotCommon::Position::POS_TOP:
				_pls->vpor(pPlotAreaSize._x,
						   pPlotAreaSize._x + pPlotAreaSize._width,
						   pPlotAreaSize._y + pAxis->getLegendOffset(),
						   pPlotAreaSize._y + pAxis->getLegendOffset() + pPlotAreaSize._height);
fbe3c2bb   Benjamin Renard   First commit
562

ba6124b0   Menouard AZIB   Add parameter id ...
563
564
				_pls->wind(std::get<0>(pPlWindow), std::get<1>(pPlWindow),
						   std::get<2>(pPlWindow), std::get<3>(pPlWindow));
fbe3c2bb   Benjamin Renard   First commit
565

ba6124b0   Menouard AZIB   Add parameter id ...
566
567
				// Draw lines, beginning by the last one
				for (auto line : boost::adaptors::reverse(lines))
fbe3c2bb   Benjamin Renard   First commit
568
				{
ba6124b0   Menouard AZIB   Add parameter id ...
569
570
					std::string lineToDraw = line.first;
					if (lineIndex == lines.size() - 1)
fbe3c2bb   Benjamin Renard   First commit
571
					{
ba6124b0   Menouard AZIB   Add parameter id ...
572
573
574
575
576
577
578
						// add unit if defined
						if (!pAxis->getAxisUnits().empty())
						{
							lineToDraw += " (";
							lineToDraw += pAxis->getAxisUnits();
							lineToDraw += ")";
						}
fbe3c2bb   Benjamin Renard   First commit
579
					}
ba6124b0   Menouard AZIB   Add parameter id ...
580
581
582
583
584
585
					Color lSavedColor;
					if (line.second.isSet())
					{
						lSavedColor = changeColor(_pls, line.second, _panel->_page->_mode);
					}
					_pls->mtex(getPlSide(pAxis->_position).c_str(), lPosition, 0.5, 0.5, lineToDraw.c_str());
f4f4fdcc   Erdogan Furkan   Done
586
587
588
					// Adding more height if needed
					addSpaceForExInd(lineToDraw, lPosition);

ba6124b0   Menouard AZIB   Add parameter id ...
589
590
591
592
593
594
					lPosition += (1 + PlPlotUtil::LINE_SPACE_TITLE);
					if (line.second.isSet())
					{
						restoreColor(_pls, lSavedColor, _panel->_page->_mode);
					}
					++lineIndex;
fbe3c2bb   Benjamin Renard   First commit
595
				}
ba6124b0   Menouard AZIB   Add parameter id ...
596
				break;
fbe3c2bb   Benjamin Renard   First commit
597

ba6124b0   Menouard AZIB   Add parameter id ...
598
			case PlotCommon::Position::POS_RIGHT:
f6eaec4e   Benjamin Renard   Optimize plot ele...
599

ba6124b0   Menouard AZIB   Add parameter id ...
600
601
602
603
				_pls->vpor(pPlotAreaSize._x,
						   pPlotAreaSize._x + pAxis->getLegendOffset() + pPlotAreaSize._width,
						   pPlotAreaSize._y,
						   pPlotAreaSize._y + pPlotAreaSize._height);
fbe3c2bb   Benjamin Renard   First commit
604

ba6124b0   Menouard AZIB   Add parameter id ...
605
606
				_pls->wind(std::get<0>(pPlWindow), std::get<1>(pPlWindow),
						   std::get<2>(pPlWindow), std::get<3>(pPlWindow));
fbe3c2bb   Benjamin Renard   First commit
607

ba6124b0   Menouard AZIB   Add parameter id ...
608
609
				// Draw lines, beginning by the first one
				for (auto line : lines)
fbe3c2bb   Benjamin Renard   First commit
610
				{
ba6124b0   Menouard AZIB   Add parameter id ...
611
612
					std::string lineToDraw = line.first;
					if (lineIndex == lines.size() - 1)
fbe3c2bb   Benjamin Renard   First commit
613
					{
ba6124b0   Menouard AZIB   Add parameter id ...
614
615
616
617
618
619
620
						// add unit if defined
						if (!pAxis->getAxisUnits().empty())
						{
							lineToDraw += " (";
							lineToDraw += pAxis->getAxisUnits();
							lineToDraw += ")";
						}
fbe3c2bb   Benjamin Renard   First commit
621
					}
ba6124b0   Menouard AZIB   Add parameter id ...
622
623
624
625
626
627
					Color lSavedColor;
					if (line.second.isSet())
					{
						lSavedColor = changeColor(_pls, line.second, _panel->_page->_mode);
					}
					_pls->mtex(getPlSide(pAxis->_position).c_str(), lPosition, 0.5, 0.5, lineToDraw.c_str());
f4f4fdcc   Erdogan Furkan   Done
628
629
630
					// Adding more height if needed
					addSpaceForExInd(lineToDraw, lPosition);

ba6124b0   Menouard AZIB   Add parameter id ...
631
632
633
634
635
636
					lPosition += (1 + PlPlotUtil::LINE_SPACE_TITLE);
					if (line.second.isSet())
					{
						restoreColor(_pls, lSavedColor, _panel->_page->_mode);
					}
					++lineIndex;
fbe3c2bb   Benjamin Renard   First commit
637
				}
fbe3c2bb   Benjamin Renard   First commit
638

ba6124b0   Menouard AZIB   Add parameter id ...
639
				break;
fbe3c2bb   Benjamin Renard   First commit
640

ba6124b0   Menouard AZIB   Add parameter id ...
641
			case PlotCommon::Position::POS_LEFT:
f6eaec4e   Benjamin Renard   Optimize plot ele...
642

ba6124b0   Menouard AZIB   Add parameter id ...
643
644
645
646
				_pls->vpor(pPlotAreaSize._x - pAxis->getLegendOffset(),
						   pPlotAreaSize._x + pPlotAreaSize._width,
						   pPlotAreaSize._y,
						   pPlotAreaSize._y + pPlotAreaSize._height);
fbe3c2bb   Benjamin Renard   First commit
647

ba6124b0   Menouard AZIB   Add parameter id ...
648
649
				_pls->wind(std::get<0>(pPlWindow), std::get<1>(pPlWindow),
						   std::get<2>(pPlWindow), std::get<3>(pPlWindow));
fbe3c2bb   Benjamin Renard   First commit
650

ba6124b0   Menouard AZIB   Add parameter id ...
651
652
				// Draw lines, beginning by the last one
				for (auto line : boost::adaptors::reverse(lines))
fbe3c2bb   Benjamin Renard   First commit
653
				{
ba6124b0   Menouard AZIB   Add parameter id ...
654
655
					std::string lineToDraw = line.first;
					if (lineIndex == lines.size() - 1)
fbe3c2bb   Benjamin Renard   First commit
656
					{
ba6124b0   Menouard AZIB   Add parameter id ...
657
658
659
660
661
662
663
						// add unit if defined
						if (!pAxis->getAxisUnits().empty())
						{
							lineToDraw += " (";
							lineToDraw += pAxis->getAxisUnits();
							lineToDraw += ")";
						}
fbe3c2bb   Benjamin Renard   First commit
664
					}
ba6124b0   Menouard AZIB   Add parameter id ...
665
666
667
668
669
670
					Color lSavedColor;
					if (line.second.isSet())
					{
						lSavedColor = changeColor(_pls, line.second, _panel->_page->_mode);
					}
					_pls->mtex(getPlSide(pAxis->_position).c_str(), lPosition, 0.5, 0.5, lineToDraw.c_str());
f4f4fdcc   Erdogan Furkan   Done
671
672
673
					// Adding more height if needed
					addSpaceForExInd(lineToDraw, lPosition);

ba6124b0   Menouard AZIB   Add parameter id ...
674
675
676
677
678
679
					lPosition += (1 + PlPlotUtil::LINE_SPACE_TITLE);
					if (line.second.isSet())
					{
						restoreColor(_pls, lSavedColor, _panel->_page->_mode);
					}
					++lineIndex;
fbe3c2bb   Benjamin Renard   First commit
680
				}
fbe3c2bb   Benjamin Renard   First commit
681

ba6124b0   Menouard AZIB   Add parameter id ...
682
				break;
fbe3c2bb   Benjamin Renard   First commit
683

ba6124b0   Menouard AZIB   Add parameter id ...
684
685
686
687
			case PlotCommon::Position::POS_CENTER:
			default:
				LOG4CXX_WARN(gLogger, "PanelPlotOutput::drawPlotArea: Unrecognized position for axis '" << pAxis->_position << "'");
			}
fbe3c2bb   Benjamin Renard   First commit
688

ba6124b0   Menouard AZIB   Add parameter id ...
689
690
691
692
			_pls->vpor(pPlotAreaSize._x,
					   pPlotAreaSize._x + pPlotAreaSize._width,
					   pPlotAreaSize._y,
					   pPlotAreaSize._y + pPlotAreaSize._height);
f6eaec4e   Benjamin Renard   Optimize plot ele...
693

ba6124b0   Menouard AZIB   Add parameter id ...
694
695
			_pls->wind(std::get<0>(pPlWindow), std::get<1>(pPlWindow),
					   std::get<2>(pPlWindow), std::get<3>(pPlWindow));
f6eaec4e   Benjamin Renard   Optimize plot ele...
696

ba6124b0   Menouard AZIB   Add parameter id ...
697
698
699
			// Restore initial color.
			restoreColor(_pls, lInitialColor, _panel->_page->_mode);
		}
fbe3c2bb   Benjamin Renard   First commit
700
	}
fbe3c2bb   Benjamin Renard   First commit
701

f4f4fdcc   Erdogan Furkan   Done
702
703
704
705
706
707
708
709
710
711
712
713
	void PanelPlotOutput::addSpaceForExInd(std::string &legend, double &lPosition){
		if(legend != ""){

			// We check if there is an exponent or an indice
			const char *exponent = std::strstr(legend.c_str(), "#u");
			const char *indice = std::strstr(legend.c_str(), "#d");

			if(exponent || indice)
				lPosition += 1;
		}
	}

ba6124b0   Menouard AZIB   Add parameter id ...
714
715
716
717
	void PanelPlotOutput::drawAxis(boost::shared_ptr<Axis> pAxis, TickConf &pTickConf,
								   std::string pXAxisOptions, std::string pYAxisOptions)
	{
		Color lInitialColor = changeColor(_pls, pAxis->_color, _panel->_page->_mode);
fbe3c2bb   Benjamin Renard   First commit
718

ba6124b0   Menouard AZIB   Add parameter id ...
719
720
		// Set axis thickness.
		_pls->width(pAxis->_thickness);
fbe3c2bb   Benjamin Renard   First commit
721

ba6124b0   Menouard AZIB   Add parameter id ...
722
723
		// Set tick (major and minor) length factor
		PLFLT lTickLenFact = DEFAULT_TICK_LENGTH_FACTOR;
d78eca08   Menouard AZIB   Fill AMDA_... cor...
724
		if (!isNAN(pAxis->_tick._lengthFactor))
ba6124b0   Menouard AZIB   Add parameter id ...
725
726
727
728
729
730
731
732
733
734
		{
			lTickLenFact = pAxis->_tick._lengthFactor;
		}
		else
		{
			// Nothing to do.
		}
		// 0 => keep tick height in millimeters.
		_pls->smaj(0, lTickLenFact);
		_pls->smin(0, lTickLenFact);
fbe3c2bb   Benjamin Renard   First commit
735

ba6124b0   Menouard AZIB   Add parameter id ...
736
737
738
739
740
		// if options contains "o" character we need to set label function
		if ((pXAxisOptions.find("o") != std::string::npos) || (pYAxisOptions.find("o") != std::string::npos))
		{
			_pls->slabelfunc(pAxis->_labelGenerator->_function, pAxis->_labelGenerator->_data);
		}
fbe3c2bb   Benjamin Renard   First commit
741

ba6124b0   Menouard AZIB   Add parameter id ...
742
743
		// Set line style (force to be plain)
		_pls->lsty(static_cast<int>(getPlLineStyle(LineStyle::PLAIN)));
fbe3c2bb   Benjamin Renard   First commit
744

ba6124b0   Menouard AZIB   Add parameter id ...
745
746
747
748
749
		// Set font to draw axes.
		Font axisFont(pAxis->getLegendFont(this->_panel.get()));
		axisFont.setStyle(Font::Style::NORMAL);
		axisFont.setWeight(Font::Weight::NORMAL);
		PlPlotUtil::setPlFont(axisFont);
fbe3c2bb   Benjamin Renard   First commit
750

ba6124b0   Menouard AZIB   Add parameter id ...
751
		size_t lPos;
fbe3c2bb   Benjamin Renard   First commit
752

ba6124b0   Menouard AZIB   Add parameter id ...
753
754
755
756
		double xMajorTickSpace = std::get<0>(pTickConf);
		double xMinorTickNumber = std::get<1>(pTickConf);
		double yMajorTickSpace = std::get<2>(pTickConf);
		double yMinorTickNumber = std::get<3>(pTickConf);
fbe3c2bb   Benjamin Renard   First commit
757

ba6124b0   Menouard AZIB   Add parameter id ...
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
		// if options contains "a" character we need to draw origin separately.
		if ((lPos = pXAxisOptions.find("a")) != std::string::npos)
		{
			pXAxisOptions.replace(lPos, 1, "");
			_pls->box("a", xMajorTickSpace, xMinorTickNumber, "", yMajorTickSpace, yMinorTickNumber);
		}
		else if ((lPos = pYAxisOptions.find("a")) != std::string::npos)
		{
			pYAxisOptions.replace(lPos, 1, "");
			_pls->box("", xMajorTickSpace, xMinorTickNumber, "a", yMajorTickSpace, yMinorTickNumber);
		}
		else
		{
			// Nothing to do.
		}
fbe3c2bb   Benjamin Renard   First commit
773

ba6124b0   Menouard AZIB   Add parameter id ...
774
775
776
		// Draw axis.
		_pls->box(pXAxisOptions.c_str(), xMajorTickSpace, xMinorTickNumber,
				  pYAxisOptions.c_str(), yMajorTickSpace, yMinorTickNumber);
fbe3c2bb   Benjamin Renard   First commit
777

ba6124b0   Menouard AZIB   Add parameter id ...
778
779
		// Restore initial color.
		restoreColor(_pls, lInitialColor, _panel->_page->_mode);
fbe3c2bb   Benjamin Renard   First commit
780

ba6124b0   Menouard AZIB   Add parameter id ...
781
782
783
		// Set axis as drawn.
		pAxis->_drawn = true;
	}
fbe3c2bb   Benjamin Renard   First commit
784

ba6124b0   Menouard AZIB   Add parameter id ...
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
	void PanelPlotOutput::drawXAxis(boost::shared_ptr<Axis> pXAxis, PlWindow &pPlWindow, Bounds &pPlotAreaSize, TickConf &pTickConf)
	{
		// Set option to draw origin.
		std::string lAxisOption = pXAxis->getPlotOpt();
		std::string lTmpAxisOption = "xi";

		// plplot doesn't provide solution to set space between tick and tick mark.
		// To do that we need to play with viewport position and size.
		// So axis will be drawn in two times:
		//		- first draw tick marks
		//		- second draw tick and edge
		// Custom space  between tick marks and tick is only done when tick length is greater than 0.75.
		// Get extra tick mark space (only if they are outwards)
		if (pXAxis->_tick._position == Tick::TickPosition::OUTWARDS)
		{
			float lTickLengthFactor = 0;
d78eca08   Menouard AZIB   Fill AMDA_... cor...
801
			if ((!isNAN(pXAxis->_tick._lengthFactor)) && (pXAxis->_tick._lengthFactor > HORIZONTAL_TICK_LENGTH_LIMIT))
ba6124b0   Menouard AZIB   Add parameter id ...
802
803
804
			{
				lTickLengthFactor = pXAxis->_tick._lengthFactor;
			}
d78eca08   Menouard AZIB   Fill AMDA_... cor...
805
			else if ((isNAN(pXAxis->_tick._lengthFactor)) && (DEFAULT_TICK_LENGTH_FACTOR > HORIZONTAL_TICK_LENGTH_LIMIT))
ba6124b0   Menouard AZIB   Add parameter id ...
806
807
808
			{
				lTickLengthFactor = DEFAULT_TICK_LENGTH_FACTOR;
			}
fbe3c2bb   Benjamin Renard   First commit
809

ba6124b0   Menouard AZIB   Add parameter id ...
810
811
812
813
814
			if (lTickLengthFactor != 0)
			{
				// 1 character size is equal to 0.75 tick length.
				PlPlotUtil::setPlFont(_panel->getFont());
				float lTickMarkSpace = (lTickLengthFactor - HORIZONTAL_TICK_LENGTH_LIMIT) * (PlPlotUtil::getCharacterSizeInPlPage(_panel->_page).second) / (DEFAULT_TICK_LENGTH_FACTOR);
fbe3c2bb   Benjamin Renard   First commit
815

ba6124b0   Menouard AZIB   Add parameter id ...
816
				size_t lPos;
fbe3c2bb   Benjamin Renard   First commit
817

ba6124b0   Menouard AZIB   Add parameter id ...
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
				if ((lPos = lAxisOption.find("m")) != std::string::npos)
				{
					lTmpAxisOption += "m";
					lAxisOption.replace(lPos, 1, "");
				}
				if ((lPos = lAxisOption.find("n")) != std::string::npos)
				{
					lTmpAxisOption += "n";
					lAxisOption.replace(lPos, 1, "");
				}
				if ((lPos = lAxisOption.find("o")) != std::string::npos)
				{
					lTmpAxisOption += "o";
					lAxisOption.replace(lPos, 1, "");
				}
				if ((lPos = lAxisOption.find("d")) != std::string::npos)
				{
					lTmpAxisOption += "d";
					lAxisOption.replace(lPos, 1, "");
				}
				if ((lPos = lAxisOption.find("f")) != std::string::npos)
				{
					lTmpAxisOption += "f";
					lAxisOption.replace(lPos, 1, "");
				}

				if (pXAxis->_position == PlotCommon::Position::POS_BOTTOM)
				{
					_pls->vpor(pPlotAreaSize._x,
							   pPlotAreaSize._x + pPlotAreaSize._width,
							   pPlotAreaSize._y - lTickMarkSpace,
							   pPlotAreaSize._y + pPlotAreaSize._height);
				}
				else
				{
					_pls->vpor(pPlotAreaSize._x,
							   pPlotAreaSize._x + pPlotAreaSize._width,
							   pPlotAreaSize._y,
							   pPlotAreaSize._y + pPlotAreaSize._height + lTickMarkSpace);
				}
fbe3c2bb   Benjamin Renard   First commit
858

ba6124b0   Menouard AZIB   Add parameter id ...
859
860
				_pls->wind(std::get<0>(pPlWindow), std::get<1>(pPlWindow),
						   std::get<2>(pPlWindow), std::get<3>(pPlWindow));
fbe3c2bb   Benjamin Renard   First commit
861

ba6124b0   Menouard AZIB   Add parameter id ...
862
863
				// Draw tick mark.
				drawAxis(pXAxis, pTickConf, lTmpAxisOption, "");
fbe3c2bb   Benjamin Renard   First commit
864
			}
ba6124b0   Menouard AZIB   Add parameter id ...
865
866
867
868
869
870
871
872
873
		}
		// Restore default plot area
		_pls->vpor(pPlotAreaSize._x,
				   pPlotAreaSize._x + pPlotAreaSize._width,
				   pPlotAreaSize._y,
				   pPlotAreaSize._y + pPlotAreaSize._height);
		// Set window.
		_pls->wind(std::get<0>(pPlWindow), std::get<1>(pPlWindow),
				   std::get<2>(pPlWindow), std::get<3>(pPlWindow));
fbe3c2bb   Benjamin Renard   First commit
874

ba6124b0   Menouard AZIB   Add parameter id ...
875
876
877
878
		// Check if origin must be drawn.
		if (std::get<0>(pPlWindow) != 0 && std::get<1>(pPlWindow) && pXAxis->_origin == 0)
		{
			lAxisOption += "a";
fbe3c2bb   Benjamin Renard   First commit
879
		}
fbe3c2bb   Benjamin Renard   First commit
880

ba6124b0   Menouard AZIB   Add parameter id ...
881
882
		// Check if opposite plot area side need to be drawn
		lAxisOption += drawOppositeSide(pXAxis);
fbe3c2bb   Benjamin Renard   First commit
883

ba6124b0   Menouard AZIB   Add parameter id ...
884
885
		// Draw rest of axis.
		drawAxis(pXAxis, pTickConf, lAxisOption, "");
fbe3c2bb   Benjamin Renard   First commit
886
887
	}

ba6124b0   Menouard AZIB   Add parameter id ...
888
889
	void PanelPlotOutput::drawYAxis(boost::shared_ptr<Axis> pYAxis, PlWindow &pPlWindow, Bounds &pPlotAreaSize, TickConf &pTickConf)
	{
fbe3c2bb   Benjamin Renard   First commit
890

ba6124b0   Menouard AZIB   Add parameter id ...
891
892
		// Get axis offset in case of multi-axes
		double axisOffset = pYAxis->getAxisOffset();
fbe3c2bb   Benjamin Renard   First commit
893

ba6124b0   Menouard AZIB   Add parameter id ...
894
895
896
		// Set option to draw origin ("v" is set to have numeric labels parallel to X axis).
		std::string lAxisOption = pYAxis->getPlotOpt();
		std::string lTmpAxisOption = "xiv";
fbe3c2bb   Benjamin Renard   First commit
897

ba6124b0   Menouard AZIB   Add parameter id ...
898
899
900
901
902
903
904
		// plplot doesn't provide solution to set space between tick and tick mark.
		// To do that we need to play with viewport position and size.
		// So axis will be drawn in two times:
		//		- first draw tick marks
		//		- second draw tick and edge
		// Custom space  between tick marks and tick is only done when tick length is greater than 0.5.
		// Get extra tick mark space (only if they are outwards)
fbe3c2bb   Benjamin Renard   First commit
905

ba6124b0   Menouard AZIB   Add parameter id ...
906
		pPlotAreaSize._width = pPlotAreaSize._width;
fbe3c2bb   Benjamin Renard   First commit
907

ba6124b0   Menouard AZIB   Add parameter id ...
908
909
910
		if (pYAxis->_tick._position == Tick::TickPosition::OUTWARDS)
		{
			float lTickLengthFactor = 0;
d78eca08   Menouard AZIB   Fill AMDA_... cor...
911
			if ((!isNAN(pYAxis->_tick._lengthFactor)) && (pYAxis->_tick._lengthFactor > VERTICAL_TICK_LENGTH_LIMIT))
ba6124b0   Menouard AZIB   Add parameter id ...
912
913
914
			{
				lTickLengthFactor = pYAxis->_tick._lengthFactor;
			}
d78eca08   Menouard AZIB   Fill AMDA_... cor...
915
			else if ((isNAN(pYAxis->_tick._lengthFactor)) && (DEFAULT_TICK_LENGTH_FACTOR > VERTICAL_TICK_LENGTH_LIMIT))
ba6124b0   Menouard AZIB   Add parameter id ...
916
917
918
			{
				lTickLengthFactor = DEFAULT_TICK_LENGTH_FACTOR;
			}
fbe3c2bb   Benjamin Renard   First commit
919

ba6124b0   Menouard AZIB   Add parameter id ...
920
921
922
923
924
			if (lTickLengthFactor != 0)
			{
				// 1 character size is equal to 0.75 tick length.
				PlPlotUtil::setPlFont(_panel->getFont());
				double lTickMarkSpace = (lTickLengthFactor - VERTICAL_TICK_LENGTH_LIMIT) * (PlPlotUtil::getCharacterSizeInPlPage(_panel->_page).second) / (DEFAULT_TICK_LENGTH_FACTOR);
fbe3c2bb   Benjamin Renard   First commit
925

ba6124b0   Menouard AZIB   Add parameter id ...
926
				size_t lPos;
fbe3c2bb   Benjamin Renard   First commit
927

ba6124b0   Menouard AZIB   Add parameter id ...
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
				if ((lPos = lAxisOption.find("m")) != std::string::npos)
				{
					lTmpAxisOption += "m";
					lAxisOption.replace(lPos, 1, "");
				}
				if ((lPos = lAxisOption.find("n")) != std::string::npos)
				{
					lTmpAxisOption += "n";
					lAxisOption.replace(lPos, 1, "");
				}
				if ((lPos = lAxisOption.find("o")) != std::string::npos)
				{
					lTmpAxisOption += "o";
					lAxisOption.replace(lPos, 1, "");
				}
				if ((lPos = lAxisOption.find("f")) != std::string::npos)
				{
					lTmpAxisOption += "f";
					lAxisOption.replace(lPos, 1, "");
				}
				if (lAxisOption.find("l") != std::string::npos)
				{
					// Do not remove on original axis option
					// because option is needed to draw logarithmic tick.
					lTmpAxisOption += "l";
				}
fbe3c2bb   Benjamin Renard   First commit
954

ba6124b0   Menouard AZIB   Add parameter id ...
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
				// Set plot area used to draw tick mark
				if (pYAxis->_position == PlotCommon::Position::POS_LEFT)
				{
					_pls->vpor(pPlotAreaSize._x - lTickMarkSpace - axisOffset,
							   pPlotAreaSize._x + pPlotAreaSize._width,
							   pPlotAreaSize._y,
							   pPlotAreaSize._y + pPlotAreaSize._height);
				}
				else
				{
					_pls->vpor(pPlotAreaSize._x,
							   pPlotAreaSize._x + pPlotAreaSize._width + lTickMarkSpace + axisOffset,
							   pPlotAreaSize._y,
							   pPlotAreaSize._y + pPlotAreaSize._height);
				}
fbe3c2bb   Benjamin Renard   First commit
970

ba6124b0   Menouard AZIB   Add parameter id ...
971
972
				_pls->wind(std::get<0>(pPlWindow), std::get<1>(pPlWindow),
						   std::get<2>(pPlWindow), std::get<3>(pPlWindow));
fbe3c2bb   Benjamin Renard   First commit
973

ba6124b0   Menouard AZIB   Add parameter id ...
974
975
				// Draw tick mark.
				drawAxis(pYAxis, pTickConf, "", lTmpAxisOption);
fbe3c2bb   Benjamin Renard   First commit
976
			}
fbe3c2bb   Benjamin Renard   First commit
977
		}
fbe3c2bb   Benjamin Renard   First commit
978

ba6124b0   Menouard AZIB   Add parameter id ...
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
		// Set plot area used to draw tick
		if (pYAxis->_position == PlotCommon::Position::POS_LEFT)
		{
			_pls->vpor(pPlotAreaSize._x - axisOffset,
					   pPlotAreaSize._x + pPlotAreaSize._width,
					   pPlotAreaSize._y,
					   pPlotAreaSize._y + pPlotAreaSize._height);
		}
		else
		{
			_pls->vpor(pPlotAreaSize._x,
					   pPlotAreaSize._x + pPlotAreaSize._width + axisOffset,
					   pPlotAreaSize._y,
					   pPlotAreaSize._y + pPlotAreaSize._height);
		}
fbe3c2bb   Benjamin Renard   First commit
994

ba6124b0   Menouard AZIB   Add parameter id ...
995
996
997
		// Set window.
		_pls->wind(std::get<0>(pPlWindow), std::get<1>(pPlWindow),
				   std::get<2>(pPlWindow), std::get<3>(pPlWindow));
fbe3c2bb   Benjamin Renard   First commit
998

ba6124b0   Menouard AZIB   Add parameter id ...
999
1000
1001
1002
1003
		// Check if origin must be drawn.
		if (std::get<0>(pPlWindow) != 0 && std::get<1>(pPlWindow) && pYAxis->_origin == 0)
		{
			lAxisOption += "a";
		}
fbe3c2bb   Benjamin Renard   First commit
1004

ba6124b0   Menouard AZIB   Add parameter id ...
1005
1006
		// Check if opposite plot area side need to be drawn
		lAxisOption += drawOppositeSide(pYAxis);
fbe3c2bb   Benjamin Renard   First commit
1007

ba6124b0   Menouard AZIB   Add parameter id ...
1008
1009
		// Draw rest of axis.
		drawAxis(pYAxis, pTickConf, "", lAxisOption);
fbe3c2bb   Benjamin Renard   First commit
1010

ba6124b0   Menouard AZIB   Add parameter id ...
1011
1012
1013
1014
1015
		// Restore default plot area
		_pls->vpor(pPlotAreaSize._x,
				   pPlotAreaSize._x + pPlotAreaSize._width,
				   pPlotAreaSize._y,
				   pPlotAreaSize._y + pPlotAreaSize._height);
fbe3c2bb   Benjamin Renard   First commit
1016

ba6124b0   Menouard AZIB   Add parameter id ...
1017
1018
1019
1020
		// Set window.
		_pls->wind(std::get<0>(pPlWindow), std::get<1>(pPlWindow),
				   std::get<2>(pPlWindow), std::get<3>(pPlWindow));
	}
fbe3c2bb   Benjamin Renard   First commit
1021
1022
1023
1024

#define COLORBAR_X_OFFSET 0.01
#define COLORBAR_BODY_WIDTH 0.0375

ba6124b0   Menouard AZIB   Add parameter id ...
1025
1026
1027
	double PanelPlotOutput::estimateZAxisWidth(boost::shared_ptr<Axis> pZAxis)
	{
		double axisWidth = (COLORBAR_X_OFFSET + COLORBAR_BODY_WIDTH) * _panel->_bounds._width;
fbe3c2bb   Benjamin Renard   First commit
1028

ba6124b0   Menouard AZIB   Add parameter id ...
1029
1030
		PlPlotUtil::setPlFont(_panel->getFont());
		CharSize lCharSize = PlPlotUtil::getCharacterSizeInPlPage(_panel->_page);
fbe3c2bb   Benjamin Renard   First commit
1031

ba6124b0   Menouard AZIB   Add parameter id ...
1032
		int nbLineLegend = pZAxis->_legend.getNbLines();
fbe3c2bb   Benjamin Renard   First commit
1033

ba6124b0   Menouard AZIB   Add parameter id ...
1034
1035
1036
1037
1038
1039
1040
		if ((pZAxis->_showLegend == true) && (nbLineLegend != 0))
		{
			if (_panel->_page->_orientation == PlotCommon::Orientation::LANDSCAPE)
				axisWidth += lCharSize.second * (2 * nbLineLegend + 1);
			else
				axisWidth += lCharSize.first * (2 * nbLineLegend + 1);
		}
fbe3c2bb   Benjamin Renard   First commit
1041

ba6124b0   Menouard AZIB   Add parameter id ...
1042
1043
		return axisWidth;
	}
fbe3c2bb   Benjamin Renard   First commit
1044

ba6124b0   Menouard AZIB   Add parameter id ...
1045
1046
1047
1048
	void PanelPlotOutput::drawZAxis(boost::shared_ptr<Axis> pZAxis, PlWindow &pPlWindow, Bounds &pPlotAreaSize, TickConf & /*pTickConf*/)
	{
		Color lInitialColor;
		_pls->gcol0(0, lInitialColor._red, lInitialColor._green, lInitialColor._blue);
fbe3c2bb   Benjamin Renard   First commit
1049

ba6124b0   Menouard AZIB   Add parameter id ...
1050
1051
		// Set axis thickness.
		_pls->width(pZAxis->_thickness);
fbe3c2bb   Benjamin Renard   First commit
1052

ba6124b0   Menouard AZIB   Add parameter id ...
1053
1054
		// Set line style (force to be plain)
		_pls->lsty(static_cast<int>(getPlLineStyle(LineStyle::PLAIN)));
fbe3c2bb   Benjamin Renard   First commit
1055

ba6124b0   Menouard AZIB   Add parameter id ...
1056
1057
		// Set font to draw axes.
		PlPlotUtil::setPlFont(_panel->getFont());
fbe3c2bb   Benjamin Renard   First commit
1058

ba6124b0   Menouard AZIB   Add parameter id ...
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
		std::string lAxisOption = pZAxis->getPlotOpt();
		std::string lAxisLegend = "";
		std::list<std::pair<std::string, Color>> lines = pZAxis->_legend.getLines();
		for (auto line : lines)
		{
			if (line.first.empty())
			{
				continue;
			}
			if (!lAxisLegend.empty())
			{
				lAxisLegend += "\n";
			}
			lAxisLegend += line.first;
8bb0f02b   Benjamin Renard   Set colors in axi...
1073
		}
fbe3c2bb   Benjamin Renard   First commit
1074

ba6124b0   Menouard AZIB   Add parameter id ...
1075
1076
1077
		PLFLT colorbar_width, colorbar_height;
		const int cont_color = 0;
		const PLFLT cont_width = 0.0;
fbe3c2bb   Benjamin Renard   First commit
1078

ba6124b0   Menouard AZIB   Add parameter id ...
1079
1080
1081
		// set legend
		const PLINT n_labels = (lAxisLegend.empty()) ? 0 : 1;
		std::string label = lAxisLegend;
fbe3c2bb   Benjamin Renard   First commit
1082

ba6124b0   Menouard AZIB   Add parameter id ...
1083
1084
1085
		const char *labels[n_labels];
		if (!lAxisLegend.empty())
			labels[0] = label.c_str();
fbe3c2bb   Benjamin Renard   First commit
1086

ba6124b0   Menouard AZIB   Add parameter id ...
1087
1088
1089
		// set axis options
		const PLINT n_axis_opts = 1;
		const char *axis_opts[n_axis_opts] = {
fbe3c2bb   Benjamin Renard   First commit
1090
			lAxisOption.c_str(),
ba6124b0   Menouard AZIB   Add parameter id ...
1091
		};
fbe3c2bb   Benjamin Renard   First commit
1092

ba6124b0   Menouard AZIB   Add parameter id ...
1093
1094
1095
1096
		PLFLT axis_ticks[n_axis_opts] = {
			0};
		PLINT axis_subticks[n_axis_opts] = {
			0};
fbe3c2bb   Benjamin Renard   First commit
1097

ba6124b0   Menouard AZIB   Add parameter id ...
1098
1099
1100
1101
1102
		// if options contains "o" character we need to set label function
		if (lAxisOption.find("o") != std::string::npos)
		{
			_pls->slabelfunc(pZAxis->_labelGenerator->_function, pZAxis->_labelGenerator->_data);
		}
fbe3c2bb   Benjamin Renard   First commit
1103

ba6124b0   Menouard AZIB   Add parameter id ...
1104
1105
		// set nb og colors
		const int nbCol = 20;
fbe3c2bb   Benjamin Renard   First commit
1106

ba6124b0   Menouard AZIB   Add parameter id ...
1107
1108
		PLINT num_values[1] = {
			nbCol + 1};
fbe3c2bb   Benjamin Renard   First commit
1109

ba6124b0   Menouard AZIB   Add parameter id ...
1110
		Range r = pZAxis->getRange();
fbe3c2bb   Benjamin Renard   First commit
1111

ba6124b0   Menouard AZIB   Add parameter id ...
1112
		PLFLT *shedge = new PLFLT[nbCol + 1];
fbe3c2bb   Benjamin Renard   First commit
1113

ba6124b0   Menouard AZIB   Add parameter id ...
1114
		ShadesTools::computeEdgesLevels(r, nbCol + 1, shedge);
fbe3c2bb   Benjamin Renard   First commit
1115

ba6124b0   Menouard AZIB   Add parameter id ...
1116
1117
		PLFLT *values[1];
		values[0] = shedge;
fbe3c2bb   Benjamin Renard   First commit
1118

ba6124b0   Menouard AZIB   Add parameter id ...
1119
1120
		// set color map
		_pls->spal1(
fbe3c2bb   Benjamin Renard   First commit
1121
1122
			ColormapManager::getInstance().getColorAxis(pZAxis->_color._colorMapIndex).c_str(), true);

ba6124b0   Menouard AZIB   Add parameter id ...
1123
1124
1125
		// set color bar and legend position
		PLINT position = PL_POSITION_OUTSIDE | PL_POSITION_VIEWPORT;
		PLINT label_opts[1];
fbe3c2bb   Benjamin Renard   First commit
1126

ba6124b0   Menouard AZIB   Add parameter id ...
1127
1128
1129
		switch (pZAxis->_position)
		{
		case PlotCommon::Position::POS_LEFT:
fbe3c2bb   Benjamin Renard   First commit
1130
1131
			position |= PL_POSITION_LEFT;
			label_opts[0] = PL_COLORBAR_LABEL_LEFT;
b76d3cfc   Benjamin Renard   Fix color axis po...
1132
			_pls->vpor(pPlotAreaSize._x - pZAxis->getAxisOffset(), pPlotAreaSize._x + pPlotAreaSize._width, pPlotAreaSize._y, pPlotAreaSize._y + pPlotAreaSize._height);
fbe3c2bb   Benjamin Renard   First commit
1133
			break;
ba6124b0   Menouard AZIB   Add parameter id ...
1134
		case PlotCommon::Position::POS_RIGHT:
fbe3c2bb   Benjamin Renard   First commit
1135
1136
			position |= PL_POSITION_RIGHT;
			label_opts[0] = PL_COLORBAR_LABEL_RIGHT;
b76d3cfc   Benjamin Renard   Fix color axis po...
1137
			_pls->vpor(pPlotAreaSize._x, pPlotAreaSize._x + pPlotAreaSize._width + pZAxis->getAxisOffset(), pPlotAreaSize._y, pPlotAreaSize._y + pPlotAreaSize._height);
fbe3c2bb   Benjamin Renard   First commit
1138
1139
1140
1141
1142
1143
			break;
		default:
		{
			std::stringstream lError;
			lError << "PanelPlotOutput::drawZAxis : Bad Z axis position";
			BOOST_THROW_EXCEPTION(
ba6124b0   Menouard AZIB   Add parameter id ...
1144
1145
				PanelPlotOutputException() << AMDA::ex_msg(lError.str()));
		}
fbe3c2bb   Benjamin Renard   First commit
1146
		}
fbe3c2bb   Benjamin Renard   First commit
1147

ba6124b0   Menouard AZIB   Add parameter id ...
1148
		_pls->wind(std::get<0>(pPlWindow), std::get<1>(pPlWindow), std::get<2>(pPlWindow), std::get<3>(pPlWindow));
b76d3cfc   Benjamin Renard   Fix color axis po...
1149

ba6124b0   Menouard AZIB   Add parameter id ...
1150
		_pls->colorbar(
fbe3c2bb   Benjamin Renard   First commit
1151
1152
			&colorbar_width,
			&colorbar_height,
ba6124b0   Menouard AZIB   Add parameter id ...
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
			PL_COLORBAR_GRADIENT, // PL_COLORBAR_SHADE,
			position,
			0.0, // COLORBAR_X_OFFSET,
			0.0,
			COLORBAR_BODY_WIDTH,
			0.875,
			0, /*bg_color*/
			1,
			1,
			0.0,
			0.0,
			cont_color,
			cont_width,
			n_labels,
			label_opts,
			labels,
			n_axis_opts,
			axis_opts,
			axis_ticks,
			axis_subticks,
			num_values,
			(const PLFLT *const *)values);

		// reset color map
		_pls->spal1(
			ColormapManager::getInstance().get(_panel->_page->_mode,
											   ColormapManager::DEFAULT_COLORMAP_1)
				.c_str(),
			true);

		_pls->scol0(0, lInitialColor._red, lInitialColor._green, lInitialColor._blue);

		delete[] shedge;

		// Restore initial color.
		restoreColor(_pls, lInitialColor, _panel->_page->_mode);

		// Restore default plot area
		_pls->vpor(pPlotAreaSize._x,
				   pPlotAreaSize._x + pPlotAreaSize._width,
				   pPlotAreaSize._y,
				   pPlotAreaSize._y + pPlotAreaSize._height);

		_pls->wind(std::get<0>(pPlWindow), std::get<1>(pPlWindow), std::get<2>(pPlWindow), std::get<3>(pPlWindow));

		// Set axis as drawn.
		pZAxis->_drawn = true;
fbe3c2bb   Benjamin Renard   First commit
1200
	}
fbe3c2bb   Benjamin Renard   First commit
1201

ba6124b0   Menouard AZIB   Add parameter id ...
1202
1203
	Range PanelPlotOutput::getXAxisRange(SeriesProperties &pSeries, boost::shared_ptr<Axis> pAxis)
	{
fbe3c2bb   Benjamin Renard   First commit
1204

ba6124b0   Menouard AZIB   Add parameter id ...
1205
1206
1207
1208
1209
1210
1211
		if (pSeries.hasXAxis() && pAxis.get() == nullptr)
		{
			std::stringstream lError;
			lError << "PanelPlotOutput::drawSeries"
				   << ": X axis with id '"
				   << pSeries.getXAxisId() << "' not found.";
			BOOST_THROW_EXCEPTION(
fbe3c2bb   Benjamin Renard   First commit
1212
				PanelPlotOutputException() << AMDA::ex_msg(lError.str()));
ba6124b0   Menouard AZIB   Add parameter id ...
1213
1214
1215
1216
1217
1218
1219
		}
		else if (pSeries.hasXAxis())
		{
			// fill X range (plplot window).
			return (pAxis->getRange());
		}
		return Range();
fbe3c2bb   Benjamin Renard   First commit
1220
	}
fbe3c2bb   Benjamin Renard   First commit
1221

ba6124b0   Menouard AZIB   Add parameter id ...
1222
1223
	Range PanelPlotOutput::getYAxisRange(SeriesProperties &pSeries, boost::shared_ptr<Axis> pAxis)
	{
fbe3c2bb   Benjamin Renard   First commit
1224

ba6124b0   Menouard AZIB   Add parameter id ...
1225
1226
1227
1228
1229
1230
1231
		if (pSeries.hasYAxis() && pAxis.get() == nullptr)
		{
			std::stringstream lError;
			lError << "PanelPlotOutput::drawSeries"
				   << ": Y axis with id '"
				   << pSeries.getYAxisId() << "' not found.";
			BOOST_THROW_EXCEPTION(
fbe3c2bb   Benjamin Renard   First commit
1232
				PanelPlotOutputException() << AMDA::ex_msg(lError.str()));
ba6124b0   Menouard AZIB   Add parameter id ...
1233
1234
1235
1236
1237
1238
1239
		}
		else if (pSeries.hasYAxis())
		{
			// fill Y range (plplot window).
			return (pAxis->getRange());
		}
		return Range();
fbe3c2bb   Benjamin Renard   First commit
1240
	}
fbe3c2bb   Benjamin Renard   First commit
1241

ba6124b0   Menouard AZIB   Add parameter id ...
1242
1243
	Range PanelPlotOutput::getZAxisRange(SeriesProperties &pSeries, boost::shared_ptr<Axis> pAxis)
	{
fbe3c2bb   Benjamin Renard   First commit
1244

ba6124b0   Menouard AZIB   Add parameter id ...
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
		if (pSeries.hasZAxis() && pAxis.get() == nullptr)
		{
			std::stringstream lError;
			lError << "PanelPlotOutput::drawSeries"
				   << ": Z axis with id '"
				   << pSeries.getYAxisId() << "' not found.";
			BOOST_THROW_EXCEPTION(
				PanelPlotOutputException() << AMDA::ex_msg(lError.str()));
		}
		else if (pSeries.hasZAxis())
		{
			// fill Z range (plplot window).
			return (pAxis->getRange());
		}
		return Range();
	}
fbe3c2bb   Benjamin Renard   First commit
1261

ba6124b0   Menouard AZIB   Add parameter id ...
1262
1263
1264
1265
1266
1267
1268
	/**
	 * Convert an X axis string value to a double X value
	 */
	double PanelPlotOutput::convertXAxisValue(const std::string &value)
	{
		return std::stod(value);
	}
fbe3c2bb   Benjamin Renard   First commit
1269

ba6124b0   Menouard AZIB   Add parameter id ...
1270
1271
1272
1273
1274
1275
1276
	/**
	 * Convert an Y axis string value to a double Y value
	 */
	double PanelPlotOutput::convertYAxisValue(const std::string &value)
	{
		return std::stod(value);
	}
fbe3c2bb   Benjamin Renard   First commit
1277

ba6124b0   Menouard AZIB   Add parameter id ...
1278
1279
1280
1281
1282
1283
	/**
	 * Get colored value associated to a data value. Return false if the value is filtered.
	 */
	bool PanelPlotOutput::getColoredValue(double value, double filterMin, double filterMax, bool useLog0AsMin, PLFLT &col)
	{
		boost::shared_ptr<ColorAxis> lZAxis = _panel->getColorAxis();
fbe3c2bb   Benjamin Renard   First commit
1284

ba6124b0   Menouard AZIB   Add parameter id ...
1285
1286
		if (lZAxis == nullptr)
			return false;
fbe3c2bb   Benjamin Renard   First commit
1287

ba6124b0   Menouard AZIB   Add parameter id ...
1288
		bool filterMinMax = (isNAN(filterMin) == false) || (isNAN(filterMax) == false);
fbe3c2bb   Benjamin Renard   First commit
1289

ba6124b0   Menouard AZIB   Add parameter id ...
1290
		Range r = lZAxis->getRange();
fbe3c2bb   Benjamin Renard   First commit
1291

d78eca08   Menouard AZIB   Fill AMDA_... cor...
1292
		if (isNAN(value))
ba6124b0   Menouard AZIB   Add parameter id ...
1293
			return false;
fbe3c2bb   Benjamin Renard   First commit
1294

ba6124b0   Menouard AZIB   Add parameter id ...
1295
		if ((filterMinMax == true) && ((value < filterMin) || (value > filterMax)))
fbe3c2bb   Benjamin Renard   First commit
1296
			return false;
fbe3c2bb   Benjamin Renard   First commit
1297

ba6124b0   Menouard AZIB   Add parameter id ...
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
		double correctedValue = value;
		if (lZAxis->_scale == Axis::Scale::LOGARITHMIC)
		{
			if (correctedValue <= 0)
			{
				if (useLog0AsMin)
				{
					col = 0;
					return true;
				}
				return false;
			}
fbe3c2bb   Benjamin Renard   First commit
1310

ba6124b0   Menouard AZIB   Add parameter id ...
1311
1312
			correctedValue = log10(correctedValue);
		}
fbe3c2bb   Benjamin Renard   First commit
1313

ba6124b0   Menouard AZIB   Add parameter id ...
1314
1315
1316
1317
		if (!lZAxis->_reverse)
			col = (correctedValue - r.getMin()) / (r.getMax() - r.getMin());
		else
			col = (correctedValue - r.getMax()) / (r.getMin() - r.getMax());
fbe3c2bb   Benjamin Renard   First commit
1318

ba6124b0   Menouard AZIB   Add parameter id ...
1319
1320
		return true;
	}
fbe3c2bb   Benjamin Renard   First commit
1321

ba6124b0   Menouard AZIB   Add parameter id ...
1322
1323
1324
1325
1326
1327
1328
1329
	/**
	 * Draw list of symbols
	 */
	void PanelPlotOutput::drawSymbols(SymbolType pType, int pSize, double pFactor, Color pColor,
									  int pNbData, double *pXData, double *pYData, double *pZData, double filterZMin, double filterZMax)
	{
		if (pType == SymbolType::NO)
			return;
fbe3c2bb   Benjamin Renard   First commit
1330

ba6124b0   Menouard AZIB   Add parameter id ...
1331
		Color lInitialColor;
fbe3c2bb   Benjamin Renard   First commit
1332

ba6124b0   Menouard AZIB   Add parameter id ...
1333
1334
		// Set color.
		lInitialColor = changeColor(_pls, pColor, _panel->_page->_mode);
f6eaec4e   Benjamin Renard   Optimize plot ele...
1335

ba6124b0   Menouard AZIB   Add parameter id ...
1336
		PlPlotUtil::setPlFont(_panel->_page->getFont());
3befa3ce   Benjamin Renard   Fix a bug with sy...
1337

ba6124b0   Menouard AZIB   Add parameter id ...
1338
1339
		// Set size.
		_pls->ssym(pSize, pFactor);
fbe3c2bb   Benjamin Renard   First commit
1340

ba6124b0   Menouard AZIB   Add parameter id ...
1341
1342
		// Get colored axis
		boost::shared_ptr<ColorAxis> lZAxis = _panel->getColorAxis();
fbe3c2bb   Benjamin Renard   First commit
1343

ba6124b0   Menouard AZIB   Add parameter id ...
1344
1345
1346
1347
1348
1349
1350
1351
		// draw symbols
		if ((pZData == NULL) || (lZAxis == nullptr))
			_pls->poin(pNbData, pXData, pYData, static_cast<int>(pType));
		else
		{
			// set color map
			_pls->spal1(
				ColormapManager::getInstance().getColorAxis(lZAxis->_color._colorMapIndex).c_str(), true);
fbe3c2bb   Benjamin Renard   First commit
1352

ba6124b0   Menouard AZIB   Add parameter id ...
1353
1354
1355
			// get specific colors for min / max values
			Color minValColor = lZAxis->getMinValColor();
			Color maxValColor = lZAxis->getMaxValColor();
fbe3c2bb   Benjamin Renard   First commit
1356

ba6124b0   Menouard AZIB   Add parameter id ...
1357
1358
1359
1360
1361
			PLFLT col;
			for (int i = 0; i < pNbData; ++i)
			{
				if (!getColoredValue(pZData[i], filterZMin, filterZMax, false, col))
					continue;
fbe3c2bb   Benjamin Renard   First commit
1362

ba6124b0   Menouard AZIB   Add parameter id ...
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
				if (col <= 0.)
				{
					if (minValColor.isSet())
					{
						restoreColor(_pls, minValColor, _panel->_page->_mode);
						_pls->poin(1, &pXData[i], &pYData[i], static_cast<int>(pType));
						_pls->spal1(ColormapManager::getInstance().getColorAxis(lZAxis->_color._colorMapIndex).c_str(), true);
					}
					else
					{
						_pls->col1(0);
						_pls->poin(1, &pXData[i], &pYData[i], static_cast<int>(pType));
					}
				}
				else if (col >= 1.)
				{
					if (maxValColor.isSet())
					{
						restoreColor(_pls, maxValColor, _panel->_page->_mode);
						_pls->poin(1, &pXData[i], &pYData[i], static_cast<int>(pType));
						_pls->spal1(ColormapManager::getInstance().getColorAxis(lZAxis->_color._colorMapIndex).c_str(), true);
					}
					else
					{
						_pls->col1(1);
						_pls->poin(1, &pXData[i], &pYData[i], static_cast<int>(pType));
					}
				}
				else
				{
					_pls->col1(col);
fbe3c2bb   Benjamin Renard   First commit
1394
					_pls->poin(1, &pXData[i], &pYData[i], static_cast<int>(pType));
ba6124b0   Menouard AZIB   Add parameter id ...
1395
1396
1397
				}
			}
		}
fbe3c2bb   Benjamin Renard   First commit
1398

ba6124b0   Menouard AZIB   Add parameter id ...
1399
1400
		// Restore color.
		restoreColor(_pls, lInitialColor, _panel->_page->_mode);
fbe3c2bb   Benjamin Renard   First commit
1401
1402
	}

ba6124b0   Menouard AZIB   Add parameter id ...
1403
1404
1405
1406
1407
1408
1409
1410
	/**
	 * Draw list of lines
	 */
	void PanelPlotOutput::drawLines(LineType pType, LineStyle pStyle, int pWidth, Color &pColor,
									int pNbData, double *pXData, double *pYData, double *pZData, double filterZMin, double filterZMax)
	{
		if (pType == LineType::EMPTY)
			return;
fbe3c2bb   Benjamin Renard   First commit
1411

ba6124b0   Menouard AZIB   Add parameter id ...
1412
1413
1414
1415
		if (pType != LineType::LINE)
		{
			BOOST_THROW_EXCEPTION(PanelPlotOutputException() << AMDA::ex_msg("HISTO line type can't be used in time plot. Use LINE or EMPTY type"));
		}
fbe3c2bb   Benjamin Renard   First commit
1416

ba6124b0   Menouard AZIB   Add parameter id ...
1417
		Color lInitialColor;
fbe3c2bb   Benjamin Renard   First commit
1418

ba6124b0   Menouard AZIB   Add parameter id ...
1419
1420
		// Set color.
		lInitialColor = changeColor(_pls, pColor, _panel->_page->_mode);
fbe3c2bb   Benjamin Renard   First commit
1421

ba6124b0   Menouard AZIB   Add parameter id ...
1422
1423
		// Set line type.
		_pls->lsty(static_cast<int>(getPlLineStyle(pStyle)));
fbe3c2bb   Benjamin Renard   First commit
1424

ba6124b0   Menouard AZIB   Add parameter id ...
1425
1426
		// Set line thickness.
		_pls->width(pWidth);
fbe3c2bb   Benjamin Renard   First commit
1427

ba6124b0   Menouard AZIB   Add parameter id ...
1428
1429
		// Get colored axis
		boost::shared_ptr<ColorAxis> lZAxis = _panel->getColorAxis();
fbe3c2bb   Benjamin Renard   First commit
1430

ba6124b0   Menouard AZIB   Add parameter id ...
1431
1432
		// draw lines.
		if ((pZData == NULL) || (lZAxis == nullptr))
fbe3c2bb   Benjamin Renard   First commit
1433
		{
ba6124b0   Menouard AZIB   Add parameter id ...
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
			_pls->line(pNbData, pXData, pYData);
		}
		else
		{
			// set color map
			_pls->spal1(
				ColormapManager::getInstance().getColorAxis(lZAxis->_color._colorMapIndex).c_str(), true);

			// get specific colors for min / max values
			Color minValColor = lZAxis->getMinValColor();
			Color maxValColor = lZAxis->getMaxValColor();

			PLFLT col;
			for (int i = 0; i < pNbData - 1; ++i)
			{
				if (!getColoredValue(pZData[i], filterZMin, filterZMax, false, col))
					continue;
fbe3c2bb   Benjamin Renard   First commit
1451

ba6124b0   Menouard AZIB   Add parameter id ...
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
				if (col <= 0.)
				{
					if (minValColor.isSet())
					{
						restoreColor(_pls, minValColor, _panel->_page->_mode);
						_pls->line(2, &pXData[i], &pYData[i]);
						_pls->spal1(ColormapManager::getInstance().getColorAxis(lZAxis->_color._colorMapIndex).c_str(), true);
					}
					else
					{
						_pls->col1(0);
						_pls->line(2, &pXData[i], &pYData[i]);
					}
				}
				else if (col >= 1.)
				{
					if (maxValColor.isSet())
					{
						restoreColor(_pls, maxValColor, _panel->_page->_mode);
						_pls->line(2, &pXData[i], &pYData[i]);
						_pls->spal1(ColormapManager::getInstance().getColorAxis(lZAxis->_color._colorMapIndex).c_str(), true);
					}
					else
					{
						_pls->col1(1);
						_pls->line(2, &pXData[i], &pYData[i]);
					}
				}
				else
				{
					_pls->col1(col);
fbe3c2bb   Benjamin Renard   First commit
1483
					_pls->line(2, &pXData[i], &pYData[i]);
ba6124b0   Menouard AZIB   Add parameter id ...
1484
1485
1486
				}
			}
		}
e257cfb9   Benjamin Renard   First implementat...
1487

ba6124b0   Menouard AZIB   Add parameter id ...
1488
1489
1490
		// Restore color.
		restoreColor(_pls, lInitialColor, _panel->_page->_mode);
	}
fbe3c2bb   Benjamin Renard   First commit
1491

ba6124b0   Menouard AZIB   Add parameter id ...
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
	/**
	 * Draw a rectangle
	 */
	void PanelPlotOutput::drawRectangle(double xmin, double xmax, double ymin, double ymax, Color &color, double alpha)
	{
		if (!color.isSet())
		{
			return;
		}

		Color lInitialColor;
fbe3c2bb   Benjamin Renard   First commit
1503

ba6124b0   Menouard AZIB   Add parameter id ...
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
		// Set color.
		lInitialColor = changeColor(_pls, color, _panel->_page->_mode);

		// Draw rectangle
		PLFLT x[4], y[4];

		x[0] = xmin;
		x[1] = xmin;
		x[2] = xmax;
		x[3] = xmax;
		y[0] = ymin;
		y[1] = ymax;
		y[2] = ymax;
		y[3] = ymin;

		// Fill rectangle
		PLINT icol = 0;
		PLINT r, g, b = 0;
		PLFLT a = 0;
		_pls->gcol0a(icol, r, g, b, a);
		a = alpha;
		_pls->scol0a(icol, r, g, b, a);
		_pls->col0(icol);
		_pls->fill(4, x, y);

		// Restore color.
		restoreColor(_pls, lInitialColor, _panel->_page->_mode);
	}
fbe3c2bb   Benjamin Renard   First commit
1532

ba6124b0   Menouard AZIB   Add parameter id ...
1533
1534
1535
1536
1537
	/*
	 * @brief Draw a matrix
	 */
	void PanelPlotOutput::drawMatrix(MatrixGrid &matrixGrid, double minDataVal, double maxDataVal,
									 Color minValColor, Color maxValColor, int colorMapIndex, bool useLog0AsMin)
fbe3c2bb   Benjamin Renard   First commit
1538
	{
ba6124b0   Menouard AZIB   Add parameter id ...
1539
1540
1541
		// set color map
		_pls->spal1(
			ColormapManager::getInstance().getColorAxis(colorMapIndex).c_str(), true);
fbe3c2bb   Benjamin Renard   First commit
1542

ba6124b0   Menouard AZIB   Add parameter id ...
1543
1544
		Color lInitialColor;
		_pls->gcol0(0, lInitialColor._red, lInitialColor._green, lInitialColor._blue);
fbe3c2bb   Benjamin Renard   First commit
1545

ba6124b0   Menouard AZIB   Add parameter id ...
1546
1547
1548
		// plot matrix
		PLFLT x[4], y[4];
		PLFLT col;
f2db3c16   Benjamin Renard   Support variable ...
1549

ba6124b0   Menouard AZIB   Add parameter id ...
1550
		for (auto part : matrixGrid)
fbe3c2bb   Benjamin Renard   First commit
1551
		{
ba6124b0   Menouard AZIB   Add parameter id ...
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
			x[0] = part.x[0];
			x[1] = part.x[1];
			x[2] = x[1];
			x[3] = x[0];

			y[0] = part.y[0];
			y[1] = y[0];
			y[2] = part.y[1];
			y[3] = y[2];

			if (isNAN(part.value))
fbe3c2bb   Benjamin Renard   First commit
1563
				continue;
fbe3c2bb   Benjamin Renard   First commit
1564

ba6124b0   Menouard AZIB   Add parameter id ...
1565
			if (!part.isColorIndex)
fbe3c2bb   Benjamin Renard   First commit
1566
			{
ba6124b0   Menouard AZIB   Add parameter id ...
1567
1568
				if (!getColoredValue(part.value, minDataVal, maxDataVal, useLog0AsMin, col))
					continue;
fbe3c2bb   Benjamin Renard   First commit
1569
1570
1571
			}
			else
			{
ba6124b0   Menouard AZIB   Add parameter id ...
1572
1573
				Color dataValueColor(colorMapIndex, (int)part.value);
				restoreColor(_pls, dataValueColor, _panel->_page->_mode);
fbe3c2bb   Benjamin Renard   First commit
1574
				_pls->fill(4, x, y);
ba6124b0   Menouard AZIB   Add parameter id ...
1575
1576
				_pls->spal1(ColormapManager::getInstance().getColorAxis(colorMapIndex).c_str(), true);
				continue;
fbe3c2bb   Benjamin Renard   First commit
1577
			}
ba6124b0   Menouard AZIB   Add parameter id ...
1578
1579

			if (col <= 0.)
fbe3c2bb   Benjamin Renard   First commit
1580
			{
ba6124b0   Menouard AZIB   Add parameter id ...
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
				if (minValColor.isSet())
				{
					restoreColor(_pls, minValColor, _panel->_page->_mode);
					_pls->fill(4, x, y);
					_pls->spal1(ColormapManager::getInstance().getColorAxis(colorMapIndex).c_str(), true);
				}
				else
				{
					_pls->col1(0);
					_pls->fill(4, x, y);
				}
			}
			else if (col >= 1.)
			{
				if (maxValColor.isSet())
				{
					restoreColor(_pls, maxValColor, _panel->_page->_mode);
					_pls->fill(4, x, y);
					_pls->spal1(ColormapManager::getInstance().getColorAxis(colorMapIndex).c_str(), true);
				}
				else
				{
					_pls->col1(1);
					_pls->fill(4, x, y);
				}
fbe3c2bb   Benjamin Renard   First commit
1606
1607
1608
			}
			else
			{
ba6124b0   Menouard AZIB   Add parameter id ...
1609
				_pls->col1(col);
fbe3c2bb   Benjamin Renard   First commit
1610
1611
1612
				_pls->fill(4, x, y);
			}
		}
fbe3c2bb   Benjamin Renard   First commit
1613

ba6124b0   Menouard AZIB   Add parameter id ...
1614
1615
		// restore to initial color context
		_pls->spal1(
fbe3c2bb   Benjamin Renard   First commit
1616
			ColormapManager::getInstance().get(_panel->_page->_mode,
ba6124b0   Menouard AZIB   Add parameter id ...
1617
1618
1619
1620
											   ColormapManager::DEFAULT_COLORMAP_1)
				.c_str(),
			true);
		_pls->scol0(0, lInitialColor._red, lInitialColor._green, lInitialColor._blue);
fbe3c2bb   Benjamin Renard   First commit
1621

ba6124b0   Menouard AZIB   Add parameter id ...
1622
1623
1624
		// Restore color.
		restoreColor(_pls, lInitialColor, _panel->_page->_mode);
	}
fbe3c2bb   Benjamin Renard   First commit
1625

ba6124b0   Menouard AZIB   Add parameter id ...
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
	/**
	 * Draw errors segments
	 */
	void PanelPlotOutput::drawYErrors(
		LineType pType,
		LineStyle pStyle,
		int pWidth,
		Color &pColor,
		int pNbData,
		double *pXData,
		double *pYMinData,
		double *pYMaxData)
fbe3c2bb   Benjamin Renard   First commit
1638
	{
ba6124b0   Menouard AZIB   Add parameter id ...
1639
1640
		if (pType == LineType::EMPTY)
			return;
fbe3c2bb   Benjamin Renard   First commit
1641

ba6124b0   Menouard AZIB   Add parameter id ...
1642
1643
1644
1645
		if (pType != LineType::LINE)
		{
			BOOST_THROW_EXCEPTION(PanelPlotOutputException() << AMDA::ex_msg("HISTO line type can't be used in time plot. Use LINE or EMPTY type"));
		}
fbe3c2bb   Benjamin Renard   First commit
1646

ba6124b0   Menouard AZIB   Add parameter id ...
1647
		Color lInitialColor;
fbe3c2bb   Benjamin Renard   First commit
1648

ba6124b0   Menouard AZIB   Add parameter id ...
1649
1650
		// Set color.
		lInitialColor = changeColor(_pls, pColor, _panel->_page->_mode);
fbe3c2bb   Benjamin Renard   First commit
1651

ba6124b0   Menouard AZIB   Add parameter id ...
1652
1653
		// Set line type.
		_pls->lsty(static_cast<int>(getPlLineStyle(pStyle)));
fbe3c2bb   Benjamin Renard   First commit
1654

ba6124b0   Menouard AZIB   Add parameter id ...
1655
1656
		// Set line thickness.
		_pls->width(pWidth);
fbe3c2bb   Benjamin Renard   First commit
1657

ba6124b0   Menouard AZIB   Add parameter id ...
1658
1659
		// Set the default tich with
		_pls->smin(0, 0.5);
fbe3c2bb   Benjamin Renard   First commit
1660

ba6124b0   Menouard AZIB   Add parameter id ...
1661
1662
		// Draw error bars
		_pls->erry(pNbData, pXData, pYMinData, pYMaxData);
fbe3c2bb   Benjamin Renard   First commit
1663

ba6124b0   Menouard AZIB   Add parameter id ...
1664
1665
1666
		// Restore color.
		restoreColor(_pls, lInitialColor, _panel->_page->_mode);
	}
fbe3c2bb   Benjamin Renard   First commit
1667

ba6124b0   Menouard AZIB   Add parameter id ...
1668
1669
1670
1671
1672
1673
	/**
	 * Draws X constant lines linked to axis
	 */
	void PanelPlotOutput::drawXConstantLines(boost::shared_ptr<Axis> pAxis, PlWindow &pPlWindow)
	{
		double x[2], y[2];
078ec265   Benjamin Renard   Give the possibil...
1674

ba6124b0   Menouard AZIB   Add parameter id ...
1675
		_pls->wind(std::get<0>(pPlWindow), std::get<1>(pPlWindow), std::get<2>(pPlWindow), std::get<3>(pPlWindow));
fbe3c2bb   Benjamin Renard   First commit
1676

ba6124b0   Menouard AZIB   Add parameter id ...
1677
1678
1679
1680
1681
1682
1683
1684
		for (auto constantLine : pAxis->_constantLines)
		{
			if (constantLine->isDrawn())
				continue;
			x[0] = convertXAxisValue(constantLine->getValue());
			x[1] = convertXAxisValue(constantLine->getValue());
			y[0] = std::get<2>(pPlWindow);
			y[1] = std::get<3>(pPlWindow);
fbe3c2bb   Benjamin Renard   First commit
1685

ba6124b0   Menouard AZIB   Add parameter id ...
1686
1687
1688
1689
1690
1691
1692
			if (pAxis->_scale == Axis::Scale::LOGARITHMIC)
			{
				x[0] = log10(x[0]);
				x[1] = log10(x[1]);
			}

			drawLines(
fbe3c2bb   Benjamin Renard   First commit
1693
1694
1695
1696
1697
1698
				LineType::LINE,
				constantLine->getStyle(),
				constantLine->getWidth(),
				constantLine->getColor(),
				2, x, y);

ba6124b0   Menouard AZIB   Add parameter id ...
1699
1700
			constantLine->setDrawn(true);
		}
fbe3c2bb   Benjamin Renard   First commit
1701
	}
fbe3c2bb   Benjamin Renard   First commit
1702

ba6124b0   Menouard AZIB   Add parameter id ...
1703
1704
1705
1706
1707
1708
	/**
	 * Draws Y constant lines linked to axis
	 */
	void PanelPlotOutput::drawYConstantLines(boost::shared_ptr<Axis> pAxis, PlWindow &pPlWindow)
	{
		double x[2], y[2];
fbe3c2bb   Benjamin Renard   First commit
1709

ba6124b0   Menouard AZIB   Add parameter id ...
1710
		_pls->wind(std::get<0>(pPlWindow), std::get<1>(pPlWindow), std::get<2>(pPlWindow), std::get<3>(pPlWindow));
078ec265   Benjamin Renard   Give the possibil...
1711

ba6124b0   Menouard AZIB   Add parameter id ...
1712
1713
1714
1715
		for (auto constantLine : pAxis->_constantLines)
		{
			if (constantLine->isDrawn())
				continue;
fbe3c2bb   Benjamin Renard   First commit
1716

ba6124b0   Menouard AZIB   Add parameter id ...
1717
1718
1719
1720
			x[0] = std::get<0>(pPlWindow);
			x[1] = std::get<1>(pPlWindow);
			y[0] = convertYAxisValue(constantLine->getValue());
			y[1] = convertYAxisValue(constantLine->getValue());
fbe3c2bb   Benjamin Renard   First commit
1721

ba6124b0   Menouard AZIB   Add parameter id ...
1722
1723
1724
1725
1726
			if (pAxis->_scale == Axis::Scale::LOGARITHMIC)
			{
				y[0] = log10(y[0]);
				y[1] = log10(y[1]);
			}
fbe3c2bb   Benjamin Renard   First commit
1727

ba6124b0   Menouard AZIB   Add parameter id ...
1728
			drawLines(
fbe3c2bb   Benjamin Renard   First commit
1729
1730
1731
1732
1733
1734
				LineType::LINE,
				constantLine->getStyle(),
				constantLine->getWidth(),
				constantLine->getColor(),
				2, x, y);

ba6124b0   Menouard AZIB   Add parameter id ...
1735
1736
			constantLine->setDrawn(true);
		}
fbe3c2bb   Benjamin Renard   First commit
1737
	}
fbe3c2bb   Benjamin Renard   First commit
1738

ba6124b0   Menouard AZIB   Add parameter id ...
1739
1740
1741
1742
1743
1744
1745
	/**
	 * Draws TextPlots
	 */
	void PanelPlotOutput::drawTextPlots(boost::shared_ptr<Axis> pXAxis, boost::shared_ptr<Axis> pYAxis, PlWindow &pPlWindow, const TextPlots &textPlots)
	{
		double x, y;
		double x1, x2, y1, y2;
fbe3c2bb   Benjamin Renard   First commit
1746

ba6124b0   Menouard AZIB   Add parameter id ...
1747
1748
1749
1750
		x1 = std::get<0>(pPlWindow);
		x2 = std::get<1>(pPlWindow);
		y1 = std::get<2>(pPlWindow);
		y2 = std::get<3>(pPlWindow);
fbe3c2bb   Benjamin Renard   First commit
1751

ba6124b0   Menouard AZIB   Add parameter id ...
1752
		_pls->wind(x1, x2, y1, y2);
078ec265   Benjamin Renard   Give the possibil...
1753

ba6124b0   Menouard AZIB   Add parameter id ...
1754
1755
1756
1757
		for (auto textPlot : textPlots)
		{
			if (textPlot->isDrawn())
				continue;
fbe3c2bb   Benjamin Renard   First commit
1758

ba6124b0   Menouard AZIB   Add parameter id ...
1759
1760
			if (!textPlot->_xAxisId.empty() && (textPlot->_xAxisId.compare(pXAxis->_id) != 0))
				continue;
078ec265   Benjamin Renard   Give the possibil...
1761

ba6124b0   Menouard AZIB   Add parameter id ...
1762
1763
			if (!textPlot->_yAxisId.empty() && (textPlot->_yAxisId.compare(pYAxis->_id) != 0))
				continue;
078ec265   Benjamin Renard   Give the possibil...
1764

ba6124b0   Menouard AZIB   Add parameter id ...
1765
1766
1767
1768
1769
1770
1771
1772
1773
1774
1775
1776
1777
1778
			// Compute x y position for the text
			if (textPlot->_x.find("%") != std::string::npos)
			{
				// Remove % before conversion
				int pos = textPlot->_x.find("%");
				std::string xPos = textPlot->_x;
				xPos.erase(pos);
				// Compute x value as a percent of the x value
				x = x1 + (x2 - x1) * std::stod(xPos) / 100.0;
			}
			else
			{
				x = convertXAxisValue(textPlot->_x);
			}
fbe3c2bb   Benjamin Renard   First commit
1779

ba6124b0   Menouard AZIB   Add parameter id ...
1780
1781
1782
1783
1784
1785
1786
1787
1788
1789
1790
1791
1792
			if (textPlot->_y.find("%") != std::string::npos)
			{
				// Remove % before conversion
				int pos = textPlot->_y.find("%");
				std::string yPos = textPlot->_y;
				yPos.erase(pos);
				// Compute x value as a percent of the x value
				y = y1 + (y2 - y1) * std::stod(yPos) / 100.0;
			}
			else
			{
				y = convertYAxisValue(textPlot->_y);
			}
fbe3c2bb   Benjamin Renard   First commit
1793

ba6124b0   Menouard AZIB   Add parameter id ...
1794
1795
			// Select font family, size, style and weight
			PlPlotUtil::setPlFont(textPlot->getFont());
fbe3c2bb   Benjamin Renard   First commit
1796

ba6124b0   Menouard AZIB   Add parameter id ...
1797
1798
			// Set color
			Color lInitialColor = changeColor(_pls, textPlot->_color, _panel->_page->_mode);
fbe3c2bb   Benjamin Renard   First commit
1799

ba6124b0   Menouard AZIB   Add parameter id ...
1800
1801
1802
			// Compute dx & dy orientation
			double dx = cos(textPlot->_angle * M_PI / 180) * (x2 - x1) / 10.0;
			double dy = sin(textPlot->_angle * M_PI / 180) * (y2 - y1) / 10.0 * _panelPlotXYRatio;
fbe3c2bb   Benjamin Renard   First commit
1803

ba6124b0   Menouard AZIB   Add parameter id ...
1804
1805
			// Draw text
			_pls->ptex(x, y, dx, dy, textPlot->_align, textPlot->_text.c_str());
fbe3c2bb   Benjamin Renard   First commit
1806

ba6124b0   Menouard AZIB   Add parameter id ...
1807
1808
			// Restore initial color.
			restoreColor(_pls, lInitialColor, _panel->_page->_mode);
fbe3c2bb   Benjamin Renard   First commit
1809

ba6124b0   Menouard AZIB   Add parameter id ...
1810
1811
			textPlot->setDrawn(true);
		}
fbe3c2bb   Benjamin Renard   First commit
1812
	}
fbe3c2bb   Benjamin Renard   First commit
1813

ba6124b0   Menouard AZIB   Add parameter id ...
1814
1815
1816
1817
1818
1819
1820
1821
1822
1823
	/*
	 * @brief Draw interval
	 */
	void PanelPlotOutput::drawSerieInterval(SeriesProperties &pSeries,
											double *xValues, double *yValues, double *timeValues,
											int nbValues, int intervalIndex)
	{
		LOG4CXX_DEBUG(gLogger, "PanelPlotOutput::drawSerieInterval");

		IntervalTickProperties itProps = pSeries.getIntervalTickProperties();
fbe3c2bb   Benjamin Renard   First commit
1824

ba6124b0   Menouard AZIB   Add parameter id ...
1825
1826
1827
		// Draw Interval ticks if required !
		if (itProps.getMode() == IntervalTickMode::NONE)
			return;
fbe3c2bb   Benjamin Renard   First commit
1828

ba6124b0   Menouard AZIB   Add parameter id ...
1829
1830
1831
		// Get X and Y axis.
		boost::shared_ptr<Axis> lXAxis(_panel->getAxis(pSeries.getXAxisId()));
		boost::shared_ptr<Axis> lYAxis(_panel->getAxis(pSeries.getYAxisId()));
fbe3c2bb   Benjamin Renard   First commit
1832

ba6124b0   Menouard AZIB   Add parameter id ...
1833
1834
		Range lXRange = getXAxisRange(pSeries, lXAxis);
		Range lYRange = getYAxisRange(pSeries, lYAxis);
fbe3c2bb   Benjamin Renard   First commit
1835

ba6124b0   Menouard AZIB   Add parameter id ...
1836
		PlWindow lPlWindow = PlWindow(lXRange.getMin(), lXRange.getMax(), lYRange.getMin(), lYRange.getMax());
fbe3c2bb   Benjamin Renard   First commit
1837

ba6124b0   Menouard AZIB   Add parameter id ...
1838
1839
1840
1841
		// prepare data for plot
		double xData[2] = {NAN, NAN};
		double yData[2] = {NAN, NAN};
		double timeData[2] = {NAN, NAN};
fbe3c2bb   Benjamin Renard   First commit
1842

ba6124b0   Menouard AZIB   Add parameter id ...
1843
1844
1845
1846
1847
1848
1849
1850
1851
		// skip NAN values
		for (int i = 0; i < nbValues; ++i)
			if (!isNAN(xValues[i]) && !isNAN(yValues[i]))
			{
				xData[0] = xValues[i];
				yData[0] = yValues[i];
				timeData[0] = timeValues[i];
				break;
			}
fbe3c2bb   Benjamin Renard   First commit
1852

ba6124b0   Menouard AZIB   Add parameter id ...
1853
1854
1855
1856
1857
1858
1859
1860
		for (int i = nbValues - 1; i >= 0; --i)
			if (!isNAN(xValues[i]) && !isNAN(yValues[i]))
			{
				xData[1] = xValues[i];
				yData[1] = yValues[i];
				timeData[1] = timeValues[i];
				break;
			}
fbe3c2bb   Benjamin Renard   First commit
1861

ba6124b0   Menouard AZIB   Add parameter id ...
1862
1863
1864
1865
1866
1867
		// draw symbols
		drawSymbols(
			itProps.getSymbol().getType(),
			itProps.getSymbol().getSize(), 1.,
			itProps.getSymbol().getColor(),
			2, (double *)&xData, (double *)&yData, NULL);
fbe3c2bb   Benjamin Renard   First commit
1868

ba6124b0   Menouard AZIB   Add parameter id ...
1869
1870
		if (itProps.getMode() == IntervalTickMode::SYMBOL_ONLY)
			return;
fbe3c2bb   Benjamin Renard   First commit
1871

ba6124b0   Menouard AZIB   Add parameter id ...
1872
1873
		// Add start interval info to a list of TextPlot
		TextPlots textPlots;
fbe3c2bb   Benjamin Renard   First commit
1874

ba6124b0   Menouard AZIB   Add parameter id ...
1875
1876
1877
		TextPlot baseTextPlot;
		baseTextPlot._color = itProps.getColor();
		baseTextPlot.setFont(itProps.getFont());
fbe3c2bb   Benjamin Renard   First commit
1878

ba6124b0   Menouard AZIB   Add parameter id ...
1879
		boost::shared_ptr<TextPlot> startTextPlot(new TextPlot(baseTextPlot));
fbe3c2bb   Benjamin Renard   First commit
1880

ba6124b0   Menouard AZIB   Add parameter id ...
1881
1882
1883
		double xPos = (xData[0] - lXRange.getMin()) / (lXRange.getMax() - lXRange.getMin()) * 100;
		startTextPlot->_x = boost::lexical_cast<std::string>(xPos);
		startTextPlot->_x += "%";
fbe3c2bb   Benjamin Renard   First commit
1884

ba6124b0   Menouard AZIB   Add parameter id ...
1885
1886
1887
		double yPos = (yData[0] - lYRange.getMin()) / (lYRange.getMax() - lYRange.getMin()) * 100 + 1.5;
		startTextPlot->_y = boost::lexical_cast<std::string>(yPos);
		startTextPlot->_y += "%";
fbe3c2bb   Benjamin Renard   First commit
1888

ba6124b0   Menouard AZIB   Add parameter id ...
1889
1890
1891
1892
1893
1894
1895
		if (itProps.getMode() == IntervalTickMode::INTERVAL_INDEX)
		{
			startTextPlot->_text = "I";
			startTextPlot->_text += std::to_string(intervalIndex);
		}
		else
			startTextPlot->_text = AMDA::TimeUtil::formatTimeDateInIso(timeData[0]);
fbe3c2bb   Benjamin Renard   First commit
1896

ba6124b0   Menouard AZIB   Add parameter id ...
1897
		textPlots.push_back(startTextPlot);
fbe3c2bb   Benjamin Renard   First commit
1898

ba6124b0   Menouard AZIB   Add parameter id ...
1899
1900
1901
		if (itProps.getMode() != IntervalTickMode::START_TIME)
		{
			boost::shared_ptr<TextPlot> stopTextPlot(new TextPlot(baseTextPlot));
fbe3c2bb   Benjamin Renard   First commit
1902

ba6124b0   Menouard AZIB   Add parameter id ...
1903
1904
1905
			xPos = (xData[1] - lXRange.getMin()) / (lXRange.getMax() - lXRange.getMin()) * 100;
			stopTextPlot->_x = boost::lexical_cast<std::string>(xPos);
			stopTextPlot->_x += "%";
fbe3c2bb   Benjamin Renard   First commit
1906

ba6124b0   Menouard AZIB   Add parameter id ...
1907
1908
1909
			yPos = (yData[1] - lYRange.getMin()) / (lYRange.getMax() - lYRange.getMin()) * 100 + 1.5;
			stopTextPlot->_y = boost::lexical_cast<std::string>(yPos);
			stopTextPlot->_y += "%";
fbe3c2bb   Benjamin Renard   First commit
1910

ba6124b0   Menouard AZIB   Add parameter id ...
1911
1912
1913
1914
			if (itProps.getMode() == IntervalTickMode::INTERVAL_INDEX)
				stopTextPlot->_text = startTextPlot->_text;
			else
				stopTextPlot->_text = AMDA::TimeUtil::formatTimeDateInIso(timeData[1]);
fbe3c2bb   Benjamin Renard   First commit
1915

ba6124b0   Menouard AZIB   Add parameter id ...
1916
1917
			textPlots.push_back(stopTextPlot);
		}
fbe3c2bb   Benjamin Renard   First commit
1918

ba6124b0   Menouard AZIB   Add parameter id ...
1919
		drawTextPlots(lXAxis, lYAxis, lPlWindow, textPlots);
fbe3c2bb   Benjamin Renard   First commit
1920
1921
	}

ba6124b0   Menouard AZIB   Add parameter id ...
1922
1923
1924
1925
1926
1927
	/**
	 * @brief Draw parameters legend.
	 */
	void PanelPlotOutput::drawParamsLegend(void)
	{
		ParamsLegendProperties &legendProp = _panel->_paramsLegendProperties;
fbe3c2bb   Benjamin Renard   First commit
1928

ba6124b0   Menouard AZIB   Add parameter id ...
1929
1930
		if (!legendProp.isVisible() || legendProp.isDrawn())
			return;
fbe3c2bb   Benjamin Renard   First commit
1931

ba6124b0   Menouard AZIB   Add parameter id ...
1932
		std::list<LegendLineProperties> lines = legendProp.getLegendLines();
fbe3c2bb   Benjamin Renard   First commit
1933

ba6124b0   Menouard AZIB   Add parameter id ...
1934
1935
		if (lines.empty())
			return;
fbe3c2bb   Benjamin Renard   First commit
1936

ba6124b0   Menouard AZIB   Add parameter id ...
1937
1938
		// init arguments to call pllegend function
		PLINT nbLines = lines.size();
fbe3c2bb   Benjamin Renard   First commit
1939

ba6124b0   Menouard AZIB   Add parameter id ...
1940
1941
1942
1943
1944
1945
1946
1947
1948
1949
		PLINT opt_array[nbLines];
		PLINT text_colors[nbLines];
		PLINT line_colors[nbLines];
		PLINT line_styles[nbLines];
		PLFLT line_widths[nbLines];
		PLINT symbol_numbers[nbLines];
		PLINT symbol_colors[nbLines];
		PLFLT symbol_scales[nbLines];
		const char *symbols[nbLines];
		const char *texts[nbLines];
fbe3c2bb   Benjamin Renard   First commit
1950

ba6124b0   Menouard AZIB   Add parameter id ...
1951
1952
1953
		int index = 0;
		std::string symbol_str[nbLines];
		for (auto line : lines)
fbe3c2bb   Benjamin Renard   First commit
1954
		{
ba6124b0   Menouard AZIB   Add parameter id ...
1955
1956
1957
1958
1959
1960
1961
1962
1963
1964
1965
1966
1967
1968
1969
1970
1971
1972
1973
1974
1975
			opt_array[index] = 0;
			// set line options
			if (!legendProp.isOnlyText() && line.isLineVisible())
			{
				opt_array[index] |= PL_LEGEND_LINE;
				line_colors[index] = legendProp.getColorIndex(_pls.get(), line.getLineProperties().getColor());
				line_styles[index] = static_cast<int>(getPlLineStyle(line.getLineProperties().getStyle()));
				line_widths[index] = line.getLineProperties().getWidth();
			}
			// set symbols options
			if (!legendProp.isOnlyText() && line.isSymbolsVisible())
			{
				opt_array[index] |= PL_LEGEND_SYMBOL;
				symbol_numbers[index] = LEGEND_NB_SYMBOLS_TO_DRAW;
				symbol_colors[index] = legendProp.getColorIndex(_pls.get(), line.getSymbolProperties().getColor());
				symbol_scales[index] = (double)line.getSymbolProperties().getSize() / PlPlotUtil::DEFAULT_CHARACTER_SIZE;
				std::stringstream workingstr;
				workingstr << "#(" << fontTypeToSymSymbol[line.getSymbolProperties().getType()] << ")";
				symbol_str[index] = workingstr.str();
				symbols[index] = symbol_str[index].c_str();
			}
fbe3c2bb   Benjamin Renard   First commit
1976

ba6124b0   Menouard AZIB   Add parameter id ...
1977
1978
1979
1980
			text_colors[index] = legendProp.getColorIndex(_pls.get(), line.getTextColor(legendProp.isOnlyText()));
			texts[index] = line.getText();
			++index;
		}
fbe3c2bb   Benjamin Renard   First commit
1981

ba6124b0   Menouard AZIB   Add parameter id ...
1982
1983
		PLFLT legend_width, legend_height;
		PLINT opt = PL_LEGEND_BACKGROUND;
fbe3c2bb   Benjamin Renard   First commit
1984

ba6124b0   Menouard AZIB   Add parameter id ...
1985
1986
1987
		// show or hide bounding box
		if (legendProp.isBorderVisible())
			opt |= PL_LEGEND_BOUNDING_BOX;
fbe3c2bb   Benjamin Renard   First commit
1988

ba6124b0   Menouard AZIB   Add parameter id ...
1989
1990
1991
1992
		PLINT position = PL_POSITION_VIEWPORT;
		switch (legendProp.getPosition())
		{
		case ParamsLegendPosition::POS_INSIDE:
fbe3c2bb   Benjamin Renard   First commit
1993
1994
			position |= PL_POSITION_INSIDE | PL_POSITION_TOP | PL_POSITION_RIGHT;
			break;
ba6124b0   Menouard AZIB   Add parameter id ...
1995
		case ParamsLegendPosition::POS_OUTSIDE:
fbe3c2bb   Benjamin Renard   First commit
1996
1997
			position |= PL_POSITION_OUTSIDE | PL_POSITION_RIGHT;
			break;
ba6124b0   Menouard AZIB   Add parameter id ...
1998
		default:
fbe3c2bb   Benjamin Renard   First commit
1999
2000
			LOG4CXX_WARN(gLogger, "Legend position not implemented => set to POS_INSIDE");
			position |= PL_POSITION_INSIDE | PL_POSITION_TOP | PL_POSITION_RIGHT;
ba6124b0   Menouard AZIB   Add parameter id ...
2001
		}
fbe3c2bb   Benjamin Renard   First commit
2002

ba6124b0   Menouard AZIB   Add parameter id ...
2003
2004
2005
		// define offset
		PLFLT x_offset = 0.0;
		PLFLT y_offset = 0.0;
fbe3c2bb   Benjamin Renard   First commit
2006

ba6124b0   Menouard AZIB   Add parameter id ...
2007
2008
2009
		switch (legendProp.getPosition())
		{
		case ParamsLegendPosition::POS_INSIDE:
fbe3c2bb   Benjamin Renard   First commit
2010
2011
2012
			x_offset = LEGEND_INSIDE_OFFSET;
			y_offset = LEGEND_INSIDE_OFFSET * _panelPlotXYRatio;
			break;
ba6124b0   Menouard AZIB   Add parameter id ...
2013
		case ParamsLegendPosition::POS_OUTSIDE:
8b6d84db   Benjamin Renard   Fix legend positi...
2014
			x_offset = LEGEND_OUTSIDE_OFFSET;
fbe3c2bb   Benjamin Renard   First commit
2015
2016
			y_offset = 0.0;
			break;
ba6124b0   Menouard AZIB   Add parameter id ...
2017
		default:
fbe3c2bb   Benjamin Renard   First commit
2018
2019
			x_offset = LEGEND_INSIDE_OFFSET;
			y_offset = LEGEND_INSIDE_OFFSET * _panelPlotXYRatio;
ba6124b0   Menouard AZIB   Add parameter id ...
2020
		}
fbe3c2bb   Benjamin Renard   First commit
2021

ba6124b0   Menouard AZIB   Add parameter id ...
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
		// show or hide line and symbols
		PLFLT plot_width = 0;
		if (!legendProp.isOnlyText())
			plot_width = LEGEND_LINE_SYM_WIDTH;

		// background color = panel color
		PLINT bg_color = legendProp.getColorIndex(_pls.get(), _panel->_backgroundColor);

		// bounding box
		PLINT bb_color = legendProp.getColorIndex(_pls.get(), legendProp.getBorderColor());
		PLINT bb_style = 1;

		// text option
		PLFLT text_offset = 0.0;
		if (!legendProp.isOnlyText())
			text_offset = LEGEND_TEXT_OFFSET;
		PLFLT text_scale = PlPlotUtil::getPlFontScaleFactor(legendProp.getFont());
		PLFLT text_spacing = LEGEND_TEXT_SPACING;
		PLFLT text_justification = LEGEND_TEXT_JUSTIFICATION;

		// colored boxes not used
		PLINT *box_colors = NULL;
		PLINT *box_patterns = NULL;
		PLFLT *box_scales = NULL;
		PLFLT *box_line_widths = NULL;

		// save color
		Color fakeColor;
		Color initialColor = changeColor(_pls, fakeColor,
										 _panel->_page->_mode);

		// set viewport
		_pls->vpor(_plotAreaBounds._x,
				   _plotAreaBounds._x + _plotAreaBounds._width + legendProp.getLeftOffset(),
				   _plotAreaBounds._y,
				   _plotAreaBounds._y + _plotAreaBounds._height);

		// set font
		PlPlotUtil::setPlFont(legendProp.getFont());

		// init cmap0 to draw legend
		std::vector<Color> colors = legendProp.getColorsMap();
		_pls->scmap0n(colors.size());
		index = 0;

		for (auto color : colors)
		{
			_pls->scol0(index, color._red, color._green, color._blue);
			++index;
		}
fbe3c2bb   Benjamin Renard   First commit
2072

ba6124b0   Menouard AZIB   Add parameter id ...
2073
2074
		// draw tthe legend
		_pls->legend(
fbe3c2bb   Benjamin Renard   First commit
2075
2076
2077
2078
2079
2080
2081
2082
2083
2084
2085
2086
2087
2088
2089
2090
2091
2092
2093
			&legend_width,
			&legend_height,
			opt,
			position,
			x_offset,
			y_offset,
			plot_width,
			bg_color,
			bb_color,
			bb_style,
			0, /* nrow */
			0, /* ncolumn */
			nbLines,
			opt_array,
			text_offset,
			text_scale,
			text_spacing,
			text_justification,
			text_colors,
ba6124b0   Menouard AZIB   Add parameter id ...
2094
			(const char **)texts,
fbe3c2bb   Benjamin Renard   First commit
2095
2096
2097
2098
2099
2100
2101
2102
2103
2104
			box_colors,
			box_patterns,
			box_scales,
			box_line_widths,
			line_colors,
			line_styles,
			line_widths,
			symbol_colors,
			symbol_scales,
			symbol_numbers,
ba6124b0   Menouard AZIB   Add parameter id ...
2105
			(const char **)symbols);
fbe3c2bb   Benjamin Renard   First commit
2106

ba6124b0   Menouard AZIB   Add parameter id ...
2107
2108
		// Restore initial color.
		restoreColor(_pls, initialColor, _panel->_page->_mode);
fbe3c2bb   Benjamin Renard   First commit
2109

ba6124b0   Menouard AZIB   Add parameter id ...
2110
2111
		legendProp.setDrawn(true);
	}
fbe3c2bb   Benjamin Renard   First commit
2112

ba6124b0   Menouard AZIB   Add parameter id ...
2113
2114
2115
	/**
	 * @brief Draw text legends.
	 */
fbe3c2bb   Benjamin Renard   First commit
2116

ba6124b0   Menouard AZIB   Add parameter id ...
2117
2118
2119
2120
2121
2122
	void PanelPlotOutput::drawTextLegends(void)
	{
		double xmin = _plotAreaBounds._x;
		double xmax = _plotAreaBounds._x + _plotAreaBounds._width;
		double ymin = _plotAreaBounds._y;
		double ymax = _plotAreaBounds._y + _plotAreaBounds._height;
fbe3c2bb   Benjamin Renard   First commit
2123

ba6124b0   Menouard AZIB   Add parameter id ...
2124
2125
2126
2127
		/*bool	leftTextLegendFound		= false;
		bool	rightTextLegendFound 	= false;
		bool	topTextLegendFound 		= false;
		bool	bottomTextLegendFound 	= false;*/
fbe3c2bb   Benjamin Renard   First commit
2128

ba6124b0   Menouard AZIB   Add parameter id ...
2129
2130
2131
2132
		for (auto textLegend : _panel->_textLegendPropertiesList)
		{
			if (textLegend->isDrawn())
				continue;
fbe3c2bb   Benjamin Renard   First commit
2133

ba6124b0   Menouard AZIB   Add parameter id ...
2134
2135
2136
2137
2138
2139
2140
2141
2142
2143
2144
2145
2146
2147
			// Set color
			Color initialColor = changeColor(_pls, textLegend->getColor(), _panel->_page->_mode);

			// set font
			PlPlotUtil::setPlFont(textLegend->getFont());

			// If legend at a given position not already drawn :
			//-  Set viewport depending on legend position
			// - Retrieve text lines from text legend and draw them
			// - See calculatePlotArea to know how text legend position are calculated
			std::vector<std::string> textLines = textLegend->getTextLines();
			double disp = 1;

			switch (textLegend->getPosition())
62024e03   Erdogan Furkan   Some modifications
2148
			{
ba6124b0   Menouard AZIB   Add parameter id ...
2149
2150
2151
2152
2153
2154
2155
2156
2157
2158
2159
2160
2161
2162
2163
2164
2165
2166
2167
2168
2169
2170
2171
2172
2173
2174
2175
2176
2177
2178
2179
2180
2181
2182
2183
2184
2185
2186
2187
2188
2189
2190
2191
2192
2193
2194
2195
2196
2197
2198
			case TextLegendPosition::POS_LEFT:
				// if (leftTextLegendFound == false) {
				_pls->vpor(xmin - textLegend->getOffset(), xmax, ymin, ymax);
				for (int i = 0; i < (int)textLines.size(); i++)
				{
					_pls->mtex("l", disp, 0.5, 0.5, textLines.at(textLines.size() - 1 - i).c_str());
					disp += 1.5;
				}
				// leftTextLegendFound = true;
				// }
				break;

			case TextLegendPosition::POS_RIGHT:
				// if (rightTextLegendFound == false) {
				_pls->vpor(xmin, xmax + textLegend->getOffset(), ymin, ymax);
				for (int i = 0; i < (int)textLines.size(); i++)
				{
					_pls->mtex("r", disp, 0.5, 0.5, textLines.at(i).c_str());
					disp += 1.5;
				}
				// rightTextLegendFound = true;
				// }
				break;

			case TextLegendPosition::POS_TOP:
				// if (topTextLegendFound == false) {
				_pls->vpor(xmin, xmax, ymin, ymax + textLegend->getOffset());
				for (int i = 0; i < (int)textLines.size(); i++)
				{
					_pls->mtex("t", disp, 0.5, 0.5, textLines.at(textLines.size() - 1 - i).c_str());
					disp += 1.5;
				}
				// topTextLegendFound = true;
				// }
				break;

			case TextLegendPosition::POS_BOTTOM:
				// if (bottomTextLegendFound == false) {
				_pls->vpor(xmin, xmax, ymin - textLegend->getOffset(), ymax);
				for (int i = 0; i < (int)textLines.size(); i++)
				{
					_pls->mtex("b", disp, 0.5, 0.5, textLines.at(i).c_str());
					disp += 1.5;
				}
				// bottomTextLegendFound = true;
				// }
				break;

			default:
				break;
fbe3c2bb   Benjamin Renard   First commit
2199
			}
fbe3c2bb   Benjamin Renard   First commit
2200

ba6124b0   Menouard AZIB   Add parameter id ...
2201
			restoreColor(_pls, initialColor, _panel->_page->_mode);
fbe3c2bb   Benjamin Renard   First commit
2202

ba6124b0   Menouard AZIB   Add parameter id ...
2203
2204
2205
			textLegend->setDrawn(true);
		}
	}
fbe3c2bb   Benjamin Renard   First commit
2206

ba6124b0   Menouard AZIB   Add parameter id ...
2207
2208
2209
2210
2211
2212
	/**
	 * Draws Curve
	 */
	void PanelPlotOutput::drawCurvePlot(CurvePlot & /*curvePlot*/)
	{
		// Nothing to do - Deleguate to subclasses
fbe3c2bb   Benjamin Renard   First commit
2213
	}
fbe3c2bb   Benjamin Renard   First commit
2214

ba6124b0   Menouard AZIB   Add parameter id ...
2215
2216
2217
2218
2219
2220
2221
	/**
	 * @brief Write plot context
	 */
	void PanelPlotOutput::writeContext(ContextFileWriter &writer, AMDA::Parameters::TimeIntervalList::iterator currentTimeInterval)
	{
		if (!isStandalone())
			return;
fbe3c2bb   Benjamin Renard   First commit
2222

ba6124b0   Menouard AZIB   Add parameter id ...
2223
2224
		writer.startElement("panel");
		_panel->writeContext(_pls, writer);
7f7e3b39   Benjamin Renard   Fix a bug with st...
2225

ba6124b0   Menouard AZIB   Add parameter id ...
2226
		writer.startElement("parameters");
8499fbdd   Benjamin Renard   Context file gene...
2227

ba6124b0   Menouard AZIB   Add parameter id ...
2228
2229
		for (ParameterAxesList::iterator it = _parameterAxesList.begin();
			 it != _parameterAxesList.end(); ++it)
24600903   Benjamin Renard   Add "hasSpectro" ...
2230
		{
ba6124b0   Menouard AZIB   Add parameter id ...
2231
2232
2233
2234
2235
2236
2237
2238
2239
2240
2241
			AMDA::Parameters::ParameterSPtr originalParam =
				_parameterManager.getParameter(it->_originalParamId);

			double resol = originalParam->getDataWriterTemplate()->getMinSampling();
			std::string resolstr = std::to_string(resol);
			writer.startElement("parameter");
			writer.addAttribute("id", originalParam->getId().c_str());
			writer.addAttribute("MinSampling", resolstr.c_str());
			writer.endElement();
		}
		writer.endElement();
eddfb311   Erdogan Furkan   9326 - Modificita...
2242

ba6124b0   Menouard AZIB   Add parameter id ...
2243
2244
2245
2246
2247
2248
2249
2250
2251
2252
2253
2254
2255
2256
2257
2258
2259
		if (!_parameterAxesList.empty())
		{
			bool hasSpectro = false;
			bool hasSauvaud = false;
			for (auto parameter : _parameterAxesList)
			{
				if (parameter.getSpectroProperties() != nullptr)
				{
					hasSpectro = true;
					break;
				}
				if (parameter.getSauvaudProperties() != nullptr)
				{
					hasSauvaud = true;
					break;
				}
				if (parameter.getIntervalsProperties() != nullptr)
eddfb311   Erdogan Furkan   9326 - Modificita...
2260
				{
ba6124b0   Menouard AZIB   Add parameter id ...
2261
2262
2263
2264
2265
2266
2267
2268
					ParameterSPtr p = _parameterManager.getParameter(parameter._originalParamId);
					AMDA::Info::ParamInfoSPtr paramInfo = AMDA::Info::ParamMgr::getInstance()->getParamInfoFromId(p->getInfoId());
					std::map<std::string, std::string> inputAdditionals = paramInfo->getAdditionInfo();
					std::string ttOrCatPath = inputAdditionals["TTCatToParamPath"];

					// Load TT or Catalog
					std::string lReaderType = TimeTableCatalog::TimeTableCatalogFactory::getInstance().getReaderType(ttOrCatPath);
					if (!lReaderType.empty())
eddfb311   Erdogan Furkan   9326 - Modificita...
2269
					{
ba6124b0   Menouard AZIB   Add parameter id ...
2270
2271
2272
2273
2274
2275
						TimeTableCatalog::Catalog inputTTOrCat;
						inputTTOrCat.read(ttOrCatPath, lReaderType);
						for (std::vector<TimeTableCatalog::TimeInterval>::const_iterator it = inputTTOrCat.getIntervals().begin(); it != inputTTOrCat.getIntervals().end(); ++it)
						{
							double acceptedRatio = 0.005; // if the interval is too small, no more info given
							double timeRatio = (currentTimeInterval->_stopTime - currentTimeInterval->_startTime) / _plotAreaBounds._width;
29818855   Erdogan Furkan   #5390 - Some modi...
2276

ba6124b0   Menouard AZIB   Add parameter id ...
2277
2278
2279
2280
2281
							std::map<std::string, std::vector<std::string>> data;
							bool needTTWriter = false;
							bool needCatWriter = false;
							double startTime = it->_startTime;
							double stopTime = it->_stopTime;
1b52e70a   Erdogan Furkan   First Kernel modi...
2282

ba6124b0   Menouard AZIB   Add parameter id ...
2283
							if (it->_startTime >= currentTimeInterval->_startTime && it->_stopTime <= currentTimeInterval->_stopTime) // inside the interval
29818855   Erdogan Furkan   #5390 - Some modi...
2284
							{
ba6124b0   Menouard AZIB   Add parameter id ...
2285
2286
2287
2288
2289
2290
2291
								if (timeRatio * acceptedRatio < (stopTime - startTime) / _plotAreaBounds._width)
								{
									needTTWriter = true;
									data = it->getAllParameterData();
									if (data.size() > 0)
										needCatWriter = true;
								}
29818855   Erdogan Furkan   #5390 - Some modi...
2292
							}
ba6124b0   Menouard AZIB   Add parameter id ...
2293
							else if (it->_startTime <= currentTimeInterval->_startTime && it->_stopTime <= currentTimeInterval->_stopTime && it->_stopTime >= currentTimeInterval->_startTime) // begins before, ends inside
29818855   Erdogan Furkan   #5390 - Some modi...
2294
							{
ba6124b0   Menouard AZIB   Add parameter id ...
2295
2296
2297
2298
2299
2300
2301
2302
								startTime = currentTimeInterval->_startTime;
								if (timeRatio * acceptedRatio < (stopTime - startTime) / _plotAreaBounds._width)
								{
									needTTWriter = true;
									data = it->getAllParameterData();
									if (data.size() > 0)
										needCatWriter = true;
								}
29818855   Erdogan Furkan   #5390 - Some modi...
2303
							}
ba6124b0   Menouard AZIB   Add parameter id ...
2304
							else if (it->_startTime >= currentTimeInterval->_startTime && it->_startTime <= currentTimeInterval->_stopTime && it->_stopTime >= currentTimeInterval->_stopTime) // begins inside, ends after
29818855   Erdogan Furkan   #5390 - Some modi...
2305
							{
ba6124b0   Menouard AZIB   Add parameter id ...
2306
2307
2308
2309
2310
2311
2312
2313
								stopTime = currentTimeInterval->_stopTime;
								if (timeRatio * acceptedRatio < (stopTime - startTime) / _plotAreaBounds._width)
								{
									needTTWriter = true;
									data = it->getAllParameterData();
									if (data.size() > 0)
										needCatWriter = true;
								}
29818855   Erdogan Furkan   #5390 - Some modi...
2314
							}
3b531e56   Erdogan Furkan   Second Kernel mod...
2315

ba6124b0   Menouard AZIB   Add parameter id ...
2316
							if (needTTWriter)
3b531e56   Erdogan Furkan   Second Kernel mod...
2317
							{
ba6124b0   Menouard AZIB   Add parameter id ...
2318
2319
								writer.startElement("intervals");
								writer.addAttribute("name", inputTTOrCat._name.c_str());
22e48491   Benjamin Renard   Start TT id to 1
2320
								writer.addAttribute("id", std::to_string(it->_index + 1).c_str());
ba6124b0   Menouard AZIB   Add parameter id ...
2321
2322
2323
								writer.addAttribute("startTime", std::to_string(startTime).c_str());
								writer.addAttribute("stopTime", std::to_string(stopTime).c_str());
								if (needCatWriter)
29818855   Erdogan Furkan   #5390 - Some modi...
2324
								{
ba6124b0   Menouard AZIB   Add parameter id ...
2325
2326
2327
2328
2329
2330
									std::string allParams;
									for (auto i : data)
									{
										allParams += i.second[0] + "|";
									}
									writer.addAttribute("params", allParams.c_str());
29818855   Erdogan Furkan   #5390 - Some modi...
2331
								}
ba6124b0   Menouard AZIB   Add parameter id ...
2332
								writer.endElement();
3b531e56   Erdogan Furkan   Second Kernel mod...
2333
							}
3b531e56   Erdogan Furkan   Second Kernel mod...
2334
						}
eddfb311   Erdogan Furkan   9326 - Modificita...
2335
					}
eddfb311   Erdogan Furkan   9326 - Modificita...
2336
2337
				}
			}
24600903   Benjamin Renard   Add "hasSpectro" ...
2338

ba6124b0   Menouard AZIB   Add parameter id ...
2339
2340
2341
2342
2343
2344
2345
2346
2347
2348
2349
2350
2351
2352
2353
			writer.startElement("plotArea");
			if (_panel->_page->_orientation == PlotCommon::Orientation::PORTRAIT)
			{
				writer.addAttribute("x", std::to_string(_plotAreaBounds._y * std::get<0>(_panel->_page->getSize())).c_str());
				writer.addAttribute("y", std::to_string(_plotAreaBounds._x * std::get<1>(_panel->_page->getSize())).c_str());
				writer.addAttribute("width", std::to_string(_plotAreaBounds._height * std::get<0>(_panel->_page->getSize())).c_str());
				writer.addAttribute("height", std::to_string(_plotAreaBounds._width * std::get<1>(_panel->_page->getSize())).c_str());
			}
			else
			{
				writer.addAttribute("x", std::to_string(_plotAreaBounds._x * std::get<0>(_panel->_page->getSize())).c_str());
				writer.addAttribute("y", std::to_string(_plotAreaBounds._y * std::get<1>(_panel->_page->getSize())).c_str());
				writer.addAttribute("width", std::to_string(_plotAreaBounds._width * std::get<0>(_panel->_page->getSize())).c_str());
				writer.addAttribute("height", std::to_string(_plotAreaBounds._height * std::get<1>(_panel->_page->getSize())).c_str());
			}
24600903   Benjamin Renard   Add "hasSpectro" ...
2354

ba6124b0   Menouard AZIB   Add parameter id ...
2355
2356
			writer.addAttribute("hasSpectro", hasSpectro ? "true" : "false");
			writer.addAttribute("hasSauvaud", hasSauvaud ? "true" : "false");
85bb5117   Benjamin Renard   Give the possibil...
2357

ba6124b0   Menouard AZIB   Add parameter id ...
2358
2359
2360
			for (Axes::iterator it = _panel->_axes.begin(); it != _panel->_axes.end(); ++it)
			{
				boost::shared_ptr<Axis> lAxis = it->second;
24600903   Benjamin Renard   Add "hasSpectro" ...
2361

ba6124b0   Menouard AZIB   Add parameter id ...
2362
2363
				if (lAxis == nullptr)
					continue;
8499fbdd   Benjamin Renard   Context file gene...
2364

ba6124b0   Menouard AZIB   Add parameter id ...
2365
2366
2367
				if (lAxis->_visible && lAxis->_used)
					lAxis->writeContext(writer);
			}
8499fbdd   Benjamin Renard   Context file gene...
2368

ba6124b0   Menouard AZIB   Add parameter id ...
2369
			writer.endElement();
85bb5117   Benjamin Renard   Give the possibil...
2370
2371
		}

85bb5117   Benjamin Renard   Give the possibil...
2372
		writer.endElement();
8499fbdd   Benjamin Renard   Context file gene...
2373
	}
85bb5117   Benjamin Renard   Give the possibil...
2374

ba6124b0   Menouard AZIB   Add parameter id ...
2375
2376
2377
2378
2379
2380
2381
2382
2383
2384
	/**
	 * @brief Compute the initial plot area for the panel
	 */
	void PanelPlotOutput::preparePlotArea(double /*startTime*/, double /*stopTime*/, int /*intervalIndex*/)
	{
		Bounds panelBounds = _panel->getBoundsInPlPage();
		_plotAreaBounds = panelBounds;
		calculatePlotArea(panelBounds, _plotAreaBounds);
		_panel->_paramsLegendProperties.resetPlot();
	}
8499fbdd   Benjamin Renard   Context file gene...
2385

ba6124b0   Menouard AZIB   Add parameter id ...
2386
	void PanelPlotOutput::fillBackground(std::shared_ptr<plstream> &pls)
337411e4   Erdogan Furkan   #5390 - Kernel pa...
2387
	{
ba6124b0   Menouard AZIB   Add parameter id ...
2388
2389
2390
		if (_panel->_plotAreaBackgroundColor._red != -1 && _panel->_plotAreaBackgroundColor._green != -1 && _panel->_plotAreaBackgroundColor._blue != -1)
		{
			Color plotAreaBackgroundColor = _panel->_plotAreaBackgroundColor;
337411e4   Erdogan Furkan   #5390 - Kernel pa...
2391

ba6124b0   Menouard AZIB   Add parameter id ...
2392
2393
2394
2395
2396
2397
			PLINT lInitialRed = -1, lInitialGreen = -1, lInitialBlue = -1;
			// Store initial color in first index.
			pls->gcol0(0, lInitialRed, lInitialGreen, lInitialBlue);
			pls->scol0(0, plotAreaBackgroundColor._red, plotAreaBackgroundColor._green,
					   plotAreaBackgroundColor._blue);
			pls->col0(0);
337411e4   Erdogan Furkan   #5390 - Kernel pa...
2398

ba6124b0   Menouard AZIB   Add parameter id ...
2399
2400
2401
2402
2403
			// Compute panel coordinate in the page
			Bounds lBounds = _plotAreaBounds;
			// Specify viewport for the panel
			pls->vpor(_plotAreaBounds._x, _plotAreaBounds._x + _plotAreaBounds._width,
					  _plotAreaBounds._y, _plotAreaBounds._y + _plotAreaBounds._height);
337411e4   Erdogan Furkan   #5390 - Kernel pa...
2404

ba6124b0   Menouard AZIB   Add parameter id ...
2405
2406
			// Set window size.
			pls->wind(0, 1, 0, 1);
337411e4   Erdogan Furkan   #5390 - Kernel pa...
2407

ba6124b0   Menouard AZIB   Add parameter id ...
2408
2409
2410
2411
			// Fill background.
			PLFLT px[] = {0, 0, 1, 1};
			PLFLT py[] = {0, 1, 1, 0};
			pls->fill(4, px, py);
337411e4   Erdogan Furkan   #5390 - Kernel pa...
2412

ba6124b0   Menouard AZIB   Add parameter id ...
2413
			pls->col0(0);
337411e4   Erdogan Furkan   #5390 - Kernel pa...
2414

ba6124b0   Menouard AZIB   Add parameter id ...
2415
2416
2417
2418
			if (lInitialRed != -1 && lInitialGreen != -1 && lInitialBlue != -1)
			{
				pls->scol0(0, lInitialRed, lInitialGreen, lInitialBlue);
			}
337411e4   Erdogan Furkan   #5390 - Kernel pa...
2419
2420
		}
	}
337411e4   Erdogan Furkan   #5390 - Kernel pa...
2421

ba6124b0   Menouard AZIB   Add parameter id ...
2422
2423
2424
2425
2426
2427
2428
	/**
	 * @brief Retrieve plot area bounds for the panel
	 */
	void PanelPlotOutput::getPlotAreaBounds(Bounds &plotAreaBounds)
	{
		plotAreaBounds = _plotAreaBounds;
	}
fbe3c2bb   Benjamin Renard   First commit
2429

ba6124b0   Menouard AZIB   Add parameter id ...
2430
2431
2432
2433
2434
2435
2436
2437
	/**
	 * @brief Force the plot area horizontal position and width
	 */
	void PanelPlotOutput::forcePlotAreaPosAndWidth(double plotAreaX, double plotAreaWidth)
	{
		_plotAreaBounds._x = plotAreaX;
		_plotAreaBounds._width = plotAreaWidth;
	}
fbe3c2bb   Benjamin Renard   First commit
2438

ba6124b0   Menouard AZIB   Add parameter id ...
2439
2440
2441
2442
2443
2444
2445
	/**
	 * @brief Retrieve left axis tickMark width
	 */
	int PanelPlotOutput::getLeftAxisTickMarkWidth(void)
	{
		return _leftAxisTickMarkWidth;
	}
fbe3c2bb   Benjamin Renard   First commit
2446

ba6124b0   Menouard AZIB   Add parameter id ...
2447
2448
2449
2450
2451
2452
2453
2454
2455
2456
2457
2458
2459
2460
2461
	/**
	 * @brief Force left axis tickmark width for the panel
	 */
	void PanelPlotOutput::forceLeftAxisTickMarkWidth(int leftAxisTickMarkWidth)
	{
		for (Axes::iterator it = _panel->_axes.begin(); it != _panel->_axes.end(); ++it)
		{
			boost::shared_ptr<Axis> lAxis = it->second;
			if (lAxis == nullptr)
				continue;
			// Look for a visible fleft Axis with legend and
			if ((lAxis->_visible) && (lAxis->_position == PlotCommon::Position::POS_LEFT))
			{
				lAxis->setFixedTickMarkWidth(leftAxisTickMarkWidth);
			}
fbe3c2bb   Benjamin Renard   First commit
2462
2463
		}
	}
fbe3c2bb   Benjamin Renard   First commit
2464

ba6124b0   Menouard AZIB   Add parameter id ...
2465
2466
2467
2468
	/**
	 * @brief Get nb series to draw by y axis
	 */
	std::map<std::string, int> &PanelPlotOutput::getNbSeriesByYAxis()
8bb0f02b   Benjamin Renard   Set colors in axi...
2469
	{
ba6124b0   Menouard AZIB   Add parameter id ...
2470
2471
2472
2473
2474
2475
2476
2477
2478
2479
2480
		if (!_nbSeriesByYAxisMap.empty())
		{
			return _nbSeriesByYAxisMap;
		}
		SeriesProperties lSeries;
		for (auto parameter : _parameterAxesList)
		{
			for (auto lSeries : parameter.getYSeriePropertiesList())
			{
				if (!lSeries.hasYAxis())
					continue;
8bb0f02b   Benjamin Renard   Set colors in axi...
2481

ba6124b0   Menouard AZIB   Add parameter id ...
2482
				std::string yAxisId = lSeries.getYAxisId();
8bb0f02b   Benjamin Renard   Set colors in axi...
2483

ba6124b0   Menouard AZIB   Add parameter id ...
2484
2485
				if (_nbSeriesByYAxisMap.find(yAxisId) == _nbSeriesByYAxisMap.end())
					_nbSeriesByYAxisMap[yAxisId] = 0;
8bb0f02b   Benjamin Renard   Set colors in axi...
2486

ba6124b0   Menouard AZIB   Add parameter id ...
2487
2488
				_nbSeriesByYAxisMap[yAxisId] += lSeries.getIndexList(_pParameterValues).size();
			}
8bb0f02b   Benjamin Renard   Set colors in axi...
2489
		}
ba6124b0   Menouard AZIB   Add parameter id ...
2490
		return _nbSeriesByYAxisMap;
8bb0f02b   Benjamin Renard   Set colors in axi...
2491
	}
8bb0f02b   Benjamin Renard   Set colors in axi...
2492

ba6124b0   Menouard AZIB   Add parameter id ...
2493
2494
2495
2496
2497
2498
2499
2500
2501
	/**
	 * @brief draw the plot for the current time interval
	 */
	bool PanelPlotOutput::draw(double startTime, double stopTime, int intervalIndex,
							   bool isFirstInterval, bool isLastInterval)
	{
		// Sets panel plplot viewport, draw background & title for the panel
		_panel->draw(_pls);
		fillBackground(_pls);
fbe3c2bb   Benjamin Renard   First commit
2502

ba6124b0   Menouard AZIB   Add parameter id ...
2503
		bool noData = true;
d57f00dc   Benjamin Renard   Draw NO DATA
2504

ba6124b0   Menouard AZIB   Add parameter id ...
2505
2506
2507
2508
2509
		if (_parameterAxesList.empty())
		{
			noData = false; // Do not draw No Data if the panel is empty
			_panel->drawEmptyPanel(_pls);
		}
08ec1dde   Benjamin Renard   Add propertie _us...
2510

ba6124b0   Menouard AZIB   Add parameter id ...
2511
2512
		if (isFirstInterval)
			_panel->_paramsLegendProperties.resetPlot();
fbe3c2bb   Benjamin Renard   First commit
2513

ba6124b0   Menouard AZIB   Add parameter id ...
2514
2515
2516
2517
		// Set pointer to ParameterData list
		if (_pParameterValues == NULL)
		{
			std::stringstream lError;
fbe3c2bb   Benjamin Renard   First commit
2518
			lError << "PanelPlotOutput::draw - Pointer to parameterValues is not set";
ba6124b0   Menouard AZIB   Add parameter id ...
2519
			BOOST_THROW_EXCEPTION(
fbe3c2bb   Benjamin Renard   First commit
2520
				PanelPlotOutputException() << AMDA::ex_msg(lError.str()));
ba6124b0   Menouard AZIB   Add parameter id ...
2521
2522
2523
2524
2525
2526
2527
2528
2529
2530
2531
2532
2533
2534
2535
2536
2537
2538
2539
2540
2541
2542
2543
2544
2545
2546
2547
2548
2549
2550
2551
2552
2553
2554
2555
2556
2557
2558
		}

		LOG4CXX_DEBUG(gLogger, "Panel bounds = " << _panel->_bounds.toString());
		LOG4CXX_DEBUG(gLogger, "Plot area = " << _plotAreaBounds.toString());

		// Draw spectro
		for (auto parameter : _parameterAxesList)
		{
			if (parameter.getSpectroProperties() != nullptr)
			{
				// draw spectro
				LOG4CXX_DEBUG(gLogger, "Draw a spectro for parameter " << parameter._originalParamId);
				// Draw (configure) window for this series.
				drawSpectro(startTime, stopTime, parameter._originalParamId, *(parameter.getSpectroProperties()));

				ParameterData &data = (*_pParameterValues)[parameter.getSpectroProperties()->getParamId()];

				if (parameter.getSpectroProperties()->getIndexes().empty())
				{
					noData = data.noData();
				}
				else
				{
					for (auto index : parameter.getSpectroProperties()->getIndexes())
					{
						if (noData)
							noData = data.noData(index);
					}
				}
			}
			if (parameter.getSauvaudProperties() != nullptr)
			{
				// draw sauvaud
				LOG4CXX_DEBUG(gLogger, "Draw a sauvaud for parameter " << parameter._originalParamId);
				// Draw (configure) window for this series.
				drawSauvaud(startTime, stopTime, parameter._originalParamId, *(parameter.getSauvaudProperties()), 0, 1, "");

				ParameterData &data = (*_pParameterValues)[parameter.getSauvaudProperties()->getParamId()];
fbe3c2bb   Benjamin Renard   First commit
2559

ba6124b0   Menouard AZIB   Add parameter id ...
2560
2561
2562
2563
2564
2565
2566
2567
2568
2569
2570
2571
2572
				if (parameter.getSauvaudProperties()->getIndexes().empty())
				{
					noData = data.noData();
				}
				else
				{
					for (auto index : parameter.getSauvaudProperties()->getIndexes())
					{
						if (noData)
							noData = data.noData(index);
					}
				}
			}
5953671a   Erdogan Furkan   For now
2573
2574
2575
2576
2577
2578
2579
2580
2581
			if (parameter.getHistogram2DSeriesProperties() != nullptr)
			{
				// draw sauvaud
				LOG4CXX_DEBUG(gLogger, "Draw a Histogram2D for parameter " << parameter._originalParamId);
				// Draw (configure) window for this series.
				drawHistogram2D(startTime, stopTime, parameter._originalParamId, *(parameter.getHistogram2DSeriesProperties()));

				ParameterData &data = (*_pParameterValues)[parameter.getHistogram2DSeriesProperties()->getParamId()];

34c311b3   Erdogan Furkan   Smooting works
2582
				noData = data.noData(parameter.getHistogram2DSeriesProperties()->getIndex());
5953671a   Erdogan Furkan   For now
2583
2584
			}
			
ba6124b0   Menouard AZIB   Add parameter id ...
2585
		}
2fc1f2f8   Benjamin Renard   Full rework for s...
2586

ba6124b0   Menouard AZIB   Add parameter id ...
2587
2588
2589
2590
2591
2592
2593
		// Draw intervals
		for (auto parameter : _parameterAxesList)
		{
			if (parameter.getIntervalsProperties() != nullptr)
			{
				// draw intervals
				LOG4CXX_DEBUG(gLogger, "Draw intervals for parameter " << parameter._originalParamId);
2fc1f2f8   Benjamin Renard   Full rework for s...
2594
				// Draw (configure) window for this series.
ba6124b0   Menouard AZIB   Add parameter id ...
2595
2596
2597
2598
2599
2600
2601
2602
2603
2604
2605
2606
2607
2608
2609
				drawIntervals(startTime, stopTime, parameter._originalParamId, *(parameter.getIntervalsProperties()));

				ParameterData &data = (*_pParameterValues)[parameter.getIntervalsProperties()->getParamId()];

				if (parameter.getIntervalsProperties()->getIndexes().empty())
				{
					noData = data.noData();
				}
				else
				{
					for (auto index : parameter.getIntervalsProperties()->getIndexes())
					{
						if (noData)
							noData = data.noData(index);
					}
2fc1f2f8   Benjamin Renard   Full rework for s...
2610
				}
d57f00dc   Benjamin Renard   Draw NO DATA
2611
			}
fbe3c2bb   Benjamin Renard   First commit
2612
		}
fbe3c2bb   Benjamin Renard   First commit
2613

ba6124b0   Menouard AZIB   Add parameter id ...
2614
2615
		// Compute panel XY ratio used for angular conversions
		computePanelPlotXYRatio();
fbe3c2bb   Benjamin Renard   First commit
2616

ba6124b0   Menouard AZIB   Add parameter id ...
2617
2618
2619
2620
2621
2622
2623
2624
2625
2626
2627
2628
2629
2630
2631
2632
2633
2634
2635
2636
2637
2638
2639
2640
2641
2642
2643
2644
2645
2646
		// Draw fill area between parameter and constant or between parameters
		drawFills(startTime, stopTime);

		// Compute nb series to draw by y axis
		std::map<std::string, int> nbSeriesByYAxisMap = getNbSeriesByYAxis();
		SeriesProperties lSeries;
		// Draw series for parameters.
		for (auto parameter : _parameterAxesList)
		{
			// Get series index to draw for parameter
			// Draw each index of parameter
			for (auto lSeries : parameter.getYSeriePropertiesList())
			{
				for (auto lIndex : lSeries.getIndexList(_pParameterValues))
				{
					bool moreThanOneSerieForYAxis = false;
					if (lSeries.hasYAxis())
						moreThanOneSerieForYAxis = (nbSeriesByYAxisMap[lSeries.getYAxisId()] > 1);

					// Draw (configure) window for this series.
					drawSeries(startTime, stopTime, intervalIndex, parameter._originalParamId,
							   lSeries, lIndex, parameter, moreThanOneSerieForYAxis);
					ParameterData &data = (*_pParameterValues)[lSeries.getParamId()];
					if (noData)
					{
						noData = data.noData(lIndex);
					}
				}
			}
		}
fbe3c2bb   Benjamin Renard   First commit
2647

ba6124b0   Menouard AZIB   Add parameter id ...
2648
2649
		// Draw additional objects
		drawAdditionalObjects();
fbe3c2bb   Benjamin Renard   First commit
2650

ba6124b0   Menouard AZIB   Add parameter id ...
2651
2652
2653
		// Draw parameter legend
		if (isLastInterval || !_panel->_page->_superposeMode)
			drawParamsLegend();
fbe3c2bb   Benjamin Renard   First commit
2654

ba6124b0   Menouard AZIB   Add parameter id ...
2655
2656
		// Draw text legends
		drawTextLegends();
d57f00dc   Benjamin Renard   Draw NO DATA
2657

ba6124b0   Menouard AZIB   Add parameter id ...
2658
2659
		return !noData;
	}
5953671a   Erdogan Furkan   For now
2660
2661
2662
2663
2664
2665
2666
2667
2668
2669
2670
2671
2672
2673
2674
2675
2676
2677
2678
2679
2680
2681
2682
2683
2684
2685
2686
2687
2688
2689
2690
2691
2692
2693
2694
2695
2696
2697
2698
2699
2700
2701
2702
2703
2704
2705
2706
2707
2708
2709
2710
2711
2712
2713
2714
2715
2716
2717
2718
2719
2720
2721
2722
2723
2724
2725
2726

	void PanelPlotOutput::drawHistogram2D(double /*startDate*/, double /*stopDate*/, std::string /*pParamId*/, Histogram2DSeriesProperties &pHistogram2DProperties){
		
		// Get X, Y and Z axis.
		boost::shared_ptr<Axis> lXAxis(_panel->getAxis(pHistogram2DProperties.getXAxisId()));
		boost::shared_ptr<Axis> lYAxis(_panel->getAxis(pHistogram2DProperties.getYAxisId()));
		boost::shared_ptr<Axis> lZAxis(_panel->getAxis(pHistogram2DProperties.getZAxisId()));

		Range lXRange = lXAxis->getRange();
		Range lYRange = lYAxis->getRange();
		// Range lZRange = getZAxisRange (pSeries, lZAxis);

		PlWindow lPlWindow = PlWindow(lXRange.getMin(), lXRange.getMax(), lYRange.getMin(), lYRange.getMax());

		// Calculate X and Y tick
		TickConf lTickConf;
		double lXMajorTickSpace = nan("");
		int lXMinorTickNumber = 0;
		double lYMajorTickSpace = nan("");
		int lYMinorTickNumber = 0;

		if (pHistogram2DProperties.hasXAxis())
		{
			// Calculate X tick
			lXMajorTickSpace = getMajorTickSpace(lXAxis.get(),
												 std::get<0>(lPlWindow), std::get<1>(lPlWindow));
			lXMinorTickNumber = getMinorTickNumber(lXAxis.get(),
												   std::get<0>(lPlWindow), std::get<1>(lPlWindow), lXMajorTickSpace);
		}

		if (pHistogram2DProperties.hasYAxis())
		{
			// Calculate Y tick
			lYMajorTickSpace = getMajorTickSpace(lYAxis.get(), std::get<2>(lPlWindow), std::get<3>(lPlWindow));
			lYMinorTickNumber = getMinorTickNumber(lYAxis.get(), std::get<2>(lPlWindow), std::get<3>(lPlWindow),
												   lYMajorTickSpace);
		}

		lTickConf = TickConf(lXMajorTickSpace, lXMinorTickNumber, lYMajorTickSpace, lYMinorTickNumber);

		// Draw Y axis and legend
		if (pHistogram2DProperties.hasYAxis() && !lYAxis->_drawn)
		{

			drawYAxis(lYAxis, lPlWindow, _plotAreaBounds, lTickConf);

			// Draw legend.
			drawLegends(lYAxis, lPlWindow, _plotAreaBounds);
		}

		// Draw X axis and legend
		if (pHistogram2DProperties.hasXAxis() && !lXAxis->_drawn)
		{
			drawXAxis(lXAxis, lPlWindow, _plotAreaBounds, lTickConf);

			// Draw legend.
			drawLegends(lXAxis, lPlWindow, _plotAreaBounds);
		}

		// Draw Z axis and legend
		if (pHistogram2DProperties.hasZAxis() && (lZAxis != nullptr) && !lZAxis->_drawn)
		{
			drawZAxis(lZAxis, lPlWindow, _plotAreaBounds, lTickConf);
		}

	}

ba6124b0   Menouard AZIB   Add parameter id ...
2727
2728
2729
2730
	void PanelPlotOutput::drawSauvaud(double /*startDate*/, double /*stopDate*/, std::string /*pParamId*/,
									  SauvaudProperties &pSauvaud, int subIndex = 0, int subsNumber = 1, std::string opositeLegend = "")
	{
		// Get X, Y and Z axis.
793c4351   Hacene SI HADJ MOHAND   creation de class...
2731
2732
		boost::shared_ptr<Axis> lXAxis(_panel->getAxis(pSauvaud.getXAxisId()));
		boost::shared_ptr<Axis> lYAxis(_panel->getAxis(pSauvaud.getYAxisId()));
793c4351   Hacene SI HADJ MOHAND   creation de class...
2733
		boost::shared_ptr<Axis> lZAxis(_panel->getAxis(pSauvaud.getZAxisId()));
ba6124b0   Menouard AZIB   Add parameter id ...
2734

793c4351   Hacene SI HADJ MOHAND   creation de class...
2735
		Range lXRange, lYRange, lZRange;
ba6124b0   Menouard AZIB   Add parameter id ...
2736
2737
		if (pSauvaud.hasXAxis() && lXAxis.get() == nullptr)
		{
793c4351   Hacene SI HADJ MOHAND   creation de class...
2738
			std::stringstream lError;
ba6124b0   Menouard AZIB   Add parameter id ...
2739
2740
2741
			lError << "PanelPlotOutput::drawSauvaud"
				   << ": X axis with id '"
				   << pSauvaud.getXAxisId() << "' not found.";
793c4351   Hacene SI HADJ MOHAND   creation de class...
2742
			BOOST_THROW_EXCEPTION(
ba6124b0   Menouard AZIB   Add parameter id ...
2743
2744
2745
2746
				PanelPlotOutputException() << AMDA::ex_msg(lError.str()));
		}
		else if (pSauvaud.hasXAxis())
		{
793c4351   Hacene SI HADJ MOHAND   creation de class...
2747
2748
2749
			// fill X range (plplot window).
			lXRange = lXAxis->getRange();
		}
fbe3c2bb   Benjamin Renard   First commit
2750

ba6124b0   Menouard AZIB   Add parameter id ...
2751
2752
		if (pSauvaud.hasYAxis() && lYAxis.get() == nullptr)
		{
793c4351   Hacene SI HADJ MOHAND   creation de class...
2753
			std::stringstream lError;
ba6124b0   Menouard AZIB   Add parameter id ...
2754
2755
2756
			lError << "PanelPlotOutput::drawSauvaud"
				   << ": Y axis with id '"
				   << pSauvaud.getYAxisId() << "' not found.";
793c4351   Hacene SI HADJ MOHAND   creation de class...
2757
			BOOST_THROW_EXCEPTION(
ba6124b0   Menouard AZIB   Add parameter id ...
2758
				PanelPlotOutputException() << AMDA::ex_msg(lError.str()));
793c4351   Hacene SI HADJ MOHAND   creation de class...
2759
			lYRange = Range();
ba6124b0   Menouard AZIB   Add parameter id ...
2760
2761
2762
		}
		else if (pSauvaud.hasYAxis())
		{
793c4351   Hacene SI HADJ MOHAND   creation de class...
2763
2764
			// fill Y range (plplot window).
			lYRange = lYAxis->getRange();
ba6124b0   Menouard AZIB   Add parameter id ...
2765
			fixRange(lYRange, lYAxis->_scale == Axis::Scale::LOGARITHMIC);
793c4351   Hacene SI HADJ MOHAND   creation de class...
2766
2767
		}

ba6124b0   Menouard AZIB   Add parameter id ...
2768
2769
		if (pSauvaud.hasZAxis() && lZAxis.get() == nullptr)
		{
793c4351   Hacene SI HADJ MOHAND   creation de class...
2770
			std::stringstream lError;
ba6124b0   Menouard AZIB   Add parameter id ...
2771
2772
2773
			lError << "PanelPlotOutput::drawSauvaud"
				   << ": Z axis with id '"
				   << pSauvaud.getZAxisId() << "' not found.";
793c4351   Hacene SI HADJ MOHAND   creation de class...
2774
			BOOST_THROW_EXCEPTION(
ba6124b0   Menouard AZIB   Add parameter id ...
2775
				PanelPlotOutputException() << AMDA::ex_msg(lError.str()));
793c4351   Hacene SI HADJ MOHAND   creation de class...
2776
2777
			lZRange = Range();
		}
ba6124b0   Menouard AZIB   Add parameter id ...
2778
2779
		else if (pSauvaud.hasZAxis())
		{
793c4351   Hacene SI HADJ MOHAND   creation de class...
2780
2781
2782
			// fill Z range (plplot window).
			lZRange = lZAxis->getRange();
		}
ba6124b0   Menouard AZIB   Add parameter id ...
2783
2784

		PlWindow lPlWindow;
793c4351   Hacene SI HADJ MOHAND   creation de class...
2785
2786
		lPlWindow = PlWindow(lXRange.getMin(), lXRange.getMax(), lYRange.getMin(), lYRange.getMax());

793c4351   Hacene SI HADJ MOHAND   creation de class...
2787
2788
2789
2790
2791
2792
		// Calculate X and Y tick
		TickConf lTickConf;
		double lXMajorTickSpace = nan("");
		int lXMinorTickNumber = 0;
		double lYMajorTickSpace = nan("");
		int lYMinorTickNumber = 0;
ba6124b0   Menouard AZIB   Add parameter id ...
2793
2794
2795
2796
2797
2798
2799
2800
2801
2802
2803
2804
2805
2806
2807
2808
2809
2810

		if (pSauvaud.hasXAxis() && (subIndex == 0))
		{
			// Calculate X tick
			lXMajorTickSpace = getMajorTickSpace(lXAxis.get(),
												 std::get<0>(lPlWindow), std::get<1>(lPlWindow));
			lXMinorTickNumber = getMinorTickNumber(lXAxis.get(),
												   std::get<0>(lPlWindow), std::get<1>(lPlWindow), lXMajorTickSpace);
		}

		if (pSauvaud.hasYAxis() && (subIndex == subsNumber - 1))
		{
			// Calculate Y tick
			lYMajorTickSpace = getMajorTickSpace(lYAxis.get(), std::get<2>(lPlWindow), std::get<3>(lPlWindow));
			lYMinorTickNumber = getMinorTickNumber(lYAxis.get(), std::get<2>(lPlWindow), std::get<3>(lPlWindow),
												   lYMajorTickSpace);
		}

793c4351   Hacene SI HADJ MOHAND   creation de class...
2811
		lTickConf = TickConf(lXMajorTickSpace, lXMinorTickNumber, lYMajorTickSpace, lYMinorTickNumber);
ba6124b0   Menouard AZIB   Add parameter id ...
2812
		Bounds areaBounds(_plotAreaBounds);
793c4351   Hacene SI HADJ MOHAND   creation de class...
2813

ba6124b0   Menouard AZIB   Add parameter id ...
2814
2815
2816
2817
2818
2819
		double width = _plotAreaBounds._height / (subsNumber + 1);
		if (subsNumber > 0)
		{
			areaBounds._y = _plotAreaBounds._y + subIndex * (width + width / 10);
			areaBounds._height = width;
		}
793c4351   Hacene SI HADJ MOHAND   creation de class...
2820
2821

		// Draw Y axis and legend
ba6124b0   Menouard AZIB   Add parameter id ...
2822
2823
2824
2825
2826
2827
2828
2829
2830
2831
2832
2833
2834
2835
2836
2837
2838
2839
2840
2841
2842
2843
2844
2845
2846
2847
2848
2849
2850
2851
2852
2853
2854
2855
2856
2857
2858
2859
2860
2861
2862
2863
2864
2865
2866
2867
2868
2869
2870
2871
2872
2873
2874
2875
2876
2877
2878
2879
2880
2881
2882
2883
2884
2885
2886
2887
2888
2889
2890
2891
2892
2893
2894
		if (pSauvaud.hasYAxis())
		{

			Label label(lYAxis->_legend.getFont(), lYAxis->_legend.getColor());

			Font font_(label.getFont());
			int size_ = font_.getSize();
			if (font_.getSize() == 0)
			{
				size_ = std::round(314.5 * width - 2.7);
				size_ = std::max(size_, 2);
				size_ = std::min(size_, 8);
				font_.setSize(size_);
				label.setFont(font_);
				lYAxis->_legend.setLabel(label);
			}
			bool changed = false;

			// Draw legend for the last spectro.
			if (subIndex == subsNumber - 1)
			{
				lYAxis->setShowTickMark(true);

				PlotCommon::Position pos_ = lYAxis->_position;
				Label label(lYAxis->_legend.getFont(), lYAxis->_legend.getColor());
				Font font_(label.getFont());
				std::string text_ = lYAxis->_legend.getText();
				if (!opositeLegend.empty())
				{
					label._text = opositeLegend;
					changed = true;
				}
				if (lYAxis->_scale == Axis::Scale::LOGARITHMIC && font_.getSize() > 3)
				{
					font_.setSize(3);
					changed = true;
				}
				lYAxis->_legend.clearLabels();
				lYAxis->_legend.setLabel(label);
				switch (pos_)
				{
				case PlotCommon::Position::POS_LEFT:
					lYAxis->_position = PlotCommon::Position::POS_RIGHT;
					break;
				case PlotCommon::Position::POS_RIGHT:
					lYAxis->_position = PlotCommon::Position::POS_LEFT;
					break;
				default:
					break;
				}
				drawYAxis(lYAxis, lPlWindow, areaBounds, lTickConf);
				if (!opositeLegend.empty())
					drawLegends(lYAxis, lPlWindow, areaBounds);
				lYAxis->_position = pos_;
				if (changed)
				{
					font_.setSize(size_);
					label.setFont(font_);
					label._text = text_;
					lYAxis->_legend.clearLabels();
					lYAxis->_legend.setLabel(label);
					changed = false;
				}
				drawLegends(lYAxis, lPlWindow, areaBounds);
			}
			else
			{
				lYAxis->setShowTickMark(false);
				if (subIndex < subsNumber)
					drawYAxis(lYAxis, lPlWindow, areaBounds, lTickConf);

				drawLegends(lYAxis, lPlWindow, areaBounds);
			}
793c4351   Hacene SI HADJ MOHAND   creation de class...
2895
2896
2897
		}

		// Draw Z axis and legend
ba6124b0   Menouard AZIB   Add parameter id ...
2898
2899
2900
		if (pSauvaud.hasZAxis() && (lZAxis != nullptr) && !lZAxis->_drawn)
		{
			drawZAxis(lZAxis, lPlWindow, _plotAreaBounds, lTickConf);
793c4351   Hacene SI HADJ MOHAND   creation de class...
2901
		}
ba6124b0   Menouard AZIB   Add parameter id ...
2902
2903
2904
2905

		// Draw X axis and legend
		if (pSauvaud.hasXAxis() && subIndex < subsNumber)
		{
b0205fd9   Hacene SI HADJ MOHAND   plot ok reste que...
2906
2907

			drawXAxis(lXAxis, lPlWindow, areaBounds, lTickConf);
ba6124b0   Menouard AZIB   Add parameter id ...
2908
2909
2910
2911
2912
2913
2914
2915
2916
2917

			// Draw legend.
			if (subIndex == 0)
				drawLegends(lXAxis, lPlWindow, areaBounds);
		}
	}
	void PanelPlotOutput::drawSpectro(double /*startDate*/, double /*stopDate*/, std::string /*pParamId*/,
									  SpectroProperties &pSpectro)
	{
		// Get X, Y and Z axis.
fbe3c2bb   Benjamin Renard   First commit
2918
2919
2920
2921
2922
2923
		boost::shared_ptr<Axis> lXAxis(_panel->getAxis(pSpectro.getXAxisId()));
		boost::shared_ptr<Axis> lYAxis(_panel->getAxis(pSpectro.getYAxisId()));
		boost::shared_ptr<Axis> lZAxis(_panel->getAxis(pSpectro.getZAxisId()));

		PlWindow lPlWindow;
		Range lXRange, lYRange, lZRange;
ba6124b0   Menouard AZIB   Add parameter id ...
2924
2925
		if (pSpectro.hasXAxis() && lXAxis.get() == nullptr)
		{
fbe3c2bb   Benjamin Renard   First commit
2926
			std::stringstream lError;
ba6124b0   Menouard AZIB   Add parameter id ...
2927
2928
2929
			lError << "PanelPlotOutput::drawSpectro"
				   << ": X axis with id '"
				   << pSpectro.getXAxisId() << "' not found.";
fbe3c2bb   Benjamin Renard   First commit
2930
			BOOST_THROW_EXCEPTION(
ba6124b0   Menouard AZIB   Add parameter id ...
2931
				PanelPlotOutputException() << AMDA::ex_msg(lError.str()));
fbe3c2bb   Benjamin Renard   First commit
2932
		}
ba6124b0   Menouard AZIB   Add parameter id ...
2933
2934
		else if (pSpectro.hasXAxis())
		{
fbe3c2bb   Benjamin Renard   First commit
2935
2936
2937
2938
			// fill X range (plplot window).
			lXRange = lXAxis->getRange();
		}

ba6124b0   Menouard AZIB   Add parameter id ...
2939
2940
		if (pSpectro.hasYAxis() && lYAxis.get() == nullptr)
		{
fbe3c2bb   Benjamin Renard   First commit
2941
			std::stringstream lError;
ba6124b0   Menouard AZIB   Add parameter id ...
2942
2943
2944
			lError << "PanelPlotOutput::drawSpectro"
				   << ": Y axis with id '"
				   << pSpectro.getYAxisId() << "' not found.";
fbe3c2bb   Benjamin Renard   First commit
2945
			BOOST_THROW_EXCEPTION(
ba6124b0   Menouard AZIB   Add parameter id ...
2946
				PanelPlotOutputException() << AMDA::ex_msg(lError.str()));
fbe3c2bb   Benjamin Renard   First commit
2947
2948
			lYRange = Range();
		}
ba6124b0   Menouard AZIB   Add parameter id ...
2949
2950
		else if (pSpectro.hasYAxis())
		{
fbe3c2bb   Benjamin Renard   First commit
2951
2952
			// fill Y range (plplot window).
			lYRange = lYAxis->getRange();
ba6124b0   Menouard AZIB   Add parameter id ...
2953
			fixRange(lYRange, lYAxis->_scale == Axis::Scale::LOGARITHMIC);
fbe3c2bb   Benjamin Renard   First commit
2954
2955
		}

ba6124b0   Menouard AZIB   Add parameter id ...
2956
2957
		if (pSpectro.hasZAxis() && lZAxis.get() == nullptr)
		{
fbe3c2bb   Benjamin Renard   First commit
2958
			std::stringstream lError;
ba6124b0   Menouard AZIB   Add parameter id ...
2959
2960
2961
			lError << "PanelPlotOutput::drawSpectro"
				   << ": Z axis with id '"
				   << pSpectro.getZAxisId() << "' not found.";
fbe3c2bb   Benjamin Renard   First commit
2962
			BOOST_THROW_EXCEPTION(
ba6124b0   Menouard AZIB   Add parameter id ...
2963
				PanelPlotOutputException() << AMDA::ex_msg(lError.str()));
fbe3c2bb   Benjamin Renard   First commit
2964
2965
			lZRange = Range();
		}
ba6124b0   Menouard AZIB   Add parameter id ...
2966
2967
		else if (pSpectro.hasZAxis())
		{
fbe3c2bb   Benjamin Renard   First commit
2968
2969
2970
2971
2972
2973
			// fill Z range (plplot window).
			lZRange = lZAxis->getRange();
		}

		lPlWindow = PlWindow(lXRange.getMin(), lXRange.getMax(), lYRange.getMin(), lYRange.getMax());

fbe3c2bb   Benjamin Renard   First commit
2974
2975
2976
2977
2978
2979
2980
		// Calculate X and Y tick
		TickConf lTickConf;
		double lXMajorTickSpace = nan("");
		int lXMinorTickNumber = 0;
		double lYMajorTickSpace = nan("");
		int lYMinorTickNumber = 0;

ba6124b0   Menouard AZIB   Add parameter id ...
2981
2982
		if (pSpectro.hasXAxis())
		{
fbe3c2bb   Benjamin Renard   First commit
2983
2984
			// Calculate X tick
			lXMajorTickSpace = getMajorTickSpace(lXAxis.get(),
ba6124b0   Menouard AZIB   Add parameter id ...
2985
												 std::get<0>(lPlWindow), std::get<1>(lPlWindow));
fbe3c2bb   Benjamin Renard   First commit
2986
			lXMinorTickNumber = getMinorTickNumber(lXAxis.get(),
ba6124b0   Menouard AZIB   Add parameter id ...
2987
												   std::get<0>(lPlWindow), std::get<1>(lPlWindow), lXMajorTickSpace);
fbe3c2bb   Benjamin Renard   First commit
2988
2989
		}

ba6124b0   Menouard AZIB   Add parameter id ...
2990
2991
		if (pSpectro.hasYAxis())
		{
fbe3c2bb   Benjamin Renard   First commit
2992
2993
2994
			// Calculate Y tick
			lYMajorTickSpace = getMajorTickSpace(lYAxis.get(), std::get<2>(lPlWindow), std::get<3>(lPlWindow));
			lYMinorTickNumber = getMinorTickNumber(lYAxis.get(), std::get<2>(lPlWindow), std::get<3>(lPlWindow),
ba6124b0   Menouard AZIB   Add parameter id ...
2995
												   lYMajorTickSpace);
fbe3c2bb   Benjamin Renard   First commit
2996
2997
2998
2999
		}

		lTickConf = TickConf(lXMajorTickSpace, lXMinorTickNumber, lYMajorTickSpace, lYMinorTickNumber);

fbe3c2bb   Benjamin Renard   First commit
3000
		// Draw Y axis and legend
ba6124b0   Menouard AZIB   Add parameter id ...
3001
3002
		if (pSpectro.hasYAxis() && !lYAxis->_drawn)
		{
fbe3c2bb   Benjamin Renard   First commit
3003
3004
3005
3006
3007
3008
3009
3010

			drawYAxis(lYAxis, lPlWindow, _plotAreaBounds, lTickConf);

			// Draw legend.
			drawLegends(lYAxis, lPlWindow, _plotAreaBounds);
		}

		// Draw X axis and legend
ba6124b0   Menouard AZIB   Add parameter id ...
3011
3012
		if (pSpectro.hasXAxis() && !lXAxis->_drawn)
		{
fbe3c2bb   Benjamin Renard   First commit
3013
3014
3015
3016
3017
3018
3019
3020

			drawXAxis(lXAxis, lPlWindow, _plotAreaBounds, lTickConf);

			// Draw legend.
			drawLegends(lXAxis, lPlWindow, _plotAreaBounds);
		}

		// Draw Z axis and legend
ba6124b0   Menouard AZIB   Add parameter id ...
3021
3022
3023
		if (pSpectro.hasZAxis() && (lZAxis != nullptr) && !lZAxis->_drawn)
		{
			drawZAxis(lZAxis, lPlWindow, _plotAreaBounds, lTickConf);
fbe3c2bb   Benjamin Renard   First commit
3024
		}
ba6124b0   Menouard AZIB   Add parameter id ...
3025
3026
3027
3028
3029
	}

	void PanelPlotOutput::drawIntervals(double /*startDate*/, double /*stopDate*/, std::string /*pParamId*/,
										IntervalsProperties &pIntervals)
	{
fbe3c2bb   Benjamin Renard   First commit
3030

ba6124b0   Menouard AZIB   Add parameter id ...
3031
		boost::shared_ptr<Axis> lXAxis(_panel->getAxis(pIntervals.getXAxisId()));
e257cfb9   Benjamin Renard   First implementat...
3032
3033
3034

		PlWindow lPlWindow;
		Range lXRange, lYRange;
ba6124b0   Menouard AZIB   Add parameter id ...
3035
3036
		if (lXAxis.get() == nullptr)
		{
e257cfb9   Benjamin Renard   First implementat...
3037
			std::stringstream lError;
ba6124b0   Menouard AZIB   Add parameter id ...
3038
3039
3040
			lError << "PanelPlotOutput::drawIntervals"
				   << ": X axis with id '"
				   << pIntervals.getXAxisId() << "' not found.";
e257cfb9   Benjamin Renard   First implementat...
3041
			BOOST_THROW_EXCEPTION(
ba6124b0   Menouard AZIB   Add parameter id ...
3042
				PanelPlotOutputException() << AMDA::ex_msg(lError.str()));
e257cfb9   Benjamin Renard   First implementat...
3043
		}
ba6124b0   Menouard AZIB   Add parameter id ...
3044
3045
3046
3047

		lXRange = lXAxis->getRange();

		lYRange = Range(0, 1);
e257cfb9   Benjamin Renard   First implementat...
3048
3049
3050
3051
3052
3053
3054
3055
3056
3057

		lPlWindow = PlWindow(lXRange.getMin(), lXRange.getMax(), lYRange.getMin(), lYRange.getMax());

		// Calculate X and Y tick
		TickConf lTickConf;
		double lXMajorTickSpace = nan("");
		int lXMinorTickNumber = 0;
		double lYMajorTickSpace = nan("");
		int lYMinorTickNumber = 0;

ba6124b0   Menouard AZIB   Add parameter id ...
3058
3059
3060
3061
3062
3063
		lXMajorTickSpace = getMajorTickSpace(lXAxis.get(),
											 std::get<0>(lPlWindow), std::get<1>(lPlWindow));
		lXMinorTickNumber = getMinorTickNumber(lXAxis.get(),
											   std::get<0>(lPlWindow), std::get<1>(lPlWindow), lXMajorTickSpace);

		lTickConf = TickConf(lXMajorTickSpace, lXMinorTickNumber, lYMajorTickSpace, lYMinorTickNumber);
e257cfb9   Benjamin Renard   First implementat...
3064
3065

		// Draw X axis and legend
ba6124b0   Menouard AZIB   Add parameter id ...
3066
3067
		if (!lXAxis->_drawn)
		{
e257cfb9   Benjamin Renard   First implementat...
3068
3069
3070
3071
3072
3073
3074

			drawXAxis(lXAxis, lPlWindow, _plotAreaBounds, lTickConf);

			// Draw legend.
			drawLegends(lXAxis, lPlWindow, _plotAreaBounds);
		}

ba6124b0   Menouard AZIB   Add parameter id ...
3075
3076
3077
		_pls->vpor(_plotAreaBounds._x, _plotAreaBounds._x + _plotAreaBounds._width,
				   _plotAreaBounds._y, _plotAreaBounds._y + _plotAreaBounds._height);
	}
e257cfb9   Benjamin Renard   First implementat...
3078

ba6124b0   Menouard AZIB   Add parameter id ...
3079
3080
3081
3082
3083
3084
	void PanelPlotOutput::drawFills(double /*startDate*/, double /*stopDate*/)
	{
		// Nothing done here except setting the viewport, see subclasses for specific implementation
		_pls->vpor(_plotAreaBounds._x, _plotAreaBounds._x + _plotAreaBounds._width,
				   _plotAreaBounds._y, _plotAreaBounds._y + _plotAreaBounds._height);
	}
fbe3c2bb   Benjamin Renard   First commit
3085

ba6124b0   Menouard AZIB   Add parameter id ...
3086
3087
3088
3089
3090
3091
3092
3093
	void PanelPlotOutput::drawSeries(double /*startDate*/, double /*stopDate*/, int /*intervalIndex*/, std::string /*pParamId*/,
									 SeriesProperties &pSeries, AMDA::Common::ParameterIndexComponent /*pParamIndex*/,
									 ParameterAxes & /*param*/, bool /*moreThanOneSerieForAxis*/)
	{
		// Get X, Y and Z axis.
		boost::shared_ptr<Axis> lXAxis(_panel->getAxis(pSeries.getXAxisId()));
		boost::shared_ptr<Axis> lYAxis(_panel->getAxis(pSeries.getYAxisId()));
		boost::shared_ptr<Axis> lZAxis(_panel->getAxis(pSeries.getZAxisId()));
fbe3c2bb   Benjamin Renard   First commit
3094

ba6124b0   Menouard AZIB   Add parameter id ...
3095
3096
3097
		Range lXRange = getXAxisRange(pSeries, lXAxis);
		Range lYRange = getYAxisRange(pSeries, lYAxis);
		// Range lZRange = getZAxisRange (pSeries, lZAxis);
fbe3c2bb   Benjamin Renard   First commit
3098

ba6124b0   Menouard AZIB   Add parameter id ...
3099
		PlWindow lPlWindow = PlWindow(lXRange.getMin(), lXRange.getMax(), lYRange.getMin(), lYRange.getMax());
fbe3c2bb   Benjamin Renard   First commit
3100

ba6124b0   Menouard AZIB   Add parameter id ...
3101
3102
3103
3104
3105
3106
		// Calculate X and Y tick
		TickConf lTickConf;
		double lXMajorTickSpace = nan("");
		int lXMinorTickNumber = 0;
		double lYMajorTickSpace = nan("");
		int lYMinorTickNumber = 0;
fbe3c2bb   Benjamin Renard   First commit
3107

ba6124b0   Menouard AZIB   Add parameter id ...
3108
3109
3110
3111
3112
3113
3114
3115
		if (pSeries.hasXAxis())
		{
			// Calculate X tick
			lXMajorTickSpace = getMajorTickSpace(lXAxis.get(),
												 std::get<0>(lPlWindow), std::get<1>(lPlWindow));
			lXMinorTickNumber = getMinorTickNumber(lXAxis.get(),
												   std::get<0>(lPlWindow), std::get<1>(lPlWindow), lXMajorTickSpace);
		}
fbe3c2bb   Benjamin Renard   First commit
3116

ba6124b0   Menouard AZIB   Add parameter id ...
3117
3118
3119
3120
3121
3122
3123
		if (pSeries.hasYAxis())
		{
			// Calculate Y tick
			lYMajorTickSpace = getMajorTickSpace(lYAxis.get(), std::get<2>(lPlWindow), std::get<3>(lPlWindow));
			lYMinorTickNumber = getMinorTickNumber(lYAxis.get(), std::get<2>(lPlWindow), std::get<3>(lPlWindow),
												   lYMajorTickSpace);
		}
fbe3c2bb   Benjamin Renard   First commit
3124

ba6124b0   Menouard AZIB   Add parameter id ...
3125
		lTickConf = TickConf(lXMajorTickSpace, lXMinorTickNumber, lYMajorTickSpace, lYMinorTickNumber);
fbe3c2bb   Benjamin Renard   First commit
3126

ba6124b0   Menouard AZIB   Add parameter id ...
3127
3128
3129
		// Draw Y axis and legend
		if (pSeries.hasYAxis() && !lYAxis->_drawn)
		{
fbe3c2bb   Benjamin Renard   First commit
3130

ba6124b0   Menouard AZIB   Add parameter id ...
3131
			drawYAxis(lYAxis, lPlWindow, _plotAreaBounds, lTickConf);
fbe3c2bb   Benjamin Renard   First commit
3132

ba6124b0   Menouard AZIB   Add parameter id ...
3133
3134
3135
			// Draw legend.
			drawLegends(lYAxis, lPlWindow, _plotAreaBounds);
		}
fbe3c2bb   Benjamin Renard   First commit
3136

ba6124b0   Menouard AZIB   Add parameter id ...
3137
3138
3139
3140
		// Draw X axis and legend
		if (pSeries.hasXAxis() && !lXAxis->_drawn)
		{
			drawXAxis(lXAxis, lPlWindow, _plotAreaBounds, lTickConf);
fbe3c2bb   Benjamin Renard   First commit
3141

ba6124b0   Menouard AZIB   Add parameter id ...
3142
3143
3144
			// Draw legend.
			drawLegends(lXAxis, lPlWindow, _plotAreaBounds);
		}
fbe3c2bb   Benjamin Renard   First commit
3145

ba6124b0   Menouard AZIB   Add parameter id ...
3146
3147
3148
3149
3150
		// Draw Z axis and legend
		if (pSeries.hasZAxis() && (lZAxis != nullptr) && !lZAxis->_drawn)
		{
			drawZAxis(lZAxis, lPlWindow, _plotAreaBounds, lTickConf);
		}
fbe3c2bb   Benjamin Renard   First commit
3151
3152
	}

ba6124b0   Menouard AZIB   Add parameter id ...
3153
3154
3155
3156
3157
3158
3159
3160
	void PanelPlotOutput::drawAdditionalObjects()
	{
		for (auto parameter : _parameterAxesList)
		{
			if (parameter.getSpectroProperties() != nullptr)
			{
				boost::shared_ptr<Axis> lXAxis(_panel->getAxis(parameter.getSpectroProperties()->getXAxisId()));
				boost::shared_ptr<Axis> lYAxis(_panel->getAxis(parameter.getSpectroProperties()->getYAxisId()));
fbe3c2bb   Benjamin Renard   First commit
3161

ba6124b0   Menouard AZIB   Add parameter id ...
3162
3163
				if ((lXAxis == nullptr) || (lYAxis == nullptr))
					continue;
fbe3c2bb   Benjamin Renard   First commit
3164

ba6124b0   Menouard AZIB   Add parameter id ...
3165
3166
				Range lXRange = lXAxis->getRange();
				Range lYRange = lYAxis->getRange();
537e3ab0   Benjamin Renard   Fix a bug with In...
3167

ba6124b0   Menouard AZIB   Add parameter id ...
3168
				PlWindow lPlWindow = PlWindow(lXRange.getMin(), lXRange.getMax(), lYRange.getMin(), lYRange.getMax());
fbe3c2bb   Benjamin Renard   First commit
3169

ba6124b0   Menouard AZIB   Add parameter id ...
3170
3171
				if (!lXAxis->_additionalObjDrawn)
					drawXConstantLines(lXAxis, lPlWindow);
fbe3c2bb   Benjamin Renard   First commit
3172

ba6124b0   Menouard AZIB   Add parameter id ...
3173
3174
				if (!lYAxis->_additionalObjDrawn)
					drawYConstantLines(lYAxis, lPlWindow);
fbe3c2bb   Benjamin Renard   First commit
3175

ba6124b0   Menouard AZIB   Add parameter id ...
3176
3177
				if (!lXAxis->_additionalObjDrawn || !lYAxis->_additionalObjDrawn)
					drawTextPlots(lXAxis, lYAxis, lPlWindow, _panel->_textPlots);
fbe3c2bb   Benjamin Renard   First commit
3178

ba6124b0   Menouard AZIB   Add parameter id ...
3179
3180
3181
				lXAxis->_additionalObjDrawn = true;
				lYAxis->_additionalObjDrawn = true;
			}
fbe3c2bb   Benjamin Renard   First commit
3182

ba6124b0   Menouard AZIB   Add parameter id ...
3183
3184
3185
3186
			if (parameter.getSauvaudProperties() != nullptr)
			{
				boost::shared_ptr<Axis> lXAxis(_panel->getAxis(parameter.getSauvaudProperties()->getXAxisId()));
				boost::shared_ptr<Axis> lYAxis(_panel->getAxis(parameter.getSauvaudProperties()->getYAxisId()));
5f13f59c   Hacene SI HADJ MOHAND   in progress worki...
3187

ba6124b0   Menouard AZIB   Add parameter id ...
3188
3189
				if ((lXAxis == nullptr) || (lYAxis == nullptr))
					continue;
5f13f59c   Hacene SI HADJ MOHAND   in progress worki...
3190

ba6124b0   Menouard AZIB   Add parameter id ...
3191
3192
				Range lXRange = lXAxis->getRange();
				Range lYRange = lYAxis->getRange();
5f13f59c   Hacene SI HADJ MOHAND   in progress worki...
3193

ba6124b0   Menouard AZIB   Add parameter id ...
3194
				PlWindow lPlWindow = PlWindow(lXRange.getMin(), lXRange.getMax(), lYRange.getMin(), lYRange.getMax());
5f13f59c   Hacene SI HADJ MOHAND   in progress worki...
3195

ba6124b0   Menouard AZIB   Add parameter id ...
3196
3197
				if (!lXAxis->_additionalObjDrawn)
					drawXConstantLines(lXAxis, lPlWindow);
5f13f59c   Hacene SI HADJ MOHAND   in progress worki...
3198

ba6124b0   Menouard AZIB   Add parameter id ...
3199
3200
				if (!lYAxis->_additionalObjDrawn)
					drawYConstantLines(lYAxis, lPlWindow);
5f13f59c   Hacene SI HADJ MOHAND   in progress worki...
3201

ba6124b0   Menouard AZIB   Add parameter id ...
3202
3203
				if (!lXAxis->_additionalObjDrawn || !lYAxis->_additionalObjDrawn)
					drawTextPlots(lXAxis, lYAxis, lPlWindow, _panel->_textPlots);
5f13f59c   Hacene SI HADJ MOHAND   in progress worki...
3204

ba6124b0   Menouard AZIB   Add parameter id ...
3205
3206
3207
				lXAxis->_additionalObjDrawn = true;
				lYAxis->_additionalObjDrawn = true;
			}
5f13f59c   Hacene SI HADJ MOHAND   in progress worki...
3208
		}
fbe3c2bb   Benjamin Renard   First commit
3209

ba6124b0   Menouard AZIB   Add parameter id ...
3210
3211
3212
3213
3214
3215
3216
		SeriesProperties lSeries;
		for (auto parameter : _parameterAxesList)
		{
			for (auto lSeries : parameter.getYSeriePropertiesList())
			{
				boost::shared_ptr<Axis> lXAxis(_panel->getAxis(lSeries.getXAxisId()));
				boost::shared_ptr<Axis> lYAxis(_panel->getAxis(lSeries.getYAxisId()));
078ec265   Benjamin Renard   Give the possibil...
3217

ba6124b0   Menouard AZIB   Add parameter id ...
3218
3219
				if ((lXAxis == nullptr) || (lYAxis == nullptr))
					continue;
c2b6616d   Benjamin Renard   Fix bug in drawAd...
3220

ba6124b0   Menouard AZIB   Add parameter id ...
3221
3222
				Range lXRange = lXAxis->getRange();
				Range lYRange = lYAxis->getRange();
078ec265   Benjamin Renard   Give the possibil...
3223

ba6124b0   Menouard AZIB   Add parameter id ...
3224
				PlWindow lPlWindow = PlWindow(lXRange.getMin(), lXRange.getMax(), lYRange.getMin(), lYRange.getMax());
078ec265   Benjamin Renard   Give the possibil...
3225

ba6124b0   Menouard AZIB   Add parameter id ...
3226
3227
				if (!lXAxis->_additionalObjDrawn)
					drawXConstantLines(lXAxis, lPlWindow);
078ec265   Benjamin Renard   Give the possibil...
3228

ba6124b0   Menouard AZIB   Add parameter id ...
3229
3230
				if (!lYAxis->_additionalObjDrawn)
					drawYConstantLines(lYAxis, lPlWindow);
078ec265   Benjamin Renard   Give the possibil...
3231

ba6124b0   Menouard AZIB   Add parameter id ...
3232
3233
				if (!lXAxis->_additionalObjDrawn || !lYAxis->_additionalObjDrawn)
					drawTextPlots(lXAxis, lYAxis, lPlWindow, _panel->_textPlots);
078ec265   Benjamin Renard   Give the possibil...
3234

ba6124b0   Menouard AZIB   Add parameter id ...
3235
3236
3237
				lXAxis->_additionalObjDrawn = true;
				lYAxis->_additionalObjDrawn = true;
			}
078ec265   Benjamin Renard   Give the possibil...
3238
		}
fbe3c2bb   Benjamin Renard   First commit
3239

ba6124b0   Menouard AZIB   Add parameter id ...
3240
3241
3242
3243
		// Draw curvePlots
		for (auto curvePlot : _panel->_curvePlots)
			drawCurvePlot(*curvePlot);
	}
fbe3c2bb   Benjamin Renard   First commit
3244

ba6124b0   Menouard AZIB   Add parameter id ...
3245
3246
3247
3248
	void PanelPlotOutput::setPlStream(std::shared_ptr<plstream> &pls)
	{
		_pls = pls;
	}
c45180e1   Benjamin Renard   Add _used propert...
3249

ba6124b0   Menouard AZIB   Add parameter id ...
3250
3251
3252
3253
	std::string PanelPlotOutput::drawOppositeSide(boost::shared_ptr<Axis> pAxis)
	{
		boost::shared_ptr<Axis> lNewAxis;
		std::string lOppositeSide;
c45180e1   Benjamin Renard   Add _used propert...
3254

ba6124b0   Menouard AZIB   Add parameter id ...
3255
3256
3257
3258
3259
3260
3261
3262
3263
3264
3265
3266
3267
3268
3269
3270
3271
3272
3273
3274
3275
3276
3277
3278
3279
3280
3281
3282
3283
		switch (pAxis->_position)
		{
		case PlotCommon::Position::POS_BOTTOM:
			if (pAxis->_visible && !_plotAreaSideSet[PlotCommon::Position::POS_TOP])
			{
				lOppositeSide = "c";
			}
			break;
		case PlotCommon::Position::POS_TOP:
			if (pAxis->_visible && !_plotAreaSideSet[PlotCommon::Position::POS_BOTTOM])
			{
				lOppositeSide = "b";
			}
			break;
		case PlotCommon::Position::POS_LEFT:
			if (pAxis->_visible && !_plotAreaSideSet[PlotCommon::Position::POS_RIGHT])
			{
				lOppositeSide = "c";
			}
			break;
		case PlotCommon::Position::POS_RIGHT:
			if (pAxis->_visible && !_plotAreaSideSet[PlotCommon::Position::POS_LEFT])
			{
				lOppositeSide = "b";
			}
			break;
		case PlotCommon::Position::POS_CENTER:
		default:
			lOppositeSide = "";
fbe3c2bb   Benjamin Renard   First commit
3284
		}
fbe3c2bb   Benjamin Renard   First commit
3285

ba6124b0   Menouard AZIB   Add parameter id ...
3286
3287
		return lOppositeSide;
	}
fbe3c2bb   Benjamin Renard   First commit
3288

ba6124b0   Menouard AZIB   Add parameter id ...
3289
3290
3291
	/*
	 * Create a sampled parameter from an original parameter and a sampling value
	 */
07bf1e7c   Menouard AZIB   EveryThing works ...
3292
	AMDA::Parameters::ParameterSPtr PanelPlotOutput::createSampledParameter(AMDA::Parameters::ParameterSPtr &originalParam, float samplingValue, int gap)
ba6124b0   Menouard AZIB   Add parameter id ...
3293
	{
07bf1e7c   Menouard AZIB   EveryThing works ...
3294
		const int userGap = gap == -1 ? originalParam->getGapThreshold(): gap;
ba6124b0   Menouard AZIB   Add parameter id ...
3295
		AMDA::Parameters::ParameterSPtr sampledParam = _parameterManager.getSampledParameter(
fbe3c2bb   Benjamin Renard   First commit
3296
3297
3298
			originalParam->getId(),
			"classic",
			samplingValue,
07bf1e7c   Menouard AZIB   EveryThing works ...
3299
			userGap, true);
fbe3c2bb   Benjamin Renard   First commit
3300

ba6124b0   Menouard AZIB   Add parameter id ...
3301
3302
3303
3304
3305
		if (sampledParam == NULL)
		{
			LOG4CXX_ERROR(gLogger,
						  "ParamOutput::createSampledParameter : cannot create sampled parameter");
			BOOST_THROW_EXCEPTION(
fbe3c2bb   Benjamin Renard   First commit
3306
				AMDA::Parameters::ParamOutput_exception());
ba6124b0   Menouard AZIB   Add parameter id ...
3307
		}
fbe3c2bb   Benjamin Renard   First commit
3308

ba6124b0   Menouard AZIB   Add parameter id ...
3309
		LOG4CXX_INFO(gLogger, "ParamOutput::createSampledParameter : sampled parameter : " << sampledParam->getId() << " created");
fbe3c2bb   Benjamin Renard   First commit
3310

ba6124b0   Menouard AZIB   Add parameter id ...
3311
3312
		return sampledParam;
	}
fbe3c2bb   Benjamin Renard   First commit
3313

ba6124b0   Menouard AZIB   Add parameter id ...
3314
3315
3316
3317
3318
3319
3320
3321
	/*
	 * Create a sampled parameter from an original parameter and a reference parameter for time definition
	 */
	AMDA::Parameters::ParameterSPtr PanelPlotOutput::createSampledParameterUnderReferenceParameter(AMDA::Parameters::ParameterSPtr &originalParam, AMDA::Parameters::ParameterSPtr &refParam)
	{
		/*if (originalParam == refParam) {
			return originalParam;
		}*/
deefda79   Benjamin Renard   Addapt resampling...
3322

ba6124b0   Menouard AZIB   Add parameter id ...
3323
		AMDA::Parameters::ParameterSPtr sampledParam = _parameterManager.getSampledParameterUnderRefParam(
fbe3c2bb   Benjamin Renard   First commit
3324
			originalParam->getId(),
ba6124b0   Menouard AZIB   Add parameter id ...
3325
			refParam->getId(), true);
fbe3c2bb   Benjamin Renard   First commit
3326

ba6124b0   Menouard AZIB   Add parameter id ...
3327
3328
3329
3330
3331
		if (sampledParam == NULL)
		{
			LOG4CXX_ERROR(gLogger,
						  "ParamOutput::createSampledParameterUnderReferenceParameter : cannot create sampled parameter");
			BOOST_THROW_EXCEPTION(
fbe3c2bb   Benjamin Renard   First commit
3332
				AMDA::Parameters::ParamOutput_exception());
ba6124b0   Menouard AZIB   Add parameter id ...
3333
		}
fbe3c2bb   Benjamin Renard   First commit
3334

ba6124b0   Menouard AZIB   Add parameter id ...
3335
		LOG4CXX_INFO(gLogger, "ParamOutput::createSampledParameterUnderReferenceParameter : sampled parameter : " << sampledParam->getId() << " created");
fbe3c2bb   Benjamin Renard   First commit
3336

ba6124b0   Menouard AZIB   Add parameter id ...
3337
3338
		return sampledParam;
	}
fbe3c2bb   Benjamin Renard   First commit
3339

ba6124b0   Menouard AZIB   Add parameter id ...
3340
	ParameterAxes *PanelPlotOutput::getParameterAxesByColorSerieId(int colorSerieId)
fbe3c2bb   Benjamin Renard   First commit
3341
	{
ba6124b0   Menouard AZIB   Add parameter id ...
3342
3343
3344
3345
3346
		if (colorSerieId < 0)
			return NULL;

		for (ParameterAxesList::iterator it = _parameterAxesList.begin();
			 it != _parameterAxesList.end(); ++it)
fbe3c2bb   Benjamin Renard   First commit
3347
		{
ba6124b0   Menouard AZIB   Add parameter id ...
3348
3349
3350
3351
3352
			for (auto serieProp : it->getColorSeriePropertiesList())
			{
				if (serieProp.getId() == colorSerieId)
					return &(*it);
			}
fbe3c2bb   Benjamin Renard   First commit
3353
		}
fbe3c2bb   Benjamin Renard   First commit
3354

ba6124b0   Menouard AZIB   Add parameter id ...
3355
3356
3357
		LOG4CXX_ERROR(gLogger, "ParamOutput::getColorSeriePropertiesById : Not founded : " << colorSerieId);
		return NULL;
	}
fbe3c2bb   Benjamin Renard   First commit
3358

ba6124b0   Menouard AZIB   Add parameter id ...
3359
	ParameterAxes *PanelPlotOutput::getParameterAxesByXSerieId(int xSerieId)
c46af5a8   Benjamin Renard   Implements multi ...
3360
	{
ba6124b0   Menouard AZIB   Add parameter id ...
3361
3362
		for (ParameterAxesList::iterator it = _parameterAxesList.begin();
			 it != _parameterAxesList.end(); ++it)
c46af5a8   Benjamin Renard   Implements multi ...
3363
		{
ba6124b0   Menouard AZIB   Add parameter id ...
3364
3365
3366
3367
3368
			for (auto serieProp : it->getXSeriePropertiesList())
			{
				if (serieProp.getId() == xSerieId)
					return &(*it);
			}
c46af5a8   Benjamin Renard   Implements multi ...
3369
		}
c46af5a8   Benjamin Renard   Implements multi ...
3370

ba6124b0   Menouard AZIB   Add parameter id ...
3371
3372
3373
		LOG4CXX_ERROR(gLogger, "ParamOutput::getXSeriePropertiesById : Not founded : " << xSerieId);
		return NULL;
	}
c46af5a8   Benjamin Renard   Implements multi ...
3374

ba6124b0   Menouard AZIB   Add parameter id ...
3375
3376
3377
3378
3379
3380
	/**
	 * Create parameters needed for this plot.
	 * By default, the creation method create parameters for a time serie.
	 * Override it for other plot type
	 */
	void PanelPlotOutput::createParameters(std::list<std::string> &usedParametersId_)
fbe3c2bb   Benjamin Renard   First commit
3381
	{
ba6124b0   Menouard AZIB   Add parameter id ...
3382
3383
3384
3385
3386
3387
		// -- for each y serie on each parameter, calculate
		// y serie sampling according to max resolution
		for (ParameterAxesList::iterator it = _parameterAxesList.begin();
			 it != _parameterAxesList.end(); ++it)
		{
			AMDA::Parameters::ParameterSPtr originalParam =
fbe3c2bb   Benjamin Renard   First commit
3388
3389
				_parameterManager.getParameter(it->_originalParamId);

ba6124b0   Menouard AZIB   Add parameter id ...
3390
3391
			// original parameter sampling
			double samplingValue = getSamplingInTreeParameter(originalParam);
fbe3c2bb   Benjamin Renard   First commit
3392

ba6124b0   Menouard AZIB   Add parameter id ...
3393
3394
3395
3396
3397
3398
			// For each series
			std::vector<SeriesProperties>::iterator ity;
			for (ity = it->getYSeriePropertiesList().begin(); ity != it->getYSeriePropertiesList().end();
				 ++ity)
			{
				ParameterAxes *colorSerieParameterAxes = getParameterAxesByColorSerieId(ity->getColorSerieId());
fbe3c2bb   Benjamin Renard   First commit
3399

ba6124b0   Menouard AZIB   Add parameter id ...
3400
3401
3402
				AMDA::Parameters::ParameterSPtr originalColorParam;
				if (colorSerieParameterAxes != NULL)
					originalColorParam = _parameterManager.getParameter(colorSerieParameterAxes->_originalParamId);
fbe3c2bb   Benjamin Renard   First commit
3403

ba6124b0   Menouard AZIB   Add parameter id ...
3404
3405
				// get corrected sampling value in relation with max resolution
				double correctedSamplingValue = getCorrectedSamplingValue(ity->getMaxResolution(), samplingValue);
fbe3c2bb   Benjamin Renard   First commit
3406

ba6124b0   Menouard AZIB   Add parameter id ...
3407
				AMDA::Parameters::ParameterSPtr usedParam;
fbe3c2bb   Benjamin Renard   First commit
3408

ba6124b0   Menouard AZIB   Add parameter id ...
3409
3410
				// create parameter and link to the serie
				switch (ity->getResamplingProperties().getType())
fbe3c2bb   Benjamin Renard   First commit
3411
				{
ba6124b0   Menouard AZIB   Add parameter id ...
3412
3413
3414
				case ResamplingType::MANUAL:
				{
					// create resampling parameters for param
2fc1f2f8   Benjamin Renard   Full rework for s...
3415
					usedParam = createSampledParameter(originalParam, ity->getResamplingProperties().getValue());
fbe3c2bb   Benjamin Renard   First commit
3416
3417
					break;
				}
ba6124b0   Menouard AZIB   Add parameter id ...
3418
3419
3420
3421
3422
3423
3424
3425
3426
3427
3428
3429
3430
3431
3432
				case ResamplingType::AUTO:
				case ResamplingType::YPARAM:
				case ResamplingType::XPARAM:
					if (abs(samplingValue - correctedSamplingValue) > 1.)
					{
						// more than one second between samplingValue and correctedSamplingValue
						//=> use resampling parameter
						usedParam = createSampledParameter(originalParam, correctedSamplingValue);
					}
					else
					{
						// use original parameter
						usedParam = originalParam;
					}
					break;
fbe3c2bb   Benjamin Renard   First commit
3433
				}
ba6124b0   Menouard AZIB   Add parameter id ...
3434
3435
3436
3437
3438
				// Add used parameter to parameters list
				if (std::find(usedParametersId_.begin(), usedParametersId_.end(), usedParam->getId()) == usedParametersId_.end())
					usedParametersId_.push_back(usedParam->getId());
				// link this paramter to the serie
				ity->setParamId(usedParam->getId());
fbe3c2bb   Benjamin Renard   First commit
3439

ba6124b0   Menouard AZIB   Add parameter id ...
3440
				ErrorBarProperties &errorBarProp = ity->getErrorBarProperties();
fbe3c2bb   Benjamin Renard   First commit
3441

ba6124b0   Menouard AZIB   Add parameter id ...
3442
3443
				// Compute min / max re-sampled parameters if min/max error bar are defined for the serie
				if (errorBarProp.getErrorMinMax() != nullptr)
fbe3c2bb   Benjamin Renard   First commit
3444
				{
fbe3c2bb   Benjamin Renard   First commit
3445

ba6124b0   Menouard AZIB   Add parameter id ...
3446
3447
3448
3449
					// Build expression for computed parameter = usedParam - minParam
					AMDA::Parameters::ParameterSPtr originalMinParam = _parameterManager.getParameter(errorBarProp.getErrorMinMax()->getOriginalParamMin());
					AMDA::Parameters::ParameterSPtr minParam = createSampledParameterUnderReferenceParameter(originalMinParam, usedParam);
					std::stringstream minExpr;
ab9fea4a   Erdogan Furkan   #7268 - Done
3450
					minExpr << "$" << usedParam->getId() << "-$" + minParam->getId();
fbe3c2bb   Benjamin Renard   First commit
3451

ba6124b0   Menouard AZIB   Add parameter id ...
3452
3453
					// create parameter from expression
					AMDA::Parameters::ParameterSPtr usedMinParam = _parameterManager.getParameterFromExpression(minExpr.str(), originalParam->getGapThreshold(), true);
fbe3c2bb   Benjamin Renard   First commit
3454

ba6124b0   Menouard AZIB   Add parameter id ...
3455
3456
3457
3458
3459
					if (usedMinParam == nullptr)
					{
						LOG4CXX_ERROR(gLogger, "PanelPlotOutput::createParameters - Cannot create parameter from expression " << minExpr.str());
						continue;
					}
fbe3c2bb   Benjamin Renard   First commit
3460

ba6124b0   Menouard AZIB   Add parameter id ...
3461
3462
3463
					if (std::find(usedParametersId_.begin(), usedParametersId_.end(), usedMinParam->getId()) == usedParametersId_.end())
						usedParametersId_.push_back(usedMinParam->getId());
					errorBarProp.getErrorMinMax()->setUsedParamMin(usedMinParam->getId());
fbe3c2bb   Benjamin Renard   First commit
3464

ba6124b0   Menouard AZIB   Add parameter id ...
3465
3466
					// Build expression for computed parameter = usedParam + maxParam
					AMDA::Parameters::ParameterSPtr originalMaxParam = _parameterManager.getParameter(errorBarProp.getErrorMinMax()->getOriginalParamMax());
e9782682   Benjamin Renard   Fix bug with erro...
3467

ba6124b0   Menouard AZIB   Add parameter id ...
3468
3469
					AMDA::Parameters::ParameterSPtr maxParam = createSampledParameterUnderReferenceParameter(originalMaxParam, usedParam);
					std::stringstream maxExpr;
ab9fea4a   Erdogan Furkan   #7268 - Done
3470
					maxExpr << "$" << usedParam->getId() << "+$" + maxParam->getId();
fbe3c2bb   Benjamin Renard   First commit
3471

ba6124b0   Menouard AZIB   Add parameter id ...
3472
3473
					// create parameter from expression
					AMDA::Parameters::ParameterSPtr usedMaxParam = _parameterManager.getParameterFromExpression(maxExpr.str(), originalParam->getGapThreshold(), true);
fbe3c2bb   Benjamin Renard   First commit
3474

ba6124b0   Menouard AZIB   Add parameter id ...
3475
3476
3477
3478
3479
3480
3481
3482
3483
					if (usedMaxParam == nullptr)
					{
						LOG4CXX_ERROR(gLogger, "PanelPlotOutput::createParameters - Cannot create parameter from expression " << maxExpr.str());
						continue;
					}

					if (std::find(usedParametersId_.begin(), usedParametersId_.end(), usedMaxParam->getId()) == usedParametersId_.end())
						usedParametersId_.push_back(usedMaxParam->getId());
					errorBarProp.getErrorMinMax()->setUsedParamMax(usedMaxParam->getId());
fbe3c2bb   Benjamin Renard   First commit
3484
3485
				}

ba6124b0   Menouard AZIB   Add parameter id ...
3486
3487
3488
3489
3490
3491
3492
3493
3494
3495
3496
3497
3498
				if (originalColorParam != nullptr)
				{
					AMDA::Parameters::ParameterSPtr usedColorParam = createSampledParameterUnderReferenceParameter(originalColorParam, usedParam);
					// Add used color parameter to parameters list
					if (std::find(usedParametersId_.begin(), usedParametersId_.end(), usedColorParam->getId()) == usedParametersId_.end())
						usedParametersId_.push_back(usedColorParam->getId());
					// link this color parameter to the y serie
					ity->setColorParamId(usedColorParam->getId());
					// link the used parameter to the color serie
					colorSerieParameterAxes->getColorSeriePropertiesById(ity->getColorSerieId()).addParamId(usedParam->getId(), usedColorParam->getId());
					// activate the Z Axis
					ity->setZAxis(true);
				}
fbe3c2bb   Benjamin Renard   First commit
3499
3500
			}

ba6124b0   Menouard AZIB   Add parameter id ...
3501
3502
3503
			// For spectro if defined
			std::shared_ptr<SpectroProperties> pSpecProp = it->getSpectroProperties();
			if (pSpecProp != nullptr)
fbe3c2bb   Benjamin Renard   First commit
3504
			{
ba6124b0   Menouard AZIB   Add parameter id ...
3505
3506
3507
3508
3509
3510
3511
				AMDA::Info::ParamInfoSPtr paramInfo = AMDA::Info::ParamMgr::getInstance()->getParamInfoFromId(originalParam->getInfoId());
				boost::shared_ptr<AMDA::Info::ParamTable> tableSPtr;
				if (paramInfo != nullptr)
					tableSPtr = paramInfo->getTable(pSpecProp->getRelatedDim());
				// get corrected sampling value in relation with max resolution
				double correctedSamplingValue = getCorrectedSamplingValue(pSpecProp->getMaxResolution(), samplingValue);
				AMDA::Parameters::ParameterSPtr usedParam;
fbe3c2bb   Benjamin Renard   First commit
3512

ba6124b0   Menouard AZIB   Add parameter id ...
3513
				if (abs(samplingValue - correctedSamplingValue) > 1.)
f2db3c16   Benjamin Renard   Support variable ...
3514
				{
ba6124b0   Menouard AZIB   Add parameter id ...
3515
3516
3517
3518
					// more than one second between samplingValue and correctedSamplingValue
					//=> use resampling parameter
					usedParam = createSampledParameter(originalParam, correctedSamplingValue);
					if ((tableSPtr != nullptr) && tableSPtr->isVariable(&_parameterManager))
f2db3c16   Benjamin Renard   Support variable ...
3519
					{
ba6124b0   Menouard AZIB   Add parameter id ...
3520
3521
3522
3523
						for (std::map<std::string, std::string>::iterator it = tableSPtr->getTableParams(&_parameterManager).begin(); it != tableSPtr->getTableParams(&_parameterManager).end(); ++it)
						{
							std::string tableParamKey = it->first;
							std::string tableParamName = it->second;
f2db3c16   Benjamin Renard   Support variable ...
3524

ba6124b0   Menouard AZIB   Add parameter id ...
3525
3526
3527
3528
							AMDA::Parameters::ParameterSPtr originalTableParam = _parameterManager.getParameter(tableParamName);
							AMDA::Parameters::ParameterSPtr usedTableParam = createSampledParameter(originalTableParam, correctedSamplingValue);
							pSpecProp->addTableParam(tableParamKey, usedTableParam->getId());
						}
f2db3c16   Benjamin Renard   Support variable ...
3529
3530
					}
				}
ba6124b0   Menouard AZIB   Add parameter id ...
3531
				else
f2db3c16   Benjamin Renard   Support variable ...
3532
				{
ba6124b0   Menouard AZIB   Add parameter id ...
3533
3534
3535
					// use original parameter
					usedParam = originalParam;
					if ((tableSPtr != nullptr) && tableSPtr->isVariable(&_parameterManager))
f2db3c16   Benjamin Renard   Support variable ...
3536
					{
ba6124b0   Menouard AZIB   Add parameter id ...
3537
3538
3539
3540
						for (std::map<std::string, std::string>::iterator it = tableSPtr->getTableParams(&_parameterManager).begin(); it != tableSPtr->getTableParams(&_parameterManager).end(); ++it)
						{
							std::string tableParamKey = it->first;
							std::string tableParamName = it->second;
f2db3c16   Benjamin Renard   Support variable ...
3541

ba6124b0   Menouard AZIB   Add parameter id ...
3542
3543
3544
							AMDA::Parameters::ParameterSPtr originalTableParam = _parameterManager.getParameter(tableParamName);
							pSpecProp->addTableParam(tableParamKey, originalTableParam->getId());
						}
f2db3c16   Benjamin Renard   Support variable ...
3545
3546
					}
				}
f2db3c16   Benjamin Renard   Support variable ...
3547

ba6124b0   Menouard AZIB   Add parameter id ...
3548
3549
3550
3551
3552
3553
3554
3555
3556
3557
3558
3559
				// Add used parameter to parameters list
				if (std::find(usedParametersId_.begin(), usedParametersId_.end(), usedParam->getId()) == usedParametersId_.end())
					usedParametersId_.push_back(usedParam->getId());
				pSpecProp->setParamId(usedParam->getId());
				// Add table parameters to parameters list
				for (std::map<std::string, std::string>::iterator it = pSpecProp->getTableParams().begin(); it != pSpecProp->getTableParams().end(); ++it)
				{
					std::string tableParamId = it->second;

					if (std::find(usedParametersId_.begin(), usedParametersId_.end(), tableParamId) == usedParametersId_.end())
						usedParametersId_.push_back(tableParamId);
				}
f2db3c16   Benjamin Renard   Support variable ...
3560
			}
5f13f59c   Hacene SI HADJ MOHAND   in progress worki...
3561

ba6124b0   Menouard AZIB   Add parameter id ...
3562
3563
3564
			// For sauvaud if defined
			std::shared_ptr<SauvaudProperties> pSauvaudProp = it->getSauvaudProperties();
			if (pSauvaudProp != nullptr)
5f13f59c   Hacene SI HADJ MOHAND   in progress worki...
3565
			{
ba6124b0   Menouard AZIB   Add parameter id ...
3566
3567
3568
3569
3570
3571
3572
3573
3574
				AMDA::Info::ParamInfoSPtr paramInfo = AMDA::Info::ParamMgr::getInstance()->getParamInfoFromId(originalParam->getInfoId());
				boost::shared_ptr<AMDA::Info::ParamTable> tableSPtr;
				if (paramInfo != nullptr)
					tableSPtr = paramInfo->getTable(pSauvaudProp->getRelatedDim());
				// get corrected sampling value in relation with max resolution
				double correctedSamplingValue = getCorrectedSamplingValue(pSauvaudProp->getMaxResolution(), samplingValue);
				AMDA::Parameters::ParameterSPtr usedParam;

				if (abs(samplingValue - correctedSamplingValue) > 1.)
5f13f59c   Hacene SI HADJ MOHAND   in progress worki...
3575
				{
ba6124b0   Menouard AZIB   Add parameter id ...
3576
3577
3578
3579
					// more than one second between samplingValue and correctedSamplingValue
					//=> use resampling parameter
					usedParam = createSampledParameter(originalParam, correctedSamplingValue);
					if ((tableSPtr != nullptr) && tableSPtr->isVariable(&_parameterManager))
5f13f59c   Hacene SI HADJ MOHAND   in progress worki...
3580
					{
ba6124b0   Menouard AZIB   Add parameter id ...
3581
3582
3583
3584
						for (std::map<std::string, std::string>::iterator it = tableSPtr->getTableParams(&_parameterManager).begin(); it != tableSPtr->getTableParams(&_parameterManager).end(); ++it)
						{
							std::string tableParamKey = it->first;
							std::string tableParamName = it->second;
5f13f59c   Hacene SI HADJ MOHAND   in progress worki...
3585

ba6124b0   Menouard AZIB   Add parameter id ...
3586
3587
3588
3589
							AMDA::Parameters::ParameterSPtr originalTableParam = _parameterManager.getParameter(tableParamName);
							AMDA::Parameters::ParameterSPtr usedTableParam = createSampledParameter(originalTableParam, correctedSamplingValue);
							pSauvaudProp->addTableParam(tableParamKey, usedTableParam->getId());
						}
5f13f59c   Hacene SI HADJ MOHAND   in progress worki...
3590
3591
					}
				}
ba6124b0   Menouard AZIB   Add parameter id ...
3592
				else
5f13f59c   Hacene SI HADJ MOHAND   in progress worki...
3593
				{
ba6124b0   Menouard AZIB   Add parameter id ...
3594
3595
3596
					// use original parameter
					usedParam = originalParam;
					if ((tableSPtr != nullptr) && tableSPtr->isVariable(&_parameterManager))
5f13f59c   Hacene SI HADJ MOHAND   in progress worki...
3597
					{
ba6124b0   Menouard AZIB   Add parameter id ...
3598
3599
3600
3601
						for (std::map<std::string, std::string>::iterator it = tableSPtr->getTableParams(&_parameterManager).begin(); it != tableSPtr->getTableParams(&_parameterManager).end(); ++it)
						{
							std::string tableParamKey = it->first;
							std::string tableParamName = it->second;
5f13f59c   Hacene SI HADJ MOHAND   in progress worki...
3602

ba6124b0   Menouard AZIB   Add parameter id ...
3603
3604
3605
							AMDA::Parameters::ParameterSPtr originalTableParam = _parameterManager.getParameter(tableParamName);
							pSauvaudProp->addTableParam(tableParamKey, originalTableParam->getId());
						}
5f13f59c   Hacene SI HADJ MOHAND   in progress worki...
3606
3607
					}
				}
ba6124b0   Menouard AZIB   Add parameter id ...
3608
3609
3610
3611
3612
3613
3614
3615
3616
3617
3618
3619
3620

				// Add used parameter to parameters list
				if (std::find(usedParametersId_.begin(), usedParametersId_.end(), usedParam->getId()) == usedParametersId_.end())
					usedParametersId_.push_back(usedParam->getId());
				pSauvaudProp->setParamId(usedParam->getId());
				// Add table parameters to parameters list
				for (std::map<std::string, std::string>::iterator it = pSauvaudProp->getTableParams().begin(); it != pSauvaudProp->getTableParams().end(); ++it)
				{
					std::string tableParamId = it->second;

					if (std::find(usedParametersId_.begin(), usedParametersId_.end(), tableParamId) == usedParametersId_.end())
						usedParametersId_.push_back(tableParamId);
				}
5f13f59c   Hacene SI HADJ MOHAND   in progress worki...
3621
			}
ba6124b0   Menouard AZIB   Add parameter id ...
3622
3623
3624
3625

			// For intervals if defined
			std::shared_ptr<IntervalsProperties> pIntProp = it->getIntervalsProperties();
			if (pIntProp != nullptr)
5f13f59c   Hacene SI HADJ MOHAND   in progress worki...
3626
			{
ba6124b0   Menouard AZIB   Add parameter id ...
3627
3628
3629
3630
3631
3632
3633
3634
3635
3636
3637
3638
3639
3640
3641
				// get corrected sampling value in relation with max resolution
				double correctedSamplingValue = getCorrectedSamplingValue(pIntProp->getMaxResolution(), samplingValue);
				AMDA::Parameters::ParameterSPtr usedParam;

				if (abs(samplingValue - correctedSamplingValue) > 1.)
				{
					// more than one second between samplingValue and correctedSamplingValue
					//=> use resampling parameter
					usedParam = createSampledParameter(originalParam, correctedSamplingValue);
				}
				else
				{
					// use original parameter
					usedParam = originalParam;
				}
5f13f59c   Hacene SI HADJ MOHAND   in progress worki...
3642

ba6124b0   Menouard AZIB   Add parameter id ...
3643
3644
3645
3646
				// Add used parameter to parameters list
				if (std::find(usedParametersId_.begin(), usedParametersId_.end(), usedParam->getId()) == usedParametersId_.end())
					usedParametersId_.push_back(usedParam->getId());
				pIntProp->setParamId(usedParam->getId());
5f13f59c   Hacene SI HADJ MOHAND   in progress worki...
3647
			}
5f13f59c   Hacene SI HADJ MOHAND   in progress worki...
3648
		}
ba6124b0   Menouard AZIB   Add parameter id ...
3649
	}
e257cfb9   Benjamin Renard   First implementat...
3650

ba6124b0   Menouard AZIB   Add parameter id ...
3651
3652
3653
3654
3655
3656
3657
3658
3659
3660
3661
3662
	/**
	 * Gets sampling value from resolution (point-per-plot) according to
	 * the plot time interval and the base parameter sampling value.
	 */
	double PanelPlotOutput::getCorrectedSamplingValue(int maxResolution, double samplingValue)
	{
		double timeInt = 0.;
		if (_panel->_page->_superposeMode)
		{
			// merge all intervals size
			TimeIntervalList::iterator crtTimeInterval = _parameterManager.getInputIntervals()->begin();
			while (crtTimeInterval != _parameterManager.getInputIntervals()->end())
e257cfb9   Benjamin Renard   First implementat...
3663
			{
ba6124b0   Menouard AZIB   Add parameter id ...
3664
3665
				timeInt += (crtTimeInterval->_stopTime - crtTimeInterval->_startTime);
				++crtTimeInterval;
e257cfb9   Benjamin Renard   First implementat...
3666
			}
ba6124b0   Menouard AZIB   Add parameter id ...
3667
3668
3669
3670
3671
3672
		}
		else
		{
			// find the biggest intervals size
			TimeIntervalList::iterator crtTimeInterval = _parameterManager.getInputIntervals()->begin();
			while (crtTimeInterval != _parameterManager.getInputIntervals()->end())
e257cfb9   Benjamin Renard   First implementat...
3673
			{
ba6124b0   Menouard AZIB   Add parameter id ...
3674
3675
3676
				if ((crtTimeInterval->_stopTime - crtTimeInterval->_startTime) > timeInt)
					timeInt = crtTimeInterval->_stopTime - crtTimeInterval->_startTime;
				++crtTimeInterval;
e257cfb9   Benjamin Renard   First implementat...
3677
			}
e257cfb9   Benjamin Renard   First implementat...
3678
		}
fbe3c2bb   Benjamin Renard   First commit
3679

ba6124b0   Menouard AZIB   Add parameter id ...
3680
		if ((timeInt == 0) || (maxResolution == -1) || (timeInt / samplingValue < maxResolution))
fbe3c2bb   Benjamin Renard   First commit
3681
		{
ba6124b0   Menouard AZIB   Add parameter id ...
3682
			return samplingValue;
fbe3c2bb   Benjamin Renard   First commit
3683
		}
ba6124b0   Menouard AZIB   Add parameter id ...
3684
3685
3686
3687
3688
		// get the exact sampling
		double correctedSampling = timeInt / maxResolution;
		// rounded it to the next int sampling
		double roundedSampling = (int)correctedSampling;
		if (roundedSampling < correctedSampling)
fbe3c2bb   Benjamin Renard   First commit
3689
		{
ba6124b0   Menouard AZIB   Add parameter id ...
3690
			roundedSampling += 1;
fbe3c2bb   Benjamin Renard   First commit
3691
		}
ba6124b0   Menouard AZIB   Add parameter id ...
3692
		return roundedSampling;
fbe3c2bb   Benjamin Renard   First commit
3693
3694
	}

ba6124b0   Menouard AZIB   Add parameter id ...
3695
3696
3697
3698
3699
	/**
	 * @brief Get the list of indexes used for a parameter
	 */
	std::vector<AMDA::Common::ParameterIndexComponent> PanelPlotOutput::getParamUsedIndexes(std::string paramId,
																							int dim1Size, int dim2Size)
fbe3c2bb   Benjamin Renard   First commit
3700
	{
ba6124b0   Menouard AZIB   Add parameter id ...
3701
3702
3703
		std::vector<AMDA::Common::ParameterIndexComponent> indexes;
		for (ParameterAxesList::iterator paramAxeIt = _parameterAxesList.begin();
			 paramAxeIt != _parameterAxesList.end(); ++paramAxeIt)
fbe3c2bb   Benjamin Renard   First commit
3704
		{
ba6124b0   Menouard AZIB   Add parameter id ...
3705
3706
3707
			// get indexes for spectro
			std::shared_ptr<SpectroProperties> pSpecProp = paramAxeIt->getSpectroProperties();
			if (pSpecProp != nullptr)
fbe3c2bb   Benjamin Renard   First commit
3708
			{
ba6124b0   Menouard AZIB   Add parameter id ...
3709
				if (pSpecProp->getParamId() == paramId)
fbe3c2bb   Benjamin Renard   First commit
3710
				{
ba6124b0   Menouard AZIB   Add parameter id ...
3711
3712
3713
3714
3715
3716
3717
3718
					if (pSpecProp->getIndexes().empty())
					{
						// get used indexes by the spectro thanks to the index definition in the request
						AMDA::Common::ParameterIndexComponentList indexList;
						AMDA::Common::ParameterIndexesTool::parse(pSpecProp->getIndexDef(),
																  dim1Size, dim2Size, indexList);
						pSpecProp->setIndexes(indexList);
					}
fbe3c2bb   Benjamin Renard   First commit
3719

ba6124b0   Menouard AZIB   Add parameter id ...
3720
3721
3722
3723
3724
3725
					for (auto index : pSpecProp->getIndexes())
					{
						if (std::find(indexes.begin(), indexes.end(), index) != indexes.end())
							continue;
						indexes.push_back(index);
					}
5f13f59c   Hacene SI HADJ MOHAND   in progress worki...
3726
3727
				}
			}
ba6124b0   Menouard AZIB   Add parameter id ...
3728

34c311b3   Erdogan Furkan   Smooting works
3729
3730
3731
3732
3733
3734
3735
3736
3737
3738
			// get indexes for histogram2D
			std::shared_ptr<Histogram2DSeriesProperties> pHistogram2DProp = paramAxeIt->getHistogram2DSeriesProperties();
			if (pHistogram2DProp != nullptr)
			{
				if (pHistogram2DProp->getParamId() == paramId)
				{
					if (std::find(indexes.begin(), indexes.end(), pHistogram2DProp->getIndex()) != indexes.end())
						continue;
					indexes.push_back(pHistogram2DProp->getIndex());
				}
4a5cc373   Erdogan Furkan   Added Mean and Ma...
3739
3740
3741
3742
3743
3744
				if (pHistogram2DProp->getHistotypeProperties().getParamId() == paramId)
				{
					if (std::find(indexes.begin(), indexes.end(), pHistogram2DProp->getHistotypeProperties().getIndex()) != indexes.end())
						continue;
					indexes.push_back(pHistogram2DProp->getHistotypeProperties().getIndex());
				}
34c311b3   Erdogan Furkan   Smooting works
3745
			}
ba6124b0   Menouard AZIB   Add parameter id ...
3746
3747
3748
			// get indexes for spectro
			std::shared_ptr<SauvaudProperties> pSauvaudProp = paramAxeIt->getSauvaudProperties();
			if (pSauvaudProp != nullptr)
5f13f59c   Hacene SI HADJ MOHAND   in progress worki...
3749
			{
ba6124b0   Menouard AZIB   Add parameter id ...
3750
				if (pSauvaudProp->getParamId() == paramId)
5f13f59c   Hacene SI HADJ MOHAND   in progress worki...
3751
				{
ba6124b0   Menouard AZIB   Add parameter id ...
3752
3753
3754
3755
3756
3757
3758
3759
					if (pSauvaudProp->getIndexes().empty())
					{
						// get used indexes by the spectro thanks to the index definition in the request
						AMDA::Common::ParameterIndexComponentList indexList;
						AMDA::Common::ParameterIndexesTool::parse(pSauvaudProp->getIndexDef(),
																  dim1Size, dim2Size, indexList);
						pSauvaudProp->setIndexes(indexList);
					}
5f13f59c   Hacene SI HADJ MOHAND   in progress worki...
3760

ba6124b0   Menouard AZIB   Add parameter id ...
3761
3762
3763
3764
3765
3766
					for (auto index : pSauvaudProp->getIndexes())
					{
						if (std::find(indexes.begin(), indexes.end(), index) != indexes.end())
							continue;
						indexes.push_back(index);
					}
fbe3c2bb   Benjamin Renard   First commit
3767
3768
				}
			}
fbe3c2bb   Benjamin Renard   First commit
3769

ba6124b0   Menouard AZIB   Add parameter id ...
3770
3771
3772
			// get indexes for intervals
			std::shared_ptr<IntervalsProperties> pIntProp = paramAxeIt->getIntervalsProperties();
			if (pIntProp != nullptr)
e257cfb9   Benjamin Renard   First implementat...
3773
			{
ba6124b0   Menouard AZIB   Add parameter id ...
3774
				if (pIntProp->getParamId() == paramId)
e257cfb9   Benjamin Renard   First implementat...
3775
				{
ba6124b0   Menouard AZIB   Add parameter id ...
3776
3777
3778
3779
3780
3781
3782
3783
3784
3785
3786
3787
3788
3789
3790
					if (pIntProp->getIndexes().empty())
					{
						// get used indexes by the intervals thanks to the index definition in the request
						AMDA::Common::ParameterIndexComponentList indexList;
						AMDA::Common::ParameterIndexesTool::parse(pIntProp->getIndexDef(),
																  dim1Size, dim2Size, indexList);
						pIntProp->setIndexes(indexList);
					}

					for (auto index : pIntProp->getIndexes())
					{
						if (std::find(indexes.begin(), indexes.end(), index) != indexes.end())
							continue;
						indexes.push_back(index);
					}
e257cfb9   Benjamin Renard   First implementat...
3791
3792
				}
			}
e257cfb9   Benjamin Renard   First implementat...
3793

ba6124b0   Menouard AZIB   Add parameter id ...
3794
3795
			// get indexes for series of this ParameterAxe
			std::vector<AMDA::Common::ParameterIndexComponent> seriesIndexes = paramAxeIt->getParamUsedIndexes(paramId);
fbe3c2bb   Benjamin Renard   First commit
3796

ba6124b0   Menouard AZIB   Add parameter id ...
3797
			for (AMDA::Common::ParameterIndexComponent index : seriesIndexes)
fbe3c2bb   Benjamin Renard   First commit
3798
			{
ba6124b0   Menouard AZIB   Add parameter id ...
3799
3800
3801
3802
3803
3804
3805
3806
3807
3808
				if ((index.getDim1Index() == -1) && (index.getDim2Index() == -1))
				{
					//-1 => all indexes
					indexes.clear();
					indexes.push_back(AMDA::Common::ParameterIndexComponent(-1, -1));
					return indexes;
				}
				if (std::find(indexes.begin(), indexes.end(), index) != indexes.end())
					continue;
				indexes.push_back(index);
fbe3c2bb   Benjamin Renard   First commit
3809
			}
fbe3c2bb   Benjamin Renard   First commit
3810
		}
fbe3c2bb   Benjamin Renard   First commit
3811

ba6124b0   Menouard AZIB   Add parameter id ...
3812
3813
		if (indexes.empty())
			indexes.push_back(AMDA::Common::ParameterIndexComponent(-1, -1));
fbe3c2bb   Benjamin Renard   First commit
3814

ba6124b0   Menouard AZIB   Add parameter id ...
3815
3816
		return indexes;
	}
fbe3c2bb   Benjamin Renard   First commit
3817

ba6124b0   Menouard AZIB   Add parameter id ...
3818
3819
3820
3821
3822
3823
3824
	/*
	 * @brief Set pointer to params values
	 */
	void PanelPlotOutput::setParameterValues(std::map<std::string, ParameterData> *pParameterValues)
	{
		_pParameterValues = pParameterValues;
	}
fbe3c2bb   Benjamin Renard   First commit
3825

ba6124b0   Menouard AZIB   Add parameter id ...
3826
3827
3828
3829
	/*
	 * @brief Set a pointer to the time intervals list
	 */
	void PanelPlotOutput::setTimeIntervalListPtr(AMDA::Parameters::TimeIntervalList *timeIntervalListPtr)
fbe3c2bb   Benjamin Renard   First commit
3830
	{
ba6124b0   Menouard AZIB   Add parameter id ...
3831
		_timeIntervalListPtr = timeIntervalListPtr;
fbe3c2bb   Benjamin Renard   First commit
3832
3833
	}

ba6124b0   Menouard AZIB   Add parameter id ...
3834
3835
3836
3837
3838
3839
3840
3841
3842
3843
3844
	/*
	 * @brief Get computed values (in relation with the y axis definition) for a y serie and a time interval
	 * Do not forget to delete computedValues !!
	 * Don't delete timeValues !!
	 */
	bool PanelPlotOutput::getComputedValuesFromSerieAndInterval(double startDate, double stopDate, SeriesProperties &rSeriesProperties,
																AMDA::Common::ParameterIndexComponent index, double **computedValues, double **timeValues, int &nbValues)
	{
		LOG4CXX_DEBUG(gLogger, "PanelPlotOutput::getComputedValuesFromSerieAndInterval");
		// get parameter data for this serie
		ParameterData &data = (*_pParameterValues)[rSeriesProperties.getParamId()];
8c71f50a   Benjamin Renard   Improve execution...
3845

ba6124b0   Menouard AZIB   Add parameter id ...
3846
3847
3848
		// get original data for interval [startDate, stopDate]
		int startIndex;
		data.getIntervalBounds(startDate, stopDate, startIndex, nbValues);
fbe3c2bb   Benjamin Renard   First commit
3849

ba6124b0   Menouard AZIB   Add parameter id ...
3850
3851
3852
3853
3854
		if (nbValues == 0)
		{
			LOG4CXX_DEBUG(gLogger, "PanelPlotOutput::getComputedValuesFromSerieAndInterval - Cannot find data for serie with id " << rSeriesProperties.getId());
			return false;
		}
fbe3c2bb   Benjamin Renard   First commit
3855

ba6124b0   Menouard AZIB   Add parameter id ...
3856
		double *valuesInterval = data.getValues(index, startIndex);
fbe3c2bb   Benjamin Renard   First commit
3857

ba6124b0   Menouard AZIB   Add parameter id ...
3858
3859
		// get computed data for interval [startDate, stopDate] in relation with the serie y axis
		(*computedValues) = _panel->getAxis(rSeriesProperties.getYAxisId())->getComputedValues(valuesInterval, nbValues, rSeriesProperties.getMin(), rSeriesProperties.getMax());
fbe3c2bb   Benjamin Renard   First commit
3860

ba6124b0   Menouard AZIB   Add parameter id ...
3861
3862
		// get time values
		(*timeValues) = &data.getTimes()[startIndex];
fbe3c2bb   Benjamin Renard   First commit
3863

ba6124b0   Menouard AZIB   Add parameter id ...
3864
		return true;
fbe3c2bb   Benjamin Renard   First commit
3865
3866
	}

ba6124b0   Menouard AZIB   Add parameter id ...
3867
3868
3869
3870
3871
3872
3873
	/*
	 * @brief Get computed values (in relation with the color axis definition) for a color serie and a time interval
	 * Do not forget to delete computedValues !!
	 * Don't delete timeValues !!
	 */
	bool PanelPlotOutput::getColoredComputedValuesFromSerieAndInterval(double startDate, double stopDate, SeriesProperties &rSeriesProperties,
																	   double **computedValues, double **timeValues, int &nbValues)
fbe3c2bb   Benjamin Renard   First commit
3874
	{
ba6124b0   Menouard AZIB   Add parameter id ...
3875
3876
3877
		LOG4CXX_DEBUG(gLogger, "PanelPlotOutput::getColoredComputedValuesFromSerieAndInterval");
		// get parameter data for this color serie
		ParameterData &data = (*_pParameterValues)[rSeriesProperties.getColorParamId()];
fbe3c2bb   Benjamin Renard   First commit
3878

ba6124b0   Menouard AZIB   Add parameter id ...
3879
		ParameterAxes *colorSerieParameterAxes = getParameterAxesByColorSerieId(rSeriesProperties.getColorSerieId());
8c71f50a   Benjamin Renard   Improve execution...
3880

ba6124b0   Menouard AZIB   Add parameter id ...
3881
3882
3883
3884
3885
		if (colorSerieParameterAxes == NULL)
		{
			LOG4CXX_DEBUG(gLogger, "PanelPlotOutput::getColoredComputedValuesFromSerieAndInterval - Cannot retrieve parameter axe");
			return false;
		}
fbe3c2bb   Benjamin Renard   First commit
3886

ba6124b0   Menouard AZIB   Add parameter id ...
3887
		ColorSeriesProperties &colorSerieProp = colorSerieParameterAxes->getColorSeriePropertiesById(rSeriesProperties.getColorSerieId());
fbe3c2bb   Benjamin Renard   First commit
3888

ba6124b0   Menouard AZIB   Add parameter id ...
3889
3890
3891
		// get original data for interval [startDate, stopDate]
		int startIndex;
		data.getIntervalBounds(startDate, stopDate, startIndex, nbValues);
fbe3c2bb   Benjamin Renard   First commit
3892

ba6124b0   Menouard AZIB   Add parameter id ...
3893
3894
3895
3896
3897
		if (nbValues == 0)
		{
			LOG4CXX_DEBUG(gLogger, "PanelPlotOutput::getColoredComputedValuesFromSerieAndInterval - Cannot find data for color serie with id " << colorSerieProp.getId());
			return false;
		}
fbe3c2bb   Benjamin Renard   First commit
3898

ba6124b0   Menouard AZIB   Add parameter id ...
3899
		double *valuesInterval = data.getValues(colorSerieProp.getIndex(), startIndex);
fbe3c2bb   Benjamin Renard   First commit
3900

ba6124b0   Menouard AZIB   Add parameter id ...
3901
3902
3903
3904
3905
3906
		// get computed data for interval [startDate, stopDate] in relation with the color axis
		(*computedValues) = _panel->getColorAxis()->getComputedValues(
			valuesInterval,
			nbValues,
			colorSerieProp.getMin(),
			colorSerieProp.getMax());
fbe3c2bb   Benjamin Renard   First commit
3907

ba6124b0   Menouard AZIB   Add parameter id ...
3908
3909
		// get time values
		(*timeValues) = &data.getTimes()[startIndex];
fbe3c2bb   Benjamin Renard   First commit
3910

ba6124b0   Menouard AZIB   Add parameter id ...
3911
		return true;
fbe3c2bb   Benjamin Renard   First commit
3912
3913
	}

ba6124b0   Menouard AZIB   Add parameter id ...
3914
3915
3916
3917
3918
3919
	/*
	 * @brief Get computed values (in relation with the y axis definition) for a y serie and a time interval
	 * Do not forget to delete computedValues !!
	 * Don't delete timeValues !!
	 */
	bool PanelPlotOutput::getErrorComputedValuesFromSerieAndInterval(double startDate, double stopDate, SeriesProperties &rSeriesProperties,
ab9fea4a   Erdogan Furkan   #7268 - Done
3920
																	 AMDA::Common::ParameterIndexComponent &pParamIndex,
ba6124b0   Menouard AZIB   Add parameter id ...
3921
3922
3923
3924
3925
3926
3927
3928
3929
3930
3931
																	 double **minComputedValues, double **minTimeValues, int &nbMinValues,
																	 double **maxComputedValues, double **maxTimeValues, int &nbMaxValues)
	{
		LOG4CXX_DEBUG(gLogger, "PanelPlotOutput::getErrorComputedValuesFromSrieAndInterval");

		ErrorBarProperties &errorBarProp = rSeriesProperties.getErrorBarProperties();
		if (errorBarProp.getErrorMinMax() == nullptr)
			return false;

		// get parameter dataMin for this color bar
		ParameterData &dataMin = (*_pParameterValues)[errorBarProp.getErrorMinMax()->getUsedParamMin()];
8c71f50a   Benjamin Renard   Improve execution...
3932

ab9fea4a   Erdogan Furkan   #7268 - Done
3933
3934
3935
3936
		if(((pParamIndex.getDim1Index() != -1) && (pParamIndex.getDim1Index() >= dataMin.getDim1Size())) || ((pParamIndex.getDim2Index() != -1) && (pParamIndex.getDim2Index() >= dataMin.getDim2Size()))){
			LOG4CXX_ERROR(gLogger, "PanelPlotOutput::getErrorComputedValuesFromSerieAndInterval - Errorbar index outside of parameter index");
			return false;
		}
ba6124b0   Menouard AZIB   Add parameter id ...
3937
3938
3939
		// get original min data for interval [startDate, stopDate]
		int minStartIndex;
		dataMin.getIntervalBounds(startDate, stopDate, minStartIndex, nbMinValues);
fbe3c2bb   Benjamin Renard   First commit
3940

ba6124b0   Menouard AZIB   Add parameter id ...
3941
3942
		if (nbMinValues == 0)
		{
ab9fea4a   Erdogan Furkan   #7268 - Done
3943
			LOG4CXX_ERROR(gLogger, "PanelPlotOutput::getErrorComputedValuesFromSerieAndInterval - Cannot get min data for error bar");
ba6124b0   Menouard AZIB   Add parameter id ...
3944
3945
			return false;
		}
fbe3c2bb   Benjamin Renard   First commit
3946

ab9fea4a   Erdogan Furkan   #7268 - Done
3947
		double *minValuesInterval = dataMin.getValues(pParamIndex, minStartIndex);
ba6124b0   Menouard AZIB   Add parameter id ...
3948
3949
		// get computed min data for interval [startDate, stopDate] in relation with the serie y axis
		(*minComputedValues) = _panel->getAxis(rSeriesProperties.getYAxisId())->getComputedValues(minValuesInterval, nbMinValues, rSeriesProperties.getMin(), rSeriesProperties.getMax());
fbe3c2bb   Benjamin Renard   First commit
3950

ba6124b0   Menouard AZIB   Add parameter id ...
3951
3952
3953
3954
3955
		// get time values
		(*minTimeValues) = &dataMin.getTimes()[minStartIndex];

		// get parameter dataMax for this color bar
		ParameterData &dataMax = (*_pParameterValues)[errorBarProp.getErrorMinMax()->getUsedParamMax()];
fbe3c2bb   Benjamin Renard   First commit
3956

ba6124b0   Menouard AZIB   Add parameter id ...
3957
3958
3959
3960
3961
3962
		// get original max data for interval [startDate, stopDate]
		int maxStartIndex;
		dataMax.getIntervalBounds(startDate, stopDate, maxStartIndex, nbMaxValues);

		if (nbMaxValues == 0)
		{
ab9fea4a   Erdogan Furkan   #7268 - Done
3963
			LOG4CXX_ERROR(gLogger, "PanelPlotOutput::getErrorComputedValuesFromSerieAndInterval - Cannot get max data for error bar");
ba6124b0   Menouard AZIB   Add parameter id ...
3964
3965
3966
			delete[](*minComputedValues);
			return false;
		}
8c71f50a   Benjamin Renard   Improve execution...
3967

ab9fea4a   Erdogan Furkan   #7268 - Done
3968
		double *maxValuesInterval = dataMax.getValues(pParamIndex, maxStartIndex);
fbe3c2bb   Benjamin Renard   First commit
3969

ba6124b0   Menouard AZIB   Add parameter id ...
3970
3971
		// get computed max data for interval [startDate, stopDate] in relation with the serie y axis
		(*maxComputedValues) = _panel->getAxis(rSeriesProperties.getYAxisId())->getComputedValues(maxValuesInterval, nbMaxValues, rSeriesProperties.getMin(), rSeriesProperties.getMax());
fbe3c2bb   Benjamin Renard   First commit
3972

ba6124b0   Menouard AZIB   Add parameter id ...
3973
3974
		// get time values
		(*maxTimeValues) = &dataMax.getTimes()[maxStartIndex];
fbe3c2bb   Benjamin Renard   First commit
3975

ba6124b0   Menouard AZIB   Add parameter id ...
3976
3977
		return true;
	}
fbe3c2bb   Benjamin Renard   First commit
3978

ba6124b0   Menouard AZIB   Add parameter id ...
3979
3980
3981
3982
	/*
	 * @brief Return the color to draw the line of a serie
	 */
	Color PanelPlotOutput::getSerieLineColor(SeriesProperties &rSeriesProperties, bool moreThanOneSerieForAxis)
fbe3c2bb   Benjamin Renard   First commit
3983
	{
ba6124b0   Menouard AZIB   Add parameter id ...
3984
		Color lLineColor = rSeriesProperties.getLineProperties().getColor();
fbe3c2bb   Benjamin Renard   First commit
3985

ba6124b0   Menouard AZIB   Add parameter id ...
3986
		if ((lLineColor._colorIndex == -1) &&
fbe3c2bb   Benjamin Renard   First commit
3987
3988
3989
3990
			(lLineColor._red == -1) &&
			(lLineColor._green == -1) &&
			(lLineColor._blue == -1))
		{
ba6124b0   Menouard AZIB   Add parameter id ...
3991
3992
3993
3994
3995
3996
3997
			// if line color not defined, try to use the serie color
			lLineColor = rSeriesProperties.getColor();

			if ((lLineColor._colorIndex == -1) &&
				(lLineColor._red == -1) &&
				(lLineColor._green == -1) &&
				(lLineColor._blue == -1))
fbe3c2bb   Benjamin Renard   First commit
3998
			{
ba6124b0   Menouard AZIB   Add parameter id ...
3999
4000
4001
4002
4003
4004
4005
4006
4007
4008
				// if color not defined
				if (!_panel->_page->_superposeMode && !moreThanOneSerieForAxis)
				{
					lLineColor = _panel->getAxis(rSeriesProperties.getYAxisId())->_color;
				}
				else
				{
					// get a default color
					getDefaultColor(_panel->_page->_mode, _automaticSerieColorCursor, lLineColor);
				}
fbe3c2bb   Benjamin Renard   First commit
4009
4010
			}
		}
fbe3c2bb   Benjamin Renard   First commit
4011

ba6124b0   Menouard AZIB   Add parameter id ...
4012
4013
		return lLineColor;
	}
fbe3c2bb   Benjamin Renard   First commit
4014

ba6124b0   Menouard AZIB   Add parameter id ...
4015
4016
4017
4018
	/*
	 * @brief Return the color to draw the symbols of a serie
	 */
	Color PanelPlotOutput::getSerieSymbolColor(SeriesProperties &rSeriesProperties, Color &pLineColor)
fbe3c2bb   Benjamin Renard   First commit
4019
	{
ba6124b0   Menouard AZIB   Add parameter id ...
4020
		Color lSymbolColor = rSeriesProperties.getSymbolProperties().getColor();
fbe3c2bb   Benjamin Renard   First commit
4021

ba6124b0   Menouard AZIB   Add parameter id ...
4022
4023
4024
4025
4026
4027
4028
4029
		if ((lSymbolColor._colorIndex == -1) &&
			(lSymbolColor._red == -1) &&
			(lSymbolColor._green == -1) &&
			(lSymbolColor._blue == -1))
		{
			// if not defined, use the line color
			lSymbolColor = pLineColor;
		}
fbe3c2bb   Benjamin Renard   First commit
4030

ba6124b0   Menouard AZIB   Add parameter id ...
4031
4032
		return lSymbolColor;
	}
fbe3c2bb   Benjamin Renard   First commit
4033

ba6124b0   Menouard AZIB   Add parameter id ...
4034
4035
4036
4037
	/**
	 * @brief Configure params legend.
	 */
	void PanelPlotOutput::configureParamsLegend(double startTime, double stopTime, int intervalIndex)
fbe3c2bb   Benjamin Renard   First commit
4038
	{
ba6124b0   Menouard AZIB   Add parameter id ...
4039
4040
4041
4042
4043
4044
4045
4046
4047
4048
		_panel->_paramsLegendProperties.resetPlot();

		for (auto parameter : _parameterAxesList)
		{
			for (auto lSeries : parameter.getYSeriePropertiesList())
			{
				for (auto lIndex : lSeries.getIndexList(_pParameterValues))
				{
					// for the legend configuration, we don't need to know the line and symbol colors
					Color fakeColor(0, 0, 0);
fbe3c2bb   Benjamin Renard   First commit
4049

ba6124b0   Menouard AZIB   Add parameter id ...
4050
4051
4052
					addSerieToParamsLegend(lSeries, lIndex, parameter._originalParamId,
										   fakeColor, fakeColor, startTime, stopTime, intervalIndex);
				}
2fc1f2f8   Benjamin Renard   Full rework for s...
4053
			}
fbe3c2bb   Benjamin Renard   First commit
4054
4055
		}
	}
fbe3c2bb   Benjamin Renard   First commit
4056

ba6124b0   Menouard AZIB   Add parameter id ...
4057
4058
4059
4060
4061
4062
4063
4064
4065
4066
	/**
	 * @brief Add a serie to the param legend
	 */
	void PanelPlotOutput::addSerieToParamsLegend(SeriesProperties &lSeriesProperties,
												 AMDA::Common::ParameterIndexComponent &index, std::string originalParamId,
												 Color &lineColor, Color &symbolColor,
												 double startTime, double stopTime, int intervalIndex)
	{
		if (!_panel->_paramsLegendProperties.isVisible())
			return;
fbe3c2bb   Benjamin Renard   First commit
4067

ba6124b0   Menouard AZIB   Add parameter id ...
4068
		LOG4CXX_DEBUG(gLogger, "PanelPlotOutput::addSerieToParamsLegend");
fbe3c2bb   Benjamin Renard   First commit
4069

ba6124b0   Menouard AZIB   Add parameter id ...
4070
4071
4072
4073
4074
4075
		std::stringstream fullLegendText;
		if (_panel->_paramsLegendProperties.isParamInfoVisible())
		{
			// add params info
			fullLegendText << getSerieParamsLegendString(lSeriesProperties, index, originalParamId);
		}
fbe3c2bb   Benjamin Renard   First commit
4076

ba6124b0   Menouard AZIB   Add parameter id ...
4077
		if (_panel->_paramsLegendProperties.isIntervalInfoVisible())
fbe3c2bb   Benjamin Renard   First commit
4078
		{
ba6124b0   Menouard AZIB   Add parameter id ...
4079
4080
4081
4082
4083
4084
4085
4086
4087
4088
4089
4090
4091
4092
4093
4094
			// add interval info
			if (!fullLegendText.str().empty())
				fullLegendText << "; ";
			switch (_panel->_paramsLegendProperties.getIntervalInfoType())
			{
			case ParamsLegendProperties::IntervalInfoType::INDEX:
				fullLegendText << "I";
				fullLegendText << intervalIndex;
				break;
			case ParamsLegendProperties::IntervalInfoType::STARTSTOP:
				fullLegendText << "[";
				fullLegendText << AMDA::TimeUtil::formatTimeDateInIso(startTime);
				fullLegendText << ", ";
				fullLegendText << AMDA::TimeUtil::formatTimeDateInIso(stopTime);
				fullLegendText << "]";
			}
fbe3c2bb   Benjamin Renard   First commit
4095
		}
fbe3c2bb   Benjamin Renard   First commit
4096

ba6124b0   Menouard AZIB   Add parameter id ...
4097
4098
4099
4100
		// push this legend to the params legend properties
		_panel->_paramsLegendProperties.addSerie(lSeriesProperties,
												 fullLegendText.str().c_str(), lineColor, symbolColor);
	}
fbe3c2bb   Benjamin Renard   First commit
4101

ba6124b0   Menouard AZIB   Add parameter id ...
4102
4103
4104
4105
4106
4107
4108
4109
	/*
	 * @brief Return the associated params legend to a serie
	 */
	std::string PanelPlotOutput::getSerieParamsLegendString(SeriesProperties &rSeriesProperties,
															AMDA::Common::ParameterIndexComponent &index, std::string originalParamId)
	{
		// Retrieve ParamInfo Manager
		ParamMgr *piMgr = ParamMgr::getInstance();
fbe3c2bb   Benjamin Renard   First commit
4110

ba6124b0   Menouard AZIB   Add parameter id ...
4111
4112
4113
		// Try to retrieve informations from paramInfo
		ParameterSPtr p = _parameterManager.getParameter(rSeriesProperties.getParamId());
		ParamInfoSPtr paramInfo = piMgr->getParamInfoFromId(p->getInfoId());
fbe3c2bb   Benjamin Renard   First commit
4114

ba6124b0   Menouard AZIB   Add parameter id ...
4115
4116
		// Build parameter text legend depending on the availability of paramInfo
		std::stringstream paramLegendText;
fbe3c2bb   Benjamin Renard   First commit
4117

ba6124b0   Menouard AZIB   Add parameter id ...
4118
		if (paramInfo)
fbe3c2bb   Benjamin Renard   First commit
4119
		{
ba6124b0   Menouard AZIB   Add parameter id ...
4120
4121
4122
4123
4124
4125
4126
4127
4128
4129
4130
4131
4132
4133
4134
4135
4136
4137
4138
			if ((index.getDim1Index() == -1) && (index.getDim2Index() == -1))
			{
				// parameter legend text = short_name
				paramLegendText << paramInfo->getShortName();
			}
			else
			{
				if (paramInfo->getComponents(index).empty() == false)
					// parameter legend text = components at index lIndex]
					paramLegendText << paramInfo->getComponents(index);
				else
				{
					// parameter legend text = short_name [lIndex]
					paramLegendText << paramInfo->getShortName() << "[" << index.getDim1Index();
					if (index.getDim2Index() != -1)
						paramLegendText << "," << index.getDim2Index();
					paramLegendText << "]";
				}
			}
fbe3c2bb   Benjamin Renard   First commit
4139
4140
4141
		}
		else
		{
ba6124b0   Menouard AZIB   Add parameter id ...
4142
4143
4144
			if ((index.getDim1Index() == -1) && (index.getDim2Index() == -1))
				// parameter legend text = _originalParamId
				paramLegendText << originalParamId;
fbe3c2bb   Benjamin Renard   First commit
4145
4146
			else
			{
ba6124b0   Menouard AZIB   Add parameter id ...
4147
4148
				// parameter legend text = _originalParamId [lIndex]
				paramLegendText << originalParamId << "[" << index.getDim1Index();
fbe3c2bb   Benjamin Renard   First commit
4149
4150
4151
4152
4153
				if (index.getDim2Index() != -1)
					paramLegendText << "," << index.getDim2Index();
				paramLegendText << "]";
			}
		}
ba6124b0   Menouard AZIB   Add parameter id ...
4154
4155

		return paramLegendText.str();
fbe3c2bb   Benjamin Renard   First commit
4156
	}
ba6124b0   Menouard AZIB   Add parameter id ...
4157
4158
4159
4160
4161

	/*
	 * Dumps properties for test.
	 */
	void PanelPlotOutput::dump(std::ostream &out)
fbe3c2bb   Benjamin Renard   First commit
4162
	{
ba6124b0   Menouard AZIB   Add parameter id ...
4163
4164
4165
4166
		out << *(_panel->_page) << std::endl;
		out << *_panel << std::endl;
		std::string prefix = "parameter.";
		for (auto parameter : _parameterAxesList)
fbe3c2bb   Benjamin Renard   First commit
4167
		{
ba6124b0   Menouard AZIB   Add parameter id ...
4168
			parameter.dump(out, prefix);
fbe3c2bb   Benjamin Renard   First commit
4169
4170
4171
		}
	}

d81cc31e   Menouard AZIB   Add INTERVAL INFO...
4172
	void PanelPlotOutput::writeDataFile(double startTime, double stopTime)
7f07dc4b   Menouard AZIB   Now we can downlo...
4173
	{
7f07dc4b   Menouard AZIB   Now we can downlo...
4174
4175
		if (!writeData_)
			return;
db5907ad   Menouard AZIB   Plot Preview Down...
4176
4177

		std::string fileName = _panel->_page->fileDataName;
4c184d91   Menouard AZIB   Delete data file ...
4178
4179
4180
4181
4182
4183
4184
4185

		if (remove(fileName.c_str()) == 0){
			LOG4CXX_DEBUG(gLogger, "Deleted successfully: " << fileName);
		}
		else{
			LOG4CXX_DEBUG(gLogger, "Unable to delete the file: " << fileName);
		}

db5907ad   Menouard AZIB   Plot Preview Down...
4186
4187
4188
4189
		LOG4CXX_DEBUG(gLogger, "Name of the data file is " << fileName);

		fileData.open(fileName);

d78eca08   Menouard AZIB   Fill AMDA_... cor...
4190
4191
4192
4193
4194
4195
4196
4197
4198
4199
4200
4201
		std::string version = AMDA_Kernel_VERSION;

		char *hideVersion;
		if ((hideVersion = getenv("HIDE_VERSION")) != NULL)
			if (strcmp(hideVersion, "true") == 0)
				version = "none-for-test"; // hide version number for tests

		AMDA::helpers::Properties lProperties("amda.properties");

		std::string createdby = lProperties["createdby"];
		std::string acknowledgement = lProperties["acknowledgement"];

d81cc31e   Menouard AZIB   Add INTERVAL INFO...
4202
4203
4204
4205
		std::stringstream startTimeStr, stopTimeStr;
		AMDA::TimeUtil::formatTimeDateInIso(startTime, startTimeStr);
		AMDA::TimeUtil::formatTimeDateInIso(stopTime, stopTimeStr);

7fb3da6b   Menouard AZIB   Add Request time ...
4206
4207
4208
4209
4210
4211
		// current date/time based on current system
		time_t now = time(0);

		// convert now to string form
		char *dt = ctime(&now);

db5907ad   Menouard AZIB   Plot Preview Down...
4212
4213
4214
4215
		// Wrtie a data header
		fileData << "# -----------" << std::endl;
		fileData << "# AMDA INFO :" << std::endl;
		fileData << "# -----------" << std::endl;
d78eca08   Menouard AZIB   Fill AMDA_... cor...
4216
4217
4218
		fileData << "# AMDA_VERSION : " << version << std::endl;
		fileData << "# AMDA_ABOUT : " << createdby << std::endl;
		fileData << "# AMDA_ACKNOWLEDGEMENT : " << acknowledgement << std::endl;
db5907ad   Menouard AZIB   Plot Preview Down...
4219
		fileData << "#" << std::endl;
f43341e7   Menouard AZIB   Improve the conte...
4220
4221
		fileData << "# -------------- " << std::endl;
		fileData << "# REQUEST INFO : " << std::endl;
d81cc31e   Menouard AZIB   Add INTERVAL INFO...
4222
		fileData << "# ---------------" << std::endl;
f43341e7   Menouard AZIB   Improve the conte...
4223
4224
4225
4226
4227
		fileData << "# REQUEST_TYPE : "<< "Downloading data for plot preview" << std::endl;
		fileData << "# REQUEST_TIME (Server Time) : "<< dt <<"#"<<std::endl;
		fileData << "# ----------------" << std::endl;
		fileData << "# INTERVAL INFO : " << std::endl;
		fileData << "# ----------------" << std::endl;
d81cc31e   Menouard AZIB   Add INTERVAL INFO...
4228
4229
		fileData << "# INTERVAL_START : " << startTimeStr.str() << std::endl;
		fileData << "# INTERVAL_STOP : " << stopTimeStr.str()<< std::endl;
7fb3da6b   Menouard AZIB   Add Request time ...
4230
		fileData << "#" << std::endl;
f43341e7   Menouard AZIB   Improve the conte...
4231
4232
4233
4234
4235
4236
4237
4238
4239
4240
4241
4242
4243
4244
4245
4246
4247
4248
4249
4250
4251
4252
4253
4254
4255
4256
4257
4258
4259
4260
4261
		fileData << "# -------------" << std::endl;
		fileData << "# PARAMETERS : " << std::endl;
		fileData << "# -------------" << std::endl;
		fileData << "#" << std::endl;
	

		 for (ParameterAxesList::iterator it = _parameterAxesList.begin();
             it != _parameterAxesList.end(); ++it)
        {
            AMDA::Parameters::ParameterSPtr originalParam =
                _parameterManager.getParameter(it->_originalParamId);

			// Retrieve ParamInfo Manager
			ParamMgr *piMgr = ParamMgr::getInstance();
			ParamInfoSPtr paramInfo = piMgr->getParamInfoFromId(it->_originalParamId);
			std::vector<std::pair<std::string, std::string>> infoMap = paramInfo->getInfoMap(&_parameterManager);
			for (auto info : infoMap)
				fileData << "# " << info.first << " : " << info.second << std::endl;
			if (paramInfo->getDatasetId() != "")
			{
				DataSetInfoSPtr dataSetInfo = DataSetMgr::getInstance()->getDataSetInfoFromId(paramInfo->getDatasetId());
				infoMap = dataSetInfo->getInfoMap();
				fileData << "#" << std::endl;
				for (auto info : infoMap)
				{
					if (info.first != DATASET_CAVEATS)
						fileData << "# 		" << info.first << " : " << info.second << std::endl;
				}
			}
			fileData << "#" << std::endl;
		}
db5907ad   Menouard AZIB   Plot Preview Down...
4262
4263
4264
4265
	}

	int PanelPlotOutput::addAxisLabelToDataFile(boost::shared_ptr<Axis> lXAxis, boost::shared_ptr<Axis> lYAxis)
	{
db5907ad   Menouard AZIB   Plot Preview Down...
4266
		std::string x_axisLabel = lXAxis != nullptr ? lXAxis->_legend.getText() : "null";
db5907ad   Menouard AZIB   Plot Preview Down...
4267
4268
		std::string y_axisLabel = lYAxis != nullptr ? lYAxis->_legend.getText() : "null";

f43341e7   Menouard AZIB   Improve the conte...
4269
4270
4271
4272
4273
4274
4275
4276
4277
4278
4279
4280
4281
4282
		std::string replaceDelimiter = " ";
		boost::replace_all(x_axisLabel, Label::DELIMITER, replaceDelimiter);
		boost::replace_all(y_axisLabel, Label::DELIMITER, replaceDelimiter);

		std::string units = "#u2";
		std::string units_ = "**2 ";

		boost::replace_all(x_axisLabel, units, units_);
		boost::replace_all(y_axisLabel, units, units_);

		boost::replace_all(x_axisLabel, "#d", "");
		boost::replace_all(y_axisLabel,  "#d", "");


db5907ad   Menouard AZIB   Plot Preview Down...
4283
4284
4285
		int n = x_axisLabel.length();
		if (n <= 45)
			n = 45;
f43341e7   Menouard AZIB   Improve the conte...
4286
		fileData << "# -------" << std::endl;
db5907ad   Menouard AZIB   Plot Preview Down...
4287
		fileData << "# DATA : " << std::endl;
f43341e7   Menouard AZIB   Improve the conte...
4288
4289
4290
4291
		fileData << "# -------" << std::endl;
		fileData << "# X-Axis Scale : " << PanelPlotOutput::scaleStr(lXAxis->_scale) << std::endl;
        fileData << "# Y-Axis Scale : " << PanelPlotOutput::scaleStr(lYAxis->_scale) << std::endl;
		fileData << "# X = " << x_axisLabel<< std::endl;
db5907ad   Menouard AZIB   Plot Preview Down...
4292
		fileData << "# Y = " << y_axisLabel << std::endl;
f43341e7   Menouard AZIB   Improve the conte...
4293
		fileData << "#" << std::endl;
db5907ad   Menouard AZIB   Plot Preview Down...
4294
		fileData << std::setw(n / 2);
db5907ad   Menouard AZIB   Plot Preview Down...
4295
		fileData << std::setw(n);
db5907ad   Menouard AZIB   Plot Preview Down...
4296
4297
4298
4299
4300
4301
4302

		return n;
	}

	void PanelPlotOutput::closeDataFile()
	{
		fileData.close();
7f07dc4b   Menouard AZIB   Now we can downlo...
4303
	}
6f6cb26b   Menouard AZIB   Delete time(0) in...
4304

ba6124b0   Menouard AZIB   Add parameter id ...
4305
} /* namespace plot */