HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
UNI_Node.h
Go to the documentation of this file.
1 /*
2  * PROPRIETARY INFORMATION. This software is proprietary to
3  * Side Effects Software Inc., and is not to be reproduced,
4  * transmitted, or disclosed in any way without written permission.
5  *
6  * NAME: UNI_Node.h ( UNI Library, C++)
7  *
8  * COMMENTS:
9  *
10  */
11 
12 #ifndef __UNI_Node_h__
13 #define __UNI_Node_h__
14 
15 #include "UNI_API.h"
16 #include "UNI_Item.h"
17 
18 // ============================================================================
19 class UNI_ConstNode : public UNI_ConstItem<UNI_NodeID>
20 {
21 public:
22  /// Expose base class constructors.
24 
25  /// Returns true if this is the graph root node.
26  bool isRootNode() const
27  { return graph() ? id() == graph()->rootNode() : false; }
28 
29  /// Returns true if this node is a subnet (can contain other nodes).
30  bool isSubnet() const
31  { return graph() ? graph()->isSubnet(id()) : false; }
32  /// Returns true if this subnet's contents can be modified.
33  bool isEditableSubnet() const
34  { return graph() ? graph()->isEditableSubnet(id()) : false; }
35  /// Returns true if this is the graph root node.
36  bool isEditable() const
37  { return graph() ? graph()->isEditable(id()) : false; }
38  /// Returns the name of the node.
40  { return graph() ? graph()->name(id()) : UT_StringHolder(); }
41  /// Return the full path from the root of the graph to this node.
43  { return graph() ? graph()->path(id()) : UT_StringHolder(); }
44  /// Returns the category name of the node.
46  { return graph() ? graph()->categoryName(id()) : UT_StringHolder(); }
47  /// Returns the type name of the node.
49  { return graph() ? graph()->typeName(id()) : UT_StringHolder(); }
50  /// Returns the name of the current signature of this node.
52  { return graph() ? graph()->signatureName(id()) : UT_StringHolder(); }
53  /// Returns the node position in the graph editor.
55  { return graph() ? graph()->position(id()) : UT_Vector2D(); }
56  /// Returns the color tint of the node in the graph editor.
57  UT_Color color() const
58  { return graph() ? graph()->color(id()) : UT_Color(); }
59  /// Returns the icon name for the given node.
61  { return graph() ? graph()->iconName(id()) : UT_StringHolder(); }
62  /// Returns the comment for the node.
64  { return graph() ? graph()->comment(id()) : UT_StringHolder(); }
65  /// Returns the tags (a set of keywords) assigned to the node.
67  { return graph() ? graph()->tags(id()) : UT_StringArray(); }
68  /// Returns a dialog script describing this node's parms.
70  { return graph() ? graph()->parmDialogScript(id()) : UT_StringHolder(); }
71  /// Get the value of a parm on this node.
72  UNI_ParmValue parmValue( const UT_StringRef &parm_name ) const
73  { return graph() ? graph()->parmValue(id(), parm_name) : UNI_ParmValue(); }
74 
75  /// Returns the id of our parent node. This may be the root node. The
76  /// parent of the root node will be an invalid node.
77  UNI_NodeID parent() const
78  {
79  return (graph() && id() != graph()->rootNode())
80  ? graph()->parentNode(id())
81  : UNI_NodeID();
82  }
83  /// Returns the id of the node specified by the provided path, which may
84  /// be absolute or relative to this node.
85  UNI_NodeID findNode( const UT_StringRef &path ) const
86  { return graph() ? graph()->findNode(id(), path) : UNI_NodeID(); }
87  /// Returns array of ids of all direct children of this node.
88  UNI_NodeIDList childNodes() const
89  { return graph() ? graph()->childNodes(id()) : UT_Array<UNI_NodeID>(); }
90 
91  /// Returns all sticky notes contained by this node.
92  UNI_StickyNoteIDList childStickyNotes() const
93  { return graph() ? graph()->childStickyNotes(id()) : UNI_StickyNoteIDList(); }
94  /// Find a sticky note using a path specified relative to this node.
95  UNI_StickyNoteID findStickyNote(const UT_StringRef &path) const
96  { return graph() ? graph()->findStickyNote(id(), path) : UNI_StickyNoteID(); }
97 
98  /// Input ports of a node.
99  UNI_PortIDList inputPorts() const
100  { return graph() ? graph()->inputPorts(id()) : UNI_PortIDList(); }
101  /// Output ports of a node.
102  UNI_PortIDList outputPorts() const
103  { return graph() ? graph()->outputPorts(id()) : UNI_PortIDList(); }
104  /// Does this node have dynamic input or output ports (not subports).
105  bool hasDynamicPorts( UNI_NodeID node_id) const
106  { return graph() ? graph()->hasDynamicPorts(id()) : false; }
107 
108  /// The position of the UI gadget for connecting to inputs or outputs of
109  /// the container node.
111  UNI_ContainerConnectType contype ) const
112  { return graph() ? graph()->containerConnectPosition(id(), contype) : UT_Vector2D(); }
113  /// The color of the UI gadget for connecting to inputs or outputs of
114  /// the container node.
116  UNI_ContainerConnectType contype ) const
117  { return graph() ? graph()->containerConnectColor(id(), contype) : UT_Color(); }
118 
119  /// Copy items contained by this node.
120  bool copyItems(const UNI_NodeIDList &node_ids,
121  const UNI_StickyNoteIDList &note_ids,
122  std::ostream &os) const
123  { return graph() ? graph()->copyItems(id(), node_ids, note_ids, os) : false; }
124 };
125 
126 // ============================================================================
127 class UNI_API UNI_Node : public UNI_Item<UNI_NodeID,
128  UNI_SessionNodeID,
129  UNI_ConstNode>
130 {
131 public:
132  /// Expose base class constructors.
133  using UNI_Item::UNI_Item;
134 
135  /// Create a new child node.
136  UNI_NodeID createNode( const UT_StringHolder &node_name,
137  const UT_StringHolder &node_type_name,
138  const UT_StringHolder &signature_name = UT_StringHolder() ) const;
139  /// Create a new subnet node with a pre-populates its inputs and outputs.
140  UNI_NodeID createSubnet( const UT_StringHolder &subnet_node_name,
141  const UNI_PortIDList &create_input_ports,
142  const UNI_PortIDList &create_output_ports ) const;
143  /// Sets the node name.
144  void setName( const UT_StringHolder &name ) const;
145  /// Sets the current signature for this node.
146  void setSignature( const UT_StringHolder &signature_name ) const;
147  /// Ensures the node signatures and port types for the downstream nodes
148  /// are up-to-date.
149  /// If @p update_node is true, this node is updated too.
150  void updateDownstreamPortTypes( bool update_node ) const;
151  /// Sets the node position in the graph editor.
152  void setPosition( const UT_Vector2D &pos ) const;
153  /// Sets the node color.
154  void setColor( const UT_Color &clr ) const;
155  /// Sets the node comment.
156  void setComment( const UT_StringHolder &comment ) const;
157  /// Sets the node tags.
158  void setTags( const UT_StringArray &tags ) const;
159  /// Sets a parm value.
160  void setParmValue( const UT_StringRef &parm_name,
161  const UNI_ParmValue &value );
162 
163  /// Create a sticky note child.
164  UNI_StickyNoteID createStickyNote( const UT_StringHolder &name ) const;
165  /// Destroys this node.
166  void destroy() const;
167 
168  /// Set the position of the special "connect to my container"
169  /// UI element in the graph editor when viewing inside this node.
170  void setContainerConnectPosition( UNI_ContainerConnectType contype,
171  const UT_Vector2D &pos );
172  /// Set the color of the special "connect to my container"
173  /// UI element in the graph editor when viewing inside this node.
174  void setContainerConnectColor( UNI_ContainerConnectType contype,
175  const UT_Color &clr );
176 
177  /// Paste items into this node from a stream (created by copyItems).
178  bool pasteItems(UNI_NodeIDList &node_ids,
179  UNI_StickyNoteIDList &note_ids,
180  std::istream &is,
181  UT_StringMap<UT_StringHolder> *rename_map);
182 };
183 
184 #endif
UT_StringArray tags() const
Returns the tags (a set of keywords) assigned to the node.
Definition: UNI_Node.h:66
UNI_PortIDList inputPorts() const
Input ports of a node.
Definition: UNI_Node.h:99
virtual UT_StringArray tags(UNI_NodeID node_id) const =0
The list of tags associated with a node.
UNI_PortIDList outputPorts() const
Output ports of a node.
Definition: UNI_Node.h:102
bool isRootNode() const
Returns true if this is the graph root node.
Definition: UNI_Node.h:26
UT_Vector2D containerConnectPosition(UNI_ContainerConnectType contype) const
Definition: UNI_Node.h:110
UT_Vector2T< fpreal64 > UT_Vector2D
GLsizei const GLfloat * value
Definition: glcorearb.h:824
GLsizei const GLchar *const * path
Definition: glcorearb.h:3341
UNI_NodeID id() const
Returns the ID of the node in the graph.
Definition: UNI_Item.h:47
UT_StringHolder comment() const
Returns the comment for the node.
Definition: UNI_Node.h:63
virtual UNI_NodeIDList childNodes(UNI_NodeID parent_id) const =0
Returns the children nodes that live inside the given parent node.
virtual UNI_StickyNoteID findStickyNote(UNI_NodeID from_id, const UT_StringRef &path) const =0
Find the sticky note at a path relative to a starting node.
#define UNI_API
Definition: UNI_API.h:11
virtual UT_Color color(UNI_NodeID node_id) const =0
The color tint of the node in the graph editor.
virtual bool hasDynamicPorts(UNI_NodeID node_id) const =0
virtual UNI_ParmValue parmValue(UNI_NodeID node_id, const UT_StringRef &parm_name) const =0
Get the value of a parm on this node.
virtual UNI_PortIDList inputPorts(UNI_NodeID node_id) const =0
Input ports of a node.
virtual UT_StringHolder comment(UNI_NodeID node_id) const =0
The user-authored comment for a node.
bool isEditable() const
Control whether this graph is editable.
Definition: UNI_Graph.h:179
UT_Color color() const
Returns the color tint of the node in the graph editor.
Definition: UNI_Node.h:57
virtual bool isEditableSubnet(UNI_NodeID parent_id) const =0
UNI_NodeIDList childNodes() const
Returns array of ids of all direct children of this node.
Definition: UNI_Node.h:88
virtual UT_StringHolder categoryName(UNI_NodeID node_id) const =0
The category name of the node.
virtual UNI_StickyNoteIDList childStickyNotes(UNI_NodeID parent_id) const =0
virtual UT_StringHolder iconName(UNI_NodeID node_id) const =0
Returns the icon name for the given node.
UT_StringHolder iconName() const
Returns the icon name for the given node.
Definition: UNI_Node.h:60
virtual UT_Vector2D position(UNI_NodeID node_id) const =0
The position of the node in the graph editor.
virtual bool isSubnet(UNI_NodeID node_id) const =0
Returns true if the given node is a subnet (can have child nodes).
virtual UT_Vector2D containerConnectPosition(UNI_NodeID parent_id, UNI_ContainerConnectType contype) const =0
UNI_StickyNoteIDList childStickyNotes() const
Returns all sticky notes contained by this node.
Definition: UNI_Node.h:92
UNI_ParmValue parmValue(const UT_StringRef &parm_name) const
Get the value of a parm on this node.
Definition: UNI_Node.h:72
virtual UT_StringHolder name() const =0
UNI_NodeID findNode(const UT_StringRef &path) const
Definition: UNI_Node.h:85
bool isEditableSubnet() const
Returns true if this subnet's contents can be modified.
Definition: UNI_Node.h:33
virtual UT_StringHolder signatureName(UNI_NodeID node_id) const =0
The name of the current signature of the given node.
GLuint const GLchar * name
Definition: glcorearb.h:786
std::variant< UNI_InvalidParmValue, UNI_DefaultParmValue, bool, int64, fpreal64, UT_Vector2D, UT_Vector3D, UT_Vector4D, UT_Matrix3D, UT_Matrix4D, UT_StringHolder, UNI_RampParmValue > UNI_ParmValue
Variant data type that holds all the parm value types allowed in UNI parms.
Definition: UNI_Graph.h:126
virtual UNI_NodeID findNode(UNI_NodeID from_id, const UT_StringRef &path) const =0
UNI_StickyNoteID findStickyNote(const UT_StringRef &path) const
Find a sticky note using a path specified relative to this node.
Definition: UNI_Node.h:95
UNI_NodeID parent() const
Definition: UNI_Node.h:77
bool copyItems(const UNI_NodeIDList &node_ids, const UNI_StickyNoteIDList &note_ids, std::ostream &os) const
Copy items contained by this node.
Definition: UNI_Node.h:120
UT_StringHolder name() const
Returns the name of the node.
Definition: UNI_Node.h:39
virtual UNI_NodeID parentNode(UNI_NodeID node_id) const =0
virtual UNI_PortIDList outputPorts(UNI_NodeID node_id) const =0
Output ports of a node.
bool hasDynamicPorts(UNI_NodeID node_id) const
Does this node have dynamic input or output ports (not subports).
Definition: UNI_Node.h:105
UNI_ContainerConnectType
Definition: UNI_Graph.h:35
UT_StringHolder typeName() const
Returns the type name of the node.
Definition: UNI_Node.h:48
virtual UT_Color containerConnectColor(UNI_NodeID parent_id, UNI_ContainerConnectType contype) const =0
UT_StringHolder path() const
Return the full path from the root of the graph to this node.
Definition: UNI_Node.h:42
UNI_Item()=default
Constructor.
UT_StringHolder parmDialogScript() const
Returns a dialog script describing this node's parms.
Definition: UNI_Node.h:69
UT_StringHolder categoryName() const
Returns the category name of the node.
Definition: UNI_Node.h:45
virtual UT_StringHolder typeName(UNI_NodeID node_id) const =0
The type name of the node.
UT_Vector2D position() const
Returns the node position in the graph editor.
Definition: UNI_Node.h:54
const UNI_Graph * graph() const
Returns the graph inside which the node lives.
Definition: UNI_Item.h:44
virtual UNI_NodeID rootNode() const =0
virtual bool copyItems(UNI_NodeID parent_id, const UNI_NodeIDList &node_ids, const UNI_StickyNoteIDList &note_ids, std::ostream &os) const =0
UT_StringHolder signatureName() const
Returns the name of the current signature of this node.
Definition: UNI_Node.h:51
bool isEditable() const
Returns true if this is the graph root node.
Definition: UNI_Node.h:36
virtual UT_StringHolder parmDialogScript(UNI_NodeID node_id) const =0
virtual UT_StringHolder path(UNI_NodeID node_id) const =0
The full path of the node.
UNI_ConstItem()=default
Constructor.
UT_Color containerConnectColor(UNI_ContainerConnectType contype) const
Definition: UNI_Node.h:115
bool isSubnet() const
Returns true if this node is a subnet (can contain other nodes).
Definition: UNI_Node.h:30