Blame view

src/ParamOutputImpl/Plot/Time/TimePlot.cc 78.1 KB
fbe3c2bb   Benjamin Renard   First commit
1
2
3
4
5
6
7
8
/*
 * TimePlot.cc
 *
 *  Created on: 22 nov. 2013
 *      Author: CS
 */

#include "TimePlot.hh"
fbe3c2bb   Benjamin Renard   First commit
9
#include "AxesNode.hh"
fe6b6521   Menouard AZIB   J'ai ajouté le tr...
10
11
#include "AxisLegendManager.hh"
#include "DefaultTimeAxisDecorator.hh"
fbe3c2bb   Benjamin Renard   First commit
12
#include "ParamInfo.hh"
fbe3c2bb   Benjamin Renard   First commit
13
#include "ParamMgr.hh"
fe6b6521   Menouard AZIB   J'ai ajouté le tr...
14
15
16
17
18
19
20
#include "ParamTable.hh"
#include "Parameter.hh"
#include "ParamsNode.hh"
#include "PlPlotUtil.hh"
#include "PlotLogger.hh"
#include "PlotOutput.hh"
#include "Range.hh"
fbe3c2bb   Benjamin Renard   First commit
21
#include "ShadesTools.hh"
fe6b6521   Menouard AZIB   J'ai ajouté le tr...
22
23
24
#include "TickMarkDecorator.hh"
#include "TimeUtil.hh"
#include <cstddef>
fbe3c2bb   Benjamin Renard   First commit
25
#include <fstream>
2acc7d49   Hacene SI HADJ MOHAND   progress
26
#include <limits>
fbe3c2bb   Benjamin Renard   First commit
27

fe6b6521   Menouard AZIB   J'ai ajouté le tr...
28
29
30
#include <sstream>
#include <string>
#include <vector>
fbe3c2bb   Benjamin Renard   First commit
31
32

#include <boost/format.hpp>
fe6b6521   Menouard AZIB   J'ai ajouté le tr...
33
#include <iostream>
fbe3c2bb   Benjamin Renard   First commit
34
35
36
37

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

