node_graphics_edge Module¶
A module containing the Graphics representation of an Edge
QDMGraphicsEdge class¶
-
class
nodeeditor.node_graphics_edge.QDMGraphicsEdge(edge: Edge, parent: PyQt5.QtWidgets.QWidget = None)¶ Bases:
PyQt5.QtWidgets.QGraphicsPathItemBase class for Graphics Edge
- Parameters
- Instance attributes
edge - reference to
EdgeposSource -
[x, y]source position in the SceneposDestination -
[x, y]destination position in the Scene
-
initUI()¶ Set up this
QGraphicsPathItem
-
initAssets()¶ Initialize
QObjectslikeQColor,QPenandQBrush
-
createEdgePathCalculator()¶ Create instance of
GraphicsEdgePathBase
-
determineEdgePathClass()¶ Decide which GraphicsEdgePath class should be used to calculate path according to edge.edge_type value
-
makeUnselectable()¶ Used for drag edge to disable click detection over this graphics item
-
changeColor(color)¶ Change color of the edge from string hex value ‘#00ff00’
-
setColorFromSockets() → bool¶ Change color according to connected sockets. Returns
Trueif color can be determined
-
onSelected()¶ Our event handling when the edge was selected
-
doSelect(new_state: bool = True)¶ Safe version of selecting the Graphics Node. Takes care about the selection state flag used internally
- Parameters
new_state (
bool) –Trueto select,Falseto deselect
-
mouseReleaseEvent(event)¶ Overridden Qt’s method to handle selecting and deselecting this Graphics Edge
-
hoverEnterEvent(event: PyQt5.QtWidgets.QGraphicsSceneHoverEvent) → None¶ Handle hover effect
-
hoverLeaveEvent(event: PyQt5.QtWidgets.QGraphicsSceneHoverEvent) → None¶ Handle hover effect
-
setSource(x: float, y: float)¶ Set source point
- Parameters
x (
float) – x positiony (
float) – y position
-
setDestination(x: float, y: float)¶ Set destination point
- Parameters
x (
float) – x positiony (
float) – y position
-
boundingRect() → PyQt5.QtCore.QRectF¶ Defining Qt’ bounding rectangle
-
shape() → PyQt5.QtGui.QPainterPath¶ Returns
QPainterPathrepresentation of this Edge- Returns
path representation
- Return type
QPainterPath
-
paint(painter, QStyleOptionGraphicsItem, widget=None)¶ Qt’s overridden method to paint this Graphics Edge. Path calculated in
calcPath()method
-
intersectsWith(p1: PyQt5.QtCore.QPointF, p2: PyQt5.QtCore.QPointF) → bool¶ Does this Graphics Edge intersect with the line between point A and point B ?
- Parameters
p1 (
QPointF) – point Ap2 (
QPointF) – point B
- Returns
Trueif this Graphics Edge intersects- Return type
bool
-
calcPath() → PyQt5.QtGui.QPainterPath¶ Will handle drawing QPainterPath from Point A to B. Internally there exist self.pathCalculator which is an instance of derived
GraphicsEdgePathBaseclass containing the actual calcPath() function - computing how the edge should look like.- Returns
QPainterPathof the edge connecting source and destination- Return type
QPainterPath