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.connector.Socket] = None, endSocket: Optional[nodedge.connector.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
- Instance Attributes
scene - reference to the
Scene
graphicsEdge
- Instance of
GraphicsEdge
subclass handling graphical representation in the
QGraphicsScene
.
- Instance of
-
edgeValidators
: List[Callable] = []¶ class variable containing list of
-
property
sourceSocket
¶ Source socket.
- Getter
Return source
Socket
.- Setter
Set source
Socket
safely.- Type
Socket
-
property
targetSocket
¶ Target socket
- Getter
Return target
Socket
orNone
if not set.- Setter
Set target
Socket
safely.- Type
Socket
orNone
-
property
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 thisQGraphicsPathItem
to theQGraphicsScene
and update edge sockets positions.- Type
-
property
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 endSocket
-
getOtherSocket
(knownSocket: Optional[Socket])¶ Return the opposite
Socket
on thisEdge
.- Parameters
knownSocket (
Socket
) – Provide knownSocket
to be able to determine the opposite one- Returns
The opposite socket on this
Edge
, eventuallyNone
.- Return type
Socket
orNone
-
removeFromSockets
() → None¶ Set start and end
Socket
toNone
-
remove
(silentForSocket: Optional[nodedge.connector.Socket] = None, silent: bool = False)¶ Safely remove this Edge.
Remove
GraphicsEdge
from theQGraphicsScene
and it’s reference to all other graphical elements. Notify previously connectedNode
(s) about this event.Triggered Node Slots: -
onEdgeConnectionChanged()
-onInputChanged()
- Parameters
silentForSocket (Optional[
Socket
]) – Socket for whom the removal is silentsilent (
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.connector.Socket, endSocket: nodedge.connector.Socket) → bool¶ Validate Edge against all registered Edge Validator Callbacks
- Parameters
startSocket (
Socket
) – StartingSocket
of Edge to checkendSocket (
Socket
) – Target/EndSocket
of Edge to check
- Returns
True
if the Edge is valid,False
otherwise- Return type
bool
-
reconnect
(sourceSocket: nodedge.connector.Socket, targetSocket: nodedge.connector.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