fe6b6521   Menouard AZIB   J'ai ajouté le tr...
38
39
namespace plot
{
fbe3c2bb   Benjamin Renard   First commit
40

fe6b6521   Menouard AZIB   J'ai ajouté le tr...
41
	QSASConfig *TimePlot::qsasconfig = NULL;
fbe3c2bb   Benjamin Renard   First commit
42

fe6b6521   Menouard AZIB   J'ai ajouté le tr...
43
44
45
46
	TimePlot::TimePlot(AMDA::Parameters::ParameterManager &manager,
					   boost::shared_ptr<Panel> panel, TimeAxisDecorator *timeAxisDecorator, bool isStandalone) : PanelPlotOutput(manager, panel, isStandalone), _startDateDrawn(false)
	{
		setTimeAxisDecorator(std::shared_ptr<TimeAxisDecorator>(timeAxisDecorator));
fbe3c2bb   Benjamin Renard   First commit
47
	}
fbe3c2bb   Benjamin Renard   First commit
48

fe6b6521   Menouard AZIB   J'ai ajouté le tr...
49
50
51
52
53
54
55
	TimePlot::~TimePlot()
	{
		if (qsasconfig != NULL)
		{
			free(qsasconfig);
			qsasconfig = nullptr;
		}
fbe3c2bb   Benjamin Renard   First commit
56
57
	}

fe6b6521   Menouard AZIB   J'ai ajouté le tr...
58
59
60
61
62
63
64
65
66
67
68
69
70
	TimeAxis *TimePlot::getTimeAxis()
	{
		std::string lAxisId = getXAxisId();
		boost::shared_ptr<Axis> xAxis = _panel->getAxis(lAxisId);
		if (xAxis.get() == nullptr)
		{
			std::stringstream lError;
			lError << "TimePlot::apply"
				   << ": time axis with id '" << lAxisId << "' not found.";
			BOOST_THROW_EXCEPTION(PanelPlotOutputException() << AMDA::ex_msg(lError.str()));
		}
		return dynamic_cast<TimeAxis *>(xAxis.get());
	}
fbe3c2bb   Benjamin Renard   First commit
71

fe6b6521   Menouard AZIB   J'ai ajouté le tr...
72
73
74
75
76
77
78
79
80
81
	void TimePlot::preparePlotArea(double startTime, double stopTime, int intervalIndex)
	{
		// dump properties for test
		const char *lBuildType = getenv("BUILD_TYPE");
		if (lBuildType && std::string(lBuildType) == "Debug")
		{
			std::ofstream out("timePlot.txt");
			dump(out);
			out.close();
		}
fbe3c2bb   Benjamin Renard   First commit
82

fe6b6521   Menouard AZIB   J'ai ajouté le tr...
83
84
85
		// Configure Series to draw on axis by checking which color to use and
		// number of series to draw on a same axis.
		configureSeriesAxis();
fbe3c2bb   Benjamin Renard   First commit
86

fe6b6521   Menouard AZIB   J'ai ajouté le tr...
87
		configureAxisLegend();
fbe3c2bb   Benjamin Renard   First commit
88

fe6b6521   Menouard AZIB   J'ai ajouté le tr...
89
		configureSpectroAxis();
62024e03   Erdogan Furkan   Some modifications
90
91
92
93

		configureSauvaudAxis();

		configureIntervalsLegend();
fbe3c2bb   Benjamin Renard   First commit
94

fe6b6521   Menouard AZIB   J'ai ajouté le tr...
95
		configureParamsLegend(startTime, stopTime, intervalIndex);
fbe3c2bb   Benjamin Renard   First commit
96

fe6b6521   Menouard AZIB   J'ai ajouté le tr...
97
98
99
100
		// configure X axis
		getTimeAxisDecorator()->configure(this, getTimeAxis(), startTime, stopTime, _pParameterValues);
		getTimeAxis()->_used = true;
		_pls->timefmt(getTimeAxisDecorator()->getPlFormat().c_str());
fbe3c2bb   Benjamin Renard   First commit
101

fe6b6521   Menouard AZIB   J'ai ajouté le tr...
102
103
		PanelPlotOutput::preparePlotArea(startTime, stopTime, intervalIndex);
	}
fbe3c2bb   Benjamin Renard   First commit
104

fe6b6521   Menouard AZIB   J'ai ajouté le tr...
105
106
107
	bool TimePlot::draw(double startTime, double stopTime, int intervalIndex,
						bool isFirstInterval, bool isLastInterval)
	{
fbe3c2bb   Benjamin Renard   First commit
108

fe6b6521   Menouard AZIB   J'ai ajouté le tr...
109
		bool dataPloted = PanelPlotOutput::draw(startTime, stopTime, intervalIndex, isFirstInterval, isLastInterval);
fbe3c2bb   Benjamin Renard   First commit
110

fe6b6521   Menouard AZIB   J'ai ajouté le tr...
111
112
113
114
115
116
		// Draw start date
		if (!_startDateDrawn /*&& getTimeAxis()->_used*/)
			drawStartDate(getTimeAxis(), startTime, stopTime);
		_startDateDrawn = true;
		return dataPloted;
	}
fbe3c2bb   Benjamin Renard   First commit
117

fe6b6521   Menouard AZIB   J'ai ajouté le tr...
118
119
120
121
122
123
	void TimePlot::calculatePlotArea(const Bounds &panelBounds_, Bounds &bounds_)
	{
		PanelPlotOutput::calculatePlotArea(panelBounds_, bounds_);
		// decorator is responsible of reserving extra space for what it manage (labels for instance).
		getTimeAxisDecorator()->updatePlotArea(this, getTimeAxis(), panelBounds_, bounds_);
	}
fbe3c2bb   Benjamin Renard   First commit
124

fe6b6521   Menouard AZIB   J'ai ajouté le tr...
125
126
127
128
129
130
	void TimePlot::configureSeriesAxis()
	{
		// map<YAxisId, userRangeDefined>
		std::map<std::string, Range> lAxisRange;
		Range lColorAxeRange;
		SeriesProperties lSeriesProperties;
fbe3c2bb   Benjamin Renard   First commit
131

fe6b6521   Menouard AZIB   J'ai ajouté le tr...
132
		boost::shared_ptr<ColorAxis> lZAxis = _panel->getColorAxis();
fbe3c2bb   Benjamin Renard   First commit
133

fe6b6521   Menouard AZIB   J'ai ajouté le tr...
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
		// Parse each parameter to define on which axis to draw series.
		for (auto param : _parameterAxesList)
		{
			// Get number of series to draw
			// For each index of parameter identify to which axis series must be drawn.
			for (auto lSeriesProperties : param.getYSeriePropertiesList())
			{
				if (!lSeriesProperties.hasYAxis())
				{
					continue;
				}
				boost::shared_ptr<Axis> lYAxis = _panel->getAxis(lSeriesProperties.getYAxisId());
				if (lYAxis.get() == nullptr)
				{
					std::stringstream lError;
					lError << "TimePlot::configureSeriesAxis"
						   << ": Y axis with id '" << lSeriesProperties.getYAxisId() << "' not found.";
					BOOST_THROW_EXCEPTION(PanelPlotOutputException() << AMDA::ex_msg(lError.str()));
				}
fbe3c2bb   Benjamin Renard   First commit
153

fe6b6521   Menouard AZIB   J'ai ajouté le tr...
154
155
156
157
158
159
160
161
162
163
				lYAxis->_used = true;
				Range lYAxisRequestRange = lYAxis->Axis::getRequestedRange();
				Range lRange = lYAxis->Axis::getRange();
				// If range status for this axis is set by the user do not update range "automatically".
				if (isnan(lYAxisRequestRange.getMin()) && isnan(lYAxisRequestRange.getMax()))
				{
					Range lEstimatedRange(lAxisRange[lYAxis->_id]);
					for (auto index : lSeriesProperties.getIndexList(_pParameterValues))
					{
						Range lParamIndexRange(
2fc1f2f8   Benjamin Renard   Full rework for s...
164
165
166
							(*_pParameterValues)[lSeriesProperties.getParamId()].getMin(index),
							(*_pParameterValues)[lSeriesProperties.getParamId()].getMax(index));

fe6b6521   Menouard AZIB   J'ai ajouté le tr...
167
						ErrorBarProperties &errBarProp = lSeriesProperties.getErrorBarProperties();
2fc1f2f8   Benjamin Renard   Full rework for s...
168

fe6b6521   Menouard AZIB   J'ai ajouté le tr...
169
170
171
172
						// Update lParamIndexRange depending on the use of ErrorBars on the plot
						if (errBarProp.getErrorMinMax() != nullptr)
						{
							Range lParamMinRange(
2fc1f2f8   Benjamin Renard   Full rework for s...
173
174
								(*_pParameterValues)[errBarProp.getErrorMinMax()->getUsedParamMin()].getMin(-1),
								(*_pParameterValues)[errBarProp.getErrorMinMax()->getUsedParamMin()].getMax(-1));
fe6b6521   Menouard AZIB   J'ai ajouté le tr...
175
							Range lParamMaxRange(
2fc1f2f8   Benjamin Renard   Full rework for s...
176
177
178
								(*_pParameterValues)[errBarProp.getErrorMinMax()->getUsedParamMax()].getMin(-1),
								(*_pParameterValues)[errBarProp.getErrorMinMax()->getUsedParamMax()].getMax(-1));

fe6b6521   Menouard AZIB   J'ai ajouté le tr...
179
180
181
182
							if (lParamMinRange.getMin() < lParamIndexRange.getMin())
								lParamIndexRange.setMin(lParamMinRange.getMin());
							if (lParamMinRange.getMax() > lParamIndexRange.getMax())
								lParamIndexRange.setMax(lParamMinRange.getMax());
2fc1f2f8   Benjamin Renard   Full rework for s...
183

fe6b6521   Menouard AZIB   J'ai ajouté le tr...
184
185
186
187
188
							if (lParamMaxRange.getMin() < lParamIndexRange.getMin())
								lParamIndexRange.setMin(lParamMaxRange.getMin());
							if (lParamMaxRange.getMax() > lParamIndexRange.getMax())
								lParamIndexRange.setMax(lParamMaxRange.getMax());
						}
fbe3c2bb   Benjamin Renard   First commit
189

fe6b6521   Menouard AZIB   J'ai ajouté le tr...
190
191
192
193
194
195
196
197
198
199
200
201
						if (isnan(lEstimatedRange.getMin()) && isnan(lEstimatedRange.getMax()))
						{
							lEstimatedRange.setMin(lParamIndexRange.getMin());
							lEstimatedRange.setMax(lParamIndexRange.getMax());
						}
						else
						{
							lEstimatedRange.setMin(std::min(lEstimatedRange.getMin(), lParamIndexRange.getMin()));
							lEstimatedRange.setMax(std::max(lEstimatedRange.getMax(), lParamIndexRange.getMax()));
						}
						if (lParamIndexRange.getMin() == lParamIndexRange.getMax())
							lEstimatedRange.setMargin(0.05);
2fc1f2f8   Benjamin Renard   Full rework for s...
202
					}
e062d6ef   Benjamin Renard   Fix axes range wh...
203

fe6b6521   Menouard AZIB   J'ai ajouté le tr...
204
					lEstimatedRange._extend = lRange._extend;
641ba7e4   Hacene SI HADJ MOHAND   ok for time plot
205

fe6b6521   Menouard AZIB   J'ai ajouté le tr...
206
207
					lAxisRange[lYAxis->_id] = lEstimatedRange;
				}
fbe3c2bb   Benjamin Renard   First commit
208

fe6b6521   Menouard AZIB   J'ai ajouté le tr...
209
210
				// Set ZAxis range if a color param is defined for this serie
				if (lZAxis != nullptr)
fbe3c2bb   Benjamin Renard   First commit
211
				{
fe6b6521   Menouard AZIB   J'ai ajouté le tr...
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
					if (!lSeriesProperties.getColorParamId().empty())
					{
						lZAxis->_used = true;
						Range lRange(lZAxis->getRange());
						ParameterAxes *colorSerieParameterAxes = getParameterAxesByColorSerieId(lSeriesProperties.getColorSerieId());
						if (colorSerieParameterAxes == NULL)
							continue;
						ColorSeriesProperties &colorSerieProp = colorSerieParameterAxes->getColorSeriePropertiesById(lSeriesProperties.getColorSerieId());
						// If range status for this axis is set by the user do not update range "automatically".
						if (isnan(lRange.getMin()) && isnan(lRange.getMax()))
						{
							Range lEstimatedRange(lColorAxeRange);
							Range lParamIndexRange(
								(*_pParameterValues)[lSeriesProperties.getColorParamId()].getMin(
									colorSerieProp.getIndex()),
								(*_pParameterValues)[lSeriesProperties.getColorParamId()].getMax(
									colorSerieProp.getIndex()));

							if (isnan(lEstimatedRange.getMin()) && isnan(lEstimatedRange.getMax()))
							{
								lEstimatedRange.setMin(lParamIndexRange.getMin());
								lEstimatedRange.setMax(lParamIndexRange.getMax());
							}
							else
							{
								lEstimatedRange.setMin(std::min(lEstimatedRange.getMin(), lParamIndexRange.getMin()));
								lEstimatedRange.setMax(std::max(lEstimatedRange.getMax(), lParamIndexRange.getMax()));
							}
							if (lParamIndexRange.getMin() == lParamIndexRange.getMax())
								lEstimatedRange.setMargin(0.05);
							lEstimatedRange._extend = lRange._extend;
							lColorAxeRange = lEstimatedRange;
fbe3c2bb   Benjamin Renard   First commit
244
						}
fbe3c2bb   Benjamin Renard   First commit
245
246
247
248
					}
				}
			}
		}
fbe3c2bb   Benjamin Renard   First commit
249

fe6b6521   Menouard AZIB   J'ai ajouté le tr...
250
251
252
253
254
255
256
257
		// Update range of axis. Done after because, axis range may be processed in several pass (one for each series)
		for (auto lAxis : lAxisRange)
		{
			boost::shared_ptr<Axis> lYAxis = _panel->getAxis(lAxis.first);
			Range lRange(lAxis.second);
			fixRange(lRange, lYAxis->_scale == Axis::Scale::LOGARITHMIC);
			lYAxis->setRange(lRange);
		}
fbe3c2bb   Benjamin Renard   First commit
258

fe6b6521   Menouard AZIB   J'ai ajouté le tr...
259
260
261
262
263
		if (lZAxis != nullptr && lColorAxeRange.isSet())
		{
			fixRange(lColorAxeRange, lZAxis->_scale == Axis::Scale::LOGARITHMIC);
			lZAxis->setRange(lColorAxeRange);
		}
5c050d50   Benjamin Renard   Fix another bugs ...
264
	}
fbe3c2bb   Benjamin Renard   First commit
265

fe6b6521   Menouard AZIB   J'ai ajouté le tr...
266
267
268
269
270
	void TimePlot::configureAxisLegend()
	{
		// Y axis
		AxisLegendManager::configureYAxisLegendForSpectro(this);
		AxisLegendManager::configureYAxisLegendForSeries(this);
fbe3c2bb   Benjamin Renard   First commit
271

fe6b6521   Menouard AZIB   J'ai ajouté le tr...
272
273
274
275
		// Z axis
		AxisLegendManager::configureColorAxisLegendForSpectro(this);
		AxisLegendManager::configureColorAxisLegendForSeries(this);
	}
fbe3c2bb   Benjamin Renard   First commit
276

62024e03   Erdogan Furkan   Some modifications
277
278
	void TimePlot::configureIntervalsLegend()
	{
0fa2d990   Erdogan Furkan   7616 - Adding lab...
279
		ParamMgr *piMgr = ParamMgr::getInstance();
62024e03   Erdogan Furkan   Some modifications
280
281
		for (auto param : _parameterAxesList)
		{
0fa2d990   Erdogan Furkan   7616 - Adding lab...
282
283
284
			std::shared_ptr<IntervalsProperties> intervalsPropertiesPtr = param.getIntervalsProperties();
			ParameterSPtr p = _parameterManager.getParameter(param._originalParamId);
			AMDA::Info::ParamInfoSPtr paramInfo = piMgr->getParamInfoFromId(p->getInfoId());
62024e03   Erdogan Furkan   Some modifications
285

0fa2d990   Erdogan Furkan   7616 - Adding lab...
286
287
			if (intervalsPropertiesPtr != nullptr)
			{
ac0e4b16   Erdogan Furkan   Some modifications
288
				boost::shared_ptr<TextLegendProperties> pTextLegendProperties = intervalsPropertiesPtr->getLegend();
0fa2d990   Erdogan Furkan   7616 - Adding lab...
289

d9ec904f   Benjamin Renard   Fix
290
291
292
293
294
				if (pTextLegendProperties != nullptr) {
					if (pTextLegendProperties->getText() == "")
					{
						pTextLegendProperties->setText(paramInfo->getShortName());
					}
0fa2d990   Erdogan Furkan   7616 - Adding lab...
295

d9ec904f   Benjamin Renard   Fix
296
297
					pTextLegendProperties->setColor(intervalsPropertiesPtr->getColor());
				}
62024e03   Erdogan Furkan   Some modifications
298
299
300
301
			}
		}
	}

fe6b6521   Menouard AZIB   J'ai ajouté le tr...
302
303
	void TimePlot::configureSpectroAxis()
	{
fbe3c2bb   Benjamin Renard   First commit
304
		// Parse each parameter to define on which axis to draw spectro
fe6b6521   Menouard AZIB   J'ai ajouté le tr...
305
306
307
308
309
		for (auto param : _parameterAxesList)
		{
			std::shared_ptr<SpectroProperties> spectroPropertiesPtr = param.getSpectroProperties();
			if (spectroPropertiesPtr == nullptr)
				continue; //no spectro defined
08ec1dde   Benjamin Renard   Add propertie _us...
310

fe6b6521   Menouard AZIB   J'ai ajouté le tr...
311
312
			if (!spectroPropertiesPtr->hasYAxis())
				continue;
fbe3c2bb   Benjamin Renard   First commit
313

fe6b6521   Menouard AZIB   J'ai ajouté le tr...
314
315
316
317
318
319
320
321
322
			LOG4CXX_DEBUG(gLogger, "Spectro Y axis is " << spectroPropertiesPtr->getYAxisId());
			boost::shared_ptr<Axis> lYAxis = _panel->getAxis(spectroPropertiesPtr->getYAxisId());
			if (lYAxis.get() == nullptr)
			{
				std::stringstream lError;
				lError << "TimePlot::configureSpectroAxis"
					   << ": Y axis with id '" << spectroPropertiesPtr->getYAxisId() << "' not found.";
				BOOST_THROW_EXCEPTION(PanelPlotOutputException() << AMDA::ex_msg(lError.str()));
			}
966af096   Benjamin Renard   Fix 'sum in range...
323

fe6b6521   Menouard AZIB   J'ai ajouté le tr...
324
			lYAxis->_used = true;
fbe3c2bb   Benjamin Renard   First commit
325

fe6b6521   Menouard AZIB   J'ai ajouté le tr...
326
327
328
			//set Z axis range
			boost::shared_ptr<Axis> lZAxis = _panel->getAxis(spectroPropertiesPtr->getZAxisId());
			if (lZAxis.get() == nullptr)
fbe3c2bb   Benjamin Renard   First commit
329
			{
fe6b6521   Menouard AZIB   J'ai ajouté le tr...
330
331
332
333
				std::stringstream lError;
				lError << "TimePlot::configureSpectroAxis"
					   << ": Z axis with id '" << spectroPropertiesPtr->getZAxisId() << "' not found.";
				BOOST_THROW_EXCEPTION(PanelPlotOutputException() << AMDA::ex_msg(lError.str()));
fbe3c2bb   Benjamin Renard   First commit
334
			}
fe6b6521   Menouard AZIB   J'ai ajouté le tr...
335
336
337
338
339
340
341

			lZAxis->_used = true;

			ParameterSPtr p = _parameterManager.getParameter(param._originalParamId);
			int parameterDimension;
			if (spectroPropertiesPtr->getRelatedDim() == 0)
				parameterDimension = (*_pParameterValues)[spectroPropertiesPtr->getParamId()].getDim1Size();
fbe3c2bb   Benjamin Renard   First commit
342
			else
fe6b6521   Menouard AZIB   J'ai ajouté le tr...
343
344
345
346
347
				parameterDimension = (*_pParameterValues)[spectroPropertiesPtr->getParamId()].getDim2Size();

			//set Y axis range
			Range lYAxisRequestRange = lYAxis->Axis::getRequestedRange();
			Range lYAxisRange = lYAxis->Axis::getRange();
0fa2d990   Erdogan Furkan   7616 - Adding lab...
348

7d595235   Erdogan Furkan   #9981 - Done
349
350
351
352
353
354
355
356
			if (lYAxis->_reverse){
				double lYAxisMin = lYAxisRange.getMin();
				lYAxisRange.setMin(lYAxisRange.getMax());
				lYAxisRange.setMax(lYAxisMin);

			}
			std::cout << std::endl<< std::endl<< std::endl<< std::endl << "FER - Range" <<  lYAxisRange << "Maybe reverse value => " << lYAxis->_reverse << std::endl<< std::endl<< std::endl<< std::endl<< std::endl;

fe6b6521   Menouard AZIB   J'ai ajouté le tr...
357
			AMDA::Info::ParamInfoSPtr paramInfo = AMDA::Info::ParamMgr::getInstance()->getParamInfoFromId(p->getInfoId());
0fa2d990   Erdogan Furkan   7616 - Adding lab...
358

fe6b6521   Menouard AZIB   J'ai ajouté le tr...
359
			if (isnan(lYAxisRequestRange.getMin()) && isnan(lYAxisRequestRange.getMax()))
fbe3c2bb   Benjamin Renard   First commit
360
			{
fe6b6521   Menouard AZIB   J'ai ajouté le tr...
361
362
363
				boost::shared_ptr<AMDA::Info::ParamTable> tableSPtr;
				if (paramInfo != nullptr)
					tableSPtr = paramInfo->getTable(spectroPropertiesPtr->getRelatedDim());
0fa2d990   Erdogan Furkan   7616 - Adding lab...
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385

				if (tableSPtr == nullptr)
				{
					// look for unique embedded table
					boost::shared_ptr<AMDA::Info::ParamTable> linkedTableSPtr;
					int counter = 0;
					for (auto pInfo : paramInfo->getLinkedParamList())
					{
						linkedTableSPtr = AMDA::Info::ParamMgr::getInstance()->getParamInfoFromId(pInfo)->getTable(spectroPropertiesPtr->getRelatedDim());
						if (linkedTableSPtr == nullptr)
							continue;
						counter++;
					}
					if (linkedTableSPtr == nullptr || counter != 1)
					{
						LOG4CXX_DEBUG(gLogger, "table cannot be defined from linked info params");
					}
					else
					{
						tableSPtr = linkedTableSPtr;
					}
				}
fe6b6521   Menouard AZIB   J'ai ajouté le tr...
386
387

				if (tableSPtr == nullptr)
fbe3c2bb   Benjamin Renard   First commit
388
				{
fe6b6521   Menouard AZIB   J'ai ajouté le tr...
389
390
391
					LOG4CXX_DEBUG(gLogger, "No table defined => use index");
					lYAxisRange.setMin(std::min(0., lYAxisRange.getMin()));
					lYAxisRange.setMax(std::max((double)parameterDimension, lYAxisRange.getMax()));
f2db3c16   Benjamin Renard   Support variable ...
392
393
394
				}
				else
				{
fe6b6521   Menouard AZIB   J'ai ajouté le tr...
395
396
					AMDA::Info::t_TableBound crtBound;
					if (!tableSPtr->isVariable(&_parameterManager))
f2db3c16   Benjamin Renard   Support variable ...
397
					{
fe6b6521   Menouard AZIB   J'ai ajouté le tr...
398
						for (int i = 0; i < parameterDimension; ++i)
f2db3c16   Benjamin Renard   Support variable ...
399
						{
fe6b6521   Menouard AZIB   J'ai ajouté le tr...
400
							crtBound = tableSPtr->getBound(&_parameterManager, i);
ed9a1eaf   Benjamin Renard   Add Maven STATIC ...
401
402
403
							if (!std::isnan(crtBound.min))
							{
								if (!((lYAxis->_scale == Axis::Scale::LOGARITHMIC) && (crtBound.min <= 0)))
fe6b6521   Menouard AZIB   J'ai ajouté le tr...
404
									lYAxisRange.setMin(std::min(crtBound.min, lYAxisRange.getMin()));
ed9a1eaf   Benjamin Renard   Add Maven STATIC ...
405
406
407
408
							}
							if (!std::isnan(crtBound.max))
							{
								if (!((lYAxis->_scale == Axis::Scale::LOGARITHMIC) && (crtBound.max <= 0)))
fe6b6521   Menouard AZIB   J'ai ajouté le tr...
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
									lYAxisRange.setMax(std::max(crtBound.max, lYAxisRange.getMax()));
							}
						}
					}
					else
					{
						//Variable table => we need to loop under all records to find axis min & max values
						for (int i = 0; i < (*_pParameterValues)[spectroPropertiesPtr->getParamId()].getSize(); ++i)
						{
							std::map<std::string, std::vector<double>> paramsTableData;
							for (std::map<std::string, std::string>::iterator it = spectroPropertiesPtr->getTableParams().begin(); it != spectroPropertiesPtr->getTableParams().end(); ++it)
							{
								ParameterData &data = (*_pParameterValues)[it->second];
								std::vector<double> paramTableValues;
								for (int j = 0; j < data.getDim1Size(); ++j)
								{
									if (i < data.getSize())
									{
										double *values = data.getValues(AMDA::Common::ParameterIndexComponent(j), i);
										paramTableValues.push_back((*values));
									}
								}
								paramsTableData[it->first] = paramTableValues;
							}
							for (int j = 0; j < parameterDimension; ++j)
							{
								crtBound = tableSPtr->getBound(&_parameterManager, j, &paramsTableData);
								if (!std::isnan(crtBound.min))
								{
									if (!((lYAxis->_scale == Axis::Scale::LOGARITHMIC) && (crtBound.min <= 0)))
										lYAxisRange.setMin(std::min(crtBound.min, lYAxisRange.getMin()));
								}
								if (!std::isnan(crtBound.max))
								{
									if (!((lYAxis->_scale == Axis::Scale::LOGARITHMIC) && (crtBound.max <= 0)))
										lYAxisRange.setMax(std::max(crtBound.max, lYAxisRange.getMax()));
								}
ed9a1eaf   Benjamin Renard   Add Maven STATIC ...
446
							}
f2db3c16   Benjamin Renard   Support variable ...
447
448
						}
					}
fbe3c2bb   Benjamin Renard   First commit
449
				}
fbe3c2bb   Benjamin Renard   First commit
450
			}
fbe3c2bb   Benjamin Renard   First commit
451

fe6b6521   Menouard AZIB   J'ai ajouté le tr...
452
453
			//do not extend the axis
			lYAxisRange._extend = false;
fbe3c2bb   Benjamin Renard   First commit
454

fe6b6521   Menouard AZIB   J'ai ajouté le tr...
455
			fixRange(lYAxisRange, lYAxis->_scale == Axis::Scale::LOGARITHMIC);
fbe3c2bb   Benjamin Renard   First commit
456

fe6b6521   Menouard AZIB   J'ai ajouté le tr...
457
			lYAxis->setRange(lYAxisRange);
fbe3c2bb   Benjamin Renard   First commit
458

fe6b6521   Menouard AZIB   J'ai ajouté le tr...
459
			LOG4CXX_DEBUG(gLogger, "Y axis range : min = " << lYAxisRange.getMin() << ", max = " << lYAxisRange.getMax());
fbe3c2bb   Benjamin Renard   First commit
460

fe6b6521   Menouard AZIB   J'ai ajouté le tr...
461
462
463
464
465
466
467
468
469
			Range lParamRange = lZAxis->Axis::getRange();
			if (isnan(lParamRange.getMin()) && isnan(lParamRange.getMax()))
			{
				std::string normalization = spectroPropertiesPtr->getNormalization();
				if (normalization == "log" || normalization == "linear")
				{
					lParamRange.setMin(0);
					lParamRange.setMax(1);
				}
fbe3c2bb   Benjamin Renard   First commit
470
				else
fe6b6521   Menouard AZIB   J'ai ajouté le tr...
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
				{
					//auto range
					for (auto index : spectroPropertiesPtr->getIndexes())
					{
						//compute global range for all indexes
						double minVal, maxVal;
						if (lZAxis->_scale == Axis::Scale::LOGARITHMIC)
							minVal = (*_pParameterValues)[spectroPropertiesPtr->getParamId()].getMinStrictPos(index);
						else
							minVal = (*_pParameterValues)[spectroPropertiesPtr->getParamId()].getMin(index);
						maxVal = (*_pParameterValues)[spectroPropertiesPtr->getParamId()].getMax(index);
						if (!isnan(minVal))
							lParamRange.setMin(std::min(minVal, lParamRange.getMin()));
						//else
						//	lParamRange.setMin(0);
						if (!isnan(maxVal))
							lParamRange.setMax(std::max(maxVal, lParamRange.getMax()));
						//else
						//	lParamRange.setMax(10);
fbe3c2bb   Benjamin Renard   First commit
490
					}
fe6b6521   Menouard AZIB   J'ai ajouté le tr...
491
492
493
494
					if (isnan(lParamRange.getMin()))
						lParamRange.setMin(0);
					if (isnan(lParamRange.getMax()))
						lParamRange.setMax(10);
fbe3c2bb   Benjamin Renard   First commit
495
496
				}
			}
fe6b6521   Menouard AZIB   J'ai ajouté le tr...
497
498
			else
				lParamRange._extend = false;
fbe3c2bb   Benjamin Renard   First commit
499

fe6b6521   Menouard AZIB   J'ai ajouté le tr...
500
501
502
503
			//set z axis range
			fixRange(lParamRange, lZAxis->_scale == Axis::Scale::LOGARITHMIC);
			LOG4CXX_DEBUG(gLogger, "ZAxis range : ZMin = " << lParamRange.getMin() << ", ZMax = " << lParamRange.getMax());
			lZAxis->setRange(lParamRange);
fbe3c2bb   Benjamin Renard   First commit
504
505
		}
	}
0fa2d990   Erdogan Furkan   7616 - Adding lab...
506
507

