-
Notifications
You must be signed in to change notification settings - Fork 0
/
plotter.h
72 lines (62 loc) · 1.4 KB
/
plotter.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
#ifndef PLOTTER_H
#define PLOTTER_H
#include <QWidget>
#include <QVector>
#include <QPixmap>
#include <QMap>
class PlotSettings;
class QToolButton;
class Plotter : public QWidget
{
Q_OBJECT
public:
Plotter(QWidget* parent = 0);
void setPlotSettings(const PlotSettings& );
void setCurveData(int , const QVector<QPointF>& );
void clearCurve(int );
QSize sizeHint() const;
QSize minimumSizeHint() const;
public slots:
void zoomIn();
void zoomOut();
protected:
void mousePressEvent(QMouseEvent* );
void mouseMoveEvent(QMouseEvent* );
void mouseReleaseEvent(QMouseEvent* );
void keyPressEvent(QKeyEvent* );
void wheelEvent(QWheelEvent* );
void paintEvent(QPaintEvent* );
void resizeEvent(QResizeEvent* );
private:
void updateRubberBandRegion();
void refreshPixmap();
void drawGrid(QPainter* );
void drawCurves(QPainter* );
enum { Margin = 50 };
QToolButton* zoomInButton;
QToolButton* zoomOutButton;
QMap<int, QVector<QPointF> > curveMap;
QVector<PlotSettings> zoomStack;
int curZoom;
bool rubberBandIsShown;
QRect rubberBandRect;
QPixmap pixmap;
};
class PlotSettings
{
public:
PlotSettings();
double minX;
double maxX;
int numXTicks;
double minY;
double maxY;
int numYTicks;
double intervalX() const { return maxX - minX; }
double intervalY() const { return maxY - minY; }
void scroll(int , int );
void adjust();
private:
static void adjustAxis(double& , double& , int& );
};
#endif