nodedge.graphics_edge

Graphics edge module containing GraphicsEdge, GraphicsEdgeDirect and GraphicsEdgeBezier classes.

class nodedge.graphics_edge.GraphicsEdge(edge: Edge, parent: Optional[PySide2.QtWidgets.QGraphicsItem] = None)

Bases: PySide2.QtWidgets.QGraphicsPathItem

GraphicsEdge class

The graphics edge is the graphical representation of the Edge.

Parameters
  • edge (Edge) – reference to Edge

  • parent (Optional[QGraphicsItem]) – parent widget

property selectedState
Getter

Return whether the edge is selected or not.

Setter

Set the selection state of the edge.

Type

bool

property sourcePos
Getter

Return the edge’s source position.

Setter

Set the edge’s source position.

Type

QPointF

property targetPos
Getter

Return the edge’s target position.

Setter

Set the edge’s target position.

Type

QPointF

initUI()

Set up this QGraphicsPathItem

initStyle()

Initialize QObject like QColor, QPen and QBrush

boundingRect()

Define Qt’ bounding rectangle

onSelected()

Slot called when the edge has just been selected.

mouseReleaseEvent(event: PySide2.QtWidgets.QGraphicsSceneMouseEvent) → None

Overridden Qt’s slot to handle mouse release on the edge.

Parameters

event (QGraphicsSceneMouseEvent) – Qt’s mouse release event

hoverEnterEvent(event: PySide2.QtWidgets.QGraphicsSceneHoverEvent) → None

Overridden Qt’s slot to handle mouse hovering on the edge.

Parameters

event (QGraphicsSceneHoverEvent) – Qt’s mouse hover event

hoverLeaveEvent(event: PySide2.QtWidgets.QGraphicsSceneHoverEvent) → None

Overridden Qt’s slot to handle mouse hovering’s end on the edge.

Parameters

event (QGraphicsSceneHoverEvent) – Qt’s mouse hover event

shape() → PySide2.QtGui.QPainterPath

Returns QPainterPath representation of the edge.

Returns

graphical path

Return type

QPainterPath

paint(painter, QStyleOptionGraphicsItem, widget=None)

Qt’s overridden method to paint the edge.

Note

The path is calculated in calcPath() method.

calcPath() → PySide2.QtGui.QPainterPath

Compute the graphical path between sourcePos and ~nodedge.graphics_edge.GraphicsEdge.targetPos.

Warning

This method needs to be overridden.

Returns

The computed path

Return type

QPainterPath

intersectsWith(p1: PySide2.QtCore.QPointF, p2: PySide2.QtCore.QPointF) → bool

Compute if the edge’s path intersects with line between points given as argument.

Parameters
  • p1 (QPointF) – first point

  • p2 (QPointF) – second point

Returns

True if this edge’s path intersects with the line between p1 and p2

Return type

bool

changeColor(color: Union[str, PySide2.QtGui.QColor])

Change color of the edge from string hex value ‘#00ff00’

setColorFromSockets() → bool

Change color according to connected sockets. Returns True if color can be determined.

makeUnselectable()

Used for EdgeDragging to disable click detection over this graphics item.

class nodedge.graphics_edge.GraphicsEdgeDirect(edge: Edge, parent: Optional[PySide2.QtWidgets.QGraphicsItem] = None)

Bases: nodedge.graphics_edge.GraphicsEdge

Graphics Edge Direct class, with straight line path between sourcePos and targetPos

Parameters
  • edge (Edge) – reference to Edge

  • parent (Optional[QGraphicsItem]) – parent widget

calcPath() → PySide2.QtGui.QPainterPath

Compute a straight line path between sourcePos and ~nodedge.graphics_edge.GraphicsEdge.targetPos.

Returns

The computed path

Return type

QPainterPath

class nodedge.graphics_edge.GraphicsEdgeBezier(edge: Edge, parent: Optional[PySide2.QtWidgets.QGraphicsItem] = None)

Bases: nodedge.graphics_edge.GraphicsEdge

Graphics Edge Bezier class, with Bezier line path between sourcePos and targetPos

Parameters
  • edge (Edge) – reference to Edge

  • parent (Optional[QGraphicsItem]) – parent widget

calcPath() → PySide2.QtGui.QPainterPath

Compute a Bezier curve path between sourcePos and targetPos.

Returns

The computed path

Return type

QPainterPath

class nodedge.graphics_edge.GraphicsEdgeCircuit(edge: Edge, parent: Optional[PySide2.QtWidgets.QGraphicsItem] = None)

Bases: nodedge.graphics_edge.GraphicsEdge

Compute a path composed of vertical and horizontal lines between sourcePos and targetPos.

Returns

The computed path

Return type

QPainterPath

Parameters
  • edge (Edge) – reference to Edge

  • parent (Optional[QGraphicsItem]) – parent widget

calcPath() → PySide2.QtGui.QPainterPath

Compute a path composed of vertical and horizontal lines between sourcePos and targetPos.

Returns

The computed path

Return type

QPainterPath