-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdrawwidget.h
92 lines (72 loc) · 2.03 KB
/
drawwidget.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
#ifndef DRAWWIDGET_H
#define DRAWWIDGET_H
#include <QWidget>
#include "hfloat.h"
#include <QVector>
#include "fpoint.h"
#include "qrecthf.h"
#include "rawdata.h"
#define CURSOR_NUM 2
class DrawWidget : public QWidget
{
Q_OBJECT
public:
explicit DrawWidget(QWidget *parent = 0);
~DrawWidget();
void setPoints(RawData *p);
RawData* Points(void);
HPoint getXRange(void);
HPoint getYRange(void);
void setCursorX(int cursor, hfloat x);
hfloat CursorY(int cursor);
void setXmin(hfloat val);
void setXmax(hfloat val);
void setYmin(hfloat val);
void setYmax(hfloat val);
// Options
void setHighlightPoints(bool state);
void setShowLabelX(bool state);
void setShowLabelY(bool state);
void setShowGridOrizzontal(bool state);
void setShowGridVertical(bool state);
signals:
void cursorPositionChanged(int cursor, hfloat x, hfloat y);
private:
int m_marginX;
int m_marginY;
QRectHF m_drawRect;
hfloat m_xFactor;
hfloat m_yFactor;
RawData *m_points;
QVector<QPoint> m_pointsFloat;
bool m_dataPointUpdate;
hfloat m_cursorX[CURSOR_NUM];
hfloat m_cursorY[CURSOR_NUM];
bool m_cursorDragged[CURSOR_NUM];
hfloat m_xmin;
hfloat m_xmax;
hfloat m_ymin;
hfloat m_ymax;
// Options
bool m_highlightPoints;
bool m_showLabelsX;
bool m_showLabelsY;
bool m_showGridOrizzontal;
bool m_showGridVertical;
private:
void paintEvent(QPaintEvent *);
void mousePressEvent(QMouseEvent* event);
void mouseMoveEvent(QMouseEvent* event);
void mouseReleaseEvent(QMouseEvent* event);
void resizeEvent(QResizeEvent *);
void updateDataPoint(void);
QPoint fromGlobalToLocal(HPoint global);
int fromGlobalToLocalX(hfloat x);
HPoint fromLocalToGlobal(QPoint local);
bool cursorNear(int cursor, QPoint p);
void int_setCursorX(int cursor, hfloat x);
void setMarginX(int marginX);
void setMarginY(int marginY);
int getXMarginRequiredByLabels(QPainter *p);
};
#endif // DRAWWIDGET_H