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:130
@ Type
Definition graphicsedge.h:65
void setState(const int &state)
Sets the edge state.
Definition graphicsedge.cpp:731
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:206
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
Paints the edge onto the canvas.
Definition graphicsedge.cpp:750
void removeRefs()
Removes any references to this edge in source and target nodes.
Definition graphicsedge.cpp:194
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:323
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:615
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:802
GraphicsWidget * graphicsWidget
Definition graphicsedge.h:143
void setLabelVisibility(const bool &toggle)
Toggles the graphics edge label visibility.
Definition graphicsedge.cpp:345
qreal m_srcAngle
Definition graphicsedge.h:177
QColor color() const
Returns the edge QColor.
Definition graphicsedge.cpp:217
QString colorToPajek()
Returns the edge color in pajek-accepted format.
Definition graphicsedge.cpp:229
void toggleBezier(const bool &toggle)
Definition graphicsedge.cpp:136
void addLabel()
Adds a graphics edge label to this edge.
Definition graphicsedge.cpp:331
void adjust()
Recomputes all geometry for this edge.
Definition graphicsedge.cpp:498
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:685
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:175
int targetNodeNumber()
Definition graphicsedge.cpp:429
qreal length() const
Returns the euclidean length of the edge.
Definition graphicsedge.cpp:468
void setStyle(const Qt::PenStyle &style)
Sets the PenStyle of this edge.
Definition graphicsedge.cpp:672
QPen m_penRegular
Definition graphicsedge.h:187
qreal dy() const
Returns the vertical difference between target and source nodes.
Definition graphicsedge.cpp:458
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:854
GraphicsNode * sourceNode() const
Returns the source node of this graphics edge.
Definition graphicsedge.cpp:364
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:708
void setWeightNumberVisibility(const bool &toggle)
Toggles visibility of weight numbers.
Definition graphicsedge.cpp:287
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:154
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:272
QBrush m_brush
Definition graphicsedge.h:190
void setLabel(const QString &label)
Changes the edge label.
Definition graphicsedge.cpp:311
qreal dx() const
Returns the horizontal difference between target and source nodes.
Definition graphicsedge.cpp:449
qreal width() const
Returns the width of the edge as a function of edge weight.
Definition graphicsedge.cpp:841
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:438
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:264
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:699
void setWeight(const qreal &w)
Changes the edge weight - Updates both the width and the weightNumber.
Definition graphicsedge.cpp:245
int arrowSize() const
Definition graphicsedge.cpp:182
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:420
qreal line_dx
Definition graphicsedge.h:177
~GraphicsEdge()
handles the events of a click on an edge
Definition graphicsedge.cpp:893
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:411
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:402
void setSourceNode(GraphicsNode *node)
Sets the source node of this graphics edge.
Definition graphicsedge.cpp:373
void setHighlighting(const bool &toggle)
Toggles edge highlighting on or off.
Definition graphicsedge.cpp:873
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:383
int directionType()
returns the direction type of this edge
Definition graphicsedge.cpp:662
int sourceNodeNumber()
Definition graphicsedge.cpp:393
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