-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathPaintWidget.h
42 lines (38 loc) · 929 Bytes
/
PaintWidget.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
#ifndef PAINTWIDGET_H
#define PAINTWIDGET_H
#include <vector>
#include <QWidget>
#include <Figure.h>
using namespace std;
enum PaintMode { CLINE, CRECT, CELLIPSE, CPOLYGON, CFREEHAND }; //图形选项
class PaintWidget :public QWidget
{
Q_OBJECT
public:
PaintWidget(QWidget *parent = 0);
~PaintWidget();
void setPaintMode(PaintMode paintmode)
{
m_paintmode = paintmode;
}
void setPaintStyle(paintstyle style)
{
m_paintstyle = style;
}
protected:
void paintEvent(QPaintEvent *event);
void mousePressEvent(QMouseEvent *event);
void mouseReleaseEvent(QMouseEvent *event);
void mouseMoveEvent(QMouseEvent *event);
private:
QPixmap *m_pixmap;
CFigure *m_currentfig;
CPolygon *m_polygon;
vector<CFigure*> m_FigrueArray; //保存图形指针
vector<QPoint> vertex;
QPoint m_lastPos;
paintstyle m_paintstyle;
PaintMode m_paintmode = CELLIPSE; //默认为椭圆
bool m_leftpressed = false;
};
#endif // ! PAINTWIDGET_H