-
Notifications
You must be signed in to change notification settings - Fork 4
/
arrow.h
50 lines (36 loc) · 1.09 KB
/
arrow.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
#ifndef ARROW_H
#define ARROW_H
#include <QGraphicsLineItem>
#include "shape.h"
#include <string>
class QGraphicsItem;
class QGraphicsLineItem;
class QGraphicsScene;
class QRectF;
class QGraphicsSceneMouseEvent;
class QPainterPath;
class Shape;
class Arrow : public QGraphicsLineItem
{
public:
enum { Type = UserType + 4 };
Arrow(Shape *startItem, Shape *endItem,
QGraphicsItem *parent = 0);
int type() const Q_DECL_OVERRIDE { return Type; }
QRectF boundingRect() const Q_DECL_OVERRIDE;
QPainterPath shape() const Q_DECL_OVERRIDE;
//setcolor sets item's color
void setColor(const QColor &color) { lineColor = color; }
Shape *startItem() const { return startShape; }
Shape *endItem() const { return endShape; }
//updatePosition()causes the arrow to recalculate the position of the arrow
void updatePosition();
protected:
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget = 0) Q_DECL_OVERRIDE;
private:
Shape *startShape;
Shape *endShape;
QColor lineColor;
QPolygonF arrowHead;
};
#endif // ARROW_H