Enzo
Loading...
Searching...
No Matches
GeometryOperator.h
1#pragma once
2#include "Engine/Core/Path.h"
3#include "Engine/Core/Types.h"
4#include "Engine/Network/GeometryOpDef.h"
5#include "Engine/Network/NodePacket.h"
6#include "Engine/Network/OpInfo.h"
7#include "Engine/Parameter/NodeParameter.h"
8#include <memory>
9
10namespace enzo::nt {
16{
17 public:
28 virtual ~GeometryOperator() = default;
33
36 void cookOp(op::CookContext context);
37
45 std::shared_ptr<const enzo::NodePacket> getOutputPacket(unsigned int outputIndex) const;
46
48 std::vector<std::weak_ptr<prm::NodeParameter>> getParameters();
49
53 std::weak_ptr<prm::NodeParameter> getParameter(std::string_view parameterName);
54
57 bool isParameterEnabled(std::string_view parmName);
58
61 bool isParameterHidden(std::string_view parmName);
62
65 const std::vector<prm::Template>& getTemplates() const;
66
76 std::string getName() const;
77
79 const Path& getPath() const { return path_; }
80
82 void setPath(const Path& path) { path_ = path; }
83
91 const op::OpInfo& getType() const;
92
100 void dirtyNode(bool dirtyDescendents = true);
101
104 bool isDirty();
105
109 unsigned int getMinInputs() const;
111 unsigned int getMaxInputs() const;
113 unsigned int getMaxOutputs() const;
114
116 Vector2 getPosition() const { return position_; }
118 void setPosition(Vector2 pos) { position_ = pos; }
119
122 boost::signals2::signal<void(nt::OpId opId, bool dirtyDescendents)> nodeDirtied;
123
125 boost::signals2::signal<void(const std::string& parmName)> parameterChanged;
126
127 private:
128 void initParameters();
129
132 bool isComparisonTrue(const std::string& conditionText);
133
135 void onParameterChanged(const std::string& parmName);
136
137 std::vector<std::shared_ptr<prm::NodeParameter>> parameters_;
138 std::unique_ptr<enzo::nt::GeometryOpDef> opDef_;
139 enzo::nt::OpId opId_;
140 enzo::op::OpInfo opInfo_;
141 // Full path locating this node within the network, its leaf is the node name
142 Path path_;
143 Vector2 position_{0.f, 0.f};
144 bool dirty_ = true;
145};
146} // namespace enzo::nt
Basic attribute, parameter, and node types for Enzo.
uint64_t OpId
The unique ID assigned to each node in the network.
Definition Types.h:137
A default path class for creation and manipulation of tree-based paths.
Definition Path.h:14
The unique runtime representation of a node.
Definition GeometryOperator.h:16
const Path & getPath() const
Returns the full path locating this node within the network.
Definition GeometryOperator.h:79
boost::signals2::signal< void(const std::string &parmName)> parameterChanged
A signal emitted when one parameter's value changes, carrying its name.
Definition GeometryOperator.h:125
GeometryOperator(enzo::nt::OpId opId, op::OpInfo opInfo)
Constructs a new node.
Definition GeometryOperator.cpp:46
bool isParameterHidden(std::string_view parmName)
Whether the named parameter's hide condition currently hides it.
Definition GeometryOperator.cpp:141
void cookOp(op::CookContext context)
Computes the output geometry based on the cookOp definition in nt::GeometryOpDef. This is set by the ...
Definition GeometryOperator.cpp:92
bool isDirty()
Returns true if the node is dirty and false if the node is clean (does not need cooking).
Definition GeometryOperator.cpp:90
unsigned int getMinInputs() const
Returns the minimum number of input connections required for the node to function....
Definition GeometryOperator.cpp:185
const op::OpInfo & getType() const
Returns the static type definition this node was created from.
Definition GeometryOperator.cpp:163
void dirtyNode(bool dirtyDescendents=true)
Marks the outputed geometry as outdated and notifies the network.
Definition GeometryOperator.cpp:77
boost::signals2::signal< void(nt::OpId opId, bool dirtyDescendents)> nodeDirtied
A signal emitted when the node is dirtied. This will usually notify the NetworkManager.
Definition GeometryOperator.h:122
std::vector< std::weak_ptr< prm::NodeParameter > > getParameters()
Returns all parameters belonging to this node.
Definition GeometryOperator.cpp:151
const std::vector< prm::Template > & getTemplates() const
Returns the template tree declared by this node's type.
Definition GeometryOperator.cpp:156
GeometryOperator(const GeometryOperator &)=delete
Deleted copy constructor to avoid accidental copies.
void setPath(const Path &path)
Sets the full path locating this node within the network.
Definition GeometryOperator.h:82
GeometryOperator & operator=(const GeometryOperator &)=delete
Deleted copy assignment operator to avoid accidental copies.
std::shared_ptr< const enzo::NodePacket > getOutputPacket(unsigned int outputIndex) const
Returns the current output geometry.
Definition GeometryOperator.cpp:102
unsigned int getMaxOutputs() const
Returns the number of available outputs the node provides.
Definition GeometryOperator.cpp:184
unsigned int getMaxInputs() const
Returns the maximum number of input connections accepted by the node.
Definition GeometryOperator.cpp:183
Vector2 getPosition() const
Returns the node's position in the network graph.
Definition GeometryOperator.h:116
void setPosition(Vector2 pos)
Sets the node's position in the network graph.
Definition GeometryOperator.h:118
std::weak_ptr< prm::NodeParameter > getParameter(std::string_view parameterName)
Returns a parameter with the given name belonging to this node.
Definition GeometryOperator.cpp:107
bool isParameterEnabled(std::string_view parmName)
Whether the named parameter's disable condition leaves it enabled.
Definition GeometryOperator.cpp:131
std::string getName() const
Returns the runtime name uniquely identifying this node within its scope (eg. "my_node_05")
Definition GeometryOperator.cpp:161
Provides network context for the cookOp function.
Definition CookContext.h:24
Definition OpInfo.h:19