Code Documentation 3.1
Social Network Visualizer
Loading...
Searching...
No Matches
graphicsedge.h
Go to the documentation of this file.
1
17#ifndef GRAPHICSEDGE_H
18#define GRAPHICSEDGE_H
19
20
21#include <QGraphicsItem>
22#include <QObject>
23#include <utility> //declares pair construct
24
25
26class GraphicsWidget;
27class QGraphicsSceneMouseEvent;
28class GraphicsNode;
31
32QT_USE_NAMESPACE
33
34using namespace std;
35
36
37static const int TypeEdge= QGraphicsItem::UserType+2;
38static const int ZValueEdge = 50;
39static const int ZValueEdgeHighlighted = 99;
40
41static const int EDGE_STATE_REGULAR = 0;
42static const int EDGE_STATE_HIGHLIGHT = 1;
43static const int EDGE_STATE_HOVER = 2;
44
45
46
47
48
49class GraphicsEdge : public QObject, public QGraphicsItem {
50 Q_OBJECT
51 Q_INTERFACES (QGraphicsItem)
52
53public:
55 const QString &label, const QString &color,
56 const Qt::PenStyle &style,
57 const int&type, const bool & drawArrows, const bool &bezier,
58 const bool &weightNumbers=false,
59 const bool &highlighting=true);
61
62 enum { Type = UserType + 2 };
63 int type() const { return Type; }
64
65 GraphicsNode *sourceNode() const;
66 void setSourceNode(GraphicsNode *node);
67
68 GraphicsNode *targetNode() const;
69 void setTargetNode(GraphicsNode *node);
70
71 int sourceNodeNumber();
72 int targetNodeNumber();
73
74 qreal dx() const;
75
76 qreal dy() const;
77
78 qreal length() const;
79
80 void setSourceNodeSize(const int & size);
81 void setTargetNodeSize(const int & size);
82
83 void setMinimumOffsetFromNode(const int & offset);
84
85 void removeRefs();
86
87 void setWeight( const qreal &w) ;
88 qreal weight() const;
89 void addWeightNumber ();
90 //void deleteWeightNumber();
91 void setWeightNumberVisibility (const bool &toggle);
92
93 void setLabel( const QString &label) ;
94 QString label() const;
95 void addLabel();
96 //void deleteLabel();
97 void setLabelVisibility (const bool &toggle);
98
99 void showArrows(const bool &);
100
101 void setDirectionType(const int &dirType=0);
102 int directionType();
103
104 qreal width() const;
105
106 QPen pen() const;
107 void setState(const int &state);
108
109 void setStyle( const Qt::PenStyle &style);
110 Qt::PenStyle style() const;
111
112 void setColor( const QString &str) ;
113 //QString color() const ;
114 QColor color() const;
115 QString colorToPajek();
116
117 void setHighlighted (const bool &flag);
118 void setHighlighting (const bool &toggle);
119
120 QPainterPath shape() const;
121
122
123public slots:
124 void adjust ();
125
126protected:
127 QRectF boundingRect() const;
128 void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget);
129 QVariant itemChange(GraphicsItemChange change, const QVariant &value);
130// void mousePressEvent(QGraphicsSceneMouseEvent *event);
131
132
133
134private:
136
138
140
142
143 QPainterPath m_path;
144
146
147 QPointF edgeOffset;
148
150
153
154 Qt::PenStyle m_style;
156
158 QColor m_color;
159
161
163
165
169};
170
171#endif
Definition graphicsedgelabel.h:28
Definition graphicsedgeweight.h:28
Definition graphicsedge.h:49
void showArrows(const bool &)
Toggles displaying edge arrow.
Definition graphicsedge.cpp:126
void setState(const int &state)
Sets the edge state.
Definition graphicsedge.cpp:667
QPointF sourcePoint
Definition graphicsedge.h:145
GraphicsEdgeLabel * edgeLabel
Definition graphicsedge.h:141
QPointF edgeOffset
Definition graphicsedge.h:147
void setColor(const QString &str)
Sets the edge color.
Definition graphicsedge.cpp:148
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
Pains the edge.
Definition graphicsedge.cpp:679
void removeRefs()
Removes any references to this edge in source and target nodes.
Definition graphicsedge.cpp:137
GraphicsEdgeWeight * weightNumber
Definition graphicsedge.h:139
QRectF boundingRect() const
Defines the outer bounds of the edge as a rectangle; All painting will be restricted to inside the ed...
Definition graphicsedge.cpp:579
QString label() const
Returns the edge label text.
Definition graphicsedge.cpp:265
QPainterPath shape() const
Returns the shape of this edge as a QPainterPath in local coordinates. The shape is used for many thi...
Definition graphicsedge.cpp:563
qreal m_arrowSize
Definition graphicsedge.h:149
qreal m_offsetFromTargetNode
Definition graphicsedge.h:152
QVariant itemChange(GraphicsItemChange change, const QVariant &value)
Called when the edge changes, i.e. moves, becomes disabled or changes its visibility.
Definition graphicsedge.cpp:723
GraphicsWidget * graphicsWidget
Definition graphicsedge.h:135
void setLabelVisibility(const bool &toggle)
Toggles the graphics edge label visibility.
Definition graphicsedge.cpp:287
QColor color() const
Returns the edge QColor.
Definition graphicsedge.cpp:158
QString colorToPajek()
Returns the edge color in pajek-accepted format.
Definition graphicsedge.cpp:170
void addLabel()
Adds a graphics edge label to this edge.
Definition graphicsedge.cpp:273
void adjust()
Leaves some empty space (offset) from node - make the edge weight appear on the centre of the edge.
Definition graphicsedge.cpp:420
int targetNodeNumber()
Definition graphicsedge.cpp:371
qreal length() const
Returns the euclidean length of the edge.
Definition graphicsedge.cpp:410
void setStyle(const Qt::PenStyle &style)
Sets the PenStyle of this edge.
Definition graphicsedge.cpp:621
qreal dy() const
Returns the vertical difference between target and source nodes.
Definition graphicsedge.cpp:400
void setHighlighted(const bool &flag)
Toggles the highlighted state of the the edge, if highlighting is allowed.
Definition graphicsedge.cpp:775
GraphicsNode * sourceNode() const
Returns the source node of this graphics edge.
Definition graphicsedge.cpp:306
QString m_label
Definition graphicsedge.h:157
QPen pen() const
Returns the QPen for this edge – the pen changes when the edge state changes/.
Definition graphicsedge.cpp:639
void setWeightNumberVisibility(const bool &toggle)
Toggles visibility of weight numbers.
Definition graphicsedge.cpp:228
bool m_drawWeightNumber
Definition graphicsedge.h:166
qreal angle
Definition graphicsedge.h:164
qreal m_width
Definition graphicsedge.h:160
GraphicsNode * target
Definition graphicsedge.h:137
bool m_hoverHighlighting
Definition graphicsedge.h:167
QColor m_color
Definition graphicsedge.h:158
void addWeightNumber()
Adds a graphics edge weight to this edge.
Definition graphicsedge.cpp:213
void setLabel(const QString &label)
Changes the edge label.
Definition graphicsedge.cpp:252
qreal dx() const
Returns the horizontal difference between target and source nodes.
Definition graphicsedge.cpp:391
qreal width() const
Returns the width of the edge as a function of edge weight.
Definition graphicsedge.cpp:762
int type() const
Definition graphicsedge.h:63
void setMinimumOffsetFromNode(const int &offset)
Updates Minimum Offset From Node and calls adjust to update the edge.
Definition graphicsedge.cpp:380
@ Type
Definition graphicsedge.h:62
bool m_Bezier
Definition graphicsedge.h:166
qreal line_length
Definition graphicsedge.h:164
bool m_drawLabel
Definition graphicsedge.h:167
qreal m_weight
Definition graphicsedge.h:160
bool m_drawArrows
Definition graphicsedge.h:166
QPainterPath m_path
Definition graphicsedge.h:143
qreal weight() const
Returns the weight/value of this edge.
Definition graphicsedge.cpp:205
bool m_isClicked
Definition graphicsedge.h:168
Qt::PenStyle m_style
Definition graphicsedge.h:154
int m_state
Definition graphicsedge.h:155
qreal m_offsetFromSourceNode
Definition graphicsedge.h:152
Qt::PenStyle style() const
Returns the PenStyle of this edge.
Definition graphicsedge.cpp:630
void setWeight(const qreal &w)
Changes the edge weight - Updates both the width and the weightNumber.
Definition graphicsedge.cpp:186
qreal line_dy
Definition graphicsedge.h:164
int m_edgeDirType
Definition graphicsedge.h:162
void setTargetNodeSize(const int &size)
Called from graphicsNode to update edge offset from target node (i.e. when node size changes)
Definition graphicsedge.cpp:362
qreal line_dx
Definition graphicsedge.h:164
~GraphicsEdge()
‍**
Definition graphicsedge.cpp:816
GraphicsNode * source
Definition graphicsedge.h:137
void setTargetNode(GraphicsNode *node)
Sets the target node.s.
Definition graphicsedge.cpp:353
void setDirectionType(const int &dirType=0)
Changes the direction type of edge A->B.
Definition graphicsedge.cpp:590
QPointF targetPoint
Definition graphicsedge.h:145
QString m_colorNegative
Definition graphicsedge.h:157
GraphicsNode * targetNode() const
Returns the target node.
Definition graphicsedge.cpp:344
void setSourceNode(GraphicsNode *node)
Sets the source node of this graphics edge.
Definition graphicsedge.cpp:315
void setHighlighting(const bool &toggle)
Toggles edge highlighting on or off.
Definition graphicsedge.cpp:795
qreal m_minOffsetFromNode
Definition graphicsedge.h:151
void setSourceNodeSize(const int &size)
Called from graphicsNode to update edge offset from source node (i.e. when node size changes)
Definition graphicsedge.cpp:325
int directionType()
returns the direction type of this edge
Definition graphicsedge.cpp:611
int sourceNodeNumber()
Definition graphicsedge.cpp:335
Definition graphicsnode.h:47
Definition graphicswidget.h:42
static const int EDGE_STATE_HOVER
Definition graphicsedge.h:43
static const int TypeEdge
Definition graphicsedge.h:37
static const int EDGE_STATE_REGULAR
Definition graphicsedge.h:41
static const int ZValueEdge
Definition graphicsedge.h:38
static const int EDGE_STATE_HIGHLIGHT
Definition graphicsedge.h:42
static const int ZValueEdgeHighlighted
Definition graphicsedge.h:39