![]() |
Code Documentation 3.6
Social Network Visualizer
|
#include <graphicsedge.h>


Public Types | |
| enum | { Type = UserType + 2 } |
Public Slots | |
| void | adjust () |
| Recomputes all geometry for this edge. | |
Public Member Functions | |
| 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) | |
| ~GraphicsEdge () | |
| handles the events of a click on an edge | |
| int | type () const |
| GraphicsNode * | sourceNode () const |
| Returns the source node of this graphics edge. | |
| void | setSourceNode (GraphicsNode *node) |
| Sets the source node of this graphics edge. | |
| GraphicsNode * | targetNode () const |
| Returns the target node. | |
| void | setTargetNode (GraphicsNode *node) |
| Sets the target node.s. | |
| int | sourceNodeNumber () |
| int | targetNodeNumber () |
| qreal | dx () const |
| Returns the horizontal difference between target and source nodes. | |
| qreal | dy () const |
| Returns the vertical difference between target and source nodes. | |
| qreal | length () const |
| Returns the euclidean length of the edge. | |
| void | setSourceNodeSize (const int &size) |
| Called from graphicsNode to update edge offset from source node (i.e. when node size changes). | |
| void | setTargetNodeSize (const int &size) |
| Called from graphicsNode to update edge offset from target node (i.e. when node size changes). | |
| void | setMinimumOffsetFromNode (const int &offset) |
| Updates Minimum Offset From Node and calls adjust to update the edge. | |
| void | removeRefs () |
| Removes any references to this edge in source and target nodes. | |
| void | setWeight (const qreal &w) |
| Changes the edge weight - Updates both the width and the weightNumber. | |
| qreal | weight () const |
| Returns the weight/value of this edge. | |
| void | addWeightNumber () |
| Adds a graphics edge weight to this edge. | |
| void | setWeightNumberVisibility (const bool &toggle) |
| Toggles visibility of weight numbers. | |
| void | setLabel (const QString &label) |
| Changes the edge label. | |
| QString | label () const |
| Returns the edge label text. | |
| void | addLabel () |
| Adds a graphics edge label to this edge. | |
| void | setLabelVisibility (const bool &toggle) |
| Toggles the graphics edge label visibility. | |
| void | showArrows (const bool &) |
| Toggles displaying edge arrow. | |
| void | toggleBezier (const bool &toggle) |
| void | setArrowSize (const int &size) |
| Sets the arrow size for this edge. Recalculates only the four cached arrow-corner points (no path rebuild) then schedules a repaint. | |
| int | arrowSize () const |
| void | setDirectionType (const int &dirType=0) |
| Changes the direction type of edge A->B. | |
| int | directionType () |
| returns the direction type of this edge | |
| qreal | width () const |
| Returns the width of the edge as a function of edge weight. | |
| QPen | pen () const |
| Returns the QPen for this edge – the pen changes when the edge state changes/. | |
| void | setState (const int &state) |
| Sets the edge state. | |
| void | setStyle (const Qt::PenStyle &style) |
| Sets the PenStyle of this edge. | |
| Qt::PenStyle | style () const |
| Returns the PenStyle of this edge. | |
| void | setColor (const QString &str) |
| Sets the edge color. | |
| QColor | color () const |
| Returns the edge QColor. | |
| QString | colorToPajek () |
| Returns the edge color in pajek-accepted format. | |
| void | setHighlighted (const bool &flag) |
| Toggles the highlighted state of the the edge, if highlighting is allowed. | |
| void | setHighlighting (const bool &toggle) |
| Toggles edge highlighting on or off. | |
| QPainterPath | shape () const |
| Returns the shape of this edge as a QPainterPath in local coordinates. The shape is used for many things, including collision detection, hit tests, and for the QGraphicsScene::items() functions. The default implementation calls boundingRect() to return a simple rectangular shape, but we reimplement it to return a more accurate shape for non-rectangular items. | |
Protected Member Functions | |
| QRectF | boundingRect () const |
| Defines the outer bounds of the edge as a rectangle; All painting will be restricted to inside the edge's bounding rect. Qt uses this bounding rect to determine whether the edge requires redrawing. | |
| void | paint (QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) |
| Paints the edge onto the canvas. | |
| QVariant | itemChange (GraphicsItemChange change, const QVariant &value) |
| Called when the edge changes, i.e. moves, becomes disabled or changes its visibility. | |
Private Member Functions | |
| void | computeArrowPoints () |
| Fills the four cached arrow-corner QPointFs. | |
| void | rebuildPens () |
| Rebuilds the three cached QPens and the cached QBrush. | |
Private Attributes | |
| GraphicsWidget * | graphicsWidget |
| GraphicsNode * | source |
| GraphicsNode * | target |
| GraphicsEdgeWeight * | weightNumber |
| GraphicsEdgeLabel * | edgeLabel |
| QPainterPath | m_path |
| QPointF | sourcePoint |
| QPointF | targetPoint |
| QPointF | edgeOffset |
| QPointF | m_destArrowP1 |
| QPointF | m_destArrowP2 |
| QPointF | m_srcArrowP1 |
| QPointF | m_srcArrowP2 |
| qreal | m_arrowSize |
| qreal | m_minOffsetFromNode |
| qreal | m_offsetFromTargetNode |
| qreal | m_offsetFromSourceNode |
| Qt::PenStyle | m_style |
| int | m_state |
| QString | m_colorNegative |
| QString | m_label |
| QColor | m_color |
| qreal | m_weight |
| qreal | m_width |
| int | m_edgeDirType |
| qreal | angle |
| qreal | m_srcAngle |
| qreal | line_length |
| qreal | line_dx |
| qreal | line_dy |
| bool | m_Bezier |
| bool | m_drawArrows |
| bool | m_drawWeightNumber |
| bool | m_drawLabel |
| bool | m_hoverHighlighting |
| bool | m_isClicked |
| QPen | m_penRegular |
| QPen | m_penHighlight |
| QPen | m_penHover |
| QBrush | m_brush |
| SOCNETV_USE_NAMESPACE GraphicsEdge::GraphicsEdge | ( | GraphicsWidget * | gw, |
| GraphicsNode * | from, | ||
| GraphicsNode * | to, | ||
| 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 ) |
| GraphicsEdge::~GraphicsEdge | ( | ) |
handles the events of a click on an edge
| event |
| void GraphicsEdge::addLabel | ( | ) |
Adds a graphics edge label to this edge.
| void GraphicsEdge::addWeightNumber | ( | ) |
Adds a graphics edge weight to this edge.
|
slot |
Recomputes all geometry for this edge.
Called whenever a connected node moves or any geometric property changes (node size, offset, bezier mode, etc.). Executes four steps in order:
line_dx / line_dy / line_length from current node centres.sourcePoint / targetPoint — offset from node centres along the chord direction (straight mode) or along the curve tangent at each endpoint (bezier mode), so arrowheads land on the node boundary in the correct direction.m_path: lineTo() quadTo() with curvature capped at min(40 px, line_length × 0.3) to avoid extreme bowing on short edgescubicTo() with fixed ±30 px control offsetsangle (tangent at targetPoint) and m_srcAngle (tangent at sourcePoint), then calls computeArrowPoints() to fill the four cached arrow-corner QPointFs.Arrow polygons are intentionally not added to m_path so that changing m_arrowSize only requires recomputing four QPointFs and a repaint — not a full path rebuild.
| int GraphicsEdge::arrowSize | ( | ) | const |
|
protected |
Defines the outer bounds of the edge as a rectangle; All painting will be restricted to inside the edge's bounding rect. Qt uses this bounding rect to determine whether the edge requires redrawing.
| QColor GraphicsEdge::color | ( | ) | const |
Returns the edge QColor.
| QString GraphicsEdge::colorToPajek | ( | ) |
|
private |
Fills the four cached arrow-corner QPointFs.
Uses angle (curve tangent direction at targetPoint, in the source→target sense) for the destination arrowhead wings, and m_srcAngle (tangent direction at sourcePoint) for the source arrowhead on undirected / reciprocated edges. For straight edges m_srcAngle == angle; for bezier curves they differ because the tangent varies along the arc.
Called by adjust() and by setArrowSize() so paint() performs no trigonometry of its own.
| int GraphicsEdge::directionType | ( | ) |
returns the direction type of this edge
| qreal GraphicsEdge::dx | ( | ) | const |
Returns the horizontal difference between target and source nodes.
| qreal GraphicsEdge::dy | ( | ) | const |
Returns the vertical difference between target and source nodes.
|
protected |
Called when the edge changes, i.e. moves, becomes disabled or changes its visibility.
| change | |
| value |
| QString GraphicsEdge::label | ( | ) | const |
Returns the edge label text.
| qreal GraphicsEdge::length | ( | ) | const |
Returns the euclidean length of the edge.
|
protected |
Paints the edge onto the canvas.
Draws the pre-built line/self-loop m_path, then draws the arrow polygons from the cached corner points (m_destArrowP1/P2 and, for undirected/reciprocated edges, m_srcArrowP1/P2). No trigonometry is performed here — all geometry is pre-computed by adjust() and computeArrowPoints(), so this method is as cheap as possible for the common case of a static network.
| painter | The QPainter provided by the scene. |
| option | Style options (selection, hover state). |
| QPen GraphicsEdge::pen | ( | ) | const |
Returns the QPen for this edge – the pen changes when the edge state changes/.
|
private |
Rebuilds the three cached QPens and the cached QBrush.
Called from the constructor and from any setter that changes a pen-relevant field (color, weight/width, style). This keeps paint() free of per-repaint object construction.
| void GraphicsEdge::removeRefs | ( | ) |
Removes any references to this edge in source and target nodes.
| void GraphicsEdge::setArrowSize | ( | const int & | size | ) |
Sets the arrow size for this edge. Recalculates only the four cached arrow-corner points (no path rebuild) then schedules a repaint.
| void GraphicsEdge::setColor | ( | const QString & | str | ) |
Sets the edge color.
| str |
| void GraphicsEdge::setDirectionType | ( | const int & | dirType = 0 | ) |
Changes the direction type of edge A->B.
| void GraphicsEdge::setHighlighted | ( | const bool & | flag | ) |
Toggles the highlighted state of the the edge, if highlighting is allowed.
Called from GraphicsNode when the user hovers over the node.
| flag |
| void GraphicsEdge::setHighlighting | ( | const bool & | toggle | ) |
Toggles edge highlighting on or off.
If enabled, the edge can be highlighted.
| toggle |
| void GraphicsEdge::setLabel | ( | const QString & | label | ) |
| void GraphicsEdge::setLabelVisibility | ( | const bool & | toggle | ) |
Toggles the graphics edge label visibility.
| toggle |
| void GraphicsEdge::setMinimumOffsetFromNode | ( | const int & | offset | ) |
Updates Minimum Offset From Node and calls adjust to update the edge.
| offset |
| void GraphicsEdge::setSourceNode | ( | GraphicsNode * | node | ) |
Sets the source node of this graphics edge.
| node |
| void GraphicsEdge::setSourceNodeSize | ( | const int & | size | ) |
Called from graphicsNode to update edge offset from source node (i.e. when node size changes).
| offset |
| void GraphicsEdge::setState | ( | const int & | state | ) |
Sets the edge state.
| state |
| void GraphicsEdge::setStyle | ( | const Qt::PenStyle & | style | ) |
Sets the PenStyle of this edge.
| style |
| void GraphicsEdge::setTargetNode | ( | GraphicsNode * | node | ) |
Sets the target node.s.
| node |
| void GraphicsEdge::setTargetNodeSize | ( | const int & | size | ) |
Called from graphicsNode to update edge offset from target node (i.e. when node size changes).
| offset |
| void GraphicsEdge::setWeight | ( | const qreal & | w | ) |
Changes the edge weight - Updates both the width and the weightNumber.
Called from MW when user wants to change an edge's weight.
| w |
| void GraphicsEdge::setWeightNumberVisibility | ( | const bool & | toggle | ) |
Toggles visibility of weight numbers.
| toggle |
| QPainterPath GraphicsEdge::shape | ( | ) | const |
Returns the shape of this edge as a QPainterPath in local coordinates. The shape is used for many things, including collision detection, hit tests, and for the QGraphicsScene::items() functions. The default implementation calls boundingRect() to return a simple rectangular shape, but we reimplement it to return a more accurate shape for non-rectangular items.
| void GraphicsEdge::showArrows | ( | const bool & | drawArrows | ) |
Toggles displaying edge arrow.
| drawArrows |
| GraphicsNode * GraphicsEdge::sourceNode | ( | ) | const |
Returns the source node of this graphics edge.
| int GraphicsEdge::sourceNodeNumber | ( | ) |
Returns the source node number
| Qt::PenStyle GraphicsEdge::style | ( | ) | const |
Returns the PenStyle of this edge.
| GraphicsNode * GraphicsEdge::targetNode | ( | ) | const |
Returns the target node.
| int GraphicsEdge::targetNodeNumber | ( | ) |
Returns the target node number
| void GraphicsEdge::toggleBezier | ( | const bool & | toggle | ) |
|
inline |
| qreal GraphicsEdge::weight | ( | ) | const |
Returns the weight/value of this edge.
| qreal GraphicsEdge::width | ( | ) | const |
Returns the width of the edge as a function of edge weight.
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |