21#include <QGraphicsItem>
29class QGraphicsSceneMouseEvent;
39static const int TypeEdge= QGraphicsItem::UserType+2;
53 Q_INTERFACES (QGraphicsItem)
58 const Qt::PenStyle &
style,
59 const int&
type,
const bool & drawArrows,
const bool &bezier,
60 const bool &weightNumbers=
false,
61 const bool &highlighting=
true,
65 enum {
Type = UserType + 2 };
97 QString
label()
const;
118 Qt::PenStyle
style()
const;
120 void setColor(
const QString &str) ;
122 QColor
color()
const;
128 QPainterPath
shape()
const;
136 void paint(QPainter *painter,
const QStyleOptionGraphicsItem *option, QWidget *widget);
137 QVariant
itemChange(GraphicsItemChange change,
const QVariant &value);
void showArrows(const bool &)
Toggles displaying edge arrow.
Definition graphicsedge.cpp:131
@ Type
Definition graphicsedge.h:65
void setState(const int &state)
Sets the edge state.
Definition graphicsedge.cpp:737
QPointF sourcePoint
Definition graphicsedge.h:153
GraphicsEdgeLabel * edgeLabel
Definition graphicsedge.h:149
QPointF edgeOffset
Definition graphicsedge.h:155
void setColor(const QString &str)
Sets the edge color.
Definition graphicsedge.cpp:202
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
Paints the edge onto the canvas.
Definition graphicsedge.cpp:756
void removeRefs()
Removes any references to this edge in source and target nodes.
Definition graphicsedge.cpp:191
GraphicsEdgeWeight * weightNumber
Definition graphicsedge.h:147
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:630
QPointF m_destArrowP1
Definition graphicsedge.h:159
QPointF m_srcArrowP1
Definition graphicsedge.h:160
QPointF m_srcArrowP2
Definition graphicsedge.h:160
QString label() const
Returns the edge label text.
Definition graphicsedge.cpp:321
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:614
qreal m_arrowSize
Definition graphicsedge.h:162
qreal m_offsetFromTargetNode
Definition graphicsedge.h:165
QVariant itemChange(GraphicsItemChange change, const QVariant &value)
Called when the edge changes, i.e. moves, becomes disabled or changes its visibility.
Definition graphicsedge.cpp:809
GraphicsWidget * graphicsWidget
Definition graphicsedge.h:143
void setLabelVisibility(const bool &toggle)
Toggles the graphics edge label visibility.
Definition graphicsedge.cpp:343
qreal m_srcAngle
Definition graphicsedge.h:177
QColor color() const
Returns the edge QColor.
Definition graphicsedge.cpp:213
QString colorToPajek()
Returns the edge color in pajek-accepted format.
Definition graphicsedge.cpp:225
void toggleBezier(const bool &toggle)
Definition graphicsedge.cpp:137
void addLabel()
Adds a graphics edge label to this edge.
Definition graphicsedge.cpp:329
void adjust()
Recomputes all geometry for this edge.
Definition graphicsedge.cpp:496
GraphicsEdge(GraphicsWidget *, GraphicsNode *, GraphicsNode *, const qreal &weight, const QString &label, const QString &color, const Qt::PenStyle &style, const int &type, const bool &drawArrows, const bool &bezier, const bool &weightNumbers=false, const bool &highlighting=true, const int &arrowSize=6)
Definition graphicsedge.cpp:36
void rebuildPens()
Rebuilds the three cached QPens and the cached QBrush.
Definition graphicsedge.cpp:686
void setArrowSize(const int &size)
Sets the arrow size for this edge. Recalculates only the four cached arrow-corner points (no path reb...
Definition graphicsedge.cpp:176
int targetNodeNumber()
Definition graphicsedge.cpp:427
qreal length() const
Returns the euclidean length of the edge.
Definition graphicsedge.cpp:466
void setStyle(const Qt::PenStyle &style)
Sets the PenStyle of this edge.
Definition graphicsedge.cpp:673
QPen m_penRegular
Definition graphicsedge.h:187
qreal dy() const
Returns the vertical difference between target and source nodes.
Definition graphicsedge.cpp:456
QPointF m_destArrowP2
Definition graphicsedge.h:159
void setHighlighted(const bool &flag)
Toggles the highlighted state of the the edge, if highlighting is allowed.
Definition graphicsedge.cpp:861
GraphicsNode * sourceNode() const
Returns the source node of this graphics edge.
Definition graphicsedge.cpp:362
QString m_label
Definition graphicsedge.h:170
QPen pen() const
Returns the QPen for this edge – the pen changes when the edge state changes/.
Definition graphicsedge.cpp:709
void setWeightNumberVisibility(const bool &toggle)
Toggles visibility of weight numbers.
Definition graphicsedge.cpp:284
bool m_drawWeightNumber
Definition graphicsedge.h:179
qreal angle
Definition graphicsedge.h:177
void computeArrowPoints()
Fills the four cached arrow-corner QPointFs.
Definition graphicsedge.cpp:155
qreal m_width
Definition graphicsedge.h:173
GraphicsNode * target
Definition graphicsedge.h:145
bool m_hoverHighlighting
Definition graphicsedge.h:180
QColor m_color
Definition graphicsedge.h:171
void addWeightNumber()
Adds a graphics edge weight to this edge.
Definition graphicsedge.cpp:269
QBrush m_brush
Definition graphicsedge.h:190
void setLabel(const QString &label)
Changes the edge label.
Definition graphicsedge.cpp:308
qreal dx() const
Returns the horizontal difference between target and source nodes.
Definition graphicsedge.cpp:447
qreal width() const
Returns the width of the edge as a function of edge weight.
Definition graphicsedge.cpp:848
int type() const
Definition graphicsedge.h:66
void setMinimumOffsetFromNode(const int &offset)
Updates Minimum Offset From Node and calls adjust to update the edge.
Definition graphicsedge.cpp:436
bool m_Bezier
Definition graphicsedge.h:179
qreal line_length
Definition graphicsedge.h:177
bool m_drawLabel
Definition graphicsedge.h:180
qreal m_weight
Definition graphicsedge.h:173
bool m_drawArrows
Definition graphicsedge.h:179
QPainterPath m_path
Definition graphicsedge.h:151
qreal weight() const
Returns the weight/value of this edge.
Definition graphicsedge.cpp:261
bool m_isClicked
Definition graphicsedge.h:181
Qt::PenStyle m_style
Definition graphicsedge.h:167
int m_state
Definition graphicsedge.h:168
qreal m_offsetFromSourceNode
Definition graphicsedge.h:165
Qt::PenStyle style() const
Returns the PenStyle of this edge.
Definition graphicsedge.cpp:700
void setWeight(const qreal &w)
Changes the edge weight - Updates both the width and the weightNumber.
Definition graphicsedge.cpp:241
int arrowSize() const
Definition graphicsedge.cpp:183
qreal line_dy
Definition graphicsedge.h:177
int m_edgeDirType
Definition graphicsedge.h:175
void setTargetNodeSize(const int &size)
Called from graphicsNode to update edge offset from target node (i.e. when node size changes).
Definition graphicsedge.cpp:418
qreal line_dx
Definition graphicsedge.h:177
~GraphicsEdge()
handles the events of a click on an edge
Definition graphicsedge.cpp:902
QPen m_penHighlight
Definition graphicsedge.h:188
GraphicsNode * source
Definition graphicsedge.h:145
void setTargetNode(GraphicsNode *node)
Sets the target node.s.
Definition graphicsedge.cpp:409
void setDirectionType(const int &dirType=0)
Changes the direction type of edge A->B.
Definition graphicsedge.cpp:642
QPointF targetPoint
Definition graphicsedge.h:153
QString m_colorNegative
Definition graphicsedge.h:170
GraphicsNode * targetNode() const
Returns the target node.
Definition graphicsedge.cpp:400
void setSourceNode(GraphicsNode *node)
Sets the source node of this graphics edge.
Definition graphicsedge.cpp:371
void setHighlighting(const bool &toggle)
Toggles edge highlighting on or off.
Definition graphicsedge.cpp:881
QPen m_penHover
Definition graphicsedge.h:189
qreal m_minOffsetFromNode
Definition graphicsedge.h:164
void setSourceNodeSize(const int &size)
Called from graphicsNode to update edge offset from source node (i.e. when node size changes).
Definition graphicsedge.cpp:381
int directionType()
returns the direction type of this edge
Definition graphicsedge.cpp:663
int sourceNodeNumber()
Definition graphicsedge.cpp:391
Definition graphicsedgelabel.h:28
Definition graphicsedgeweight.h:28
Definition graphicsnode.h:49
static const int EDGE_STATE_HOVER
Definition graphicsedge.h:45
static const int TypeEdge
Definition graphicsedge.h:39
static const int EDGE_STATE_REGULAR
Definition graphicsedge.h:43
static const int ZValueEdge
Definition graphicsedge.h:40
static const int EDGE_STATE_HIGHLIGHT
Definition graphicsedge.h:44
static const int ZValueEdgeHighlighted
Definition graphicsedge.h:41