-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmychart1.h
95 lines (77 loc) · 1.78 KB
/
mychart1.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
#ifndef MYCHART1_H
#define MYCHART1_H
#define TEXT_BOX_SPACE 5
#define X_INCREMENT 5
#define POINT_RADIUS 1
#include <QWidget>
#include <QtGui>
class myChart1 : public QWidget
{
Q_OBJECT
public:
explicit myChart1(QWidget *parent = 0);
public slots:
void addData(qreal data);
void setUseAntialiasing(bool use)
{
m_bUseAntialiasing=use;
update();
}
bool getUseAntialiasing() const
{
return m_bUseAntialiasing;
}
void setHorizontalLineColor(const QColor& clr)
{
m_hLineClr=clr;
update();
}
void setShowPoint(bool show)
{
m_bShowPoint=show;
update();
}
void setTitle(const QString& str)
{
m_strTitle=str;
update();
}
protected:
void paintEvent(QPaintEvent *);
void resizeEvent(QResizeEvent *)
{
updateVector();
}
QSize sizeHint() const
{
return QSize(350,350);
}
QSize minimumSizeHint() const
{
return QSize(280,280);
}
private:
void resetVariables(QPainter* painter);
void drawBackground(QPainter* painter);
void drawBox(QPainter* painter);
void drawText(QPainter* painter);
void drawGraph(QPainter* painter);
void drawTitle(QPainter* painter);
void drawTime(QPainter* painter);
private:
qreal m_leftSpace;
qreal m_topSpace;
QVector<qreal> m_dataVec;
QVector<QPointF> m_potVec;
bool m_bUseAntialiasing;
bool m_bShowHLine;
bool m_bShowPoint;
QRectF m_topRect;
QRectF m_bottomRect;
QRectF m_boxRect;
QColor m_hLineClr;
QString m_strTitle;
void initVariables();
void updateVector();
};
#endif // MYCHART1_H