12 #ifndef __UN_GraphData_h__
13 #define __UN_GraphData_h__
119 void clearData(
bool reset_ids =
false );
132 UN_NodeID root_dst_node = UN_ROOT_NODE_ID );
152 {
return UN_ROOT_NODE_ID; }
169 bool force_valid_name,
170 bool force_unique_name,
171 UN_NodeID parent_node,
176 UN_NodeID createNode(
177 UN_NodeID parent_node,
185 const UN_NodeType * nodeType( UN_NodeID node_id )
const;
192 void setNodeSignature( UN_NodeID node_id,
196 const UT_StringArray &nodeSignatureNames( UN_NodeID node_id )
const;
199 void deleteNode( UN_NodeID node );
203 void clearNode( UN_NodeID node );
216 UN_NodeID
parent( UN_NodeID child )
const
217 {
return myTopology.nodeParent( child ); }
218 UN_NodeID
parent( UN_StickyNoteID child )
const
219 {
return myTopology.stickyNoteParent( child ); }
227 {
return myTopology.nonRootNodeParent( child ); }
231 {
return myTopology.nodeSubnet(node).isValid(); }
235 {
return mySubnetData.idRange(); }
240 void moveNode( UN_NodeID node, UN_NodeID new_parent )
241 { myTopology.moveNode( node, new_parent ); }
245 UN_NodeID new_parent )
247 myTopology.moveAllChildNodes(
248 old_parent, new_parent );
256 myNodeData.size().exintValue() - 1 );
261 {
return myNodeData.idRange(); }
265 {
return myTopology.nodeChildNodes( parent ); }
267 {
return myTopology.subnetChildNodes( parent ); }
273 {
return myWireData.size(); }
277 {
return myWireData.idRange(); }
281 {
return myTopology.nodeChildWires( parent ); }
283 {
return myTopology.subnetChildWires( parent ); }
287 UN_NodeID findChildNode(
290 UN_StickyNoteID findChildStickyNote(
310 UN_NodeID current_node,
312 UN_StickyNoteID findStickyNote(
313 UN_NodeID current_node,
324 void deleteParm( UN_ParmID parm );
327 const UN_ParmIDList &
parms( UN_NodeID node )
const
328 {
return myTopology.nodeParms( node ); }
331 UN_ParmID parm( UN_NodeID node,
335 UN_NodeID
node( UN_ParmID parm )
const
336 {
return myTopology.parmNode( parm ); }
363 void setPortName( UN_PortID port_id,
367 void deletePort( UN_PortID port );
371 {
return myPortData.size(); }
375 {
return myPortData.idRange(); }
386 : outputPorts( node );
391 {
return myTopology.nodeInputPorts( node ); }
395 {
return myTopology.nodeOutputPorts( node ); }
398 UN_NodeID
node( UN_PortID port )
const
399 {
return myTopology.portNode( port ); }
407 {
return createWire( src_port, dst_port ); }
410 void disconnectPorts(
412 UN_PortID dst_port );
416 const UN_WireIDList &
srcWires( UN_PortID port )
const
417 {
return myTopology.portSrcWires( port ); }
421 const UN_WireIDList &
dstWires( UN_PortID port )
const
422 {
return myTopology.portDstWires( port ); }
426 UN_WireID createWire(
428 UN_PortID dst_port );
434 UN_PortID dst_port )
const;
437 void deleteWire( UN_WireID wire );
442 {
return myTopology.wireSrcPort( wire ); }
447 {
return myTopology.wireDstPort( wire ); }
451 UN_StickyNoteID createStickyNote( UN_NodeID parent_node,
456 void deleteStickyNote( UN_StickyNoteID sticky_note );
459 void setStickyNoteName( UN_StickyNoteID sticky_note,
464 {
return myTopology.nodeChildStickyNotes( parent ); }
466 {
return myTopology.subnetChildStickyNotes( parent ); }
473 {
return myNodeData.isValid( node ); }
475 {
return mySubnetData.isValid( subnet ); }
477 {
return myParmData.isValid( parm ); }
479 {
return myPortData.isValid( port ); }
481 {
return myWireData.isValid( wire ); }
482 bool isValid( UN_StickyNoteID sticky_note )
const
483 {
return myStickyNoteData.isValid( sticky_note ); }
489 {
return myNodeData; }
491 {
return myNodeData; }
496 {
return myParmData; }
498 {
return myParmData; }
503 {
return myPortData; }
505 {
return myPortData; }
510 {
return myWireData; }
512 {
return myWireData; }
517 {
return mySubnetData; }
519 {
return mySubnetData; }
524 {
return myStickyNoteData; }
526 {
return myStickyNoteData; }
531 { myWireDrawStyle = style; }
533 {
return myWireDrawStyle; }
540 {
return myTopology; }
544 UN_SubnetID findOrCreateSubnet( UN_NodeID node );
547 void deleteSubnet( UN_NodeID node );
548 void deleteSubnet( UN_SubnetID subnet );
557 myTopology.reorderChildren( subnet, child_order );
563 { myTopology.updateSubnetWires( old_subnet ); }
567 void createRootNode();
570 void ensureSubnetCreated( UN_NodeID node );
575 void mergeNodeClassic( UN_NodeID node,
UN_NodeID rootNode() const
UT_UniquePtr< UN_CustomNodeData > UN_CustomNodeDataPtr
GLuint GLsizei const GLchar * label
const UN_NodeData & nodeData() const
Returns the container of data for the nodes in the graph.
bool isValid(UN_SubnetID subnet) const
bool isValid(UN_ParmID parm) const
void reorderChildren(UN_SubnetID subnet, const UT_Array< UN_NodeID > &child_order)
Sets the new order for the children.
UN_WireData::IDRange allWires() const
Returns a wire ID iterator range for all the valid wires in the graph.
UN_NodeID parent(UN_NodeID child) const
UN_WireDrawStyle wireDrawStyle() const
Drawing style of the connection wires in the editor.
const UN_WireIDList & childWires(UN_SubnetID parent) const
Returns a list of wires directly inside the given node (subnet).
const UN_StickyNoteIDList & childStickyNotes(UN_SubnetID parent) const
Returns a list of direct children of the given node (subnet).
const UN_PortIDList & outputPorts(UN_NodeID node) const
Returns output ports of the given node.
const UN_GraphContext & context() const
Returns the graph context used by this graph.
const UN_PortIDList & inputPorts(UN_NodeID node) const
Returns input ports of the given node.
GLTFZ_API void setNodeName(const GLTF_Index node_id, GLTF_Writer &writer, const char *name)
UN_NodeData::IDRange allNodes() const
Returns a node ID iterator range for all the valid nodes in the graph.
bool isValid(UN_PortID port) const
std::optional< T > UT_Optional
UN_SubnetData::IDRange allSubnets() const
Returns an ID iterator range for all the valid subnets in the graph.
const UN_WireIDList & childWires(UN_NodeID parent) const
Returns a list of wires directly inside the given node (subnet).
UN_NodeID nonRootParent(UN_NodeID child) const
void moveNode(UN_NodeID node, UN_NodeID new_parent)
Moves a node from one parent to another.
bool isValid(UN_NodeID node) const
GLint GLint GLsizei GLint GLenum GLenum type
UN_SubnetData & subnetData()
Returns the container of data for the subnets in the graph.
UT_UniquePtr< UN_CustomSubnetData > UN_CustomSubnetDataPtr
UN_API UN_PortID createPort(UN_GraphData *graph_data, UN_NodeID node_id, UN_PortKind port_kind, const UT_StringRef &port_name, const UT_StringRef &port_type_name=UN_UNDEFINED_PORT_TYPE_NAME.asRef(), const UT_StringRef &port_label=UT_StringRef(), const UT_Optional< exint > &index=std::nullopt)
UN_NodeData & nodeData()
Returns the container of data for the nodes in the graph.
UT_UniquePtr< UN_CustomParmData > UN_CustomParmDataPtr
UN_PortData::IDRange allPorts() const
Returns a port ID iterator range for all the valid ports in the graph.
const UN_SubnetData & subnetData() const
Returns the container of data for the subnets in the graph.
constexpr std::enable_if< I< type_count_base< T >::value, int >::type tuple_type_size(){return subtype_count< typename std::tuple_element< I, T >::type >::value+tuple_type_size< T, I+1 >);}template< typename T > struct type_count< T, typename std::enable_if< is_tuple_like< T >::value >::type >{static constexpr int value{tuple_type_size< T, 0 >)};};template< typename T > struct subtype_count{static constexpr int value{is_mutable_container< T >::value?expected_max_vector_size:type_count< T >::value};};template< typename T, typename Enable=void > struct type_count_min{static const int value{0};};template< typename T >struct type_count_min< T, typename std::enable_if<!is_mutable_container< T >::value &&!is_tuple_like< T >::value &&!is_wrapper< T >::value &&!is_complex< T >::value &&!std::is_void< T >::value >::type >{static constexpr int value{type_count< T >::value};};template< typename T > struct type_count_min< T, typename std::enable_if< is_complex< T >::value >::type >{static constexpr int value{1};};template< typename T >struct type_count_min< T, typename std::enable_if< is_wrapper< T >::value &&!is_complex< T >::value &&!is_tuple_like< T >::value >::type >{static constexpr int value{subtype_count_min< typename T::value_type >::value};};template< typename T, std::size_t I >constexpr typename std::enable_if< I==type_count_base< T >::value, int >::type tuple_type_size_min(){return 0;}template< typename T, std::size_t I > constexpr typename std::enable_if< I< type_count_base< T >::value, int >::type tuple_type_size_min(){return subtype_count_min< typename std::tuple_element< I, T >::type >::value+tuple_type_size_min< T, I+1 >);}template< typename T > struct type_count_min< T, typename std::enable_if< is_tuple_like< T >::value >::type >{static constexpr int value{tuple_type_size_min< T, 0 >)};};template< typename T > struct subtype_count_min{static constexpr int value{is_mutable_container< T >::value?((type_count< T >::value< expected_max_vector_size)?type_count< T >::value:0):type_count_min< T >::value};};template< typename T, typename Enable=void > struct expected_count{static const int value{0};};template< typename T >struct expected_count< T, typename std::enable_if<!is_mutable_container< T >::value &&!is_wrapper< T >::value &&!std::is_void< T >::value >::type >{static constexpr int value{1};};template< typename T > struct expected_count< T, typename std::enable_if< is_mutable_container< T >::value >::type >{static constexpr int value{expected_max_vector_size};};template< typename T >struct expected_count< T, typename std::enable_if<!is_mutable_container< T >::value &&is_wrapper< T >::value >::type >{static constexpr int value{expected_count< typename T::value_type >::value};};enum class object_category:int{char_value=1, integral_value=2, unsigned_integral=4, enumeration=6, boolean_value=8, floating_point=10, number_constructible=12, double_constructible=14, integer_constructible=16, string_assignable=23, string_constructible=24, other=45, wrapper_value=50, complex_number=60, tuple_value=70, container_value=80,};template< typename T, typename Enable=void > struct classify_object{static constexpr object_category value{object_category::other};};template< typename T >struct classify_object< T, typename std::enable_if< std::is_integral< T >::value &&!std::is_same< T, char >::value &&std::is_signed< T >::value &&!is_bool< T >::value &&!std::is_enum< T >::value >::type >{static constexpr object_category value{object_category::integral_value};};template< typename T >struct classify_object< T, typename std::enable_if< std::is_integral< T >::value &&std::is_unsigned< T >::value &&!std::is_same< T, char >::value &&!is_bool< T >::value >::type >{static constexpr object_category value{object_category::unsigned_integral};};template< typename T >struct classify_object< T, typename std::enable_if< std::is_same< T, char >::value &&!std::is_enum< T >::value >::type >{static constexpr object_category value{object_category::char_value};};template< typename T > struct classify_object< T, typename std::enable_if< is_bool< T >::value >::type >{static constexpr object_category value{object_category::boolean_value};};template< typename T > struct classify_object< T, typename std::enable_if< std::is_floating_point< T >::value >::type >{static constexpr object_category value{object_category::floating_point};};template< typename T >struct classify_object< T, typename std::enable_if<!std::is_floating_point< T >::value &&!std::is_integral< T >::value &&std::is_assignable< T &, std::string >::value >::type >{static constexpr object_category value{object_category::string_assignable};};template< typename T >struct classify_object< T, typename std::enable_if<!std::is_floating_point< T >::value &&!std::is_integral< T >::value &&!std::is_assignable< T &, std::string >::value &&(type_count< T >::value==1)&&std::is_constructible< T, std::string >::value >::type >{static constexpr object_category value{object_category::string_constructible};};template< typename T > struct classify_object< T, typename std::enable_if< std::is_enum< T >::value >::type >{static constexpr object_category value{object_category::enumeration};};template< typename T > struct classify_object< T, typename std::enable_if< is_complex< T >::value >::type >{static constexpr object_category value{object_category::complex_number};};template< typename T > struct uncommon_type{using type=typename std::conditional<!std::is_floating_point< T >::value &&!std::is_integral< T >::value &&!std::is_assignable< T &, std::string >::value &&!std::is_constructible< T, std::string >::value &&!is_complex< T >::value &&!is_mutable_container< T >::value &&!std::is_enum< T >::value, std::true_type, std::false_type >::type;static constexpr bool value=type::value;};template< typename T >struct classify_object< T, typename std::enable_if<(!is_mutable_container< T >::value &&is_wrapper< T >::value &&!is_tuple_like< T >::value &&uncommon_type< T >::value)>::type >{static constexpr object_category value{object_category::wrapper_value};};template< typename T >struct classify_object< T, typename std::enable_if< uncommon_type< T >::value &&type_count< T >::value==1 &&!is_wrapper< T >::value &&is_direct_constructible< T, double >::value &&is_direct_constructible< T, int >::value >::type >{static constexpr object_category value{object_category::number_constructible};};template< typename T >struct classify_object< T, typename std::enable_if< uncommon_type< T >::value &&type_count< T >::value==1 &&!is_wrapper< T >::value &&!is_direct_constructible< T, double >::value &&is_direct_constructible< T, int >::value >::type >{static constexpr object_category value{object_category::integer_constructible};};template< typename T >struct classify_object< T, typename std::enable_if< uncommon_type< T >::value &&type_count< T >::value==1 &&!is_wrapper< T >::value &&is_direct_constructible< T, double >::value &&!is_direct_constructible< T, int >::value >::type >{static constexpr object_category value{object_category::double_constructible};};template< typename T >struct classify_object< T, typename std::enable_if< is_tuple_like< T >::value &&((type_count< T >::value >=2 &&!is_wrapper< T >::value)||(uncommon_type< T >::value &&!is_direct_constructible< T, double >::value &&!is_direct_constructible< T, int >::value)||(uncommon_type< T >::value &&type_count< T >::value >=2))>::type >{static constexpr object_category value{object_category::tuple_value};};template< typename T > struct classify_object< T, typename std::enable_if< is_mutable_container< T >::value >::type >{static constexpr object_category value{object_category::container_value};};template< typename T, enable_if_t< classify_object< T >::value==object_category::char_value, detail::enabler >=detail::dummy >constexpr const char *type_name(){return"CHAR";}template< typename T, enable_if_t< classify_object< T >::value==object_category::integral_value||classify_object< T >::value==object_category::integer_constructible, detail::enabler >=detail::dummy >constexpr const char *type_name(){return"INT";}template< typename T, enable_if_t< classify_object< T >::value==object_category::unsigned_integral, detail::enabler >=detail::dummy >constexpr const char *type_name(){return"UINT";}template< typename T, enable_if_t< classify_object< T >::value==object_category::floating_point||classify_object< T >::value==object_category::number_constructible||classify_object< T >::value==object_category::double_constructible, detail::enabler >=detail::dummy >constexpr const char *type_name(){return"FLOAT";}template< typename T, enable_if_t< classify_object< T >::value==object_category::enumeration, detail::enabler >=detail::dummy >constexpr const char *type_name(){return"ENUM";}template< typename T, enable_if_t< classify_object< T >::value==object_category::boolean_value, detail::enabler >=detail::dummy >constexpr const char *type_name(){return"BOOLEAN";}template< typename T, enable_if_t< classify_object< T >::value==object_category::complex_number, detail::enabler >=detail::dummy >constexpr const char *type_name(){return"COMPLEX";}template< typename T, enable_if_t< classify_object< T >::value >=object_category::string_assignable &&classify_object< T >::value<=object_category::other, detail::enabler >=detail::dummy >constexpr const char *type_name(){return"TEXT";}template< typename T, enable_if_t< classify_object< T >::value==object_category::tuple_value &&type_count_base< T >::value >=2, detail::enabler >=detail::dummy >std::string type_name();template< typename T, enable_if_t< classify_object< T >::value==object_category::container_value||classify_object< T >::value==object_category::wrapper_value, detail::enabler >=detail::dummy >std::string type_name();template< typename T, enable_if_t< classify_object< T >::value==object_category::tuple_value &&type_count_base< T >::value==1, detail::enabler >=detail::dummy >inline std::string type_name(){return type_name< typename std::decay< typename std::tuple_element< 0, T >::type >::type >);}template< typename T, std::size_t I >inline typename std::enable_if< I==type_count_base< T >::value, std::string >::type tuple_name(){return std::string{};}template< typename T, std::size_t I >inline typename std::enable_if<(I< type_count_base< T >::value), std::string >::type tuple_name(){auto str=std::string{type_name< typename std::decay< typename std::tuple_element< I, T >::type >::type >)}+ ','+tuple_name< T, I+1 >);if(str.back()== ',') str.pop_back();return str;}template< typename T, enable_if_t< classify_object< T >::value==object_category::tuple_value &&type_count_base< T >::value >=2, detail::enabler > > std::string type_name()
Recursively generate the tuple type name.
const UN_WireIDList & dstWires(UN_PortID port) const
UT_UniquePtr< UN_CustomWireData > UN_CustomWireDataPtr
UN_WireData & wireData()
Returns the container of data for the wires in the graph.
UNI_PortKind
Specifies the port kind, ie, wheter it is an input or an output port.
bool isValid(UN_StickyNoteID sticky_note) const
UN_WireID connectPorts(UN_PortID src_port, UN_PortID dst_port)
void updateSubnetWires(UN_SubnetID old_subnet)
const UN_StickyNoteData & stickyNoteData() const
Returns the container of data for the sticky notes in the graph.
GLuint const GLchar * name
UN_DataSize wireCount() const
Returns the number of all wires in the graph.
UN_NodeID node(UN_ParmID parm) const
Returns the owner node of the given parameter.
UN_API UN_OptionsPtr asOptions(const UN_GraphData *graph_data)
const UN_PortIDList & ports(UN_NodeID node, UN_PortKind kind) const
Returns the ports of the given kind for the given node.
const UN_WireData & wireData() const
Returns the container of data for the wires in the graph.
UN_StickyNoteData & stickyNoteData()
Returns the container of data for the sticky notes in the graph.
void setWireDrawStyle(UN_WireDrawStyle style)
Drawing style of the connection wires in the editor.
const UN_StickyNoteIDList & childStickyNotes(UN_NodeID parent) const
Returns a list of direct children of the given node (subnet).
bool isSubnet(UN_NodeID node) const
Returns true if the given node is a subnet (ie, can have children).
const UN_NodeIDList & childNodes(UN_NodeID parent) const
Returns a list of direct children of the given node (subnet).
UN_PortID srcPort(UN_WireID wire) const
A map of string to various well defined value types.
bool isValid(UN_WireID wire) const
UN_ParmData & parmData()
Returns the container of data for the parameters in the graph.
UT_UniquePtr< UN_CustomPortData > UN_CustomPortDataPtr
Information about the result of a merge from another graph.
void moveAllChildNodes(UN_NodeID old_parent, UN_NodeID new_parent)
Moves all children of the given parent node to another one.
const UN_GraphTopology & topology() const
const UN_PortData & portData() const
Returns the container of data for the ports in the graph.
const UN_WireIDList & srcWires(UN_PortID port) const
LeafData & operator=(const LeafData &)=delete
const UN_ParmIDList & parms(UN_NodeID node) const
Returns the parameters of the given node.
const UN_ParmData & parmData() const
Returns the container of data for the parameters in the graph.
UN_DataSize portCount() const
Returns the number of all ports in the graph.
UN_PortData & portData()
Returns the container of data for the ports in the graph.
const UN_NodeIDList & childNodes(UN_SubnetID parent) const
Returns a list of direct children of the given node (subnet).
UN_NodeID node(UN_PortID port) const
Returns the owner node of the given port.
UN_PortID dstPort(UN_WireID wire) const
UN_NodeID parent(UN_StickyNoteID child) const
UT_UniquePtr< UN_CustomStickyNoteData > UN_CustomStickyNoteDataPtr
UT_UniquePtr< UN_Options > UN_OptionsPtr
UN_API UN_ParmID createParm(UN_GraphData *graph_data, UN_NodeID node_id, const UT_StringRef &parm_name, const UT_StringRef &parm_type_name=UN_UNDEFINED_PARM_TYPE_NAME.asRef())
UN_DataSize nodeCount() const
Returns the number of all nodes in the graph.