-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlinkline.h
28 lines (24 loc) · 915 Bytes
/
linkline.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
#ifndef LINKLINE_H
#define LINKLINE_H
#include <QGraphicsLineItem>
#include <QLinkedList>
#include "linknode.h"
class LinkLineItem : public QGraphicsLineItem {
public:
LinkLineItem(const QLineF& line, QGraphicsItem* parent = 0, QGraphicsScene* scene = 0);
//Sets line rounded to grid.
void setLine(const QLineF& line);
//Used by qgraphicsitem_cast<> to quickly determine type.
enum { Type = UserType + 103 };
virtual int type() const { return Type; }
//Creates child LinkNodes where other LinkNodes overlap.
virtual void paint(QPainter* painter, const QStyleOptionGraphicsItem* option, QWidget* widget = 0);
private:
//List of child linknodes, to avoid re-adding existing ones.
QLinkedList<LinkNodeItem*> nodes;
//Spacing of grid, if parent is a ChartScene.
int grid_size = 20;
//Whether line is horizontal (otherwise should be vertical).
bool horizontal;
};
#endif //LINKLINE_H