Blame view

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

#ifndef PANELPLOTOUTPUT_HH_
#define PANELPLOTOUTPUT_HH_

3cf11811   Menouard AZIB   FFT Validated and...
11
12
#include "ContextFileWriter.hh"
#include "Layout.hh"
fbe3c2bb   Benjamin Renard   First commit
13
#include "Panel.hh"
3cf11811   Menouard AZIB   FFT Validated and...
14
15
#include "PanelPlotOutputException.hh"
#include "ParamOutput.hh"
fbe3c2bb   Benjamin Renard   First commit
16
#include "ParameterAxes.hh"
fbe3c2bb   Benjamin Renard   First commit
17
#include "ParameterData.hh"
3cf11811   Menouard AZIB   FFT Validated and...
18
#include "PlotLogger.hh"
fbe3c2bb   Benjamin Renard   First commit
19
20
#include <AMDA_exception.hh>
#include <cxxabi.h>
3cf11811   Menouard AZIB   FFT Validated and...
21
22
#include <tuple>
#include <vector>
fbe3c2bb   Benjamin Renard   First commit
23
24
25

#include <cfloat>

3cf11811   Menouard AZIB   FFT Validated and...
26
27
namespace plot
{
fbe3c2bb   Benjamin Renard   First commit
28

3cf11811   Menouard AZIB   FFT Validated and...
29
30
31
32
33
34
35
36
37
38
	// 0 => xmin
	// 1 => xmax
	// 2 => ymin
	// 3 => ymax
	typedef std::tuple<double, double, double, double> PlWindow;
	// 0 => x major tick space
	// 1 => x minor tick number
	// 2 => y major tick space
	// 3 => y minor tick number
	typedef std::tuple<double, double, double, double> TickConf;
fbe3c2bb   Benjamin Renard   First commit
39
40

	/**
3cf11811   Menouard AZIB   FFT Validated and...
41
	 * Margin.
fbe3c2bb   Benjamin Renard   First commit
42
	 */
fbe3c2bb   Benjamin Renard   First commit
43
44
45
46
47
	virtual const std::string typeName() = 0;

	/**
	 * @brief Compute the initial plot area for the panel
	 */
9c833529   Menouard AZIB   Updates from develop
48
	virtual void preparePlotArea(double startTime, double stopTime, int intervalIndex);
fbe3c2bb   Benjamin Renard   First commit
49
50
51
52

	/**
	 * @brief Retrieve plot area bounds for the panel
	 */
9c833529   Menouard AZIB   Updates from develop
53
	virtual void getPlotAreaBounds(Bounds &plotAreaBounds);
fbe3c2bb   Benjamin Renard   First commit
54
55
56
57
58
59
60
61
62

	/**
	 * @brief Force the plot area horizontal position and width
	 */
	virtual void forcePlotAreaPosAndWidth(double plotAreaX, double plotAreaWidth);

	/**
	 * @brief Retrieve left axis tickMark width
	 */
9c833529   Menouard AZIB   Updates from develop
63
	virtual int getLeftAxisTickMarkWidth(void);
fbe3c2bb   Benjamin Renard   First commit
64
65
66
67
68
69
70
71
72

	/**
	 * @brief Force left axis tickmark width for the panel
	 */
	virtual void forceLeftAxisTickMarkWidth(int leftAxisTickMarkWidth);

	/**
	 * @brief draw the plot for the current time interval
	 */
d57f00dc   Benjamin Renard   Draw NO DATA
73
	virtual bool draw(double startTime, double stopTime, int intervalIndex, bool isFirstInterval, bool isLastInterval);
fbe3c2bb   Benjamin Renard   First commit
74

8499fbdd   Benjamin Renard   Context file gene...
75
76
77
	/**
	 * @brief Write plot context
	 */
11080d60   Erdogan Furkan   Previous/next but...
78
	virtual void writeContext(ContextFileWriter &writer, AMDA::Parameters::TimeIntervalList::iterator currentTimeInterval);
8499fbdd   Benjamin Renard   Context file gene...
79

fbe3c2bb   Benjamin Renard   First commit
80
81
82
	/*
	 * @brief Set a pointer to the time intervals list
	 */
1b52e70a   Erdogan Furkan   First Kernel modi...
83
	void setTimeIntervalListPtr(AMDA::Parameters::TimeIntervalList *timeIntervalListPtr);
fbe3c2bb   Benjamin Renard   First commit
84
85
86
87

