HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
OP_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: OP Library (C++)
7  *
8  * COMMENTS: The base class for all OP operators
9  *
10  */
11 
12 #ifndef __OP_Node_h__
13 #define __OP_Node_h__
14 
15 #include "OP_API.h"
16 #include "OP_BundleReferences.h"
17 #include "OP_Cache.h"
18 #include "OP_ConnectorId.h"
19 #include "OP_Context.h"
20 #include "OP_DataMicroNode.h"
21 #include "OP_DataTypes.h"
22 #include "OP_Dependency.h"
23 #include "OP_Error.h"
24 #include "OP_EventMicroNode.h"
25 #include "OP_InterestRef.h"
26 #include "OP_ItemId.h"
27 #include "OP_Lock.h"
28 #include "OP_NetworkBoxItem.h"
29 #include "OP_NodeFlags.h"
30 #include "OP_OpTypeId.h"
31 #include "OP_OTLLicenseType.h"
32 #include "OP_Parameters.h"
33 #include "OP_Value.h"
34 #include "OP_Version.h"
35 
36 #include <CH/CH_EventManager.h>
37 #include <CH/CH_Types.h>
38 #include <DEP/DEP_MicroNode.h>
39 #include <UT/UT_Algorithm.h>
40 #include <UT/UT_Array.h>
41 #include <UT/UT_ArrayMap.h>
42 #include <UT/UT_Assert.h>
43 #include <UT/UT_BitArray.h>
44 #include <UT/UT_BoundingBox.h>
45 #include <UT/UT_Color.h>
46 #include <UT/UT_Error.h>
47 #include <UT/UT_KnownPath.h>
48 #include <UT/UT_LockedRawPtr.h>
49 #include <UT/UT_Matrix4.h>
50 #include <UT/UT_Options.h>
51 #include <UT/UT_SharedPtr.h>
52 #include <UT/UT_SmallArray.h>
53 #include <UT/UT_String.h>
54 #include <UT/UT_StringHolder.h>
55 #include <UT/UT_StringMap.h>
56 #include <UT/UT_StringView.h>
57 #include <UT/UT_TaskState.h>
58 #include <UT/UT_TokenString.h>
59 #include <UT/UT_UniquePtr.h>
60 #include <UT/UT_ValArray.h>
61 #include <UT/UT_Vector3.h>
62 #include <UT/UT_VectorTypes.h>
63 #include <UT/UT_XformOrder.h>
64 #include <SYS/SYS_AtomicInt.h>
65 #include <SYS/SYS_Deprecated.h>
66 #include <SYS/SYS_Math.h>
67 #include <SYS/SYS_Types.h>
68 
69 #include <iosfwd>
70 #include <utility>
71 #include <limits.h>
72 #include <string.h>
73 
74 class UT_InfoTree;
75 class UT_IStream;
76 class UT_Ramp;
77 class UT_StringArray;
78 class UT_Undo;
79 class UT_WorkArgs;
80 class UT_WorkBuffer;
82 class IMG_Raster;
83 class PY_OpaqueObject;
84 class PY_Result;
85 class DD_Source;
86 class DD_ChoiceList;
87 class CL_Clip;
88 class CL_Track;
89 class CMD_Args;
90 class CH_Channel;
91 class CH_ChannelRef;
92 class CH_LocalVariable;
93 class PRM_BatchList;
94 class PRM_Name;
95 class PRM_Parm;
96 class PRM_ParmList;
97 class PRM_ParmMicroNode;
98 class PRM_RefId;
99 class PRM_Template;
100 class OP_Bundle;
101 class OP_DopParent;
102 class OP_Dot;
103 class OP_EditorContext;
104 class OP_GalleryEntry;
105 class OP_GlobContext;
106 class OP_Group;
107 class OP_IndirectInput;
108 class OP_Input;
109 class OP_Network;
110 class OP_NetworkBox;
111 class OP_Node;
112 class OP_NodeInfoParms;
114 class OP_Operator;
115 class OP_Output;
116 class OP_OutputCodeParms;
117 class OP_PostIt;
118 class OP_PreDefRules;
119 class OP_PropagateData;
120 class OP_SaveFlags;
122 class DOP_Parent;
123 class VOP_CodeGenerator;
126 
127 // avoid lengthy compilation dependency
129 
130 typedef int (*OP_EditCallback)(void *data, OP_Node *src,
131  CL_Track *track, fpreal t, fpreal value);
132 
136 
138 {
140  : myInput(p), myName(n) {}
143 };
144 
146 {
148  : myOutput(p), myName(n) {}
151 };
152 
154 {
155  OP_NodeParmRef(const OP_Node *eval_node = 0,
156  const PRM_Parm *parm_ref = 0,
157  int vi = -1)
158  : myEvalNode(eval_node)
159  , myParmRef(parm_ref)
160  , myVectorIndex(vi)
161  {
162  }
163 
164  bool operator==(const OP_NodeParmRef &other)
165  {
166  return (myEvalNode == other.myEvalNode
167  && myParmRef == other.myParmRef
168  && myVectorIndex == other.myVectorIndex);
169  }
170 
171  const OP_Node * myEvalNode; // node evaluating the given parameter
172  const PRM_Parm * myParmRef; // pointer to evaluated parameter
173  int myVectorIndex; // parameter component index
174 };
175 
177 {
180 };
181 
182 // Callback to delay the evaluation of a transform
184 {
185 public:
187  virtual const UT_Matrix4D& eval(bool &ret) = 0;
188 };
189 
191 {
192 public:
193  OP_EvaluateTransformTracksArgs( const UT_StringHolder name, UT_Matrix4D *w, UT_Matrix4D *l=nullptr, OP_TransformCallback *parent_cb=nullptr, int *timedep=nullptr )
194  : myTrackIndex(-1)
195  , myTrackCount(1)
196  , myTrackName(name)
197  , myWorldXfo(w)
198  , myLocalXfo(l)
199  , myParentXfo(parent_cb)
200  , myTimeDep(timedep)
201  {}
202 
203  OP_EvaluateTransformTracksArgs( int index, UT_Matrix4D *w, UT_Matrix4D *l=nullptr, OP_TransformCallback *parent_cb=nullptr, int *timedep=nullptr )
204  : myTrackIndex(index)
205  , myTrackCount(1)
206  , myWorldXfo(w)
207  , myLocalXfo(l)
208  , myParentXfo(parent_cb)
209  , myTimeDep(timedep)
210  {}
211 
212  // Callback to delay the evaluation of a transform
216 
220  int *myTimeDep;
221 };
222 
223 // Utility for detecting cycles when traversing graphs
226 
230 typedef std::pair<const OP_Node *, int> opNodeOutput;
231 
232 // The prefix used to specify an operator where a path would normally be used.
233 #define OPREF_PREFIX "op:"
234 #define OPREF_PREFIX_LEN 3
235 
236 // Default value of hash for compiled code associated with this node that
237 // shouldn't conflict with the hash of any actual cached code.
238 #define DEFAULT_COMP_HASH_VALUE (17*19)
239 
240 // Please, no spaces in these table names!
241 #define INVALID_TABLE_NAME "Node"
242 #define OBJ_TABLE_NAME "Object"
243 #define SOP_TABLE_NAME "Sop"
244 #define CHOPNET_TABLE_NAME "ChopNet"
245 #define CHOP_TABLE_NAME "Chop"
246 #define ROP_TABLE_NAME "Driver"
247 #define SHOP_TABLE_NAME "Shop"
248 #define COP2_TABLE_NAME "Cop2"
249 #define COP2NET_TABLE_NAME "CopNet"
250 #define VOP_TABLE_NAME "Vop"
251 #define VOPNET_TABLE_NAME "VopNet"
252 #define DOP_TABLE_NAME "Dop"
253 #define TOP_TABLE_NAME "Top"
254 #define TOPNET_TABLE_NAME "TopNet"
255 #define LOP_TABLE_NAME "Lop"
256 
257 // Manager and Director table names:
258 #define MGR_TABLE_NAME "Manager"
259 #define DIR_TABLE_NAME "Director"
260 #define DATA_TABLE_NAME "Data"
261 
262 // These are the "script" directories where help and initialization scripts
263 // are found.
264 #define INVALID_SCRIPT_NAME "node"
265 #define OBJ_SCRIPT_NAME "obj"
266 #define SOP_SCRIPT_NAME "sop"
267 #define CHOPNET_SCRIPT_NAME "ch"
268 #define CHOP_SCRIPT_NAME "chop"
269 #define ROP_SCRIPT_NAME "out"
270 #define SHOP_SCRIPT_NAME "shop"
271 #define COP2_SCRIPT_NAME "cop2"
272 #define COP2NET_SCRIPT_NAME "img"
273 #define VOP_SCRIPT_NAME "vop"
274 #define VOPNET_SCRIPT_NAME "vex"
275 #define DOP_SCRIPT_NAME "dop"
276 #define TOP_SCRIPT_NAME "top"
277 #define TOPNET_SCRIPT_NAME "tasks"
278 #define LOP_SCRIPT_NAME "lop"
279 
280 // Manager and Director scripts... I doubt these will be used.
281 #define MGR_SCRIPT_NAME "mgr"
282 #define DIR_SCRIPT_NAME "dir"
283 #define MAT_SCRIPT_NAME "mat"
284 #define DATA_SCRIPT_NAME "data"
285 
286 // These are the op type names. These are used by icons among others.
287 #define INVALID_OPTYPE_NAME "NODE"
288 #define OBJ_OPTYPE_NAME "OBJ"
289 #define SOP_OPTYPE_NAME "SOP"
290 #define CHOPNET_OPTYPE_NAME "CHOPNET"
291 #define CHOP_OPTYPE_NAME "CHOP"
292 #define ROP_OPTYPE_NAME "ROP"
293 #define SHOP_OPTYPE_NAME "SHOP"
294 #define COP2_OPTYPE_NAME "COP2"
295 #define COP2NET_OPTYPE_NAME "IMG"
296 #define VOP_OPTYPE_NAME "VOP"
297 #define VOPNET_OPTYPE_NAME "VOPNET"
298 #define DOP_OPTYPE_NAME "DOP"
299 #define TOP_OPTYPE_NAME "TOP"
300 #define TOPNET_OPTYPE_NAME "TOPNET"
301 #define LOP_OPTYPE_NAME "LOP"
302 
303 // These are the types of the manager nodes & director nodes.
304 // Manager nodes are things like /shop which don't have a specific
305 // type
306 // The director node is the root node which has everything inside it.
307 #define MGR_OPTYPE_NAME "MGR"
308 #define DIR_OPTYPE_NAME "DIR"
309 #define DATA_OPTYPE_NAME "DATA"
310 
311 /// Nice label names used by network view, corresponding to OP_OpTypeId
312 OP_API extern const char *OPtypeIdLabels[NUM_MANAGERS];
313 
314 // Stores the status of the node - undefined for currently
315 // uncached state,
317 {
321 };
322 
323 // These are some special defines used by VOPs. They need to be here
324 // because the OP_ConnectionMemory has to handle these operators in a
325 // special way,
326 #define VOP_OUTPUT_NODE_NAME "output"
327 #define VOP_SUBNET_OUTPUT_NODE_NAME "suboutput"
328 #define VOP_SUBNET_INPUT_NODE_NAME "subinput"
329 #define VOP_COLLECT_NODE_NAME "collect"
330 
331 // These defines provide a common place where the names of the management
332 // operator types are defined.
333 #define SHOP_MANAGEMENT_OPTYPE "shopnet"
334 #define COP2_MANAGEMENT_OPTYPE "cop2net"
335 #define ROP_MANAGEMENT_OPTYPE "ropnet"
336 #define CHOP_MANAGEMENT_OPTYPE "chopnet"
337 #define SOP_MANAGEMENT_OPTYPE "sopnet"
338 #define OBJ_MANAGEMENT_OPTYPE "objnet"
339 #define VOP_MANAGEMENT_OPTYPE "vopnet"
340 #define DOP_MANAGEMENT_OPTYPE "dopnet"
341 #define TOP_MANAGEMENT_OPTYPE "topnet"
342 #define LOP_MANAGEMENT_OPTYPE "lopnet"
343 
344 // This class has each of the above entities filled out.
345 // You can thus convert between different types by looking up
346 // with the known key and extracting what you want from this class.
347 // Looking up by id is fast, the rest requires a scan.
349 {
350 public:
355 };
356 
357 /// Options class for use with OP_Node::saveCommand()
359 {
360  // Initialize the options to match the opscript defaults
362  ( bool values_only_ = false
363  , bool defaultstoo_ = true
364  , bool docreate_ = true
365  , bool doparms_ = true
366  , bool doflags_ = true
367  , bool dowires_ = true
368  , bool dowiresout_ = true
369  , bool frames_ = false
370  , bool dogeneral_ = false
371  , bool dochblock_ = true
372  , bool dospareparms_ = true
373  , bool omit_version_info_ = false
374  )
375  : values_only(values_only_)
376  , defaultstoo(defaultstoo_)
377  , docreate(docreate_)
378  , doparms(doparms_)
379  , doflags(doflags_)
380  , dowires(dowires_)
381  , dowiresout(dowiresout_)
382  , frames(frames_)
383  , dogeneral(dogeneral_)
384  , dochblock(dochblock_)
385  , dospareparms(dospareparms_)
386  , omit_version_info(omit_version_info_)
387  {
388  }
389 
392  bool docreate;
393  bool doparms;
394  bool doflags;
395  bool dowires;
397  bool frames;
398  bool dogeneral;
399  bool dochblock;
402 };
403 
404 //___________________________________________________________________________
405 
406 
407 //
408 // a container class to describe the instantaneous state of a parameter
409 //
411 {
412 public:
416  int myIndex;
418 
419  int operator==(const opParmData &v) const
420  {
421  return (myValue == v.myValue &&
422  myLabel == v.myLabel &&
423  myNode == v.myNode &&
424  myIndex == v.myIndex &&
425  mySubIndex == v.mySubIndex
426  );
427  }
428 };
429 
430 
431 // Blank class definitions for all our node types...
432 class OBJ_Node;
433 class SOP_Node;
434 class CHOPNET_Node;
435 class CHOP_Node;
436 class COP2_Node;
437 class COP2NET_Node;
438 class ROP_Node;
439 class TOP_Node;
440 class TOPNET_Node;
441 class LOP_Node;
442 class SHOP_Node;
443 class VOP_Node;
444 class VOPNET_Node;
445 class DOP_Node;
446 
447 #define INSTANTIATE_FINDNODE_FUNCTIONS(PREFIX) \
448  PREFIX##_Node *find##PREFIX##Node(const char *path) const \
449  { \
450  OP_Node *node; \
451  \
452  node = findNode(path); \
453  if (node) return node->castTo##PREFIX##Node(); \
454  return 0; \
455  }
456 #define INSTANTIATE_CASTNODE_FUNCTIONS(PREFIX) \
457  PREFIX##_Node *castTo##PREFIX##Node() const \
458  { \
459  /* If this is triggered, use CAST_FOONODE instead */ \
460  /* This is because foo->bar() should not be done with */ \
461  /* NULL foo for aesthetic reasons. */ \
462  { const void *this_local = this; \
463  UT_ASSERT(this_local); \
464  if (!this_local) return 0; } \
465  if (getOpTypeID() == PREFIX##_OPTYPE_ID) \
466  { \
467  return (PREFIX##_Node *) this; \
468  } \
469  return 0; \
470  }
471 
472 /// This macro allows us to run another macro for all node types
473 #define INSTANTIATE_FOR_ALL_NODE_TYPES(MACRO_FUNC) \
474  MACRO_FUNC(OBJ) \
475  MACRO_FUNC(SOP) \
476  MACRO_FUNC(CHOPNET) \
477  MACRO_FUNC(CHOP) \
478  MACRO_FUNC(ROP) \
479  MACRO_FUNC(SHOP) \
480  MACRO_FUNC(COP2) \
481  MACRO_FUNC(COP2NET) \
482  MACRO_FUNC(VOP) \
483  MACRO_FUNC(VOPNET) \
484  MACRO_FUNC(DOP) \
485  MACRO_FUNC(TOP) \
486  MACRO_FUNC(TOPNET) \
487  MACRO_FUNC(LOP)
488 
495 
497 {
498 public:
499  // Methods to convert our enums and strings:
500  static const OP_TypeInfo *getOpInfoFromOpTypeID(OP_OpTypeId opid);
501  static const OP_TypeInfo *getOpInfoFromOpTypeName(const char *name);
502  static const OP_TypeInfo *getOpInfoFromTableName(const char *name);
503  static const OP_TypeInfo *getOpInfoFromScriptDir(const char *dir);
504 
506  { return myParent; }
508  { return myRootCompiledParent; }
509 
510  //Return the network this item resides in (i.e. getParent()). This method
511  //was introduced to provide a standardized way of accessing the parent
512  //network of all different network box item types.
513  OP_Network *getParentNetwork() const override;
514 
515  // This function looks up our parent tree to determine if the given node
516  // is our parent, grandparent, great-grandparent...
517  bool getIsContainedBy(const OP_Node *testparent) const;
518 
519  /// Return the name of this node's parent
520  const UT_String &getNetName() const;
521 
522  /// This returns the OP_OpTypeId which corresponds to this node type.
523  /// Management nodes will return the type they really are, which
524  /// is likely different than the network they currently reside in.
525  virtual OP_OpTypeId getOpTypeID() const
526  { return INVALID_OPTYPE_ID; }
527 
528  // This is the proper way to determine the optype.
529  // Do not assume your parents child type is your type! This will only
530  // become less true as time goes on :>
531  // The strings returned are the *_OPTYPE_NAME defined above
532  virtual const char *getOpType() const;
533 
534  OP_ItemType getItemType() const override;
535 
536  /// @anchor OP_Node_findFOONode
537  ///
538  /// FOO_Node *findFOONode(const char *path) const; @n
539  /// This function searches for the node at path relative
540  /// to this node. If not found, or if the found node is
541  /// not of type FOO_Node, it returns NULL. The result
542  /// is already cast to FOO_Node.
543  /// findOBJNode(const char *path)
544  /// findSOPNode(const char *path)
545  /// findCHOPNETNode(const char *path)
546  /// findCHOPNode(const char *path)
547  /// findROPNode(const char *path)
548  /// findSHOPNode(const char *path)
549  /// findCOP2Node(const char *path)
550  /// findCOP2NETNode(const char *path)
551  /// findVOPNode(const char *path)
552  /// findVOPNETNode(const char *path)
553  /// findDOPNode(const char *path)
554  /// findTOPNode(const char *path)
555  /// findTOPNETNode(const char *path)
556  /// findLOPNode(const char *path)
557  // @{
559  // @}
560 
561  /// @anchor OP_Node_castToFOONode
562  ///
563  /// FOO_Node *castToFOONode() const; @n
564  /// This type checks the current node against FOO_Node.
565  /// If the cast is legal, this is returned. Otherwise, NULL.
566  /// While it likely will do the "right" thing with this == NULL,
567  /// that case is UT_ASSERTed as it is just asking for trouble.
568  /// castToOBJNode()
569  /// castToSOPNode()
570  /// castToCHOPNETNode()
571  /// castToCHOPNode()
572  /// castToROPNode()
573  /// castToSHOPNode()
574  /// castToCOP2Node()
575  /// castToCOP2NETNode()
576  /// castToVOPNode()
577  /// castToVOPNETNode()
578  /// castToDOPNode()
579  /// castToTOPNode()
580  /// castToTOPNETNode()
581  /// castToLOPNode()
582  // @{
584  // @}
586  /// Obtain the node's script which is called when it is being deleted.
587  const UT_String &getDelScript() const { return myDelScript; }
588 
589  /// Set the node's deletion script. Returns true if the delete script was
590  /// set successfully.
591  bool setDelScript(const char *str);
592 
593  /// Accessors for this node's comment string.
594  // @{
595  const UT_String &getComment() const { return myComment; }
596  bool setComment(const char *str);
597  // @}
598 
599  /// Overrides the NetworkBoxItem implementations of getColor and setColor
600  /// to provide support Node-specific features like using the default color.
601  // @{
602  UT_Color getColor() const override;
603  bool setColor(const UT_Color &col) override;
604  // @}
605 
606  /// Accessors for this node's flag indicating if it should use its
607  /// operator's default color instead of its local color.
608  // @{
609  bool getColorDefault() const;
610  bool setColorDefault(bool usedefault);
611 
612  /// Accessors for this node's shape
613  // @{
614  const UT_StringHolder &getNodeShape() const;
615  void setNodeShape(const UT_StringHolder &shape);
616  // @}
617 
618  /// Node position/scale is used by the UI.
619  // @{
620  // These are in absolute coordinates, not the UI coordinates found in
621  // OPUI_Worksheet, though.
622  void setXY(fpreal x, fpreal y) override;
623  fpreal getX() const override { return myPosX; }
624  fpreal getY() const override { return myPosY; }
625  fpreal getW() const override;
626  fpreal getH() const override;
627  // @}
628 
629  void pickRequest(int shift);
630 
631  /// Set allow_rel_paths to true to accept "." or ".." as valid paths.
632  static bool isValidOpName(const UT_StringView &s,
633  bool allow_rel_paths = false,
634  bool ignore_node_names_env_var = false);
635  static bool isValidOpName(const char *s,
636  bool allow_rel_paths = false,
637  bool ignore_node_names_env_var = false)
638  {
639  return isValidOpName(UT_StringView(s),
640  allow_rel_paths,
641  ignore_node_names_env_var);
642  }
643  static bool isValidOpName(const UT_String &str,
644  bool allow_rel_paths = false,
645  bool ignore_node_names_env_var = false)
646  {
647  return isValidOpName(str.c_str(),
648  allow_rel_paths,
649  ignore_node_names_env_var);
650  }
651  static bool isValidOpPath(const UT_StringRef &s);
652  static bool forceValidOpName(UT_String &name);
653 
654  /// Override these methods so that search-and-replace operations
655  /// affect our delete script as well as our parameters.
656  // @{
657  int findString(const char *str, bool fullword,
658  bool usewildcards) const override;
659  int changeString(const char *from, const char *to,
660  bool fullword) override;
661  // @}
662 
663  /// Mark this node, its descendants, and all data dependents containing
664  /// varname as being dirty. If changed_nodes is non-NULL, then it is
665  /// updated with the list of dirtied nodes which contains varname.
666  /// Returns true iff at least one node was dirtied.
667  bool notifyVarChange(
668  const char *varname,
669  OP_NodeList *changed_nodes = nullptr);
670 
671  // These are no-ops for nodes but will be implemented for networks:
672  virtual int getNchildren() const;
673  virtual OP_Node *getChild(const char *name, int *hint=0) const;
674  virtual OP_Node *getChild(int index) const;
675  void getPickedChildren(OP_NodeList &picked,
676  bool include_hidden=false) const;
677  void getAllChildren(OP_NodeList &children) const;
678  virtual OP_Node *matchChild(const char *pattern, OP_Node *prevmatch=0,
679  const char *optype=0,
680  int casesensitive = 0) const;
681  virtual OP_Node *matchChildBackwards(const char *pattern,
682  OP_Node *prevmatch=0,
683  const char *optype=0,
684  int casesensitive = 0) const;
685  virtual OP_Network *createProxyRefNode( const char *path );
686 
687  // Returns the maximum error severity of ourself and all of our
688  // children. For efficiency, early-exits at ABORT (so embedded
689  // FATAL might be shadowed by an ABORT) but in practice FATAL is
690  // unused.
691  OP_ERROR getChildErrorSeverity();
692 
693  // Returns the list of nodes eligible to be considered for child
694  // errors.
695  virtual void getPotentialChildErrorNodes(OP_NodeList &nodes) const;
697  // Returns the node with the requested unique integer identifier.
698  static OP_Node *lookupNode(int unique_id, bool include_proxy=false)
699  {
700  if( unique_id >= 0 && unique_id <= theUniqueId
701  && theUniqueNodes[unique_id] )
702  {
703  if( include_proxy || !theUniqueNodes[unique_id]
704  ->isProxyRefNode() )
705  return theUniqueNodes[unique_id];
706  }
707  return 0;
708  }
709  static int getNumUniqueIds()
710  { return theUniqueId + 1; }
711  // Fills the provided array with every node that currently exists.
712  static void getAllNodes(OP_NodeList &nodes);
713 
714  int getUniqueId() const
715  { return myUniqueId; }
716  int64 getItemUniqueId() const override
717  { return myUniqueId; }
718 
719  // The following function will take a standard pattern and expand
720  // all the groups out of the pattern, leaving a simple pattern
721  // in the result.
722  bool expandGroupPattern(const char *pattern,
723  UT_String &result,
724  bool expandToFullPaths = false);
725 
726  // The following methods take a standard pattern and return whether
727  // the pattern contains the specified bundle or group.
728  bool patternContainsBundle(const char *pattern,
729  const OP_Bundle *bundle) const;
730  bool patternContainsGroup(const char *pattern,
731  const OP_Group *group) const;
732 
733  virtual int isManager() const;
734  // This differs from isManager. Managers are the old school static
735  // things which are always present in fixed directories. Management
736  // nodes are managers that are in the wrong directory.
737  virtual int isManagementNode() const;
738  // This is a bit broader than management nodes. These nodes may
739  // be in the right directory, but represent an unexpected change
740  // of directory type, so need to be tracked so our tree filter
741  // will know about them.
742  bool isEffectivelyAManagementNode() const;
743 
744  // Returns ture if this node contains material nodes.
745  virtual bool isMaterialManager() const;
746 
747  // This function checks if the node is a subnet. Now that we can have
748  // NWN subnets (object subnets, vopnet subnets), we need to explicitly
749  // specify if these types of subnets count. In some cases we want them
750  // to count (such as checking for VOPNET subnets to see if we can
751  // generate code, or SHOP subnets to see if we can save to a palette).
752  // In other cases we want to exclude these management ops (such as
753  // when deciding to show the "Create Type From" menu item or checking
754  // if we can do an opwire -i command).
755  virtual int isSubNetwork(bool includemanagementops) const;
756  virtual int isNetwork() const;
757  virtual int isInSubNetwork() const;
758 
759  bool isProxyRefNode() const
760  { return myIsProxyRefNode; }
761  void setProxyRefNode(bool f)
762  { myIsProxyRefNode = f; }
763 
764  // Used by SOPs to determine which node is the output of a subnetwork.
765  virtual bool isOutputNode() const;
766  // Returns which output this node represents.
767  virtual int whichOutputNode() const;
768 
769  // isNetworkWithKids() will return 1 if the node is a network and the
770  // operator table for the node contains children which can be added to the
771  // node.
772  int isNetworkWithKids() const;
773 
774  virtual int isVex() const;
775 
776  // methods for managing the bundles we depend on in so that any change to
777  // the bundle in which we are interested triggers bundleChange call.
778  // NB: getParmBundle methods find or create a bundle ad it to the
779  // internal list of referenced bundles
780  OP_Bundle * getParmBundle(const char* parm_name, int vector_index,
781  UT_String &pattern, OP_Network *creator,
782  const char *filter);
783  void markBundleRefsAsUnused();
784  void cleanUnusedBundleRefs();
785  void cleanAllBundleRefs();
786 
787  static void getValueAsBundlePaths(fpreal t,
788  UT_WorkBuffer &resultbuf,
789  PRM_Parm *parm, int index,
790  OP_Node *srcnode
791  );
792  static void getValueAsBundlePaths(fpreal t,
793  OP_NodeList &resultnodes,
794  PRM_Parm *parm, int index,
795  OP_Node *srcnode
796  );
797 
798  // The bundleChanged() method is called whenever a bundle referenced by the
799  // OP is changed. The bundle is passed to the OP to let the OP know that
800  // it's out of date. The function should return 1 if the event was handled
801  // properly or 0 if it failed. The return codes are used for debugging
802  // only.
803  virtual bool bundleChanged(const OP_Bundle *bundle);
804  // If a bundle changes, you should call this method to touch the parameter
805  // which the bundle affects. The name is the token of the parm.
806  void touchBundleParm(const char *name);
807  void touchBundleParm(int parm_index);
809  // Function to determine if Display and Render node ptrs are the same
810  virtual int getDandROpsEqual() { return 1; }
811  // Function to update info about whether Render and Display node ptrs
812  // are the same. Recurses tree and updates all kids values.
813  virtual int updateDandROpsEqual(int = 1) { return 1; }
814 
815  /// Check to see whether @c node is an ancestor of @c this node in the
816  /// input hierarchy. Optionally check extra inputs. This method will
817  /// recurse using @c getInputs() (and optional getExtraInputNodes()
818  /// @note This node is considered to be an ancestor of itself
819  bool isInputAncestor(const OP_Node *parent,
820  bool check_extra=true) const;
821  /// Check to see whether the @c parent node is an ancestor of @c this node
822  /// in the parent/child hierarchy. That is, this method will call
823  /// getParent()/getChild() to traverse the hierarchy.
824  /// @note This node is considered to be an ancestor of itself
825  bool isParentAncestor(const OP_Node *parent) const;
826 
827  /// Get the info text for this op. This non-virtual function does
828  /// all the stuff common to all operator types.
829  /// @warning The return value is the value of the work buffer in the
830  /// OP_NodeInfoParms. Thus, you should never do @code
831  /// str = node->getInfoText(context, OP_NodeInfoParms());
832  /// @endcode
833  /// Since the lifetime of the temporary may not be long enough to extract
834  /// the string properly.
835  const char *getInfoText(OP_Context &context,
836  OP_NodeInfoParms &parms);
837  // Get Info Text that is specific to this node type.
838  virtual void getNodeSpecificInfoText(OP_Context &context,
840 
842  {
843  OTLSYNC_DELAY = 0,
844  OTLSYNC_DOSYNC = 1,
845  };
846 
847  /// Uses the path (eg. "/obj/geo1") to find a node in our hierarchy
848  OP_Node *findNode(const char *path, OTLSyncMode syncmode = OTLSYNC_DOSYNC) const;
849 
850  /// Same as findNode() except it will return NULL if the path is to a node
851  /// that is either not a descendant of this node, or if it isn't the same
852  /// type as our children.
853  OP_Node *findSubNode(const char *path) const;
854 
855  // These are all Implemented in OP_Network, but put here as a virtual to
856  // make working / with hscript easier so that it can be called directly on
857  // an op node
858  virtual OP_NetworkBox *findNetworkBox(const char *name)
859  { return nullptr; }
860  virtual OP_PostIt *findPostItNote(const char *const_path)
861  { return nullptr; }
862  virtual OP_Dot *findDot(const char *const_path)
863  { return nullptr; }
864  virtual OP_SubnetIndirectInput *findParentInput(const char *const_path)
865  { return nullptr; }
866  virtual OP_NetworkBoxItem *findItem(const char *const_path,
867  OP_ItemTypeMask item_type =
869  { return nullptr; }
870 
871  // These functions will adhere to certain conventions, such as a reference
872  // to an object actually means a reference to the display or render
873  // guy in that object. This will also check this->isCookingRender
874  // to determine if it should auto-use the Render or Display.
875  // These will not fail if the returned node is the node itself.
876  SOP_Node *getSOPNode(const char *path, int addextra = 0,
877  bool *got_by_flag=nullptr) const;
878  // This method will use the render node of the composite network if
879  // it is a comp rather than a cop2 that is pointed to...
880  COP2_Node *getCOP2Node(const char *path, int addextra = 0) const;
881 
882  // And this one will use the display node, which corresponds to the
883  // cook node in DOPs land.
884  DOP_Node *getDOPNode(const char *path, int addextra = 0) const;
885  ROP_Node *getROPNode(const char *path, int addextra = 0) const;
886  // This method will use the audio node of the chop network
887  CHOP_Node *getCHOPNode(const char *path, int addextra = 0,
888  bool *got_by_flag=nullptr) const;
889  // This method will use the display node of the top network
890  TOP_Node *getTOPNode(const char *path, int addextra = 0) const;
891  // This method will use the display node of the lop network
892  LOP_Node *getLOPNode(const char *path, int addextra = 0) const;
893  OBJ_Node *getOBJNode(const char *path, int addextra = 0) const;
894 
895  OP_Node *castToOPNode() override { return this; }
896  const OP_Node *castToOPNode() const override { return this; }
897 
898  /// Returns the path of this node relative to its getCreator()
899  virtual void getPathWithSubnet(UT_String &str) const;
900  void getPathWithSubnet(UT_StringHolder &str) const
901  { UT_String tmp; getPathWithSubnet(tmp); str.adoptFromString(tmp); }
902 
903  /// This will try to complete the path by finding the longest suffix
904  /// that will work with the given prefix. It will only complete up
905  /// to the next child. If it finds a valid child, it will append
906  /// a slash (/).
907  void completePath(const char *prefixpath,
908  UT_String &completepath) const;
909 
910  virtual CH_Channel *getTrackChannel(const char *name);
911 
912  virtual bool findParmFromTrack(const OP_FollowChanRefsOptions& opt,
913  const char *trackname,
914  OP_NodeParmRefCycle &cycle,
915  OP_Node *&node,
916  PRM_Parm *&parm, int &vecidx);
917 
918  // Batch evaluation of named parameters. This method requires extra lookup
919  // since parameters are specified by names, but it can handle generic
920  // parameter layout.
921  virtual void evaluateBatchParms(PRM_BatchList &list, fpreal now);
922 
923  // Do global expansion on a pattern - get lists of channels or nodes
924  // If expand is given, concatenated with full list of names
925  // If list is given, appended with list of nodes.
926  // If dependent given, addExtraInputs.
927  void globNodes(const char *pat, UT_String *expand,
928  UT_Array<OP_Node *> *list=0,
929  OP_GlobContext *context = 0,
930  const char *prefix = " ");
931 
932  CH_Channel *findChannel(const char *path);
933  void globChannels(const char *, UT_String &expand,
934  OP_GlobContext *context = 0,
935  const char *prefix = " ") const;
936 
937  void globChannels(const char *pattern,
938  CH_ChannelList &clist,
939  OP_GlobContext *context = 0,
940  OP_Node *dependent = 0);
941  // If use_multi_match is false, the pattern is
942  // treated as a single pattern instead of a space
943  // separated list of patterns. (Only applies
944  // to direct parameter names, i.e. the pattern must not be
945  // a path and must not contain a slash)
946  void globChanRefs(const char *pattern,
947  CH_ChannelRefList &list,
948  OP_GlobContext *context = 0,
949  OP_Node *dependent = 0,
950  bool use_multi_match = true);
951 
952  int globParms(const char *pattern, fpreal t,
953  UT_Array<opParmData> &list,
954  OP_GlobContext *context = 0,
955  OP_Node *dependent = 0,
956  int calc_value = 1);
957 
958  // this version only globs the current node
959  void globNodeParms(const char *pattern, fpreal t,
960  UT_Array<opParmData> &list,
961  OP_GlobContext *context,
962  OP_Node *dependent,
963  int calc_value,
964  bool animated_only);
965 
966  // this version only globs the current node
967  void globNodeChannels(const char *pattern,
968  CH_ChannelList &list,
969  OP_GlobContext *context,
970  int *parm_start = nullptr,
971  UT_IntArray *parm_indices = nullptr,
972  UT_IntArray *parm_sub_indices = nullptr
973  ) const;
974 
975  // this version only globs the current node
976  // If use_multi_match is false, the pattern is
977  // treated as a single pattern instead of a space
978  // separated list of patterns
979  void globNodeChanRefs(const char *pattern,
980  CH_ChannelRefList &list,
981  OP_GlobContext *context,
982  int *parm_start = nullptr,
983  UT_IntArray *parm_indices = nullptr,
984  UT_IntArray *parm_sub_indices=nullptr,
985  bool use_multi_match = true
986  ) const;
987 
988  ///Same as 'globNodes', except for network boxes. This is to be implemented
989  ///by OP_Network, but has been put here so it can be called directly on
990  ///OP_Node like all the other "glob" methods without a cast
991  virtual void globNetworkBoxes(const char *pat, UT_String *expand,
993  OP_GlobContext *glob_context = 0,
994  const char *prefix = " ");
995 
996  virtual void globPostIts(const char *pat, UT_String *expand,
997  UT_ValArray<OP_PostIt *> *list=0,
998  OP_GlobContext *glob_context = 0,
999  const char *prefix = " ");
1000 
1001  // Fetch all channels from this node on down.
1002  int getAllChannels(CH_ChannelList &list, int scoped=0);
1003 
1004  // If you override opChanged() in a sub-class, you must call
1005  // the OP_Node base method from the sub-class method
1006  void opChanged(OP_EventType reason, void *data=0) override;
1007 
1008  // If you override opChanged() in a subclass, you should first call
1009  // opShouldHandleChange() before taking any custom action.
1010  virtual bool opShouldHandleChange(OP_EventType reason);
1011 
1012  // This function is called whenever we have a parameter that references
1013  // another parameter, and that referenced parameter changes. The pi
1014  // value is the index of the parameter containing the reference.
1015  virtual void referencedParmChanged(int pi);
1016 
1017  /// Mark this node as needing a full recook.
1018  /// If 'evensmartcache' is true, a recook will occur even if all the
1019  /// parameters match in this node and all its inputs (only valid for
1020  /// COP2_Node).
1021  virtual void forceRecook(bool evensmartcache = true);
1022 
1023  /// This method causes any operators that load files to recook.
1024  /// By default, this searches for 'file' operators by iterating through
1025  /// inputs. Parms of type PRM_FILE are also marked dirty. Other nodes that
1026  /// load files differently may wish to override this method.
1027  virtual void reloadExternalFiles();
1028 
1029  /// Determines if this node needs to cook.
1030  ///
1031  /// The queryonly flag will not flag this as a read attempt to the
1032  /// caching mechanisms, and thus not update the touch time.
1033  virtual unsigned needToCook(OP_Context &context, bool queryonly=false);
1034 
1035  /// Cook this node's data. Returns true upon success, false otherwise.
1036  ///
1037  /// Upon failure, use OP_Parameters::error() and
1038  /// OP_Parameters::getErrorMessages() to determine reason.
1039  virtual bool cook(OP_Context &context);
1040 
1041  /// Schedule a task for cooking this node in parallel and wait for it to
1042  /// finish. Returns true upon success, false otherwise.
1043  bool parallelCook(OP_Context &context);
1044 
1045  /// Cook the given node list in parallel
1046  static bool parallelCook(OP_Context &context,
1047  const OP_NodeList &nodes);
1048 
1049  /// The cook lock is used to protect per node data structures during
1050  /// cooking. Subclasses should use this when calling cook(). Example:
1051  /// @code
1052  /// cookLockedExecute([&]() {
1053  /// // run code
1054  /// });
1055  /// @endcode
1056  /// @note Include OP_NodeCookLockedExecute.h to call this.
1057  template <typename F>
1058  void cookLockedExecute(const F &functor);
1059 
1060  /// The cook lock is used to protect per node data structures during
1061  /// cooking. Subclasses should use lock this to protect private data.
1062  OP_CookLock & getCookLock() { return myCookLock; }
1064  UT_TaskState & taskState() { return myTaskState; }
1065  const UT_TaskState & taskState() const { return myTaskState; }
1066 
1067  // This normally chains to cookInputGroups.
1068  // Some networks, such as SOPs, use it to be able to
1069  // properly lock their gdp pointer around the cook.
1070  virtual OP_ERROR pubCookInputGroups(OP_Context &context, int alone = 0);
1071 
1072  void bumpVersionParm()
1073  {
1074  dataMicroNode().bumpModVersion();
1075  if (hasIndepParmListMicroNode())
1076  parmListMicroNode().bumpModVersion();
1077  }
1078  int cookParmsModified() const
1079  { return parmListMicroNodeConst()
1080  .isModVersionOutdated(); }
1081 
1082  // The data class of an OP is currently used solely for networks which
1083  // contain heterogeneous node types (i.e. used in SHOP networks to
1084  // distinguish different shader types). A data class of 0 is returned by
1085  // default.
1086  // A value of 0 is returned by default.
1087  virtual int getDataClass() const;
1088 
1089  // The xform order for how to interpret the given channel. Default
1090  // is XYZ.
1091  virtual void getXformOrder(UT_XformOrder &xord,
1092  const CH_Channel *chp) const;
1093 
1094  // "getCookedData" should return a void * version of the results of
1095  // the cook. NULL if it fails with appropriate stuff in our error manager.
1096  virtual OP_DataType getCookedDataType() const = 0;
1097  virtual void *getCookedData(OP_Context &);
1098  virtual void deleteCookedData() = 0;
1099 
1100  virtual int saveCookedData(std::ostream &os, OP_Context &,
1101  int binary = 0) = 0;
1102  virtual bool loadCookedData(UT_IStream &is, const char *path=0);
1103  virtual int saveCookedData(const char *filename, OP_Context &) = 0;
1104 
1105  /// Get the transform from this node's space to the 'to' node's space.
1106  /// Returns 1 if this was possible, 0 otherwise (e.g. failure to cook).
1107  virtual int getRelativeTransform(OP_Node &to, UT_Matrix4 &xform,
1108  OP_Context &context);
1109  virtual int getRelativeTransform(OP_Node &to, UT_DMatrix4 &xform,
1110  OP_Context &context);
1111  // overrides for OPs that can capture (right now only OBJ_Bone)
1112  virtual int getRelativeCaptureTransform(OP_Node &to,
1113  UT_Matrix4 &xform,
1114  OP_Context &context);
1115  virtual int getRelativeCaptureTransform(OP_Node &to,
1116  UT_DMatrix4 &xform,
1117  OP_Context &context);
1118 
1120  {
1121  TRANSFORM_WORLD,
1122  TRANSFORM_IWORLD,
1123  TRANSFORM_PRE,
1124  TRANSFORM_PARENT,
1125  TRANSFORM_PARM,
1126  TRANSFORM_PRECONSTRAINT,
1127  TRANSFORM_PARENTBONE,
1128  TRANSFORM_RAWPARM,
1129  TRANSFORM_PREPARM,
1130  TRANSFORM_PRERAWPARM,
1131  };
1132 
1133  // these next 3 are the minimal overrides for subclasses that have
1134  // transforms (see OBJ_Node)
1135  virtual bool getWorldTransform(UT_Matrix4D &xform, OP_Context &);
1136  virtual bool getIWorldTransform(UT_Matrix4D &xform, OP_Context &);
1137  virtual bool getTransform( TransformMode mode, UT_Matrix4D &xform, OP_Context &);
1139  // single precision versions of the above
1140  bool getWorldTransform(UT_Matrix4F &xform, OP_Context &ctx)
1141  {
1142  UT_Matrix4D m;
1143  bool ok = getWorldTransform(m, ctx);
1144  xform = m;
1145  return ok;
1146  }
1147  bool getIWorldTransform(UT_Matrix4F &xform, OP_Context &ctx)
1148  {
1149  UT_Matrix4D m;
1150  bool ok = getIWorldTransform(m, ctx);
1151  xform = m;
1152  return ok;
1153  }
1154  bool getTransform( TransformMode mode, UT_Matrix4F &xform, OP_Context &ctx)
1155  {
1156  UT_Matrix4D m;
1157  bool ok = getTransform(mode, m, ctx);
1158  xform = m;
1159  return ok;
1160  }
1161 
1162  /// Registers an error for cooking the given node's transform. If label is
1163  /// supplied, then it will be used as a label of the transform error.
1164  void addTransformError(const OP_Node &node,
1165  const char *label=0) const;
1166 
1167  // Compute the bounding box for the operator (if applicable). If the box
1168  // could be computed, return true, else return false.
1169  virtual bool getBoundingBox(UT_BoundingBox &box, OP_Context &);
1170 
1171  // This is used by VOPNETs to determine which table needs to be
1172  // refreshed when they change.
1173  virtual const char *getInternalOpTable() const
1174  { return INVALID_TABLE_NAME; }
1175  virtual OP_Operator *getInternalOperator() const
1176  { return 0; }
1177 
1178  virtual const char *inputLabel(unsigned idx) const;
1179  virtual const char *outputLabel(unsigned idx) const;
1180 
1181  // Here's a useful method which will return the string "Source %d", where
1182  // %d is the idx passed. Lets us check if the input label is using the
1183  // default or not.
1184  const char *inputLabelNum(unsigned idx) const;
1185  const char *outputLabelNum(unsigned idx) const;
1186 
1187  // returns a label that is applied to the drawn connector. NULL may be
1188  // returned as 'no label'.
1189  virtual const char *inputConnectorLabel(unsigned idx);
1190 
1191  // if true, the connector to the input will be dashed rather than solid.
1192  virtual int isRefInput(unsigned idx) const;
1193 
1194  // returns the index of the auxilary input, if any (currently only used
1195  // for the mask inputs in COPs).
1196  virtual int getAuxInput() const;
1197  virtual void getAuxInputName(OP_ConnectorId& name_out);
1198 
1199  // The lock method is used to lock the OP.
1200  // Returns the previous state of the lock flag.
1201  //
1202  // Note that to mimic the behaviour of the lock button, you MUST
1203  // call setModelLock, not setLockState()/setHardLock()/setSoftLock(), or
1204  // your next unlock won't have a cached data.
1206  OP_LockTypes setLockState(OP_LockTypes state, bool saveundo = true);
1207  OP_LockTypes getLockState() const { return flags().getLockState(); }
1209  // Returns true if either hard or soft locked
1210  bool getLock() const { return flags().isLocked(); }
1212  bool getSoftLock() const {return flags().getSoftLocked();}
1213  void setSoftLock(bool on_off)
1214  {
1215  setLockState(on_off ? OP_NodeFlags::OP_SOFT_LOCKED
1217  }
1219  bool getHardLock() const {return flags().getHardLocked();}
1220  void setHardLock(bool on_off)
1221  {
1222  setLockState(on_off ? OP_NodeFlags::OP_HARD_LOCKED
1224  }
1225 
1226  // The Model lock is similar to the normal lock but will also cause
1227  // the node data to be saved.
1228  virtual OP_LockTypes setModelLock(OP_LockTypes state,
1229  void *modeler = nullptr,
1230  bool allow_softlock_promotion = false,
1231  UT_Undo *undo = nullptr);
1232 
1233  // getNetworkLock() checks to see if the OP is effectively locked by
1234  // the network, i.e., each of the OPs output branches connect to a locked
1235  // OP down the network. Returns > 0 if locked, <= 0 if unlocked.
1236  // When relaxedlockcheck is set, subnet branches that are not displayed
1237  // are ignored.
1238  int getNetworkLock(bool relaxedlockcheck = false,
1239  const OP_Node *inputNode=nullptr) const;
1240 
1241  // The unload flag triggers whether we keep the ops data around
1242  // after a cook or discard it as soon as its not needed. Its currently
1243  // only implemented in CHOPs.
1244  bool setUnload(bool on_off);
1245  bool getUnload() const;
1247  // Returns whether this node has data loaded into it.
1248  virtual bool isLoaded() const { return true; }
1249 
1250  // This will explicitly delete all data associated with the OP
1251  // false is returned if no data was deleted (ie, OP is in use, etc)
1252  // Only works with SOPs now.
1253  virtual bool unloadData();
1254 
1255  // Take control for flags
1256  void takeActivateFlag(uchar flag, bool enable=true,
1257  bool send_flag_event=true);
1258  void takeDeactivateFlag(uchar flag)
1259  { takeActivateFlag(flag, false); }
1260  bool takeIsActiveFlag(uchar flag) const;
1261  void setHasTakeData(bool onoff);
1262 
1263  bool canAccessFlag(unsigned mask, uchar flag) const;
1264 
1265  // The template flag indicates that the node date should be displayed
1266  // The display & render flags indicate that the node is turned on
1267  // for display purposes or for rendering purposes, which may take
1268  // on different meanings per node type.
1269  // Setting save data only has meaning for some node types.
1270  bool setPicked(bool on_off,
1271  bool propagate_parent_event = true) override;
1272 
1273  /// The edit flag is used whenever something is picked
1274  /// from the viewport. This causes the pane paths to
1275  /// be changed to the first writable parent of the
1276  /// node being picked.
1277  bool setEditPicked(bool on_off,
1278  bool propagate_parent_event = true);
1279 
1280  // The Autoscope flag on OP_Node is used to temporary turn-off the Auto-Add to Channel List
1281  // behavior when selecting nodes.
1282  // This is used when setting selected nodes from selected channels in the channel list
1283  void setAutoscope(bool on_off) { myAutoscope = on_off; }
1284  bool isAutoscope() { return myAutoscope; }
1285 
1286  bool setCurrent(bool on_off);
1287  bool setExpose(bool on_off);
1288  bool setBypass(bool on_off);
1289  bool setTemplate(bool on_off);
1290  bool setFootprint(bool on_off);
1291  bool setXray(bool on_off);
1292  bool setDisplay(bool on_off);
1293  bool setRender(bool on_off);
1294  bool setHighlight(bool on_off);
1295  bool setModified(bool on_off);
1296  bool setSaveBypass(bool on_off);
1297  bool setSaveData(bool on_off);
1298  // these are for subclasses to implement, they do nothing by default
1299  virtual bool setPickable(bool on_off)
1300  { return false; }
1301  virtual bool setAudio(bool on_off)
1302  { return false; }
1303  virtual bool setExport(bool on_off)
1304  { return false; }
1305  virtual bool setDebug(bool on_off)
1306  { return false; }
1307  virtual bool setDisplayOrigin(bool on_off_unchanged)
1308  { return false; }
1309 
1310  /// The user has set the template flag. If we are turning on the template
1311  /// flag, we do the same as setTemplate(). If we are turning it *off*,
1312  /// we also turn off the selectable template (footprint) flag.
1313  void userSetTemplate(bool onoff);
1314 
1315  /// The user has set the selectable template flag. If we are making a node
1316  /// into a selectable template, we turn on the template flag as well.
1317  /// If we are turning off selectable template, we leave template alone.
1318  void userSetSelectableTemplate(bool onoff);
1319 
1320  // Here are the generalised versions, they add a bit of overhead to
1321  // the code because of the big switch statement.
1322  virtual void setFlag(char tag, int8 val);
1323  virtual int8 getFlag(char tag) const;
1324 
1325  bool getPicked() const override
1326  { return flags().getPicked(); }
1327  virtual bool getEditPicked() const
1328  { return flags().getEditPicked(); }
1329  bool getCurrent() const;
1330  bool getDisplay() const {return flags().getDisplay(); }
1331  bool getRender() const {return flags().getRender(); }
1332  bool getHighlight() const {return flags().getHighlight();}
1333  bool getBypass() const {return flags().getBypass(); }
1334  bool getTemplate() const {return flags().getTemplate(); }
1335  bool getFootprint() const {return flags().getFootprint(); }
1336  bool getXray() const {return flags().getXray(); }
1337  bool getExpose() const {return flags().getExpose(); }
1338  bool getModified() const {return flags().getModified(); }
1339  bool getSaveBypass() const{return flags().getSaveBypass(); }
1340  bool getSaveData() const {return flags().getSaveData(); }
1341  bool getHasTakeData() const override
1342  { return flags().getHasTakeData(); }
1343  virtual bool getPickable()
1344  { return false; }
1345  virtual bool getAudio() const
1346  { return false; }
1347  virtual bool getExport() const
1348  { return false; }
1349  virtual bool getDebug() const
1350  { return false; }
1351  virtual bool getDisplayOrigin() const
1352  { return false; }
1353  bool getItemExpose() const override
1354  { return getExpose(); }
1355  void setItemExpose(bool expose) override
1356  { setExpose(expose); }
1357  virtual bool getUseBypassLook(const OP_EditorContext &ctx) const;
1358 
1359  bool getDisplayDescriptiveName() const
1360  {return flags().getDisplayDescriptiveName();}
1361  bool setDisplayDescriptiveName(bool state);
1362  bool getDisplayComment() const
1363  {return flags().getDisplayComment();}
1364  bool setDisplayComment(bool state);
1365  int8 getOutputForView() const
1366  { return flags().getOutputForView(); }
1367  int8 setOutputForView(int8 output);
1368 
1369  OP_Node *getPickableSelfOrParent();
1370 
1371  // The compress flag indicates that the OP connector should be displayed
1372  // in a compressed UI. In ICE this means don't display the mini raster
1373  // image.
1374  bool setCompress(bool on_off);
1375  bool getCompress() const;
1376 
1377  // This method sets this node as the current and picked node and correctly
1378  // adjusts the picked states of the other sibling nodes.
1379  void setCurrentAndPicked();
1380 
1381  // setVisible() simply calls setDisplay() at this level but subclasses
1382  // override this to perform smarter behaviour. Objects for example will
1383  // try to set the display flag on parent subnets and change visible object
1384  // parameters as necessary.
1385  // Returns true if it was successful, false if there were not sufficient
1386  // permissions.
1387  virtual bool setVisible(bool onoff);
1388  virtual bool getVisible() const;
1389 
1390  const OP_NodeFlags &flags() const
1391  { return myFlags; }
1392  OP_NodeFlags &flags()
1393  { return myFlags; }
1394 
1395  virtual void getSaveFlagsString(UT_String &cmd,
1396  const char *flags,
1397  bool save_to_hip) const;
1398  virtual void getPreParmSaveFlagsString( UT_String &cmd ) const;
1399  virtual void getPostParmSaveFlagsString( UT_String &cmd ) const;
1400 
1401  /// Returns true if given notifcation callback has been added via
1402  /// addOpInterest().
1403  int hasOpInterest(void *data, OP_EventMethod m) const
1404  { return myEventValue.hasOpInterest(data, m); }
1405 
1406  /// Add a notification callback for changes to the node. See the @c
1407  /// OP_EventType enum in OP_Value.h for the list of events and data sent.
1408  void addOpInterest(void *data, OP_EventMethod m)
1409  { myEventValue.addOpInterest(data, m); }
1411  /// Remove notification callback added via addOpInterest()
1412  void removeOpInterest(void *data, OP_EventMethod m)
1413  { myEventValue.removeOpInterest(data, m); }
1414 
1415  int isBeingDeleted() const
1416  { return myBeingDeleted; }
1417  void setNodeBeingDeleted(int beingdeleted);
1418 
1419  /// Sets the flag that prevents consolidation of variable inputs.
1420  /// Returns previous value of the flag;
1421  bool setInhibitInputConsolidation(bool value);
1422 
1423  /// Move the upper-left most node in 'ops' to x-coordinate 'x' and to have
1424  /// its TOP border at y-coordinate 'y', and move all other nodes in 'ops'
1425  /// by the same amount. All netboxes in 'netboxes' will also be moved that
1426  /// amount. If a netbox's top border is higher than any node's top border,
1427  /// everything will be moved down accordingly. Note that the repositioning
1428  /// calculation does not include the nodes contained in the network boxes
1429  /// in 'netboxes'.
1430  static void repositionOpsMaxY(OP_NetworkBoxItemList &items,
1431  fpreal x, fpreal y);
1432 
1433  /// Minimum inputs that must be connected to a node for it to cook.
1434  virtual unsigned minInputs() const;
1435 
1436  /// Maximum inputs that can be connected to a node.
1437  virtual unsigned maxInputs() const;
1438 
1439  /// Number of input connectors that should be visible on a node. This is
1440  /// only used by VOPs and DOPs. All other OPs return maxInputs() here.
1441  virtual unsigned getNumVisibleInputs() const;
1442 
1443  /// Returns the number of ordered inputs on a node that remain separate
1444  /// even on nodes that have a variable number of inputs. These separate
1445  /// inputs always start at the beginning (variable input connectors are
1446  /// always last).
1447  ///
1448  /// The default implementation returns getOperator()->numOrderedInputs() so
1449  /// prefer calling OP_Operator::setNumOrderedInputs() instead of overriding
1450  /// this.
1451  virtual unsigned orderedInputs() const;
1452 
1453  /// Maximum number of output connectors on a node. Only VOPs and DOPs ever
1454  /// return a value other than 1 here.
1455  virtual unsigned maxOutputs() const;
1456 
1457  /// Number of output connections that should be visible on a node tile.
1458  /// Only used by VOPs and DOPs.
1459  virtual unsigned getNumVisibleOutputs() const;
1460 
1461  /// Returns true if the operator type says we have unordered inputs.
1462  bool hasUnorderedInputs() const;
1463 
1464  /// Returns the index of the last connected input incremented by one.
1465  /// If there are no inputs connected, returns 0. This means that the
1466  /// function behaves as if the lasted connected input was always the
1467  /// last entry in the inputs array. Note that other array entries up
1468  /// to the index of the one returned may contain null entries, so this
1469  /// is not necessarily the same as the number of connections. Also note
1470  /// that there may be more null entries at indices beyond the returned
1471  /// one.
1472  virtual unsigned nInputs() const;
1473 
1474  /// The number of nodes actually connected to this node. This function
1475  /// goes through the myInputs array and counts non-null entries.
1476  /// @param check_subnet_inside If true, the (vopnet) subnet node will check
1477  /// if a corresponding connector is connected inside, and count it in
1478  /// if so.
1479  unsigned nConnectedInputs(bool check_subnet_inside=true) const;
1480 
1481  unsigned getActiveInputIndex() const
1482  { return myActiveInputIndex; }
1483  void setActiveInputIndex(unsigned idx);
1484 
1485  /// Returns the node connected to a particular input (may be null).
1486  OP_Node *getInput(unsigned idx, bool mark_used=false) const;
1487 
1488  /// Returns the connected input, may be null. If it is a SOP & subnet,
1489  /// and not primary output, will chase to the child output node.
1490  /// This may induce flag dependencies, the provided micronode
1491  /// can accumulate them.
1492  OP_Node *getInputFollowingOutputs(int input,
1493  DEP_MicroNode *depnode=0) const;
1494 
1495  /// Returns the first non-null input beyond the specified starting index.
1496  /// This function can be used to easily loop through all connected inputs.
1497  int getConnectedInputIndex(int startAt = -1) const;
1498 
1499  /// Gets the index of the Nth non-null connection to this node.
1500  int getNthConnectedInput(int n) const;
1501 
1502  /// Override this to specify the inputs which are needed for cooking this
1503  /// node which can be executed in parallel.
1504  virtual void getParallelInputs(OP_Context &context,
1505  OP_NodeList &nodes) const;
1506 
1507  /// Forcibly clear an input. Used when deleting the input.
1508  void forceClearInput(int idx);
1509 
1510  /// Sets a given input to connect to an output of a particular node.
1511  virtual OP_ERROR setInput(unsigned idx, OP_Node *op,
1512  unsigned outputIdx = 0);
1513 
1514  /// Connects an input to an indirect input of our parent subnet.
1515  virtual OP_ERROR setIndirectInput(unsigned idx,
1516  OP_IndirectInput *input);
1517 
1518  /// Connects an input to particular node by name in the network.
1519  virtual OP_ERROR setInputReference(unsigned idx, const char *label,
1520  int keeppos, unsigned outputIdx = 0);
1521 
1522  /// Returns the index of the first connection from node "who" to this node,
1523  /// or -1 if "who" is not an input.
1524  int whichInputIs(const OP_Node *who) const;
1525 
1526  /// Returns the index of the first connection of an indirect input.
1527  int whichInputIs(const OP_IndirectInput *who) const;
1528 
1529  // Returns the index of the Nth connection of an idirect input.
1530  int whichInputIs(const OP_IndirectInput *whoi,
1531  int cnt) const;
1532 
1533  // Returns an index of the output which goes out from this node to
1534  // the target_node, and connects to the target_node at the specified
1535  // input index. Returns -1 if the connection doesn't exist.
1536  // Use whichOutputIsFollowingIndirect for a more robust solution.
1537  int whichOutputIs(const OP_Node* target_node,
1538  int input_on_target_node) const;
1539 
1540  // Computes the output, but handles the case that target_node's input
1541  // is an indirect input. This will then follow the indirect chain
1542  // up until a node's real input.
1543  int whichOutputIsFollowingIndirect(
1544  const OP_Node* target_node,
1545  int input_on_target_node) const;
1546 
1547  // Returns the index of an input into which source_node is connected
1548  // on this node. counter determines the Nth such connection from
1549  // source node to this particular node.
1550  int whichInputIs(const OP_Node* source_node,
1551  int counter) const;
1552 
1553  // Compacts the inputs array, removing all null entries.
1554  void consolidateInputs();
1555  virtual void clearUnreferencedInputs();
1556  virtual bool allowConsolidatingInput(int idx);
1557 
1558  // Returns a pointer to an input given an input index. If the input index
1559  // is less than nInputs() it will always return a valid input. If the grow
1560  // flag is set to true, then any inputs between nInputs and the index
1561  // given will be created, up to maxInputs().
1562  virtual OP_Input *getInputReference(unsigned idx, bool grow);
1563 
1564  // As before, except missing inputs are not created. NULL is returned for
1565  // non-existent inputs.
1566  virtual OP_Input *getInputReferenceConst(unsigned idx) const;
1567 
1568  virtual int doDeleteRewire() const { return 1; }
1569  // This moves the input at srcidx to dstidx. forcesubnet will enable
1570  // modificatio of subnet inputs and outputs even when inside a
1571  // blockModify().
1572  virtual void moveInput(int srcidx, int dstidx,
1573  bool forcesubnet = false);
1574  OP_ERROR insertInput(unsigned idx, OP_Node *op,
1575  unsigned outputIdx);
1576  OP_ERROR insertIndirectInput(unsigned idx,
1577  OP_IndirectInput *input);
1578 
1579  // For nodes with editable input names, this function is used to set the
1580  // default name for a new input.
1581  virtual UT_Options getInputDataDefault(int idx) const
1582  { return UT_Options(); }
1583 
1584  /// The following methods are used for nodes that allow reordering inputs.
1585  /// Returns the number of inputs that editor should display.
1586  virtual int getInputEditorInputs();
1587  /// Returns true if editor should display parameter option menu button.
1588  virtual bool allowInputEditorInputParm();
1589  /// Returns true if editor should display delete input button.
1590  virtual bool allowInputEditorInputDelete();
1591  /// Gets the input label to display in editor and returns true. Otherwise,
1592  /// returns false if editor should use backward-compatible labeling scheme.
1593  virtual bool getInputEditorInputLabel(UT_String &label, int idx);
1595  virtual const OP_DataMicroNode &
1596  dataMicroNodeConst() const
1597  { return myDataMicroNode; }
1598  OP_DataMicroNode & dataMicroNode()
1599  {
1600  return const_cast<OP_DataMicroNode &>(
1601  dataMicroNodeConst());
1602  }
1603 
1604  /// Subclasses should override this to customize the micro-node dependency
1605  /// of their parameter list. The default is just dataMicroNode().
1606  virtual const OP_DataMicroNode &
1607  parmListMicroNodeConst() const
1608  { return dataMicroNodeConst(); }
1609  OP_DataMicroNode & parmListMicroNode()
1610  {
1611  return const_cast<OP_DataMicroNode &>(
1612  parmListMicroNodeConst());
1613  }
1614 
1615  bool hasIndepParmListMicroNode() const
1616  {
1617  return (&parmListMicroNodeConst()
1618  != &dataMicroNodeConst());
1619  }
1620 
1621  DEP_MicroNode & flagMicroNode()
1622  { return myFlagMicroNode; }
1623  DEP_MicroNode & parmMicroNode(int parm_idx, int vi)
1624  { return getParmList()->parmMicroNode(
1625  parm_idx, vi); }
1627  /// Accessors to event micro nodes.
1628  const DEP_MicroNode &eventMicroNodeConst(OP_EventType e) const
1629  {
1630  return SYSconst_cast(this)->eventMicroNode(e);
1631  }
1632  DEP_MicroNode & eventMicroNode(OP_EventType e);
1633 
1634  bool hasEventMicroNode(OP_EventType e) const
1635  {
1636  UT_ASSERT_P(e >= 0 && e < OP_EVENT_TYPE_COUNT);
1637  if (!myEventMicroNodes)
1638  return false;
1639  return bool(myEventMicroNodes[e]);
1640  }
1641 
1642  /// Subclasses should override this provide any additional micronodes that
1643  /// they own. This list is used in places such as node deletion so that
1644  /// dependents are dirtied.
1645  virtual void getOwnedMicroNodes(
1646  DEP_MicroNodeList &micronodes);
1647 
1648  /// Explicitly propagate dirtiness for a particular micronode owned by
1649  /// some node.
1650  void propagateDirtyMicroNode(
1651  DEP_MicroNode &micronode,
1652  OP_EventType reason,
1653  void *data,
1654  bool send_root_event);
1655 
1656  /// Declares that this node's data depends on the @c op for the given
1657  /// reason (OP_INTEREST_DATA, OP_INTEREST_FLAG).
1658  /// @note There are no other acceptable values for type.
1659  virtual void addExtraInput(OP_Node *op, OP_InterestType type);
1660 
1661  /// Declares that this node's data depends on @c op channel. If vec_i is
1662  /// -1, then this node depends on all the channels of the parameter.
1663  void addExtraInput(OP_Node &op, int parm_i, int vec_i);
1664 
1665  /// Generic version of addExtraInput() which adds a dependency from an
1666  /// source ref to this node's data micronode.
1667  void addExtraInput(const OP_InterestRef &source_ref);
1668 
1669  /// Generic version of addExtraInput() which adds a dependency from an
1670  /// source micronode to this node's data micronode.
1671  void addExtraInput(DEP_MicroNode &source_micronode);
1672 
1673  /// Marks this to be dependent on all the parameters inside of the
1674  /// multiparm.
1675  void addMultiparmInterests(OP_Node *srcnode, PRM_Parm &parm);
1676 
1677 
1678  static DEP_MicroNode *getEvalChannelMicroNode(int thread);
1679 
1680  /// Declare from an expression callback that the current evaluation channel
1681  /// is dependent on the given source.
1682  // @{
1683  static void addExtraInputToEvalChannel(
1684  int thread,
1686  {
1687  addExtraInputToEvalChannel(
1688  thread,
1689  OP_InterestRef(op, type));
1690  }
1691  static void addExtraInputToEvalChannel(
1692  int thread,
1693  OP_Node &op, int parm_i, int vec_i)
1694  {
1695  addExtraInputToEvalChannel(
1696  thread,
1697  OP_InterestRef(op,parm_i,vec_i));
1698  }
1699  static void addExtraInputToEvalChannel(
1700  int thread,
1701  const OP_InterestRef &source_ref)
1702  {
1703  DEP_MicroNode *
1704  target = getEvalChannelMicroNode(thread);
1705  if (target)
1706  OP_Node::addExtraInput(*target, source_ref);
1707  }
1708  static void addExtraInputToEvalChannel(
1709  int thread,
1710  DEP_MicroNode &src_micronode)
1711  {
1712  DEP_MicroNode *
1713  target = getEvalChannelMicroNode(thread);
1714  if (target)
1715  target->addExplicitInput(src_micronode);
1716  }
1717  // @}
1718 
1719  /// Generic versions of addExtraInput() used by the others. In particular,
1720  /// the static version of addExtraInput() allows you to define channel to
1721  /// channel dependencies.
1722  // @{
1723  static void addExtraInput(
1724  const OP_InterestRef &target_ref,
1725  const OP_InterestRef &source_ref);
1726  static void addExtraInput(
1727  const OP_InterestRef &target_ref,
1728  DEP_MicroNode &source_micronode);
1729  static void addExtraInput(
1730  DEP_MicroNode &target_micronode,
1731  const OP_InterestRef &source_ref);
1732  // @}
1733 
1734  static void addMultiparmInterests(const OP_InterestRef &target_ref,
1735  OP_Node *srcnode,
1736  PRM_Parm &parm);
1737  static void addMultiparmInterests(DEP_MicroNode &target,
1738  OP_Node *srcnode,
1739  PRM_Parm &parm);
1740 
1741  void getExtraInputNodes(
1742  OP_NodeList &extras,
1743  bool remove_duplicates = true,
1744  bool data_interest = true,
1745  bool parm_interest = true,
1746  bool flag_interest = true,
1747  bool include_parmlist = true,
1748  bool follow_simulation_inputs = false) const;
1749  void getExtraOutputNodes(
1750  OP_NodeList &extras,
1751  bool remove_duplicates = true,
1752  bool data_interest = true,
1753  bool parm_interest = true,
1754  bool flag_interest = true) const;
1755 
1756  int getNumExtraInputs() const;
1757 
1758  void dumpExtraInputs(
1759  std::ostream &os,
1760  bool as_DOT,
1761  int indent_level = 0) const;
1762 
1763  // addExprOpDependency is a helper function for building dependencies for
1764  // the expression library callback functions.
1765  static void addExprOpDependency(const char *arg_str,
1766  const PRM_RefId &ref_id,
1767  OP_InterestType interest_type);
1768  static void addExprOpDependency1From2(const char *arg_str1,
1769  const char *arg_str2,
1770  const PRM_RefId &ref_id,
1771  OP_InterestType interest_type);
1772  static void addExprOpParmDependency(const char *arg_str,
1773  const PRM_RefId &ref_id,
1774  OP_InterestType interest_type);
1775  // NB: is reponsible for freeing new_arg!
1776  static void changeExprOpRef(const char *arg_str,
1777  char *&new_arg,
1778  const char *new_fullpath,
1779  const char *old_fullpath,
1780  const char *old_cwd);
1781  // NB: is reponsible for freeing new_arg!
1782  static void changeExprOpRef1From2(const char *arg_str1,
1783  const char *arg_str2,
1784  char *&new_arg1,
1785  char *&new_arg2,
1786  const char *new_fullpath,
1787  const char *old_fullpath,
1788  const char *old_cwd);
1789  // NB: is reponsible for freeing new_arg!
1790  static void changeExprOpParmRef(const char *arg_str,
1791  char *&new_arg,
1792  const char *new_fullpath,
1793  const char *old_fullpath,
1794  const char *old_cwd,
1795  const char *chan_name,
1796  const char *old_chan_name);
1797 
1798  void addGenericOpNameReference( const UT_String &oppath );
1799  void addGenericOpNameReference( const PRM_RefId &ref_id,
1800  OP_Node *node );
1801  void addGenericOpInputReference( const PRM_RefId &ref_id,
1802  OP_Node *node );
1803 
1804  static void moveAndUpdateDependencies(
1805  const OP_NodeList &src_nodes,
1806  const OP_NodeList &dest_nodes );
1807 
1808  static void updateChannelPtrs( CH_CollectionList &parents );
1809 
1810  bool getParmBaseNodePath(
1811  UT_String &path,
1812  int parm_index,
1813  int thread) const;
1814 
1815  // Make this function public so it can be called by OPUI_EditSubnet
1816  // and possibly others. Note that it is defined in PRM_ParmOwner so
1817  // that it can be called from the PRM library.
1818  void rebuildParmDependency(int parm_index) override;
1819 
1820  // Clear op name dependencies
1821  void clearParmDependency(int parm_index) override;
1822  // decrementOpReference() should only be called by clearParmDependency()
1823  void decrementOpReference(int node_id);
1824 
1825  virtual void dumpDependencies(std::ostream &os);
1826  void dumpOpDependents(OP_Node *ref, int brief,
1827  std::ostream &os);
1828  const OP_DependencyList
1829  &getOpDependents() const { return myOpDependents; }
1830 
1831 
1832  // INTERNAL: Do NOT use outside of OP_Node! Will be made private.
1833  int countReferences(int op_id);
1834 
1835  // Get the existing node *NAME* references (eg. expr references)
1836  // NB: This function assumes that refs is sorted without duplicate entries!
1837  void getExistingOpReferences(OP_NodeList &refs,
1838  bool recurse) const;
1839 
1840  // Get the as complete list of data references as possible for this node.
1841  // This combines getExistingOpReferences() which exist without cooking, and
1842  // getExtraInputNodes() which are the current references since the last
1843  // cook of its refernces.
1844  void getFullOpReferences(OP_NodeList &refs,
1845  bool include_descendants) const;
1846 
1847  // Get the existing node *NAME* dependents (eg. expr references)
1848  // NB: This function assumes that deps is sorted without duplicate entries!
1849  void getExistingOpDependents(OP_NodeList &deps,
1850  bool include_descendants) const;
1851 
1852  // Get the as complete list of data dependents as possible for this node.
1853  // This combines getExistingOpDependents() which exist without cooking, and
1854  // getExtraOutputNodes() which are the current dependents since the last
1855  // cook.
1856  void getFullOpDependents(OP_NodeList &deps,
1857  bool include_descendants) const;
1858 
1859  // Gets a list of parms that reference one of our channels/parms.
1860  void getParmsThatReference(const char *channame,
1861  UT_ValArray<PRM_Parm *> &parms,
1862  UT_IntArray &parmsubidxs);
1863 
1864  virtual void inputConnectChanged(int which);
1865 
1866  // Returns the number of output entries in the output array. Note
1867  // that this done regardless of which entries have any outputs connected.
1868  unsigned nOutputEntries() const;
1869  // Get access to the raw network items connected to our outputs.
1870  // These functions can focus on a single output connector, or treat
1871  // all outputs as a flat array by passign output_idx = -1.
1872  int nOutputItems(int output_idx = -1) const;
1873  OP_NetworkBoxItem *getOutputItem(int idx, int output_idx = -1) const;
1874  // Quick check if this node has any node outputs.
1875  bool hasAnyOutputNodes(bool through_dots = true,
1876  int output_idx = -1) const;
1877  // Fills a node list with all outputs from this node. This function can
1878  // search through dots, and dive into subnets. It can also run on a
1879  // single output connector or all of them.
1880  void getOutputNodes(UT_Array<OP_Node*> &outputs,
1881  bool into_subnets = false,
1882  bool through_dots = true,
1883  int output_idx = -1) const;
1884  // Quick function to return the first output node, searching depth first
1885  // through dots if requested.
1886  OP_Node *getFirstOutputNode(bool through_dots = true,
1887  int output_idx = -1) const;
1888 
1889  // obtains an output node that leads to a target node (e.g., during network
1890  // traversal). Null if target is not a descendant.
1891  OP_Node *getOutputTowardsNode(const OP_Node *target);
1892 
1893  /// Fill in 'tree' with details that are common to all node types. Then call
1894  /// fillInfoTreeNodeSpecific() to get specific details about this specific
1895  /// node (be it a SOP, CHOP, etc)
1896  void fillInfoTree(UT_InfoTree &tree,
1897  const OP_NodeInfoTreeParms &parms);
1898 
1899  /// Triggered by 'fillInfoTree()', this virtual function adds all node-
1900  /// specific info to 'tree'. All child classes must create their own
1901  /// branches under 'tree' to place their info
1902  virtual void fillInfoTreeNodeSpecific(UT_InfoTree &tree,
1903  const OP_NodeInfoTreeParms &parms);
1904 
1905  /// Optionally called on parent from fillInfoTreeNodeSpecific() to provide
1906  /// some information about node that only parent network can provide.
1907  /// @return True if parent added info specific to that child.
1908  virtual bool fillInfoTreeChildSpecific(UT_InfoTree &tree,
1909  const OP_NodeInfoTreeParms &parms,
1910  OP_Node *child);
1911 
1912  // These methods get input data for the OP. If they return an error code
1913  // >= UT_ERROR abort, then the errno should be set, and there may be a
1914  // further local error message. There is no error checking to ensure that
1915  // each locked source is only released once, so it's up to the user. The
1916  // standard method is to call lockInputs(), then call unlockInputs() on
1917  // exit. However, in some cases (i.e. switch SOP) only some sources need
1918  // to be cooked.
1919  //
1920  // lockInput() will return an error code >= UT_ERROR iff idx <
1921  // minInputs(). Otherwise, it's considered to be an optional input, so no
1922  // data will be returned. A simple rule of thumb: If lockInput() returns
1923  // ok, the source has to be unlocked, otherwise it shouldn't be unlocked!
1924  // If lockInputs() detects an error, it will automatically unlock the
1925  // inputs so that unlockInputs() should NOT be called!
1926  virtual OP_ERROR lockInput(unsigned idx, OP_Context &context);
1927  virtual void unlockInput(unsigned idx);
1928  virtual OP_ERROR lockInputs(OP_Context &context);
1929  virtual void unlockInputs();
1930 
1931  // This "serial" number refers to the number of times that the geometry
1932  // had been changed. Note, only the "modeller" should bump the cook count,
1933  // the OP cook method does this also, but has privilaged access.
1934  int getCookCount() const { return myCookCount; }
1935  void triggerOutputChanged();
1936 
1937  void triggerUIChanged(
1940  // Returns the index of cooked input to a SOP switch
1941  virtual int cookedInputIndex() const { return -1; }
1942 
1943  /// For nodes which simply pass-through their data from some other node,
1944  /// this returns the node whose data will used transparently as this node's
1945  /// output. This function can give different values depending on its
1946  /// parameters. Used by node traversal algorithms.
1947  ///
1948  /// The default implementation returns the first input if it's bypassed, so
1949  /// subclasses should only do something different if this function returns
1950  /// NULL.
1951  ///
1952  /// @param t Eval time
1953  /// @param mark_used Mark this node is using the returned node (if
1954  /// non-NULL).
1955  ///
1956  virtual OP_Node *getPassThroughNode(
1957  fpreal t,
1958  bool mark_used = false);
1959 
1960  bool setMinimumCacheSize(int min_size);
1961 
1962  OP_VERSION getVersionParms() const
1963  { return dataMicroNodeConst().modVersion(); }
1964 
1965  // This will be called if the timeInterest flag is set.
1966  // This will return true if the node needs to be dirtied for cooking
1967  virtual bool handleTimeChange(fpreal /* t */) { return false; }
1968 
1969  /// Returns true if the OP depends on time at the given time. This
1970  /// is sensitive to handleTimeChange's overrides.
1971  bool isTimeDependent(const OP_Context &context);
1972 
1973  // Returns true if this node is an HDA with a dive target, or a C++ node
1974  // with a subnework, but is not an OBJ, subnet, or manager.
1975  virtual bool isDiveable() const;
1976 
1977  static int getGlobbedNodes(OP_Node *cwd, UT_String &holder,
1978  const char *pattern, UT_WorkArgs &argv,
1979  OP_GlobContext *context);
1980 
1981  static int getGlobbedNetworkBoxes(OP_Node *cwd, UT_String &holder,
1982  const char *pattern, UT_WorkArgs &argv,
1983  OP_GlobContext *context);
1984 
1985  static int getGlobbedPostIts(OP_Node *cwd, UT_String &holder,
1986  const char *pattern, UT_WorkArgs &argv,
1987  OP_GlobContext *context);
1988 
1989 
1990  /// Obtains additional nodes that should be copied or deleted when this
1991  /// node is copied or deleted. It applies to situations, such as, where
1992  /// an hidden input node feeds only to this node and serves only that
1993  /// purpose, so it should be coppied/deleted along with the master.
1994  virtual void getExtraNodesForCopyOrDelete(OP_NodeList &extras)const;
1995 
1996  // Runs the creation script (if there is one). The return value is false
1997  // if the node was deleted while running the script. In this case
1998  // obviously the node pointer becomes invalid and should not be used
1999  // any more. It returns true if the node still exists.
2000  virtual bool runCreateScript();
2001  // Go through all our parms to match the values to the current hip file
2002  // units settings.
2003  void updateParmsToMatchCurrentUnits();
2004 
2005  /// True if the otl is marked as matching, but hasn't actually been
2006  /// synced yet.
2007  bool getDelaySyncOTL() const
2008  { return myDelaySyncOTL; }
2009 
2010  /// Shallowly sets the delayed sync flag,
2011  void setDelaySyncOTL(bool isdelayed);
2012 
2013  /// Determines if this node should do delayed syncing or not.
2014  bool shouldDelaySyncOTL() const;
2016  /// Verifies this node has been synchronized in case it was delayed.
2017  void syncDelayedOTL()
2018  {
2019  if (!getDelaySyncOTL()) return;
2020  internalSyncDelayedOTL();
2021  }
2022 
2023  /// Matches the node to the current HDA definition, loading the contents
2024  /// section if ncecessary and setting the match flag.
2025  virtual void matchOTLDefinition();
2026 
2027  /// Unmatches (unlocks) the node from the current HDA definition.
2028  virtual void unmatchOTLDefinition();
2029 
2030  /// Method that is invoked when the HDA index file has been cleared
2031  /// because the underlying HDA definition has changed.
2032  virtual void handleOTLIndexFileCleared();
2033 
2034  /// Returns the error string where we keep all errors generated during
2035  /// our most recent synchronization attempt.
2036  const UT_String &getSyncErrors() const
2037  { return mySyncErrors; }
2038  /// Returns the error level generated in our last synchronization attempt.
2039  OP_ERROR getSyncErrorLevel() const
2040  { return mySyncErrorLevel; }
2041 
2042  /// Return true if any ancestor of this node is currently running the
2043  /// syncContents function (and so has mySyncDepth > 0). This is used to
2044  /// detect changes to nodes that are not currently "locked", but will
2045  /// become locked once the sync is complete.
2046  bool isAnyAncestorBeingSynced() const;
2047 
2048  /// Interface to flag that specifies whether or not we match our definition.
2049  int getMatchesOTLDefinition() const;
2050 
2051  /// Utility function for syncing/unsyncing all uncestor nodes.
2052  static void propagateMatchOTLDefinitionToAncestors(OP_Node *node,
2053  bool sync_flag);
2054 
2055  // Some extra functions for dealing with access rights as they relate
2056  // to matching the OTL definition.
2057  int getCanDeviateFromOTLDefinition() const;
2058  void setAllChildAssetPermissions(int permission);
2059  // Recompute the asset permissions because something changed like the node
2060  // was locked or unlocked.
2061  void computeAllChildAssetPermissions();
2062  // Returns true if this node is contained inside a locked HDA, but
2063  // is marked as an editable node within that HDA.
2064  bool getIsEditableAssetSubNode() const;
2065 
2066  // Turn off our export flag and the export flags of our children.
2067  void turnOffAllChildExports();
2068 
2069  // Collection of methods for working with licensed assets.
2070  bool haveLicenseToAccessContents(
2071  OP_Node* opt_specific_child = nullptr) const;
2072  bool haveLicenseToAccessParentContents() const;
2073  bool haveAncestorWithoutFullLicense(bool ignore_self) const;
2074  OP_OTLLicenseType getLicense() const;
2075  // Get the first (oldest) ancestor without a license to access contents.
2076  OP_Node *getFirstExecLicenseOnlyAncestor(
2077  bool ignore_self = true) const;
2078  // Get the last (youngest) ancestor without a license to access contents.
2079  OP_Node *getLastExecLicenseOnlyAncestor(
2080  bool ignore_self = true) const;
2081 
2082  bool isCompiled() const;
2083 
2084  // Save as a series of ASCII commands.
2085  void saveWires(std::ostream &os, const char *name,
2086  int dogeneral = 0);
2087  void saveOutputWires(std::ostream &os, const char *name,
2088  int dogeneral = 0);
2089  virtual void saveIntrinsicCommand(std::ostream &os,
2090  const char *name);
2091 
2092  /// Writes to 'os' a string of hscript commands to recreate this node.
2093  virtual OP_ERROR saveCommand(std::ostream &os,
2094  const char *name,
2095  fpreal x,
2096  fpreal y,
2097  const char *netboxname,
2098  const OP_SaveCommandOptions &options);
2099 
2100  // This method saves a chlock style command for this node's parameters.
2101  // name - the name of the node to print on the command;
2102  // command - the name of the command;
2103  // flag_method - a PRM_Parm method that can be queried for the flag to
2104  // output;
2105  // defaultstoo - prints a default "-*" or "+*" as the first parameter
2106  // reverse - normally the default is "-*" followed by the list of
2107  // parameters that result true for flag_method(). If
2108  // reverse is true, then the default is "+*" followed by
2109  // the parameters where flag_method() is false. Only useful
2110  // when defaultstoo is true.
2111  // parm_array - an optional array of parameters whose values should be
2112  // printed. If this array is NULL, then the entire node
2113  // is searched.
2114  void saveParameterFlags(std::ostream &os, const char *name,
2115  const char *command,
2116  bool (PRM_Parm::*flag_method)(int) const,
2117  bool defaultstoo, bool reverse,
2118  UT_Array<opParmData> *parm_array);
2119 
2120  void saveUserDataCommand(
2121  std::ostream &os, const char *node_name,
2122  bool omit_version = false);
2123 
2125  {
2126  RAMP_ERR_SUCCESS,
2127  RAMP_ERR_NOT_FOUND,
2128  RAMP_ERR_ONLY_KEY
2129  };
2130  virtual RampError rampCommand(bool remove, fpreal pos, float rgba[4]);
2131  RampError rampCommand(bool remove, fpreal pos, float rgba[4],
2132  UT_Ramp &ramp);
2133 
2134  virtual bool loadRamp(UT_IStream &is, const char *path=0);
2135 
2136  bool loadRamp(UT_IStream &is, UT_Ramp &ramp,
2137  const char *path=0);
2138  OP_ERROR saveRamp(std::ostream &os, UT_Ramp &ramp,
2139  const char *name = 0, int command = 0);
2140 
2141  bool getUserData(const UT_StringRef &key,
2142  UT_StringHolder &result) const;
2143  void setUserData(const UT_StringRef &key,
2144  const UT_StringHolder &data,
2145  bool save_undo);
2146  bool hasUserData(const UT_StringRef &key) const;
2147  bool deleteUserData(const UT_StringRef &key,
2148  bool save_undo);
2149  const UT_Options &userData() const
2150  { return myUserData; }
2151  bool loadUserData(UT_IStream &is, const char *path=nullptr);
2152  OP_ERROR saveUserData(std::ostream &os, const char *path);
2153  void clearUserData(bool save_undo);
2154  virtual void userDataChanged(const UT_StringHolder &key);
2156  /// Prefix to use for internally used user data.
2157  static const char *internalUserDataPrefix() { return "sidefx::"; }
2158 
2159  /// Returns a shared pointer to a previously stored blind data. If no
2160  /// blind data exists with the given key, an empty shared pointer is
2161  /// returned.
2162  UT_SharedPtr<void> getBlindData(const char *key) const;
2163 
2164  /// Return a pointer to a previously stored blind data, statically cast
2165  /// to the type given. If the cast fails, or if there's no data of that
2166  /// type, a NULL pointer is returned. To distinguish between the two cases
2167  /// call hasBlindData().
2168  template<typename T>
2169  UT_SharedPtr<T> getBlindData(const char *key) const
2170  { return UTstatic_pointer_cast<T>(getBlindData(key)); }
2171 
2172  /// Stores a blind data pointer on this OP_Node object. Any entry that
2173  /// previously existed will be erased, and, if it is the last reference,
2174  /// the object itself deleted. The \c void type can convert from any other
2175  /// shared pointer type, while storing the deleter function, allowing
2176  /// OP_Node to delete the data without knowing anything about the class.
2177  /// Blind data is *not* stored with the class.
2178  void setBlindData(const char *key, UT_SharedPtr<void> ptr);
2179 
2180  /// Returns true if this object stores a blind data with the given key.
2181  bool hasBlindData(const char *key) const;
2182 
2183  /// Remove any reference to the blind data of the given key from this
2184  /// object.
2185  bool deleteBlindData(const char *key);
2186 
2187  void getDataBlockKeys(UT_StringArray &keys,
2188  const UT_StringHolder &type =
2189  UT_StringHolder()) const;
2190  OP_DataBlockPtr getDataBlock(const char *key) const;
2191  bool setDataBlock(const char *key, OP_DataBlockPtr ptr);
2192  OP_ERROR saveDataBlocksPacket(std::ostream &os,
2193  const char *path_prefix,
2194  const UT_String &node_name);
2195  bool loadDataBlocks(UT_IStream &is, const char *path);
2196  bool clearDataBlocks();
2197  virtual void dataBlockChanged(const UT_StringHolder &key);
2198 
2199  // deleteNodeData is called when the OP_Cache wants to delete some data.
2200  // This method should return 1 if you want change events to be propagated
2201  // to the extra inputs when data is deleted from the cache.
2202  virtual int deleteNodeData(void *);
2203  void propagateNodeDataDeleted();
2204 
2205  // getCachedPythonObject returns NULL if no object exists with the given
2206  // key.
2207  PY_OpaqueObject *getCachedPythonObject(const UT_StringRef &key) const;
2208  // Call setCachedPythonObject with a PyObject * cast to a void *, not with
2209  // a PY_OpaqueObject * cast to a void *. The pointer must not be null.
2210  void setCachedPythonObject(
2211  const UT_StringHolder &key, void *opaque_py_object);
2212  // deleteCachedPythonObject returns false if no value exists with that key.
2213  bool deleteCachedPythonObject(const UT_StringRef &key);
2214  void clearCachedPythonObjects();
2215  // cachedPythonObjects returns a UT_StringMap containing pointers to
2216  // PY_OpaqueObjects. The pointers are not null.
2217  const OP_PythonObjectCache &cachedPythonObjects() const
2218  { return myCachedPythonObjects; }
2219 
2220  bool loadExtraInputs(UT_IStream &is, const char *path=0);
2221 
2222  void saveOverrides(std::ostream &os);
2223  void saveOverrides(std::ostream &os, OP_Node *root,
2224  const UT_String &rootpath,
2225  bool &added);
2226  void saveChildOverrides(std::ostream &os, OP_Node *root,
2227  const UT_String &rootpath,
2228  bool &added);
2229  bool loadOverride(UT_IStream &is);
2231  fpreal t, int thread,
2232  const char *parm_name,
2233  int vec_idx) override;
2234  bool isParmPendingOverride(const char *parm_name,
2235  int vec_idx) const override;
2236  OP_ERROR cookOverrides(OP_Context &c);
2238  virtual void removeOverrideDestination(OP_Node * /*dest*/) {}
2239  virtual void removeOverrideDestination(OP_Node * /*dest*/,
2240  int /*parm_idx*/) {}
2241 
2242  // Overriding virtual function in PRM_ParmOwner to run a command.
2243  void executeCommand(const char *command,
2244  std::ostream *out,
2245  std::ostream *err) const override;
2246 
2249  pushAsPwd() const override;
2250 
2251  OP_ERROR executeHscriptScript(UT_String &script,
2252  const OP_Context &context);
2253  OP_ERROR executePythonScript(UT_String &script,
2254  const OP_Context &context);
2255 
2256  void addPythonNodeError(const PY_Result &py_result);
2257 
2258  void saveInputs(std::ostream &os, bool compile_basic);
2259  bool loadInputs(UT_IStream &is, const char *path=0,
2260  bool named = false);
2261  void saveNamedInputs(std::ostream &os, bool compile_basic);
2262  void saveNamedOutputs(std::ostream &os);
2263  bool loadNamedOutputs(UT_IStream &is, const char *path=0);
2264 
2265  // These methods provide access to the options that can be stored on each
2266  // input of a node, if the node type enables this feature.
2267  void getEditableInputDataKeys(int idx,
2268  UT_StringArray &keys) const;
2269  const UT_OptionEntry*getEditableInputData(int idx,
2270  const UT_StringRef &key) const;
2271  bool setEditableInputData(int idx,
2272  const UT_StringHolder &key,
2273  const UT_OptionEntry &value);
2274  void saveEditableInputData(std::ostream &os) const;
2275  bool loadEditableInputData(UT_IStream &is,
2276  const char *path);
2277  // Special case functions for getting and setting the input "name", which
2278  // just call the generic InputData functions.
2279  UT_StringHolder getEditableInputString(int idx,
2280  const UT_StringRef &key) const;
2281  bool setEditableInputString(int idx,
2282  const UT_StringRef &key,
2283  const UT_StringHolder &str);
2284 
2285  /// @{ If a subclass is interested in the saved input or output names, then
2286  /// it should override this method. The array will be filled during load.
2287  virtual UT_StringArray * getArrayForLoadedInputNames();
2288  virtual UT_StringArray * getArrayForLoadedOutputNames();
2289  /// @}
2290 
2291  void checkInputs(); // this method will check the
2292  // node references in all the inputs
2293 
2294  // Saves out extra information for this node to be included in a dialog
2295  // script that defines an operator type created from this one.
2296  virtual void saveDialogScriptExtraInfo(std::ostream &os);
2297 
2298  // Fills in the supplied default gallery entry with info from this node.
2299  virtual void createGalleryEntry(OP_GalleryEntry &entry);
2300 
2301  // When a string parameter can have the syntax: 'op:/...', use these
2302  // evaulate methods to do the approprate checking and reference building.
2303  // These methods will return a reference to the OP_Node if one is
2304  // referenced. If the syntax is something like:
2305  // op:/foo/bar[32]
2306  // Then the optime will be (32-1)/$FPS rather than the evaluation time.
2307  void evalOpPathString(UT_String &val, int pi, int vi,
2308  fpreal t, int &op_id, fpreal &op_time,
2309  int expanded = 1);
2310  void evalOpPathString(UT_String &val, const char *pn,
2311  int &pi, int vi, fpreal t,
2312  int &op_id, fpreal &op_time,
2313  int expanded=1);
2314  static int findOpFramePair(const char *path, int &op_id,
2315  fpreal &frame);
2316 
2317  /// Build a UT_XformOrder out of TRS and XYZ parameter values
2318  static void buildXformOrder(int trs, int xyz,
2319  UT_XformOrder &order);
2320 
2321  static const UT_XformOrder& buildXformOrder(int trs, int xyz );
2322 
2323  /// Translate a TRS parameter menu index into the UT_XformOrder type
2324  static UT_XformOrder::rstOrder getMainOrder( int trs );
2325  /// Translate a UT_XformOrder type into a TRS parameter menu index
2326  /// (inverse of getMainOrder())
2327  static int getMainOrderMenuIndex(UT_XformOrder::rstOrder order);
2328  /// Translate a XYZ parameter menu index into the UT_XformOrder type
2329  static UT_XformOrder::xyzOrder getRotOrder( int xyz );
2330  /// Translate a UT_XformOrder type into a XYZ parameter menu index
2331  /// (inverse of getRotOrder())
2332  static int getRotOrderMenuIndex(UT_XformOrder::xyzOrder order);
2333 
2334  /// NB: None of the getXformPivot() or getPivotParmValue() methods take
2335  /// any pivot compensation transform into account. It is up to the
2336  /// caller to account for any such transform.
2337  static UT_Vector3R getXformPivot(int trs,
2338  fpreal tx, fpreal ty, fpreal tz,
2339  fpreal px, fpreal py, fpreal pz);
2340  static UT_Vector3R getXformPivot(int trs,
2341  fpreal tx, fpreal ty, fpreal tz,
2342  fpreal px, fpreal py, fpreal pz,
2343  fpreal pivot_rx, fpreal pivot_ry,
2344  fpreal pivot_rz, bool inverse = false);
2345  static UT_Vector3R getPivotParmValue(int trs,
2346  fpreal tx, fpreal ty, fpreal tz,
2347  fpreal px, fpreal py, fpreal pz);
2348  static UT_Vector3R getPivotParmValue(int trs,
2349  fpreal tx, fpreal ty, fpreal tz,
2350  fpreal px, fpreal py, fpreal pz,
2351  fpreal pivot_rx, fpreal pivot_ry,
2352  fpreal pivot_rz, bool inverse = false);
2353 
2354  static void buildXform(int trs, int xyz,
2355  float tx, float ty, float tz,
2356  float rx, float ry, float rz,
2357  float sx, float sy, float sz,
2358  float px, float py, float pz,
2359  UT_Matrix4 &mat);
2360  static void buildXform(int trs, int xyz,
2361  double tx, double ty, double tz,
2362  double rx, double ry, double rz,
2363  double sx, double sy, double sz,
2364  double px, double py, double pz,
2365  UT_DMatrix4 &mat);
2366  static void buildXform(int trs, int xyz,
2367  float tx, float ty, float tz,
2368  float rx, float ry, float rz,
2369  float sx, float sy, float sz,
2371  UT_Matrix4 &mat);
2372  static void buildXform(int trs, int xyz,
2373  double tx, double ty, double tz,
2374  double rx, double ry, double rz,
2375  double sx, double sy, double sz,
2377  UT_DMatrix4 &mat);
2378  static void buildXform(int trs, int xyz,
2379  float tx, float ty, float tz,
2380  float rx, float ry, float rz,
2381  float sx, float sy, float sz,
2382  float s_xy, float s_xz, float s_yz,
2383  float px, float py, float pz,
2384  UT_Matrix4 &mat);
2385  static void buildXform(int trs, int xyz,
2386  double tx, double ty, double tz,
2387  double rx, double ry, double rz,
2388  double sx, double sy, double sz,
2389  double s_xy, double s_xz, double s_yz,
2390  double px, double py, double pz,
2391  UT_DMatrix4 &mat);
2392  static void buildXform(int trs, int xyz,
2393  float tx, float ty, float tz,
2394  float rx, float ry, float rz,
2395  float sx, float sy, float sz,
2396  float s_xy, float s_xz, float s_yz,
2398  UT_Matrix4 &mat);
2399  static void buildXform(int trs, int xyz,
2400  double tx, double ty, double tz,
2401  double rx, double ry, double rz,
2402  double sx, double sy, double sz,
2403  double s_xy, double s_xz, double s_yz,
2405  UT_DMatrix4 &mat);
2406  static void buildXform(
2407  const UT_Matrix4F::FullTransformModel &parms,
2408  UT_Matrix4F &mat);
2409  static void buildXform(
2410  const UT_Matrix4D::FullTransformModel &parms,
2411  UT_Matrix4D &mat);
2412  static void buildXform(int trs,
2413  float tx, float ty, float rz,
2414  float sx, float sy, float px, float py,
2415  UT_Matrix3 &mat);
2416  static void buildXform(int trs,
2417  double tx, double ty, double rz,
2418  double sx, double sy, double px, double py,
2419  UT_DMatrix3 &mat);
2420  static void buildXform(int trs,
2421  float tx, float ty, float rz,
2422  float sx, float sy, float s_xy,
2423  float px, float py,
2424  UT_Matrix3 &mat);
2425  static void buildXform(int trs,
2426  double tx, double ty, double rz,
2427  double sx, double sy, double s_xy,
2428  double px, double py,
2429  UT_DMatrix3 &mat);
2430 
2431  virtual int getTranslateParmIndex();
2432 
2433  // This is done only after a load to make sure that
2434  // all inputs have been resolved correctly.
2435  void resolveInputReferences();
2436 
2437  static void clearAllPendingUndoFlags();
2438 
2439  void clearUndoFlags() override;
2440  void setAnyUndoFlag() override;
2441  void saveForUndoInput();
2442 
2443  /// When doing bulk parameter modifications, they can be sandwiched between
2444  /// blockModify(true) and blockModify(false) statements as an optimization.
2445  /// Parameters modified during blockModify(true) will have their dirtiness
2446  /// propagation to other scene entities like nodes and parameters
2447  /// suppressed until blockModify(false) is called.
2448  ///
2449  /// @note This will NOT suppress events to addOpInterest() callbacks.
2450  /// In fact, blockModify(false) currently sends out an extraneous
2451  /// OP_PARM_CHANGED with parm index of -1.
2452  void blockModify(int on_off, int propagate = 1);
2453 
2454  int isBlockModify() const;
2455  bool isModifyWaiting() const;
2456  virtual void propagateEndBlockModify();
2457 
2458  // Only returns anything in the case of chops
2459  virtual const CL_Clip *getClip(OP_Context *context = 0);
2460 
2461  /// Returns the a chop network path suitable for storing motion effects
2462  /// associated with this node.
2463  void getMotionEffectsNetworkPath(UT_String &path);
2464 
2465  /// Return the cook information as a formatted string.
2466  void getCookInfo(UT_String &info) const;
2467  /// Return the cook information in a UT_InfoTree.
2468  void getCookInfoTree(UT_InfoTree &tree) const;
2469 
2470  // Query color for Net Overview rendering
2471  virtual int getNetOverviewColor( UT_Color &color );
2472 
2473  // Those operators which need a ramp editor must define this method.
2474  virtual UT_Ramp *getRamp();
2475 
2476  virtual int isCookingRender() const { return 0; }
2477  virtual void setCookingRender(int val);
2478 
2479  virtual void clearInterrupted()
2480  { clearInterruptedImpl(/*allow_recook*/true); }
2481  bool wasInterrupted() const
2482  { return flags().getInterrupted(); }
2483 
2484  // work-around to display warning message when export src or destination
2485  // are renamed. OP_Node::cook clears the error messages when a node export
2486  // changes so we had to save the fact that a rename conflict is pending
2487  void setRenameConflict()
2488  { myRenameConflict = 1; }
2489  void setRunningCreateScript(int onoff);
2490 
2491  // Base class methods to output code to a file or a stream:
2492  virtual int outputCode(OP_OutputCodeParms &, OP_Context &);
2493 
2494  virtual fpreal getTimeTransform(int input, fpreal t);
2495  virtual void getInputRes(int input, fpreal t,
2496  const OP_Context &context,
2497  OP_Context &input_context);
2498 
2499  // Utility methods:
2500  UT_TokenString & getHashCode(OP_Context &context, int group_mask =1);
2501  virtual UT_TokenString & getParmHashCode(OP_Context &context,
2502  int group_mask = 1);
2503 
2504  virtual int getNumInputsToHash();
2505  virtual OP_Node *getInputToHash(int i);
2507  void clearHashCodeFlags();
2508  bool isHashCodeBuilt() const { return myBuiltHashCode;}
2509  void builtHashCode(bool b = true) { myBuiltHashCode = b; }
2510  void buildInputHashCode(UT_TokenString &string,
2511  OP_Context &context,
2512  int group_mask,
2513  int level);
2515  // If an interactive state was used to create this node, set it here.
2516  void setCreatorState(const char *s)
2517  { myCreatorState.harden(s); }
2518  const UT_String &getCreatorState() const { return myCreatorState; }
2519  void builtExplicitly(int yn) { myBuiltExplicitly = yn; }
2520  int wasBuiltExplicitly() const{ return myBuiltExplicitly; }
2521 
2522  bool matchesState(const char *state) const;
2523 
2524  /// Some nodes (VOPs and SHOPs) represent shaders, so this method
2525  /// returns node parameters that are used as shader parameters.
2526  virtual const PRM_Template *getShaderParmTemplates();
2527 
2528  // Don't even think about calling changeParmTemplate if you aren't
2529  // OP_Operator.
2530  virtual void changeParmTemplate(PRM_Template *new_template);
2531 
2532  // Deletes any input or output connections in excess of maximum allowed.
2533  virtual void ensureInputsAndOutputsAreValid();
2534 
2535  // Connect the node to an input. If branch_off is false and the input node
2536  // currently has outputs, the node will be inserted before the outputs.
2537  void connectToInputNode(OP_Node &inputnode, int input_idx,
2538  int branch_off=0);
2539 
2540  // This method should be called when the user edits an overridden channel
2541  virtual int editCallback(CL_Track *track, fpreal t,
2542  fpreal newValue);
2543 
2544  // This mechanism allows users to communicate editing changes
2545  static OP_EditCallback getEditCallback(void *&data);
2546  //static void setEditCallback(OP_EditCallback func,
2547  //void *data);
2548 
2549  // These build an xform matrix based upon the given parameters.
2550  // The axis is the axis around which to rotate by 90 degrees. If
2551  // it is lower case, it will be rotated by +90, if it is upper case,
2552  // by -90. To not rotate at all, use '-'.
2553  static void buildQuadricXform(UT_Matrix4 &mat,
2554  float tx, float ty, float tz,
2555  float sx, float sy, float sz,
2556  char axis = 'y',
2557  float rx = 0.0f, float ry = 0.0f,
2558  float rz = 0.0f);
2559 
2560  static void buildQuadricXform(UT_DMatrix4 &mat,
2561  double tx, double ty, double tz,
2562  double sx, double sy, double sz,
2563  char axis = 'y',
2564  double rx = 0.0, double ry = 0.0,
2565  double rz = 0.0);
2566 
2567  static int buildOpMenu(OP_Network *net, PRM_Name *theMenu,
2568  int theMenuSize, int (*doAdd)(OP_Node *) = 0,
2569  int startItem = 0, const PRM_Parm *parm = 0,
2570  int showSubnets = 1, int expandSubnets = 1,
2571  bool recurse = false);
2572 
2573  // Build the "Predefined Rules" menu that is common to several OPs
2574  // including Event and Group POPs. This is built from the text file table
2575  // OP<name>Rules, where name is the OP type (ie Event).
2576  static void buildPreDefRulesMenu(PRM_Name *menu,
2577  OP_PreDefRules &pdr);
2578 
2579  // Allows operators to use their own local table for variables and build
2580  // structures on demand... Implement the syntax highlight version only
2581  // if you need to resolve variables for syntax highlighting that are not
2582  // normally resolved by the generic resolveVariable() method.
2583  virtual const CH_LocalVariable *resolveVariable(const char *name);
2584  virtual const CH_LocalVariable *resolveExtraVariableForSyntaxHighlight(
2585  const char *name);
2586 
2587  // This value bumps whenever nodes are created/deleted/renamed.
2588  static int getNameSerialIndex();
2589 
2590  // export mapping techniques
2591  virtual void setMapping(int idx, int type, const char *label = 0);
2592  virtual int getMapping(int idx, const char *&label) const;
2593 
2594  // drag-n-drop receive methods
2595  virtual int acceptDragDrop(DD_Source &src, const char *label);
2596  virtual int testDragDrop(DD_Source &src);
2597  virtual void getDragDropChoice(DD_Source &src, DD_ChoiceList &c);
2598 
2599  // These methods are used to give quick overview information about a node
2600  bool hasComment() const;
2601  bool hasParmsNotAtFactoryDefault() const;
2602  bool hasAnimatedParms() const;
2603  bool hasChopOverriddenParms() const;
2604 
2605  /// traverseInputs calls 'callback' on this node and all its inputs.
2606  /// If callback returns true for any node, it will stop and return
2607  /// true, otherwise it will return false;
2608  /// @param callback Callback function
2609  /// @param data User data passed to the callback function
2610  /// @param opts A set of flags to configure the traversal:
2611  /// TRAVERSE_INTO_SUBNETS If input is a subnet, we continue
2612  /// traversing from its display node.
2613  /// TRAVERSE_REF_INPUTS Follow inputs marked as reference inputs
2614  /// TRAVERSE_ONLY_USED_INPUTS Follow only inputs used in the last cook
2615  /// TRAVERSE_PASSTHROUGH_INPUTS Use the getPassThroughNode to traverse
2616  /// through nodes that directly steal their
2617  /// input node's data.
2618  /// TRAVERSE_EXTRA_INPUTS Follow nodes which this node implicitly
2619  /// depends on.
2620  /// TRAVERSE_SIMULATION_INPUTS For nodes that are DOP parents, grab extra
2621  /// inputs from the simulation.
2622  /// TRAVERSE_COOKED_INPUT_INDEX_INPUTS
2623  /// Uses the cookedInputIndex method to
2624  /// traverse "passthrough"-type inputs for
2625  /// nodes that might trigger a cook when
2626  /// calling getPassThroughNode, but where we
2627  /// want to avoid triggering a cook.
2628  /// @param extra_interest_mask For extra inputs, this mask allows one to
2629  /// restrict which of those dependency types
2630  /// follow.
2631  //@{
2633  TRAVERSE_DEFAULT = 0x0000,
2634  TRAVERSE_INTO_SUBNETS = 0x0001,
2635  TRAVERSE_REF_INPUTS = 0x0002,
2636  TRAVERSE_ONLY_USED_INPUTS = 0x0004,
2637  TRAVERSE_PASSTHROUGH_INPUTS = 0x0008,
2638  TRAVERSE_EXTRA_INPUTS = 0x0010,
2639  TRAVERSE_SIMULATION_INPUTS = 0x0020,
2640  TRAVERSE_COOKED_INPUT_INDEX_INPUTS = 0x0040,
2641  };
2642  bool traverseInputs(bool (*callback)(OP_Node &, void *),
2643  void *data,
2644  TraverseOptions opts,
2645  OP_InterestType extra_interest_mask =
2646  OP_INTEREST_ALL);
2647  bool traverseInputs(bool (*callback)(const OP_Node &, void*),
2648  void *data,
2649  TraverseOptions opts,
2650  OP_InterestType extra_interest_mask =
2651  OP_INTEREST_ALL) const;
2652  //@}
2653 
2654  /// Using this node as a starting point, traverse our inputs recursively
2655  /// to get our best guess of the nodes that have been cooked to generate
2656  /// the current cooked result of this node.
2657  void getCookPathNodes(OP_NodeList &nodes);
2658 
2659  /// Traverses children of this node, calling 'callback' on all children.
2660  /// If callback returns true, the traversal stops at that node.
2661  bool traverseChildren(bool (*callback)(OP_Node &, void*),
2662  void *data,
2663  bool recurse_into_subnets);
2664 
2665  // Very specialized to see if this node (and optionally, any input
2666  // ancestors are also cooking.
2667  bool isCooking(bool include_ancestors) const;
2668 
2669  // This method returns true if the OP_Node makes use of its footprint
2670  // flag and false otherwise.
2671  virtual bool usesFootprint() const { return false; }
2672 
2673  void getExternalReferences(UT_StringArray &reflist,
2674  UT_StringArray *nodelist = 0,
2675  bool from_children_too = true,
2676  bool collapse = false,
2677  bool check_missing = false,
2678  bool show_missing_only = false);
2679  virtual bool getSaveWithVopnets();
2680  virtual void runDelScript();
2681  /// Overriden in VOPs to remove any channel refrences we may have
2682  /// to the node being deleted.
2683  virtual void preDelete() { }
2684 
2685  // Two functions for upcasting this node to a DOP_Parent. DOP_Parent
2686  // is a class which owns a simulation and has DOP_Nodes as children.
2687  virtual DOP_Parent *castToDOPParent() { return 0; }
2688  virtual const DOP_Parent *castToDOPParent() const { return 0; }
2690  // These provide a version which you can query without being above DOP.
2692  { return (OP_DopParent *) castToDOPParent(); }
2693  const OP_DopParent *castToOpDopParent() const
2694  { return (const OP_DopParent *) castToDOPParent(); }
2695 
2696  // This function upcasts this node to a VOP_CodeGenerator.
2697  // VOP_CodeGenerator is a class which generates VEX code from the VOPs
2698  // contained inside the node.
2699  virtual VOP_CodeGenerator *getVopCodeGenerator() { return 0; }
2701  virtual const VOP_CodeGenerator
2702  *getVopAutoCodeGenerator() const{ return 0; }
2703  // Some nodes will only generate vop code generators on demand, this
2704  // will ensure they are built.
2705  virtual void buildVopCodeGenerator() {}
2706 
2707  // Return the manager that handles exported parameters from contained
2708  // Parameter VOPs. Only certain kinds of VOP nodes can have such a manager
2709  // (i.e. Subnet VOPs, VOP HDAs). Note that a node cannot have both a code
2710  // generator AND a parms manager because the code generator already has its
2711  // own parms manager.
2712  virtual VOP_ExportedParmsManager *getVopExportedParmsManager(
2713  bool create_if_needed=false)
2714  { return nullptr; }
2715 
2716  /// @{
2717  /// Methods to postpone the update of the code generator until ending
2718  /// the last (level zero) update. This avoids recalculation of parameters
2719  /// and vop signatures, which can be quite costly.
2720  // TODO: remove these two virtuals in farour of getVopCodeGenerator()
2721  // returning OP_VopCodeGenerator from which VOP_CodeGenerator
2722  // derives and which has these two virtuals available at OP level.
2723  virtual int beginVopCodeGeneratorUpdate() { return 0; }
2724  virtual void endVopCodeGeneratorUpdate(int update_level) {}
2725  /// @}
2726 
2727  // Build a command line for a VEX script to be called with. This does all
2728  // the channel evaluation and string expansion required. If there is an
2729  // error, 0 is returned (otherwise 1).
2730  int buildVexCommand(UT_String &result,
2731  const PRM_Template *templatelist,
2732  fpreal now,
2733  int start_parm = 0,
2734  int end_parm = INT_MAX,
2735  bool use_parmvop_tag=true
2736  );
2737  int buildVexCommandWithDependencies(OP_Node *owner,
2738  DEP_MicroNode *depnode,
2739  UT_String &result,
2740  const PRM_Template *templatelist,
2741  fpreal now,
2742  int start_parm = 0,
2743  int end_parm = INT_MAX,
2744  bool use_parmvop_tag=true
2745  );
2746 
2747  // Builds a VEX script using standardized parameter names.
2748  // "vexsrc": int for myself, shop, or script.
2749  // "script": raw vex script
2750  // "soppath": for the shop path.
2751  static PRM_ChoiceList theVexSrcParmMenu;
2752  static PRM_Name theVexSrcParmName;
2753  static PRM_Name theVexScriptParmName;
2754  static PRM_Name theVexNodePathParmName;
2755  static PRM_Name theVexClearParmName;
2756  static PRM_Name theVexCWDName;
2757  virtual void buildVexScript(UT_String &script, fpreal t,
2758  OP_Node *owner,
2759  UT_Map<int, bool> *visitlist = 0);
2760  virtual void buildVexScript(UT_String &script, fpreal t,
2761  DEP_MicroNode *depnode,
2762  UT_Map<int, bool> *visitlist = 0);
2763 
2764 
2765  // Returns true if vex shader has parameter by a given name.
2766  virtual bool hasVexShaderParameter(const char *parm_name);
2767 
2768 
2769  /// This function returns a string that encodes all the necessary
2770  /// information about a node-based material that helps the script-based
2771  /// materials to function properly. The string usually encodes info stored
2772  /// on child nodes, such as rendering properties or procedurals. Then
2773  /// the script node can use that info to provide necessary data
2774  /// for rendering.
2775  /// Returns true if the method provides usable information.
2776  virtual bool getScriptMaterialInfo( UT_String & mat_info,
2777  VOP_ScriptMaterialCodeMapper * mapper )
2778  { return false; }
2779 
2780  /// Returns the sub type name, if the node's operator wants to be
2781  /// saved as an HDA in a special way (ie, other than the regular
2782  /// scripted operator handling). The sub type name is then used
2783  /// to distinguish how to handle the HDA creation.
2784  virtual const char *getHDASubType()
2785  { return 0; }
2786 
2787  // Set the channel alias for a channel (or parm subindex). Returns true
2788  // if successful and false otherwise.
2789  bool setChannelAlias(PRM_Parm &parm, int subindex,
2790  const char *alias_name);
2791 
2792  void disconnectAllInputsOutputs(bool keepSelected,
2793  bool forceDisconnectOutputs = false);
2794 
2795  void disconnectAllInputs();
2796  void disconnectAllOutputs();
2797 
2798  // Notify dependents that a parm name has changed.
2799  virtual void notifyParmRenameDependents(
2800  const UT_String &chan_name,
2801  const UT_String &old_chan_name );
2802 
2803  void writeChannel(CH_Channel *channel, std::ostream &os,
2804  const char *name, bool frames);
2805  void writeAllChannels(std::ostream &os, const char *name,
2806  bool frames, bool dochblock,
2807  bool dospareparms);
2808 
2809  // Run the callback function for a particular parm, and the callbacks
2810  // of any parms linked to this parm. Returns false if the node is
2811  // deleted while running the callback.
2812  bool triggerParmCallback(
2813  PRM_Parm *parmptr,
2814  fpreal now,
2815  int value,
2816  void *data,
2817  const UT_Options *options = nullptr) override;
2818 
2819  int64 getMemoryUsage(bool inclusive) const override;
2820  int64 getExtraInputMemoryUsage() const;
2821  static void printOpMemoryUsageStats(std::ostream &os);
2822 
2823  /// This method will unscope all the channels belonging to this op.
2824  /// If the recurse flag is set it will recurse through the children
2825  /// (at this level the recurse flag is ignored).
2826  virtual void unscopeChannels(bool recurse);
2827 
2828  /// This method will undisplay all the channels belonging to this op.
2829  /// If the recurse flag is set it will recurse through the children
2830  /// (at this level the recurse flag is ignored).
2831  virtual void undisplayChannels(bool recurse);
2832 
2833  /// This method will unpin all the channels belonging to this op.
2834  /// If the recurse flag is set it will recurse through the children
2835  /// (at this level the recurse flag is ignored).
2836  virtual void unpinChannels(bool recurse);
2837 
2838  /// This method takes a pattern string and will perform the ch_scope_op
2839  /// on each of our paramaeters that match the pattern. This method
2840  /// primarily supports the chscope command.
2841  virtual void setChannelScope(const char *pattern,
2842  OP_ScopeOp scope_op,
2843  const OP_ScopeOptions &scope_opts);
2844 
2845  /// A simple wrapper around getName() to allow us to abstract its
2846  /// functionality up to OP_NetworkBoxItem.
2847  const UT_String &getItemName() const override
2848  { return getName(); };
2849  bool setItemName(const UT_String &name) override;
2850 
2851  /// Caches the descriptive name to member data, and returns that. The
2852  /// cache is automatically dirtied in opChanged.
2853  const UT_StringHolder &getCachedDescriptiveName();
2854 
2855  // This function is called when our spare parm definition is changing.
2856  bool changeSpareParms(UT_IStream &istream,
2857  UT_String &errors) override;
2858  // This function is called during the changeSpareParms operation when
2859  // one of our parameters is being removed.
2860  void spareParmRemoved(const char *parmname) override;
2861 
2862  // This is a secondary parm list where all obsolete parameters are
2863  // placed (if any)
2866  PRM_ParmList *&obsolete_parms) override;
2867 
2868  unsigned referenceAllParameters(
2869  OP_Parameters *from,
2870  bool relative_references = true) override;
2871 
2872  void clearVersionUserData();
2873  void updateVersionUserData();
2874 
2875  /// After the nodes parameter list is loaded, syncNodeVersionIfNeeded() is
2876  /// called to perform any necessary upgrades if the version number of
2877  /// the loaded node (taken from user data) is different from the node
2878  /// type's version number (getOperator()->getVersion()). Use the
2879  /// from_version parameter to override the node current version.
2880  /// If needed, this will call syncNodeVersion(). After synching, the node's
2881  /// version user data will be set to the current version if
2882  /// update_node_version is true.
2883  void syncNodeVersionIfNeeded(
2884  bool *node_deleted,
2885  const char *from_version = nullptr,
2886  bool update_node_version = false);
2887 
2888  /// Sync the node assuming that it is currently at old_version to the
2889  /// current_version. By default, this will call the corresponding
2890  /// OTL_SYNCNODEVERSION section if it exists.
2891  void syncNodeVersion(
2892  const char *old_version,
2893  const char *current_version,
2894  bool *node_deleted) override;
2895 
2896  // Sets the given stamping parameter.
2897  // Returns true if the param was changed. Note that we may return false
2898  // even if this was a valid operation as param might have already been
2899  // set to the given value.
2900  // If the warned variable is given, then we only warn if its contents
2901  // is false. Then in that case, we will set it to true when needed.
2902  bool setGlobalFloatParam(const char *param,
2903  fpreal value,
2904  bool *warned);
2905  bool setGlobalStringParam(const char *param,
2906  const char *strvalue,
2907  bool *warned);
2908 
2909  // This allows one to prevent chop cooking due to parameter modifications
2910  // until the outermost block is done.
2911  void beginPropagateModification();
2912  void endPropagateModification();
2913 
2914  // Add any OTL-defined operators used by this node to the specified table.
2915  virtual void getActiveOperatorsDefinedByOTL(
2916  UT_Set<OP_Operator *> &active_operators) const;
2917 
2918  // Returns true if we are in the middle of a call to sendBulkNotifications,
2919  // Or doing some other operation that involves sending out a whole bunch
2920  // of change notifications all at once. This allows VOP Networks to avoid
2921  // over-cooking.
2922  static bool getDoingBulkNotification();
2923  static bool isDirectorDoingBulkNotification();
2924 
2925  /// Returns whether multi-inputs on this particular op might have different
2926  /// names for each of the inputs, or if the name will always be the same for
2927  /// all the inputs.
2928  virtual bool hasDifferentMultiInputs() const;
2929 
2930 
2931  virtual bool canCreateNewOpType() const;
2932  static bool createNewOpType
2933  (OP_Node *node,
2934  UT_String &errors,
2935  const char *typeName=nullptr,
2936  const char *typeLabel=nullptr,
2937  const char *otlFile=nullptr,
2938  const char *metaSource=nullptr,
2939  const char *comment=nullptr,
2940  const char *version=nullptr,
2941  const char *newName=nullptr,
2942  int minimumInputs=-1,
2943  int maximumInputs=-1,
2944  bool ignore_external_references=false,
2945  bool compress_contents=false,
2946  bool force=false,
2947  int *newNodeId=nullptr,
2948  bool compile_contents = false,
2949  bool change_node_type = true,
2950  bool create_backup = true);
2952  virtual UT_String *getMaterialIconFilename() { return 0; }
2953  virtual void setMaterialIconFilename(const char * /*icon_file*/) {}
2954  virtual IMG_Raster *getMaterialIconImage() { return 0; }
2955  virtual bool getMaterialIconAllowRegenerateFlag() { return true; }
2956  virtual void setMaterialIconAllowRegenerateFlag(bool) {}
2957 
2958  // Call these functions when making a lot of calls to opChanged on a
2959  // list of nodes. These functions make sure that VOP Networks only get
2960  // one change notification no matter how many child nodes are about
2961  // to send any number of change events.
2962  // @parm caller The node that starts the bulk notifications, if applicable.
2963  static void startBulkNotifications(
2964  const OP_NodeList &changed,
2965  OP_Node *caller = nullptr);
2966  static void endBulkNotifications(
2967  const OP_NodeList &changed);
2968 
2969  /// This is overriden in VOPs. It returns true if the input at input_idx
2970  /// will need *and* can perform autoconversion of its input type to the
2971  /// type it needs. If autoconversion is not needed, or is impossible,
2972  /// this will return false.
2973  virtual bool willAutoconvertInputType(int input_idx);
2974 
2975  bool isDependentOn(OP_Node* other_node, PRM_Parm* parm);
2976 
2977  // Gets whether the input at idx is collapsed. Currently this is only used
2978  // in VOPs.
2979  virtual bool getIsInputVisibleDefault(int idx);
2980 
2981  // Debugging function to confirm that all PRM_Template's are consistent
2982  // with their parameters.
2983  bool verifyTemplatesWithParameters() const;
2984 
2985  // Same as getInputReference, except using a named reference.
2986  OP_Input *getNamedInputReference(
2987  const OP_ConnectorId& input_name, bool grow);
2988  OP_Input *getNamedInputReferenceConst(
2989  const OP_ConnectorId& input_name) const;
2990 
2991  OP_Node *getNamedInput(const OP_ConnectorId& input_name,
2992  bool mark_used=false) const;
2993  /// Note that this function only looks through currently connected
2994  /// inputs for the name, not through all possible input names on
2995  /// this node. mapInputNameToIndex does that instead.
2996  virtual int getInputFromName(const UT_String &in) const;
2997  virtual int getOutputFromName(const UT_String &out) const;
2998  virtual void getInputName(UT_String &in, int idx) const;
2999  virtual void getOutputName(UT_String &out, int idx) const;
3000  static UT_StringHolder defaultInputName(int idx);
3001  static UT_StringHolder defaultOutputName(int idx);
3002 
3003  int getInputFromUniqueName(
3004  const OP_ConnectorId& id) const;
3005  int getOutputFromUniqueName(
3006  const OP_ConnectorId& id) const;
3007 
3008  // Returns the unique name of the input at index idx. Creates the input if
3009  // grow is set to true.
3010  void getUniqueInputName(
3011  OP_ConnectorId& id_out, int idx, bool grow);
3012  bool getUniqueInputNameConst(
3013  OP_ConnectorId& id_out, int idx) const;
3014 
3015  void getUniqueOutputName(OP_ConnectorId& id_out, int idx);
3016  bool getUniqueOutputNameConst(
3017  OP_ConnectorId& id_out, int idx) const;
3018 
3019  /// New input functions that use names instead of indices.
3020  virtual OP_ERROR setNamedInput(const OP_ConnectorId& input_name,
3021  OP_Node *op,
3022  const OP_ConnectorId* output_name = nullptr);
3023 
3024  virtual OP_ERROR setNamedIndirectInput(
3025  const OP_ConnectorId& input_name,
3026  OP_IndirectInput *input);
3027  virtual OP_ERROR setNamedInputReference(
3028  const OP_ConnectorId& input_name,
3029  const char *label, int,
3030  const OP_ConnectorId* output_name = nullptr);
3031 
3032  OP_ERROR insertNamedInput(
3033  const OP_ConnectorId& input_name, OP_Node *op,
3034  const OP_ConnectorId* output_name);
3035  OP_ERROR insertNamedIndirectInput(
3036  const OP_ConnectorId& input_name,
3037  OP_IndirectInput *input);
3039  /// Overriden in VOPs.
3040  virtual void onCreated() { }
3041 
3042  virtual bool isOrderedInput(const OP_ConnectorId& input_name) const;
3043 
3044  /// Returns the name of the first connection from node "who" to this node,
3045  /// or an empty string if "who" is not an input.
3046  OP_ConnectorId whichNamedInputIs(const OP_Node *who) const;
3047 
3048  /// Returns the index of the first connection of an indirect input.
3049  OP_ConnectorId whichNamedInputIs(const OP_IndirectInput *who) const;
3050  virtual bool willAutoconvertNamedInputType(
3051  const OP_ConnectorId& input_name);
3052 
3053  /// Note: Use these carefully, since they assume that no inputs are actually
3054  /// added or removed (or renamed) during the traversal.
3055  OP_ConnectorInputIter traverseInputs(OP_ConnectorInputIter* prev_iter);
3056  OP_ConnectorInputIter traverseConnectedInputs(OP_ConnectorInputIter* prev_iter);
3057  OP_ConnectorInputIter getTraverseEndIterator();
3058 
3059  unsigned getInputsArraySize()
3060  { return myInputs.entries(); }
3061  /// Deprecated in favour of getInputsArraySize()
3062  SYS_DEPRECATED(17.0) unsigned isInput(unsigned idx)
3063  { return (getInputsArraySize() > idx) ? 1 : 0; }
3064 
3065  /// Retrieve a sorted list of local variables visible to this OP_Node.
3066  void getLocalVarNames(UT_StringArray &out_vars);
3067 
3068  // Forcibly enable evaluation of local variables outside of cooking code
3069  // paths so that the last cooked value can be used for things like
3070  // pivot values for handles.
3071  bool setLocalVarActive(bool f)
3072  {
3073  bool old = myLocalVarActive;
3074  myLocalVarActive = f;
3075  return old;
3076  }
3078  /// Get the myLocalVarActive flag
3079  bool isLocalVarActive() const
3080  { return myLocalVarActive; }
3081 
3082  /// Return a UT_AttributeEvaluator for dealing with the evaluation of
3083  /// local variables designated by an "@" prefix.
3084  virtual UT_AttributeEvaluator *createAttributeEvaluator(const char *name);
3085  virtual void getAttributeEvaluatorNames(UT_StringArray &names);
3086 
3087  void recomputeCompiledHash();
3088 
3089  /// Clears the compiled hash (needed when switching from a compiled library
3090  /// definition to one that is not compiled).
3091  void clearCompiledHash()
3092  { myCompHash = DEFAULT_COMP_HASH_VALUE; }
3093 
3094  /// You should use opChanged() instead. This is only for very special
3095  /// cases. If you don't know you are a special case, you aren't.
3096  void directSendEvent(OP_EventType type, void *data=0)
3097  { sendEvent(type, data); }
3098 
3099  virtual bool scopedChannelsDirty();
3100 
3101  /// This mechanism allows users to evaluate active layer contribution
3102  /// without needing to link against CHOP.
3103  virtual bool getActiveLayerContribution(const UT_String &track_name,
3104  fpreal t, fpreal &value, fpreal &weight)
3105  { return false; }
3106 
3107  /// Try to resolve exports on CHOP Channel Nodes from a value parameter
3108  /// within the array.
3109  virtual bool resolveExport(const PRM_Parm* p, int subindex,
3110  CH_ChannelRef& out_export )
3111  { return false; }
3112 
3113  /// Creates or moves an existing visualizer in this network to
3114  /// this nodes output.
3115  virtual bool addOrMoveVisualizerToOutput(int outputidx)
3116  { return false; }
3117 
3118  const PRM_Parm *traverseRef(
3119  int *sub_idx,
3120  fpreal time,
3121  int parm_idx,
3122  int vec_idx) const override;
3123 
3124  OP_Bundle * getParmBundle(const char* parm_name, int vector_index,
3125  UT_String &pattern, OP_Network *creator,
3126  const char *filter, bool subnet_inclusion);
3127 
3128  /// For node types with no other default color override, this is the
3129  /// final fallback default color for all nodes.
3130  static const UT_Color &getGlobalDefaultColor();
3131 
3132  /// The following methods are to be used to implement getW() and getH() in
3133  /// sub-classes. They are in absolute, pan-and-scale independent UI units.
3134 
3135  /// Get the width of flags.
3136  static fpreal getFlagWidth();
3137  /// Get the default node height.
3138  static fpreal getNodeHeight();
3139  /// Get the default width of the "node button" (the part of the node
3140  /// that you can drag and click on that isn't flags).
3141  static fpreal getNodeButtonWidth();
3142  /// Get the default connector height.
3143  static fpreal getConnectorHeight();
3144 
3145  /// Returns true if we are allowed to destroy the specified nodes. If
3146  /// nodes is non-null, we test those nodes. If nodes is null, we test
3147  /// the picked nodes of the src_net. The return value assumes that all
3148  /// specified nodes will be destroyed, which is important because it
3149  /// may be safe to delete node A iff node B is also going to be deleted.
3150  static bool canDestroyNodes(OP_Network *src_net,
3151  const OP_NodeList *nodes);
3152 
3153  /// Add an error to the given error manager, collapsing chains
3154  /// of invalid sources.
3155  static void addInputNodeErrorToManager(UT_ErrorManager *error,
3156  OP_Node *src);
3157 
3158  /// Must be implemented to associate this node to a viewer state.
3159  /// @parm default_state_name should be set with the viewer state type name.
3160  /// OP_Node implementation first looks for a 'viewerstate' node string
3161  /// parameter. The parameter can be added as a spare parameter to any node.
3162  /// If the node is an HDA it can define a default state section.
3163  /// Otherwise, the operator name is returned as a default state name.
3164  virtual void getDefaultState(UT_String &default_state_name);
3165 
3166  // If this node sets a context option to a specific value, we can clear
3167  // this option dependency for this node (and its outputs), because we
3168  // know that changing this option value past this node won't affect the
3169  // cooking of our input nodes, even if they use this context option. One
3170  // exception to this is if this node sets the context option as a
3171  // function of the option value handed to it. This exception is dealt with
3172  // when transferring option dependencies from our inputs to this node.
3173  //
3174  // Another exception is when the context used to cook this node has a
3175  // non-default (i.e. set by a node) value for the option. Because our
3176  // context option change may get "popped" by a node higher up the chain,
3177  // we must assume that nodes above this "pop" node depend on this option
3178  // set by one of our outputs, so we need to recook when that node changes
3179  // option value (even though we overwrite it). This isn't a problem when
3180  // the option is set to a default value because dependencies on default
3181  // values are tracked by micro nodes, so changing the default will force
3182  // a recook from the top of the chain. Testing for this case is why we
3183  // need to be passed the context passed to this nodes cook method.
3184  void clearInputContextOptionDepIfSafe(
3185  const UT_StringHolder &opt,
3186  const OP_Context &context);
3188  // CHOP Transform Tracks
3189  virtual bool hasTransformTracks() const { return false; }
3190  virtual bool evaluateTransformTracks( OP_Context &context, OP_EvaluateTransformTracksArgs &args ) { return false; }
3191  virtual bool evaluateTransformTracksTargets( OP_Context &context, OP_NodeList &nodes, OP_Node *caller) { return false; }
3192 
3193 
3194 protected:
3195 
3196  OP_Node(OP_Network *parent, const char *name, OP_Operator *entry);
3197  ~OP_Node() override;
3198 
3199  /// Implement the method from PRM_ParmOwner
3200  void doGetFullPath(UT_WorkBuffer &str) const override;
3201 
3202  /// Retrieve a list of the local variables visible to this OP_Node.
3203  /// This list is unsorted and may contain duplicates.
3204  virtual void buildLocalVarNames(UT_StringArray &out_vars);
3205 
3207  const UT_StringRef &function) const override;
3208 
3209  /// Resolves any inputs for which the names were not found during
3210  /// actual loading.
3211  void resolveUnresolvedLoadedInputs();
3212 
3213  /// Called when loadNetwork finishes loading the whole parent network of
3214  /// this node.
3215  void finishedLoadingParentNetwork();
3216 
3217  void setNewParent( OP_Network *new_parent );
3218 
3219  static void bumpNameSerialIndex();
3220 
3221  /// @{
3222  /// Methods to disallow node deletion during the execution of a script.
3223  void beginScriptBlockingDel()
3224  { myScriptsBlockingDelCount += 1; }
3225  void endScriptBlockingDel()
3226  { myScriptsBlockingDelCount -= 1; }
3227  /// @}
3228 
3229  void setLegacyConnectingInputIndex(int index)
3230  { myLegacyConnectingInputIndex = index; }
3231 
3232  // All external references must be removed by the time this function
3233  // returns!
3234  virtual void clearAndDestroy();
3235 
3236  // invalidate any cached data
3237  virtual void clearCache();
3238 
3239  void clearInterruptedImpl(bool allow_recook);
3240 
3241  // "cookMe" is where the actual work is done.
3242  // The error is returned (OP_ERR_NONE on success).
3243  virtual OP_ERROR cookMe(OP_Context &context) = 0;
3244 
3245  // "bypassMe" is used to cook the op when the bypass flag is set.
3246  // The copied_input parameter should be set to indicate which input was
3247  // copied. Use -1 if no input was copied.
3248  // The error is returned (OP_ERR_NONE on success).
3249  virtual OP_ERROR bypassMe(OP_Context &context, int &copied_input) = 0;
3250 
3251  // The following two functions are called from evaluateAllParms() so that
3252  // subclasses may hook into it to do some work before and after evaluating
3253  // all the parameters.
3254  virtual void doOverridePreCook() { }
3255  virtual void doOverridePostCook() { }
3256 
3257  // These "serial" numbers are used for keeping track of how many sources
3258  // are accessing us. Only call getSourceCount() when locked inside
3259  // getCookLock()!
3260  int getSourceCount() const;
3261  virtual int bumpSourceCount(int d);
3262 
3263  // This is what you should override to do your own OP specific cooking.
3264  // This should not be called other than from pubCookInputGroups.
3265  virtual OP_ERROR cookInputGroups(OP_Context &context, int alone = 0);
3266 
3267  // I/O methods
3268  virtual OP_ERROR saveIntrinsic(std::ostream &os,
3269  const OP_SaveFlags &flags);
3270  virtual OP_ERROR save(std::ostream &os, const OP_SaveFlags &flags,
3271  const char *path_prefix = "",
3272  const UT_String &name_override = UT_String());
3273  OP_ERROR saveUserDataPacket(std::ostream &os,
3274  const char *path_prefix,
3275  const UT_String &node_name);
3276 
3277  bool loadIntrinsicParentUneditable(UT_IStream &is,
3278  const char *path=0);
3279  bool loadIntrinsic(UT_IStream &is, const char *path=0);
3280  virtual bool loadPacket(UT_IStream &is, short class_id,
3281  short sig, const char *path=0);
3282  virtual bool loadPacket(UT_IStream &is, const char *token,
3283  const char *path=0);
3284  virtual bool load(UT_IStream &is,
3285  const char *ext="",
3286  const char *path = 0);
3287 
3288  // load only things that that an uneditable parent deems uneditable, e.g.
3289  // input/output connections. This is so that it can be matched to the OTL
3290  // rather than the editable contents of a node.
3291  bool loadParentUneditable(UT_IStream &is,
3292  const char *ext="",
3293  const char *path = 0);
3294 
3295  // this called when the entire network is done loading
3296  virtual void loadStart();
3297  virtual void loadFinished();
3298 
3299  // Loads the OTL_CONTENTS_SECTION for our OTL definition, if it exists,
3300  // using the syncContents method.
3301  void loadContentsSection();
3302 
3303  // This is a dummy virtual that just exists to be overridden by
3304  // OP_Network. See that class for more description.
3305  virtual bool syncContents(UT_IStream &is);
3306 
3307  /// Sets the flag idicating if the node is synced (matched) to the HDA.
3308  void setMatchesOTLDefinition(int matches);
3309 
3310  virtual const char *getFileExtension(int binary) const = 0;
3311  virtual const char *getDataFileExtension(int binary) const;
3312 
3313  /// This will set the time dependent flag based on parms, inputs and/or
3314  /// extra (non-graph) inputs. This can be overridden by subclasses to have
3315  /// more control over a node's time dependent flag by forcibly calling the
3316  /// bass class method with false for these parameters.
3317  ///
3318  /// @param do_parms Controls whether this node should become time dependent
3319  /// if any of its own cooking parameters are time dependent.
3320  /// @param do_inputs Controls whether the node should become time dependent
3321  /// if any of its used inputs are time dependent
3322  /// @param do_extras Controls if this node should become time dependent if
3323  /// any of the "extra" inputs (see
3324  /// OP_Node::addExtraInput()) nodes are time dependent.
3325  /// These extra inputs typically nodes referenced by the
3326  /// expressions on this node's parameters.
3327  virtual void checkTimeDependencies(int do_parms=1,
3328  int do_inputs=1,
3329  int do_extras=1);
3330  // This will gather context option dependencies based on parms,
3331  // inputs and extra (non-graph) inputs. These dependencies are
3332  // applied to the data micro node and the node itself.
3333  virtual void checkContextOptionDependencies(int do_parms);
3334 
3335  // To allow our sub-classes to send events, we make this protected.
3336  void sendEvent(OP_EventType type, void *data=0);
3337 
3338  // haveSeenDataModification() can be used by sub-classes to decide if they
3339  // need to respond to a particular modification notice.
3340  int haveSeenDataModification(exint modification_id);
3341 
3342  // If you sub-class propagateModification, then be sure to call this
3343  // OP_Node base class method *last*.
3344  //
3345  // This routine will return TRUE if the modification is a new one for this
3346  // node. FALSE will be returned if the modification has been seen before.
3347  //
3348  // Note that "by_whom" is the immediate input node that caused the
3349  // propagation to "this" node.
3350  virtual int propagateModification(OP_Node *by_whom,
3351  OP_EventType reason,
3352  int parm_index,
3353  OP_PropagateData &prop_data);
3354 
3355  // Use this to obtain the cook cache.
3356  // @pre The caller has locked myCookLock if it is currently being cooked.
3357  OP_Cache * getCookCache() { return &myCache; }
3358 
3359  static void cmd_locate(CMD_Args &);
3360 
3361  virtual void saveFlagsForUndo();
3362  void saveForUndoLayout();
3363 
3364  static void saveForUndoDelete(OP_NodeList &nodes);
3365 
3366  /// Clears all cook dependencies (i.e., items that may cause it to cook)
3367  void clearDependency();
3368 
3369  /// This function will dirty our data if the given time is different from
3370  /// our last cooked time.
3371  ///
3372  /// This function is normally called from cook() but subclasses can prevent
3373  /// this with flags().setClearDependency(false). In that case, subclasses
3374  /// are responsible for calling this function at the appropriate time. This
3375  /// is primarily for nodes which cache their data across time. In that
3376  /// case, if they did _not_ reuse their cached data, then
3377  /// dirtyForTimeChange() needs to be called.
3378  ///
3379  /// @returns true if node was dirtied, false otherwise.
3380  bool dirtyForTimeChange(fpreal t)
3381  {
3382  if (isCookedTime(t))
3383  return false;
3384 
3385  OP_DataMicroNode &dm = dataMicroNode();
3386  OP_DataMicroNode &pm = parmListMicroNode();
3387  dm.setDirty(true);
3388  if (&dm != &pm && pm.isTimeDependent())
3389  pm.setDirty(true);
3390 
3391  return true;
3392  }
3393 
3394  // clone dependencies from the proxy. proxy is no longer valid
3395  // after the clone!
3396  virtual void cloneFromProxyRefNode( OP_Network *proxy );
3397  // clone a new proxy node. this node is no longer valid after this!
3398  virtual OP_Network * cloneToProxyRefNode();
3399  void stealDependents( OP_Node *other );
3400 
3401  bool hasOpDependents()
3402  { return !myOpDependents.isEmpty(); }
3403  virtual int hasProxyRefNodes() const
3404  { return 0; }
3405  virtual void moveProxyRefNodes( OP_Network * /*dest */ ) { }
3406  void clearOpReferences();
3407  virtual void rebuildOpDependents( bool proxy_only );
3408 
3409  /// removeOpDependent() returns the number of dependents removed
3410  virtual int removeOpDependent(
3411  int op_id, const PRM_RefId &ref_id,
3413  virtual int removeOpDependent(
3414  int op_id, OP_InterestType mask = OP_INTEREST_ALL );
3415 
3416  // new method for dependencies: use the PRM_TYPE_OP_REF_*
3417  // in your parm template to add your dependency.
3418  // override this to do special cases, make sure you call the base class
3419  // first before adding your own dependencies!
3420  void buildOpDependencies() override;
3422  CH_Channel *ch,
3423  CH_CHANGE_TYPE reason) override;
3424 
3425  void notifyOpDependents( OP_InterestType interest,
3426  bool recurse );
3427  virtual void moveDependencies( OP_Node *from_node );
3428  // Two functions for notifying dependent nodes of name changes. The
3429  // non-virtual function is the one that should be called to do the
3430  // update. It calls the virtual function to do the actual updating,
3431  // and generate a list of dependent nodes that were changed. Then it
3432  // forces a recook on the changed nodes.
3433  void notifyRenameDependents( const UT_String &full_from );
3434  virtual void notifyRenameDependents( const UT_String &full_from,
3435  OP_NodeList &cook_nodes );
3436  // Two functions for notifying referencing nodes of name changes. The
3437  // non-virtual function is the one that should be called to do the
3438  // update. It calls the virtual function to do the actual updating,
3439  // and generate a list of dependent nodes that were changed. Then it
3440  // forces a recook on the changed nodes.
3441  void notifyRenameReferences( const UT_String &full_from );
3442  virtual void notifyRenameReferences( const UT_String &full_from,
3443  OP_NodeList &cook_nodes );
3444  // this method is called to alert this op that its dependency has
3445  // changed. if it's a name interest, then the old full path is given
3446  virtual void handleOpDependency( int referenced_op_id,
3447  const OP_Dependency &op_dep,
3448  OP_InterestType interest_type,
3449  bool &need_cook,
3450  const char *old_fullpath,
3451  const char *old_cwd,
3452  const char *old_chan_name );
3453  virtual void buildParmDependency( int parm_index );
3454 
3455  void addOpNameReference(
3456  const PRM_RefId &ref_id, const UT_String &op_path,
3458  // chan_name must be real channel name not an alias
3459  void addChannelNameReference(
3460  const PRM_RefId &ref_id,
3461  const UT_StringRef &op_path,
3462  const UT_StringRef &chan_name,
3464 
3465  OP_Node *getNodeOrCreateProxy(const UT_StringRef &op_path);
3466 
3467  void addOpReference( const PRM_RefId &ref_id, OP_Node *node,
3468  const PRM_RefId &source_ref_id,
3470 
3471  void removeOpReference(
3472  const PRM_RefId &ref_id,
3474  void removeOpReference(
3475  const PRM_RefId &ref_id,
3476  int op_id,
3478 
3479  /// This function takes the given parm string value containing an op path
3480  /// and does a search and replace given the old and new op paths.
3481  ///
3482  /// value_str - the old parm value to modify
3483  /// new_fullpath - the new path value to change to
3484  /// old_fullpath - the old path that needs changing
3485  /// old_cwd - the old path that the parm value was relative to
3486  /// new_cwd - the new path that the parm value is to be relative to
3487  ///
3488  /// The reason for old_cwd & new_cwd is when collapsing a node into a
3489  /// subnet. We need to figure out the new path references of the collapsed
3490  /// subnet since it has changed location. We match using the old_cwd but
3491  /// take the new path relative to new_cwd. Note that in this situation,
3492  /// old_fullpath is the same as new_fullpath.
3493  bool changeOpPathRef( UT_String &value_str,
3494  const char *new_fullpath,
3495  const char *old_fullpath,
3496  const char *old_cwd,
3497  const char *new_cwd );
3498 
3499  // handy functions for dealing with string parms that can have the
3500  // op:/path[frame] syntax
3501  static bool getStringParmOpPath(
3502  PRM_Parm &parm, int vi, UT_String &oppath,
3503  int thread );
3504  void handleStringParmOpPathDependency(
3505  int parm_index, int vi,
3506  const char *new_fullpath,
3507  const char *old_fullpath, const char *old_cwd );
3508 
3509  // Only OP_Network should call notifyNodeDeletion()
3510  void notifyNodeDeletion();
3511 
3512  // Only notifyNodeDeletion() should call nodeDeleted().
3513  // nodeDeleted() - gets called every time a node is deleted
3514  virtual void nodeDeleted(OP_Node *op, int propagate=1);
3515 
3516  void startCookTimer(const OP_Context &context);
3517  void stopCookTimer(const OP_Context &context);
3518 
3519  virtual const char *getCookTimerLabel(const OP_Context &context) const;
3520 
3521  // Overrides permission errors so that we don't have problems when cooking.
3522  void permissionError(const char *chname = 0) override;
3523 
3524  // Add an error for the invalid input given by input_idx
3525  void addInputError(unsigned input_idx);
3526 
3527  // Add an error for the given node having failed to load.
3528  void addInputNodeError(OP_Node *src);
3529 
3530 protected:
3531  /// This function is currently only used by VOPs. It checks if an input
3532  /// on the subnet is connected inside the subnet. The default implementation
3533  /// here simply returns false to preserve existing behaviour for all other
3534  /// contexts.
3535  virtual bool isInputConnectedInsideSubnet(int input_idx) const;
3536  virtual bool isNamedInputConnectedInsideSubnet(
3537  const OP_ConnectorId& input_name) const;
3539  // notifier when this node is unlocked
3540  virtual void nodeUnlocked() { ; }
3541 
3542  // These functions must be used with care!
3543  virtual void setUniqueId(int id);
3544  void changeOpDependentUniqueId( int old_id, int new_id );
3545  void changeOpReferenceUniqueId( int old_id, int new_id );
3546  virtual void clearUniqueId();
3547 
3548  void setAllowBuildDependencies( int yesno )
3549  { myAllowBuildDependencies = yesno; }
3550  int allowBuildDependencies() const
3551  { return myAllowBuildDependencies; }
3552 
3553  /// Evaluate all parameters for this operator. This is used for scripted
3554  /// Ops to make sure that our dependencies get set up properly.
3555  void evaluateAllParms(fpreal t);
3556 
3557  /// Override and assign any external (file) references to the reflist,
3558  /// and if nodelist is non-null, the full pathname of the node with the
3559  /// reference.
3560  virtual void getMyExternalReferences(UT_StringArray &reflist,
3561  UT_StringArray *nodelist =0,
3562  bool collapse = false,
3563  bool check_missing = false,
3564  bool show_missing_only=false);
3565 
3566  void getExternalFiles(UT_StringArray &files,
3567  const char *stringparm,
3568  int framestart, int frameend,
3569  bool collapse,
3570  bool check_missing,
3571  bool show_only_missing,
3572  UT_KnownPath path);
3573 
3574  /// Rather than overloading the descriptive name, you can instead
3575  /// just provide a parameter name that will be evaluated to
3576  /// become the descriptive name.
3577  virtual void getDescriptiveParmName(UT_String &str) const;
3578 
3579  /// Additonal information that should be provided at the network
3580  /// level in addition to the name.
3581  /// By default will inspect the getDescriptiveParmName.
3582  virtual void getDescriptiveName(UT_String &str) const;
3583 
3584  /// Marks our cached descriptive name as dirty.
3585  void dirtyDescriptiveNameCache();
3586 
3587  /// Return true if it is safe at this time to destroy this node.
3588  virtual bool canDestroyNode();
3589 
3590  /// Override this to return true in an operator type that wants its
3591  /// cooked data to rely on all its parameter values but doesn't actually
3592  /// evaluate any parameters in its cook function (the prototypical
3593  /// example of this is SHOPs).
3594  virtual bool cookedDataUsesAllParameters() const
3595  { return false; }
3596  /// If the cook method relies on the base class cook to evaluate parameters
3597  /// (like in SHOPs), we need to trap the errors during this evaluation.
3598  virtual bool cookedDataNeedsErrors() const
3599  { return false; }
3600  /// If this node should be cooked for any output connected to it, return
3601  /// true here. Otherwise we only cook a node if something is connected to
3602  /// it's primary output. This does not let the node cook differently for
3603  /// each output, since the cook method doesn't know what output is being
3604  /// cooked for. So this should only be used if the cook is unaffected by
3605  /// the specific connected output.
3606  virtual bool cookDataForAnyOutput() const
3607  { return false; }
3608 
3609  // Returns true if we are running our creation script, or any parent
3610  // node of us is running its creation script.
3611  bool getIsRunningInCreateScript() const;
3612 
3613  /// This method is called whenever something in the network changes
3614  /// that may have an impact on the representative node this network may
3615  /// have. It is used at this level to notify parents, and at the OBJ level
3616  /// to actually refresh the representative object.
3617  virtual void refreshRepresentativeNode(OP_Node &changed_child);
3618 
3619  /// Sets up the inputs and outputs after all nodes have been loading
3620  /// from file (in case it needs its children to determine inputs/oututs).
3621  virtual void setupConnectorsAfterLoad();
3622 
3623  /// Converts opdef and oplib format paths from opdef:nodepath to
3624  /// opdef:tablename/optype.
3626  UT_String &str) const override;
3627 
3628  bool isCookedTime(fpreal t) const
3629  {
3630  return dataMicroNodeConst()
3631  .isEqualToLastUpdateTime(t);
3632  }
3633 
3634  /// Subclasses should override this to dump extra micronodes that they own
3635  /// for debugging purposes.
3636  virtual void dumpMicroNodes(
3637  std::ostream &os,
3638  bool as_DOT,
3639  int indent_level) const;
3642  UT_TokenString myHashCode; // Generates a unique
3643  UT_TokenString myParmHashCode; // parameters & inputs.
3644  int myLastGroupMask;
3645  OP_VERSION myHashVersion;
3646  fpreal myHashTime;
3647  int myParmLastGroupMask;
3648  OP_VERSION myParmHashVersion;
3649  fpreal myParmHashTime;
3650  UT_String mySyncErrors;
3651  OP_ERROR mySyncErrorLevel;
3652  int mySyncDepth;
3653 
3654  /// Deletes an input completely if it is disconnected. If the input
3655  /// is connected, does nothing.
3656  void deleteInput(int idx);
3657  void deleteInput(const OP_ConnectorId& input_name);
3658 
3659  /// Performs actual removal from the member input array.
3660  virtual void doDeleteInput(int idx);
3661 
3662  /// Update the error severity of this node.
3663  void updateErrorSeverity();
3665  /// Overriden in VOPs.
3666  virtual void onInputAllocated(OP_Input* new_input, int index) { }
3667 
3668  /// Debug method for checking connector consistency.
3669  void checkConnectorsConsistency();
3670 
3671  /// Use these to collect all inputs/outputs in cases where they will
3672  /// need to be modified.
3673  void gatherInputs(UT_Array<OP_InputPair> &input_pairs);
3674  void gatherOutputs(UT_Array<OP_OutputPair> &output_pairs);
3675 
3676  void renameInput(OP_Input* input, int new_id);
3677 
3678  void notifyChannelOpDependents(PRM_Parm * in_parm, int vecid);
3679  // Compiled hash code
3680  uint32 myCompHash;
3681 
3682 private:
3683 
3684  void updateSpareParmTemplates(
3685  PRM_Template *newtemplates,
3686  bool leavedefaultsunchanged) override;
3687 
3688  bool doDebugConsistencyCheck();
3689  void createCollection( OP_Operator *entry );
3690 
3691  // these are extra private. only to be called from saveIntrinsic and save
3692  // respectively
3693  OP_ERROR saveIntrinsicError();
3694  OP_ERROR saveError();
3695  OP_ERROR saveGroupMemberships(std::ostream &os,
3696  const OP_SaveFlags &flags,
3697  const char *path_prefix);
3698  bool loadGroupMemberships(UT_IStream &is,const char*path=0);
3699 
3700  ///Make a note of which network box we're in
3701  OP_ERROR saveNetworkBox(std::ostream &os,
3702  const OP_SaveFlags &flags,
3703  const char *path_prefix);
3704 
3705  ///Put ourselves into a network box if we saved ourselves as being in one
3706  bool loadNetworkBox(UT_IStream &is, const char *path=0);
3707 
3708  bool loadNodeFlags(UT_IStream &is, const char *path);
3709 
3710  void saveForUndoComment();
3711  void saveForUndoDelScript();
3712 
3713  UT_BitArray &getGroups() { return myGroups; }
3714  const UT_BitArray &getGroups() const { return myGroups; }
3715  // Only OP_Input should call setOutput() and delOutput() functions.
3716  bool setOutput(OP_NetworkBoxItem *item, int outputIdx);
3717  bool delOutput(OP_NetworkBoxItem *item, int outputIdx);
3718  bool setNamedOutput(OP_NetworkBoxItem *item,
3719  const OP_ConnectorId& output_name);
3720  bool delNamedOutput(OP_NetworkBoxItem *item,
3721  const OP_ConnectorId& output_name);
3722 
3723  void setInterrupted();
3724 
3725  int findAncestor(const OP_Node *node) const;
3726  int findDataAncestor(const OP_Node *node) const;
3727  void clearRecursionBit() const;
3728 
3729  void initializeExpressions() const;
3730  void clearInputs();
3731  void clearOutputs();
3732 
3733  PRM_ParmMicroNode *createParmMicroNodes(PRM_Parm &parm) const override;
3734 
3735  static bool getMicroNodesFromRef(
3736  const OP_InterestRef &ref,
3737  DEP_MicroNodeList &micronodes,
3738  bool data_target);
3739  static void traverseInputsAddInputs(
3740  opNodeOutput &output,
3742  UT_Set<opNodeOutput> &visited,
3743  TraverseOptions opts,
3744  OP_InterestType extra_interest_mask,
3745  bool include_parmlist);
3746 
3747  // ref_chan_name must be the real channel name and not an alias
3748  int addOpDependent( int op_id,
3749  const PRM_RefId &source_ref,
3750  const PRM_RefId &ref_id,
3752 
3753  void updateRenameDependent( OP_Node *dependent,
3754  const char *old_cwd,
3755  OP_NodeList &cook_nodes );
3756 
3757  void notifyInputOpDependents(int input_i);
3758 
3759  void getExistingOpReferencesImpl(
3760  OP_NodeList &refs, bool include_descendants) const;
3761  void getExistingOpDependentsImpl(
3762  OP_NodeList &deps, bool include_descendants) const;
3763 
3764  void buildScriptOpDependencies();
3765  void changeScriptOpRef( const char *new_fullpath,
3766  const char *old_path,
3767  const char *old_cwd );
3768  static void changeScriptCB( UT_String &str,
3769  const char *token_start,
3770  const char *&ch, void *userdata );
3771 
3772  // Go through and find all nodes which have time interest and requires
3773  // cooking. If the update_cook flag is true, then we will call force
3774  // recook on the node as long as node != this. 'interests' if non-null,
3775  // stores the path of nodes that has time interest and will set the time
3776  // interest cook flag on those nodes.
3777  bool findTimeInterests(const OP_Context &context, OP_Node *node,
3778  bool update_cook,
3779  OP_NodeCycleDetect &cycle,
3780  OP_NodeList *interests = nullptr);
3781 
3782  /// Helper method for 'completePath()'
3783  bool attemptPrefixMatch(const OP_NetworkBoxItem *item,
3784  char *childpref, int childpreflen,
3785  UT_String &maxprefix) const;
3786 
3787  /// Helper for propagateModification()
3788  void findUsedDataInterests(OP_NodeList &nodes, OP_Node *op);
3789 
3790  /// Helper function for the setGlobal*Param functions. This function
3791  /// interprets the return value from CH_Manager::setGlobal*Param.
3792  bool internalSetGlobalParam(const char *param,
3793  int setreturned,
3794  bool *warned);
3795 
3796  bool internalSetPicked(bool on_off,
3797  bool propagate_parent_event,
3798  bool edit);
3799 
3800  OP_ERROR internalCookInput(OP_Context &context, int input_idx,
3801  OP_Node &input_node);
3802 
3803  virtual void removeInputFromMapping(int idx);
3804  void removeOutputFromMapping(int idx);
3805 
3806  void generateConnectorUniqueId(OP_ConnectorId& id_out);
3807  OP_Output *getOrCreateOutput(int array_index, bool create,
3808  int id_to_use);
3809 
3810  uint32 computeCompiledHash() const;
3811 
3812  // Adds a warning to the current error manager if this node has been
3813  // marked as deprecated.
3814  void addDeprecationWarningsIfAny();
3815 
3816  // Find an unused connectorId to assign to the next input/output
3817  int getConnectorNextId() const;
3818 
3819  bool computeCompiledStatus() const;
3820 
3821  bool isOperatorThreadSafe() const;
3822 
3823  void internalSyncDelayedOTL();
3824 
3825 public:
3826  /// SOP, OBJ, and SOP Solver DOP nodes can be a selection owner,
3827  /// but other nodes cannot.
3828  /// This replaces the previous inheritance from SOP_SelectionOwner.
3829  virtual bool isSelectionOwnerType() const
3830  { return false; }
3831 
3832  /// Add many extra inputs in one call. See addExtraInput
3833  void addExtraInputs(const UT_Array<OP_InterestRef> &source_refs);
3834  void addExtraInputs(const DEP_MicroNodeList &deps);
3835 
3836  static void addExtraInputs(
3837  const UT_Array<OP_InterestRef> &target_refs,
3838  const UT_Array<OP_InterestRef> &source_refs);
3839 
3840  /// Optimized version of addExtraInput that doesn't create OP_InterestRef
3841  static void addExtraInput(OP_Node &source, int source_pi, int source_vi,
3842  OP_Node &target, int target_pi, int target_vi
3843  );
3844 
3845  static bool getMicroNodesFromRef(
3847  DEP_MicroNodeList &micronodes, bool data_target);
3848 
3849  static bool getMicroNodesFromRef(
3850  OP_Node &op, int parm_i, int vec_i,
3851  DEP_MicroNodeList &micronodes);
3852 
3853  void addExtraInput(OP_Node *op, OP_InterestType type, DEP_MicroNodeList &sources_cache);
3854 
3855  /// Optimized version of addExtraInput that doesn't create OP_InterestRef
3856  static void addExtraInput(OP_Node &source, PRM_Parm &source_parm, int source_vi,
3857  OP_Node &target, PRM_Parm &target_parm, int target_vi
3858  );
3859 
3860  void addExtraInputs(const UT_Array<OP_Node*> &nodes, OP_InterestType type, DEP_MicroNodeList &sources_cache);
3861 
3862  virtual bool isUsingCurrentFrameForVexTransformContext() const {return true;}
3863 private:
3864  OP_Cache myCache;
3865 
3866  OP_ERROR myLastErrorSeverity;
3867  exint myLastErrorVersion;
3868  OP_Network *myParent;
3869  OP_Network *myRootCompiledParent;
3870  UT_ValArray<OP_Input *> myInputs;
3871  // This is a map of names to inputs.
3872  OP_ConnectorInputMap myInputsMap;
3873  mutable UT_BitArray myUsedInputs;
3875  myOutputs;
3876  // This is a map of names to outputs.
3877  OP_ConnectorOutputMap myOutputsMap;
3878 
3879  // Default data micro node.
3880  OP_DataMicroNode myDataMicroNode;
3881  DEP_MicroNode myFlagMicroNode;
3882  UT_StringArray myClearInputContextOptionDeps;
3883 
3884  // Event micronodes for OP events
3885  using MicroNodePtr = UT_UniquePtr<DEP_MicroNode>;
3886  using EventMicroNodesPtr = UT_UniquePtr<MicroNodePtr[]>;
3887  EventMicroNodesPtr myEventMicroNodes;
3888 
3889  UT_String myComment;
3890  UT_String myDelScript;
3891  UT_String myCreatorState;
3892  UT_BitArray myGroups;
3893  OP_Value myEventValue;
3894  fpreal myPosX;
3895  fpreal myPosY;
3896  exint myCookCount;
3897  SYS_AtomicInt32 mySourceCount;
3898  int myBlockModify;
3899  int myScriptsBlockingDelCount;
3900  int myUniqueId;
3901  int myNextIdOverride;
3902  unsigned myActiveInputIndex;
3903  // Indicates which input is currently being connected,
3904  // -1 if none.
3905  int myLegacyConnectingInputIndex;
3906 
3907  bool myAutoscope;
3908 
3909  fpreal myCookDuration; // time spent cooking
3910  unsigned int myRenameConflict : 1,
3911  myCookedForRender : 1,
3912  myModifyWaiting : 1,
3913  myBuiltExplicitly : 1,
3914  myAllowBuildDependencies : 1,
3915  myBeingDeleted : 1,
3916  myRunningCreateScript : 1,
3917  myRunningDelScript : 1,
3918  myAlreadyRunDelScript : 1,
3919  myMatchesOTLDefinition : 1,
3920  myLoadCookedDataError : 1,
3921  myBuiltHashCode : 1,
3922  myIsProxyRefNode : 1,
3923  myInhibitInputConsolidation : 1,
3924  // Tracks if we have engaged our local variables, true from the
3925  // SOP_Node::setupLocalVars() until the SOP_Node::resetLocalVarRefs(). Any
3926  // attempt to evaluate local vars outside of here will redflag. This
3927  // flag is here instead of SOP_Node so that PI_OpHandleLink has access
3928  // to temporarily enable it.
3929  myLocalVarActive : 1,
3930  myDelaySyncOTL : 1,
3931  mySyncingDelayedOTL : 1;
3932 
3933  mutable bool myRecursionFlag;
3934 
3935  // Tracks the nesting level of the modification propagation chains
3936  static int thePropagateLevel;
3937 
3938  // ops that we have a reference to
3939  OP_ReferenceList myOpReferences;
3940  // ops that depend on us
3941  OP_DependencyList myOpDependents;
3942 
3943  // bundles that we have a reference to
3944  OP_BundleReferences myBundleRefs;
3945 
3946  // Locking for cooking and adding extra inputs
3947  mutable OP_CookLock myCookLock;
3948  UT_TaskState myTaskState;
3949 
3950  // Arbitrary string data that users can attach to nodes that gets saved
3951  // with the hip file.
3952  UT_Options myUserData;
3953  // Cached value for the node shape.
3954  UT_StringHolder myNodeShape;
3955 
3956  // Arbitrary blind data that users can attach to nodes. These do not get
3957  // saved with the hip file.
3958  UT_StringMap<UT_SharedPtr<void> > myBlindData;
3959 
3960  // Arbitrary data blocks that, unlike blind data, are saved with the node.
3961  // This obviously implies the data must be self contained (no pointers).
3962  UT_StringMap<OP_DataBlockPtr> myDataBlocks;
3963 
3964  // Arbitrary data (in the form of Python objects) the users can attach to
3965  // nodes that does not get saved with the hip file.
3966  OP_PythonObjectCache myCachedPythonObjects;
3967 
3968  // During load, not all of our input names are known. This stores
3969  // unresolved input names until OP_Node::loadFinished() is called,
3970  // where they are resolved.
3971  UT_Array<OP_UnresolvedConnection *> *myUnresolvedInputs;
3972 
3973  OP_NodeFlags myFlags;
3974 
3975  /// Cached evaluation of the node's descriptive name.
3976  UT_StringHolder myCachedDescriptiveName;
3977  bool myCachedDescriptiveNameDirty;
3978 
3979  /// Only used during loading. Set to false initially, it is set to true
3980  /// once we load inputsNamed intrinsic section. If we do, the regular
3981  /// inputs section will then be ignored.
3982  bool myLoadedNamedInputs;
3983 
3984  /// Used for caching the compiled status of the node. Initially undefined,
3985  /// gets set on first isCompiled() call.
3986  mutable OP_CompileStatusType myCachedCompileStatus;
3987 
3988  OP_ERROR myChildErrorSeverity;
3989  int myChildErrorSeverityTimestamp;
3990 
3991  // Maintenance of node id's
3992  static int makeUniqueId(OP_Node *node);
3993 
3994  static bool *theCheckConnectionConsistency;
3995  static int theUniqueId;
3996  static int theUniqueSize;
3997  static OP_Node **theUniqueNodes;
3998  static bool theDoingBulkNotification;
3999  static OP_Node *theBulkNotificationCaller;
4001  friend class OP_Channels;
4002  friend class OP_DataMicroNode;
4003  friend class OP_EventMicroNode;
4004  friend class OP_Group;
4005  friend class OP_IndirectInput;
4006  friend class OP_Input;
4007  friend class OP_Network;
4008  friend class OP_ParmMicroNode;
4009  friend class OP_UndoCreate;
4010  friend class OP_UndoDelete;
4011  friend class OP_UndoInput;
4012  friend class OP_UndoSpareParm;
4013  friend class OP_UndoUserData;
4015  friend class op_MicroNodeDirtied;
4016  friend class MOT_RemoteExecMessage;
4017 };
4018 
4019 // helper function
4020 // should always return a valid pointer
4022 
4023 // Link a Node to a Channel for SOP Channels
4024 OP_API void OPlinkNodeToChannel( const OP_Node *node, const CH_Channel *chp );
4026 
4027 // Replaces CH_Manager::getUniqueCollections() as it needs access to OP.
4029  const CH_ChannelList &channels,
4030  CH_CollectionList &collections );
4031 
4032 // UTformat support.
4033 static inline size_t
4034 format(char *buffer, size_t buffer_size, const OP_Node &v)
4035 {
4036  UT_StringHolder s = v.getFullPath();
4037  if (!buffer)
4038  return s.length();
4039  else
4040  {
4041  size_t len = std::min(size_t(s.length()), buffer_size);
4042  ::memcpy(buffer, s.c_str(), len);
4043  return len;
4044  }
4046 
4048 {
4049 public:
4052 };
4053 
4054 #define CAST_INSTANTIATE(PREFIX) \
4055 inline static PREFIX##_Node *CAST_##PREFIX##NODE(OP_Node *op) \
4056 { \
4057  return ((op) ? (op)->castTo##PREFIX##Node() : 0); \
4058 } \
4059  \
4060 inline static const PREFIX##_Node *CAST_##PREFIX##NODE(const OP_Node *op) \
4061 { \
4062  return ((op) ? (op)->castTo##PREFIX##Node() : 0); \
4063 } \
4064 
4065 /// @anchor OP_Node_CAST_FOONODE
4066 /// These convenience functions let you do the cast without worrying if the
4067 /// underlying pointer is null or not. They aren't macros because this way we
4068 /// avoid double evaluating the op.
4069 /// CAST_OBJNODE()
4070 /// CAST_SOPNODE()
4071 /// CAST_CHOPNETNODE()
4072 /// CAST_CHOPNODE()
4073 /// CAST_ROPNODE()
4074 /// CAST_SHOPNODE()
4075 /// CAST_COP2NODE()
4076 /// CAST_COP2NETNODE()
4077 /// CAST_VOPNODE()
4078 /// CAST_VOPNETNODE()
4079 /// CAST_DOPNODE()
4080 /// CAST_TOPNODE()
4081 /// CAST_TOPNETNODE()
4082 /// CAST_LOPNODE()
4083 //@{
4085 //@}
4086 
4087 #undef CAST_INSTANTIATE
4088 
4089 // We don't want anyone to conflict with this..
4090 #undef INSTANTIATE_FINDNODE_FUNCTIONS
4091 #undef INSTANTIATE_CASTNODE_FUNCTIONS
4092 #undef INSTANTIATE_FOR_ALL_NODE_TYPES
4093 
4094 //___________________________________________________________________________
4096 /// Simple class that makes it easy to write loops that iterate over all the
4097 /// outputs from a node. The parameters are passed on to getOutputNodes.
4098 class OP_API OP_OutputIterator : private UT_SmallArray<OP_Node*>
4099 {
4101 
4102 public:
4104  const OP_Node &node,
4105  bool into_subnets = false,
4106  bool through_dots = true,
4107  int output_idx = -1)
4108  {
4109  node.getOutputNodes(*this, into_subnets, through_dots, output_idx);
4110  }
4111 
4112  using Parent::begin;
4113  using Parent::end;
4114 
4115  using Parent::rbegin;
4116  using Parent::rend;
4117 
4118  using Parent::operator();
4119  using Parent::entries;
4120  using Parent::size;
4121 
4122  using Parent::sort;
4123 };
4125 /// Same as OP_OutputIterator, but with the iterators all swapped around so a
4126 /// range loop will go backwards (without having to mess with reverse adaptors)
4127 class OP_API OP_OutputReversedIterator : private UT_SmallArray<OP_Node*>
4128 {
4130 
4131 public:
4133  const OP_Node &node,
4134  bool into_subnets = false,
4135  bool through_dots = true,
4136  int output_idx = -1)
4137  {
4138  node.getOutputNodes(*this, into_subnets, through_dots, output_idx);
4139  }
4141  const_reverse_iterator begin() const { return Parent::rbegin(); }
4142  const_reverse_iterator end() const { return Parent::rend(); }
4143  reverse_iterator begin() { return Parent::rbegin(); }
4144  reverse_iterator end() { return Parent::rend(); }
4146  const_iterator rbegin() const { return Parent::begin(); }
4147  const_iterator rend() const { return Parent::end(); }
4148  iterator rbegin() { return Parent::begin(); }
4149  iterator rend() { return Parent::end(); }
4150 
4151  using Parent::operator();
4152  using Parent::entries;
4153  using Parent::size;
4154 
4155  using Parent::sort;
4156 };
4157 
4158 /// Safe reference to an OP node
4161 public:
4162  OP_NodeId() { myId = OP_INVALID_NODE_ID; }
4163  OP_NodeId(const OP_Node *node) { *this = node; }
4164  OP_NodeId(const OP_NodeId &id) { myId = id.myId; }
4165 
4166  bool isValid() const
4167  { return (OP_Node::lookupNode(myId) != nullptr); }
4168 
4169  OP_Node *ptr() { return OP_Node::lookupNode(myId); }
4170  const OP_Node *ptr() const { return OP_Node::lookupNode(myId); }
4172  void clear() { myId = OP_INVALID_NODE_ID; }
4173 
4174  void operator=(const OP_Node *node)
4175  { myId = node ? node->getUniqueId() : OP_INVALID_NODE_ID; }
4176 
4177  bool operator==(const OP_Node *node) const
4178  {
4179  const int id = node ? node->getUniqueId() : OP_INVALID_NODE_ID;
4180  return id == myId;
4181  }
4182  bool operator!=(const OP_Node *node) const
4183  {
4184  const int id = node ? node->getUniqueId() : OP_INVALID_NODE_ID;
4185  return id != myId;
4186  }
4187  void setId(int id) { myId = id; }
4188 private:
4189  int myId;
4190 };
4191 
4192 #endif
OP_API const UT_StringHolder OP_USERDATA_NODESHAPE
int getUniqueId() const
Definition: OP_Node.h:712
The change type wasn't set, so it could be any of them.
Definition: OP_DataTypes.h:79
virtual void executeCommand(const char *command, std::ostream *out, std::ostream *err) const =0
typedef int(APIENTRYP RE_PFNGLXSWAPINTERVALSGIPROC)(int)
virtual bool setColor(const UT_Color &color)
void adoptFromString(UT_String &str)
short * getInput(int size) override
GLbitfield flags
Definition: glcorearb.h:1596
#define CAST_INSTANTIATE(PREFIX)
Definition: OP_Node.h:4052
Definition: UT_Set.h:58
OP_API void OPgetUniqueCollections(const CH_ChannelList &channels, CH_CollectionList &collections)
virtual const VOP_CodeGenerator * getVopAutoCodeGenerator() const
Definition: OP_Node.h:2700
GT_API const UT_StringHolder filename
OP_InputPair(OP_Input *p, OP_ConnectorId n)
Definition: OP_Node.h:139
const PRM_Parm * myParmRef
Definition: OP_Node.h:172
GLuint GLsizei const GLchar * label
Definition: glcorearb.h:2545
virtual UT_ErrorSeverity prmCookOverrides(fpreal, int, const char *, int)
virtual OP_ItemType getItemType() const =0
Our children should implement this and return what type of item they are.
OP_ConnectorInputMap::iterator OP_ConnectorInputIter
Definition: OP_Node.h:135
UT_KnownPath
Definition: UT_KnownPath.h:14
#define SYS_DEPRECATED(__V__)
virtual void checkChannelDependencies(CH_Channel *, CH_CHANGE_TYPE)
Unsorted map container.
Definition: UT_Map.h:107
uint64 OP_VERSION
Definition: OP_Version.h:6
int64 getMemoryUsage(bool inclusive) const
UT_String myInputName
Definition: OP_Node.h:178
OP_CompileStatusType
Definition: OP_Node.h:316
virtual int changeString(const char *from, const char *to, bool fullword)
GLboolean * data
Definition: glcorearb.h:131
OP_API void OPlinkNodeToChannel(const OP_Node *node, const CH_Channel *chp)
UT_CycleDetect< OP_Node * > OP_NodeCycleDetect
Definition: OP_Node.h:224
GT_API const UT_StringHolder time
const GLdouble * v
Definition: glcorearb.h:837
void addExplicitInput(DEP_MicroNode &inp, bool check_dup)
Methods for manipulating explicit edges.
TraverseOptions
Definition: OP_Node.h:2630
A task node for managing which thread is currently working on a given task.
Definition: UT_TaskState.h:47
Transformation order of scales, rotates, and translates.
Definition: UT_XformOrder.h:23
GLsizei const GLfloat * value
Definition: glcorearb.h:824
virtual void opChanged(OP_EventType type, void *dataptr=0)=0
const UT_StringHolder myTableName
Definition: OP_Node.h:353
const GLuint GLenum const void * binary
Definition: glcorearb.h:1924
UT_LockedRawPtr< OP_NodeList, OP_Lock > OP_LockedNodeList
Definition: OP_Node.h:227
GLsizei const GLchar *const * path
Definition: glcorearb.h:3341
SYS_FORCE_INLINE T * SYSconst_cast(const T *foo)
Definition: SYS_Types.h:136
base_iterator< const OP_Node *, false > const_reverse_iterator
Definition: UT_Array.h:981
#define INSTANTIATE_CASTNODE_FUNCTIONS(PREFIX)
Definition: OP_Node.h:456
virtual void setXY(fpreal x, fpreal y)=0
int64 exint
Definition: SYS_Types.h:125
GLint level
Definition: glcorearb.h:108
UT_StringMap< UT_UniquePtr< PY_OpaqueObject > > OP_PythonObjectCache
Definition: OP_Node.h:229
virtual fpreal getY() const =0
virtual bool getHasTakeData() const
void reverse(I begin, I end)
Definition: pugixml.cpp:7190
GLdouble s
Definition: glad.h:3009
UT_ErrorSeverity
Definition: UT_Error.h:25
virtual fpreal getX() const =0
Parameters for OP_Node::getInfoText()/OP_Node::getNodeSpecificInfoText()
OP_API const UT_StringHolder OP_USERDATA_BGIMAGES
const OP_DopParent * castToOpDopParent() const
Definition: OP_Node.h:2691
ImageBuf OIIO_API min(Image_or_Const A, Image_or_Const B, ROI roi={}, int nthreads=0)
std::pair< const OP_Node *, int > opNodeOutput
Definition: OP_Node.h:230
GLint y
Definition: glcorearb.h:103
virtual OP_Network * getParentNetwork() const =0
Returns the network that is our parent.
**But if you need a result
Definition: thread.h:613
GLdouble GLdouble GLdouble q
Definition: glad.h:2445
OP_ConnectorId myName
Definition: OP_Node.h:142
#define OP_INVALID_NODE_ID
Definition: OP_ItemId.h:24
virtual void clearParmDependency(int parmidx)=0
int(* OP_EditCallback)(void *data, OP_Node *src, CL_Track *track, fpreal t, fpreal value)
Definition: OP_Node.h:130
const char * c_str() const
Definition: UT_String.h:508
virtual UT_StringHolder evaluateDisableExpression(const PRM_Parm &prm, const UT_StringRef &function) const
int myIndex
Definition: OP_Node.h:416
virtual int findString(const char *str, bool fullword, bool usewildcards) const
virtual bool setPicked(bool on_off, bool propagate_parent_event=true)=0
base_iterator< OP_Node *, false > reverse_iterator
Definition: UT_Array.h:980
const OP_Node * myEvalNode
Definition: OP_Node.h:171
std::unique_ptr< T, Deleter > UT_UniquePtr
A smart pointer for unique ownership of dynamically allocated objects.
Definition: UT_UniquePtr.h:39
void setDirty(bool flag, bool allow_clear=true)
Flag accessors.
virtual void setAnyUndoFlag()
PivotSpaceT< fpreal32 > PivotSpace
Definition: UT_Matrix4.h:862
< returns > If no error
Definition: snippets.dox:2
fpreal myValue
Definition: OP_Node.h:413
virtual int64 getItemUniqueId() const =0
Functions to get hip-file-unique ids for any item type.
OP_OutputPair(OP_Output *p, OP_ConnectorId n)
Definition: OP_Node.h:147
OP_ItemType
Definition: OP_ItemId.h:28
PRM_ParmList * createObsoleteParmList() override
bool operator==(const BaseDimensions< T > &a, const BaseDimensions< Y > &b)
Definition: Dimensions.h:137
A utility class to do read-only operations on a subset of an existing string.
Definition: UT_StringView.h:39
const char * getFullPath(UT_String &str) const
Definition: PRM_ParmOwner.h:52
virtual fpreal getW() const =0
GLdouble n
Definition: glcorearb.h:2008
GLfloat f
Definition: glcorearb.h:1926
const UT_StringHolder myScriptDir
Definition: OP_Node.h:354
#define INSTANTIATE_FOR_ALL_NODE_TYPES(MACRO_FUNC)
This macro allows us to run another macro for all node types.
Definition: OP_Node.h:473
int mySubIndex
Definition: OP_Node.h:417
OP_InterestType
Definition: OP_DataTypes.h:44
Definition: core.h:760
UT_ValArray< const CL_Track * > CL_TrackListC
Definition: OP_Node.h:125
reverse_iterator rbegin()
Begin iterating over the array in reverse.
Definition: UT_Array.h:1011
CH_CHANGE_TYPE
exint length() const
GLint ref
Definition: glcorearb.h:124
Mapper that provides an HDA section name for a given shader node.
std::shared_ptr< T > UT_SharedPtr
Wrapper around std::shared_ptr.
Definition: UT_SharedPtr.h:36
OP_OpTypeId myOptypeId
Definition: OP_Node.h:351
void(* OP_EventMethod)(OP_Node *caller, void *callee, OP_EventType type, void *data)
Definition: OP_Value.h:178
PXL_API const char * getName(const ColorSpace *space)
Return the name of the color space.
#define UT_ASSERT_P(ZZ)
Definition: UT_Assert.h:155
void resolveAndDeleteObsoleteParmList(PRM_ParmList *&obsolete_parms) override
OP_API const UT_StringHolder OP_USERDATA_OPMENUFILE
GLuint GLuint end
Definition: glcorearb.h:475
GLint GLint GLsizei GLint GLenum format
Definition: glcorearb.h:108
GLsizei GLsizei GLchar * source
Definition: glcorearb.h:803
#define INVALID_TABLE_NAME
Definition: OP_Node.h:241
GLint GLuint mask
Definition: glcorearb.h:124
OP_Network * getRootCompiledParent() const
Definition: OP_Node.h:507
virtual ~OP_TransformCallback()
Definition: OP_Node.h:186
Wrapper around hboost::intrusive_ptr.
iterator begin()
Definition: UT_Array.h:986
GLdouble GLdouble GLint GLint order
Definition: glad.h:2676
virtual bool triggerParmCallback(PRM_Parm *parmptr, fpreal now, int value, void *data, const UT_Options *options=0)=0
long long int64
Definition: SYS_Types.h:116
GLenum target
Definition: glcorearb.h:1667
#define SYS_NO_DISCARD_RESULT
Definition: SYS_Compiler.h:93
GLuint id
Definition: glcorearb.h:655
DEP_MicroNode & parmMicroNode(int parm_idx, int vi)
SYS_FORCE_INLINE const char * c_str() const
SYS_FORCE_INLINE bool isTimeDependent() const
Flag accessors.
OP_OpTypeId
Definition: OP_OpTypeId.h:18
HUSD_API bool eval(VtValue &val, T &ret_val)
#define INSTANTIATE_FINDNODE_FUNCTIONS(PREFIX)
Definition: OP_Node.h:447
OTLSyncMode
Definition: OP_Node.h:839
UT_ArrayMap< OP_ConnectorId, OP_Input * > OP_ConnectorInputMap
Definition: OP_Node.h:133
OP_UIChangeType
Definition: OP_DataTypes.h:76
GLuint const GLchar * name
Definition: glcorearb.h:786
virtual void setItemExpose(bool expose)
virtual void buildOpDependencies()
Definition: OP_Dot.h:24
signed char int8
Definition: SYS_Types.h:35
GLushort pattern
Definition: glad.h:2583
GLboolean GLboolean GLboolean b
Definition: glcorearb.h:1222
GLint GLenum GLint x
Definition: glcorearb.h:409
virtual bool getItemExpose() const
UT_ArrayMap< OP_ConnectorId, OP_Output * > OP_ConnectorOutputMap
Definition: OP_Node.h:134
int myVectorIndex
Definition: OP_Node.h:173
reverse_iterator rend()
End reverse iterator.
Definition: UT_Array.h:1017
virtual OP_OpTypeId getOpTypeID() const
Definition: OP_Node.h:525
virtual bool changeSpareParms(UT_IStream &ds, UT_String &errors)
GLdouble t
Definition: glad.h:2397
OP_API void OPclearNodeToChannelLinks()
GLenum mode
Definition: glcorearb.h:99
GT_API const UT_StringHolder version
OP_TransformCallback * myParentXfo
Definition: OP_Node.h:219
IFDmantra py
Definition: HDK_Image.dox:266
void doGetFullPath(UT_WorkBuffer &str) const override
Compute the full path of the node.
virtual void rebuildParmDependency(int parmidx)=0
GLsizeiptr size
Definition: glcorearb.h:664
unsigned int OP_ItemTypeMask
Definition: OP_ItemId.h:43
**Note that the tasks the is the thread number *for the or if it s being executed by a non pool thread(this *can happen in cases where the whole pool is occupied and the calling *thread contributes to running the work load).**Thread pool.Have fun
const UT_StringHolder myOptypeName
Definition: OP_Node.h:352
OP_API const char * OPtypeIdLabels[NUM_MANAGERS]
Nice label names used by network view, corresponding to OP_OpTypeId.
A map of string to various well defined value types.
Definition: UT_Options.h:84
GLenum GLfloat param
Definition: glcorearb.h:104
OP_EvaluateTransformTracksArgs(const UT_StringHolder name, UT_Matrix4D *w, UT_Matrix4D *l=nullptr, OP_TransformCallback *parent_cb=nullptr, int *timedep=nullptr)
Definition: OP_Node.h:193
Parameters for OP_Node::fillInfoTree()/OP_Node::fillInfoTreeNodeSpecific()
bool operator==(const OP_NodeParmRef &other)
Definition: OP_Node.h:164
virtual const UT_String & getItemName() const =0
SIM_API const UT_StringHolder force
virtual void addExtraInput(OP_Node *op, OP_InterestType type)
GLuint color
Definition: glcorearb.h:1261
virtual bool setItemName(const UT_String &name)=0
fpreal64 fpreal
Definition: SYS_Types.h:277
virtual void permissionError(const char *chname=0)
Utility class for containing a color ramp.
Definition: UT_Ramp.h:88
typename set_type::iterator iterator
Inherit iterator and const_iterator.
Definition: UT_ArrayMap.h:103
#define OP_API
Definition: OP_API.h:10
GLuint index
Definition: glcorearb.h:786
OP_OTLLicenseType
OP_Output * myOutput
Definition: OP_Node.h:149
virtual unsigned referenceAllParameters(OP_Parameters *from, bool relative_references=true)
auto ptr(T p) -> const void *
Definition: format.h:2448
GLuint GLfloat * val
Definition: glcorearb.h:1608
OP_API const UT_StringHolder OP_USERDATA_CHILDOPMENUFILE
TransformMode
Definition: OP_Node.h:1117
OP_Node * myNode
Definition: OP_Node.h:415
void getOutputNodes(UT_Array< OP_Node * > &outputs, bool into_subnets=false, bool through_dots=true, int output_idx=-1) const
OP_EventType
Definition: OP_Value.h:22
A global error manager scope.
GA_API const UT_StringHolder pivot
base_iterator< const OP_Node *, true > const_iterator
Definition: UT_Array.h:979
OP_DataType
Definition: OP_DataTypes.h:28
**If you just want to fire and args
Definition: thread.h:609
unsigned int uint32
Definition: SYS_Types.h:40
OP_API const UT_StringHolder OP_USERDATA_WIRESTYLE
static OP_Node * lookupNode(int unique_id, bool include_proxy=false)
Definition: OP_Node.h:696
constexpr T pi()
Pi constant taken from Boost to match old behaviour.
Definition: Math.h:119
UT_CycleDetect< OP_NodeParmRef > OP_NodeParmRefCycle
Definition: OP_Node.h:225
OP_Network * getParent() const
Definition: OP_Node.h:505
virtual void clearUndoFlags()
virtual UT_Color getColor() const
Accessors for color used in the network view.
virtual bool getPicked() const =0
virtual void convertOpdefToAbsolutePath(UT_String &str) const =0
This is the base class for all DOP nodes.
Definition: DOP_Node.h:77
GLubyte GLubyte GLubyte GLubyte w
Definition: glcorearb.h:857
virtual OP_Node * castToOPNode()
Definition: PRM_ParmOwner.h:49
Definition: core.h:1131
virtual void spareParmRemoved(const char *parmname)=0
virtual fpreal getH() const =0
OP_NodeParmRef(const OP_Node *eval_node=0, const PRM_Parm *parm_ref=0, int vi=-1)
Definition: OP_Node.h:155
bool operator!=(const BaseDimensions< T > &a, const BaseDimensions< Y > &b)
Definition: Dimensions.h:165
int operator==(const opParmData &v) const
Definition: OP_Node.h:419
#define const
Definition: zconf.h:214
virtual void syncNodeVersion(const char *old_version, const char *current_version, bool *node_deleted)
Safe reference to an OP node.
Definition: OP_Node.h:4156
Options class for use with OP_Node::saveCommand()
Definition: OP_Node.h:358
#define DEFAULT_COMP_HASH_VALUE
Definition: OP_Node.h:238
OP_ScopeOp
Definition: OP_Parameters.h:58
bool wasInterrupted(T *i, int percent=-1)
OP_Input * myInput
Definition: OP_Node.h:141
OP_NodeFlags & flags()
Definition: OP_Node.h:1390
SYS_FORCE_INLINE PRM_ParmList * getParmList()
Definition: PRM_ParmOwner.h:71
type
Definition: core.h:1059
void sort(I begin, I end, const Pred &pred)
Definition: pugixml.cpp:7334
virtual PRM_ParmMicroNode * createParmMicroNodes(PRM_Parm &parm) const
#define UTstatic_pointer_cast
Definition: UT_SharedPtr.h:43
OP_EvaluateTransformTracksArgs(int index, UT_Matrix4D *w, UT_Matrix4D *l=nullptr, OP_TransformCallback *parent_cb=nullptr, int *timedep=nullptr)
Definition: OP_Node.h:203
OP_API const UT_StringHolder OP_USERDATA_DESCRIPTIVE_PARM
unsigned char uchar
Definition: SYS_Types.h:42
OP_Input * mySavedInput
Definition: OP_Node.h:179
UT_LockedRawPtr< const OP_NodeList, OP_Lock > OP_LockedConstNodeList
Definition: OP_Node.h:228
Definition: format.h:895
Definition: OP_PostIt.h:42
iterator end()
End iterator.
Definition: UT_Array.h:991
OP_API OP_Node * OPgetNodeFromChannel(const CH_Channel *chp)
virtual bool isParmPendingOverride(const char *, int) const
ImageBuf OIIO_API channels(const ImageBuf &src, int nchannels, cspan< int > channelorder, cspan< float > channelvalues={}, cspan< std::string > newchannelnames={}, bool shuffle_channel_names=false, int nthreads=0)
OP_ConnectorId myName
Definition: OP_Node.h:150
virtual SYS_NO_DISCARD_RESULT UT_UniquePtr< PRM_ParmOwnerContext > pushAsPwd() const =0
UT_StringHolder myTrackName
Definition: OP_Node.h:213
GLint GLint GLint GLint GLint GLint GLint GLbitfield GLenum filter
Definition: glcorearb.h:1297
GLenum src
Definition: glcorearb.h:1793
virtual const PRM_Parm * traverseRef(int *sub_idx, fpreal time, int parm_idx, int vec_idx) const =0
UT_String myLabel
Definition: OP_Node.h:414
PcpNodeRef_ChildrenIterator begin(const PcpNodeRef::child_const_range &r)
Support for range-based for loops for PcpNodeRef children ranges.
Definition: node.h:483