-
Notifications
You must be signed in to change notification settings - Fork 0
/
COMMAND.H
69 lines (56 loc) · 1.43 KB
/
COMMAND.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
#ifndef _Command_h_
#define _Command_h_
#include <QPoint>
#include <QGraphicsSceneMouseEvent>
#ifdef __cplusplus
enum ECommandType // 命令类
{
ctSelect = 0,
// 创建对象命令类
ctCreateLine = 1, // 创建直线段
ctCreateRectangle = 2, // 创建矩形
ctCreateCircle = 3, // 创建圆
ctCreateArc = 4, // 创建圆弧
ctCreateEllipse = 5, //创建椭圆
ctCreatePolygon = 6, //多边形
ctCreateText = 7, //创建文本
// 修改命令类
ctMove = 11, // 移动
ctRotate = 12, // 旋转
ctMirror = 13, // 镜像
//修改视图命令类
ctZoomPan = 20 ,
ctZoomWindow = 21
};
class DiagramScene;
class CCommand
{
protected:
int m_nStep ; // 命令操作步
bool m_bCaptured; //捕捉
QPointF m_ptCapture; //捕捉点
void ShowCapturePoint(const QPointF &pos,bool bShow = false);
bool GetNearKeyPoint(QPointF &pt);
DiagramScene* m_pDiagramScene;
public:
CCommand() {
m_nStep = 0;
m_bCaptured = false;
}
CCommand(DiagramScene* pScene) {
m_nStep = 0;
m_bCaptured = false;
m_pDiagramScene = pScene;
}
~CCommand() {}
virtual int GetType() = 0; // 返回命令类型 ECommandType
virtual int OnLButtonDown(QGraphicsSceneMouseEvent* mouseEvent) = 0 ;
virtual int OnMouseMove(QGraphicsSceneMouseEvent* mouseEvent);
virtual int OnRButtonDown(QGraphicsSceneMouseEvent* mouseEvent) = 0 ;
virtual int OnLButtonDblClk(QGraphicsSceneMouseEvent* mouseEvent) {return 0;}
virtual int Cancel() = 0 ;
public:
void Prompt(QString sInfo);
} ;
#endif
#endif