-
Notifications
You must be signed in to change notification settings - Fork 1
/
rmapobjectmovepolicy.h
executable file
·75 lines (55 loc) · 2.07 KB
/
rmapobjectmovepolicy.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
#ifndef RMAPOBJECTMOVEPOLICY_H
#define RMAPOBJECTMOVEPOLICY_H
#include "rmapobjectbehaviourpolicy.h"
#include <QPolygon>
#include <QPoint>
class QMouseEvent;
class QKeyEvent;
//--------------------------------------------------------------------------------------
class RMapObjectMovePolicy : public RMapObjectBehaviourPolicy {
public:
RMapObjectMovePolicy(RMapObject *obj = 0);
virtual bool mousePressEvent(QMouseEvent *event);
virtual bool mouseReleaseEvent(QMouseEvent *event);
virtual bool mouseMoveEvent(QMouseEvent *event);
virtual bool keyPressEvent(QKeyEvent *event);
virtual RMapObjectMovePolicy *clone() const = 0;
const QPolygon &movePolygon() const;
void setMovePolygon(const QPolygon &polygon);
bool isMoveClip() const;
void setMoveClip(bool clip = true);
protected:
const QPoint &mouseDownPoint() const;
void adjustClippingPos(int &row, int &col);
private:
QPoint mouse_down_point;
QPolygon move_polygon;
bool is_clipped;
};
//--------------------------------------------------------------------------------------
class RMapObjectNoMovePolicy : public RMapObjectMovePolicy {
public:
RMapObjectNoMovePolicy();
virtual RMapObjectNoMovePolicy *clone() const;
};
//--------------------------------------------------------------------------------------
class RMapObjectSimpleMovePolicy : public RMapObjectMovePolicy {
public:
RMapObjectSimpleMovePolicy(RMapObject *obj = 0);
virtual bool mouseMoveEvent(QMouseEvent *event);
virtual bool keyPressEvent(QKeyEvent *event);
virtual RMapObjectSimpleMovePolicy *clone() const;
};
//--------------------------------------------------------------------------------------
class RMapObjectGridMovePolicy : public RMapObjectMovePolicy {
public:
RMapObjectGridMovePolicy(size_t size, RMapObject *obj = 0);
virtual bool mouseMoveEvent(QMouseEvent *event);
virtual bool keyPressEvent(QKeyEvent *event);
virtual RMapObjectGridMovePolicy *clone() const;
protected:
void doMove(const QPoint &p);
private:
size_t gridSize;
};
#endif // RMAPOBJECTMOVEPOLICY_H