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


Public Slots | |
| void | handleSelectionChanged () |
| Handles the event of selection change in the scene. | |
| void | relationSet (int relation) |
| Changes the current relation. | |
| void | drawNode (const QPointF &p, const int &num, const int &nodeSize, const QString &nodeShape, const QString &nodeIconPath, const QString &nodeColor, const QString &numberColor, const int &numberSize, const int &numberDistance, const QString &nodeLabel, const QString &labelColor, const int &labelSize, const int &labelDistance) |
| Draws a new node in the scene. | |
| void | removeNode (const int &nodeNum) |
| Deletes the node with the given number from the scene, if exists. | |
| void | setNodeVisibility (const int &nodeNum, const bool &toggle) |
| Changes the visibility of a Node. | |
| void | setNodeClicked (GraphicsNode *) |
| Clears clickedEdge and emits a signal to Graph. | |
| void | moveNode (const int &num, const qreal &x, const qreal &y) |
| Moves the node with the given number to the new coordinates. | |
| bool | setNodeSize (const int &nodeNumber, const int &size=0) |
| Changes the size of a node. | |
| bool | setNodeShape (const int &nodeNum, const QString &shape, const QString &iconPath=QString()) |
| Sets the shape of an node. | |
| bool | setNodeColor (const int &nodeNum, const QString &color) |
| Sets the color of an node. | |
| void | setNodeNumberColor (const int &nodeNum, const QString &color) |
| Changes the color of a node number. | |
| void | setNodeNumberVisibility (const bool &toggle) |
| Toggles the visibility of node numbers. | |
| bool | setNodeNumberSize (const int &nodeNum, const int &size=0) |
| Changes the size of the number of a node. | |
| bool | setNodeNumberDistance (const int &, const int &distance=0) |
| Changes the distance of the number of a node. | |
| void | setNodeLabelsVisibility (const bool &toggle) |
| Toggles the visibility of all node labels. | |
| bool | setNodeLabelColor (const int &nodeNum, const QString &color="green") |
| Changes the label color of a node to 'color'. | |
| bool | setNodeLabelSize (const int &, const int &size=0) |
| Changes the label size of a node to 'size'. | |
| bool | setNodeLabel (const int &, const QString &label) |
| Sets the label of an node. | |
| bool | setNodeLabelDistance (const int &, const int &distance=0) |
| Changes the distance of the label of the given node. | |
| void | drawEdge (const int &source, const int &target, const qreal &weight, const QString &label="", const QString &color="black", const int &type=0, const bool &drawArrows=true, const bool &bezier=false, const bool &weightNumbers=false) |
| Draws a new edge in the scene, from node with sourceNum to node with targetNum. | |
| void | removeEdge (const int &source, const int &target, const bool &removeOpposite=false) |
| Removes the edge from node sourceNum to node targetNum from the scene. | |
| void | setEdgeVisibility (const int &relation, const int &sourceNum, const int &targetNum, const bool &visible, const bool &preserveReverseEdge=false, const int &edgeWeight=1, const int &reverseEdgeWeight=1) |
| Toggles the visibility of the given edge. | |
| void | setEdgesVisibilityBatch (const QList< EdgeVisibilityChange > &changes) |
| Applies a batch of edge visibility changes in one call (WS3 M2). | |
| bool | setEdgeDirectionType (const int &source, const int &target, const int &dirType=false) |
| Changes the direction type of an existing edge. | |
| bool | setEdgeWeight (const int &, const int &, const qreal &) |
| Sets the weight of an edge. | |
| void | setEdgeLabel (const int &source, const int &target, const QString &label) |
| Sets the label of an edge. | |
| void | setEdgeColor (const int &, const int &, const QString &) |
| Sets the color of an edge. | |
| void | setEdgeClicked (GraphicsEdge *, const bool &openMenu=false) |
| Sets the clicked edge. | |
| void | setEdgeOffsetFromNode (const int &source, const int &target, const int &offset) |
| Changes the offset of an edge (or all edges) from source and target nodes. | |
| void | setEdgeArrowsVisibility (const bool &toggle) |
| Toggles the visibility of all edge arrows. | |
| void | setEdgeArrowSize (const int &size) |
| Sets the arrow size for all edges and stores it as the default for new edges. | |
| void | setEdgeWeightNumbersVisibility (const bool &toggle) |
| Toggles all edge weight numbers visibility. | |
| void | setEdgeLabelsVisibility (const bool &toggle) |
| Toggles all edge labels visibility. | |
| void | setEdgesBezier (const bool &toggle) |
| Toggles bezier-curve rendering for all edges currently in the scene. | |
| void | setEdgeHighlighting (const bool &toggle) |
| Enables or disables edge highlighting. | |
| void | selectPath (const QList< int > &path) |
| Selects the edges that form a shortest path, exactly as if the user had Shift-clicked each edge in turn. | |
| void | handleDoubleClickOnNode (GraphicsNode *node) |
| Handles double-clicks (or middle-clicks) on the given node, creating a new edge if needed. | |
| void | clearGuides () |
| Removes and deletes all guide items previously added via addGuideCircle()/addGuideHLine(), without scanning the scene. | |
| void | addGuideCircle (const double &x0, const double &y0, const double &radius) |
| Adds a circular guideline. | |
| void | addGuideHLine (const double &y0) |
| Adds a horizonal guideline. | |
| void | zoomIn (const int step=1) |
| Increases the numerical zoom index of the scene by the given step. | |
| void | zoomOut (const int step=1) |
| Decreases the numerical zoom index of the scene by the given step. | |
| void | zoomToFit () |
| Scales and centres the view so that the full network is visible. | |
| void | rotateLeft () |
| Decreases the numerical rotation Rotates the view to the left, by a fixed angle. | |
| void | rotateRight () |
| Rotates the view to the right, by a fixed angle. | |
| void | changeMatrixScale (const int value) |
| Does the actual zoom in or out while preserving current rotation. | |
| void | changeMatrixRotation (int angle) |
| Rotates the view transformation by angle degrees clockwise, while preserving the current scale. | |
| void | reset () |
| Resets to default rotation, zoom and scale. | |
| void | setOptionsOpenGL (const bool &enabled=false) |
| Toggles openGL. | |
| void | setOptionsAntialiasing (const bool &toggle) |
| Toggles QPainter render hints for primitive edges and text antialiasing. | |
| void | setOptionsNoAntialiasingAutoAdjust (const bool &toggle) |
| Toggles QGraphicsView's antialiasing auto-adjustment of exposed areas. | |
Signals | |
| void | userDoubleClickNewNode (const QPointF &) |
| Double-click on empty canvas space; MW creates a new node at this scene position. | |
| void | userMiddleClicked (const int &sourceNum, const int &targetNum, const qreal &weight=1) |
| Two consecutive middle-clicks (or double-clicks) on two different nodes; MW/Graph creates a new edge from the first node to the second. | |
| void | userClickOnEmptySpace (const QPointF &p) |
| Left-click on empty canvas space, at scene position p. | |
| void | openNodeMenu () |
| Right-click on a node; MW opens the node context menu for the currently clicked node. | |
| void | openContextMenu (const QPointF p) |
| Right-click on empty canvas space, at scene position p; MW opens the general context menu. | |
| void | userNodeMoved (const int &, const int &, const int &) |
| One node from the current selection finished being dragged to a new position (nodeNumber, x, y); emitted once per selected node on mouse release. | |
| void | userSelectedItems (const QList< int > selectedNodes, const QList< SelectedEdge > selectedEdges) |
| The full current node/edge selection, emitted whenever it changes (single emission per change, not per item). | |
| void | userClickedNode (const int &nodeNumber, const QPointF &p) |
| A node was clicked (nodeNumber, scene position); also used with nodeNumber=0 as a generic "selection changed" notification from selectAll()/selectNone(). | |
| void | userClickedEdge (const int &source, const int &target, const bool &openMenu=false) |
| An edge was clicked (source, target); openMenu requests MW open its context menu. | |
| void | zoomChanged (const int) |
| Current zoom index changed; keeps the MW zoom slider in sync. | |
| void | rotationChanged (const int) |
| Current rotation angle changed; keeps the MW rotation slider in sync. | |
| void | resized (const int, const int) |
| Canvas viewport was resized (debounced to fire once, 150ms after the last resize event). | |
| void | setCursor (Qt::CursorShape) |
| Requests MW change the application cursor shape (e.g. while creating an edge). | |
Public Member Functions | |
| GraphicsWidget (QGraphicsScene *m_scene, MainWindow *m_parent) | |
| Constructs a GraphicsWidget object. | |
| ~GraphicsWidget () | |
| Destructor. Calls the method to clear the data. | |
| void | clear () |
| Clears the scene and all hashes, lists, var etc. | |
| bool | isClearing () const |
| True while a bulk clear() is in progress; false otherwise. | |
| quint64 | edgeKey (const int &v1, const int &v2, const int &relation=-1) |
| Packs (relation, v1, v2) into a single quint64 key for edgesHash. | |
| void | setInitNodeSize (int) |
| Sets initial node size from MW. | |
| void | setInitZoomIndex (const int &) |
| Sets the initial zoom setting. Use setMaxZoomIndex() instead. | |
| void | setMaxZoomIndex (const int &) |
| Sets the max zoom allowed (and the initial zoom as half of it). Called from MW on startup. | |
| void | setSelectedNodes (const QList< int > &list) |
| Selects all nodes in the given list. | |
| QList< QGraphicsItem * > | selectedItems () |
| Returns a list of all selected QGraphicsItem(s). | |
| QList< int > | selectedNodes () |
| Returns a List of selected node numbers. | |
| QList< SelectedEdge > | selectedEdges () |
| Returns a QList of selected directed edges structs in the form of v1,v2. | |
| void | selectAll () |
| Forces the scene to select all items. Also signals that no node is clicked. | |
| void | selectNone () |
| Clears any item selection from the scene. Also signals that no node is clicked. | |
| void | removeItem (GraphicsEdge *) |
| Removes an edge item from the scene. | |
| void | removeItem (GraphicsEdgeWeight *edgeWeight) |
| Removes an edge weight number item from the scene. | |
| void | removeItem (GraphicsEdgeLabel *edgeLabel) |
| Removes an edge label item from the scene. | |
| void | removeItem (GraphicsNode *) |
| Removes a node item from the scene. | |
| void | removeItem (GraphicsNodeNumber *) |
| Removes a node number item from the scene. | |
| void | removeItem (GraphicsNodeLabel *) |
| Removes a node label item from the scene. | |
| void | setNumbersInsideNodes (const bool &toggle) |
| Toggles displaying node numbers in or out of nodes. | |
| void | setAllItemsVisibility (int, bool) |
| Toggles the visibility of all items of the given type. | |
Protected Member Functions | |
| void | wheelEvent (QWheelEvent *event) |
| Handles the mouse wheel event. If CTRL is pressed, zooms in or out. | |
| void | mouseDoubleClickEvent (QMouseEvent *e) |
| Handles user double-clicks. | |
| void | mousePressEvent (QMouseEvent *e) |
| Handles the mouse press event. | |
| void | mouseReleaseEvent (QMouseEvent *e) |
| Handles the mouse release events. | |
| void | resizeEvent (QResizeEvent *e) |
| Handles the canvas resize event. | |
| void | scrollContentsBy (int dx, int dy) override |
| Tracks the user's pan position so zoom can anchor to it. | |
Private Attributes | |
| H_NumToNode | nodeHash |
| H_KeyToEdge | edgesHash |
| QList< int > | m_selectedNodes |
| QList< SelectedEdge > | m_selectedEdges |
| int | m_curRelation |
| int | m_nodeSize |
| int | m_currentRotationAngle |
| int | m_zoomIndex |
| int | m_zoomIndexInit |
| int | m_zoomIndexMax |
| int | markedEdgeSourceOrigSize |
| int | markedEdgeTargetOrigSize |
| int | m_edgeMinOffsetFromNode |
| int | m_arrowSize |
| double | m_currentScaleFactor |
| qreal | fX |
| qreal | fY |
| qreal | factor |
| QString | m_nodeLabel |
| QString | m_numberColor |
| QString | m_labelColor |
| quint64 | m_edgeKey |
| QPointF | m_viewCenter |
| bool | m_viewCenterValid |
| bool | m_isZooming |
| bool | m_isTransformationActive |
| bool | m_isClearing |
| bool | hasDoubleClickedNode |
| bool | clickedEdgeExists |
| bool | m_nodeNumbersInside |
| bool | m_nodeNumberVisibility |
| bool | m_nodeLabelVisibility |
| bool | m_edgeHighlighting |
| bool | m_edgesBezier |
| QTimer | m_resizeTimer |
| QList< GraphicsGuide * > | m_guides |
| GraphicsNode * | firstDoubleClickedNode |
| GraphicsNode * | secondDoubleClickedNode |
| GraphicsNode * | markedEdgeSource |
| GraphicsNode * | markedEdgeTarget |
| GraphicsEdge * | clickedEdge |
| GraphicsWidget::GraphicsWidget | ( | QGraphicsScene * | sc, |
| MainWindow * | m_parent ) |
Constructs a GraphicsWidget object.
| sc | |
| m_parent |
| GraphicsWidget::~GraphicsWidget | ( | ) |
Destructor. Calls the method to clear the data.
|
slot |
Adds a circular guideline.
| x0 | |
| y0 | |
| radius |
|
slot |
Adds a horizonal guideline.
| y0 |
|
slot |
Rotates the view transformation by angle degrees clockwise, while preserving the current scale.
| angle |
|
slot |
Does the actual zoom in or out while preserving current rotation.
Scales the view transformation by the given value (0..m_zoomIndexMax)
| value |
| void GraphicsWidget::clear | ( | ) |
Clears the scene and all hashes, lists, var etc.
|
slot |
Removes and deletes all guide items previously added via addGuideCircle()/addGuideHLine(), without scanning the scene.
GraphicsGuide::die() only clears geometry/visibility bookkeeping — it does not delete or schedule deletion — so a direct synchronous delete is safe.
|
slot |
Draws a new edge in the scene, from node with sourceNum to node with targetNum.
Used when we do not have references to nodes but only node numbers: a) when we load a network file b) when the user clicks on the AddLink button on the MW.
| sourceNum | |
| targetNum | |
| weight | |
| label | |
| color | |
| type | |
| drawArrows | |
| bezier | |
| weightNumbers |
|
slot |
Draws a new node in the scene.
Called when we load files, or when the user presses "Add Node" button or the user double clicks on the canvas.
| nodeNum | |
| nodeSize | |
| nodeColor | |
| numberColor | |
| numberSize | |
| nodeLabel | |
| labelColor | |
| labelSize | |
| p | |
| nodeShape | |
| showLabels | |
| numberInsideNode | |
| showNumbers |
| quint64 GraphicsWidget::edgeKey | ( | const int & | v1, |
| const int & | v2, | ||
| const int & | relation = -1 ) |
Packs (relation, v1, v2) into a single quint64 key for edgesHash.
Used to be a QString built as "relation:v1>v2" (e.g. "0:3>7"), which cost several heap allocations per call (QString::number() x3 plus concatenation) and character-wise hashing on every lookup. This is purely a UI-layer lookup key for GraphicsWidget's own edgesHash (mapping a graph edge to its GraphicsEdge item) — it has nothing to do with Graph's own data model or any algorithm kernel.
The key is decimal-digit-packed, not bit-packed, so it stays readable in a debugger the same way the old string was: reading left to right you get relation, then v1, then v2 - e.g. relation=0, v1=3, v2=7 packs to 300000007. (Leading zeros aren't preserved by a plain integer print, so a value like relation=0 won't visually show its 3-digit field width unless printed zero-padded to 19 digits — this key is only ever used as an opaque hash bucket key, never parsed back into fields, so that's not a correctness concern.)
This is a positional encoding, not a mixing hash: as long as every field's value stays within its allocated width (relation < 1000, v1 < 100'000'000, v2 < 100'000'000), the mapping from (relation, v1, v2) to key is a true bijection - collisions between distinct triples are structurally impossible, not just statistically unlikely. The three asserts below exist because that guarantee only holds while every field stays under its digit budget; an overflow would silently bleed into the next field and could produce a genuine collision with a different triple.
| v1 | Source node number (must be < 100,000,000) |
| v2 | Target node number (must be < 100,000,000) |
| relation | Relation index, or -1 to use the current relation (must be < 1000) |
|
slot |
Handles double-clicks (or middle-clicks) on the given node, creating a new edge if needed.
If it is the first double/middle-click on a node, it saves the first node as source. On a second double/middle-click on a node, it saves the second node as target and signals MW to notify activeGraph, which will create a new edge from source to target and will signal back to GW to draw the edge on the canvas.
| node |
|
slot |
Handles the event of selection change in the scene.
Queries scene()->selectedItems() once, populates m_selectedNodes and m_selectedEdges from a single pass, then emits both lists to Graph.
|
inline |
True while a bulk clear() is in progress; false otherwise.
GraphicsNode/GraphicsEdge destructors check this to skip per-item unlinking work (edge-list removal from neighbours, individual scene/hash removal) that's pointless during a bulk teardown - scene()->clear() destroys every item anyway, so proactively unlinking each one from its neighbours' edge lists is pure wasted O(degree) work per edge, repeated across the whole network. See #260.
|
protected |
Handles user double-clicks.
If the double-click was on empty space, it initiates the new node creation process. Otherwise, it the user double-clicks on a node, starts the new edge creation process.
| QMouseEvent |
|
protected |
Handles the mouse press event.
| e |
|
protected |
Handles the mouse release events.
Called when the user releases a mouse button, after a click. First sees what was in the position where the user clicked If a node was underneath, it signals for every node in scene selectedItems
| e |
|
slot |
Moves the node with the given number to the new coordinates.
Called while creating random networks.
| nodeNum | |
| x | |
| y |
|
signal |
Right-click on empty canvas space, at scene position p; MW opens the general context menu.
|
signal |
Right-click on a node; MW opens the node context menu for the currently clicked node.
|
slot |
Changes the current relation.
| relation |
|
slot |
Removes the edge from node sourceNum to node targetNum from the scene.
Called when erasing edges using vertex numbers. Also called when transforming directed edges to undirected.
| sourceNum | |
| targetNum | |
| removeReverse |
| void GraphicsWidget::removeItem | ( | GraphicsEdge * | edge | ) |
Removes an edge item from the scene.
Called from GraphicsEdge::~GraphicsEdge() to remove itself from edgesHash, scene and be deleted
| edge |
| void GraphicsWidget::removeItem | ( | GraphicsEdgeLabel * | edgeLabel | ) |
Removes an edge label item from the scene.
| edgeLabel |
| void GraphicsWidget::removeItem | ( | GraphicsEdgeWeight * | edgeWeight | ) |
Removes an edge weight number item from the scene.
| edgeWeight |
| void GraphicsWidget::removeItem | ( | GraphicsNode * | node | ) |
Removes a node item from the scene.
Called from GraphicsNode::~GraphicsNode() to remove itself from nodeHash, scene and be deleted
| node |
| void GraphicsWidget::removeItem | ( | GraphicsNodeLabel * | nodeLabel | ) |
Removes a node label item from the scene.
| nodeLabel |
| void GraphicsWidget::removeItem | ( | GraphicsNodeNumber * | nodeNumber | ) |
Removes a node number item from the scene.
| nodeNumber |
|
slot |
Deletes the node with the given number from the scene, if exists.
Called from Graph
| nodeNum |
|
slot |
Resets to default rotation, zoom and scale.
|
signal |
Canvas viewport was resized (debounced to fire once, 150ms after the last resize event).
|
protected |
|
slot |
Decreases the numerical rotation Rotates the view to the left, by a fixed angle.
|
slot |
Rotates the view to the right, by a fixed angle.
|
signal |
Current rotation angle changed; keeps the MW rotation slider in sync.
|
overrideprotected |
Tracks the user's pan position so zoom can anchor to it.
Called by Qt whenever the scroll position changes — user scroll bars, mouse wheel scroll, or programmatic centerOn(). The m_isZooming flag blocks updates during our own centerOn() call in changeMatrixScale(), so only genuine user pans update m_viewCenter.
| void GraphicsWidget::selectAll | ( | ) |
Forces the scene to select all items. Also signals that no node is clicked.
| QList< SelectedEdge > GraphicsWidget::selectedEdges | ( | ) |
Returns a QList of selected directed edges structs in the form of v1,v2.
| QList< QGraphicsItem * > GraphicsWidget::selectedItems | ( | ) |
Returns a list of all selected QGraphicsItem(s).
| QList< int > GraphicsWidget::selectedNodes | ( | ) |
Returns a List of selected node numbers.
| void GraphicsWidget::selectNone | ( | ) |
Clears any item selection from the scene. Also signals that no node is clicked.
|
slot |
Selects the edges that form a shortest path, exactly as if the user had Shift-clicked each edge in turn.
Uses QSignalBlocker so that scene()->selectionChanged fires only once (via the explicit handleSelectionChanged() call at the end), not once per edge. MainWindow then receives a single userSelectedItems() emission with the complete path edge set — same as any other multi-selection.
For each hop (path[i] → path[i+1]) the forward key is tried first; if the edge is not found (directed graph, path goes the "other way") the reverse key is tried.
| path | Ordered list of vertex numbers returned by Graph::graphGeodesicShortestPath(). |
| void GraphicsWidget::setAllItemsVisibility | ( | int | type, |
| bool | visible ) |
Toggles the visibility of all items of the given type.
| type | |
| visible |
|
signal |
Requests MW change the application cursor shape (e.g. while creating an edge).
|
slot |
Sets the arrow size for all edges and stores it as the default for new edges.
Each edge only recomputes its four cached arrow-corner QPointFs and schedules a repaint — no full path rebuild is triggered.
| size | Arrow size in pixels (typically 2–20). |
|
slot |
Toggles the visibility of all edge arrows.
| toggle |
|
slot |
Sets the clicked edge.
Emits signal to Graph to:
| edge | |
| openMenu |
|
slot |
Sets the color of an edge.
Called when the user changes the color of an edge (right-clicking). Also called from Graph when all edge colors need to be changed.
| source | |
| target | |
| color |
|
slot |
Changes the direction type of an existing edge.
| source | |
| target | |
| dirType |
|
slot |
Enables or disables edge highlighting.
If enabled, an edge will be highlighted on mouse hover and edges connected to a node will be highlighted when the user selects that node.
| toggle |
|
slot |
Sets the label of an edge.
Called when the user changes the label of an edge (right-clicking).
| source | |
| target | |
| label |
|
slot |
Toggles all edge labels visibility.
| toggle |
|
slot |
Changes the offset of an edge (or all edges) from source and target nodes.
| source | |
| target | |
| offset |
|
slot |
Toggles bezier-curve rendering for all edges currently in the scene.
Also stores the toggle in m_edgesBezier so it applies to edges drawn afterwards. Viewport updates are disabled for the duration of the loop to avoid a repaint per edge.
| toggle |
|
slot |
Applies a batch of edge visibility changes in one call (WS3 M2).
Reuses setEdgeVisibility() per entry unchanged - the only difference from N separate signal/slot dispatches is that this whole batch crosses from graphThread to the GUI thread as a single queued call, not one per edge. See Graph::signalSetEdgesVisibilityBatch.
| changes |
|
slot |
Toggles the visibility of the given edge.
| relation | |
| sourceNum | |
| targetNum | |
| visible | |
| preserveReverseEdge |
|
slot |
Sets the weight of an edge.
Called when the user changes the weight of an edge (right-clicking).
| source | |
| target | |
| weight |
|
slot |
Toggles all edge weight numbers visibility.
| toggle |
| void GraphicsWidget::setInitNodeSize | ( | int | size | ) |
Sets initial node size from MW.
It is called from MW on startup and when user changes it.
| size |
| void GraphicsWidget::setInitZoomIndex | ( | const int & | zoomIndex | ) |
Sets the initial zoom setting. Use setMaxZoomIndex() instead.
| zoomIndex |
| void GraphicsWidget::setMaxZoomIndex | ( | const int & | maxZoomIndex | ) |
Sets the max zoom allowed (and the initial zoom as half of it). Called from MW on startup.
| zoomIndex |
|
slot |
Clears clickedEdge and emits a signal to Graph.
The signal is used to
Called when the user clicks or double-clicks on a node.
| node |
|
slot |
Sets the color of an node.
Called when the user changes the color of a node (right-clicking).
| nodeNumber | |
| color |
|
slot |
Sets the label of an node.
| nodeNumber | |
| label |
|
slot |
Changes the label color of a node to 'color'.
| nodeNum | |
| color |
|
slot |
Changes the distance of the label of the given node.
| nodeNum | |
| distance |
|
slot |
Changes the label size of a node to 'size'.
| nodeNum | |
| size |
|
slot |
Toggles the visibility of all node labels.
| toggle |
|
slot |
Changes the color of a node number.
| nodeNumber | |
| color |
|
slot |
Changes the distance of the number of a node.
| nodeNum | |
| distance |
|
slot |
Changes the size of the number of a node.
| nodeNum | |
| size |
|
slot |
Toggles the visibility of node numbers.
| toggle |
|
slot |
Sets the shape of an node.
| nodeNumber | |
| shape | |
| iconPath |
|
slot |
Changes the size of a node.
| nodeNum | |
| size |
|
slot |
Changes the visibility of a Node.
| nodeNum | |
| toggle |
| void GraphicsWidget::setNumbersInsideNodes | ( | const bool & | toggle | ) |
Toggles displaying node numbers in or out of nodes.
| numIn |
|
slot |
Toggles QPainter render hints for primitive edges and text antialiasing.
| toggle |
|
slot |
Toggles QGraphicsView's antialiasing auto-adjustment of exposed areas.
Default: false Items that render antialiased lines on the boundaries of their QGraphicsItem::boundingRect() can end up rendering parts of the line outside. To prevent rendering artifacts, QGraphicsView expands all exposed regions by 2 pixels in all directions. If you enable this flag, QGraphicsView will no longer perform these adjustments, minimizing the areas that require redrawing, which improves performance. A common side effect is that items that do draw with antialiasing can leave painting traces behind on the scene as they are moved.
| toggle |
|
slot |
Toggles openGL.
| enabled |
| void GraphicsWidget::setSelectedNodes | ( | const QList< int > & | list | ) |
Selects all nodes in the given list.
| list |
|
signal |
An edge was clicked (source, target); openMenu requests MW open its context menu.
|
signal |
A node was clicked (nodeNumber, scene position); also used with nodeNumber=0 as a generic "selection changed" notification from selectAll()/selectNone().
|
signal |
Left-click on empty canvas space, at scene position p.
|
signal |
Double-click on empty canvas space; MW creates a new node at this scene position.
|
signal |
Two consecutive middle-clicks (or double-clicks) on two different nodes; MW/Graph creates a new edge from the first node to the second.
|
signal |
One node from the current selection finished being dragged to a new position (nodeNumber, x, y); emitted once per selected node on mouse release.
|
signal |
The full current node/edge selection, emitted whenever it changes (single emission per change, not per item).
|
protected |
Handles the mouse wheel event. If CTRL is pressed, zooms in or out.
| e |
|
signal |
Current zoom index changed; keeps the MW zoom slider in sync.
|
slot |
Increases the numerical zoom index of the scene by the given step.
Signals to MW to update the UI and do the rest.
| level |
|
slot |
Decreases the numerical zoom index of the scene by the given step.
Signals to MW to update the UI and do the rest.
| level |
|
slot |
Scales and centres the view so that the full network is visible.
Computes the scale factor needed to fit the scene's bounding rect inside the viewport (with a 20 px margin on each side), maps it to the nearest discrete zoom index, updates m_viewCenter to the content centre, and applies the transform via changeMatrixScale(). zoomChanged() is also emitted to keep the zoom slider in sync, but the transform is applied unconditionally — not via the slider chain — so the view is always re-centred even when the computed zoom index equals the slider's current value.
Called automatically via a QueuedConnection on Graph::signalLayoutFinished, which is emitted after every layout algorithm completes. The queued delivery guarantees that all setNodePos signals (which move scene items to their new positions) have been processed before this slot runs — so itemsBoundingRect() reflects the finished layout.
After this call, subsequent zoom or pan operations anchor normally to the new view centre (the #248 behaviour is preserved).
|
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 |
|
private |