-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbasepicker.h
71 lines (57 loc) · 1.73 KB
/
basepicker.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
#ifndef BASESELECTPICKER_H
#define BASESELECTPICKER_H
#include <QGraphicsObject>
class BaseElement;
class BaseSpace;
enum PickerDirection
{
PD_NONE,
PD_TOP,
PD_LEFT,
PD_BOTTOM,
PD_RIGHT,
PD_TOP_LEFT,
PD_TOP_RIGHT,
PD_BOTTOM_LEFT,
PD_BOTTOM_RIGHT,
PD_MOVE,
PD_ROTATE
};
class ElementTransform
{
public:
inline ElementTransform():dx(0),dy(0),sx(0),sy(0),type(QTransform::TxNone),direction(PD_NONE)
{}
qreal dx;
qreal dy;
qreal sx;
qreal sy;
QTransform::TransformationType type;
PickerDirection direction;
QPointF origin;
};
class BasePicker : public QGraphicsObject
{
Q_OBJECT
public:
explicit BasePicker(BaseElement *element);
virtual void setByElement() = 0;
//outside =====>> element->setRotation =====>> m_picker->setElementRotation =====>> element->setElementRotation
virtual void setElementRotation(qreal angle,const QPointF & center){Q_UNUSED(angle);Q_UNUSED(center);}
//outside =====>> element->setRect =====>> m_picker->setElementRect =====>> element->setElementRect
virtual void setElementRect(const QRectF & r) {Q_UNUSED(r);}
virtual void adjust(const ElementTransform & t) {Q_UNUSED(t);}
private:
BaseElement * m_element;
BaseSpace * m_space;
public:
inline BaseSpace * space() const {return m_space;}
inline BaseElement * element() const {return m_element;}
public slots:
void sceneScaled();
protected:
virtual QVariant itemChange(GraphicsItemChange change, const QVariant &value) Q_DECL_OVERRIDE;
QPointF elementToPicker(const QPointF & p) const;
QPointF pickerToElement(const QPointF & p) const;
};
#endif // BASESELECTPICKER_H