	void TimePlot::configureSauvaudAxis()
736a40f7   Hacene SI HADJ MOHAND   configureSauvaudAxis
508
509
510
511
512
513
514
	{
		// Parse each parameter to define on which axis to draw Sauvaud
		for (auto param : _parameterAxesList)
		{
			std::shared_ptr<SauvaudProperties> sauvaudPropertiesPtr = param.getSauvaudProperties();
			if (sauvaudPropertiesPtr == nullptr)
				continue; //no sauvaud defined
fbe3c2bb   Benjamin Renard   First commit
515

736a40f7   Hacene SI HADJ MOHAND   configureSauvaudAxis
516
517
			if (!sauvaudPropertiesPtr->hasYAxis())
				continue;
fbe3c2bb   Benjamin Renard   First commit
518

736a40f7   Hacene SI HADJ MOHAND   configureSauvaudAxis
519
520
			LOG4CXX_DEBUG(gLogger, "Sauvaud Y axis is " << sauvaudPropertiesPtr->getYAxisId());
			boost::shared_ptr<Axis> lYAxis = _panel->getAxis(sauvaudPropertiesPtr->getYAxisId());
736a40f7   Hacene SI HADJ MOHAND   configureSauvaudAxis
521
522
523
524
525
526
527
			if (lYAxis.get() == nullptr)
			{
				std::stringstream lError;
				lError << "TimePlot::configureSauvaudAxis"
					   << ": Y axis with id '" << sauvaudPropertiesPtr->getYAxisId() << "' not found.";
				BOOST_THROW_EXCEPTION(PanelPlotOutputException() << AMDA::ex_msg(lError.str()));
			}
fbe3c2bb   Benjamin Renard   First commit
528

736a40f7   Hacene SI HADJ MOHAND   configureSauvaudAxis
529
			lYAxis->_used = true;
0fa2d990   Erdogan Furkan   7616 - Adding lab...
530

736a40f7   Hacene SI HADJ MOHAND   configureSauvaudAxis
531
532
533
534
535
536
537
538
539
			//set Z axis range
			boost::shared_ptr<Axis> lZAxis = _panel->getAxis(sauvaudPropertiesPtr->getZAxisId());
			if (lZAxis.get() == nullptr)
			{
				std::stringstream lError;
				lError << "TimePlot::configureSauvaudAxis"
					   << ": Z axis with id '" << sauvaudPropertiesPtr->getZAxisId() << "' not found.";
				BOOST_THROW_EXCEPTION(PanelPlotOutputException() << AMDA::ex_msg(lError.str()));
			}
fbe3c2bb   Benjamin Renard   First commit
540

736a40f7   Hacene SI HADJ MOHAND   configureSauvaudAxis
541
542
543
			lZAxis->_used = true;

			ParameterSPtr p = _parameterManager.getParameter(param._originalParamId);
b0205fd9   Hacene SI HADJ MOHAND   plot ok reste que...
544
			int rightParameterDimension;
0fa2d990   Erdogan Furkan   7616 - Adding lab...
545
			int rightDim = sauvaudPropertiesPtr->getRightDim();
b0205fd9   Hacene SI HADJ MOHAND   plot ok reste que...
546
547
			if (rightDim == 0){
				rightParameterDimension = (*_pParameterValues)[sauvaudPropertiesPtr->getParamId()].getDim1Size();
b0205fd9   Hacene SI HADJ MOHAND   plot ok reste que...
548
549
			}else{
				rightParameterDimension = (*_pParameterValues)[sauvaudPropertiesPtr->getParamId()].getDim2Size();
0fa2d990   Erdogan Furkan   7616 - Adding lab...
550
			}
736a40f7   Hacene SI HADJ MOHAND   configureSauvaudAxis
551
			//set Y axis range
b0205fd9   Hacene SI HADJ MOHAND   plot ok reste que...
552

736a40f7   Hacene SI HADJ MOHAND   configureSauvaudAxis
553
			AMDA::Info::ParamInfoSPtr paramInfo = AMDA::Info::ParamMgr::getInstance()->getParamInfoFromId(p->getInfoId());
0fa2d990   Erdogan Furkan   7616 - Adding lab...
554
555
556

			// configure right axis
			Range lYAxisRequestRange = lYAxis->Axis::getRequestedRange();
b0205fd9   Hacene SI HADJ MOHAND   plot ok reste que...
557
			Range lYAxisRange = lYAxis->Axis::getRange();
736a40f7   Hacene SI HADJ MOHAND   configureSauvaudAxis
558
559
			if (isnan(lYAxisRequestRange.getMin()) && isnan(lYAxisRequestRange.getMax()))
			{
5f13f59c   Hacene SI HADJ MOHAND   in progress worki...
560
				boost::shared_ptr<AMDA::Info::ParamTable> rightTableSPtr;
0fa2d990   Erdogan Furkan   7616 - Adding lab...
561
562
563
564
565
566

				if (paramInfo != nullptr)
				{

					rightTableSPtr = paramInfo->getTable(rightDim);
				}
5f13f59c   Hacene SI HADJ MOHAND   in progress worki...
567
				if (rightTableSPtr == nullptr)
736a40f7   Hacene SI HADJ MOHAND   configureSauvaudAxis
568
569
570
				{
					LOG4CXX_DEBUG(gLogger, "No table defined => use index");
					lYAxisRange.setMin(std::min(0., lYAxisRange.getMin()));
b0205fd9   Hacene SI HADJ MOHAND   plot ok reste que...
571
					lYAxisRange.setMax(std::max((double)rightParameterDimension, lYAxisRange.getMax()));
736a40f7   Hacene SI HADJ MOHAND   configureSauvaudAxis
572
				}
0fa2d990   Erdogan Furkan   7616 - Adding lab...
573
574
575
				else
				{
					AMDA::Info::t_TableBound crtBound;
b0205fd9   Hacene SI HADJ MOHAND   plot ok reste que...
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
					if (!rightTableSPtr->isVariable(&_parameterManager))
					{
						for (int i = 0; i < rightParameterDimension; ++i)
						{
							crtBound = rightTableSPtr->getBound(&_parameterManager, i);
							if (!std::isnan(crtBound.min))
							{
								if (!((lYAxis->_scale == Axis::Scale::LOGARITHMIC) && (crtBound.min <= 0)))
									lYAxisRange.setMin(std::min(crtBound.min, lYAxisRange.getMin()));
							}
							if (!std::isnan(crtBound.max))
							{
								if (!((lYAxis->_scale == Axis::Scale::LOGARITHMIC) && (crtBound.max <= 0)))
									lYAxisRange.setMax(std::max(crtBound.max, lYAxisRange.getMax()));
							}
						}
					}
					else
					{
0fa2d990   Erdogan Furkan   7616 - Adding lab...
595
						// Variable table => we need to loop under all records to find axis min & max values
b0205fd9   Hacene SI HADJ MOHAND   plot ok reste que...
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
						for (int i = 0; i < (*_pParameterValues)[sauvaudPropertiesPtr->getParamId()].getSize(); ++i)
						{
							std::map<std::string, std::vector<double>> paramsTableData;
							for (std::map<std::string, std::string>::iterator it = sauvaudPropertiesPtr->getTableParams().begin(); it != sauvaudPropertiesPtr->getTableParams().end(); ++it)
							{
								ParameterData &data = (*_pParameterValues)[it->second];
								std::vector<double> paramTableValues;
								for (int j = 0; j < data.getDim1Size(); ++j)
								{
									if (i < data.getSize())
									{
										double *values = data.getValues(AMDA::Common::ParameterIndexComponent(j), i);
										paramTableValues.push_back((*values));
									}
								}
								paramsTableData[it->first] = paramTableValues;
							}
							for (int j = 0; j < rightParameterDimension; ++j)
							{
								crtBound = rightTableSPtr->getBound(&_parameterManager, j, &paramsTableData);
								if (!std::isnan(crtBound.min))
								{
									if (!((lYAxis->_scale == Axis::Scale::LOGARITHMIC) && (crtBound.min <= 0)))
										lYAxisRange.setMin(std::min(crtBound.min, lYAxisRange.getMin()));
								}
								if (!std::isnan(crtBound.max))
								{
									if (!((lYAxis->_scale == Axis::Scale::LOGARITHMIC) && (crtBound.max <= 0)))
										lYAxisRange.setMax(std::max(crtBound.max, lYAxisRange.getMax()));
								}
							}
						}
					}
				}
0fa2d990   Erdogan Furkan   7616 - Adding lab...
630
631
			}

736a40f7   Hacene SI HADJ MOHAND   configureSauvaudAxis
632
			//do not extend the axis
0fa2d990   Erdogan Furkan   7616 - Adding lab...
633
			lYAxisRange._extend = false;
fbe3c2bb   Benjamin Renard   First commit
634

736a40f7   Hacene SI HADJ MOHAND   configureSauvaudAxis
635
			fixRange(lYAxisRange, lYAxis->_scale == Axis::Scale::LOGARITHMIC);
fbe3c2bb   Benjamin Renard   First commit
636

736a40f7   Hacene SI HADJ MOHAND   configureSauvaudAxis
637
			lYAxis->setRange(lYAxisRange);
fbe3c2bb   Benjamin Renard   First commit
638

0fa2d990   Erdogan Furkan   7616 - Adding lab...
639
640
			LOG4CXX_DEBUG(gLogger, "Y right axis range : min = " << lYAxisRange.getMin() << ", max = " << lYAxisRange.getMax());

736a40f7   Hacene SI HADJ MOHAND   configureSauvaudAxis
641
642
643
644
645
646
647
648
649
650
651
			Range lParamRange = lZAxis->Axis::getRange();
			if (isnan(lParamRange.getMin()) && isnan(lParamRange.getMax()))
			{
				std::string normalization = sauvaudPropertiesPtr->getNormalization();
				if (normalization == "log" || normalization == "linear")
				{
					lParamRange.setMin(0);
					lParamRange.setMax(1);
				}
				else
				{
0fa2d990   Erdogan Furkan   7616 - Adding lab...
652
					// auto range
736a40f7   Hacene SI HADJ MOHAND   configureSauvaudAxis
653
654
					for (auto index : sauvaudPropertiesPtr->getIndexes())
					{
0fa2d990   Erdogan Furkan   7616 - Adding lab...
655
						// compute global range for all indexes
736a40f7   Hacene SI HADJ MOHAND   configureSauvaudAxis
656
657
658
659
660
661
662
663
						double minVal, maxVal;
						if (lZAxis->_scale == Axis::Scale::LOGARITHMIC)
							minVal = (*_pParameterValues)[sauvaudPropertiesPtr->getParamId()].getMinStrictPos(index);
						else
							minVal = (*_pParameterValues)[sauvaudPropertiesPtr->getParamId()].getMin(index);
						maxVal = (*_pParameterValues)[sauvaudPropertiesPtr->getParamId()].getMax(index);
						if (!isnan(minVal))
							lParamRange.setMin(std::min(minVal, lParamRange.getMin()));
0fa2d990   Erdogan Furkan   7616 - Adding lab...
664
						// else
736a40f7   Hacene SI HADJ MOHAND   configureSauvaudAxis
665
666
667
						//	lParamRange.setMin(0);
						if (!isnan(maxVal))
							lParamRange.setMax(std::max(maxVal, lParamRange.getMax()));
0fa2d990   Erdogan Furkan   7616 - Adding lab...
668
						// else
736a40f7   Hacene SI HADJ MOHAND   configureSauvaudAxis
669
670
671
672
673
674
675
676
677
678
						//	lParamRange.setMax(10);
					}
					if (isnan(lParamRange.getMin()))
						lParamRange.setMin(0);
					if (isnan(lParamRange.getMax()))
						lParamRange.setMax(10);
				}
			}
			else
				lParamRange._extend = false;
fbe3c2bb   Benjamin Renard   First commit
679

736a40f7   Hacene SI HADJ MOHAND   configureSauvaudAxis
680
681
682
683
684
			//set z axis range
			fixRange(lParamRange, lZAxis->_scale == Axis::Scale::LOGARITHMIC);
			LOG4CXX_DEBUG(gLogger, "ZAxis range : ZMin = " << lParamRange.getMin() << ", ZMax = " << lParamRange.getMax());
			lZAxis->setRange(lParamRange);
		}
fbe3c2bb   Benjamin Renard   First commit
685
686
	}

fe6b6521   Menouard AZIB   J'ai ajouté le tr...
687
	/**
fbe3c2bb   Benjamin Renard   First commit
688
689
690
 * @brief Identify if other side of the plot area need to be drawn or not.
 * @note A plot area side need to be drawn when there is no axis associated to it.
 */
fe6b6521   Menouard AZIB   J'ai ajouté le tr...
691
692
693
694
695
	std::string TimePlot::drawOppositeSide(boost::shared_ptr<Axis> pAxis)
	{
		if (pAxis.get() == getTimeAxis() && getTimeAxis()->isOnlyTickmarks())
		{
			return "";
fbe3c2bb   Benjamin Renard   First commit
696
		}
fe6b6521   Menouard AZIB   J'ai ajouté le tr...
697
698
699
		else
		{
			return PanelPlotOutput::drawOppositeSide(pAxis);
fbe3c2bb   Benjamin Renard   First commit
700
		}
fbe3c2bb   Benjamin Renard   First commit
701
	}
fbe3c2bb   Benjamin Renard   First commit
702

fe6b6521   Menouard AZIB   J'ai ajouté le tr...
703
704
705
706
707
708
709
	void TimePlot::drawXAxis(boost::shared_ptr<Axis> pXAxis, PlWindow &pPlWindow, Bounds &pPlotAreaSize, TickConf &pTickConf)
	{
		LOG4CXX_DEBUG(gLogger, "Drawing X axis ");
		// draw main axis...
		PanelPlotOutput::drawXAxis(pXAxis, pPlWindow, pPlotAreaSize, pTickConf);
		// delegate to decorator any extra drawing stuff it needs to perform...
		getTimeAxisDecorator()->draw(this, getTimeAxis(), _pls);
fbe3c2bb   Benjamin Renard   First commit
710
711
	}

fe6b6521   Menouard AZIB   J'ai ajouté le tr...
712
713
714
715
	// Convert an X axis string value to a double X value assuming it's a DD_Time value
	double TimePlot::convertXAxisValue(const std::string &value)
	{
		return DD_Time2Double(value.c_str());
fbe3c2bb   Benjamin Renard   First commit
716
717
	}

fe6b6521   Menouard AZIB   J'ai ajouté le tr...
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
	ConstantLine *TimePlot::getConstantLineFromId(int serieId, int constantId, boost::shared_ptr<Axis> &yAxis)
	{
		for (auto parameter : _parameterAxesList)
		{
			for (auto serieProperties : parameter.getYSeriePropertiesList())
			{
				if ((serieProperties.getId() == serieId) && (serieProperties.hasYAxis() == true))
				{
					yAxis = _panel->getAxis(serieProperties.getYAxisId());
					for (auto constantLine : yAxis->_constantLines)
					{
						if (constantLine->getId() == constantId)
						{
							return constantLine.get();
						}
fbe3c2bb   Benjamin Renard   First commit
733
734
735
736
					}
				}
			}
		}
fbe3c2bb   Benjamin Renard   First commit
737

fe6b6521   Menouard AZIB   J'ai ajouté le tr...
738
739
740
741
742
743
		// ConstantId not found, we throw an exception
		std::stringstream lError;
		lError << "TimePlot::getConstantLineFromId : Unable to find constantId='" << constantId << "' for serieId='" << serieId << "'";
		BOOST_THROW_EXCEPTION(PanelPlotOutputException() << AMDA::ex_msg(lError.str()));
		return NULL;
	}
fbe3c2bb   Benjamin Renard   First commit
744

fe6b6521   Menouard AZIB   J'ai ajouté le tr...
745
746
747
748
749
750
751
752
753
754
755
	bool TimePlot::getSeriePropertiesById(int serieId, SeriesProperties &rSerieProperties)
	{
		for (auto parameter : _parameterAxesList)
		{
			for (auto serieProperties : parameter.getYSeriePropertiesList())
			{
				if (serieProperties.getId() == serieId)
				{
					rSerieProperties = serieProperties;
					return true;
				}
fbe3c2bb   Benjamin Renard   First commit
756
757
			}
		}
fbe3c2bb   Benjamin Renard   First commit
758

fe6b6521   Menouard AZIB   J'ai ajouté le tr...
759
760
		return false;
	}
fbe3c2bb   Benjamin Renard   First commit
761

fe6b6521   Menouard AZIB   J'ai ajouté le tr...
762
	void TimePlot::mergeAndSortTime(double *values1Time, int values1Nb,
fbe3c2bb   Benjamin Renard   First commit
763
									double *values2Time, int values2Nb,
fe6b6521   Menouard AZIB   J'ai ajouté le tr...
764
765
									std::vector<double> &valuesTime)
	{
fbe3c2bb   Benjamin Renard   First commit
766

fe6b6521   Menouard AZIB   J'ai ajouté le tr...
767
768
769
		// Build 2 vectors
		std::vector<double> v1(values1Time, values1Time + values1Nb);
		std::vector<double> v2(values2Time, values2Time + values2Nb);
fbe3c2bb   Benjamin Renard   First commit
770

fe6b6521   Menouard AZIB   J'ai ajouté le tr...
771
772
773
		// Populate resulting vector
		valuesTime.insert(valuesTime.end(), v1.begin(), v1.end());
		valuesTime.insert(valuesTime.end(), v2.begin(), v2.end());
fbe3c2bb   Benjamin Renard   First commit
774

fe6b6521   Menouard AZIB   J'ai ajouté le tr...
775
776
777
		// Sort and remove duplicates for the resulting vector
		sort(valuesTime.begin(), valuesTime.end());
		valuesTime.erase(unique(valuesTime.begin(), valuesTime.end()), valuesTime.end());
fbe3c2bb   Benjamin Renard   First commit
778
	}
fbe3c2bb   Benjamin Renard   First commit
779

fe6b6521   Menouard AZIB   J'ai ajouté le tr...
780
781
	double TimePlot::getInterpolatedValue(double *values, double *valuesTime, int valuesNb, double atTime)
	{
fbe3c2bb   Benjamin Renard   First commit
782

fe6b6521   Menouard AZIB   J'ai ajouté le tr...
783
784
785
786
		// get index of first time after given time_
		if (isnan(atTime))
		{
			return nan("");
fbe3c2bb   Benjamin Renard   First commit
787
788
		}

fe6b6521   Menouard AZIB   J'ai ajouté le tr...
789
790
791
792
793
794
795
796
		double *pTime = valuesTime;

		for (int t = 0; t < valuesNb; t++)
		{
			// No interpolation required
			if (*pTime == atTime)
			{
				return values[t];
fbe3c2bb   Benjamin Renard   First commit
797
			}
fe6b6521   Menouard AZIB   J'ai ajouté le tr...
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
			// Interpolation required
			if (*pTime >= atTime)
			{
				if (t == 0)
				{
					return nan("");
				}
				else
				{
					double v1 = values[t - 1];
					double v2 = values[t];
					double d1 = valuesTime[t - 1];
					double d2 = valuesTime[t];
					// Return a linear interpolation of the value for the index
					return (v1 + (v2 - v1) * (atTime - d1) / (d2 - d1));
				}
fbe3c2bb   Benjamin Renard   First commit
814
			}
fe6b6521   Menouard AZIB   J'ai ajouté le tr...
815
			pTime++;
fbe3c2bb   Benjamin Renard   First commit
816
		}
fe6b6521   Menouard AZIB   J'ai ajouté le tr...
817
		return nan("");
fbe3c2bb   Benjamin Renard   First commit
818
819
	}

fe6b6521   Menouard AZIB   J'ai ajouté le tr...
820
821
822
823
	bool TimePlot::intersect(double xi, double y1i, double y2i,
							 double xj, double y1j, double y2j,
							 double *xInter)
	{
fbe3c2bb   Benjamin Renard   First commit
824

fe6b6521   Menouard AZIB   J'ai ajouté le tr...
825
826
827
828
829
		// Simply checks if segment are above or below the other
		if (((y1i >= y2i) && (y1j >= y2j)) || ((y1i <= y2i) && (y1j <= y2j)))
		{
			return false;
		}
fbe3c2bb   Benjamin Renard   First commit
830

fe6b6521   Menouard AZIB   J'ai ajouté le tr...
831
832
833
834
		// Computes intersection point :
		// Compute a and b (y = a * x + b) for each segment
		double a1 = (y1j - y1i) / (xj - xi);
		double b1 = y1i - a1 * xi;
fbe3c2bb   Benjamin Renard   First commit
835

fe6b6521   Menouard AZIB   J'ai ajouté le tr...
836
837
		double a2 = (y2j - y2i) / (xj - xi);
		double b2 = y2i - a2 * xi;
fbe3c2bb   Benjamin Renard   First commit
838

fe6b6521   Menouard AZIB   J'ai ajouté le tr...
839
840
		// Compute intersection point (a1*x+b1 = a2*x+b2)
		*xInter = (b2 - b1) / (a1 - a2);
fbe3c2bb   Benjamin Renard   First commit
841

fe6b6521   Menouard AZIB   J'ai ajouté le tr...
842
843
		return true;
	}
fbe3c2bb   Benjamin Renard   First commit
844

fe6b6521   Menouard AZIB   J'ai ajouté le tr...
845
846
847
	void TimePlot::addIntersectionTime(double *values1, double *values1Time, int values1Nb,
									   double *values2, double *values2Time, int values2Nb,
									   std::vector<double> &valuesTime)
fbe3c2bb   Benjamin Renard   First commit
848
	{
fbe3c2bb   Benjamin Renard   First commit
849

fe6b6521   Menouard AZIB   J'ai ajouté le tr...
850
851
		if (valuesTime.empty() == true)
			return;
fbe3c2bb   Benjamin Renard   First commit
852

fe6b6521   Menouard AZIB   J'ai ajouté le tr...
853
854
		// For each time segment compute intersection if it exists
		std::vector<double> intersectionTime;
fbe3c2bb   Benjamin Renard   First commit
855

fe6b6521   Menouard AZIB   J'ai ajouté le tr...
856
857
858
		double xi = valuesTime[0];
		double y1i = getInterpolatedValue(values1, values1Time, values1Nb, xi);
		double y2i = getInterpolatedValue(values2, values2Time, values2Nb, xi);
fbe3c2bb   Benjamin Renard   First commit
859

fe6b6521   Menouard AZIB   J'ai ajouté le tr...
860
861
862
863
864
		for (size_t t = 1; t < valuesTime.size(); t++)
		{
			double xj = valuesTime[t];
			double y1j = getInterpolatedValue(values1, values1Time, values1Nb, xj);
			double y2j = getInterpolatedValue(values2, values2Time, values2Nb, xj);
fbe3c2bb   Benjamin Renard   First commit
865

fe6b6521   Menouard AZIB   J'ai ajouté le tr...
866
867
868
869
870
			double xInter;
			if (intersect(xi, y1i, y2i, xj, y1j, y2j, &xInter) == true)
			{
				intersectionTime.push_back(xInter);
			}
fbe3c2bb   Benjamin Renard   First commit
871

fe6b6521   Menouard AZIB   J'ai ajouté le tr...
872
873
874
875
876
			// Next vector element
			xi = xj;
			y1i = y1j;
			y2i = y2j;
		}
fbe3c2bb   Benjamin Renard   First commit
877

fe6b6521   Menouard AZIB   J'ai ajouté le tr...
878
879
		// Add intersections informations to the resulting values
		valuesTime.insert(valuesTime.end(), intersectionTime.begin(), intersectionTime.end());
fbe3c2bb   Benjamin Renard   First commit
880

fe6b6521   Menouard AZIB   J'ai ajouté le tr...
881
882
883
884
		// Sort and remove duplicates for the resulting vector
		sort(valuesTime.begin(), valuesTime.end());
		valuesTime.erase(unique(valuesTime.begin(), valuesTime.end()), valuesTime.end());
	}
fbe3c2bb   Benjamin Renard   First commit
885

fe6b6521   Menouard AZIB   J'ai ajouté le tr...
886
	void TimePlot::drawFillArea(double *values1, double *values1Time, int values1Nb,
fbe3c2bb   Benjamin Renard   First commit
887
888
								double *values2, double *values2Time, int values2Nb,
								std::vector<double> &valuesTime,
fe6b6521   Menouard AZIB   J'ai ajouté le tr...
889
890
891
892
893
894
895
								bool colorGreaterSpecified, Color &colorGreater,
								bool colorLessSpecified, Color &colorLess,
								SeriesProperties &rSeriesProperties)
	{
		// Get X and Y axis.
		boost::shared_ptr<Axis> lXAxis(_panel->getAxis(rSeriesProperties.getXAxisId()));
		boost::shared_ptr<Axis> lYAxis(_panel->getAxis(rSeriesProperties.getYAxisId()));
fbe3c2bb   Benjamin Renard   First commit
896

fe6b6521   Menouard AZIB   J'ai ajouté le tr...
897
898
		Range lXRange = getXAxisRange(rSeriesProperties, lXAxis);
		Range lYRange = getYAxisRange(rSeriesProperties, lYAxis);
fbe3c2bb   Benjamin Renard   First commit
899

fe6b6521   Menouard AZIB   J'ai ajouté le tr...
900
		_pls->wind(lXRange.getMin(), lXRange.getMax(), lYRange.getMin(), lYRange.getMax());
fbe3c2bb   Benjamin Renard   First commit
901

fe6b6521   Menouard AZIB   J'ai ajouté le tr...
902
903
904
		PLFLT x[4], y[4], deltai, deltaj;
		Color curColor;
		Color lInitialColor = changeColor(_pls, colorGreater, _panel->_page->_mode);
fbe3c2bb   Benjamin Renard   First commit
905

fe6b6521   Menouard AZIB   J'ai ajouté le tr...
906
		for (size_t i = 0; i < (valuesTime.size() - 1); i++)
fbe3c2bb   Benjamin Renard   First commit
907
		{
fe6b6521   Menouard AZIB   J'ai ajouté le tr...
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
			x[0] = valuesTime[i];
			x[1] = x[0];
			x[2] = valuesTime[i + 1];
			x[3] = x[2];

			y[0] = getInterpolatedValue(values1, values1Time, values1Nb, valuesTime[i]);
			y[1] = getInterpolatedValue(values2, values2Time, values2Nb, valuesTime[i]);
			y[2] = getInterpolatedValue(values2, values2Time, values2Nb, valuesTime[i + 1]);
			y[3] = getInterpolatedValue(values1, values1Time, values1Nb, valuesTime[i + 1]);

			deltai = y[1] - y[0];
			deltaj = y[2] - y[3];

			// Set fill color depending on segment position
			if (((deltai > 0) && (fabs(deltai) > fabs(deltaj))) ||
				((deltaj > 0) && (fabs(deltaj) > fabs(deltai))))
			{
				// s1 above s2
				if (colorGreaterSpecified == true)
				{
					curColor = colorGreater;
				}
				else
				{
					continue;
				}
fbe3c2bb   Benjamin Renard   First commit
934
			}
fe6b6521   Menouard AZIB   J'ai ajouté le tr...
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
			else if (((deltai < 0) && (fabs(deltai) > fabs(deltaj))) ||
					 ((deltaj < 0) && (fabs(deltaj) > fabs(deltai))))
			{
				// s1 under s2
				if (colorLessSpecified == true)
				{
					curColor = colorLess;
				}
				else
				{
					continue;
				}
			}
			else
			{
				// Colinear segments, no fill required
fbe3c2bb   Benjamin Renard   First commit
951
952
				continue;
			}
fbe3c2bb   Benjamin Renard   First commit
953

fe6b6521   Menouard AZIB   J'ai ajouté le tr...
954
955
956
			// Fill polygon using the given color
			changeColor(_pls, curColor, _panel->_page->_mode);
			_pls->fill(4, x, y);
fbe3c2bb   Benjamin Renard   First commit
957
958
		}

fe6b6521   Menouard AZIB   J'ai ajouté le tr...
959
960
961
		// Restore color.
		restoreColor(_pls, lInitialColor, _panel->_page->_mode);
	}
e7b3586a   Benjamin Renard   Fix fill between ...
962

fe6b6521   Menouard AZIB   J'ai ajouté le tr...
963
964
965
966
	void TimePlot::drawFills(double startDate, double stopDate)
	{
		PanelPlotOutput::drawFills(startDate, stopDate);
		LOG4CXX_DEBUG(gLogger, "TimePlot::drawFills");
e7b3586a   Benjamin Renard   Fix fill between ...
967

fe6b6521   Menouard AZIB   J'ai ajouté le tr...
968
		SeriesProperties rSeriesProperties;
fbe3c2bb   Benjamin Renard   First commit
969

fe6b6521   Menouard AZIB   J'ai ajouté le tr...
970
971
972
		double *values1 = NULL;
		double *values1Time = NULL;
		int values1Nb = 0;
fbe3c2bb   Benjamin Renard   First commit
973

fe6b6521   Menouard AZIB   J'ai ajouté le tr...
974
975
976
		double *values2 = NULL;
		double *values2Time = NULL;
		int values2Nb = 0;
fbe3c2bb   Benjamin Renard   First commit
977

fe6b6521   Menouard AZIB   J'ai ajouté le tr...
978
		std::vector<double> valuesTime;
e7b3586a   Benjamin Renard   Fix fill between ...
979

fe6b6521   Menouard AZIB   J'ai ajouté le tr...
980
981
		// Drawing Fill Area located between Serie and Constant (horizontal) line
		for (auto fillSerieConstant : _panel->_fillSerieConstants)
fbe3c2bb   Benjamin Renard   First commit
982
		{
fbe3c2bb   Benjamin Renard   First commit
983

fe6b6521   Menouard AZIB   J'ai ajouté le tr...
984
985
986
987
988
989
			// Retrieve serie parameter values for serieId
			if (!getSeriePropertiesById(fillSerieConstant->getSerieId(), rSeriesProperties))
			{
				LOG4CXX_DEBUG(gLogger, "TimePlot::drawFills - Cannot find serie id " << fillSerieConstant->getSerieId());
				continue;
			}
fbe3c2bb   Benjamin Renard   First commit
990

fe6b6521   Menouard AZIB   J'ai ajouté le tr...
991
992
993
994
995
996
997
			//get computed values for this serie and interval
			if (!getComputedValuesFromSerieAndInterval(startDate, stopDate, rSeriesProperties,
													   rSeriesProperties.getIndex(), &values1, &values1Time, values1Nb))
			{
				LOG4CXX_DEBUG(gLogger, "TimePlot::drawFills - Cannot get computed values for serie id " << fillSerieConstant->getSerieId());
				continue;
			}
fbe3c2bb   Benjamin Renard   First commit
998

fe6b6521   Menouard AZIB   J'ai ajouté le tr...
999
1000
1001
			// Retrieve constantLine informations for these fill
			boost::shared_ptr<Axis> yAxis;
			ConstantLine *constantLine = getConstantLineFromId(fillSerieConstant->getSerieId(), fillSerieConstant->getConstantId(), yAxis);
fbe3c2bb   Benjamin Renard   First commit
1002

fe6b6521   Menouard AZIB   J'ai ajouté le tr...
1003
			// Retrieve axis attachment
fbe3c2bb   Benjamin Renard   First commit
1004

fe6b6521   Menouard AZIB   J'ai ajouté le tr...
1005
1006
1007
			// Build values2 values2Time array with 2 values : yConst & (first time, last time) for serie
			values2 = new double[2];
			values2Time = new double[2];
fbe3c2bb   Benjamin Renard   First commit
1008

fe6b6521   Menouard AZIB   J'ai ajouté le tr...
1009
1010
			values2[0] = convertYAxisValue(constantLine->getValue());
			values2[1] = convertYAxisValue(constantLine->getValue());
fbe3c2bb   Benjamin Renard   First commit
1011

fe6b6521   Menouard AZIB   J'ai ajouté le tr...
1012
1013
1014
1015
1016
			if (yAxis->_scale == Axis::Scale::LOGARITHMIC)
			{
				values2[0] = log10(values2[0]);
				values2[1] = log10(values2[1]);
			}
fbe3c2bb   Benjamin Renard   First commit
1017

fe6b6521   Menouard AZIB   J'ai ajouté le tr...
1018
1019
			values2Time[0] = values1Time[0];
			values2Time[1] = values1Time[values1Nb - 1];
fbe3c2bb   Benjamin Renard   First commit
1020

fe6b6521   Menouard AZIB   J'ai ajouté le tr...
1021
			values2Nb = 2;
fbe3c2bb   Benjamin Renard   First commit
1022

fe6b6521   Menouard AZIB   J'ai ajouté le tr...
1023
1024
1025
1026
1027
1028
1029
			// Build time vector by merging existing times and computing intersections, and draw it !
			mergeAndSortTime(values1Time, values1Nb, values2Time, values2Nb, valuesTime);
			addIntersectionTime(values1, values1Time, values1Nb, values2, values2Time, values2Nb, valuesTime);
			drawFillArea(values1, values1Time, values1Nb, values2, values2Time, values2Nb, valuesTime,
						 fillSerieConstant->isColorGreaterSpecified(), fillSerieConstant->getColorGreater(),
						 fillSerieConstant->isColorLessSpecified(), fillSerieConstant->getColorLess(),
						 rSeriesProperties);
fbe3c2bb   Benjamin Renard   First commit
1030

fe6b6521   Menouard AZIB   J'ai ajouté le tr...
1031
1032
1033
			delete[] values1;
			delete[] values2;
			delete[] values2Time;
fbe3c2bb   Benjamin Renard   First commit
1034
1035
		}

fe6b6521   Menouard AZIB   J'ai ajouté le tr...
1036
1037
		// Drawing Fill Area located between first and second Serie
		for (auto fillSerieSerie : _panel->_fillSerieSeries)
fbe3c2bb   Benjamin Renard   First commit
1038
		{
fe6b6521   Menouard AZIB   J'ai ajouté le tr...
1039
1040
1041
1042
1043
1044
			// Retrieve serie parameter values for firstSerieId
			if (!getSeriePropertiesById(fillSerieSerie->getFirstSerieId(), rSeriesProperties))
			{
				LOG4CXX_DEBUG(gLogger, "TimePlot::drawFills - Cannot find serie id " << fillSerieSerie->getFirstSerieId());
				continue;
			}
fbe3c2bb   Benjamin Renard   First commit
1045

fe6b6521   Menouard AZIB   J'ai ajouté le tr...
1046
1047
1048
1049
1050
1051
1052
			//get computed values for this serie and interval
			if (!getComputedValuesFromSerieAndInterval(startDate, stopDate, rSeriesProperties,
													   rSeriesProperties.getIndex(), &values1, &values1Time, values1Nb))
			{
				LOG4CXX_DEBUG(gLogger, "TimePlot::drawFills - Cannot get computed values for serie id " << fillSerieSerie->getFirstSerieId());
				continue;
			}
fbe3c2bb   Benjamin Renard   First commit
1053

fe6b6521   Menouard AZIB   J'ai ajouté le tr...
1054
1055
1056
1057
1058
1059
			// Retrieve serie parameter values for secondSerieId
			if (!getSeriePropertiesById(fillSerieSerie->getSecondSerieId(), rSeriesProperties))
			{
				LOG4CXX_DEBUG(gLogger, "TimePlot::drawFills - Cannot find serie id " << fillSerieSerie->getSecondSerieId());
				continue;
			}
fbe3c2bb   Benjamin Renard   First commit
1060

fe6b6521   Menouard AZIB   J'ai ajouté le tr...
1061
1062
1063
1064
1065
1066
1067
			//get computed values for this serie and interval
			if (!getComputedValuesFromSerieAndInterval(startDate, stopDate, rSeriesProperties,
													   rSeriesProperties.getIndex(), &values2, &values2Time, values2Nb))
			{
				LOG4CXX_DEBUG(gLogger, "TimePlot::drawFills - Cannot get computed values for serie id " << fillSerieSerie->getSecondSerieId());
				continue;
			}
fbe3c2bb   Benjamin Renard   First commit
1068

fe6b6521   Menouard AZIB   J'ai ajouté le tr...
1069
1070
1071
1072
1073
1074
1075
			// Build time vector by merging existing times and computing intersections, and draw it !
			mergeAndSortTime(values1Time, values1Nb, values2Time, values2Nb, valuesTime);
			addIntersectionTime(values1, values1Time, values1Nb, values2, values2Time, values2Nb, valuesTime);
			drawFillArea(values1, values1Time, values1Nb, values2, values2Time, values2Nb, valuesTime,
						 fillSerieSerie->isColorGreaterSpecified(), fillSerieSerie->getColorGreater(),
						 fillSerieSerie->isColorLessSpecified(), fillSerieSerie->getColorLess(),
						 rSeriesProperties);
fbe3c2bb   Benjamin Renard   First commit
1076

fe6b6521   Menouard AZIB   J'ai ajouté le tr...
1077
1078
1079
			delete[] values1;
			delete[] values2;
		}
fbe3c2bb   Benjamin Renard   First commit
1080
1081
	}

fe6b6521   Menouard AZIB   J'ai ajouté le tr...
1082
1083
1084
1085
	void TimePlot::drawSeries(double startDate, double stopDate, int intervalIndex,
							  std::string pParamId, SeriesProperties &pSeries,
							  AMDA::Common::ParameterIndexComponent pParamIndex,
							  ParameterAxes &param, bool moreThanOneSerieForAxis)
fbe3c2bb   Benjamin Renard   First commit
1086
	{
fe6b6521   Menouard AZIB   J'ai ajouté le tr...
1087
1088
1089
		LOG4CXX_DEBUG(gLogger, "TimePlot::drawSeries - Drawing serie for parameter " << pParamId << "[" << pParamIndex.getDim1Index() << "," << pParamIndex.getDim2Index() << "]");
		// This will configure window, draw axes (if needed) and legend of axes.
		PanelPlotOutput::drawSeries(startDate, stopDate, intervalIndex, pParamId, pSeries, pParamIndex, param, moreThanOneSerieForAxis);
fbe3c2bb   Benjamin Renard   First commit
1090

fe6b6521   Menouard AZIB   J'ai ajouté le tr...
1091
1092
		if (!pSeries.hasYAxis())
			return;
fbe3c2bb   Benjamin Renard   First commit
1093

fe6b6521   Menouard AZIB   J'ai ajouté le tr...
1094
1095
1096
1097
		// Y axis may be missing (tickplot for example)
		std::string yAxisId = pSeries.getYAxisId();
		if (yAxisId.empty())
			return;
fbe3c2bb   Benjamin Renard   First commit
1098

fe6b6521   Menouard AZIB   J'ai ajouté le tr...
1099
1100
1101
1102
1103
1104
		//get computed values
		double *computedValues = NULL;
		double *timeValues = NULL;
		int nbValues;
		if (!getComputedValuesFromSerieAndInterval(startDate, stopDate, pSeries, pParamIndex,
												   &computedValues, &timeValues, nbValues))
fbe3c2bb   Benjamin Renard   First commit
1105
		{
fe6b6521   Menouard AZIB   J'ai ajouté le tr...
1106
			LOG4CXX_DEBUG(gLogger, "TimePlot::drawSeries - Cannot get computed values for serie");
fbe3c2bb   Benjamin Renard   First commit
1107
1108
			return;
		}
fbe3c2bb   Benjamin Renard   First commit
1109

fe6b6521   Menouard AZIB   J'ai ajouté le tr...
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
		double *coloredComputedValues = NULL;
		double *coloredTimeValues = NULL;
		//get colored value if needed
		if (!pSeries.getColorParamId().empty() && (_panel->getColorAxis() != nullptr))
		{
			int nbColoredValues;
			if (!getColoredComputedValuesFromSerieAndInterval(startDate, stopDate, pSeries,
															  &coloredComputedValues, &coloredTimeValues, nbColoredValues))
			{
				LOG4CXX_DEBUG(gLogger, "TimePlot::drawSeries - Cannot get computed values for colored parameter");
				return;
			}
		}

		PlWindow lPlWindow = PlWindow(getTimeAxis()->getRange().getMin(), getTimeAxis()->getRange().getMax(),
									  _panel->getAxis(yAxisId)->getRange().getMin(), _panel->getAxis(yAxisId)->getRange().getMax());
fbe3c2bb   Benjamin Renard   First commit
1126

fe6b6521   Menouard AZIB   J'ai ajouté le tr...
1127
1128
		_pls->wind(std::get<0>(lPlWindow), std::get<1>(lPlWindow),
				   std::get<2>(lPlWindow), std::get<3>(lPlWindow));
fbe3c2bb   Benjamin Renard   First commit
1129

fe6b6521   Menouard AZIB   J'ai ajouté le tr...
1130
1131
1132
		//draw serie
		Color lineColor = getSerieLineColor(pSeries, moreThanOneSerieForAxis);
		Color symbolColor = getSerieSymbolColor(pSeries, lineColor);
fbe3c2bb   Benjamin Renard   First commit
1133

fe6b6521   Menouard AZIB   J'ai ajouté le tr...
1134
1135
1136
1137
1138
		drawSymbols(
			pSeries.getSymbolProperties().getType(),
			pSeries.getSymbolProperties().getSize(), 1.,
			symbolColor,
			nbValues, timeValues, computedValues, coloredComputedValues);
fbe3c2bb   Benjamin Renard   First commit
1139

fe6b6521   Menouard AZIB   J'ai ajouté le tr...
1140
1141
1142
1143
1144
1145
		drawLines(
			pSeries.getLineProperties().getType(),
			pSeries.getLineProperties().getStyle(),
			pSeries.getLineProperties().getWidth(),
			lineColor,
			nbValues, timeValues, computedValues, coloredComputedValues);
fbe3c2bb   Benjamin Renard   First commit
1146

fe6b6521   Menouard AZIB   J'ai ajouté le tr...
1147
1148
		//add serie to param legend
		addSerieToParamsLegend(pSeries, pParamIndex, param._originalParamId, lineColor, symbolColor, startDate, stopDate, intervalIndex);
fbe3c2bb   Benjamin Renard   First commit
1149

fe6b6521   Menouard AZIB   J'ai ajouté le tr...
1150
1151
		//draw interval
		drawSerieInterval(pSeries, timeValues, computedValues, timeValues, nbValues, intervalIndex);
fbe3c2bb   Benjamin Renard   First commit
1152

fe6b6521   Menouard AZIB   J'ai ajouté le tr...
1153
1154
1155
		delete[] computedValues;
		if (coloredComputedValues != NULL)
			delete[] coloredComputedValues;
fbe3c2bb   Benjamin Renard   First commit
1156

fe6b6521   Menouard AZIB   J'ai ajouté le tr...
1157
1158
1159
		// Draw min/max error bars if required
		ErrorBarProperties &errorBarProp = pSeries.getErrorBarProperties();
		if (errorBarProp.getErrorMinMax() != nullptr)
fbe3c2bb   Benjamin Renard   First commit
1160
		{
fe6b6521   Menouard AZIB   J'ai ajouté le tr...
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
			//get computed min/max error data
			double *minComputedValues = NULL;
			double *minTimeValues = NULL;
			int nbMinValues;

			double *maxComputedValues = NULL;
			double *maxTimeValues = NULL;
			int nbMaxValues;

			if (!getErrorComputedValuesFromSerieAndInterval(startDate, stopDate, pSeries,
															&minComputedValues, &minTimeValues, nbMinValues,
															&maxComputedValues, &maxTimeValues, nbMaxValues))
			{
				LOG4CXX_DEBUG(gLogger, "TimePlot::drawSeries - Cannot get min/max error values for serie");
				return;
			}
fbe3c2bb   Benjamin Renard   First commit
1177

fe6b6521   Menouard AZIB   J'ai ajouté le tr...
1178
1179
			LineProperties &lineProps = pSeries.getErrorBarProperties().getLineProperties();
			drawYErrors(lineProps.getType(),
fbe3c2bb   Benjamin Renard   First commit
1180
1181
1182
1183
1184
1185
						lineProps.getStyle(),
						lineProps.getWidth(),
						lineProps.getColor(),
						nbMinValues, minTimeValues,
						minComputedValues, maxComputedValues);

fe6b6521   Menouard AZIB   J'ai ajouté le tr...
1186
1187
1188
1189
			// Free values
			delete[] minComputedValues;
			delete[] maxComputedValues;
		}
fbe3c2bb   Benjamin Renard   First commit
1190
	}
fbe3c2bb   Benjamin Renard   First commit
1191

fe6b6521   Menouard AZIB   J'ai ajouté le tr...
1192
1193
1194
1195
1196
	void TimePlot::drawSpectro(double startDate, double stopDate, std::string pParamId, SpectroProperties &pSpectro)
	{
		LOG4CXX_DEBUG(gLogger, "TimePlot::drawSpectro Drawing spectro for parameter " << pParamId);
		// This will configure window, draw axes (if needed) and legend of axes.
		PanelPlotOutput::drawSpectro(startDate, stopDate, pParamId, pSpectro);
fbe3c2bb   Benjamin Renard   First commit
1197

fe6b6521   Menouard AZIB   J'ai ajouté le tr...
1198
1199
		//get parameter data and info
		ParameterSPtr p = _parameterManager.getParameter(pParamId);
fbe3c2bb   Benjamin Renard   First commit
1200

fe6b6521   Menouard AZIB   J'ai ajouté le tr...
1201
		ParameterData &data = (*_pParameterValues)[pSpectro.getParamId()];
fbe3c2bb   Benjamin Renard   First commit
1202

fe6b6521   Menouard AZIB   J'ai ajouté le tr...
1203
1204
1205
1206
		boost::shared_ptr<AMDA::Info::ParamTable> tableSPtr;
		AMDA::Info::ParamInfoSPtr paramInfo = AMDA::Info::ParamMgr::getInstance()->getParamInfoFromId(p->getInfoId());
		if (paramInfo != nullptr)
			tableSPtr = paramInfo->getTable(pSpectro.getRelatedDim());
f3cd5351   Hacene SI HADJ MOHAND   us ok
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
                
                                        if (tableSPtr == nullptr){
                                            boost::shared_ptr<AMDA::Info::ParamTable> linkedTableSPtr;
                                            int counter = 0;
                                            // work on this 
                                            for (auto pInfo :paramInfo->getLinkedParamList()){
                                                linkedTableSPtr = AMDA::Info::ParamMgr::getInstance()->getParamInfoFromId(pInfo)->getTable(pSpectro.getRelatedDim());
                                                if (linkedTableSPtr == nullptr)
                                                    continue;
                                                counter ++;
                                            }
                                            if(linkedTableSPtr == nullptr || counter !=1){
                                                LOG4CXX_DEBUG(gLogger, "table cannot be defined from linked info params");
                                            }else{
                                                tableSPtr = linkedTableSPtr;
                                            }
                                        }                
fbe3c2bb   Benjamin Renard   First commit
1224

fe6b6521   Menouard AZIB   J'ai ajouté le tr...
1225
1226
1227
1228
		//get axis
		boost::shared_ptr<Axis> lXAxis = _panel->getAxis(pSpectro.getXAxisId());
		boost::shared_ptr<Axis> lYAxis = _panel->getAxis(pSpectro.getYAxisId());
		boost::shared_ptr<ColorAxis> lZAxis = _panel->getColorAxis();
fbe3c2bb   Benjamin Renard   First commit
1229

fe6b6521   Menouard AZIB   J'ai ajouté le tr...
1230
1231
		//Check dimensions
		if (pSpectro.getRelatedDim() == 0)
fbe3c2bb   Benjamin Renard   First commit
1232
		{
fe6b6521   Menouard AZIB   J'ai ajouté le tr...
1233
1234
1235
1236
1237
			if (data.getDim1Size() + 1 <= 0)
			{
				LOG4CXX_INFO(gLogger, "TimePlot::drawSpectro - No data to plot");
				return;
			}
fbe3c2bb   Benjamin Renard   First commit
1238
		}
fe6b6521   Menouard AZIB   J'ai ajouté le tr...
1239
		else
fbe3c2bb   Benjamin Renard   First commit
1240
		{
fe6b6521   Menouard AZIB   J'ai ajouté le tr...
1241
1242
1243
1244
1245
			if (data.getDim2Size() + 1 <= 0)
			{
				LOG4CXX_INFO(gLogger, "TimePlot::drawSpectro - No data to plot");
				return;
			}
fbe3c2bb   Benjamin Renard   First commit
1246
		}
fbe3c2bb   Benjamin Renard   First commit
1247

fe6b6521   Menouard AZIB   J'ai ajouté le tr...
1248
1249
		LOG4CXX_DEBUG(gLogger, "TimePlot::drawSpectro - Build data grid");
		MatrixGrid matrixGrid;
f2db3c16   Benjamin Renard   Support variable ...
1250

fe6b6521   Menouard AZIB   J'ai ajouté le tr...
1251
1252
1253
		//get specific colors for min / max values
		Color minValColor = lZAxis->getMinValColor();
		Color maxValColor = lZAxis->getMaxValColor();
2d64c235   Benjamin Renard   Fix bug with spec...
1254

fe6b6521   Menouard AZIB   J'ai ajouté le tr...
1255
		if ((tableSPtr == nullptr) || !tableSPtr->isVariable(&_parameterManager))
fbe3c2bb   Benjamin Renard   First commit
1256
		{
b0205fd9   Hacene SI HADJ MOHAND   plot ok reste que...
1257
			int startIndex; // index corresponding to startDate
fe6b6521   Menouard AZIB   J'ai ajouté le tr...
1258
1259
1260
			int nbValues;
			data.getIntervalBounds(startDate, stopDate, startIndex, nbValues);
			for (auto index : pSpectro.getIndexes())
fbe3c2bb   Benjamin Renard   First commit
1261
			{
fe6b6521   Menouard AZIB   J'ai ajouté le tr...
1262
1263
1264
1265
1266
1267
1268
1269
1270
				GridPart part;
				if (tableSPtr == nullptr)
				{
					if (pSpectro.getRelatedDim() == 0)
						part.y[0] = index.getDim1Index();
					else
						part.y[0] = index.getDim2Index();
					part.y[1] = part.y[0] + 1;
				}
f2db3c16   Benjamin Renard   Support variable ...
1271
				else
f2db3c16   Benjamin Renard   Support variable ...
1272
				{
fe6b6521   Menouard AZIB   J'ai ajouté le tr...
1273
1274
1275
1276
1277
1278
					AMDA::Info::t_TableBound crtBound;
					if (pSpectro.getRelatedDim() == 0)
						crtBound = tableSPtr->getBound(&_parameterManager, index.getDim1Index());
					else
						crtBound = tableSPtr->getBound(&_parameterManager, index.getDim2Index());
					if (std::isnan(crtBound.min) || std::isnan(crtBound.max))
ed9a1eaf   Benjamin Renard   Add Maven STATIC ...
1279
						continue;
fe6b6521   Menouard AZIB   J'ai ajouté le tr...
1280
1281
1282
1283
1284
1285
1286
1287
1288
					part.y[0] = crtBound.min;
					part.y[1] = crtBound.max;
					if (lYAxis->_scale == Axis::Scale::LOGARITHMIC)
					{
						if ((crtBound.min <= 0) || (crtBound.max <= 0))
							continue;
						part.y[0] = log10(part.y[0]);
						part.y[1] = log10(part.y[1]);
					}
f2db3c16   Benjamin Renard   Support variable ...
1289
				}
fbe3c2bb   Benjamin Renard   First commit
1290

fe6b6521   Menouard AZIB   J'ai ajouté le tr...
1291
1292
1293
1294
1295
1296
1297
				if (lYAxis->_reverse)
				{
					if (((part.y[0] < lYAxis->getRange().getMax()) && (part.y[1] < lYAxis->getRange().getMax())) ||
						((part.y[0] > lYAxis->getRange().getMin()) && (part.y[1] < lYAxis->getRange().getMin())))
					{
						continue;
					}
2d64c235   Benjamin Renard   Fix bug with spec...
1298
				}
fe6b6521   Menouard AZIB   J'ai ajouté le tr...
1299
1300
1301
1302
1303
1304
1305
				else
				{
					if (((part.y[0] < lYAxis->getRange().getMin()) && (part.y[1] < lYAxis->getRange().getMin())) ||
						((part.y[0] > lYAxis->getRange().getMax()) && (part.y[1] < lYAxis->getRange().getMax())))
					{
						continue;
					}
2d64c235   Benjamin Renard   Fix bug with spec...
1306
				}
2d64c235   Benjamin Renard   Fix bug with spec...
1307

fe6b6521   Menouard AZIB   J'ai ajouté le tr...
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
				for (int i = 0; i < nbValues - 1; ++i)
				{
					part.x[0] = data.getTimes()[startIndex + i];
					part.x[1] = data.getTimes()[startIndex + i + 1];
					part.isColorIndex = false;
					part.value = data.getValues(index, startIndex)[i];
					matrixGrid.push_back(part);
				}
				//Apply background subtraction
				applyBackgroundSubtraction(matrixGrid, pSpectro, data);
				//draw spectro
				LOG4CXX_DEBUG(gLogger, "TimePlot::drawSpectro - Draw data grid - " << matrixGrid.size());
				std::string normalization = pSpectro.getNormalization();
				if (!normalization.empty())
					normalize(matrixGrid, normalization);
				drawMatrix(matrixGrid, pSpectro.getMin(), pSpectro.getMax(),
						   minValColor, maxValColor, lZAxis->_color._colorMapIndex, pSpectro.getUseLog0AsMin());
				matrixGrid.clear();
			}
f2db3c16   Benjamin Renard   Support variable ...
1327
		}
fe6b6521   Menouard AZIB   J'ai ajouté le tr...
1328
		else
fbe3c2bb   Benjamin Renard   First commit
1329
		{
fe6b6521   Menouard AZIB   J'ai ajouté le tr...
1330
1331
1332
1333
1334
1335
1336
1337
			//Variable table
			AMDA::Info::t_TableBound crtBound;
			//for (auto index : pSpectro.getIndexes())
			//{
			int startIndex;
			int nbValues;
			data.getIntervalBounds(startDate, stopDate, startIndex, nbValues);
			for (int i = 0; i < nbValues - 1; ++i)
8c71f50a   Benjamin Renard   Improve execution...
1338
			{
fe6b6521   Menouard AZIB   J'ai ajouté le tr...
1339
1340
1341
1342
1343
1344
				GridPart part;
				part.x[0] = data.getTimes()[startIndex + i];
				part.x[1] = data.getTimes()[startIndex + i + 1];

				std::map<std::string, std::vector<double>> paramsTableData;
				for (std::map<std::string, std::string>::iterator it = pSpectro.getTableParams().begin(); it != pSpectro.getTableParams().end(); ++it)
f2db3c16   Benjamin Renard   Support variable ...
1345
				{
fe6b6521   Menouard AZIB   J'ai ajouté le tr...
1346
1347
1348
1349
1350
1351
1352
1353
					ParameterData &tableData = (*_pParameterValues)[it->second];
					std::vector<double> paramTableValues;
					for (int j = 0; j < tableData.getDim1Size(); ++j)
					{
						double *values = tableData.getValues(AMDA::Common::ParameterIndexComponent(j, -1), i);
						paramTableValues.push_back((*values));
					}
					paramsTableData[it->first] = paramTableValues;
f2db3c16   Benjamin Renard   Support variable ...
1354
				}
8c71f50a   Benjamin Renard   Improve execution...
1355

fe6b6521   Menouard AZIB   J'ai ajouté le tr...
1356
1357
1358
1359
				for (auto index : pSpectro.getIndexes())
				{
					part.isColorIndex = false;
					part.value = data.getValues(index, startIndex)[i];
f2db3c16   Benjamin Renard   Support variable ...
1360

fe6b6521   Menouard AZIB   J'ai ajouté le tr...
1361
1362
1363
1364
					if (pSpectro.getRelatedDim() == 0)
						crtBound = tableSPtr->getBound(&_parameterManager, index.getDim1Index(), &paramsTableData);
					else
						crtBound = tableSPtr->getBound(&_parameterManager, index.getDim2Index(), &paramsTableData);
f2db3c16   Benjamin Renard   Support variable ...
1365

fe6b6521   Menouard AZIB   J'ai ajouté le tr...
1366
1367
					part.y[0] = crtBound.min;
					part.y[1] = crtBound.max;
ed9a1eaf   Benjamin Renard   Add Maven STATIC ...
1368

fe6b6521   Menouard AZIB   J'ai ajouté le tr...
1369
					if (!std::isnan(crtBound.min) && !std::isnan(crtBound.max))
ed9a1eaf   Benjamin Renard   Add Maven STATIC ...
1370
					{
fe6b6521   Menouard AZIB   J'ai ajouté le tr...
1371
						if (lYAxis->_scale == Axis::Scale::LOGARITHMIC)
ed9a1eaf   Benjamin Renard   Add Maven STATIC ...
1372
						{
fe6b6521   Menouard AZIB   J'ai ajouté le tr...
1373
1374
1375
1376
1377
1378
							if ((crtBound.min > 0) && (crtBound.max > 0))
							{
								part.y[0] = log10(part.y[0]);
								part.y[1] = log10(part.y[1]);
								matrixGrid.push_back(part);
							}
ed9a1eaf   Benjamin Renard   Add Maven STATIC ...
1379
						}
fe6b6521   Menouard AZIB   J'ai ajouté le tr...
1380
1381
						else
							matrixGrid.push_back(part);
ed9a1eaf   Benjamin Renard   Add Maven STATIC ...
1382
					}
f2db3c16   Benjamin Renard   Support variable ...
1383
				}
fe6b6521   Menouard AZIB   J'ai ajouté le tr...
1384
1385
1386
1387
1388
1389
1390
1391
				//draw spectro
				LOG4CXX_DEBUG(gLogger, "TimePlot::drawSpectro - Draw data grid - " << matrixGrid.size());
				std::string normalization = pSpectro.getNormalization();
				if (!normalization.empty())
					normalize(matrixGrid, normalization);
				drawMatrix(matrixGrid, pSpectro.getMin(), pSpectro.getMax(),
						   minValColor, maxValColor, lZAxis->_color._colorMapIndex, pSpectro.getUseLog0AsMin());
				matrixGrid.clear();
f2db3c16   Benjamin Renard   Support variable ...
1392
			}
fbe3c2bb   Benjamin Renard   First commit
1393
1394
		}
	}
736a40f7   Hacene SI HADJ MOHAND   configureSauvaudAxis
1395
        
e1e55413   Hacene SI HADJ MOHAND   us ok
1396
        	void TimePlot::drawSauvaud(double startDate, double stopDate, std::string pParamId, SauvaudProperties &pSauvaud, int /*subIndex=0*/, int /*subsNumber=1*/, std::string /*opositeLegend*/)
736a40f7   Hacene SI HADJ MOHAND   configureSauvaudAxis
1397
1398
	{
		LOG4CXX_DEBUG(gLogger, "TimePlot::drawSauvaud Drawing sauvaud for parameter " << pParamId);
b0205fd9   Hacene SI HADJ MOHAND   plot ok reste que...
1399
1400
                
                                     
736a40f7   Hacene SI HADJ MOHAND   configureSauvaudAxis
1401
1402
1403
1404
1405

		//get parameter data and info
		ParameterSPtr p = _parameterManager.getParameter(pParamId);

		ParameterData &data = (*_pParameterValues)[pSauvaud.getParamId()];
b0205fd9   Hacene SI HADJ MOHAND   plot ok reste que...
1406
1407
1408
                                        int rightDim = pSauvaud.getRightDim();
                                        int leftDim   = (rightDim ==0) ? 1 :0;
                                        int rightDimSize =-1;
d924031c   Hacene SI HADJ MOHAND   progress
1409
1410
                                        int leftDimSize =-1;
                                        bool invertedTable = false;
b0205fd9   Hacene SI HADJ MOHAND   plot ok reste que...
1411
1412
1413
1414
1415
1416
1417
                                        if(rightDim ==0){
                                                rightDimSize = data.getDim1Size();
                                                leftDimSize = data.getDim2Size() ;
                                        }else{
                                                rightDimSize = data.getDim2Size() ;
                                                leftDimSize = data.getDim1Size() ;
                                        }
736a40f7   Hacene SI HADJ MOHAND   configureSauvaudAxis
1418

b0205fd9   Hacene SI HADJ MOHAND   plot ok reste que...
1419
1420
1421
1422
1423
                                        if (  rightDimSize < 0 && leftDimSize<0 )
                                        {
                                                LOG4CXX_INFO(gLogger, "TimePlot::drawSauvaud - No data to plot");
                                                return;
                                        }
5f13f59c   Hacene SI HADJ MOHAND   in progress worki...
1424
1425
		boost::shared_ptr<AMDA::Info::ParamTable> rightTableSPtr;
                                        boost::shared_ptr<AMDA::Info::ParamTable> leftTableSPtr;
736a40f7   Hacene SI HADJ MOHAND   configureSauvaudAxis
1426
		AMDA::Info::ParamInfoSPtr paramInfo = AMDA::Info::ParamMgr::getInstance()->getParamInfoFromId(p->getInfoId());
5f13f59c   Hacene SI HADJ MOHAND   in progress worki...
1427
		if (paramInfo != nullptr){
d924031c   Hacene SI HADJ MOHAND   progress
1428
1429
1430
			rightTableSPtr  = paramInfo->getTable(rightDim);
                                                            leftTableSPtr     = paramInfo->getTable(leftDim);
                                                            invertedTable   = leftTableSPtr->isInvertedOrder(&_parameterManager);
5f13f59c   Hacene SI HADJ MOHAND   in progress worki...
1431
1432
                                         }
                                
736a40f7   Hacene SI HADJ MOHAND   configureSauvaudAxis
1433
1434
1435
		//get axis
		boost::shared_ptr<Axis> lXAxis = _panel->getAxis(pSauvaud.getXAxisId());
		boost::shared_ptr<Axis> lYAxis = _panel->getAxis(pSauvaud.getYAxisId());
736a40f7   Hacene SI HADJ MOHAND   configureSauvaudAxis
1436
		boost::shared_ptr<ColorAxis> lZAxis = _panel->getColorAxis();
5f13f59c   Hacene SI HADJ MOHAND   in progress worki...
1437
                
b0205fd9   Hacene SI HADJ MOHAND   plot ok reste que...
1438
1439
1440
1441
                                        // Init data                 
                                        int startIndex; // index corresponding to startDate
                                        int nbValues;
                                        data.getIntervalBounds(startDate, stopDate, startIndex, nbValues);
5f13f59c   Hacene SI HADJ MOHAND   in progress worki...
1442

736a40f7   Hacene SI HADJ MOHAND   configureSauvaudAxis
1443
		LOG4CXX_DEBUG(gLogger, "TimePlot::drawSauvaud - Build data grid");
d924031c   Hacene SI HADJ MOHAND   progress
1444
1445
                
                                        int plotIndex; 
736a40f7   Hacene SI HADJ MOHAND   configureSauvaudAxis
1446

9aec59c6   Hacene SI HADJ MOHAND   inverted table in...
1447
                                        for(int spectroIndex =0; spectroIndex < leftDimSize; spectroIndex ++){
b0205fd9   Hacene SI HADJ MOHAND   plot ok reste que...
1448
1449
		// This will configure window, draw axes (if needed) and legend of axes.
                                            
9aec59c6   Hacene SI HADJ MOHAND   inverted table in...
1450
                                            plotIndex = (!invertedTable)? spectroIndex : leftDimSize-spectroIndex-1;
d924031c   Hacene SI HADJ MOHAND   progress
1451
                                            
b0205fd9   Hacene SI HADJ MOHAND   plot ok reste que...
1452
                                            // set left label for each sub-plot label table value or index  
b0205fd9   Hacene SI HADJ MOHAND   plot ok reste que...
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
1483
1484
1485
1486
1487
1488
1489
                                            std::string plotLabel = std::to_string(spectroIndex);
                                                       if ((leftTableSPtr == nullptr) || !leftTableSPtr->isVariable(&_parameterManager))
                                                        {
                                                            if ( leftTableSPtr== nullptr)
                                                                {
                                                                // nothing to do 
                                                            }else{
                                                                AMDA::Info::t_TableBound rightBound = leftTableSPtr->getBound(&_parameterManager, spectroIndex);
                                                                 if (!std::isnan(rightBound.min) && !std::isnan(rightBound.max)){
                                                                        double boundVal =  (rightBound.min + rightBound.max)/2;
                                                                        plotLabel = std::to_string((int)std::round(boundVal));
                                                                 }
                                                            }
                                                            }else{
                                                                            // variable
                                                                      for (int i = 0; i < nbValues - 1; ++i){
                                                                            std::map<std::string, std::vector<double>> paramsTableData;
                                                                            for (std::map<std::string, std::string>::iterator it = pSauvaud.getTableParams().begin(); it != pSauvaud.getTableParams().end(); ++it)
                                                                            {
                                                                                    ParameterData &tableData = (*_pParameterValues)[it->second];
                                                                                    std::vector<double> paramTableValues;
                                                                                    for (int j = 0; j < rightDimSize; ++j)
                                                                                    {
                                                                                            double *values = tableData.getValues(AMDA::Common::ParameterIndexComponent(j, -1), i);
                                                                                            paramTableValues.push_back((*values));
                                                                                    }
                                                                                    paramsTableData[it->first] = paramTableValues;
                                                                            }
                                                                          AMDA::Info::t_TableBound rightBound  = leftTableSPtr->getBound(&_parameterManager, spectroIndex, &paramsTableData);
                                                                          if (!std::isnan(rightBound.min) && !std::isnan(rightBound.max)){
                                                                                double boundVal =  (rightBound.min + rightBound.max)/2;
                                                                                plotLabel = std::to_string((int)std::round(boundVal));
                                                                            }
                                                                       }     
                                                             }
                                                    Label label(lYAxis->_legend.getFont(), lYAxis->_legend.getColor());
                                                    label._text = plotLabel;
e1e55413   Hacene SI HADJ MOHAND   us ok
1490
1491
1492
1493
1494
                                                    lYAxis->_legend.setLabel(label);
                                                    std::string opositeLabel ="";
                                                    if(spectroIndex == leftDimSize -1){
                                                            opositeLabel = "  "+rightTableSPtr ->getName(&_parameterManager);
                                                            opositeLabel = opositeLabel + "\n ["+rightTableSPtr ->getUnits(&_parameterManager)+"]";
d924031c   Hacene SI HADJ MOHAND   progress
1495
                                                            PanelPlotOutput::drawSauvaud(startDate, stopDate, pParamId, pSauvaud,plotIndex , leftDimSize, opositeLabel);
e1e55413   Hacene SI HADJ MOHAND   us ok
1496
                                                    }else{
d924031c   Hacene SI HADJ MOHAND   progress
1497
                                                            PanelPlotOutput::drawSauvaud(startDate, stopDate, pParamId, pSauvaud,plotIndex , leftDimSize, "");
e1e55413   Hacene SI HADJ MOHAND   us ok
1498
                                                    }
b0205fd9   Hacene SI HADJ MOHAND   plot ok reste que...
1499
                                                    
b0205fd9   Hacene SI HADJ MOHAND   plot ok reste que...
1500
                                                    
e1e55413   Hacene SI HADJ MOHAND   us ok
1501

b0205fd9   Hacene SI HADJ MOHAND   plot ok reste que...
1502
1503
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
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
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
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
                                                    MatrixGrid matrixGrid;
                                                    
                                                    		//get specific colors for min / max values
                                                Color minValColor = lZAxis->getMinValColor();
                                                Color maxValColor = lZAxis->getMaxValColor();

                                                if ((rightTableSPtr == nullptr) || !rightTableSPtr->isVariable(&_parameterManager))
                                                {

                                                        AMDA::Common::ParameterIndexComponentList indexes =  pSauvaud.getIndexesByIndex(spectroIndex, leftDim);
                                                        for (auto index : indexes) 
                                                        {
                                                                GridPart part;
                                                                if ( rightTableSPtr== nullptr)
                                                                {
                                                                        if (rightDim == 0)
                                                                                part.y[0] = index.getDim1Index();
                                                                        else
                                                                                part.y[0] = index.getDim2Index();
                                                                        part.y[1] = part.y[0] + 1;
                                                                }
                                                                else
                                                                {
                                                                        AMDA::Info::t_TableBound crtBound;
                                                                        if (rightDim == 0)
                                                                                crtBound = rightTableSPtr->getBound(&_parameterManager, index.getDim1Index());
                                                                        else
                                                                                crtBound = rightTableSPtr->getBound(&_parameterManager, index.getDim2Index());
                                                                        if (std::isnan(crtBound.min) || std::isnan(crtBound.max))
                                                                                continue;
                                                                        part.y[0] = crtBound.min;
                                                                        part.y[1] = crtBound.max;
                                                                        if (lYAxis->_scale == Axis::Scale::LOGARITHMIC)
                                                                        {
                                                                                if ((crtBound.min <= 0) || (crtBound.max <= 0))
                                                                                        continue;
                                                                                part.y[0] = log10(part.y[0]);
                                                                                part.y[1] = log10(part.y[1]);
                                                                        }
                                                                }

                                                                if (lYAxis->_reverse)
                                                                {
                                                                        if (((part.y[0] < lYAxis->getRange().getMax()) && (part.y[1] < lYAxis->getRange().getMax())) ||
                                                                                ((part.y[0] > lYAxis->getRange().getMin()) && (part.y[1] < lYAxis->getRange().getMin())))
                                                                        {
                                                                                continue;
                                                                        }
                                                                }
                                                                else
                                                                {
                                                                        if (((part.y[0] < lYAxis->getRange().getMin()) && (part.y[1] < lYAxis->getRange().getMin())) ||
                                                                                ((part.y[0] > lYAxis->getRange().getMax()) && (part.y[1] < lYAxis->getRange().getMax())))
                                                                        {
                                                                                continue;
                                                                        }
                                                                }

                                                                for (int i = 0; i < nbValues - 1; ++i)
                                                                {
                                                                        part.x[0] = data.getTimes()[startIndex + i];
                                                                        part.x[1] = data.getTimes()[startIndex + i + 1];
                                                                        part.isColorIndex = false;
                                                                        part.value = data.getValues(index, startIndex)[i];
                                                                        matrixGrid.push_back(part);
                                                                }
                                                        
                                                                //Apply background subtraction
                                                                applyBackgroundSubtraction(matrixGrid, pSauvaud, data);
                                                                //draw sauvaud
                                                                LOG4CXX_DEBUG(gLogger, "TimePlot::drawSauvaud - Draw data grid - " << matrixGrid.size());
                                                                std::string normalization = pSauvaud.getNormalization();
                                                                if (!normalization.empty())
                                                                        normalize(matrixGrid, normalization);
                                                                drawMatrix(matrixGrid, pSauvaud.getMin(), pSauvaud.getMax(),
                                                                                   minValColor, maxValColor, lZAxis->_color._colorMapIndex, pSauvaud.getUseLog0AsMin());
                                                                matrixGrid.clear();
                                                                }
                                                        
		          }else{
                                                            //Variable table
                                                            AMDA::Info::t_TableBound crtBound;
                                                            int startIndex;
                                                            int nbValues;
                                                            data.getIntervalBounds(startDate, stopDate, startIndex, nbValues);
                                                            for (int i = 0; i < nbValues - 1; ++i)
                                                            {
                                                                    GridPart part;
                                                                    part.x[0] = data.getTimes()[startIndex + i];
                                                                    part.x[1] = data.getTimes()[startIndex + i + 1];

                                                                    std::map<std::string, std::vector<double>> paramsTableData;
                                                                    for (std::map<std::string, std::string>::iterator it = pSauvaud.getTableParams().begin(); it != pSauvaud.getTableParams().end(); ++it)
                                                                    {
                                                                            ParameterData &tableData = (*_pParameterValues)[it->second];
                                                                            std::vector<double> paramTableValues;
                                                                            for (int j = 0; j < tableData.getDim1Size(); ++j)
                                                                            {
                                                                                    double *values = tableData.getValues(AMDA::Common::ParameterIndexComponent(j, -1), i);
                                                                                    paramTableValues.push_back((*values));
                                                                            }
                                                                            paramsTableData[it->first] = paramTableValues;
                                                                    }

                                                                    for (auto index : pSauvaud.getIndexesByIndex(spectroIndex, leftDim))
                                                                    {
                                                                            part.isColorIndex = false;
                                                                            part.value = data.getValues(index, startIndex)[i];

                                                                            if (rightDim == 0)
                                                                                    crtBound = rightTableSPtr->getBound(&_parameterManager, index.getDim1Index(), &paramsTableData);
                                                                            else
                                                                                    crtBound = rightTableSPtr->getBound(&_parameterManager, index.getDim2Index(), &paramsTableData);

                                                                            part.y[0] = crtBound.min;
                                                                            part.y[1] = crtBound.max;

                                                                            if (!std::isnan(crtBound.min) && !std::isnan(crtBound.max))
                                                                            {
                                                                                    if (lYAxis->_scale == Axis::Scale::LOGARITHMIC)
                                                                                    {
                                                                                            if ((crtBound.min > 0) && (crtBound.max > 0))
                                                                                            {
                                                                                                    part.y[0] = log10(part.y[0]);
                                                                                                    part.y[1] = log10(part.y[1]);
                                                                                                    matrixGrid.push_back(part);
                                                                                            }
                                                                                    }
                                                                                    else
                                                                                            matrixGrid.push_back(part);
                                                                            }
                                                                    
                                                                    //draw sauvaud
                                                                    LOG4CXX_DEBUG(gLogger, "TimePlot::drawSauvaud - Draw data grid - " << matrixGrid.size());
                                                                    std::string normalization = pSauvaud.getNormalization();
                                                                    if (!normalization.empty())
                                                                            normalize(matrixGrid, normalization);
                                                                    drawMatrix(matrixGrid, pSauvaud.getMin(), pSauvaud.getMax(),
                                                                                       minValColor, maxValColor, lZAxis->_color._colorMapIndex, pSauvaud.getUseLog0AsMin());
                                                                    matrixGrid.clear();
                                                            }
                                                 }                   
736a40f7   Hacene SI HADJ MOHAND   configureSauvaudAxis
1644
		}
b0205fd9   Hacene SI HADJ MOHAND   plot ok reste que...
1645
                                     }
9aec59c6   Hacene SI HADJ MOHAND   inverted table in...
1646
1647
1648
1649
1650
1651
1652
1653
1654
                                        // draw legend
                                        std::string plotLabel = "  "+leftTableSPtr ->getName(&_parameterManager);
                                        plotLabel = plotLabel + "\n ["+leftTableSPtr ->getUnits(&_parameterManager)+"]";
                                                
                                        Label label(lYAxis->_legend.getFont(), lYAxis->_legend.getColor());
                                        label._text = plotLabel;
                                        lYAxis->_legend.setLabel(label);
                                                   
                                        PanelPlotOutput::drawSauvaud(startDate, stopDate, pParamId, pSauvaud, leftDimSize, leftDimSize, "");
736a40f7   Hacene SI HADJ MOHAND   configureSauvaudAxis
1655
1656
1657
	}
        
        
fe6b6521   Menouard AZIB   J'ai ajouté le tr...
1658
1659
1660
1661
1662
1663