	/**
	 * Sets PLplot stream to draw panel and plot
	 */
9c833529   Menouard AZIB   Updates from develop
88
	virtual void setPlStream(std::shared_ptr<plstream> &pls);
fbe3c2bb   Benjamin Renard   First commit
89
90
91
92

	/**
	 * Adds a parameter
	 */
9c833529   Menouard AZIB   Updates from develop
93
94
	virtual void addParam(const std::string &name)
	{
fbe3c2bb   Benjamin Renard   First commit
95
96
97
98
		ParameterAxes newParameter(name);
		_parameterAxesList.push_back(newParameter);
	}

9c833529   Menouard AZIB   Updates from develop
99
100
101
102
103
104
	virtual ParameterAxes &getParameter(const std::string &name)
	{
		for (ParameterAxes &param : _parameterAxesList)
		{
			if (param._originalParamId == name)
			{
fbe3c2bb   Benjamin Renard   First commit
105
106
107
108
109
110
111
112
				return param;
			}
		}
		ParameterAxes newParameter(name);
		_parameterAxesList.push_back(newParameter);
		return _parameterAxesList.back();
	}

fbe3c2bb   Benjamin Renard   First commit
113
114
115
	/*
	 * Create a sampled parameter from an original parameter and a sampling value
	 */
9c833529   Menouard AZIB   Updates from develop
116
	AMDA::Parameters::ParameterSPtr createSampledParameter(AMDA::Parameters::ParameterSPtr &originalParam, float samplingValue);
fbe3c2bb   Benjamin Renard   First commit
117
118
119
120

	/*
	 * Create a sampled parameter from an original parameter and a reference parameter for time definition
	 */
9c833529   Menouard AZIB   Updates from develop
121
122
	AMDA::Parameters::ParameterSPtr createSampledParameterUnderReferenceParameter(AMDA::Parameters::ParameterSPtr &originalParam,
																				  AMDA::Parameters::ParameterSPtr &refParam);
fbe3c2bb   Benjamin Renard   First commit
123
124
125
126
127
128

	/**
	 * Create parameters needed for this plot
	 * By default, the creation method create parameters for a time serie.
	 * Override it for other plot type
	 */
9c833529   Menouard AZIB   Updates from develop
129
	virtual void createParameters(std::list<std::string> &usedParametersId_);
fbe3c2bb   Benjamin Renard   First commit
130
131
132
133

	/**
	 * Get related ParameterAxes for a given color serie id
	 */
9c833529   Menouard AZIB   Updates from develop
134
	ParameterAxes *getParameterAxesByColorSerieId(int colorSerieId);
fbe3c2bb   Benjamin Renard   First commit
135
136

	/**
c46af5a8   Benjamin Renard   Implements multi ...
137
138
	 * Get related ParameterAxes for a given x serie id
	 */
9c833529   Menouard AZIB   Updates from develop
139
	ParameterAxes *getParameterAxesByXSerieId(int xSerieId);
c46af5a8   Benjamin Renard   Implements multi ...
140
141

	/**
fbe3c2bb   Benjamin Renard   First commit
142
143
144
145
146
147
148
149
150
151
	 * Gets sampling value from resolution (point-per-plot) according to
	 * the plot time interval and the base parameter sampling value.
	 */
	virtual double getCorrectedSamplingValue(int maxResolution, double samplingValue);

	/**
	 * @brief Get the list of indexes used for a parameter
	 */
	virtual std::vector<AMDA::Common::ParameterIndexComponent> getParamUsedIndexes(std::string paramId, int dim1Size, int dim2Size = -1);

9c833529   Menouard AZIB   Updates from develop
152
153
	const Margin getMargin()
	{
f6eaec4e   Benjamin Renard   Optimize plot ele...
154
		Bounds panelBounds(_panel->getBoundsInPlPage());
fbe3c2bb   Benjamin Renard   First commit
155
156
157
158
159
160
161
162
163
164
165
166

		Margin m;
		m._left = _plotAreaBounds._x - panelBounds._x;
		m._right = (panelBounds._x + panelBounds._width) - (_plotAreaBounds._x + _plotAreaBounds._width);
		m._top = (panelBounds._y + panelBounds._height) - (_plotAreaBounds._y + _plotAreaBounds._height);
		m._bottom = _plotAreaBounds._y - panelBounds._y;
		return m;
	}

