NumeRe v1.1.4
NumeRe: Framework für Numerische Rechnungen
plotdata.hpp
Go to the documentation of this file.
1/*****************************************************************************
2 NumeRe: Framework fuer Numerische Rechnungen
3 Copyright (C) 2014 Erik Haenel et al.
4
5 This program is free software: you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation, either version 3 of the License, or
8 (at your option) any later version.
9
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
14
15 You should have received a copy of the GNU General Public License
16 along with this program. If not, see <http://www.gnu.org/licenses/>.
17******************************************************************************/
18
19
20// --> CLASS: PLOTDATA <--
21
22#ifndef PLOTDATA_HPP
23#define PLOTDATA_HPP
24
25#include <string>
26#include <cmath>
27#include <vector>
28
29#include "../ui/error.hpp"
30#include "../utils/tools.hpp"
31#include "../structures.hpp"
32#include "../interval.hpp"
33#include "plotdef.hpp"
34
35extern const char* SECAXIS_DEFAULT_COLOR;
36
41class PlotData : public FileSystem
42{
43 public:
45 {
49 COLSTART = 0
50 };
51
53 {
54 ALL = 0,
55 LOCAL = 1,
56 GLOBAL = 2,
57 SUPERGLOBAL = 4
58 };
59
61 {
94 };
95
97 {
113 };
114
116 {
124 };
125
127 {
148 };
149
150 private:
154 bool bRanges[4];
155 bool bMirror[4];
157 bool bLogscale[4];
158 std::string sAxisLabels[3];
159 std::string sTickTemplate[4];
160 std::string sCustomTicks[4];
161 double dRotateAngles[2];
162 double dAxisScale[4];
163 double dOrigin[3];
164 unsigned short nSlices[3];
166
171
172 std::vector<Line> _lHlines;
173 std::vector<Line> _lVLines;
176
177 PlotData(const PlotData&) = delete;
178 PlotData& operator=(const PlotData&) = delete;
179
180 void replaceControlChars(std::string& sString);
181 std::string removeSurroundingQuotationMarks(const std::string& sString);
182 void rangeByPercentage(double* dData, size_t nLength, double dLowerPercentage, double dUpperPercentage, std::vector<double>& vRanges);
183
184 public:
185 PlotData();
186
187 void setParams(const std::string& __sCmd, int nType = ALL);
188 std::string getParams(bool asstr = false) const;
189 std::string getAxisLabel(size_t axis) const;
190 void setSamples(int _nSamples);
191 void setFileName(std::string _sFileName);
192 void reset();
193 void deleteData(bool bGraphFinished = false);
194
195 inline void setGlobalComposeParams(const std::string& __sCmd)
196 {
197 return setParams(__sCmd, GLOBAL | SUPERGLOBAL);
198 }
199
200 inline void setLocalComposeParams(const std::string& __sCmd)
201 {
202 return setParams(__sCmd, LOCAL);
203 }
204
206 {
207 return ranges;
208 }
209
210 bool getSettings(LogicalPlotSetting setting) const
211 {
212 return logicalSettings[setting];
213 }
214
215 int getSettings(IntPlotSetting setting) const
216 {
217 return intSettings[setting];
218 }
219
220 double getSettings(FloatPlotSetting setting) const
221 {
222 return floatSettings[setting];
223 }
224
225 std::string getSettings(StringPlotSetting setting) const
226 {
227 return stringSettings[setting];
228 }
229
230 inline bool getRangeSetting(int i = 0) const
231 {
232 if (i < 3 && i >= 0)
233 return bRanges[i];
234 else
235 return false;
236 }
237
238 inline bool getInvertion(int i = 0) const
239 {
240 if (i < 4 && i >= 0)
241 return bMirror[i];
242 else
243 return false;
244 }
245
246 inline double getAxisScale(int i = 0) const
247 {
248 if (i >= 0 && i < 4)
249 return dAxisScale[i];
250 else
251 return 1.0;
252 }
253
254 inline void setFont(const std::string& Font)
255 {
257 return;
258 }
259
260 inline std::string getAxisbind(unsigned int i) const
261 {
262 if (2*i+1 < stringSettings[STR_AXISBIND].length())
263 return stringSettings[STR_AXISBIND].substr(2*i,2);
264 else
265 return "lb";
266 }
267
268 inline int getGivenRanges() const
269 {
270 return nRanges;
271 }
272
273 inline bool getLogscale(size_t i) const
274 {
275 return i < 4 ? bLogscale[i] : false;
276 }
277
278 inline double getRotateAngle(int _i = 0) const
279 {
280 return dRotateAngles[_i];
281 }
282
283 inline int getAnimateSamples() const
284 {
287 else
288 return 0;
289 }
290
291 inline double getOrigin(int nDir = 0) const
292 {
293 if (nDir >= 0 && nDir < 3)
294 return dOrigin[nDir];
295 else
296 return 0.0;
297 }
298
299 inline unsigned short getSlices(unsigned int nDir = 0) const
300 {
301 if (nDir < 3)
302 return nSlices[nDir];
303 else
304 return 1;
305 }
306
307 inline std::string getColorScheme(const std::string& _sAddOpt = "") const
308 {
309 return (stringSettings[STR_COLORSCHEME]+_sAddOpt);
310 }
311
312 inline std::string getColorSchemeMedium(const std::string& _sAddOpt = "") const
313 {
314 return (stringSettings[STR_COLORSCHEMEMEDIUM]+_sAddOpt);
315 }
316
317 inline std::string getColorSchemeLight(const std::string& _sAddOpt = "") const
318 {
319 return (stringSettings[STR_COLORSCHEMELIGHT]+_sAddOpt);
320 }
321
322 inline std::string getColors() const
323 {
327 }
328
329 inline std::string getContColors() const
330 {
334 }
335
336 inline std::string getLineStyles() const
337 {
341 }
342
343 inline std::string getGridStyle() const
344 {
345 return stringSettings[STR_GRIDSTYLE].substr(0,3);
346 }
347
348 inline std::string getFineGridStyle() const
349 {
350 return stringSettings[STR_GRIDSTYLE].substr(3);
351 }
352
353 inline const std::vector<Line>& getHLines() const
354 {
355 return _lHlines;
356 }
357
358 inline const std::vector<Line>& getVLines() const
359 {
360 return _lVLines;
361 }
362
363 inline Axis getAddAxis(unsigned int i = 0) const
364 {
365 Axis _Axis;
366 _Axis.sLabel = "";
368 _Axis.ivl.reset(NAN, NAN);
369
370 if (i < 2)
371 return _AddAxes[i];
372 else
373 return _Axis;
374 }
375
376 inline void setAddAxis(unsigned int i, const Interval& _ivl)
377 {
378 if (i < 2
379 && mu::isnan(_AddAxes[i].ivl.front())
380 && mu::isnan(_AddAxes[i].ivl.back())
381 && !mu::isnan(_ivl.front())
382 && !mu::isnan(_ivl.back()))
383 {
384 _AddAxes[i].ivl = _ivl;
385
386 if (!i && !_AddAxes[i].sLabel.length())
387 _AddAxes[i].sLabel = "\\i x";
388 else if (!_AddAxes[i].sLabel.length())
389 _AddAxes[i].sLabel = "\\i y";
390 }
391 }
392
393 inline TimeAxis getTimeAxis(unsigned int i = 0) const
394 {
395 TimeAxis axis;
396
397 if (i < 4)
398 return _timeAxes[i];
399
400 return axis;
401 }
402
403 inline const int* getTargetGUI() const
404 {
405 return nTargetGUI;
406 }
407
408 inline std::string getTickTemplate(int nAxis = 0) const
409 {
410 if (nAxis >= 0 && nAxis < 4)
411 return sTickTemplate[nAxis];
412 else
413 return "";
414 }
415
416 inline std::string getCustomTick(int nAxis = 0) const
417 {
418 if (nAxis >= 0 && nAxis < 4)
419 return sCustomTicks[nAxis];
420 else
421 return "";
422 }
423
424
425};
426
427#endif
This class implements the basic input/ output file system and provides functionalities to work with f...
Definition: filesystem.hpp:92
This class represents a single interval in code providing reading access functionality.
Definition: interval.hpp:34
mu::value_type back() const
Return the last element in the interval.
Definition: interval.cpp:200
void reset(const std::string &sDef)
Reset the interval with a new definition.
Definition: interval.cpp:402
mu::value_type front() const
Return the first element in the interval.
Definition: interval.cpp:187
This class contains all the plot settings usable by the plotting algorithm.
Definition: plotdata.hpp:42
double floatSettings[FLOAT_SETTING_SIZE]
Definition: plotdata.hpp:169
int intSettings[INT_SETTING_SIZE]
Definition: plotdata.hpp:168
@ COLSTART
Definition: plotdata.hpp:49
@ ONLYRIGHT
Definition: plotdata.hpp:48
@ ONLYLEFT
Definition: plotdata.hpp:47
@ ALLRANGES
Definition: plotdata.hpp:46
std::string getColorSchemeMedium(const std::string &_sAddOpt="") const
Definition: plotdata.hpp:312
bool getInvertion(int i=0) const
Definition: plotdata.hpp:238
bool bLogscale[4]
Definition: plotdata.hpp:157
std::string getContColors() const
Definition: plotdata.hpp:329
TimeAxis _timeAxes[4]
Definition: plotdata.hpp:175
StringPlotSetting
Definition: plotdata.hpp:127
@ STR_GRIDSTYLE
Definition: plotdata.hpp:141
@ STR_BACKGROUND
Definition: plotdata.hpp:129
@ STR_FILENAME
Definition: plotdata.hpp:138
@ STR_PLOTTITLE
Definition: plotdata.hpp:145
@ STR_SETTING_SIZE
Definition: plotdata.hpp:147
@ STR_COLORSCHEME
Definition: plotdata.hpp:132
@ STR_COLORSCHEMEMEDIUM
Definition: plotdata.hpp:134
@ STR_LINESTYLESGREY
Definition: plotdata.hpp:144
@ STR_LINESTYLES
Definition: plotdata.hpp:143
@ STR_LINESIZES
Definition: plotdata.hpp:142
@ STR_AXISBIND
Definition: plotdata.hpp:128
@ STR_COLORSCHEMELIGHT
Definition: plotdata.hpp:133
@ STR_FONTSTYLE
Definition: plotdata.hpp:139
@ STR_BACKGROUNDCOLORSCHEME
Definition: plotdata.hpp:130
@ STR_CONTCOLORS
Definition: plotdata.hpp:136
@ STR_CONTGREYS
Definition: plotdata.hpp:137
@ STR_POINTSTYLES
Definition: plotdata.hpp:146
@ STR_COLORS
Definition: plotdata.hpp:131
@ STR_COMPOSEDTITLE
Definition: plotdata.hpp:135
PlotData & operator=(const PlotData &)=delete
bool getRangeSetting(int i=0) const
Definition: plotdata.hpp:230
void setSamples(int _nSamples)
Change the number of samples.
Definition: plotdata.cpp:2398
PlotData(const PlotData &)=delete
int getAnimateSamples() const
Definition: plotdata.hpp:283
std::string getGridStyle() const
Definition: plotdata.hpp:343
void setFileName(std::string _sFileName)
Change the output file name.
Definition: plotdata.cpp:2411
bool bDefaultAxisLabels[3]
Definition: plotdata.hpp:156
std::string getCustomTick(int nAxis=0) const
Definition: plotdata.hpp:416
const std::vector< Line > & getHLines() const
Definition: plotdata.hpp:353
const std::vector< Line > & getVLines() const
Definition: plotdata.hpp:358
std::string getSettings(StringPlotSetting setting) const
Definition: plotdata.hpp:225
int getSettings(IntPlotSetting setting) const
Definition: plotdata.hpp:215
std::string sCustomTicks[4]
Definition: plotdata.hpp:160
double getSettings(FloatPlotSetting setting) const
Definition: plotdata.hpp:220
std::string getColors() const
Definition: plotdata.hpp:322
IntPlotSetting
Definition: plotdata.hpp:97
@ INT_LEGENDPOSITION
Definition: plotdata.hpp:105
@ INT_LEGENDSTYLE
Definition: plotdata.hpp:106
@ INT_COORDS
Definition: plotdata.hpp:102
@ INT_SETTING_SIZE
Definition: plotdata.hpp:112
@ INT_COMPLEXMODE
Definition: plotdata.hpp:100
@ INT_LIGHTING
Definition: plotdata.hpp:107
@ INT_AXIS
Definition: plotdata.hpp:99
@ INT_SAMPLES
Definition: plotdata.hpp:109
@ INT_SIZE_X
Definition: plotdata.hpp:110
@ INT_ANIMATESAMPLES
Definition: plotdata.hpp:98
@ INT_SIZE_Y
Definition: plotdata.hpp:111
@ INT_CONTLINES
Definition: plotdata.hpp:101
@ INT_HIGHRESLEVEL
Definition: plotdata.hpp:104
unsigned short getSlices(unsigned int nDir=0) const
Definition: plotdata.hpp:299
std::string stringSettings[STR_SETTING_SIZE]
Definition: plotdata.hpp:170
std::string getAxisLabel(size_t axis) const
Return the axis label associated to the selected axis.
Definition: plotdata.cpp:2521
const int * getTargetGUI() const
Definition: plotdata.hpp:403
std::string getLineStyles() const
Definition: plotdata.hpp:336
std::string sTickTemplate[4]
Definition: plotdata.hpp:159
FloatPlotSetting
Definition: plotdata.hpp:116
@ FLOAT_SETTING_SIZE
Definition: plotdata.hpp:123
@ FLOAT_TEXTSIZE
Definition: plotdata.hpp:122
@ FLOAT_ALPHAVAL
Definition: plotdata.hpp:117
@ FLOAT_ASPECT
Definition: plotdata.hpp:118
@ FLOAT_HBARS
Definition: plotdata.hpp:120
@ FLOAT_PERSPECTIVE
Definition: plotdata.hpp:121
@ FLOAT_BARS
Definition: plotdata.hpp:119
IntervalSet & getRanges()
Definition: plotdata.hpp:205
unsigned short nSlices[3]
Definition: plotdata.hpp:164
double getAxisScale(int i=0) const
Definition: plotdata.hpp:246
void setFont(const std::string &Font)
Definition: plotdata.hpp:254
void replaceControlChars(std::string &sString)
Replaces tab and newlines correspondingly.
Definition: plotdata.cpp:2445
TimeAxis getTimeAxis(unsigned int i=0) const
Definition: plotdata.hpp:393
void rangeByPercentage(double *dData, size_t nLength, double dLowerPercentage, double dUpperPercentage, std::vector< double > &vRanges)
double dOrigin[3]
Definition: plotdata.hpp:163
int nRanges
Definition: plotdata.hpp:152
std::vector< Line > _lVLines
Definition: plotdata.hpp:173
bool logicalSettings[LOG_SETTING_SIZE]
Definition: plotdata.hpp:167
void setGlobalComposeParams(const std::string &__sCmd)
Definition: plotdata.hpp:195
double getOrigin(int nDir=0) const
Definition: plotdata.hpp:291
void reset()
Resets all settings to the initialisation stage.
Definition: plotdata.cpp:1897
std::string sAxisLabels[3]
Definition: plotdata.hpp:158
void setParams(const std::string &__sCmd, int nType=ALL)
Identifies parameters and values in the passed parameter string and updates the selected type of the ...
Definition: plotdata.cpp:233
Axis _AddAxes[2]
Definition: plotdata.hpp:174
std::string getAxisbind(unsigned int i) const
Definition: plotdata.hpp:260
bool getSettings(LogicalPlotSetting setting) const
Definition: plotdata.hpp:210
int getGivenRanges() const
Definition: plotdata.hpp:268
double dRotateAngles[2]
Definition: plotdata.hpp:161
std::string getParams(bool asstr=false) const
Return the internal plotting parameters as a human-readable string. Can be converted to an internal s...
Definition: plotdata.cpp:2084
@ SUPERGLOBAL
Definition: plotdata.hpp:57
IntervalSet ranges
Definition: plotdata.hpp:151
std::string getColorScheme(const std::string &_sAddOpt="") const
Definition: plotdata.hpp:307
LogicalPlotSetting
Definition: plotdata.hpp:61
@ LOG_CRUST
Definition: plotdata.hpp:76
@ LOG_YERROR
Definition: plotdata.hpp:83
@ LOG_TABLE
Definition: plotdata.hpp:92
@ LOG_ALLHIGHRES
Definition: plotdata.hpp:62
@ LOG_PARAMETRIC
Definition: plotdata.hpp:86
@ LOG_REGION
Definition: plotdata.hpp:88
@ LOG_FIXEDLENGTH
Definition: plotdata.hpp:79
@ LOG_SILENTMODE
Definition: plotdata.hpp:90
@ LOG_CONTPROJ
Definition: plotdata.hpp:75
@ LOG_XERROR
Definition: plotdata.hpp:82
@ LOG_COLORMASK
Definition: plotdata.hpp:71
@ LOG_COLORBAR
Definition: plotdata.hpp:70
@ LOG_STEPPLOT
Definition: plotdata.hpp:91
@ LOG_ANIMATE
Definition: plotdata.hpp:65
@ LOG_ALPHAMASK
Definition: plotdata.hpp:64
@ LOG_PIPE
Definition: plotdata.hpp:87
@ LOG_AREA
Definition: plotdata.hpp:66
@ LOG_CLOUDPLOT
Definition: plotdata.hpp:69
@ LOG_BOXPLOT
Definition: plotdata.hpp:68
@ LOG_ORTHOPROJECT
Definition: plotdata.hpp:85
@ LOG_INTERPOLATE
Definition: plotdata.hpp:81
@ LOG_SCHEMATIC
Definition: plotdata.hpp:89
@ LOG_FLOW
Definition: plotdata.hpp:80
@ LOG_CONNECTPOINTS
Definition: plotdata.hpp:72
@ LOG_ALPHA
Definition: plotdata.hpp:63
@ LOG_CONTLABELS
Definition: plotdata.hpp:74
@ LOG_DRAWPOINTS
Definition: plotdata.hpp:78
@ LOG_OPENIMAGE
Definition: plotdata.hpp:84
@ LOG_SETTING_SIZE
Definition: plotdata.hpp:93
@ LOG_CONTFILLED
Definition: plotdata.hpp:73
@ LOG_CUTBOX
Definition: plotdata.hpp:77
void deleteData(bool bGraphFinished=false)
Delete the internal per-plot data (i.e. weak reset).
Definition: plotdata.cpp:2011
double getRotateAngle(int _i=0) const
Definition: plotdata.hpp:278
Axis getAddAxis(unsigned int i=0) const
Definition: plotdata.hpp:363
int nRequestedLayers
Definition: plotdata.hpp:153
PlotData()
PlotData constructor. Calls PlotData::reset() for initialisation.
Definition: plotdata.cpp:216
std::string getTickTemplate(int nAxis=0) const
Definition: plotdata.hpp:408
std::string getColorSchemeLight(const std::string &_sAddOpt="") const
Definition: plotdata.hpp:317
void setAddAxis(unsigned int i, const Interval &_ivl)
Definition: plotdata.hpp:376
bool bMirror[4]
Definition: plotdata.hpp:155
int nTargetGUI[2]
Definition: plotdata.hpp:165
std::vector< Line > _lHlines
Definition: plotdata.hpp:172
void setLocalComposeParams(const std::string &__sCmd)
Definition: plotdata.hpp:200
bool bRanges[4]
Definition: plotdata.hpp:154
std::string getFineGridStyle() const
Definition: plotdata.hpp:348
bool getLogscale(size_t i) const
Definition: plotdata.hpp:273
std::string removeSurroundingQuotationMarks(const std::string &sString)
Removes surrounding quotation marks.
Definition: plotdata.cpp:2468
double dAxisScale[4]
Definition: plotdata.hpp:162
bool isnan(const value_type &v)
Definition: muParserDef.h:379
const char * SECAXIS_DEFAULT_COLOR
Definition: plotdata.cpp:27
Structure for the axes in plots.
Definition: interval.hpp:120
Interval ivl
Definition: interval.hpp:123
std::string sStyle
Definition: interval.hpp:122
std::string sLabel
Definition: interval.hpp:121
This class represents a set of intervals used together for calculations and simulations.
Definition: interval.hpp:84
Structure for describing time axes in plots.
Definition: interval.hpp:132