Core::Node
Base class interface for all boxes.
#include "Core/Nodes/Node.h"
Inherits from std::enable_shared_from_this< Node >
Inherited by Core::Camera, Core::Cycle, Core::Model, Core::Operator< T >, Core::Sequence, Core::Transform
Public Functions
Name | |
---|---|
virtual void | addDeleteCallback(std::function< void(Node )> callback)<br> The callback parameters: Node = node that has been deleted |
virtual void | addPlugCallback(std::function< void(Node *, Node *, size_t, size_t)> callback)<br>Registers a callback that gets called when the node's output pins get plugged in. |
virtual void | addUnplugCallback(std::function< void(Node *, Node *, size_t, size_t)> callback)<br>Registers a callback that gets called when the node's input pins get unplugged. |
virtual void | addUpdateCallback(std::function< void(Node *)> callback)<br>Registers a callback that gets called on any updateValues() call. |
void | appendChildNode(Ptr< Node > node) |
bool | areAllInputsPlugged() |
bool | areAllInputsUnplugged() const |
bool | areInputsPlugged(int numInputs) |
template <typename T > <br>Ptr< T > | as() |
const Data & | data(size_t index =0) const<br>Get Node contents, read only. |
Data & | dataMut(size_t index) |
void | finalize()<br>Prepares node for its destruction, after that the destructor can be called. |
ID | getId() const |
Pin & | getInput(size_t i) |
std::vector< Pin > & | getInputPins() |
Data & | getInternalData(size_t index =0)<br>Get data storage for read and write purposes. |
const char * | getLabel() const |
const Operation * | getOperation() const |
Pin & | getOutput(size_t i) |
std::vector< Pin > & | getOutputPins() |
Ptr< Node > | getOwner() const<br>Get direct owner of this node. |
Ptr< Node > | getPtr()<br>Get reference to this node instance. |
Ptr< Node > | getRootOwner()<br>Get the topmost owner of this node. |
std::string | getSignature()<br>"{node type} #{node ID}" |
EValueState | getState(size_t pinIndex =0) |
void | init()<br>Initialize node id, inputs, and outputs according to the preset node type. |
void | notifyOwner() |
virtual void | onInit() |
bool | operator!=(const Node & other) const |
bool | operator==(const Node & other) const |
ENodePlugResult | plug(const Ptr< Node > & childNode, unsigned fromIndex, unsigned toIndex)<br>Connect this (parent) node output to the childNode input. |
void | pulse(size_t index) |
virtual void | receiveSignal(int inputIndex)<br>Implements the operator reaction to the change of its inputIndex input. |
virtual SetValueResult | setValue(const glm::mat4 & mat) |
virtual SetValueResult | setValue(const glm::mat4 & mat, const DataMap & map)<br>Smart set function, used with constrained transformation for value checking. |
virtual SetValueResult | setValue(const glm::quat & q) |
virtual SetValueResult | setValue(const glm::vec3 & vec) |
virtual SetValueResult | setValue(const glm::vec4 & vec) |
template <typename T > <br>SetValueResult | setValue(const T & value, unsigned index) |
virtual SetValueResult | setValue(float val)<br>Set the value of the node. |
virtual SetValueResult | setValue(float val, glm::ivec2 coords) |
virtual SetValueResult | setValue(void * ptr) |
void | spreadSignal()<br>Spread signal to all outputs. |
void | spreadSignal(size_t outIndex)<br>Spread signal to the selected output outIndex only. |
virtual void | updateValues(int inputIndex =0)<br>Computes new values of outputs based on inputs. |
Protected Functions
Name | |
---|---|
Node(const Operation * operation)<br>Node is never constructed directory. | |
virtual | ~Node() |
ENodePlugResult | isPlugCorrect(const Pin & input, const Pin & output) |
virtual void | onUnplugInput(size_t index) |
template <typename T > <br>void | setInternalValue(const T & value, size_t index =0)<br>Sets the node value without validation. |
void | setInternalValue(float value, glm::ivec2 coordinates, size_t index =0) |
bool | shouldPulse(size_t inputIndex, size_t updatedInputIndex)<br>Tests if the updatedInputIndex should be pulsed. |
void | triggerDeleteCallback(Node * node) |
void | triggerPlugCallback(Node * fromNode, Node * toNode, size_t fromIndex, size_t toIndex) |
void | triggerUnplugCallback(Node * fromNode, Node * toNode, size_t fromIndex, size_t toIndex) |
void | triggerUpdateCallback(Node * node) |
Public Attributes
Name | |
---|---|
std::vector< EValueState > | m_OperatorState |
Protected Attributes
Name | |
---|---|
std::vector< Node * > | m_children <br>Nested nodes. |
ID | m_id |
std::vector< Pin > | m_inputs <br>Inputs of the box: Input tabs with glyphs. |
std::vector< Data > | m_internalData <br>Results of operations. |
const Operation * | m_operation <br>Operator node properties. |
std::vector< Pin > | m_outputs <br>Outputs of the box: output tabs with glyphs. |
Node * | m_owner <br>Owner of the node, used in complex type of nodes, such as sequence or camera. |
Friends
Name | |
---|---|
class | GraphManager |
class | Pin |
Public Functions Documentation
function addDeleteCallback
virtual void addDeleteCallback(
std::function< void(Node *)> callback
)
virtual void addDeleteCallback(
std::function< void(Node *)> callback
)
The callback parameters: Node* = node that has been deleted
function addPlugCallback
virtual void addPlugCallback(
std::function< void(Node *, Node *, size_t, size_t)> callback
)
virtual void addPlugCallback(
std::function< void(Node *, Node *, size_t, size_t)> callback
)
Registers a callback that gets called when the node's output pins get plugged in.
The callback parameters:
Node* = Start node
Node* = End node
size_t = Start node's output pin index
size_t = End node's input pin index
function addUnplugCallback
virtual void addUnplugCallback(
std::function< void(Node *, Node *, size_t, size_t)> callback
)
virtual void addUnplugCallback(
std::function< void(Node *, Node *, size_t, size_t)> callback
)
Registers a callback that gets called when the node's input pins get unplugged.
The callback parameters:
Node* = Start node
Node* = End node
size_t = Start node's output pin index
size_t = End node's input pin index
function addUpdateCallback
virtual void addUpdateCallback(
std::function< void(Node *)> callback
)
virtual void addUpdateCallback(
std::function< void(Node *)> callback
)
Registers a callback that gets called on any updateValues() call.
Note that some derived nodes might not always call this callback.
The callback parameters:
Node* = node that has been updated
function appendChildNode
void appendChildNode(
Ptr< Node > node
)
void appendChildNode(
Ptr< Node > node
)
function areAllInputsPlugged
bool areAllInputsPlugged()
bool areAllInputsPlugged()
function areAllInputsUnplugged
bool areAllInputsUnplugged() const
bool areAllInputsUnplugged() const
function areInputsPlugged
bool areInputsPlugged(
int numInputs
)
bool areInputsPlugged(
int numInputs
)
function as
template <typename T >
inline Ptr< T > as()
template <typename T >
inline Ptr< T > as()
function data
inline const Data & data(
size_t index =0
) const
inline const Data & data(
size_t index =0
) const
Get Node contents, read only.
Parameters:
- index Index of the internal modifiable data field (e.g, 0 or 1 for two vectors). Value of field[0] is returned if this parameter omitted)
Return: Struct which holds data
function dataMut
inline Data & dataMut(
size_t index
)
inline Data & dataMut(
size_t index
)
function finalize
void finalize()
void finalize()
Prepares node for its destruction, after that the destructor can be called.
Todo: MH: Remove, use destructor directly.
function getId
ID getId() const
ID getId() const
Return: Application unique ID.
function getInput
inline Pin & getInput(
size_t i
)
inline Pin & getInput(
size_t i
)
function getInputPins
inline std::vector< Pin > & getInputPins()
inline std::vector< Pin > & getInputPins()
function getInternalData
Data & getInternalData(
size_t index =0
)
Data & getInternalData(
size_t index =0
)
Get data storage for read and write purposes.
Todo: Make this function non public.
No written value validation is performed.
Overridden in Sequence class. This function won't work for mapped pins.
function getLabel
inline const char * getLabel() const
inline const char * getLabel() const
function getOperation
inline const Operation * getOperation() const
inline const Operation * getOperation() const
function getOutput
inline Pin & getOutput(
size_t i
)
inline Pin & getOutput(
size_t i
)
function getOutputPins
inline std::vector< Pin > & getOutputPins()
inline std::vector< Pin > & getOutputPins()
function getOwner
Ptr< Node > getOwner() const
Ptr< Node > getOwner() const
Get direct owner of this node.
Return: nullptr if owner is not set.
function getPtr
inline Ptr< Node > getPtr()
inline Ptr< Node > getPtr()
Get reference to this node instance.
Note that this operation may be slower. A new shared pointer must be created, it obtains atomic counter increment.
function getRootOwner
Ptr< Node > getRootOwner()
Ptr< Node > getRootOwner()
Get the topmost owner of this node.
function getSignature
inline std::string getSignature()
inline std::string getSignature()
"{node type} #{node ID}"
function getState
EValueState getState(
size_t pinIndex =0
)
EValueState getState(
size_t pinIndex =0
)
function init
void init()
void init()
Initialize node id, inputs, and outputs according to the preset node type.
Called in create node function.
function notifyOwner
void notifyOwner()
void notifyOwner()
function onInit
inline virtual void onInit()
inline virtual void onInit()
function operator!=
inline bool operator!=(
const Node & other
) const
inline bool operator!=(
const Node & other
) const
function operator==
inline bool operator==(
const Node & other
) const
inline bool operator==(
const Node & other
) const
function plug
ENodePlugResult plug(
const Ptr< Node > & childNode,
unsigned fromIndex,
unsigned toIndex
)
ENodePlugResult plug(
const Ptr< Node > & childNode,
unsigned fromIndex,
unsigned toIndex
)
Connect this (parent) node output to the childNode
input.
Parameters:
- childNode this node's toIndex input will be connected
- fromIndex index of the parent (this) node output
- toIndex index of the childNode input
See: ENodePlugResult.
Return: Result enum is returned from the function.
function pulse
void pulse(
size_t index
)
void pulse(
size_t index
)
function receiveSignal
virtual void receiveSignal(
int inputIndex
)
virtual void receiveSignal(
int inputIndex
)
Implements the operator reaction to the change of its inputIndex input.
Parameters:
- inputIndex Index of the input that was changed and that forces the operator to recompute its outputs.
- Forces the operator to recompute its outputs based on the changed input inputIndex by calling updateValues() and
- Spread signal to the connected children by spreadSignal().
This method is called by the spreadSignal() of the parent box in the scene graph. The computation may be restricted by internal bool value restrictedOutput to a single previously defined output index restrictedOutputIndex.
function setValue
inline virtual SetValueResult setValue(
const glm::mat4 & mat
)
inline virtual SetValueResult setValue(
const glm::mat4 & mat
)
Reimplemented by: Core::Transform::setValue, Core::TransformImpl< ETransformType::AxisAngle >::setValue, Core::TransformImpl< ETransformType::Quat >::setValue
function setValue
inline virtual SetValueResult setValue(
const glm::mat4 & mat,
const DataMap & map
)
inline virtual SetValueResult setValue(
const glm::mat4 & mat,
const DataMap & map
)
Smart set function, used with constrained transformation for value checking.
Parameters:
- mat
function setValue
inline virtual SetValueResult setValue(
const glm::quat & q
)
inline virtual SetValueResult setValue(
const glm::quat & q
)
Reimplemented by: Core::TransformImpl< ETransformType::Quat >::setValue
function setValue
inline virtual SetValueResult setValue(
const glm::vec3 & vec
)
inline virtual SetValueResult setValue(
const glm::vec3 & vec
)
Reimplemented by: Core::TransformImpl< ETransformType::AxisAngle >::setValue, Core::TransformImpl< ETransformType::Scale >::setValue, Core::TransformImpl< ETransformType::EulerX >::setValue, Core::TransformImpl< ETransformType::EulerY >::setValue, Core::TransformImpl< ETransformType::EulerZ >::setValue, Core::TransformImpl< ETransformType::Translation >::setValue
function setValue
inline virtual SetValueResult setValue(
const glm::vec4 & vec
)
inline virtual SetValueResult setValue(
const glm::vec4 & vec
)
Reimplemented by: Core::TransformImpl< ETransformType::Scale >::setValue, Core::TransformImpl< ETransformType::EulerX >::setValue, Core::TransformImpl< ETransformType::EulerY >::setValue, Core::TransformImpl< ETransformType::EulerZ >::setValue, Core::TransformImpl< ETransformType::Translation >::setValue
function setValue
template <typename T >
inline SetValueResult setValue(
const T & value,
unsigned index
)
template <typename T >
inline SetValueResult setValue(
const T & value,
unsigned index
)
function setValue
inline virtual SetValueResult setValue(
float val
)
inline virtual SetValueResult setValue(
float val
)
Set the value of the node.
Parameters:
- val
Reimplemented by: Core::TransformImpl< ETransformType::EulerX >::setValue, Core::TransformImpl< ETransformType::EulerY >::setValue, Core::TransformImpl< ETransformType::EulerZ >::setValue, Core::TransformImpl< ETransformType::AxisAngle >::setValue, Core::TransformImpl< ETransformType::Scale >::setValue, Core::TransformImpl< ETransformType::Translation >::setValue
Sets the value of the first float of DataStore. Derived types may override the default behavior.
function setValue
inline virtual SetValueResult setValue(
float val,
glm::ivec2 coords
)
inline virtual SetValueResult setValue(
float val,
glm::ivec2 coords
)
Parameters:
- val new value
- coords in the column major order: coords.x is the column index and coords.y is the row index.
Return:
Reimplemented by: Core::Transform::setValue, Core::TransformImpl< ETransformType::Free >::setValue, Core::TransformImpl< ETransformType::Scale >::setValue, Core::TransformImpl< ETransformType::EulerX >::setValue, Core::TransformImpl< ETransformType::EulerY >::setValue, Core::TransformImpl< ETransformType::EulerZ >::setValue, Core::TransformImpl< ETransformType::Translation >::setValue, Core::TransformImpl< ETransformType::Ortho >::setValue, Core::TransformImpl< ETransformType::Perspective >::setValue, Core::TransformImpl< ETransformType::Frustum >::setValue
function setValue
inline virtual SetValueResult setValue(
void * ptr
)
inline virtual SetValueResult setValue(
void * ptr
)
function spreadSignal
void spreadSignal()
void spreadSignal()
Spread signal to all outputs.
Todo: Does not use operators for calling each follower just once
TodoMH Correct the owner of the pin.
function spreadSignal
void spreadSignal(
size_t outIndex
)
void spreadSignal(
size_t outIndex
)
Spread signal to the selected output outIndex only.
function updateValues
virtual void updateValues(
int inputIndex =0
)
virtual void updateValues(
int inputIndex =0
)
Computes new values of outputs based on inputs.
Parameters:
- inputIndex Index of the modified input.
Reimplemented by: Core::Operator::updateValues, Core::Operator::updateValues, Core::Operator::updateValues, Core::Operator::updateValues, Core::Operator::updateValues, Core::Operator::updateValues, Core::Operator::updateValues, Core::Operator::updateValues, Core::Operator::updateValues, Core::Operator::updateValues, Core::Operator::updateValues, Core::Operator::updateValues, Core::Operator::updateValues, Core::Operator::updateValues, Core::Operator::updateValues, Core::Operator::updateValues, Core::Operator::updateValues, Core::Operator::updateValues, Core::Operator::updateValues, Core::Operator::updateValues, Core::Operator::updateValues, Core::Operator::updateValues, Core::Operator::updateValues, Core::Operator::updateValues, Core::Operator::updateValues, Core::Operator::updateValues, Core::Operator::updateValues, Core::Operator::updateValues, Core::Operator::updateValues, Core::Operator::updateValues, Core::Operator::updateValues, Core::Operator::updateValues, Core::Operator::updateValues, Core::Operator::updateValues, Core::Operator::updateValues, Core::Operator::updateValues, Core::Operator::updateValues, Core::Operator::updateValues, Core::Operator::updateValues, Core::Operator::updateValues, Core::Operator::updateValues, Core::Operator::updateValues, Core::Operator::updateValues, Core::Operator::updateValues, Core::Operator::updateValues, Core::Operator::updateValues, Core::Operator::updateValues, Core::Operator::updateValues, Core::Operator::updateValues, Core::Operator::updateValues, Core::Operator::updateValues, Core::Operator::updateValues, Core::Operator::updateValues, Core::Operator::updateValues, Core::Operator::updateValues, Core::Operator::updateValues, Core::Operator::updateValues, Core::Operator::updateValues, Core::Operator::updateValues, Core::Operator::updateValues, Core::Operator::updateValues, Core::Operator::updateValues, Core::Operator::updateValues, Core::Operator::updateValues, Core::Operator::updateValues, Core::Operator::updateValues, Core::Operator::updateValues, Core::Operator::updateValues, Core::Operator::updateValues, Core::Operator::updateValues, Core::Operator::updateValues, Core::Operator::updateValues, Core::Operator::updateValues, Core::Operator::updateValues, Core::Operator::updateValues, Core::Operator::updateValues, Core::Operator::updateValues, Core::Operator::updateValues, Core::Operator::updateValues, Core::Operator::updateValues, Core::Operator::updateValues, Core::Operator::updateValues, Core::Operator::updateValues, Core::Operator::updateValues, Core::Camera::updateValues, Core::Cycle::updateValues, Core::Operator::updateValues, Core::Sequence::updateValues, Core::Model::updateValues
Encodes the box function by updating the output values for a given inputIndex - fired by receiveSignal().
The base class method calls update callbacks registered with addUpdateCallback(). So derived methods should also call their base method if they want to inform any outside observers.
Protected Functions Documentation
function Node
inline Node(
const Operation * operation
)
inline Node(
const Operation * operation
)
Node is never constructed directory.
Parameters:
- operation Node properties.
See: init() function for pin and data storage initialization
function ~Node
virtual ~Node()
virtual ~Node()
function isPlugCorrect
ENodePlugResult isPlugCorrect(
const Pin & input,
const Pin & output
)
ENodePlugResult isPlugCorrect(
const Pin & input,
const Pin & output
)
function onUnplugInput
inline virtual void onUnplugInput(
size_t index
)
inline virtual void onUnplugInput(
size_t index
)
Reimplemented by: Core::Model::onUnplugInput
function setInternalValue
template <typename T >
inline void setInternalValue(
const T & value,
size_t index =0
)
template <typename T >
inline void setInternalValue(
const T & value,
size_t index =0
)
Sets the node value without validation.
Parameters:
- value Value to set.
- index Index of the DataStore (if the node stores more than one value)
Template Parameters:
- T Value type, no need to specify it in angle brackets, it will be deduced by the compiler (C++17).
function setInternalValue
inline void setInternalValue(
float value,
glm::ivec2 coordinates,
size_t index =0
)
inline void setInternalValue(
float value,
glm::ivec2 coordinates,
size_t index =0
)
function shouldPulse
bool shouldPulse(
size_t inputIndex,
size_t updatedInputIndex
)
bool shouldPulse(
size_t inputIndex,
size_t updatedInputIndex
)
Tests if the updatedInputIndex
should be pulsed.
Parameters:
- inputIndex Index of the tested input.
- updatedInputIndex Index of the input which was updated.
Return:
function triggerDeleteCallback
void triggerDeleteCallback(
Node * node
)
void triggerDeleteCallback(
Node * node
)
function triggerPlugCallback
void triggerPlugCallback(
Node * fromNode,
Node * toNode,
size_t fromIndex,
size_t toIndex
)
void triggerPlugCallback(
Node * fromNode,
Node * toNode,
size_t fromIndex,
size_t toIndex
)
function triggerUnplugCallback
void triggerUnplugCallback(
Node * fromNode,
Node * toNode,
size_t fromIndex,
size_t toIndex
)
void triggerUnplugCallback(
Node * fromNode,
Node * toNode,
size_t fromIndex,
size_t toIndex
)
function triggerUpdateCallback
void triggerUpdateCallback(
Node * node
)
void triggerUpdateCallback(
Node * node
)
Public Attributes Documentation
variable m_OperatorState
std::vector< EValueState > m_OperatorState;
std::vector< EValueState > m_OperatorState;
Todo:
Protected Attributes Documentation
variable m_children
std::vector< Node * > m_children;
std::vector< Node * > m_children;
Nested nodes.
variable m_id
ID m_id {};
ID m_id {};
variable m_inputs
std::vector< Pin > m_inputs;
std::vector< Pin > m_inputs;
Inputs of the box: Input tabs with glyphs.
variable m_internalData
std::vector< Data > m_internalData;
std::vector< Data > m_internalData;
Results of operations.
variable m_operation
const Operation * m_operation = nullptr;
const Operation * m_operation = nullptr;
Operator node properties.
variable m_outputs
std::vector< Pin > m_outputs;
std::vector< Pin > m_outputs;
Outputs of the box: output tabs with glyphs.
variable m_owner
Node * m_owner = nullptr;
Node * m_owner = nullptr;
Owner of the node, used in complex type of nodes, such as sequence or camera.
Friends
friend GraphManager
friend class GraphManager(
GraphManager
);
friend class GraphManager(
GraphManager
);
friend Pin
friend class Pin(
Pin
);
friend class Pin(
Pin
);
Updated on 2024-11-06 at 20:16:54 +0000