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