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