InstantPlot.hh
6.82 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
/*
* InstantPlot.hh
*
* Created on: 29 oct. 2013
* Author: CS
*/
#ifndef INSTANTPLOT_HH_
#define INSTANTPLOT_HH_
//includes boost
#include <boost/shared_ptr.hpp>
#include "PanelPlotOutput.hh"
#include "NodeCfg.hh"
#include "InstantPlotNode.hh"
#include "InstantSeriesProperties.hh"
#include "InstantSpectroProperties.hh"
namespace plot {
/**
* @brief Plot that draws f(x).
*/
class InstantPlot: public PanelPlotOutput {
public:
InstantPlot(AMDA::Parameters::ParameterManager& manager,
boost::shared_ptr<Panel> panel);
virtual ~InstantPlot();
/**
* @overload plot::PanelPlotOutput
*/
virtual const std::string typeName() {
return INSTANTPLOT_NODENAME;
}
/**
* @overload plot::PanelPlotOutput::preparePlotArea()
*/
virtual void preparePlotArea(double startTime, double stopTime, int intervalIndex);
/**
* @overload plot::PanelPlotOutput::createParameters()
*/
virtual void createParameters(std::list<std::string>& usedParametersId_);
/**
* Adds a parameter
*/
virtual void addParam(const std::string& name) {
// There is only one parameter for instant plots
_originalParamId = name;
}
/**
* @brief draw the plot for the current time interval
*/
virtual bool draw(double startTime, double stopTime, int intervalIndex,
bool isFirstInterval, bool isLastInterval);
/**
* @brief Override drawAdditionalObjects
* draw additional objects
*/
virtual void drawAdditionalObjects();
/**
* @overload PanelPlotOutput::getLayoutConstraint (void)
* @brief Defines the layout constraint to be used for the panel when used within a layout
*/
virtual PanelConstraint getLayoutConstraint (void) {
return PanelConstraint::Square;
}
double getTime() const {
return _time;
}
void setTime(double time) {
_time = time;
}
const boost::shared_ptr<InstantSeriesProperties>& getInstantSerieProperties() const {
return _iSerieProperties;
}
void setInstantSerieProperties(
const boost::shared_ptr<InstantSeriesProperties>& instantSerieProperties) {
_iSerieProperties = instantSerieProperties;
}
const boost::shared_ptr<InstantSpectroProperties>& getInstantSpectroProperties() const {
return _iSpectroProperties;
}
void setInstantSpectroProperties(
const boost::shared_ptr<InstantSpectroProperties>& instantSpectroProperties) {
_iSpectroProperties = instantSpectroProperties;
}
const std::string& getOriginalParamId() const {
return _originalParamId;
}
void setOriginalParamId(const std::string& originalParamId) {
_originalParamId = originalParamId;
}
protected:
/**
* @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);
/**
* @brief Draw series of parameter on plot.
*/
virtual void drawSeries(double startDate, double stopDate, int intervalIndex, std::string pParamId,
SeriesProperties& pSerie,
AMDA::Common::ParameterIndexComponent pParamIndex,
ParameterAxes& param, bool moreThanOneSerieForAxis, bool& noData);
/**
* @brief Draw sprctro of parameter on plot.
*/
virtual void drawSpectro(double startDate, double stopDate, std::string pParamId, SpectroProperties& pSpectro, bool& noData);
/*
* Dumps properties for test.
*/
virtual void dump(std::ostream& fileName_);
virtual void writeContext(ContextFileWriter &writer, AMDA::Parameters::TimeIntervalList::iterator currentTimeInterval);
private:
/**
* @brief Configure series color (symbols and line) and range of axis (depending of parameters series to draw).
*/
void configureSeriesAxis();
/**
* @brief Configure serie axis legend with paramInfo.
*/
void configureSeriesAxisLegend();
/**
* @overload PanelPlotOutput::getSerieParamsLegendString Get the instant serie legend
*/
std::string getSerieParamsLegendString(SeriesProperties &rSeriesProperties,
AMDA::Common::ParameterIndexComponent& index, std::string originalParamId);
/**
* @overload PanelPlotOutput::configureParamsLegend Configure params legend for an instant plot.
*/
virtual void configureParamsLegend(double startTime, double stopTime, int intervalIndex);
/**
* @brief Configure table axis for the parameter
*/
void configureTableAxis (boost::shared_ptr<Axis> axisSPtr, bool isSpectro, int relatedDim);
/**
* @brief Configure data axis for the parameter
*/
void configureDataAxis (boost::shared_ptr<Axis> axisSPtr, bool isSpectro);
/**
* @brief Configure legend for table axis
*/
void configureTableAxisLegend(boost::shared_ptr<Axis> axisSPtr, int relatedDim);
/**
* @brief Configure legend for data axis
*/
void configureDataAxisLegend(boost::shared_ptr<Axis> axisSPtr, bool isSpectro);
/**
* @brief Configure spectro range of axis (depending of parameters spectro to draw).
*/
void configureSpectroAxis();
/**
* @brief Configure spectro axis legend with paramInfo.
*/
void configureSpectroAxisLegend();
/**
* @brief Retrieve ConstantLine informations for a given serieId and constantId.
*/
ConstantLine * getConstantLineFromSerieId (int serieId, int constantId);
/**
* @brief Retrieve values for a given serieId.
*/
void getSerieParameterValues(int serieId, double **xValues, double **yValues, int *nbValues);
/**
* @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 addIntersectionTable ( 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);
/**
* @brief time used for instantPlot plotting.
*/
double _time;
double _prevTime;
double _nextTime;
/**
* @brief Intant pot param Id.
*/
std::string _originalParamId;
/**
* @brief Instant plot serie properties
*/
boost::shared_ptr<InstantSeriesProperties> _iSerieProperties;
/*
* @brief Instant plot spectro properties
*/
boost::shared_ptr<InstantSpectroProperties> _iSpectroProperties;
};
} /* namespace plot */
#endif /* INSTANTPLOT_HH_ */