	void TimePlot::applyBackgroundSubtraction(MatrixGrid &matrixGrid, SpectroProperties &pSpectro, ParameterData &data)
	{
		//We get the background subtraction value given by the user
		const double backgroundSubValue = pSpectro.getBackgroundSubValue();

9e7f1f63   Menouard AZIB   Remplacer les str...
1664
1665
1666
		//If negative value then quit and do nothing
		if (backgroundSubValue < 0)
			return;
fe6b6521   Menouard AZIB   J'ai ajouté le tr...
1667
1668
1669

		const int len = matrixGrid.size();
		//Channel subtraction
9e7f1f63   Menouard AZIB   Remplacer les str...
1670
		if (pSpectro.getBackgroundSubType() == SpectroProperties::BackgroundSubType::BYCHANNEL)
fe6b6521   Menouard AZIB   J'ai ajouté le tr...
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
		{
			int indexChannelDim1 = -1;
			int indexChannelDim2 = -1;

			//The selected dimension of the background subtraction
			if (pSpectro.getBackgroundSubDim() == 0)
				indexChannelDim1 = (int)backgroundSubValue;
			else
				indexChannelDim2 = (int)backgroundSubValue;

			//Get the values which corresponds to the selected channel
			double *values = data.getValues(AMDA::Common::ParameterIndexComponent(indexChannelDim1, indexChannelDim2), 0);
			//Apply the subtraction
			for (int i = 0; i < len; i++)
				matrixGrid[i].value -= values[i];
		}
		//Fixed value substraction
9e7f1f63   Menouard AZIB   Remplacer les str...
1688
		else if (pSpectro.getBackgroundSubType() == SpectroProperties::BackgroundSubType::FIXEDVALUE)
fe6b6521   Menouard AZIB   J'ai ajouté le tr...
1689
1690
1691
1692
1693
1694
1695
1696
		{
			for (int i = 0; i < len; i++)
				matrixGrid[i].value -= backgroundSubValue;
		}
		else
		{
			std::stringstream lError;
			lError << "Unknown background substracion type "
9e7f1f63   Menouard AZIB   Remplacer les str...
1697
				   << pSpectro.getBackgroundSubType();
fe6b6521   Menouard AZIB   J'ai ajouté le tr...
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
1739
1740
1741
1742
1743
1744
1745
1746
1747
1748
1749
1750
1751
1752
1753
1754
1755
1756
1757
1758
1759
1760
1761
1762
1763
1764
1765
1766
1767
1768
1769
1770
1771
1772
1773
1774
1775
1776
1777
1778
			BOOST_THROW_EXCEPTION(PanelPlotOutputException() << AMDA::ex_msg(lError.str()));
		}

		return;
	}

