12 #ifndef __UNI_Graph_h__
13 #define __UNI_Graph_h__
61 {
return (myValue == value); }
63 {
return (myValue != value); }
66 {
return myValue !=
NONE; }
68 {
return ((myValue & value) != 0); }
163 static UNI_Graph * findGraph( UNI_GraphID
id );
176 {
return myGraphID; }
180 {
return myIsEditable; }
182 { myIsEditable = editable; }
189 virtual bool isEmpty()
const = 0;
192 virtual UNI_NodeID rootNode()
const = 0;
200 virtual bool isValid( UNI_NodeID node_id )
const = 0;
201 virtual bool isValid( UNI_PortID port_id )
const = 0;
202 virtual bool isValid( UNI_WireID wire_id )
const = 0;
203 virtual bool isValid( UNI_StickyNoteID note_id )
const = 0;
208 virtual bool isNameInUse(UNI_NodeID parent_id,
217 virtual UNI_NodeID parentNode( UNI_NodeID node_id )
const = 0;
219 virtual bool isSubnet( UNI_NodeID node_id )
const = 0;
223 virtual bool isEditable( UNI_NodeID node_id )
const = 0;
227 virtual bool isEditableSubnet( UNI_NodeID parent_id )
const = 0;
229 virtual UNI_NodeIDList childNodes( UNI_NodeID parent_id )
const = 0;
232 virtual UNI_NodeID findNode( UNI_NodeID from_id,
245 virtual bool isMultiSignature( UNI_NodeID node_id )
const = 0;
253 signatures( UNI_NodeID node_id,
254 bool compatible_only,
255 bool force_include_current)
const = 0;
272 virtual UT_StringHolder parmDialogScript( UNI_NodeID node_id )
const = 0;
278 virtual bool parmOverriddenByConnection( UNI_NodeID node_id,
283 virtual int numberOfInputPorts( UNI_NodeID node_id )
const = 0;
284 virtual UNI_PortIDList inputPorts( UNI_NodeID node_id )
const = 0;
285 virtual UNI_PortID inputPort( UNI_NodeID node_id,
286 int port_index )
const = 0;
287 virtual int findInputPortIndex( UNI_NodeID node_id,
288 UNI_PortID port_id )
const = 0;
292 virtual int numberOfOutputPorts( UNI_NodeID node_id )
const = 0;
293 virtual UNI_PortIDList outputPorts( UNI_NodeID node_id )
const = 0;
294 virtual UNI_PortID outputPort( UNI_NodeID node_id,
295 int port_index )
const = 0;
296 virtual int findOutputPortIndex( UNI_NodeID node_id,
297 UNI_PortID port_id )
const = 0;
303 virtual bool hasDynamicPorts( UNI_NodeID node_id )
const = 0;
310 virtual bool wireDirectlyToContainer()
const = 0;
311 virtual UT_Vector2D containerConnectPosition( UNI_NodeID parent_id,
313 virtual UT_Color containerConnectColor( UNI_NodeID parent_id,
319 virtual UNI_NodeID ownerNode( UNI_PortID port_id )
const = 0;
321 virtual UNI_PortKind portKind( UNI_PortID port_id )
const = 0;
323 virtual bool portAcceptsSubPorts( UNI_PortID port_id )
const = 0;
325 virtual bool portIsSubPort( UNI_PortID port_id )
const = 0;
327 virtual UNI_PortID outerPort( UNI_PortID port_id )
const = 0;
331 virtual UNI_PortIDList subnetOutputPorts( UNI_PortID port_id )
const = 0;
335 virtual UNI_PortIDList subnetInputPorts( UNI_PortID port_id )
const = 0;
339 virtual bool canSetName( UNI_PortID port_id )
const = 0;
351 virtual UNI_WireIDList childWires( UNI_NodeID parent_id )
const = 0;
355 virtual UNI_WireIDList
srcWires( UNI_PortID port_id )
const = 0;
356 virtual UNI_WireIDList
dstWires( UNI_PortID port_id )
const = 0;
363 virtual UNI_PortID
srcPort( UNI_WireID wire_id )
const = 0;
364 virtual UNI_PortID
dstPort( UNI_WireID wire_id )
const = 0;
369 virtual UNI_StickyNoteIDList childStickyNotes( UNI_NodeID parent_id )
const = 0;
371 virtual UNI_StickyNoteID findStickyNote( UNI_NodeID from_id,
378 virtual UNI_NodeID ownerNode( UNI_StickyNoteID note_id )
const = 0;
382 virtual UT_Color textColor( UNI_StickyNoteID note_id )
const = 0;
384 virtual float textSize( UNI_StickyNoteID note_id )
const = 0;
386 virtual UT_Color color( UNI_StickyNoteID note_id )
const = 0;
392 virtual bool isCollapsed( UNI_StickyNoteID note_id )
const = 0;
395 virtual bool isBackgroundHidden( UNI_StickyNoteID note_id )
const = 0;
400 virtual bool copyItems(UNI_NodeID parent_id,
401 const UNI_NodeIDList &node_ids,
402 const UNI_StickyNoteIDList ¬e_ids,
403 std::ostream &os)
const = 0;
406 UNI_NodeID currentChildNode( UNI_NodeID parent_id );
411 for (
auto &&item : mySelectedItems)
412 if (
auto *t_id = std::get_if<T>(&item))
419 void clearSelection();
431 using ChangeCallback =
453 { myGraph =
nullptr; }
461 {
return myChangeType; }
465 { myChangeType = myChangeType | change_type; }
484 createNode( UNI_NodeID parent_id,
493 virtual UNI_NodeID createSubnet( UNI_NodeID parent_id,
495 const UNI_PortIDList &create_input_ports,
496 const UNI_PortIDList &create_output_ports) = 0;
498 virtual void setName( UNI_NodeID node_id,
501 virtual void setSignature( UNI_NodeID node_id,
506 virtual void updateDownstreamPortTypes( UNI_NodeID node_id,
507 bool update_node ) = 0;
511 virtual void updateDownstreamPortTypes( UNI_PortID port_id,
512 bool update_port ) = 0;
517 virtual void setColor( UNI_NodeID node_id,
520 virtual void setComment( UNI_NodeID node_id,
523 virtual void setTags( UNI_NodeID node_id,
526 virtual void setParmValue( UNI_NodeID node_id,
530 virtual void destroy( UNI_NodeID node_id ) = 0;
534 virtual void setContainerConnectPosition( UNI_NodeID parent_id,
539 virtual void setContainerConnectColor( UNI_NodeID parent_id,
544 virtual void setName( UNI_PortID port_id,
547 virtual UNI_WireID createWire( UNI_PortID
src, UNI_PortID
dst ) = 0;
550 virtual void destroy( UNI_WireID wire_id ) = 0;
553 virtual UNI_StickyNoteID createStickyNote( UNI_NodeID parent_id,
556 virtual void setName( UNI_StickyNoteID note_id,
559 virtual void setPosition( UNI_StickyNoteID note_id,
562 virtual void setSize( UNI_StickyNoteID note_id,
565 virtual void setColor( UNI_StickyNoteID note_id,
568 virtual void setText( UNI_StickyNoteID note_id,
574 virtual void setTextSize( UNI_StickyNoteID note_id,
575 const float size ) = 0;
578 bool collapsed ) = 0;
584 virtual void destroy( UNI_StickyNoteID note_id ) = 0;
588 virtual bool pasteItems(UNI_NodeID parent_id,
589 UNI_NodeIDList &node_ids,
590 UNI_StickyNoteIDList ¬e_ids,
598 void forceTriggerChangeCallbacks(
608 UNI_GraphID myGraphID;
623 bool myIsEditable =
true;
void setEditable(bool editable)
Control whether this graph is editable.
UT_Array< T > selectedItemsOfType() const
Functions for tracking the current and selected nodes and wires.
typedef int(APIENTRYP RE_PFNGLXSWAPINTERVALSGIPROC)(int)
UT_Matrix4T< fpreal64 > UT_Matrix4D
GLuint GLsizei const GLchar * label
static constexpr exint UI
UNI_InvalidParmValue
Special parm value type indicating an invalid/unset value type.
void setName(const UT_StringHolder &name)
static constexpr exint GENERIC
UT_Vector2T< fpreal64 > UT_Vector2D
static constexpr exint PARAMETER
GLsizei const GLfloat * value
GLsizei const GLchar *const * path
static constexpr exint DELETED
void setTextSize(const float size)
void setBackgroundHidden(bool hidden)
void setText(const UT_StringHolder &text)
UNI_GraphID graphID() const
A reference counter base class for use with UT_IntrusivePtr.
std::pair< bool, UT_Ramp > UNI_RampParmValue
bool operator==(int value) const
bool isEditable() const
Control whether this graph is editable.
static constexpr exint NONE
UT_StringHolder text() const
#define UT_NON_COPYABLE(CLASS)
Define deleted copy constructor and assignment operator inside a class.
UNI_PortKind
Specifies the port kind, ie, wheter it is an input or an output port.
Wrapper around hboost::intrusive_ptr.
UNI_GraphChangeType operator&(const UNI_GraphChangeType &other)
UT_Function< void(UNI_Graph &, UNI_GraphChangeType, bool)> ChangeCallback
UT_Vector3T< fpreal64 > UT_Vector3D
GLuint const GLchar * name
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.
bool isSet(exint value) const
std::function< T > UT_Function
static constexpr exint SELECTION
MX_CORE_API bool isValidName(const string &name)
Return true if the given string is a valid MaterialX name.
std::variant< UNI_NodeID, UNI_WireID, UNI_StickyNoteID, UNI_ContainerConnectType > UNI_SelectableItemID
UN_API UN_PortID srcPort(const UN_GraphData *graph_data, UN_PortID dst_port_id)
void addChangeType(UNI_GraphChangeType change_type)
Reports a change that occurred in the graph.
void setTextColor(const UT_Color &clr)
UNI_GraphChangeType(int value=NONE)
Removes the graph from the lookup table and deletes it.
static constexpr exint NAME
void setPosition(const UT_Vector2D &pos)
static constexpr exint SIGNATURE
size_t UNI_API UTformatBuffer(char *buffer, size_t buffer_size, const UNI_GraphChangeType &t)
void setColor(const UT_Color &clr)
SIM_API const UT_StringHolder position
UNI_PortShape
Specifies the visual shape of the port in the UI.
void resetGraph()
Clear the graph; used only when the graph has been deleted.
UNI_GraphChangeType changeType() const
Returns the types of changes that occurred in the graph.
void setCollapsed(bool collapsed)
UNI_GraphChangeType operator|(const UNI_GraphChangeType &other)
UN_API UN_WireIDList srcWires(const UN_GraphData *graph_data, UN_NodeID node_id, UN_PortKind port_kind)
UNI_Graph * graph() const
Returns the graph that changed.
UT_Vector4T< fpreal64 > UT_Vector4D
UN_API UN_PortID dstPort(const UN_GraphData *graph_data, UN_PortID src_port_id)
void setSize(const UT_Vector2D &size)
UN_API UN_WireIDList dstWires(const UN_GraphData *graph_data, UN_NodeID node_id, UN_PortKind port_kind)
bool operator!=(int value) const
UT_Matrix3T< fpreal64 > UT_Matrix3D
static constexpr exint TOPOLOGY