	/**
	 * @brief reset plot
	 */
9c833529   Menouard AZIB   Updates from develop
167
168
	virtual void resetPlot()
	{
fbe3c2bb   Benjamin Renard   First commit
169
		if (_panel != nullptr)
20fef3b6   Benjamin Renard   Fix reset functio...
170
			_panel->resetPlot();
fbe3c2bb   Benjamin Renard   First commit
171
		_automaticSerieColorCursor = 0;
8bb0f02b   Benjamin Renard   Set colors in axi...
172
		_nbSeriesByYAxisMap.clear();
fbe3c2bb   Benjamin Renard   First commit
173
174
175
176
177
178
179
180
181
182
183
184
185
186
		_pls.reset();
	}

	/*
	 * @brief Set pointer to params values
	 */
	void setParameterValues(std::map<std::string, ParameterData> *pParameterValues);

	/*
	 * @brief Get computed values (in relation with the y axis definition) for a y serie, an index of the serie and a time interval
	 * Do not forget to delete (*computedValues) !!
	 * Do not delete (*timeValues), the buffer is not copied !!
	 */
	bool getComputedValuesFromSerieAndInterval(double startDate, double stopDate, SeriesProperties &rSeriesProperties,
9c833529   Menouard AZIB   Updates from develop
187
											   AMDA::Common::ParameterIndexComponent index, double **computedValues, double **timeValues, int &nbValues);
fbe3c2bb   Benjamin Renard   First commit
188
189
190
191
192
193
194

	/*
	 * @brief Get computed values (in relation with the color axis definition) for a color serie and a time interval
	 * Do not forget to delete computedValues !!
	 * Don't delete timeValues !!
	 */
	bool getColoredComputedValuesFromSerieAndInterval(double startDate, double stopDate, SeriesProperties &rSeriesProperties,
9c833529   Menouard AZIB   Updates from develop
195
													  double **computedValues, double **timeValues, int &nbValues);
fbe3c2bb   Benjamin Renard   First commit
196
197
198
199
200
201

	/*
	 * @brief Get computed values (in relation with the y axis definition) for a y serie and a time interval
	 * Do not forget to delete computedValues !!
	 * Don't delete timeValues !!
	 */
9c833529   Menouard AZIB   Updates from develop
202
203
204
205
	bool getErrorComputedValuesFromSerieAndInterval(double startDate, double stopDate, SeriesProperties &rSeriesProperties,
													AMDA::Common::ParameterIndexComponent &pParamIndex,
													double **minComputedValues, double **minTimeValues, int &nbMinValues,
													double **maxComputedValues, double **maxTimeValues, int &nbMaxValues);
fbe3c2bb   Benjamin Renard   First commit
206
207
208
209

	/**
	 *@brief Defines the layout constraint to be used for the panel when used within a layout
	 */
9c833529   Menouard AZIB   Updates from develop
210
211
	virtual PanelConstraint getLayoutConstraint(void)
	{
fbe3c2bb   Benjamin Renard   First commit
212
213
214
215
		return PanelConstraint::MaxWidth;
	}

	/**
8bb0f02b   Benjamin Renard   Set colors in axi...
216
217
	 * @brief Get nb series to draw by y axis
	 */
9c833529   Menouard AZIB   Updates from develop
218
	std::map<std::string, int> &getNbSeriesByYAxis();
8bb0f02b   Benjamin Renard   Set colors in axi...
219

9c833529   Menouard AZIB   Updates from develop
220
221
	/*
	 * @brief Return the color to draw the line of a serie
8bb0f02b   Benjamin Renard   Set colors in axi...
222
	 */
9c833529   Menouard AZIB   Updates from develop
223
	Color getSerieLineColor(SeriesProperties &rSeriesProperties, bool moreThanOneSerieForAxis);
8bb0f02b   Benjamin Renard   Set colors in axi...
224
225

	/**
fbe3c2bb   Benjamin Renard   First commit
226
227
228
229
230
231
232
233
234
235
236
237
238
	 * @brief Plot container
	 */
	boost::shared_ptr<Panel> _panel;

	/**
	 * @brief Parameters and series info
	 */
	ParameterAxesList _parameterAxesList;