	void TimePlot::normalize(MatrixGrid &matrixGrid, std::string normalizationType)
	{
		if (normalizationType == "none")
			return;
		double min = DBL_MAX;
		double max = DBL_MIN;
		int len = matrixGrid.size();
		if (normalizationType == "log")
		{
			for (auto val : matrixGrid)
			{
				if (val.value < min && val.value > 0)
					min = val.value;
				if (val.value > max)
					max = val.value;
			}
		}
		else
		{
			for (auto val : matrixGrid)
			{
				if (val.value < min)
					min = val.value;
				if (val.value > max)
					max = val.value;
			}
		}
		if (std::isnan(min) || std::isnan(max))
		{
			return;
		}
		else if (min == max)
		{
			for (int i = 0; i < len; i++)
				matrixGrid[i].value = matrixGrid[i].value / max;
		}
		else
		{
			if (normalizationType == "log")
			{
				for (int i = 0; i < len; i++)
					matrixGrid[i].value = (std::log10(matrixGrid[i].value) - std::log10(min)) / (std::log10(max) - std::log10(min));
				return;
			}
			else if (normalizationType == "linear")
			{
				for (int i = 0; i < len; i++)
					matrixGrid[i].value = (matrixGrid[i].value - min) / (max - min);
				return;
			}
			else
			{
				std::stringstream lError;
				lError << "Unknwon normalization " << normalizationType;
				BOOST_THROW_EXCEPTION(PanelPlotOutputException() << AMDA::ex_msg(lError.str()));
			}
		}
	}

