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