	/*
	 * @brief Type used to define a matrix grid
	 */
	struct GridPart
fbe3c2bb   Benjamin Renard   First commit
239
	{
3cf11811   Menouard AZIB   FFT Validated and...
240
241
242
243
		double _left;
		double _right;
		double _top;
		double _bottom;
fbe3c2bb   Benjamin Renard   First commit
244
245
	};

3cf11811   Menouard AZIB   FFT Validated and...
246
	class PanelPlotOutput
793c4351   Hacene SI HADJ MOHAND   creation de class...
247
	{
3cf11811   Menouard AZIB   FFT Validated and...
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
	public:
		static const float DEFAULT_TICK_LENGTH_FACTOR;

		/**
		 * Width character proportion is approximatively 0.83 times smaller than height.
		 */
		static const float CHAR_RATIO;

		/**
		 * This two next attribute tell from which tick length plplot is insufficient to calculate space between tickmarks and ticks.
		 * Space between the two is static and can't be modified by user request.
		 * So when limit is reached we must bypass problem by setting two different viewport to let sufficient space between tickmarks and ticks.
		 */
		static const float VERTICAL_TICK_LENGTH_LIMIT;
		static const float HORIZONTAL_TICK_LENGTH_LIMIT;
		static const float YAXISMARGIN;

		PanelPlotOutput(AMDA::Parameters::ParameterManager &manager,
						boost::shared_ptr<Panel> panel, bool isStandalone = true);
		virtual ~PanelPlotOutput();

		/**
		 * type name. This name is used to identify nodes in xml config
		 * and xml request.
		 * @return
		 */
		virtual const std::string typeName() = 0;

		/**
		 * @brief Compute the initial plot area for the panel
		 */
		virtual void preparePlotArea(double startTime, double stopTime, int intervalIndex);

		/**
		 * @brief Retrieve plot area bounds for the panel
		 */
		virtual void getPlotAreaBounds(Bounds &plotAreaBounds);

		/**
		 * @brief Force the plot area horizontal position and width
		 */
		virtual void forcePlotAreaPosAndWidth(double plotAreaX, double plotAreaWidth);

		/**
		 * @brief Retrieve left axis tickMark width
		 */
		virtual int getLeftAxisTickMarkWidth(void);

		/**
		 * @brief Force left axis tickmark width for the panel
		 */
		virtual void forceLeftAxisTickMarkWidth(int leftAxisTickMarkWidth);

		/**
		 * @brief draw the plot for the current time interval
		 */
		virtual bool draw(double startTime, double stopTime, int intervalIndex, bool isFirstInterval, bool isLastInterval);

		/**
		 * @brief Write plot context
		 */
		virtual void writeContext(ContextFileWriter &writer, AMDA::Parameters::TimeIntervalList::iterator currentTimeInterval);

		/*
		 * @brief Set a pointer to the time intervals list
		 */
		void setTimeIntervalListPtr(AMDA::Parameters::TimeIntervalList *timeIntervalListPtr);

		/**
		 * Sets PLplot stream to draw panel and plot
		 */
		virtual void setPlStream(std::shared_ptr<plstream> &pls);

		/**
		 * Adds a parameter
		 */
		virtual void addParam(const std::string &name)
		{
			ParameterAxes newParameter(name);
			_parameterAxesList.push_back(newParameter);
		}
fbe3c2bb   Benjamin Renard   First commit
329

3cf11811   Menouard AZIB   FFT Validated and...
330
331
332
333
334
335
336
337
338
339
340
341
342
		virtual ParameterAxes &getParameter(const std::string &name)
		{
			for (ParameterAxes &param : _parameterAxesList)
			{
				if (param._originalParamId == name)
				{
					return param;
				}
			}
			ParameterAxes newParameter(name);
			_parameterAxesList.push_back(newParameter);
			return _parameterAxesList.back();
		}
fbe3c2bb   Benjamin Renard   First commit
343

3cf11811   Menouard AZIB   FFT Validated and...
344
345
346
		/*
		 * Create a sampled parameter from an original parameter and a sampling value
		 */
07bf1e7c   Menouard AZIB   EveryThing works ...
347
		AMDA::Parameters::ParameterSPtr createSampledParameter(AMDA::Parameters::ParameterSPtr &originalParam, float samplingValue, int gap = -1);
3cf11811   Menouard AZIB   FFT Validated and...
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393

		/*
		 * Create a sampled parameter from an original parameter and a reference parameter for time definition
		 */
		AMDA::Parameters::ParameterSPtr createSampledParameterUnderReferenceParameter(AMDA::Parameters::ParameterSPtr &originalParam,
																					  AMDA::Parameters::ParameterSPtr &refParam);

		/**
		 * Create parameters needed for this plot
		 * By default, the creation method create parameters for a time serie.
		 * Override it for other plot type
		 */
		virtual void createParameters(std::list<std::string> &usedParametersId_);

		/**
		 * Get related ParameterAxes for a given color serie id
		 */
		ParameterAxes *getParameterAxesByColorSerieId(int colorSerieId);

		/**
		 * Get related ParameterAxes for a given x serie id
		 */
		ParameterAxes *getParameterAxesByXSerieId(int xSerieId);

		/**
		 * Gets sampling value from resolution (point-per-plot) according to
		 * the plot time interval and the base parameter sampling value.
		 */
		virtual double getCorrectedSamplingValue(int maxResolution, double samplingValue);

		/**
		 * @brief Get the list of indexes used for a parameter
		 */
		virtual std::vector<AMDA::Common::ParameterIndexComponent> getParamUsedIndexes(std::string paramId, int dim1Size, int dim2Size = -1);

		const Margin getMargin()
		{
			Bounds panelBounds(_panel->getBoundsInPlPage());

			Margin m;
			m._left = _plotAreaBounds._x - panelBounds._x;
			m._right = (panelBounds._x + panelBounds._width) - (_plotAreaBounds._x + _plotAreaBounds._width);
			m._top = (panelBounds._y + panelBounds._height) - (_plotAreaBounds._y + _plotAreaBounds._height);
			m._bottom = _plotAreaBounds._y - panelBounds._y;
			return m;
		}
fbe3c2bb   Benjamin Renard   First commit
394

3cf11811   Menouard AZIB   FFT Validated and...
395
396
397
398
399
400
401
402
403
404
405
		/**
		 * @brief reset plot
		 */
		virtual void resetPlot()
		{
			if (_panel != nullptr)
				_panel->resetPlot();
			_automaticSerieColorCursor = 0;
			_nbSeriesByYAxisMap.clear();
			_pls.reset();
		}
337411e4   Erdogan Furkan   #5390 - Kernel pa...
406

3cf11811   Menouard AZIB   FFT Validated and...
407
408
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
		/*
		 * @brief Set pointer to params values
		 */
		void setParameterValues(std::map<std::string, ParameterData> *pParameterValues);

		/*
		 * @brief Get computed values (in relation with the y axis definition) for a y serie, an index of the serie and a time interval
		 * Do not forget to delete (*computedValues) !!
		 * Do not delete (*timeValues), the buffer is not copied !!
		 */
		bool getComputedValuesFromSerieAndInterval(double startDate, double stopDate, SeriesProperties &rSeriesProperties,
												   AMDA::Common::ParameterIndexComponent index, double **computedValues, double **timeValues, int &nbValues);

		/*
		 * @brief Get computed values (in relation with the color axis definition) for a color serie and a time interval
		 * Do not forget to delete computedValues !!
		 * Don't delete timeValues !!
		 */
		bool getColoredComputedValuesFromSerieAndInterval(double startDate, double stopDate, SeriesProperties &rSeriesProperties,
														  double **computedValues, double **timeValues, int &nbValues);

		/*
		 * @brief Get computed values (in relation with the y axis definition) for a y serie and a time interval
		 * Do not forget to delete computedValues !!
		 * Don't delete timeValues !!
		 */
		bool getErrorComputedValuesFromSerieAndInterval(double startDate, double stopDate, SeriesProperties &rSeriesProperties,
														double **minComputedValues, double **minTimeValues, int &nbMinValues,
														double **maxComputedValues, double **maxTimeValues, int &nbMaxValues);

		/**
		 *@brief Defines the layout constraint to be used for the panel when used within a layout
		 */
		virtual PanelConstraint getLayoutConstraint(void)
		{
			return PanelConstraint::MaxWidth;
		}
337411e4   Erdogan Furkan   #5390 - Kernel pa...
444

3cf11811   Menouard AZIB   FFT Validated and...
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
		/**
		 * @brief Get nb series to draw by y axis
		 */
		std::map<std::string, int> &getNbSeriesByYAxis();

		/*
		 * @brief Return the color to draw the line of a serie
		 */
		Color getSerieLineColor(SeriesProperties &rSeriesProperties, bool moreThanOneSerieForAxis);

		/**
		 * @brief Plot container
		 */
		boost::shared_ptr<Panel> _panel;

		/**
		 * @brief Parameters and series info
		 */
		ParameterAxesList _parameterAxesList;

		/*
		 * @brief Type used to define a matrix grid
		 */
		struct GridPart
		{
			double x[2];
			double y[2];
			double value;
			double isColorIndex;
		};

		typedef std::vector<GridPart> MatrixGrid;

		// datastore for sauvaud plot
		struct SauvaudPart
		{
			double x[2];
			double y[2];
			std::vector<double> value;
			double isColorIndex;
		};

		typedef std::vector<SauvaudPart> SauvaudGrid;

		/*
		 * @brief Draw a matrix
		 */
		void drawMatrix(MatrixGrid &matrixGrid, double minDataVal, double maxDataVal,
						Color minValColor, Color maxValColor, int colorMapIndex, bool useLog0AsMin = false);

		void draw2DMatrix(SauvaudGrid &sauvaudGrid, double minDataVal, double maxDataVal,
						  Color minValColor, Color maxValColor, int colorMapIndex, bool useLog0AsMin = false);

		/**
		 * @brief Reset cursor used to attribute automatically a color to a serie
		 */
		void resetAutomaticSerieColorCursor()
		{
			_automaticSerieColorCursor = 0;
		}
fbe3c2bb   Benjamin Renard   First commit
505

3cf11811   Menouard AZIB   FFT Validated and...
506
507
508
509
		/**
		 * Draw a rectangle
		 */
		void drawRectangle(double xmin, double xmax, double ymin, double ymax, Color &pColor, double alpha = 1.);
fbe3c2bb   Benjamin Renard   First commit
510

3cf11811   Menouard AZIB   FFT Validated and...
511
512
513
514
		bool isStandalone()
		{
			return _isStandalone;
		}
fbe3c2bb   Benjamin Renard   First commit
515

3cf11811   Menouard AZIB   FFT Validated and...
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
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
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
		AMDA::Parameters::ParameterManager &_parameterManager;

		std::map<std::string, ParameterData> *_pParameterValues;

	protected:
		AMDA::Parameters::TimeIntervalList *_timeIntervalListPtr;

		/**
		 * @brief Compute plot area.
		 * @note If ratio need to be kept, ratio will be kept between width and height.
		 * @param bounds_ plot area bounds. It is updated by this method.
		 */
		virtual void calculatePlotArea(const Bounds &panelBounds_, Bounds &bounds_);

		/**
		 *@brief computes Panel Plot XY ratio
		 */
		void computePanelPlotXYRatio(void);

		/**
		 * @brief Get colored value associated to a data value. Return false if the value is filtered.
		 */
		bool getColoredValue(double value, double filterMin, double filterMax, bool useLog0AsMin, PLFLT &col);

		/**
		 *@brief Draw fill area between parameter and constant or between parameters
		 */
		virtual void drawFills(double startDate, double stopDate);

		/**
		 * Draw list of symbols
		 */
		void drawSymbols(SymbolType pType, int pSize, double pFactor, Color pColor,
						 int pNbData, double *pXData, double *pYData,
						 double *pZData = NULL, double filterZMin = -DBL_MAX, double filterZMax = DBL_MAX);

		/**
		 * Draw list of lines
		 */
		void drawLines(LineType pType, LineStyle pStyle, int pWidth, Color &pColor,
					   int pNbData, double *pXData, double *pYData,
					   double *pZData = NULL, double filterZMin = -DBL_MAX, double filterZMax = DBL_MAX);

		/**
		 * Draw errors segments
		 */
		void drawYErrors(LineType pType, LineStyle pStyle, int pWidth, Color &pColor,
						 int pNbData, double *pXData, double *pYMinData, double *pYMaxData);

		/**
		 *@brief Draw the serie of a parameter component on plot.
		 */
		virtual void drawSeries(double startDate, double stopDate, int intervalIndex, std::string pParamId, SeriesProperties &pSeries,
								AMDA::Common::ParameterIndexComponent pParamIndex, ParameterAxes &param, bool moreThanOneSerieForAxis);

		/**
		 *@brief Draw the spectro of a parameter on plot.
		 */
		virtual void drawSpectro(double startDate, double stopDate, std::string pParamId,
								 SpectroProperties &pSpectro);

		/**
		 *@brief Draw sauvaud plot of a parameter on plot.
		 */
		virtual void drawSauvaud(double startDate, double stopDate, std::string pParamId,
								 SauvaudProperties &pSauvaud, int subIndex, int subsNumber, std::string opositeLegend);

		virtual void drawIntervals(double startDate, double stopDate, std::string pParamId,
								   IntervalsProperties &pIntervals);

		/*
		 * @brief Draw interval
		 */
		virtual void drawSerieInterval(SeriesProperties &pSeries,
									   double *xValues, double *yValues, double *timeValues,
									   int nbValues, int intervalIndex);

		/**
		 * Draw an horizontal axis.
		 * Subclasses may override it to take into account decorator attached to that axis (for instance).
		 * @param pXAxis axis to draw.
		 * @param pPlWindow real word ranges.
		 * @param pPlotAreaSize plot ranges.
		 * @param pTickConf ticks configuration.
		 */
		virtual void drawXAxis(boost::shared_ptr<Axis> pXAxis, PlWindow &pPlWindow, Bounds &pPlotAreaSize, TickConf &pTickConf);
		/**
		 * Draw a vertical axis.
		 * Subclasses may override it to take into account decorator attached to that axis (for instance).
		 * @param pXAxis axis to draw.
		 * @param pPlWindow real word ranges.
		 * @param pPlotAreaSize plot ranges.
		 * @param pTickConf ticks configuration.
		 */
		virtual void drawYAxis(boost::shared_ptr<Axis> pXAxis, PlWindow &pPlWindow, Bounds &pPlotAreaSize, TickConf &pTickConf);
		/**
		 * @brief Draw legend for each axis.
		 * @param pAxis axis to draw.
		 * @param pPlWindow real word ranges.
		 * @param pPlotAreaSize plot ranges.
		 */
		virtual void drawLegends(boost::shared_ptr<Axis> &pAxis, PlWindow &pPlWindow, Bounds &pPlotAreaSize);

		/**
		 * @brief Draw parameters legend.
		 */
		virtual void drawParamsLegend(void);

		/**
		 * @brief Draw text legends.
		 */
		virtual void drawTextLegends(void);

		/**
		 * Convert an X axis string value to a double X value
		 * Subclasses may override it to take into account specific value meaning.
		 * @param value string value to convert.
		 */
		virtual double convertXAxisValue(const std::string &value);

		/**
		 * Convert an Y axis string value to a double Y value
		 * Subclasses may override it to take into account specific value meaning.
		 * @param value string value to convert.
		 */
		virtual double convertYAxisValue(const std::string &value);

		/**
		 * Draw X constant lines linked to an axis.
		 * Subclasses may override it to take into account decorator attached (for instance).
		 * @param pXAxis axis to draw.
		 * @param pPlWindow real word ranges.
		 */
		virtual void drawXConstantLines(boost::shared_ptr<Axis> pAxis, PlWindow &pPlWindow);
		/**
		 * Draw X constant lines linked to an axis.
		 * Subclasses may override it to take into account decorator attached (for instance).
		 * @param pXAxis axis to draw.
		 * @param pPlWindow real word ranges.
		 */
		virtual void drawYConstantLines(boost::shared_ptr<Axis> pAxis, PlWindow &pPlWindow);
		/**
		 * Draw textPlots for a panel.
		 * Subclasses may override it for specific drawings.
		 * @param pPlWindow real word ranges.
		 */
		virtual void drawTextPlots(boost::shared_ptr<Axis> pXAxis, boost::shared_ptr<Axis> pYAxis, PlWindow &pPlWindow, const TextPlots &textPlots);

		/**
		 * Draw curvePlot for a panel.
		 * Subclasses may override it for specific drawings.
		 * @param curvePlot curve properties.
		 */
		virtual void drawCurvePlot(CurvePlot &curvePlot);

		/**
		 * @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.
		 */
		virtual std::string drawOppositeSide(boost::shared_ptr<Axis> pAxis);

		/**
		 *@brief Draw additional objects on plot.
		 */
		virtual void drawAdditionalObjects();

		/**
		 * Draw a z axis
		 */
		virtual void drawZAxis(boost::shared_ptr<Axis> pZAxis, PlWindow &pPlWindow, Bounds &pPlotAreaSize, TickConf &pTickConf);

		/**
		 * Get X Axis range for a serie
		 */
		Range getXAxisRange(SeriesProperties &pSeries, boost::shared_ptr<Axis> pAxis);

		/**
		 * Get Y Axis range for a serie
		 */
		Range getYAxisRange(SeriesProperties &pSeries, boost::shared_ptr<Axis> pAxis);

		/**
		 * Get Z Axis range for a serie
		 */
		Range getZAxisRange(SeriesProperties &pSeries, boost::shared_ptr<Axis> pAxis);

		/*
		 * @brief Return the color to draw the symbols of a serie
		 */
		Color getSerieSymbolColor(SeriesProperties &rSeriesProperties, Color &pLineColor);

		/**
		 * @brief Configure params legend for a plot.
		 */
		virtual void configureParamsLegend(double startTime, double stopTime, int intervalIndex);

		/**
		 * @brief Add a serie to the param legend
		 */
		void addSerieToParamsLegend(SeriesProperties &lSeriesProperties,
									AMDA::Common::ParameterIndexComponent &index, std::string originalParamId,
									Color &lineColor, Color &symbolColor,
									double startTime, double stopTime, int intervalIndex);

		/*
		 * @brief Return the associated params legend to a serie
		 */
		virtual std::string getSerieParamsLegendString(SeriesProperties &rSeriesProperties,
													   AMDA::Common::ParameterIndexComponent &index, std::string originalParamId);

		/**
		 * @brief plplot stream
		 */
		std::shared_ptr<plstream> _pls;

		/*
		 * Dumps properties for test.
		 */
		virtual void dump(std::ostream &out_);

		/**
		 * @brief Fill the background of the plot area
		 *
		 * @param pls
		 */

		void fillBackground(std::shared_ptr<plstream> &pls);

	private:
		void drawAxis(boost::shared_ptr<Axis> pAxis, TickConf &pTickConf, std::string pXAxisOptions,
					  std::string pYAxisOptions);

		double estimateZAxisWidth(boost::shared_ptr<Axis> pZAxis);

		/**
		 * @brief _plotAreaSideSet Store which side of plot area is linked to an axis.
		 */
		std::map<PlotCommon::Position, bool> _plotAreaSideSet;

		/**
		 * @brief nb series to draw by y axis
		 */
		std::map<std::string, int> _nbSeriesByYAxisMap;

		/**
		 * @brief plot array on which to draw data.
		 */
		Bounds _plotAreaBounds;

		/*
		 * @brief Panel XY ratio used for angular conversion
		 */
		double _panelPlotXYRatio;

		/*
		 * @brief Panel left axis tickmark width
		 */
		double _leftAxisTickMarkWidth;

		/*
		 * @brief cursor use to set a default color to a serie
		 */
		int _automaticSerieColorCursor;

		/*
		 *
		 */
		bool _isStandalone;

		void reserveSpaceForAxis(boost::shared_ptr<Axis> &pAxis, double titleHeight, std::map<PlotCommon::Position, int> nbAxesBySide,
								 double &topSpace, double &bottomSpace, double &leftSpace, double &rightSpace);

		void reserveSpaceForTextLegend(boost::shared_ptr<TextLegendProperties> &pTextLegendProp, double titleHeight, double &topSpace, double &bottomSpace, double &leftSpace, double &rightSpace);
	};
fbe3c2bb   Benjamin Renard   First commit
790
791

	/**
3cf11811   Menouard AZIB   FFT Validated and...
792
	 * Calculate room taken by tick.
8bb0f02b   Benjamin Renard   Set colors in axi...
793
	 */
3cf11811   Menouard AZIB   FFT Validated and...
794
	double getHorizontalTickLength(Axis *pAxis, double charHeight);
8bb0f02b   Benjamin Renard   Set colors in axi...
795
796

	/**
3cf11811   Menouard AZIB   FFT Validated and...
797
	 * Calculate room taken by tick.
fbe3c2bb   Benjamin Renard   First commit
798
	 */
3cf11811   Menouard AZIB   FFT Validated and...
799
	double getVerticalTickLength(Axis *pAxis, double charHeight);
fbe3c2bb   Benjamin Renard   First commit
800
801
802

} /* namespace plot */
#endif /* PANELPLOTOUTPUT_HH_ */