	Color TimePlot::getStatusColor(AMDA::Info::ParamInfoSPtr &paramInfo, double value)
	{
		Color color;

		if ((paramInfo != nullptr) && !paramInfo->getStatusDef().empty())
		{
			for (int s = 0; s < (int)paramInfo->getStatusDef().size(); ++s)
			{
				if (value >= paramInfo->getStatusDef()[s].getMinValue() && value <= paramInfo->getStatusDef()[s].getMaxValue())
				{
					if (!paramInfo->getStatusDef()[s].getColor().empty())
					{
						std::string colorStr = paramInfo->getStatusDef()[s].getColor();
						createColor(color, colorStr);
						return color;
					}
677db865   Benjamin Renard   Draw intervals on...
1779
1780
1781
				}
			}
		}
fe6b6521   Menouard AZIB   J'ai ajouté le tr...
1782
1783

		return color;
677db865   Benjamin Renard   Draw intervals on...
1784
1785
	}

fe6b6521   Menouard AZIB   J'ai ajouté le tr...
1786
1787
1788
1789
1790
1791
	void TimePlot::drawOneInterval(double tmin, double tmax, Color color)
	{
		if (!color.isSet())
		{
			return;
		}
677db865   Benjamin Renard   Draw intervals on...
1792

fe6b6521   Menouard AZIB   J'ai ajouté le tr...
1793
1794
1795
1796
1797
1798
1799
1800
1801
1802
1803
1804
1805
1806
1807
1808
		//Fill interval
		PanelPlotOutput::drawRectangle(tmin, tmax, 0., 1., color, 0.25);

		//Draw borders
		PLFLT x[2], y[2];
		x[0] = tmin;
		y[0] = 0.;
		x[1] = tmin;
		y[1] = 1.;
		PanelPlotOutput::drawLines(LineType::LINE, LineStyle::PLAIN, 2, color, 2, x, y);

		x[0] = tmax;
		y[0] = 0.;
		x[1] = tmax;
		y[1] = 1.;
		PanelPlotOutput::drawLines(LineType::LINE, LineStyle::PLAIN, 2, color, 2, x, y);
677db865   Benjamin Renard   Draw intervals on...
1809
1810
	}

fe6b6521   Menouard AZIB   J'ai ajouté le tr...
1811
1812
1813
1814
1815
1816
	void TimePlot::drawIntervals(double startDate, double stopDate, std::string pParamId,
								 IntervalsProperties &pIntervals)
	{
		LOG4CXX_DEBUG(gLogger, "TimePlot::drawIntervals Drawing intervals for parameter " << pParamId);
		// This will configure window, draw axes (if needed) and legend of axes.
		PanelPlotOutput::drawIntervals(startDate, stopDate, pParamId, pIntervals);
e257cfb9   Benjamin Renard   First implementat...
1817

fe6b6521   Menouard AZIB   J'ai ajouté le tr...
1818
		PlWindow lPlWindow = PlWindow(getTimeAxis()->getRange().getMin(), getTimeAxis()->getRange().getMax(), 0, 1);
e257cfb9   Benjamin Renard   First implementat...
1819

fe6b6521   Menouard AZIB   J'ai ajouté le tr...
1820
1821
		_pls->wind(std::get<0>(lPlWindow), std::get<1>(lPlWindow),
				   std::get<2>(lPlWindow), std::get<3>(lPlWindow));
677db865   Benjamin Renard   Draw intervals on...
1822

fe6b6521   Menouard AZIB   J'ai ajouté le tr...
1823
		ParameterData &data = (*_pParameterValues)[pIntervals.getParamId()];
677db865   Benjamin Renard   Draw intervals on...
1824

fe6b6521   Menouard AZIB   J'ai ajouté le tr...
1825
1826
1827
1828
		ParameterSPtr p = _parameterManager.getParameter(pIntervals.getParamId());
		AMDA::Info::ParamInfoSPtr paramInfo = AMDA::Info::ParamMgr::getInstance()->getParamInfoFromId(p->getInfoId());

		//get computed values
17074cf0   Benjamin Renard   Merge amdadev int...
1829
		int startIndex, nbData = 0;
fe6b6521   Menouard AZIB   J'ai ajouté le tr...
1830
1831
1832
1833
1834
1835
1836
1837
1838
1839
1840
1841
1842
1843
1844
1845
1846
1847
1848
1849
1850
1851
1852
1853
1854
1855
		data.getIntervalBounds(startDate, stopDate, startIndex, nbData);

		Color crtColor;

		// Draw intervals
		double crtVal = NAN;
		double tmin = 0, tmax = 0;
		for (int i = 0; i < nbData - 1; ++i)
		{
			double t1 = data.getTimes()[startIndex + i];
			double t2 = data.getTimes()[startIndex + i + 1];
			double v = *data.getValues(AMDA::Common::ParameterIndexComponent(-1, -1), startIndex + i);

			if (isNAN(crtVal))
			{
				tmin = t1;
				tmax = t2;
				crtVal = v;
				continue;
			}
			else if (crtVal == v)
			{
				tmax = t2;
				continue;
			}

e803aecf   Erdogan Furkan   7616 - Adding mod...
1856
			crtColor = pIntervals.getColor();
fe6b6521   Menouard AZIB   J'ai ajouté le tr...
1857
1858
1859
1860
1861
1862
1863
1864
1865
1866
1867
1868

			drawOneInterval(tmin, tmax, crtColor);

			tmin = t1;
			tmax = t2;
			crtVal = v;
			crtColor = Color();
		}

		//Draw last interval if need
		if ((tmin != tmax) && !isNAN(crtVal))
		{
e803aecf   Erdogan Furkan   7616 - Adding mod...
1869
			crtColor = pIntervals.getColor();
fe6b6521   Menouard AZIB   J'ai ajouté le tr...
1870
1871
			drawOneInterval(tmin, tmax, crtColor);
		}
4de2b52c   Benjamin Renard   Fix some tests + ...
1872
	}
e257cfb9   Benjamin Renard   First implementat...
1873

fe6b6521   Menouard AZIB   J'ai ajouté le tr...
1874
	/**
fbe3c2bb   Benjamin Renard   First commit
1875
1876
 * @brief Draw further information (for instance start date).
 */
fe6b6521   Menouard AZIB   J'ai ajouté le tr...
1877
1878
1879
	void TimePlot::drawStartDate(TimeAxis *pXAxis, double startTime, double stopTime)
	{
		LOG4CXX_DEBUG(gLogger, "Drawing start date.");
fbe3c2bb   Benjamin Renard   First commit
1880

fe6b6521   Menouard AZIB   J'ai ajouté le tr...
1881
1882
		if (pXAxis->_showTickMark == false || !pXAxis->_drawn || !pXAxis->_visible)
			return;
fbe3c2bb   Benjamin Renard   First commit
1883

fe6b6521   Menouard AZIB   J'ai ajouté le tr...
1884
		// use panel font to draw start date.
fbe3c2bb   Benjamin Renard   First commit
1885

fe6b6521   Menouard AZIB   J'ai ajouté le tr...
1886
1887
		// If font of legend is not defined, use panel font.
		Font font(_panel->getFont());
fbe3c2bb   Benjamin Renard   First commit
1888

fe6b6521   Menouard AZIB   J'ai ajouté le tr...
1889
1890
1891
1892
1893
1894
1895
1896
1897
1898
1899
1900
1901
1902
1903
1904
1905
1906
1907
1908
1909
1910
1911
1912
1913
1914
1915
1916
1917
1918
1919
1920
1921
1922
1923
1924
1925
1926
1927
1928
1929
1930
1931
1932
1933
1934
1935
1936
1937
1938
1939
1940
1941
1942
1943
1944
1945
1946
1947
1948
1949
1950
		// PlPlotUtil::setPlFont(font);
		//CharSize charsize = PlPlotUtil::getCharacterSizeInPlPage(_panel->_page);
		// panel bounds.
		Bounds lPanelBounds(_panel->getBoundsInPlPage());

		// plotting area bounds (i.e. current viewport dimensions)
		PLFLT lXMin, lXMax, lYMin, lYMax;
		_pls->gvpd(lXMin, lXMax, lYMin, lYMax);

		// position of reference point of string along the bottom edge
		// expressed as a fraction of the length of the bottom edge
		// set it at the very beginning of edge and use justification to handle
		// reverse axis.
		float lPosition = 0.0;
		// display it one line above the main panel bottom border :
		float disp = -1;

		long int lTime = static_cast<long int>(startTime);
		tm *lTimeTm = gmtime(&lTime);
		char lTimeChr[80];

		// Format date.
		strftime(lTimeChr, 80,
				 getPlStartTimeFormat(pXAxis->_timeFormat,
									  startTime,
									  stopTime)
					 .c_str(),
				 lTimeTm);

		PLFLT mxmin, mxmax, mymin, mymax;
		plgspa(&mxmin, &mxmax, &mymin, &mymax);
		float x_subpage_per_mm = 1. / (mxmax - mxmin);

		LOG4CXX_DEBUG(gLogger, "Start date to draw : " << lTimeChr);

		// Set font
		PlPlotUtil::setPlFont(font);

		PLFLT dateWidthInMm;
		dateWidthInMm = plstrl(lTimeChr);

		// set viewport for start date :
		_pls->vpor(lXMin, lXMax, lPanelBounds._y, lPanelBounds._y + lPanelBounds._height);

		// Draw start date.
		if (pXAxis->_reverse)
		{
			lPosition = 1.;
			if (dateWidthInMm * x_subpage_per_mm > lPanelBounds._x + lPanelBounds._width - lXMax)
				lPosition = 1. - (dateWidthInMm * x_subpage_per_mm - (lPanelBounds._x + lPanelBounds._width - lXMax)) / (lXMax - lXMin);
			_pls->mtex("b", disp, lPosition, 0., lTimeChr);
		}
		else
		{
			lPosition = 0.;
			if (dateWidthInMm * x_subpage_per_mm > lXMin - lPanelBounds._x)
				lPosition = (dateWidthInMm * x_subpage_per_mm - lXMin + lPanelBounds._x) / (lXMax - lXMin);
			_pls->mtex("b", disp, lPosition, 1., lTimeChr);
		}

		// restore viewport :
		_pls->vpor(lXMin, lXMax, lYMin, lYMax);
fbe3c2bb   Benjamin Renard   First commit
1951
1952
	}

fe6b6521   Menouard AZIB   J'ai ajouté le tr...
1953
1954
1955
1956
1957
1958
1959
1960
1961
1962
1963
1964
1965
	const std::string TimePlot::getXAxisId() const
	{
		// time plot can manage only one x axis.
		// search for its id
		for (auto param : _parameterAxesList)
		{
			//search time axis in color serie if exist
			if (!param.getYSeriePropertiesList().empty())
				return param.getYSeriePropertiesList().begin()->getXAxisId();
			//search time axis in spectro if exist
			if (param.getSpectroProperties() != nullptr)
				return param.getSpectroProperties()->getXAxisId();
		}
fbe3c2bb   Benjamin Renard   First commit
1966

fe6b6521   Menouard AZIB   J'ai ajouté le tr...
1967
1968
		return DefaultPlotConfiguration::TIME_DEFAULT_ID;
	}
fbe3c2bb   Benjamin Renard   First commit
1969
1970

} /* namespace plot */