PlotFunction.hh
8.83 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
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
#ifndef PLOTFUNCTION_HH_
#define PLOTFUNCTION_HH_
// includes boost
#include <boost/shared_ptr.hpp>
#include <iostream>
#include <fstream>
#include "NodeCfg.hh"
#include "PanelPlotOutput.hh"
#include "PlPlotUtil.hh"
#include "PlotFunctionNode.hh"
#include "plotFunctionElements/Abscisse.hh"
#include <climits>
#include "DefaultTimeAxisDecorator.hh"
#include "TimeAxisDecorator.hh"
#include "plplot/plplot.h"
#include "plplot/plplotP.h"
#include "plplot/plstream.h"
#include <map>
#include "plplot/plstream.h"
extern "C"
{
#include <plplot/qsastime.h>
}
/**
* @brief Id pour l'axe X qui sera crée
*
*/
#define X_AXIS_ID "xaxis_id"
#define X_AXIS_ID1 "xaxis_id1"
/**
* @brief Id pour l'axe Y qui sera crée
*
*/
#define Y_AXIS_ID "y-left"
namespace plot
{
class PlotFunction : public PanelPlotOutput
{
public:
/**
* @brief enum to represent the type of fucntion to apply for plotfunction feature
*
*/
enum Function
{
NONE,
AVG,
FFT,
DFT,
SUM
};
PlotFunction(AMDA::Parameters::ParameterManager &manager,
boost::shared_ptr<Panel> panel, TimeAxisDecorator *timeAxisDecorator = new DefaultTimeAxisDecorator());
virtual ~PlotFunction();
/**
* @overload plot::PanelPlotOutput
*/
virtual const std::string typeName()
{
return PlotFunction_NODENAME;
}
/**
* @overload plot::PanelPlotOutput
*/
virtual const std::string subTypeName()
{
return PlotFunction_NODENAME;
}
void setAbscisse(Abscisse abscisse_)
{
abscisse = abscisse_;
};
Abscisse getAbscisse()
{
return abscisse;
};
Function getFunction()
{
return function;
};
void setFunction(Function function_)
{
function = function_;
};
void setAbscisseScale(Axis::Scale scale)
{
abscisseScale = scale;
};
Axis::Scale getAbscisseScale()
{
return abscisseScale;
};
Axis::Scale getOrdonneeScale()
{
return ordonneeScale;
};
void setOrdonneeScale(Axis::Scale scale)
{
ordonneeScale = scale;
};
static QSASConfig *qsasconfig;
void setTimeAxisDecorator(std::shared_ptr<TimeAxisDecorator> pDecorator_)
{
_xdecoratorPtr = pDecorator_;
}
std::shared_ptr<TimeAxisDecorator> getTimeAxisDecorator()
{
return _xdecoratorPtr;
}
bool isFourier()
{
return function == PlotFunction::Function::FFT || function == PlotFunction::Function::DFT;
}
std::string functionStr()
{
switch (function)
{
case PlotFunction::Function::AVG:
return "AVERAGE";
case PlotFunction::Function::SUM:
return "SUM";
case PlotFunction::Function::FFT:
return "FFT";
case PlotFunction::Function::DFT:
return "DFT";
default:
return "NONE";
}
}
/**
* @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;
}
protected:
/**
*@brief Draw the serie of a parameter component on plot.
*/
virtual void
drawSeries(double startDate, double stopDate, int intervalIndex, std::string pParamId,
SeriesProperties &pSerie,
AMDA::Common::ParameterIndexComponent pParamIndex,
ParameterAxes ¶m, bool moreThanOneSerieForAxis);
virtual void writeDataFile(double startTime, double stopTime);
virtual void preparePlotArea(double startTime, double stopTime, int intervalIndex, std::vector<std::string>* ttNames = NULL);
/**
* @brief Get original id of the concerned parameter (for the plot) then add it to the usedParametersId_ and store it in originalParamId
*
* @param usedParametersId_
*/
virtual void createParameters(std::list<std::string> &usedParametersId_);
/**
* @brief draw the plot for the current time interval
*/
virtual bool draw(double startTime, double stopTime, int intervalIndex,
bool isFirstInterval, bool isLastInterval);
private:
/**
* @brief Format a time to given format
*
* @param time given time
* @param format given format
* @return std::string
*/
std::string formatTime(double time, std::string format)
{
long int lTime = static_cast<long int>(time);
tm *lTimeTm = gmtime(&lTime);
char lTimeChr[80];
// Format date.
strftime(lTimeChr, 80, format.c_str(), lTimeTm);
std::string lTimeStr = lTimeChr;
return lTimeStr;
}
/**
* @brief Add a title to panel
*
* @param startTime add startime
* @param stopTime add stoptime
*/
void addTitleToPanel(double startTime, double stopTime);
/**
* @brief draw Series for compued data for given spectro
*
* @param startDate
* @param stopDate
* @param intervalIndex
*/
void drawSeriesForSpectro(double startDate, double stopDate, int intervalIndex);
/**
* @brief Apply a function either for Series or Spectro
*
*/
void applyFunction();
/**
* @brief Configure axis ranges
*
*/
void setAxisRange();
/**
* @brief Configure axis legend
*
*/
void configureAxisLegend();
/**
* @brief Afficher sur le plot the starting date
*
* @param _timeFormat le format
* @param startTime le start time envoyé depuis le l'ihm
* @param stopTime le stop time envoyé depuis le l'ihm
*/
void drawStartDate(std::string _timeFormat, double startTime, double stopTime);
/**
* @brief Apply log scaling on given data
*
* @param vect vector of data
*/
void applyScale(std::vector<double> &vectX, std::vector<double> &vectY);
/**
* @brief Get the Min Max de xValuesMap et yValuesMap
*
* @param minToFill la variable qui store la valeur minimale
* @param maxToFill la variable qui store la valeur maximale
*/
void getMinMax(std::map<std::string, std::vector<double>>, double *minToFill, double *maxToFill);
/**
* @brief Compute function
*
* @param pParamIndex index of Series or (-1,-1) if it is spectro
* @param ParameterData parameter data
* @param pSerie pointer to series
* @param pSpectro pointer to spectro
* @param paramOriginID origin param ID
*/
void compute(AMDA::Common::ParameterIndexComponent pParamIndex, plot::ParameterData &data, SeriesProperties *pSerie, SpectroProperties *pSpectro, std::string paramOriginID);
/**
* @brief Une map pour stocker les valeurs calculées de l'axe X associés aux pseudo paramètres crées localement
*
*/
std::map<std::string, std::vector<double>> xValuesMap;
/**
* @brief Une map pour stocker les valeurs calculées de l'axe Y associés aux pseudo paramètres crées localement
*
*/
std::map<std::string, std::vector<double>> yValuesMap;
/**
* @brief Une map pour stocker les valeurs x-originales
*
*/
std::map<std::string, std::vector<double>> xValuesMapOriginalValues;
/**
* @brief Une map pour stocker les valeurs y-orginales
*
*/
std::map<std::string, std::vector<double>> yValuesMapOriginalValues;
/**
* @brief function type to be applied
* @see Function
*/
Function function;
/**
* @brief Abscisse type for Fourier
* @see Abscisse
*
*/
Abscisse abscisse;
/**
* @brief Scale of x-axis
*
*/
Axis::Scale abscisseScale;
/**
* @brief Scale for y-axis
*
*/
Axis::Scale ordonneeScale;
std::shared_ptr<TimeAxisDecorator> _xdecoratorPtr;
/**
* @brief Flag to store if is spectro
*
*/
bool isSpectro = false;
};
}
#endif