nodedge.edge

Edge module containing Edge and EdgeType class.

class nodedge.edge.EdgeType

Bases: enum.IntEnum

Edge Type Constants

STRAIGHT = 1
BEZIER = 2
CIRCUIT = 3
class nodedge.edge.Edge(scene: Scene, startSocket: Optional[nodedge.socket.Socket] = None, endSocket: Optional[nodedge.socket.Socket] = None, edgeType: nodedge.edge.EdgeType = <EdgeType.CIRCUIT: 3>)

Bases: nodedge.serializable.Serializable

Edge class.

The edge is the component connecting two Node s.

[NODE 1]——EDGE——[NODE 2]

Parameters:
  • scene (Scene) – Reference to the scene
  • startSocket (Socket) – Reference to the starting socket
  • endSocket (Socket | None) – Reference to the End socket or None
  • edgeType (EdgeType) – Constant determining type of edge.
Instance Attributes:
 
  • scene - reference to the Scene
  • graphicsEdge
  • Instance of GraphicsEdge subclass
    handling graphical representation in the QGraphicsScene.
edgeValidators = []

class variable containing list of

sourceSocket

Source socket.

Getter:Return source Socket.
Setter:Set source Socket safely.
Type:Socket
targetSocket

Target socket

Getter:Return target Socket or None if not set.
Setter:Set target Socket safely.
Type:Socket or None
edgeType

Edge type

Getter:Get edge type constant for current Edge.
Setter:Set new edge type. On background, create new GraphicsEdge child class if necessary, add this QGraphicsPathItem to the QGraphicsScene and update edge sockets positions.
Type:EdgeType
isSelected

Property defining whether the edge is selected or not.

Getter:Get selection state of the edge.
Setter:Provide the safe selecting/deselecting operation. In the background it takes care about the flags, notifications and storing history for undo/redo.
Type:bool
updatePos() → None

Update the internal GraphicsEdge positions according to the start and end Socket

getOtherSocket(knownSocket: nodedge.socket.Socket)

Return the opposite Socket on this Edge.

Parameters:knownSocket (Socket) – Provide known Socket to be able to determine the opposite one
Returns:The opposite socket on this Edge, eventually None.
Return type:Socket or None
removeFromSockets() → None

Set start and end Socket to None

remove(silentForSocket: Optional[nodedge.socket.Socket] = None, silent: bool = False)

Safely remove this Edge.

Remove GraphicsEdge from the QGraphicsScene and it’s reference to all other graphical elements. Notify previously connected Node (s) about this event.

Triggered Node Slots: - onEdgeConnectionChanged() - onInputChanged()

Parameters:
  • silentForSocket (Optional[Socket]) – Socket for whom the removal is silent
  • silent (bool) – True if no events should be triggered during removing
classmethod getEdgeValidators()

Return the list of Edge Validator Callbacks

classmethod registerEdgeValidator(validatorCallback: Callable)

Register Edge Validator Callback

Parameters:validatorCallback (function) – A function handle to validate Edge
classmethod validateEdge(startSocket: nodedge.socket.Socket, endSocket: nodedge.socket.Socket) → bool

Validate Edge against all registered Edge Validator Callbacks

Parameters:
Returns:

True if the Edge is valid, False otherwise

Return type:

bool

reconnect(sourceSocket: nodedge.socket.Socket, targetSocket: nodedge.socket.Socket)

Helper function which reconnects edge sourceSocket to targetSocket

serialize() → collections.OrderedDict

Serialization method.

Returns:Serialized edge
Return type:OrderedDict
deserialize(data: dict, hashmap: Optional[dict] = None, restoreId: bool = True, *args, **kwargs) → bool

Deserialization method.

Parameters:
  • data (dict) –
  • hashmap (Optional[dict]) –
  • restoreId (bool) –
Returns:

success status

Return type:

bool