-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathconnectionline.h
79 lines (59 loc) · 2.06 KB
/
connectionline.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
#ifndef CONNECTIONLINE_H
#define CONNECTIONLINE_H
#include <QtQuick>
class ConnectionLine : public QQuickPaintedItem
{
Q_OBJECT
Q_PROPERTY(QPointF startPoint READ startPoint WRITE setStartPoint NOTIFY startPointChanged)
Q_PROPERTY(QPointF endPoint READ endPoint WRITE setEndPoint NOTIFY endPointChanged)
Q_PROPERTY(StartDirection startDirection READ startDirection WRITE setStartDirection NOTIFY startDirectionChanged)
Q_PROPERTY(QColor color READ color WRITE setColor NOTIFY colorChanged)
Q_PROPERTY(qreal thickness READ thickness WRITE setThickness NOTIFY thicknessChanged)
Q_PROPERTY(qreal hitTolerance READ hitTolerance WRITE setHitTolerance NOTIFY hitToleranceChanged)
Q_PROPERTY(qreal roundness READ roundness WRITE setRoundness NOTIFY roundnessChanged)
public:
enum StartDirection {
ToHorizontal,
ToVertical
};
Q_ENUMS(StartDirection)
ConnectionLine(QQuickItem * parent = 0);
void paint(QPainter *painter);
void setStartPoint(const QPointF& p);
QPointF startPoint() const;
void setEndPoint(const QPointF& p);
QPointF endPoint() const;
void setStartDirection(const StartDirection& dir);
StartDirection startDirection() const;
void setColor(const QColor& color);
QColor color() const;
void setThickness(const qreal& thickness);
qreal thickness() const;
void setHitTolerance(const qreal& tol);
qreal hitTolerance() const;
void setRoundness(const qreal& r);
qreal roundness() const;
Q_INVOKABLE bool hitTest(qreal x, qreal y) const;
signals:
void startPointChanged();
void endPointChanged();
void startDirectionChanged();
void colorChanged();
void thicknessChanged();
void hitToleranceChanged();
void roundnessChanged();
public slots:
private:
QPointF m_startPoint;
QPointF m_endPoint;
StartDirection m_startDirection;
QColor m_color;
qreal m_thickness;
qreal m_hitTolerance;
qreal m_roundness;
QPainterPath path;
QPainterPath arrow;
private:
void updateRect();
};
#endif // CONNECTIONLINE_H