NumeRe v1.1.4
NumeRe: Framework für Numerische Rechnungen
plotting.hpp
Go to the documentation of this file.
1/*****************************************************************************
2 NumeRe: Framework fuer Numerische Rechnungen
3 Copyright (C) 2017 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#ifndef PLOTTING_HPP
20#define PLOTTING_HPP
21
22#include <mgl2/mgl.h>
23#include <string>
24#include <vector>
25
26#include "../datamanagement/memorymanager.hpp"
27#include "../ParserLib/muParser.h"
28#include "../settings.hpp"
29#include "../maths/define.hpp"
30#include "plotdata.hpp"
31#include "plotinfo.hpp"
32#include "plotasset.hpp"
33#include "graph_helper.hpp"
34
36
37void createPlot(std::string& sCmd, MemoryManager& _data, mu::Parser& _parser, Settings& _option, FunctionDefinitionManager& _functions, PlotData& _pData);
38
39
40
41
46class Plot
47{
48 private:
50 std::vector<short> m_types;
54 std::string sFunc;
55 std::string sOutputName;
56 size_t nLegends;
57
63
65 mglGraph* _graph;
66
67 Plot(const Plot&) = delete;
68 Plot& operator=(const Plot&) = delete;
69
70 protected:
71 void determinePlottingDimensions(const std::string& sPlotCommand);
72 size_t createSubPlotSet(bool& bAnimateVar, std::vector<std::string>& vPlotCompose, size_t nSubPlotStart, size_t nMultiplots[2], size_t& nSubPlots, size_t& nSubPlotMap);
74 bool createPlotOrAnimation(size_t nPlotCompose, size_t nPlotComposeSize, bool bNewSubPlot, bool bAnimateVar, std::vector<std::string>& vDrawVector, const std::vector<std::string>& vDataPlots);
75 void create2dPlot(size_t nPlotCompose, size_t nPlotComposeSize);
76 bool plot2d(mglData& _mData, mglData& _mData2, mglData* _mAxisVals, mglData& _mContVec);
77 void createStdPlot(size_t nPlotCompose, size_t nPlotComposeSize);
78 bool plotstd(mglData& _mData, mglData& _mAxisVals, mglData _mData2[2], const short nType);
79 void create3dPlot();
80 void create3dVect();
81 void create2dVect();
82 void create2dDrawing(std::vector<std::string>& vDrawVector);
83 void create3dDrawing(std::vector<std::string>& vDrawVector);
84 void createStd3dPlot(size_t nPlotCompose, size_t nPlotComposeSize);
85 bool plotstd3d(mglData _mData[3], mglData _mData2[3], const short nType);
86 bool checkMultiPlotArray(unsigned int nMultiPlot[2], unsigned int& nSubPlotMap, unsigned int nPlotPos, unsigned int nCols, unsigned int nLines);
87 long getNN(const mglData& _mData);
88 void filename(size_t nPlotComposeSize, size_t nPlotCompose);
89 void setStyles();
90 std::string expandStyleForCurveArray(const std::string& sCurrentStyle, bool expand);
91 void evaluateSubplot(std::string& sCmd, size_t nMultiplots[2], size_t& nSubPlots, size_t& nSubPlotMap);
92 void displayMessage(bool bAnimateVar);
93 std::vector<std::string> separateFunctionsAndData();
94 void extractDataValues(const std::vector<std::string>& vDataPlots);
95 void createDataLegends();
96 std::string constructDataLegendElement(std::string& sColumnIndices, const std::string& sTableName);
97 size_t countValidElements(const mglData& _mData);
98 void prepareMemory();
99 void defaultRanges(size_t nPlotCompose, bool bNewSubPlot);
100 void fillData(double dt_max, int t_animate);
101 void fitPlotRanges(size_t nPlotCompose, bool bNewSubPlot);
102 void clearData();
103 void passRangesToGraph();
104 void applyColorbar();
105 void applyLighting();
106 void applyGrid();
107 double getLabelPosition(int nCoord);
108 mglPoint createMglPoint(int nCoords, double r, double phi, double theta, bool b3D = false);
109 void setLogScale(bool bzLogscale);
110 void directionalLight(double dPhi, double dTheta, int nId, char cColor = 'w', double dBrightness = 0.5);
111 std::string getLegendStyle(const std::string& sLegend);
112 mglPoint CalcCutBox(double dPhi, int nEdge = 0, int nCoords = 0, bool b3D = false);
113 double getProjBackground(double dPhi, int nEdge = 0);
114 mglData fmod(const mglData& _mData, double dDenominator);
115 void CoordSettings();
116 std::string CoordFunc(const std::string& sFuncDef, double dPhiScale = 1.0, double dThetaScale = 1.0);
117 std::string composeColoursForBarChart(long int nNum);
118
119 public:
120 Plot(std::string& sCmd, MemoryManager& __data, mu::Parser& __parser, Settings& __option, FunctionDefinitionManager& __functions, PlotData& __pData);
121 ~Plot();
123 {
124 GraphHelper* _helper = new GraphHelper(_graph, _pData);
125 _graph = nullptr;
126 return _helper;
127 }
128};
129
130
131#endif
132
133
This class is defined to abstrahize the determination of the correct data object and the calculation ...
Definition: dataaccess.hpp:38
This class implements the function definition managing instance.
Definition: define.hpp:74
This class encapsulates the mglGraph object during transmission from the kernel to the GUI.
This class represents the central memory managing instance. It will handle all tables and clusters,...
This class combines the plotassets into a single structure.
Definition: plotasset.hpp:191
This class contains all the plot settings usable by the plotting algorithm.
Definition: plotdata.hpp:42
This class handles the complete plotting process.
Definition: plotting.hpp:47
void createStdPlot(size_t nPlotCompose, size_t nPlotComposeSize)
This member function wraps the creation of all one-dimensional plots (e.g. line or point plots).
Definition: plotting.cpp:1388
double getProjBackground(double dPhi, int nEdge=0)
This member function determines the positions for the projected density and contour maps,...
Definition: plotting.cpp:5939
void applyPlotSizeAndQualitySettings()
This member function determines output size and quality on the plotting target and the plotting param...
Definition: plotting.cpp:854
void determinePlottingDimensions(const std::string &sPlotCommand)
This member function determines the maximal plotting dimension of the passed command.
Definition: plotting.cpp:475
mglPoint CalcCutBox(double dPhi, int nEdge=0, int nCoords=0, bool b3D=false)
This member function calculates the two coordinates in space, which describe the cutting box....
Definition: plotting.cpp:5745
void setStyles()
This member function prepares the line and point styles based upon the currently used parameters.
Definition: plotting.cpp:3228
Plot(const Plot &)=delete
void create2dDrawing(std::vector< std::string > &vDrawVector)
This member function handles the creation of all two-dimensional drawings.
Definition: plotting.cpp:2167
Plot & operator=(const Plot &)=delete
std::string sFunc
Definition: plotting.hpp:54
~Plot()
Plot class destructor.
Definition: plotting.cpp:457
IntervalSet secDataRanges
Definition: plotting.hpp:52
bool bOutputDesired
Definition: plotting.hpp:53
size_t createSubPlotSet(bool &bAnimateVar, std::vector< std::string > &vPlotCompose, size_t nSubPlotStart, size_t nMultiplots[2], size_t &nSubPlots, size_t &nSubPlotMap)
This member function handles the creation of a single subplot, which may be a single plot or part of ...
Definition: plotting.cpp:515
IntervalSet dataRanges
Definition: plotting.hpp:51
std::string constructDataLegendElement(std::string &sColumnIndices, const std::string &sTableName)
This member function is used to construct special legend elements.
Definition: plotting.cpp:4285
std::string CoordFunc(const std::string &sFuncDef, double dPhiScale=1.0, double dThetaScale=1.0)
This member function is used to create a coordinate function for the coordinate system,...
Definition: plotting.cpp:7008
FunctionDefinitionManager & _functions
Definition: plotting.hpp:61
void create3dPlot()
This member function handles the creation of all three-dimensional plots.
Definition: plotting.cpp:1794
void filename(size_t nPlotComposeSize, size_t nPlotCompose)
This member function creates a default plot file name based upon the currently used plotting command.
Definition: plotting.cpp:3146
std::vector< short > m_types
Definition: plotting.hpp:50
double getLabelPosition(int nCoord)
This member function determines the position of the axis label, which depends on whether a box surrou...
Definition: plotting.cpp:6899
mu::Parser & _parser
Definition: plotting.hpp:59
std::string sOutputName
Definition: plotting.hpp:55
void applyLighting()
This member function applies the light effects to two- or three-dimensional plots....
Definition: plotting.cpp:5593
void extractDataValues(const std::vector< std::string > &vDataPlots)
Creates the internal mglData objects and fills them with the data values from the MemoryManager class...
Definition: plotting.cpp:3663
void displayMessage(bool bAnimateVar)
This member function writes a message to the terminal indicating that the algorithm is currently work...
Definition: plotting.cpp:3475
Settings & _option
Definition: plotting.hpp:60
PlotAssetManager m_manager
Definition: plotting.hpp:49
void fillData(double dt_max, int t_animate)
This member function calculates the plotting data points from usual expressions.
Definition: plotting.cpp:4589
PlotData & _pData
Definition: plotting.hpp:62
long getNN(const mglData &_mData)
This member function is a helper to return the number of data points located in the passed mglData ob...
Definition: plotting.cpp:3130
std::string expandStyleForCurveArray(const std::string &sCurrentStyle, bool expand)
This protected member function expands a style string into 9 style string with different luminosities...
Definition: plotting.cpp:3287
std::string getLegendStyle(const std::string &sLegend)
This member function prepares the legend strings to fit the selected legend style (only colours or on...
Definition: plotting.cpp:5983
bool plotstd3d(mglData _mData[3], mglData _mData2[3], const short nType)
This member function creates an actual single three-dimensional trajectory.
Definition: plotting.cpp:3014
void passRangesToGraph()
This member function informs the mglGraph object about the new plotting interval ranges.
Definition: plotting.cpp:5172
void setLogScale(bool bzLogscale)
This member function handles the complex logscale logic applied to the coordinate system of the plot.
Definition: plotting.cpp:5672
size_t countValidElements(const mglData &_mData)
This member function counts the valid data points in the passed mglData object.
Definition: plotting.cpp:4336
void applyColorbar()
This member function applies the colour bar to the plot.
Definition: plotting.cpp:5523
mglPoint createMglPoint(int nCoords, double r, double phi, double theta, bool b3D=false)
This member function creates a mglPoint instance depending on the chosen coordinate system.
Definition: plotting.cpp:5900
void CoordSettings()
This member function applies axes and axis labels to the graph.
Definition: plotting.cpp:6054
std::vector< std::string > separateFunctionsAndData()
This member function separates the functions from the data plots and returns a vector containing the ...
Definition: plotting.cpp:3590
mglGraph * _graph
Definition: plotting.hpp:65
void directionalLight(double dPhi, double dTheta, int nId, char cColor='w', double dBrightness=0.5)
This member function calculates the light source depending on the orientation of the graph....
Definition: plotting.cpp:5701
void create3dDrawing(std::vector< std::string > &vDrawVector)
This member function handles the creation of all three-dimensional drawings.
Definition: plotting.cpp:2430
void defaultRanges(size_t nPlotCompose, bool bNewSubPlot)
This member function applies the default ranges to the plotting ranges.
Definition: plotting.cpp:4428
void createStd3dPlot(size_t nPlotCompose, size_t nPlotComposeSize)
This member function wraps the creation of all trajectory-like plots (plots describing a series of po...
Definition: plotting.cpp:2797
void clearData()
Clearing member function for allocated memory on the heap.
Definition: plotting.cpp:5107
MemoryManager & _data
Definition: plotting.hpp:58
bool plot2d(mglData &_mData, mglData &_mData2, mglData *_mAxisVals, mglData &_mContVec)
This member function creates an actual single two-dimensional plot based upon the current plotting co...
Definition: plotting.cpp:1233
void create2dPlot(size_t nPlotCompose, size_t nPlotComposeSize)
This member function wraps the creation of all all two-dimensional plots (e.g. surface or density plo...
Definition: plotting.cpp:1101
void fitPlotRanges(size_t nPlotCompose, bool bNewSubPlot)
This member function fits the remaining plotting ranges for the calculated interval of data points.
Definition: plotting.cpp:4879
PlotInfo _pInfo
Definition: plotting.hpp:64
std::string composeColoursForBarChart(long int nNum)
This member function creates a special colour string, which is used for bar charts,...
Definition: plotting.cpp:7047
mglData fmod(const mglData &_mData, double dDenominator)
This member function applies a floating point modulo operator on the data set.
Definition: plotting.cpp:6009
bool createPlotOrAnimation(size_t nPlotCompose, size_t nPlotComposeSize, bool bNewSubPlot, bool bAnimateVar, std::vector< std::string > &vDrawVector, const std::vector< std::string > &vDataPlots)
This member function creates the plot or animation selected by the plotting command.
Definition: plotting.cpp:929
GraphHelper * createGraphHelper()
Definition: plotting.hpp:122
void create3dVect()
This member function handles the creation of all three-dimensional vector fields.
Definition: plotting.cpp:2076
void evaluateSubplot(std::string &sCmd, size_t nMultiplots[2], size_t &nSubPlots, size_t &nSubPlotMap)
This member function evaluates the subplot command in a plot composition and determines,...
Definition: plotting.cpp:3318
void create2dVect()
This member function handles the creation of all two-dimensional vector fields.
Definition: plotting.cpp:2122
void applyGrid()
This member function applies the grid with the selected styles to the plot.
Definition: plotting.cpp:6971
size_t nLegends
Definition: plotting.hpp:56
bool checkMultiPlotArray(unsigned int nMultiPlot[2], unsigned int &nSubPlotMap, unsigned int nPlotPos, unsigned int nCols, unsigned int nLines)
This member function checks, whether the selected subplot position is still empty.
Definition: plotting.cpp:7075
void prepareMemory()
This member function prepares the memory array in the PlotData class instance to fit the desired plot...
Definition: plotting.cpp:4361
void createDataLegends()
This member function creates the legend strings for the data plots.
Definition: plotting.cpp:4042
bool plotstd(mglData &_mData, mglData &_mAxisVals, mglData _mData2[2], const short nType)
This member function creates an actual single one-dimensional plot based upon the current plotting co...
Definition: plotting.cpp:1675
This class manages the setting values of the internal (kernel) settings of this application.
Definition: settings.hpp:663
Mathematical expressions parser.
Definition: muParser.h:51
void createPlot(std::string &sCmd, MemoryManager &_data, mu::Parser &_parser, Settings &_option, FunctionDefinitionManager &_functions, PlotData &_pData)
Wrapper function for creating plots. Will create an instance of the Plot class, which will handle the...
Definition: plotting.cpp:113
This class represents a set of intervals used together for calculations and simulations.
Definition: interval.hpp:84
This structure governs the needed parameters for plotting.
Definition: plotinfo.hpp:34