node_node Module¶
A module containing NodeEditor’s class for representing Node.
-
class
nodeeditor.node_node.Node(scene: Scene, title: str = 'Undefined Node', inputs: list = [], outputs: list = [])¶ Bases:
nodeeditor.node_serializable.SerializableClass representing Node in the Scene.
- Parameters
- Instance Attributes
scene - reference to the
ScenegrNode - Instance of
QDMGraphicsNodehandling graphical representation in theQGraphicsScene. Automatically created in the constructorcontent - Instance of
QDMGraphicsContentwhich is child ofQWidgetrepresenting container for all inner widgets inside of the Node. Automatically created in the constructorinputs - list containin Input
Socketinstancesoutputs - list containin Output
Socketinstances
-
GraphicsNode_class¶
-
NodeContent_class¶ alias of
nodeeditor.node_content_widget.QDMNodeContentWidget
-
Socket_class¶ alias of
nodeeditor.node_socket.Socket
-
property
title¶ Title shown in the scene
- Getter
return current Node title
- Setter
sets Node title and passes it to Graphics Node class
- Type
str
-
property
pos¶ Retrieve Node’s position in the Scene
- Returns
Node position
- Return type
QPointF
-
setPos(x: float, y: float)¶ Sets position of the Graphics Node
- Parameters
x – X Scene position
y – Y Scene position
-
initInnerClasses()¶ Sets up graphics Node (PyQt) and Content Widget
-
getNodeContentClass()¶ Returns class representing nodeeditor content
-
getGraphicsNodeClass()¶
-
initSettings()¶ Initialize properties and socket information
-
initSockets(inputs: list, outputs: list, reset: bool = True)¶ Create sockets for inputs and outputs
- Parameters
inputs (
list) – list of Socket Types (int)outputs (
list) – list of Socket Types (int)reset (
bool) – ifTruedestroys and removes old Sockets
-
onEdgeConnectionChanged(new_edge: Edge)¶ Event handling that any connection (Edge) has changed. Currently not used…
-
onInputChanged(socket: nodeeditor.node_socket.Socket)¶ Event handling when Node’s input Edge has changed. We auto-mark this Node to be Dirty with all it’s descendants
-
onDeserialized(data: dict)¶ Event manually called when this node was deserialized. Currently called when node is deserialized from scene Passing data containing the data which have been deserialized
-
onDoubleClicked(event)¶ Event handling double click on Graphics Node in Scene
-
doSelect(new_state: bool = True)¶ Shortcut method for selecting/deselecting the Node
- Parameters
new_state (
bool) –Trueif you want to select the Node.Falseif you want to deselect the Node
-
isSelected()¶ Returns
Trueif current Node is selected
-
getSocketPosition(index: int, position: int, num_out_of: int = 1)¶ Get the relative x, y position of a
Socket. This is used for placing the Graphics Sockets on Graphics Node.- Parameters
index (
int) – Order number of the Socket. (0, 1, 2, …)position (
int) – Socket Position Constant describing where the Socket is located. See Socket Position Constantsnum_out_of (
int) – Total number of Sockets on this Socket Position
- Returns
Position of described Socket on the Node
- Return type
x, y
-
getSocketScenePosition(socket: Socket)¶ Get absolute Socket position in the Scene
- Parameters
socket – Socket which position we want to know
- Returns
(x, y) Socket’s scene position
-
updateConnectedEdges()¶ Recalculate (Refresh) positions of all connected Edges. Used for updating Graphics Edges
-
remove()¶ Safely remove this Node
-
isDirty() → bool¶ Is this node marked as Dirty
- Returns
Trueif Node is marked as Dirty- Return type
bool
-
markDirty(new_value: bool = True)¶ Mark this Node as Dirty. See Evaluation for more
- Parameters
new_value (
bool) –Trueif this Node should be Dirty.Falseif you want to un-dirty this Node
-
onMarkedDirty()¶ Called when this Node has been marked as Dirty. This method is supposed to be overridden
-
markChildrenDirty(new_value: bool = True)¶ Mark all first level children of this Node to be Dirty. Not this Node it self. Not other descendants
- Parameters
new_value (
bool) –Trueif children should be Dirty.Falseif you want to un-dirty children
-
markDescendantsDirty(new_value: bool = True)¶ Mark all children and descendants of this Node to be Dirty. Not this Node it self
- Parameters
new_value (
bool) –Trueif children and descendants should be Dirty.Falseif you want to un-dirty children and descendants
-
isInvalid() → bool¶ Is this node marked as Invalid?
- Returns
Trueif Node is marked as Invalid- Return type
bool
-
markInvalid(new_value: bool = True)¶ Mark this Node as Invalid. See Evaluation for more
- Parameters
new_value (
bool) –Trueif this Node should be Invalid.Falseif you want to make this Node valid
-
onMarkedInvalid()¶ Called when this Node has been marked as Invalid. This method is supposed to be overridden
-
markChildrenInvalid(new_value: bool = True)¶ Mark all first level children of this Node to be Invalid. Not this Node it self. Not other descendants
- Parameters
new_value (
bool) –Trueif children should be Invalid.Falseif you want to make children valid
-
markDescendantsInvalid(new_value: bool = True)¶ Mark all children and descendants of this Node to be Invalid. Not this Node it self
- Parameters
new_value (
bool) –Trueif children and descendants should be Invalid.Falseif you want to make children and descendants valid
-
eval(index=0)¶ Evaluate this Node. This is supposed to be overridden. See Evaluation for more
-
evalChildren()¶ Evaluate all children of this Node
-
getChildrenNodes() → List[Node]¶ Retreive all first-level children connected to this Node Outputs
- Returns
list of Nodes connected to this Node from all Outputs
- Return type
List[
Node]
-
getInput(index: int = 0) → [‘Node’, None]¶ Get the first Node connected to the Input specified by index
-
getInputWithSocket(index: int = 0) → [(‘Node’, ‘Socket’), (None, None)]¶ Get the first Node connected to the Input specified by index and the connection Socket
-
getInputWithSocketIndex(index: int = 0) -> ('Node', <class 'int'>)¶ Get the first Node connected to the Input specified by index and the connection Socket
-
serialize() → collections.OrderedDict¶ Serialization method to serialize this class data into
OrderedDictwhich can be easily stored in memory or file.- Returns
data serialized in
OrderedDict- Return type
OrderedDict
-
deserialize(data: dict, hashmap: dict = {}, restore_id: bool = True, *args, **kwargs) → bool¶ Deserialization method which take data in python
dictformat with helping hashmap containing references to existing entities.- Parameters
data (
dict) – Dictionary containing serialized datahashmap (
dict) – Helper dictionary containing references (by id == key) to existing objectsrestore_id (bool) – True if we are creating new Sockets. False is useful when loading existing Sockets of which we want to keep the existing object’s id.
- Returns
Trueif deserialization was successful, otherwiseFalse- Return type
bool