/
PlotWindow.h
182 lines (162 loc) · 4.33 KB
/
PlotWindow.h
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
/*
* GNU version 3 is obtained from: http://www.gnu.org/copyleft/gpl.html.
*
* This program is distributed WITHOUT ANY WARRANTY; without
* even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE, EXCEPT AS EXPRESSLY SET FORTH
* IN THE BY RECIPIENT SELECTED SUBSIDIARY LICENSE CONDITIONS
* OF OSMC-PL.
*
* See the full OSMC Public License conditions for more details.
*
* Main Authors 2010: Syed Adeel Asghar, Sonia Tariq
*
*/
//! @file plotwindow.h
//! @author harka011
//! @date 2011-02-03
//! @brief Tool drawing 2D plot graph, supports .plt .mat .csv and plot plotParametric plotAll
#ifndef PLOTWINDOW_H
#define PLOTWINDOW_H
#include <QtGui>
#include <QtCore>
#include <qwt_plot.h>
#include <qwt_text.h>
#include <qwt_plot_curve.h>
#include <qwt_plot_picker.h>
#include <qwt_picker_machine.h>
#include <qwt_plot_grid.h>
#include <qwt_curve_fitter.h>
#include <qwt_legend.h>
#include <qwt_plot_zoomer.h>
#include <qwt_plot_panner.h>
#include <qwt_scale_engine.h>
#if QWT_VERSION >= 0x060000
#include <qwt_compat.h>
#endif
#include <stdexcept>
#include "../../SimulationRuntime/c/util/read_matlab4.h"
#include "../../SimulationRuntime/c/util/read_csv.h"
#include "Plot.h"
namespace OMPlot
{
class Plot;
class PlotCurve;
class PlotWindow : public QMainWindow
{
Q_OBJECT
public:
enum PlotType {PLOT, PLOTALL, PLOTPARAMETRIC};
private:
Plot *mpPlot;
QCheckBox *mpLogXCheckBox;
QCheckBox *mpLogYCheckBox;
QToolButton *mpGridButton;
QToolButton *mpDetailedGridButton;
QToolButton *mpNoGridButton;
QToolButton *mpZoomButton;
QToolButton *mpPanButton;
QTextStream *mpTextStream;
QFile mFile;
QStringList mVariablesList;
PlotType mPlotType;
QString mXRangeMin;
QString mXRangeMax;
QString mYRangeMin;
QString mYRangeMax;
double mCurveWidth;
int mCurveStyle;
public:
PlotWindow(QStringList arguments = QStringList(), QWidget *parent = 0);
~PlotWindow();
void setUpWidget();
void initializePlot(QStringList arguments);
void setVariablesList(QStringList variables);
void setPlotType(PlotType type);
PlotType getPlotType();
void initializeFile(QString file);
void setupToolbar();
void plot();
void plotParametric();
void setTitle(QString title);
QCheckBox* getLogXCheckBox();
QCheckBox* getLogYCheckBox();
void setXLabel(QString label);
void setYLabel(QString label);
void setXRange(double min, double max);
QString getXRangeMin();
QString getXRangeMax();
void setYRange(double min, double max);
QString getYRangeMin();
QString getYRangeMax();
void setCurveWidth(double width);
double getCurveWidth();
void setCurveStyle(int style);
int getCurveStyle();
void setLegendPosition(QString position);
QString getLegendPosition();
void checkForErrors(QStringList variables, QStringList variablesPlotted);
Plot* getPlot();
QToolButton* getPanButton();
void receiveMessage(QStringList arguments);
void closeEvent(QCloseEvent *event);
signals:
void closingDown();
public slots:
void enableZoomMode(bool on);
void enablePanMode(bool on);
void exportDocument();
void printPlot();
void setGrid(bool on);
void setDetailedGrid(bool on);
void setNoGrid(bool on);
void fitInView();
void setLogX(bool on);
void setLogY(bool on);
};
//Exception classes
class PlotException : public std::runtime_error
{
public:
PlotException(const char *e) : std::runtime_error(e) {}
PlotException(const QString str) : std::runtime_error(str.toStdString().c_str()) {}
};
class NoFileException : public PlotException
{
public:
NoFileException(const char *fileName) : PlotException(fileName) {}
private:
const char *temp;
};
class NoVariableException : public PlotException
{
public:
NoVariableException(const char *varName) : PlotException(varName) {}
};
//Options Class
//class Options : public QDialog
//{
// Q_OBJECT
//public:
// Options(PlotWindow *pPlotWindow);
// void setUpForm();
// void show();
// //MainWindow *mpParentMainWindow;
//private:
// QLineEdit *mpTitle;
// QLineEdit *mpXLabel;
// QLineEdit *mpYLabel;
// QLineEdit *mpXRangeMin;
// QLineEdit *mpXRangeMax;
// QLineEdit *mpYRangeMin;
// QLineEdit *mpYRangeMax;
// QLabel *mpTitleLabel;
// QGroupBox *mpLabelGroup;
// QPushButton *mpOkButton;
// QPushButton *mpCancelButton;
// PlotWindow *mpPlotWindow;
//public slots:
// void edit();
//};
}
#endif // PLOTWINDOW_H