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