Blame view

src/ParamOutputImpl/Plot/Time/TimePlot.hh 6.22 KB
fbe3c2bb   Benjamin Renard   First commit
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
/*
 * TimePlot.hh
 *
 *  Created on: 22 nov. 2013
 *      Author: CS
 */

#ifndef TIMEPLOT_HH_
#define TIMEPLOT_HH_

#include "PanelPlotOutput.hh"
#include "NodeCfg.hh"

#include <algorithm>
#include <map>
#include <memory>

#include "DefaultTimeAxisDecorator.hh"


#include "TimeAxisDecorator.hh"

#include "TimePlotNode.hh"

677db865   Benjamin Renard   Draw intervals on...
25
26
#include "ParamInfo.hh"

fbe3c2bb   Benjamin Renard   First commit
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
extern "C" {
#include <plplot/qsastime.h>
}

namespace plot {

class TimeAxis;

/**
 * Plot that draws f(t)
 */
class TimePlot: public PanelPlotOutput {
public:

	TimePlot(AMDA::Parameters::ParameterManager& manager,
8c860e4f   Benjamin Renard   Rework for tickpl...
42
			boost::shared_ptr<Panel> panel, TimeAxisDecorator* timeAxisDecorator = new DefaultTimeAxisDecorator(), bool isStandalone = true);
fbe3c2bb   Benjamin Renard   First commit
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
	virtual ~TimePlot();
	/**
	 * @overload plot::PanelPlotOutput
	 */
	virtual const std::string typeName(){
		return TIMEPLOT_NODENAME;
	}

	/**
	 * @brief overloads ParamOutput::preparePlotArea
	 */
	virtual void preparePlotArea (double startTime, double stopTime, int intervalIndex);

	/**
	 * @brief overloads ParamOutput::draw()
	 */
d57f00dc   Benjamin Renard   Draw NO DATA
59
	virtual bool draw(double startTime, double stopTime, int intervalIndex,
fbe3c2bb   Benjamin Renard   First commit
60
61
62
63
64
65
66
67
68
69
70
			bool isFirstInterval, bool isLastInterval);

	TimeAxis* getTimeAxis();

	void setTimeAxisDecorator(std::shared_ptr<TimeAxisDecorator> pDecorator_){
		_xdecoratorPtr = pDecorator_;
	}

	std::shared_ptr<TimeAxisDecorator> getTimeAxisDecorator(){
		return _xdecoratorPtr;
	}
2acc7d49   Hacene SI HADJ MOHAND   progress
71
        
a436273c   Hacene SI HADJ MOHAND   evol ok
72
                      void  normalize(MatrixGrid & matrixGrid, std::string normalizationType);  
fbe3c2bb   Benjamin Renard   First commit
73
74
75
76
77
78
79
80
81
82
83

	/**
	 * @brief QSAS time configuration for time formatting
	 */
	static QSASConfig* qsasconfig;

protected:
	/**
	 * @overload PanelPlotOutput::calculatePlotArea(Bounds const& pPanelBounds, bool pKeepRatio)
	 * @brief Calculate and draw plot area.
	 */
8c860e4f   Benjamin Renard   Rework for tickpl...
84
	virtual void calculatePlotArea(const Bounds& panelBounds_, Bounds& bounds_);
fbe3c2bb   Benjamin Renard   First commit
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108

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

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

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


e257cfb9   Benjamin Renard   First implementat...
109
110
111
112
113
114
115
	/**
	 * @overload PanelPlotOutput::drawIntervals(double startDate, double stopDate, std::string pParamId, IntervalsProperties& pIntervals)
	 * @brief Draw intervals defined by a parameter
	 */
	virtual void drawIntervals(double startDate, double stopDate, std::string pParamId,
			IntervalsProperties& pIntervals);

fbe3c2bb   Benjamin Renard   First commit
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
	void drawXAxis(boost::shared_ptr<Axis> pXAxis, PlWindow& pPlWindow, Bounds& pPlotAreaSize, TickConf& pTickConf);

	/**
//	 * @overload convertXAxisValue(const std::string &value)
//	 * @brief 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);

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

	/**
20fef3b6   Benjamin Renard   Fix reset functio...
133
	 * @overload PanelPlotOutput::resetPlot - reset plot
fbe3c2bb   Benjamin Renard   First commit
134
	 */
20fef3b6   Benjamin Renard   Fix reset functio...
135
	virtual void resetPlot() {
fbe3c2bb   Benjamin Renard   First commit
136
		_startDateDrawn = false;
20fef3b6   Benjamin Renard   Fix reset functio...
137
		PanelPlotOutput::resetPlot();
fbe3c2bb   Benjamin Renard   First commit
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
	}
	/*
	 *
	 */

private:
	void drawStartDate(TimeAxis* pXAxis, double startTime, double stopTime);

	const std::string getXAxisId() const;

	/**
	 * @brief Configure series color (symbols and line) and range of axis (depending of parameters series to draw).
	 */
	void configureSeriesAxis();

	/**
	 * @brief Configure axis legend with paramInfo.
	 */
	void configureAxisLegend();

	/**
	* @brief Configure spectro.
	*/
	void configureSpectroAxis();

	/**
	* @brief Retrieve ConstantLine informations for a given serieId and constantId.
	*/
e7b3586a   Benjamin Renard   Fix fill between ...
166
	ConstantLine * getConstantLineFromId (int serieId, int constantId, boost::shared_ptr<Axis>& yAxis);
fbe3c2bb   Benjamin Renard   First commit
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208

	/**
	* @brief Retrieve serie properties by serie Id.
	*/
	bool getSeriePropertiesById(int serieId, SeriesProperties &rSerieProperties);

	/**
	* @brief Merge, sort and remove duplicate from 2 arrays in a vector
	*/
	void mergeAndSortTime (	double *values1Time, int values1Nb,
							double *values2Time, int values2Nb,
							std::vector<double> &values);

	/**
	* @brief Return or compute an interpolated value
	*/
	double getInterpolatedValue (double *values, double *valuesTime, int valuesNb, double atTime);

	/**
	* @brief Compute if two ligne segments intersects
	*/
	bool intersect (double xi, double y1i, double y2i,
					double xj, double y1j, double y2j,
					double *xInter);

	/**
	* @brief Compute and add intersections time to the vector if intersections exist
	*/
	void addIntersectionTime (	double *values1, double *values1Time, int values1Nb,
								double *values2, double *values2Time, int values2Nb,
								std::vector<double> &valuesTime);

	/**
	* @brief Draw Fill Area for the given arrays and the valueTime timeline
	*/
	void drawFillArea (	double *values1, double *values1Time, int values1Nb,
						double *values2, double *values2Time, int values2Nb,
						std::vector<double> &valuesTime,
						bool colorGreaterSpecified, Color& colorGreater,
						bool colorLessSpecified, Color& colorLess,
						SeriesProperties &rSeriesProperties);

677db865   Benjamin Renard   Draw intervals on...
209
210
211
212
	Color getStatusColor(AMDA::Info::ParamInfoSPtr& paramInfo, double value);

	void drawOneInterval(double tmin, double tmax, Color color);

fbe3c2bb   Benjamin Renard   First commit
213
214
215
216
217
218
219
220
221
222
223
224
225
	std::shared_ptr<TimeAxisDecorator> _xdecoratorPtr;

	bool _startDateDrawn;
};

/**
 * @brief Custom generator for time label, just not display min time.
 */
void generateTimeLabel(PLINT axis, PLFLT value, char *label, PLINT length,
		PLPointer data);

} /* namespace plot */
#endif /* TIMEPLOT_HH_ */