HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
VOP_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: VOP Library (C++)
7  *
8  * COMMENTS: The base class for all VOP operators
9  *
10  */
11 
12 #ifndef __VOP_Node_h__
13 #define __VOP_Node_h__
14 
15 #include <set>
16 #include <map>
17 #include <iosfwd>
18 
19 #include "VOP_API.h"
20 #include "VOP_DataMicroNode.h"
21 #include "VOP_Error.h"
22 #include "VOP_Language.h"
23 #include "VOP_TypeInfo.h"
24 #include "VOP_OperatorInfo.h"
25 #include "VOP_OutputInfoManager.h"
26 #include <OP/OP_Director.h>
27 #include <OP/OP_Network.h>
28 #include <UT/UT_UniquePtr.h>
29 #include <UT/UT_BitArray.h>
30 #include <UT/UT_ValArray.h>
31 #include <UT/UT_SymbolTable.h>
32 #include <UT/UT_Array.h>
33 #include <UT/UT_Map.h>
34 #include <SYS/SYS_Types.h>
35 #include <utility>
36 #include <vector>
37 
38 class UT_StringRef;
39 
40 #define VOP_OPT_LOW_FLAG 'L'
41 #define VOP_OPT_MEDIUM_FLAG 'M'
42 #define VOP_OPT_HIGH_FLAG 'H'
43 #define VOP_DEBUG_FLAG 'D'
44 #define VOP_MATERIAL_FLAG 'E'
45 
46 // The name of the parameter that contains the ordering of the
47 // VOPNET Parameters.
48 #define VOP_PARMORDER_NAME "parmorder"
49 #define VOP_BIND_NAME "bind"
50 #define VOP_GLOBAL_NODE_NAME "global"
51 #define VOP_ILLUM_NODE_NAME "illuminance"
52 #define VOP_PARM_NODE_NAME "parameter"
53 #define VOP_CONST_NODE_NAME "constant"
54 #define VOP_PARMRAMP_NODE_NAME "rampparm"
55 #define VOP_INLINE_CODE_NODE_NAME "inline"
56 #define VOP_SNIPPET_NODE_NAME "snippet"
57 #define VOP_MATERIAL_BUILDER_NODE_NAME "materialbuilder"
58 #define VOP_RSL_PREFIX "rsl_"
59 #define VOP_VARIABLE_INOUT_MAX 2048
60 
61 /// Prefix given to the subnet input variables.
62 #define VOP_SUBNET_VARIABLE_PREFIX "_"
63 
65 {
67 };
68 
69 class TIL_Thumbnail;
70 class VCC_DiagnosticInfo;
71 class VOP_Node;
72 class VOP_GlobalVarData;
73 class VOP_ParmGenerator;
74 class VOP_OutputVar;
75 class VOP_Bind;
76 class VOP_Block;
77 class VOP_AutoNode;
78 class VOP_CodeGenContext;
81 class VOP_VariableTags;
82 class VOP_SubnetBase;
84 
85 extern "C" {
87 };
88 
92 
96 
98 {
99  VOP_AutoNode* myAutoVopNode; // Auto-node that provides VEX code to adjust VOP's code.
100  int myIndex; // Index of the input on the node the auto-node connects to.
101 };
103 
104 //=============================================================================
106 {
107 public:
108  UT_StringHolder myName; // variable name
109  UT_StringHolder myDescription; // variable description
110  VOP_ContextType myContextType; // context type in which var exists
111  int myVarIndex; // index in the context's var table
112  VOP_TypeInfo myTypeInfo; // variable type (int, float, etc)
113  bool myReadable; // can read from variable?
114  bool myWritable; // can write to variable?
115  bool myIlluminanceVar; // is illuminance?
116 };
117 
118 //=============================================================================
120 {
121 public:
122  VOP_GlobalVarData( const char * name, const VOP_VarInfo & info );
124  void appendInfo( const VOP_VarInfo & info );
125 
126  const UT_StringHolder & getName() const
127  { return myName; }
128 
129  const UT_StringHolder & getDescription( VOP_ContextType type ) const;
130  const VOP_TypeInfo & getTypeInfo( VOP_ContextType type ) const;
131  int getVarIndex( VOP_ContextType type ) const;
132  bool isReadable( VOP_ContextType type ) const;
133  bool isWriteable( VOP_ContextType type ) const;
134  bool isIlluminance( VOP_ContextType type ) const;
135  bool isValidInContext( VOP_ContextType type ) const;
136 
137  const VOP_TypeInfo & getAnyTypeInfo() const
138  {
139  return myInfos(0).myTypeInfo;
140  }
141 
142 private:
143  template<typename T> T getInfoMember( VOP_ContextType ctx_type,
144  T VOP_VarInfo::*member,
145  T default_val ) const;
146  template<typename T> const T &getInfoMemberRef( VOP_ContextType ctx_type,
147  T VOP_VarInfo::*member,
148  const T & default_val ) const;
149  int getIndexForContextType( VOP_ContextType type) const;
150 
151 private:
152  UT_StringHolder myName; // variable name
153  UT_Array<VOP_VarInfo> myInfos; // infos for applicable contexts
154 };
155 
156 //=============================================================================
158 {
159 public:
160  virtual ~VOP_OutputNameEditorSource();
161  virtual int getNumInputsFromParent() const = 0;
162  virtual void NAMEFROMPARM(UT_String &str, int idx) const = 0;
163  virtual void LABELFROMPARM(UT_String &str, int idx) const = 0;
164  virtual void setNAMEFROMPARM(UT_String &str, int idx) = 0;
165  virtual void setLABELFROMPARM(UT_String &str, int idx) = 0;
166 };
167 
168 // ============================================================================
169 /// Abstracts information about shader function parameters/arguments.
170 /// It has two use cases: when declaring and defining a shader function, and
171 /// when calling a shader function. It always stores shader parameter type and
172 /// name, but may not store some of the other information for some use cases.
174 {
175 public:
177 
178  /// Argument type.
179  void setTypeInfo( const VOP_TypeInfo &type_info );
180  const VOP_TypeInfo & getTypeInfo() const
181  { return myTypeInfo; }
182 
183  /// Argument name.
184  void setName( const char *name );
185  const UT_StringHolder & getName() const
186  { return myName; }
187 
188  /// Local variable name to use when calling the function.
189  void setVarName( const char *var_name );
190  const UT_StringHolder & getVarName() const;
191 
192  /// Expression (ie, RHS of the assignment) to use for initialization
193  /// of the argument when calling the shader function.
194  void setInitCodeStr( const char *init_code );
196  { return myInitCodeStr; }
197 
198  /// Node input index, if argument corresponds to an input; otherwise -1.
199  void setInputIndex( int input_index );
200  int getInputIndex() const
201  { return myInputIdx; }
202 
203  /// Node output index, if argument corresponds to an input; otherwise -1.
204  void setOutputIndex( int output_index );
205  int getOutputIndex() const
206  { return myOutputIdx; }
207 
208  /// True if it's an export (output) shader function parameter.
209  void setExported( bool exported );
210  bool isExported() const
211  { return myIsExported; }
212 
213 private:
214  VOP_TypeInfo myTypeInfo; // Argument type
215  UT_StringHolder myName; // Argument name
216  UT_StringHolder myVarName; // Variable name to use in function call
217  UT_StringHolder myInitCodeStr; // Expression code to init an arg to.
218  int myInputIdx; // Input index this variable corresponds to
219  int myOutputIdx; // Output index this var corresponds to
220  bool myIsExported; // Is an output argument
221 };
222 
223 //=============================================================================
225 {
226 public:
227  vop_Connector(int groups_above,
228  int index = -1)
229  : myIndex(index),
230  myGroupsAbove(groups_above),
231  myIsExpanded(false),
232  myIsGroup(false)
233  { }
234  vop_Connector(int groups_above,
235  const UT_StringHolder &group_name,
236  int index,
237  bool expanded)
238  : myGroupName(group_name),
239  myIndex(index),
240  myGroupsAbove(groups_above),
241  myIsExpanded(expanded),
242  myIsGroup(true)
243  { }
245  { }
246 
247  int myIndex;
251  bool myIsGroup;
252 };
254 
255 //=============================================================================
256 /// The allowed name formats when asking for shader name.
258 {
259  PLAIN, // Straight forward name only.
260  ALLOW_HDA_SECTION, // Allow paths to HDA sections in name.
261  RELAXED_AUTO // For potential auto shaders, Parm & Const
262  // input VOPs don't trigger auto-wrapping.
263  // Note, this implies allowing HDA sections.
264 };
265 
266 //=============================================================================
268 {
269 public:
270  static const char *theChildTableName;
271  const char *getChildType() const override;
272  const char *getOpType() const override;
273 
274  OP_OpTypeId getChildTypeID() const override;
275  OP_OpTypeId getOpTypeID() const override;
276 
277  /// Nobody should have to override this, but it's public for other people
278  OP_DataType getCookedDataType() const override;
279 
280  /// Whenever a variable type parm changes, we have to send out an event
281  /// to get our tile to update.
282  void opChanged(OP_EventType reason, void *data=0) override;
283  void referencedParmChanged(int pi) override;
284 
285  static void buildOperatorTable(OP_OperatorTable &table);
286 
287  /// Get the parm block information that will go in the dialog script
288  /// for our VOPNET. The shader_contexts argument is a list of
289  /// contexts, in which the parameter is a shader argument.
290  virtual void getParameterBlock(UT_String &parmstr,
291  const char *shader_contexts);
292 
293  /// The parameter variable declaration using the syntax of a given language.
294  virtual void getParameterDeclaration(UT_String &parmdecl,
295  const VOP_Language *language,
296  const VOP_CodeGenContext &context);
297 
298  /// Obtains the parameter declaration code comment, which is appended
299  /// after the declaration in the generated source code.
300  virtual void getParameterComment(UT_String &parm_comment,
301  const VOP_Language *language,
302  const VOP_CodeGenContext &context);
303 
304  /// If false, getShaderExtraParameters is not invoked as it is assumed
305  /// to return an empty list
306  virtual bool definesShaderExtraParameters() const;
307 
308  /// Returns a list of the attributes that we want to bind or export.
309  /// These are added to the vex functions parameter list, but not to the
310  /// UI as they are only expected to be overridden. If they match
311  /// an existing value, they do not replace.
312  /// The shader type is used only in a very specific cases of material
313  /// builder, when extra parameters may depend on a shader type.
314  virtual int getShaderExtraParameters(UT_Array<VOP_Type> &types,
315  UT_IntArray &doexport, UT_StringArray &names,
316  UT_StringArray &def,
317  VOP_Type shader_type = VOP_TYPE_UNDEF ) const;
318 
319  /// Get compiler pragmas for thi snode.
320  virtual void getPragmas(UT_String &pragmastr,
321  const VOP_CodeGenContext &context);
322 
323  /// If the node generates a shader call, get the modules names to import.
324  virtual void getModulesToImport(UT_StringArray &modules,
325  const VOP_CodeGenContext &context);
326 
327  /// Get the code fragment to be included in the outer code,
328  /// before the main shader code.
329  virtual void getOuterCode(UT_String &codestr,
330  const VOP_CodeGenContext &context);
331 
332  /// Get the code fragment to be included in the shader code.
333  virtual void getCode(UT_String &codestr,
334  const VOP_CodeGenContext &context);
335 
336  /// Get the constant code that encodes the value of the node parameter.
337  virtual bool getParmConstantString(const char *parmname,
338  const VOP_TypeInfo &type_info,
339  UT_String &str,
340  bool expand_string,
341  const VOP_Language *l=0);
342  /// Returns the code name of the type, such as "float" from VOP_TYPE_FLOAT
343  /// Threadsafe but not re-entrant.
344  static const char *getTypeNameFromType(const VOP_TypeInfo &type_info,
345  const VOP_Language *lang);
346  /// Returns a UI friendly version of the string, with NiceNumber
347  /// type effects embedded.
348  bool getParmPrintableString(const char *parmname,
349  VOP_Type type,
350  UT_String &str,
351  bool expand_string) const;
352 
353 
354 
355  /// Returns true if this VOP is a VOP_ParmGenerator or subclass.
356  virtual bool getIsParmGenerator() const;
357 
358  /// @{
359  /// Virtual methods to avoid dynamic_casts
360 #define VOP_IMPLEMENT_CASTS(NAME) \
361  static const VOP_##NAME *castTo##NAME(const OP_Node *node) { \
362  const VOP_Node *vop = CAST_VOPNODE(node); \
363  return vop ? vop->castTo##NAME() : nullptr; } \
364  static VOP_##NAME *castTo##NAME(OP_Node *node) { \
365  VOP_Node *vop = CAST_VOPNODE(node); \
366  return vop ? vop->castTo##NAME() : nullptr; } \
367  virtual const VOP_##NAME *castTo##NAME() const { return nullptr; } \
368  virtual VOP_##NAME *castTo##NAME() { return nullptr; }
369 
370  VOP_IMPLEMENT_CASTS(ParmGenerator)
371  VOP_IMPLEMENT_CASTS(SubnetBase)
372  VOP_IMPLEMENT_CASTS(OutputVar)
373  VOP_IMPLEMENT_CASTS(Bind)
374  VOP_IMPLEMENT_CASTS(Block)
375 #undef VOP_IMPLEMENT_CASTS
376  /// @}
377 
378  /// Moves a visualizer into our output list.
379  bool addOrMoveVisualizerToOutput(int outputidx) override;
380 
381  /// Creates a code generator for the VOP, if it needs one.
382  /// When a VOP is placed in a non-shaer container node that does not have
383  /// an overarching code generator, this method may be called to create one
384  /// for a VOP to act as a stand-alone shader.
385  void createAutoCodeGenerator();
386 
387  /// Utility method to create explicit children inside that node.
388  /// The children correspond to the epilogue in auto-generated shader.
389  void createAutoShaderChildren();
390 
391  /// @{ Obtains a code generator that provides shader code associated
392  /// with a node. Usually, vopnet shader VOPs have their own dedicated
393  /// code generator for shader constructed fom their children.
394  /// However, also, all VOP nodes inside a Shader Network container node
395  /// have their own auto-generator for automatically constructing temporary
396  /// shader from their inputs (siblings).
399  /// @}
400 
401  /// Gives the node a chance to initialize itself when it is first created.
402  /// This is only used for VOP_ParmGenerator nodes.
403  virtual void initializeNode();
404 
405  /// Called by VOP_CodeGenerator::afterAddNode to ensure that nodes
406  /// have been properly initialized. Some nodes weren't calling their
407  /// base class' initializeNode() resulting in only partial initialization.
408  bool isInitialized() const { return myInitialized; }
409 
410  /// Make sure that our parmname parameter (if we have one) doesn't
411  /// conflict with any other parmname parameter values.
412  virtual void ensureParametersAreValid();
413  static void incrementVariableName(UT_String &varname);
414 
415  /// @{ Some variable names may contain characters that are illegal in
416  /// C-style variable names. Eg, Snippet VOP may allow colons to indicate
417  /// namespaced attributes which get bound to VEX parameters/variables.
418  /// To ensure the variable name is valid, such characters are encoded
419  /// using only alphanumeric (and underscore) characters.
420  /// The decode function reverses such encoding.
421  static UT_StringHolder ensureValidVarName(const UT_StringHolder &var);
422  static UT_StringHolder decodeVarName(const UT_StringHolder &var);
423  /// @}
424 
425  /// Functions to get information about our operator outputs.
426  /// These just call the getOutputXXXSubclass functions.
427  void getOutputName(UT_String &out, int idx) const override;
428  void getOutputName(UT_StringHolder &out, int idx) const
429  { UT_String tmp; getOutputName(tmp, idx); out.adoptFromString(tmp); }
430  int getOutputFromName(const UT_String &out) const override;
431  VOP_Type getOutputType(int idx);
432  void getOutputTypeInfo(VOP_TypeInfo &type_info,
433  int idx) const;
434  VOP_Type getNamedOutputType(const OP_ConnectorId& output_name);
435  void getNamedOutputTypeInfo(VOP_TypeInfo &type_info,
436  const OP_ConnectorId& output_name);
437  /// Obtains annotations (tags) for the variable value pushed out on
438  /// the given output connector. The tags are arbitrary, but are primarily
439  /// used to denote the contents of arrays (ie, export name for the value).
440  VOP_VariableTagsHandle getOutputVariableTags(int idx,
441  VOP_Type shader_type) const;
442  VOP_VariableTagsHandle getNamedOutputVariableTags(
443  const OP_ConnectorId& output_name,
444  VOP_Type shader_type) const;
445 
446  /// Returns variable tags provided by an input node on the given input idx.
447  VOP_VariableTagsHandle getVariableTagsFromInputNode( int idx,
448  VOP_Type shader_type) const;
449 
450  /// @{ Virtuals for obtaining inputs from which to copy shader layer
451  /// exports variable tags and which exports to add, for a given output.
452  virtual UT_IntArray getShaderLayerExportsInputsToCopy(int out_idx,
453  VOP_Type shader_type);
454  virtual UT_StringHolder getShaderLayerExportsToAdd(int out_idx,
455  VOP_Type shader_type);
456  /// @}
457 
458 
459  /// Returns the variable name associated with a given input number.
460  /// These just call the getInputXXXSubclass functions.
461  void getInputName(UT_String &in, int idx) const override;
462  void getInputName(UT_StringHolder &in, int idx) const
463  { UT_String tmp; getInputName(tmp, idx); in.adoptFromString(tmp); }
464  int getInputFromName(const UT_String &in) const override;
465 
466  /// will_autoconvert_out, if not null, is set to true if autoconversion
467  /// will be needed, to false otherwise.
468  VOP_Type getInputType(int idx) const;
469  void getInputTypeInfo(VOP_TypeInfo &type_info,
470  int idx) const;
471  VOP_Type getNamedInputType(const OP_ConnectorId& input_name);
472  void getNamedInputTypeInfo(VOP_TypeInfo &type_info,
473  const OP_ConnectorId& input_name);
474 
475  // Whether the visibility flag has been set in the operator type property.
476  // This is not the same flag as the one in OP_Input.
477  bool getIsInputVisibleDefault(int idx) override;
478 
479  /// Returns currently allowed input types for a given input, regardless
480  /// of what is connected to that input at the moment.
481  /// These do not include types to which autoconversion is possible.
482  virtual void getAllowedInputTypeInfos(unsigned idx,
483  VOP_VopTypeInfoArray &typeinfos);
484  virtual void getAllowedInputTypes(unsigned idx,
485  VOP_VopTypeArray &voptypes);
486 
487  /// Returns all allowed types for a given input, regardless of what is
488  /// currently wired to that input *and* regardless of what subset of all
489  /// these types is currently legal due to pruning of invalid signatures
490  /// (input types) on a script node (etc).
491  /// This is similar to getAllowedInputTypeInfos(), but unlike it, this
492  /// method returns types belonging to invalid signatures.
493  void getAllAllowedInputTypeInfos(unsigned idx,
494  VOP_VopTypeInfoArray &typeinfos);
495 
496  /// Get the nuber of signatures that the node has, and obtain the i-th
497  /// signature name.
498  /// The VOP signatures apply mostly to the VOP HDAs,
499  /// where a user can define several signatures for the operator (a
500  /// signature is a set of input types, and the user provides a name
501  /// associated with each such set). The build-in operators ususally have
502  /// only a single signature, and thus don't bother to provide any
503  /// distinguishing name for it (but they may).
504  virtual int getSignatureCount() const;
505  virtual void getSignatureName(UT_String &name, int index) const;
506 
507  /// Sets the current signature. The name must be a valid signature
508  /// recognized by the node. Also it should be possible to switch to that
509  /// signature, which may not be possible due to the types of connected
510  /// inputs, which limit the aplicability of some signatures.
511  virtual void setCurrentSignature(const char *name);
512  /// Obtains the current signature name.
513  virtual bool getCurrentSignatureName(UT_String &name);
514 
515  /// Some variables associated with vop inputs can be overriden or set
516  /// without an explicit wire to that input.
517  /// The override comes from an output connector of another node,
518  /// encoded as <node, output index> pair.
519  using InputVariableOverride = std::pair<VOP_Node*, int>;
520  void setInputVariableOverride(int input_index,
521  const InputVariableOverride &var_override);
522  InputVariableOverride getInputVariableOverride(int input_index) const;
523 
524  /// Returns true if the output variables of this node should not be
525  /// renamed in the code (in an attempt to avoid name collisions);
526  /// it usually applies to the shader output parameters in a given context.
527  /// If so, the second function returns the name of this output variable.
528  /// The version with VOP_CodeGenContext argument should be used.
529  virtual bool areOutputVariablesFixed(const VOP_CodeGenContext &ctx);
530  virtual bool areOutputVariablesFixed(VOP_ContextType context_type);
531  virtual void getFixedOutputVariable(UT_String &var, int idx);
532 
533  /// Returns the variable name (in the generated code) that corresponds to
534  /// the node's idx-th output. Usually it's just the output name.
535  virtual void getOutputVariableName(UT_String &var, int idx) const;
536 
537  /// If node explicitly declares variables by itself (eg, subnet), it should
538  /// report such types with this method, in case it uses some custom
539  /// data type that needs to be defined in the shader code (eg, struct).
540  /// Most nodes don't need to override this, since code generator knows
541  /// what types it used for this node's (output connector) variables.
542  virtual void getExtraTypesToDefine( UT_Array<VOP_TypeInfo> &types );
543 
544  /// Returns true if the methods below should consider only the inputs
545  /// of this node that belong to the given shader context.
546  /// Most nodes indiscriminately merge all their inputs, but some (like
547  /// Material Buider VOP) need pick inuts that belong to the given context.
548  virtual bool shouldCheckInputContextForMergeInputNodeList() const;
549 
550  /// Recurse through our inputs and add them in order to the given list.
551  /// Note this this might create new auto-conversion nodes in this list,
552  /// and these will have to be deallocated by the caller (using
553  /// the utility function deleteAutoNodesIn())
554  void mergeInputNodeList(VOP_NodeList &nodes,
555  const VOP_CodeGenContext *context = nullptr);
556  void mergeInputNodeListInternal(VOP_NodeList &nodes,
557  VOP_NodeList &extraterminals,
558  const VOP_CodeGenContext *context = nullptr);
559 
560  /// Scans the node list and deletes the auto convert nodes (and replaces
561  /// them with NULLs in the list). Also, clears any auto-convert information
562  /// for all other nodes in the list. Note, thet the node list is usually
563  /// constructed with mergeInputNodeList() method.
564  static void deleteAutoNodesIn(VOP_NodeList& nodes);
565 
566  /// Determines if this is a terminal node. Ie, whether this node is a
567  /// code sink that culminates (one of) the shader calculations.
568  /// The culmination may be in the form of setting the global variable,
569  /// setting an export parameter, or a general reqest by a user to
570  /// ensure the node is part of the shader (eg, print vop).
571  /// The code code generator determines all the nodes that participate
572  /// in the shader definition by by recursively traversing the inputs
573  /// starting from this node.
574  /// @param check_shader_context Is true when the node should consider
575  /// the shader context name/type contained in the code gen context
576  /// parameter; the node should return true only if it really
577  /// is a terminal node for the given shader type.
578  /// Otherwise, if false, the node can disregard the shader type
579  /// most likely because it lives in a single-context vopnet.
580  virtual bool forceCodeGenerationOfInputs(
581  const VOP_CodeGenContext &context,
582  bool check_shader_context) const;
583 
584  /// Returns true if the node can and should initiate generation of code
585  /// in the given context. If, if the node is a terminal node.
586  bool forceCodeGenerationInContext(
587  const VOP_CodeGenContext &context)const;
588 
589  /// Returns true if the given output represents an export variable for
590  /// a shader of a type specified by context.
591  bool isInputForShaderType(int input_idx,
592  const VOP_CodeGenContext &context)const;
593  bool isOutputForShaderType(int output_idx,
594  const VOP_CodeGenContext &context)const;
595 
596  /// @ Returns a node that implements or represents the given shader type.
597  /// The returned node may be a stand-alone (self-contained) shader node,
598  /// or a building-block node from which a shader of a given type can
599  /// be generated.
600  virtual VOP_Node *findShader(VOP_Type shader_type, fpreal now);
601 
602  /// Returns all applicable shader nodes and their corresponding shader
603  /// types, and if applicable output names.
604  /// Output names become important when a VOP node is a subnetwork
605  /// containing a few surface shaders, one for different renderer.
606  /// Note, some returned output names may correspond to a AOV data (eg,
607  /// the output type may be float or a vector rather than a shader type),
608  /// in which case the shader type will be reflect that.
609  virtual void findAllShaders( VOP_NodeList &shader_nodes,
610  VOP_ShaderTypeList &shader_types,
611  UT_StringArray &output_names );
612  /// @}
613 
614  /// Returns true if the VOP can represent a shader. Ie,
615  /// whether it can be converted into a shader.
616  virtual bool canDefineShader() const;
617 
618  /// Returns true if the VOP is a stand-alone shader (and not
619  /// a building-block for a shader).
620  /// The VOP may generate the code from its children VOPs, point to
621  /// an external file, or store the code in the HDA section.
622  /// But, it represents a self-contained shader code, which can be invoked
623  /// for shading an object (surface), used as an encapsulated shader (CVEX
624  /// shader for geometry procedurals, like fur), or called from another
625  /// shader (as a shader function call).
626  virtual bool isShader() const;
627 
628  /// Returns true if the VOP is a stand-alone shader (and not a
629  /// building-block for a shader), and can provide the shader code for
630  /// a shader of the given type. Note, material VOP may return true for
631  /// several shader types, such as both surface and displacement.
632  virtual bool isShader(VOP_Type shader_type) const;
633 
634  /// Returns true if the VOP is directly translatable to a USD primitive.
635  /// Ie, it is not a shader code building-block VOP.
636  virtual bool translatesDirectlyToUSD() const;
637 
638  /// Returns ture if the node represents a USD NodeGraph, and false
639  /// if it is a USD Material.
640  virtual bool isUSDNodeGraph() const;
641 
642  /// Returns true if the node has pre-generated shader code and is not
643  /// using network to generate it. This mainly applies to digital assets
644  /// that store shader code in their sections (whether or not they also
645  /// store the network contents).
646  virtual bool isCachedShader() const;
647 
648  /// Returns true if the operator represents an externally defined shader
649  /// such as a Geometry Shader, or a shader whose code is saved in a file
650  /// on disk separately from the operator or HDA definition.
651  bool isExternalShader() const;
652 
653  /// Returns true if this is a subnetwork which generates an encapsulated
654  /// shader. For example the SubnetCVEX VOP. Parent material passes
655  /// encapsulated shaders as shader string to other shaders (usually,
656  /// geometry procedurals) to calculate certain properties dynamically.
657  /// And to construct shader string there are some restrictions on
658  /// encapsulated shaders (eg, their inputs can be only wired to constants
659  /// and parameter VOPs).
660  // TODO: But there is little distinction between them and regular shaders,
661  // so remove this method. The difference is really how they are used
662  // (ie, whether the shader string of the main shader like fur
663  // procedural contains the shader string for this cvex 'encapsulated'
664  // shader. But, to distinguis that, the clerk calls
665  // hou.VopNode.shaderString(as_encapsulated=True)
666  virtual bool isEncapsulatedShader() const;
667 
668  /// Material VOP may be able to return a procedural node.
669  virtual VOP_Node *getProcedural(VOP_Type type);
670 
671  /// @{ Returns the name, type, and render mask of the VOP shader.
672  virtual UT_StringHolder getShaderName(
673  VOP_ShaderNameStyle style,
674  VOP_Type shader_type) const;
675  UT_StringHolder getShaderName(bool forvex,
676  VOP_Type shader_type) const;
677  virtual UT_StringHolder getShaderNameForSignature(
678  const UT_StringRef &signature) const;
679 
680  virtual VOP_Type getShaderType() const;
681  const char * getRenderMask() const;
682  /// @}
683 
684  /// @{ For expanding compiler string used in auto code generator.
685  bool evalVariableValue(
686  UT_String &v, int index, int thread) override;
688  fpreal &v, int i, int thr) override
689  { return OP_Network::evalVariableValue(v,i,thr); }
690  /// @}
691 
692  /// @{
693  /// Obtains a coshader node (or array of nodes) associated with the parm.
694  /// Usually, the co-shader computes the value for the parameter, and
695  /// is represented as a wired input to the main shader node.
696  /// If no coshaders are wired in, the output list is empty.
697  void getCoShaderNodes(UT_ValArray<VOP_Node *> &coshaders,
698  const char* parm_name);
699  void getCoShaderNodesOutputNames(UT_StringArray &outputs,
700  const char* parm_name);
701  /// @}
702 
703  /// Writes out the shader code from the cache to the given output stream.
704  /// Returns true if successful, otherwise, returns false, if there's no
705  /// cached shader code for this context.
706  virtual bool getCachedShaderCode(std::ostream &os,
707  VOP_ContextType context_type) const;
708 
709  /// @{
710  /// To be able to use Cvex VOP in Attribute SOP, etc.
711  using VexBuildFn1 = void (*)(VOP_Node*, UT_String&, fpreal, OP_Node*,
715  static void setBuildVexScriptCB(VexBuildFn1 fn1, VexBuildFn2 fn2);
716  void buildVexScript(
717  UT_String &result,
718  fpreal t,
719  OP_Node *parent,
720  UT_Map<int, bool> *visited) override;
721  void buildVexScript(
722  UT_String &result,
723  fpreal t,
724  DEP_MicroNode *depnode,
725  UT_Map<int, bool> *v) override;
726  /// @}
727 
728 
729  /// @{ Returns true if the VOP represents a method inside a class.
730  virtual bool isVopMethod() const;
731  virtual bool isVopMethodPublic() const;
732  /// @}
733 
734  /// @{ If the node represents a function, a method, or a shader,
735  /// then these functions return the info (name, return type, args) about
736  /// the function or a shader function as it appears in the source code.
737  virtual void getVopFunctionName(UT_String &function_name) const;
738  virtual void getVopFunctionReturnInfo(VOP_FunctionArgInfo &i) const;
739  virtual void getVopFunctionArgInfos(
740  UT_Array<VOP_FunctionArgInfo> &arg_infos);
741  /// @}
742 
743  /// Obtains shader parameters information.
744  void getShaderArgInfos(
746  VOP_Type shader_type);
747 
748  /// Checks whether the given parm belongs to the shader of a given type.
749  bool isParmForShaderType(const PRM_Parm &parm,
750  VOP_Type shader_type, bool check_context_tag);
751 
752  /// Helper method for getVopFunctionArgInfos() to obtain shader function
753  /// parameter infos based on the node inputs and outputs.
754  /// Optionally, the method can prefix function argument names with an
755  /// underscore, which is customary for shaders based on subnets. If so,
756  /// the variable name will be also implicitly prefixed (otherwise,
757  /// it would most likely be resolved to an input value).
758  /// If argument name is not prefixed, the local variable used in a call
759  /// may still be optionally prefixed (when needed to avoid var replacement).
760  void getVopFunctionArgInfosFromInputsAndOutputs(
761  UT_Array<VOP_FunctionArgInfo> &arg_infos,
762  int first_input, int last_input,
763  int first_output, int last_output,
764  bool prefix_input_arg_and_var_names,
765  bool prefix_input_var_names = false,
766  const VOP_CodeGenContext *context = nullptr);
767 
768  /// Helper method to obtain shader function parameter infos based on
769  /// the node parameters.
770  void getVopFunctionArgInfosFromNodeParameters(
772  const VOP_CodeGenContext *context = nullptr);
773  void getVopFunctionArgInfosFromNodeParameters(
775  VOP_Type shader_type);
776 
777  /// Helper method to obtain shader function parameter infos based on
778  /// the node inputs, outputs, and parameters.
779  void getVopFunctionArgInfosFromInputsOutputsAndParms(
780  UT_Array<VOP_FunctionArgInfo> &arg_infos,
781  int first_input, int last_input,
782  int first_output, int last_output,
783  bool prefix_input_arg_and_var_names,
784  bool prefix_input_var_names = false,
785  const VOP_CodeGenContext *context = nullptr);
786 
787  /// Helper method to obtain shader function parameter infos based
788  /// on writable global variables in the shader's context.
789  /// Used for shader call, that explicitly binds shader parameters
790  /// to callee's globals, by listing them as arguments.
791  void getVopFunctionArgInfosFromGlobals(
792  UT_Array<VOP_FunctionArgInfo> &arg_infos,
793  VOP_Type shader_type );
794 
795  /// Helper method to obtain all known export parameters from a shader node.
796  virtual void getVopFunctionArgInfosFromExports(
797  UT_Array<VOP_FunctionArgInfo> &arg_infos,
798  VOP_Type shader_type );
799 
800  /// Gives this node a chance to register an interest in a varialbe that
801  /// the upstream vop computes, but only optionally when explicitly asked.
802  virtual void registerExtraVarRequests(
803  VOP_ExtraVarRequests &extra_var_requests,
804  const VOP_CodeGenContext &context);
805 
806  /// Removes entries that correspond to a shader function parameters
807  /// at a default value (or unconnected).
808  /// If @p keep_export_args is true, all exports args are kept, even
809  /// if they are at default. Otherwise, at-default exports are pruned.
810  void pruneVopFunctionArgInfos(
812  bool keep_all_export_args = false );
813 
814  /// Returns true if the parameter of a given name is at default value.
815  /// If the parameter template is also given, it is used for default value,
816  /// otherwise the parameter's template is used.
817  bool isParmAtDefaultValue( const char *parm,
818  const PRM_Template *tplate = nullptr ) const;
819 
820  /// Writes declarations of variables used as argument to a function call.
821  /// @param[out] buffer
822  /// Outgoing argument that is filled with variable declarations.
823  /// @parm[in] arg_infos
824  /// Information about inputs/output variables to write out.
825  /// @parm[in] use_defined_input_defaults
826  /// Flags whether the input variables should be initialized to
827  /// special defaults defined by the owner subnet. If true, any
828  /// unconnected inputs will be initialized to such specially defined
829  /// defaults (connected inputs will be initialized to incoming
830  /// variables corresponding to the incoming wire). If false, the
831  /// input defaults defined by owner subnet are not used, and all
832  /// inputs are initialized to incoming variables, which resolve to
833  /// the value if input is connected or to the empty constant or node
834  /// parm value.
835  void outputVopFunctionVariableDeclarations(UT_WorkBuffer &buffer,
836  const UT_Array<VOP_FunctionArgInfo> & arg_infos,
837  bool use_defined_input_defaults);
838 
839  /// @{ Constructs a shader call, assuming this node represents a shader.
840  UT_StringHolder getVopFunctionCallName(const VOP_CodeGenContext &ctx);
841  void getVopFunctionCallCode(UT_String &codestr,
842  const VOP_CodeGenContext &ctx);
843  void getVopFunctionCallModules(UT_StringArray &modules,
844  const VOP_CodeGenContext &ctx);
845  void appendVopFunctionArgument(UT_StringArray &arg_names,
846  UT_StringArray &arg_vals,
847  const VOP_FunctionArgInfo &arg_info);
848  /// @}
849 
850  /// Returns true if the code generator should declare local variables
851  /// for this node's outputs. Returns false, if node declares them itself.
852  virtual bool shouldOutputNodeVariableDeclarations() const;
853 
854  /// Get or set the table of global or local variables for this context.
855  /// The global variables are defined solely by the VEX context. The
856  /// data associated with each entry is the VEX_Type of the variable.
857  /// The local variables are those defined by Parameter ops. This
858  /// table provides a common place to look for variable name conflicts.
859  const VOP_GlobalVarMap *getGlobalVariables() const;
860  const VOP_ParmGeneratorMap *getLocalVariables() const;
861  const VOP_LocalChannelMap *getLocalChannels() const;
862  void setTables(const VOP_GlobalVarMap *globals,
863  VOP_ParmGeneratorMap *locals,
865  void setTablesFromVop(VOP_Node *vop);
866  void addLocalVariable(const UT_StringRef &varname,
867  VOP_ParmGenerator *definer);
868  void deleteLocalVariable(const UT_StringRef &varname);
869  void deleteLocalChannelDefiner( VOP_ParmGenerator *definer);
870  void getSortedGlobalVariableList(VOP_GlobalVarList &vars,
872  bool mustBeReadable,
873  bool mustBeWritable);
874 
875  /// Similar to getLocalVariables() but it returns a table of Parameter ops
876  /// that define subnet inputs rather than shader parameters.
877  virtual VOP_ParmGeneratorMap* getSubnetVariables();
878  VOP_ParmGeneratorMap* getParentSubnetVariables() const;
879  void addParentSubnetVariable(const char *varname,
880  VOP_ParmGenerator *definer);
881  void deleteParentSubnetVariable(const char *varname);
882 
883  /// Returns true if input variables should be prefixed inside the subnet.
884  virtual bool shouldPrefixInputVariablesInsideSubnet() const;
885 
886  /// Returns true if parm nodes that define subnet connectors are treated
887  /// as shader parms. This is true for subnet material (or shader) nodes.
888  virtual bool usesSubnetConnectorsAsShaderParms() const;
889 
890  /// Returns true if shader parameters should be displayed as node inputs
891  /// and outputs. This is true for subnet shader nodes.
892  virtual bool showsShaderParmsAsSubnetConnectors() const;
893 
894  /// Informs this node that some descendent (but not immediate child)
895  /// was added and it represents a shader input or output.
896  virtual void shaderParmGrandChildAdded(VOP_Node *grand_child);
897  virtual void shaderParmGrandChildChanged(VOP_Node *grand_child);
898  virtual void shaderParmGrandChildDeleted(VOP_Node *grand_child);
899 
900  /// Functions for getting and setting the in/out LOD value, using the
901  /// OP_NodeFlag mechanism.
902  void setFlag(char flag, int8 val) override;
903  bool setInOutLOD(int level, bool inoff);
904  bool getInOutLOD(int level) const;
905  static int &getLODPref() { return theLODPref; }
906  static void setLODPref(int value);
907 
908  /// Override the setInput functions so that we can send notification to
909  /// the nodes that are our inputs when we disconnect from them.
910  OP_ERROR setInput(unsigned idx, OP_Node *op,
911  unsigned outputIdx = 0) override;
913  unsigned idx,
914  const char *label,
915  int keeppos,
916  unsigned outputIdx = 0) override;
917 
919  const OP_ConnectorId &input_name,
920  OP_Node *op,
921  const OP_ConnectorId* output_name = nullptr
922  ) override;
924  const OP_ConnectorId &input_name,
925  const char *label, int,
926  const OP_ConnectorId* output_name = nullptr
927  ) override;
928 
929  /// For subnet VOPs, when moving an input, we want to go in and
930  /// reorganize the connections to our subinput and suboutput nodes
931  /// so that the internal connections remain the same.
932  void moveInput(int srcidx, int dstidx,
933  bool forcesubnet = false) override;
934 
935  /// Return our input node for the give index. If recursive is true and we
936  /// are in a subnet and the direct input for inputidx is a subnet input
937  /// node, travel up the parent chain until no longer in a subnet or the
938  /// input node is not a subnet input node. Basically, we want to know if we
939  /// are connected to anything meaningful.
940  virtual bool isConnected(int inputidx, bool recursive);
941 
942  /// Returns a pointer used by OPUI_OutputNameEditor to get and set data.
944  { return 0; }
945 
946 
947  /// Some material vops cache a list of shader that needs to be dirtied.
948  virtual void dirtyShaderList();
949 
950  /// Used by subnet type operators which must always have an output node.
951  /// However, some specialty subnets, such as volume sampler, may return
952  /// NULL, since its output node is not a regular subnet output node that
953  /// determines subnet output connectors (which is for what the subnet base
954  /// class uses the output node returned by this method).
955  virtual VOP_Node *getSubnetOutputNode() const;
956 
957  /// Returns true if this node is immediatly inside a non-shader subnet.
958  bool isInNonShaderSubNetwork() const;
959 
960  /// Returns true if the node is considered a subnet's input node.
961  virtual bool isSubnetInput() const
962  { return false; }
963 
964  /// Returns the node from which to transfer information about local
965  /// variables used in source code generated by this node.
967  { return nullptr; }
968 
969  /// Returns true if code generator should attempt to copy info about
970  /// a variable corresponding to the i-th output connector.
971  virtual bool shouldPreResolveOutput(int output_index) const
972  { return true; }
973 
974  /// Returns true if the node is consdered an output node that represents
975  /// a shader or a function that connects to a Collect node.
976  virtual bool isOutputVopNode() const
977  { return false; }
978 
979  /// Retruns true if the node is an internal auto node used only during
980  /// code generation.
981  virtual bool isAutoVopNode() const
982  { return false; }
983 
984  /// Retruns true if the node is an internal auto-convert node.
985  virtual bool isAutoConvertNode() const
986  { return false; }
987 
988  /// Defines the different nodes that can be created and automatically
989  /// connected to a VOP node's input.
991  {
992  // Create a const VOP to connect to the input.
994  // Create a parm VOP to connect to the input.
996  // Create a subnet-scoped parm VOP to connect to the input.
998  };
999 
1000  /// Create a Parameter or Constant VOP that matches the type, name and
1001  /// value of one of our inputs, and connect it to that input. 'parm'
1002  /// specifies whether to build a Parameter or a Constant.
1003  VOP_Node *insertParmGenerator(int inputidx,
1004  InputParmGenType type);
1005  VOP_Node *insertNode(int inputidx, const char* nodetype,
1006  bool connect_to_input,
1007  const char* undo_string = NULL);
1008 
1009  int inputParmTypeIndex(int inputidx,
1010  const PRM_Parm* parm) const;
1011  const char *inputParmTypeString(int inputidx,
1012  const PRM_Parm *parm) const;
1013 
1014  /// When inserting a parameter (i.e. Promote Parameter), the source VOP is
1015  /// allowed to give us a source VOP_ParmGenerator if there's no
1016  /// corresponding parameter found. The source parm generator is used to
1017  /// initialize settings on the new parameter node.
1018  virtual VOP_ParmGenerator *getInsertParmGeneratorSource(int inputidx);
1019 
1020  /// Create Parameter or Constant VOPs for all inputs of this node. We
1021  /// don't create nodes for inputs that are already connected.
1022  /// If `created_vops` is not NULL, then the method will populate the table
1023  /// with the input names for the keys and the created VOP nodes for the
1024  /// values.
1025  void insertParmGeneratorsForAllInputs(
1026  InputParmGenType type,
1027  UT_SymbolMap<VOP_Node *> *created_vops=NULL);
1028 
1029  /// Create Bind Export VOPs for all outputs of this node.
1030  /// Set `subnet` to true to create subnet-scoped Bind Export VOPs that
1031  /// produce output connectors on the owner subnetwork.
1032  void insertBindExportsForAllOutputs(bool subnet);
1033  VOP_Node *insertBindExport(int outputidx, bool subnet);
1034 
1035  /// Updates the output connections based on the correspondence
1036  /// between old and new output names.
1037  void rewireOutputConnections(
1038  const UT_StringArray &old_names,
1039  const UT_StringArray &new_names );
1040 
1041  /// The following method is needed to obtain the parameter name to be
1042  /// associated with an input. It is possible that the parameter name
1043  /// differs from the input name.
1044  virtual void getParmNameFromInput(UT_String &parmname,
1045  int inputidx) const;
1046  virtual void getParmNameFromOutput(UT_String &parmname,
1047  int outputidx) const;
1048 
1049  /// Find the parameter associated with an input, if any
1050  const PRM_Parm *getParmFromInput(int inputidx) const;
1051  const PRM_Parm *getParmFromOutput(int outputidx) const;
1052 
1053  /// Based on the specified input index, output a parm definition block
1054  /// appropriate for a dialog script. The parm definition provides a
1055  /// default value for the input if it is not connected. If the input is
1056  /// VEX_TYPE_UNDEF, we output nothing and return false. Otherwise we return
1057  /// true.
1058  bool outputDefaultParmDefinition(std::ostream &os, int idx);
1059 
1060  /// Writes out the input and output connector definitions.
1061  void saveNodeInputAndOutputDefinitions(std::ostream &os);
1062 
1063  void saveDialogScriptExtraInfo(std::ostream &os) override;
1064 
1065  /// Saves the parameter values to the output stream.
1066  bool saveParmValues(std::ostream &os);
1067  /// Loads the parameter values to the output stream.
1068  bool loadParmValues(UT_IStream &is);
1069 
1070  /// This virtual is overridden by VOP_ParmGenerator so we can find out
1071  /// which VOP defines the actual parameter attributes.
1073  { return 0; }
1074 
1075  const VOP_Language *getLanguage() const
1076  { return myLanguage; }
1077  void setLanguage(const VOP_Language *language)
1078  { myLanguage = language; }
1079 
1080  /// Absolute width
1081  fpreal getW() const override;
1082  /// Absolute height
1083  fpreal getH() const override;
1084 
1085  /// Override clearInterrupted so that we don't recook the whole DOP Network
1086  /// when the user interrupts a cook. The clearInterrupted on the containing
1087  /// VOP Network willb be enough.
1088  void clearInterrupted() override;
1089 
1090  /// Calls cacheParmName on all VOP_ParmGenerator nodes under root.
1091  static void cacheAllParmNames(OP_Node *root);
1092  /// Calls recalculateParmDefiner on all VOP_ParmGenerator nodes under root.
1093  static void recalculateAllParmDefiners(OP_Node *root,
1094  bool dive_into_subnets = true,
1095  const UT_StringRef &target_parm_name
1096  = UT_StringRef());
1097 
1098  /// Returns true if the input will be auto-converetd, false otherwise.
1099  bool willAutoconvertInputType(int input_idx) override;
1100 
1101  /// Returns the type to which the input will be auto-convert. This is
1102  /// necessary because some inputs can take in a range of various types,
1103  /// and we need to know which one will be converting to. This function
1104  /// assumes that autoconversion is necessary. If it is not possible, or
1105  /// not needed, it returns VOP_TYPE_UNDEF.
1106  VOP_TypeInfo getAutoConvertTargetTypeInfo(int input_idx);
1107  VOP_Type getAutoConvertTargetType(int input_idx);
1108 
1109  // Similar to the getAutoConvertTargetType(), but takes in an input type
1110  // instead of trying to read it from the connected node. This is useful
1111  // when one needs to know what the incoming type will be converted to
1112  // before it is actually connected.
1113  VOP_TypeInfo getAutoConvertTypeInfoFromType(int input_idx,
1114  const VOP_TypeInfo &source_type);
1115  VOP_Type getAutoConvertTypeFromType(int input_idx,
1116  VOP_Type source_type);
1117 
1118  /// Do not call this method directly.
1119  void addAutoVopNodePointer(VOP_AutoNode* auto_node,
1120  int input_index);
1121  void clearAutoVopNodeInfos();
1122  VOP_AutoNode *getAutoVopNode(int input_idx);
1123  const VOP_AutoNode *getAutoVopNode(int input_idx) const;
1124  int getAutoVopNodeCount();
1125 
1126  // Returns the output information manager. The manager is responsible for
1127  // manipulating VOP_OutputInfo objects for each output. These objects
1128  // dictate how an output behaves when the node is in debug or bypass mode.
1129  // See VOP_OutputInfo for more information. Please note that by default,
1130  // an output info does not exist for any outputs, and is only created when
1131  // a debug/bypass value is changed.
1132  VOP_OutputInfoManager* getOutputInfoManager();
1133 
1134  // Appends code which overrides output values if necessary (uses
1135  // myOutputInfos below to determine this).
1136  void appendOutputOverrideCode(UT_String& str_code);
1137 
1138  // If this returns false, getCode() will not be called during code
1139  // generation on this node (appendOutputOverrideCode() still will). This is
1140  // useful when all outputs of this node are overriden, and no execution is
1141  // necessary.
1142  bool needToExecute();
1143 
1144  /// Do not call this method directly.
1145  void onNodeChange(OP_EventType type);
1146 
1147  OP_ERROR save(std::ostream &os,
1148  const OP_SaveFlags &flags,
1149  const char *path_prefix = "",
1150  const UT_String &name_override = UT_String()
1151  ) override;
1152  bool load(UT_IStream &is, const char *ext="",
1153  const char *path=0) override;
1154 
1155  /// Gets/sets the value of the debug flag on this node.
1156  bool getDebug() const override;
1157  bool setDebug(bool on_off) override;
1158 
1159  /// Gets/sets the value of the material flag on this node.
1160  bool getMaterialFlag() const;
1161  bool setMaterialFlag(bool on_off);
1162  virtual void initMaterialFlag();
1163 
1164  void getSubOutputAndSubInputs(OP_Node *&outputnode,
1165  OP_NodeList &inputnodes) const;
1166 
1167  void hideInput(int input_index, bool hide);
1168  void setReferenceTargetDefaults(int input_index,bool do_set);
1169  bool getAllowEditingParmDefaults(int input_index);
1170 
1171  /// Determine the VEX context type if the node is single-context type.
1172  /// For nodes in a multi-context vopnet returns
1173  /// VEX_INVALID_CONTEXT, because the specific VEX context cannot be
1174  /// reliably and unambiguously determined.
1175  // TODO: remove these methods
1176  VEX_ContextType getVexContextType() const;
1177  RSL_ContextType getRslContextType() const;
1178  OSL_ContextType getOslContextType() const;
1179 
1180  /// Determines if the vop can be interpreted as a single or several RSL/VEX
1181  /// context types (surface, disp, ..), by looking at code generator.
1182  /// Returns true if the vop node is multi-type and false if single-type.
1183  virtual bool isSingleContextType() const;
1184 
1185  /// Gets the context type (VEX_ContextType or RSL_ContextType) to which
1186  /// this node subscribes.
1187  /// In single-type vopnets, it is equal to the node's VEX/RSL context type.
1188  /// In multi-type vopnets, the exact type is variable and usually
1189  /// depends on the node's parameter value.
1190  VOP_ContextType getShaderContextType() const;
1191 
1192  /// Returns a parmmap string array where alternate entries contain key and
1193  /// value, where key is the vop parameter name and the value is the
1194  /// parameter name specified by the Parm VOP connected to the input
1195  /// corresponding to that vop parameter.
1196  virtual void getFixedParameterMap(UT_StringArray &parmmap);
1197 
1198  /// Returns an input map string array where alternate entries contain
1199  /// key and value, where key is the vop parameter name and the value is the
1200  /// node path specified for that parameter (usually connected into an
1201  /// input corresponding to that vop parameter).
1202  virtual void getShaderInputMap(UT_StringArray &inputmap);
1203 
1204  /// Utility function to check if a parm by a given name is a cvex shader.
1205  bool isCVEXPathParm(const char *parm_name) const;
1206 
1207  /// Obtains the template array for shader parameters.
1208  const PRM_Template *getShaderParmTemplates() override;
1209  static void refreshShaderParmTemplatesIfNeeded(OP_Node *n);
1210 
1211  /// Returns node parameters that should be authored as input attributes
1212  /// (shader parameters) on a USD shader prim.
1213  UT_ValArray<PRM_Parm *> getUSDShaderParms();
1214 
1215  /// Returns node parameters used to author a standard USD preview shader.
1216  UT_ValArray<PRM_Parm *> getUSDPreviewShaderParms();
1217 
1218  /// Returns true if the given parameter should currently be included
1219  /// in the USD shader parameters.
1220  /// Note, this is a dynamic test, and some nodes will consider a given
1221  /// parameter to be a USD shader parm under certain conditions but not
1222  /// under the others (eg, depending on signature).
1223  virtual bool allowUSDShaderParm(PRM_Parm &parm);
1224 
1225  /// Returns a set of parm tags relevant to authoring the USD preview shader.
1226  static const UT_Set<UT_StringHolder> &getUSDPreviewShaderTags();
1227 
1228  /// Deletes the input nodes for a given input (recursively), but
1229  /// only if none of them depend on anything other than this node.
1230  /// Returns true if any nodes were deleted, false otherwise.
1231  bool deleteIndependentInputNodes(int input_index);
1232 
1233  void getInputsRecursive(OP_NodeList& nodes_out);
1234  bool doesDependOnlyOn(const VOP_Node* other_node,
1235  int max_connections, bool recurse);
1236 
1237  /// Search through this node's inputs and return a list of parameter VOPs
1238  /// that appear in the input network. Recursively search through
1239  /// subnetworks as well. If this node is a parameter VOP, then add
1240  /// it to the list.
1241  void getParmInputs(VOP_ParmGeneratorList &parm_vops);
1242 
1243  /// Returns the node wired to this VOP's 'index' input tracing past
1244  /// simple VOPs like the Switch or Null VOP.
1245  VOP_Node *findSimpleInput(int index);
1246  /// Virtual helper to findSimpleInput() which returns the simple input
1247  /// node (ie the final node we look for) based on the request coming
1248  /// from the node connected to on the output of a given index.
1249  virtual VOP_Node *findSimpleInputFromOutput(int output_index)
1250  { return this; }
1251  /// A method that reports which immediate input connectors are considered
1252  /// by findSimpleInputFromOutput() method. This is useful when analyzing
1253  /// the simple input decision tree.
1254  virtual void findSimpleInputCandidatesFromOutput(int output_index,
1255  UT_IntArray & input_indices )
1256  { input_indices.clear(); }
1257 
1258  /// Gets a default value of an explicitly defined input (applies to subnets)
1259  virtual void getInputDefaultValue(UT_String &def, int idx) const;
1260 
1261  /// Gets number of outputs provided by a subnet, in addition to the outputs
1262  /// defined by wires connected to sub output.
1263  virtual int getNumNodeDefinedOutputs() const;
1264 
1265  /// @{ VOP subnets may restrict which inputs should show up in the
1266  /// Subnet Input and Subnet Output VOPs. These two methods control that.
1267  /// Gets number of subnet inputs available to subnet input/output children.
1268  /// Gets the subnet input index corresponding to the given index of
1269  /// (limited number of) input available to subnet input/output children.
1270  virtual int getNumSubnetInputsForChildren() const;
1271  virtual int getSubnetInputIndexForChildren(int child_input) const;
1272  int getChildConnectorIndexFromParent(int parent_input) const;
1273  virtual void getSubnetOutputTerminalChild(
1274  VOP_Node * &output_vop, int &input_idx,
1275  int subnet_output_idx ) const;
1276  /// @}
1277 
1278  /// Obtains additional nodes that should be copied or deleted when this
1279  /// node is copied or deleted.
1281  OP_NodeList &extras)const override;
1282 
1283  /// Some clerks add own stuff on creation. Any such action can be
1284  /// registered with this method.
1285  static void setRunCreateScriptCB( void (*)(const char *node_path,
1286  const char*render_mask, VOP_Type shader_type ));
1287 
1288  // Runs the creation script (if there is one). The return value is false
1289  // if the node was deleted while running the script. In this case
1290  // obviously the node pointer becomes invalid and should not be used
1291  // any more. It returns true if the node still exists.
1292  bool runCreateScript() override;
1293 
1294  void updateInputFlagsFromOperator(
1295  VOP_OperatorInfo *type_info,
1296  bool keep_visible);
1297 
1298  void onCreated() override;
1299  void hideNamedInput(const OP_ConnectorId& connector_name,
1300  bool hide);
1301 
1302  /// Returns all allowed input types on a given input, regardless of what
1303  /// is currently connected to that input. These do not include types
1304  /// to which autoconversion is possible.
1305  virtual void getAllowedNamedInputTypeInfos(
1306  const OP_ConnectorId& input_name,
1307  VOP_VopTypeInfoArray &typeinfos);
1308  virtual void getAllowedNamedInputTypes(
1309  const OP_ConnectorId& input_name,
1310  VOP_VopTypeArray &voptypes);
1311 
1312  VOP_TypeInfo getNamedAutoConvertTargetTypeInfo(
1313  const OP_ConnectorId& input_name);
1314  VOP_Type getNamedAutoConvertTargetType(
1315  const OP_ConnectorId& input_name);
1316  VOP_TypeInfo getNamedAutoConvertTypeInfoFromType(
1317  const OP_ConnectorId& input_name,
1318  const VOP_TypeInfo &source_type);
1319  VOP_Type getNamedAutoConvertTypeFromType(
1320  const OP_ConnectorId& input_name,
1321  VOP_Type source_type);
1322 
1324  const OP_ConnectorId& input_name
1325  ) override;
1326  VOP_Node *insertNamedNode(const OP_ConnectorId& input_name,
1327  const char* nodetype,
1328  bool connect_to_input,
1329  const char* undo_string = NULL);
1330 
1331  const OP_DataMicroNode &dataMicroNodeConst() const override
1332  { return myVopDataMicroNode; }
1333 
1334  /// Exposes protected method for taking over the errors from global manager.
1335  /// Should be used only by cerain helpers.
1337  { stealGlobalErrors(); }
1338 
1339  /// @{ Manipulate cook error dirty state
1340  void setErrorsDirty();
1341  void setErrorsClean(const OP_Context &context);
1342  bool areErrorsDirty(const OP_Context &context);
1343  /// @}
1344 
1345  /// Obtains the idx-th input type info from the connected input node.
1346  /// If not connected, type info is set to undefined.
1347  /// @param type_info The type info to fill out.
1348  /// @parm idx The index of the input from where to take the type.
1349  /// @param grow_inputs_to_idx
1350  /// If true and the the requested idx is larger than
1351  /// the input list size, then the list is expanded
1352  /// to make the requested index legal. Otherwise,
1353  /// list is kept constant and input is treated as NULL,
1354  /// resulting in an info for an undefined type.
1355  /// @return True if the info was obtained from the vop,
1356  /// otherwise false (info is set to undef, by default).
1357  bool getInputTypeInfoFromInputNode(
1358  VOP_TypeInfo &type_info, int idx,
1359  bool grow_inputs_to_idx = false) const;
1360 
1361  /// Obtains the idx-th input name based on a connected input node.
1362  /// If not connected, the name is "next".
1363  /// It's ensured that the name is unique even if many input nodes
1364  /// provide the same name.
1365  /// If check_output_names is true, the input name is ensured to be unique
1366  /// and different from the all the output names too.
1367  void getInputNameFromInputNode(UT_String &in, int idx,
1368  bool check_output_names)const;
1369 
1370  /// @{ Virtual overrides for evaluating parameters as render properties,
1371  /// in case the VOP node is a shader or a material.
1373  const UT_StringRef &name, fpreal now,
1374  OP_Node *&op, PRM_Parm *&parm,
1375  bool create_missing_multiparms,
1376  PRM_ParmList *obsolete = 0) override;
1378  const UT_StringRef &chname,
1379  fpreal now, OP_Node *&op,
1380  PRM_Parm *&parm, int &vector_index,
1381  PRM_ParmList *obsolete = 0) override;
1383  OP_PropertyLookupList &list) override;
1384  /// @}
1385 
1386  /// Queries information about visible connectors. This takes into account
1387  /// grouping of inputs, the current LOD flag, etc.
1388  int getInputVisibleIndex(int idx);
1389  const vop_ConnectorArray &getVisibleInputConnectors();
1390  int getOutputVisibleIndex(int idx);
1391  const vop_ConnectorArray &getVisibleOutputConnectors();
1392 
1393  /// Get or set the expansion state of an input group for this node.
1394  /// The information is stored in the user data.
1395  void setInputGroupExpanded(const UT_StringHolder &group,
1396  bool expanded);
1397  void setAllInputGroupsExpanded(bool expanded);
1398  bool getInputGroupExpanded(const UT_StringHolder &group);
1399 
1400  /// Fetches grouping information for all inputs whether they
1401  /// are visible or not. All inputs not in a group will be
1402  /// returned in the map with an empty string as the key.
1403  void getAllInputsGrouped(UT_StringArray &groups,
1405 
1406  /// Give this VOP ownership of a TIL_Thumbnail object. Deletes any
1407  /// thumbnail that was already here.
1408  void setThumbnail(TIL_Thumbnail *thumbnail);
1409  /// Returns a pointer to our thumbnail if we have one.
1410  TIL_Thumbnail *getThumbnail() const;
1411  /// Handle changes to our user data. This may require a redraw.
1412  void userDataChanged(const UT_StringHolder &key) override;
1413 
1414  // Global preferences controlled by the pref dialog.
1415  static bool getShowPreviewPref();
1416  static void setShowPreviewPref(bool show);
1417 
1418 protected:
1419  VOP_Node(OP_Network *parent, const char *name, OP_Operator *entry);
1420  ~VOP_Node() override;
1421 
1423  OP_Context &context,
1424  OP_NodeInfoParms &iparms) override;
1426  UT_InfoTree &tree,
1427  const OP_NodeInfoTreeParms &parms) override;
1428 
1429  void deleteCookedData() override;
1430  int saveCookedData(std::ostream &, OP_Context &,
1431  int binary = 0) override;
1432  int saveCookedData(const char *, OP_Context &) override;
1433  const char *getFileExtension(int) const override;
1434 
1435  OP_ERROR cookMe(OP_Context &) override;
1436  OP_ERROR bypassMe(OP_Context &, int &) override;
1437 
1438  virtual void preOpChanged(OP_EventType, void *)
1439  { }
1440  virtual void postOpChanged(OP_EventType, void *)
1441  { }
1442 
1443  /// @{ Helpers for getParameterOrProperty() and
1444  /// getParameterOrPropertyByChannel()
1445  bool getPropertyFromNode(
1446  const UT_StringRef &name, fpreal now,
1447  OP_Node *&op, PRM_Parm *&parm,
1448  bool add_missing_mparms, PRM_ParmList *obsolet);
1449  bool getPropertyFromNode(
1450  const UT_StringRef &chname, fpreal now,
1451  OP_Node *&op, PRM_Parm *&parm, int &vec_index,
1452  PRM_ParmList *obsolete);
1453  bool getPropertyFromCodeGen(
1454  const UT_StringRef &name, fpreal now,
1455  OP_Node *&op, PRM_Parm *&parm,
1456  bool add_missing_mparms, PRM_ParmList *obsolet);
1457  bool getPropertyFromCodeGen(
1458  const UT_StringRef &chname, fpreal now,
1459  OP_Node *&op, PRM_Parm *&parm, int &vec_index,
1460  PRM_ParmList *obsolete);
1461  bool getPropertyFromInputs(
1462  const UT_StringRef &name, fpreal now,
1463  OP_Node *&op, PRM_Parm *&parm,
1464  bool add_missing_mparms, PRM_ParmList *obsolet);
1465  bool getPropertyFromInputs(
1466  const UT_StringRef &chname, fpreal now,
1467  OP_Node *&op, PRM_Parm *&parm, int &vec_index,
1468  PRM_ParmList *obsolete);
1469  /// @}
1470 
1471  /// Gets the shader context type (VEX_ContextType
1472  /// or RSL_ContextType) to which a node belongs to.
1473  ///
1474  /// This method is meant to be overriden by nodes that can specify a single
1475  /// concrete context type when they are created in a multi-context vopnet.
1476  /// This method is invoked by getShaderContextType() to obtain the concrete
1477  /// type, if possible
1478  ///
1479  /// In multi-context vopnets, for nodes that explicitly specify a single
1480  /// context (such as an output node, usually determined from the node's
1481  /// parameter), this method returns such explicltly selected context
1482  /// type. For other nodes that don't explicltly choose a context, this
1483  /// method returns an invalid type, meaning such nodes don't have control
1484  /// over a specific type, and they belong to a type specified during code
1485  /// generation.
1486  virtual VOP_ContextType getSpecificShaderContextType() const;
1487 
1488  /// Obtains a list of shading contexts in which this node wants to initiate
1489  /// the generation of code.
1490  virtual void getContextsForCodeGeneration(
1491  UT_StringArray & context_names ) const;
1492 
1493  /// Functions to get information about our operator outputs.
1494  /// These functions are used for variable name replacement and for
1495  /// creating output labels on the op tiles.
1496  virtual void getOutputNameSubclass(UT_String &out, int idx) const;
1497  virtual VOP_Type getOutputTypeSubclass(int idx);
1498  virtual void getOutputTypeInfoSubclass(VOP_TypeInfo &type_info,
1499  int idx);
1500  virtual VOP_VariableTagsHandle getOutputVariableTagsSubclass(int idx,
1501  VOP_Type shader_type);
1502 
1503  /// Clears the cached info (name and type) about output connectors.
1504  void dirtyCachedOutputData();
1505 
1506  /// Returns the variable name associated with a given input number.
1507  /// Implementers of this function should also implement the reverse
1508  /// function.
1509  virtual void getInputNameSubclass(UT_String &in, int idx) const;
1510  virtual int getInputFromNameSubclass(const UT_String &in) const;
1511  int findInputFromInputName(const UT_String &in) const;
1512  virtual void getInputTypeInfoSubclass(VOP_TypeInfo &type_info,
1513  int idx);
1514  // Depreciated in favour of getInputTypeInfoSubclass():
1515  virtual VOP_Type getInputTypeSubclass(int idx);
1516  virtual bool getIsInputVisibleDefaultSubclass(int idx);
1517 
1518  /// @{ One of these two methods should be overriden in most VOP nodes.
1519  /// It is preferable to override the one that gets type infos, since
1520  /// they can encode complex types.
1521  /// They should fill in voptypes vector with vop types that are allowed to
1522  /// be connected to this node at the input at index idx.
1523  /// Note that this method should return valid vop types even when nothing
1524  /// is connected to the corresponding input.
1525  virtual void getAllowedInputTypeInfosSubclass(unsigned idx,
1526  VOP_VopTypeInfoArray &infos);
1527  virtual void getAllowedInputTypesSubclass(unsigned idx,
1528  VOP_VopTypeArray &voptypes);
1529  /// @}
1530 
1531  /// If the can only accept parameters as inputs, this method should return
1532  /// true. By default, this method checks the operator to see whether the
1533  /// VOP relies on external code (i.e. geometry procedurals)
1534  virtual bool getRequiresInputParameters() const;
1535 
1536  /// Disables parameters whose corresponding inputs are connected.
1537  bool disableConnectedParameters();
1538  bool updateParmsFlags() override;
1539  bool preUpdateParmsFlags() override;
1540  bool updateParmsActiveState(bool active);
1541 
1542  void addError(VOP_ErrorCodes code, const char *msg=0,
1543  const UT_SourceLocation *loc=0)
1544  { UTaddError("VOP", code, msg, loc); }
1545  void addMessage(VOP_ErrorCodes code, const char *msg=0,
1546  const UT_SourceLocation *loc=0)
1547  { UTaddMessage("VOP", code, msg, loc); }
1548  void addWarning(VOP_ErrorCodes code, const char *msg=0,
1549  const UT_SourceLocation *loc=0)
1550  { UTaddWarning("VOP", code, msg, loc); }
1551  void addFatal(VOP_ErrorCodes code, const char *msg=0,
1552  const UT_SourceLocation *loc=0)
1553  { UTaddFatal("VOP", code, msg, loc); }
1554 
1555  virtual void addDiagnosticInfo(const VCC_DiagnosticInfo &diag);
1556 
1557  /// This function is used to rewire nodes when we do a moveInput.
1558  static void rewireInputs(OP_Network *parent, OP_NodeList &inputs,
1559  int srcidx, int dstidx);
1560 
1562 
1563  void getAdditionalUndoNodes(const OP_NodeList& orig_list,
1564  OP_NodeList& nodes_for_input_undo) override;
1565 
1566  /// Save and load VOP version numbers
1568  std::ostream &os,
1569  const OP_SaveFlags &flags) override;
1570  bool loadPacket(
1571  UT_IStream &is,
1572  short class_id,
1573  short sig,
1574  const char *path = 0) override;
1575  bool loadPacket(
1576  UT_IStream &is,
1577  const char *token,
1578  const char *path = 0) override;
1579 
1580  /// If a subclass has VOP versioning, it should return a value greater
1581  /// than 0 for the latest version.
1582  virtual int getLatestVopVersion() const
1583  { return 0; }
1584 
1585  void getInputsRecursiveHelper(OP_NodeList& nodes_out,
1586  UT_Array<int> &array);
1587 
1588  bool doesDependOnlyOnHelper(const VOP_Node* other_node,
1589  int max_connections,
1590  bool recurse,
1591  UT_Array<int> &array);
1592 
1593  void onInputAllocated(
1594  OP_Input* new_input, int index) override;
1595 
1597  bool is_child_call = false) override;
1598 
1599  OP_ERROR getErrorSeverity() override;
1600  void ensureErrorsAreUpdatedSubclass() override;
1601 
1602  /// Generate the node errors.
1603  /// Return true if an error was generated and false otherwise.
1604  /// This method can be overridden to generate errors
1605  /// specific to the subclass.
1606  virtual bool generateErrorsSubclass();
1607 
1608  /// Returns true if the node should attempt testing its parameters
1609  /// for time dependence during the error generation pass.
1610  virtual bool shouldCheckTimeDependence() const;
1611 
1613 
1614  /// This returns true if it is okay to modify parms based on input changing
1615  /// and false otherwise. The decision is based on things like whether or
1616  /// not we are being loaded or running in a creation script.
1617  bool allowedToChangeParms();
1618 
1619  /// @{ Represents this node as a co-shader. Usually it just adds itself
1620  /// to the list, but some VOPs may represent a co-shader array, in which
1621  /// chase, they add a bunch of other VOPs that make up the array.
1622  virtual void representAsCoShader(UT_ValArray<VOP_Node*> &coshader);
1623  virtual void representAsCoShaderOutputName(UT_StringArray &name,
1624  int output_index);
1625  /// @}
1626 
1627  /// Ensures the given connector name does not have any conflicts
1628  /// with other connectors and is safe to use.
1629  /// If check_outputs' is true, the output names are checked for conflicts
1630  /// too, otherwise only inputs are tested.
1631  void findSafeConnectorNameBase(UT_String &in,
1632  bool check_outputs ) const;
1633 
1634  /// Returns the name the input connector would prefer to have,
1635  /// if we did not need to worry about multiple inputs having the same name.
1636  virtual void getTentativeInputName(UT_String &in, int idx) const;
1637 
1638  /// Returns the name the output connector would prefer to have,
1639  /// if we did not need to worry about multiple outputs having the same name.
1640  virtual void getTentativeOutputName(UT_String &out, int idx) const;
1641 
1642  /// Flag our visible connector info as dirty so it will be rebuilt the
1643  /// next time anyone asks for it.
1644  void setVisibleConnectorsDirty();
1645 
1646 private:
1647  /// Generate the node errors.
1648  void generateErrors(const OP_Context &context);
1649 
1650  /// Returns true if this node can access illuminance global variables.
1651  bool getIncludeIllumVars() const;
1652 
1653  /// Helper method for opChanged().
1654  /// Propagates the node change to the VOP code generator
1655  /// so that the code is re-generated and the exported parameters
1656  /// are updated.
1657  void propagateOpChangeToCodeGenerator(
1658  OP_EventType reason) const;
1659 
1660  /// Report a recursive loop error.
1661  void reportRecursiveLoopError();
1662 
1663  /// Get node type that should be used for promoting input at given index.
1664  const char *getParameterOpName(int input_index);
1665  const char *getConstantOpName(int input_index);
1666  bool isInputRampRBG(int input_index);
1667 
1668  /// Get the output index that should be used as parameter value.
1669  virtual int getParameterOpOutputIndex();
1670 
1671  /// Create Parameter VOPs for all inputs of this node. We
1672  /// don't create nodes for inputs that are already connected.
1673  /// If `created_vops` is not NULL, then the method will populate the table
1674  /// with the input names for the keys and the created VOP nodes for the
1675  /// values.
1676  void insertParmVOPsForAllInputs(
1678  UT_SymbolMap<VOP_Node *> *created_vops);
1679 
1680  /// Create Constant VOPs for all inputs of this node. We
1681  /// don't create nodes for inputs that are already connected.
1682  /// If `created_vops` is not NULL, then the method will populate the table
1683  /// with the input names for the keys and the created VOP nodes for the
1684  /// values.
1685  void insertConstantVOPsForAllInputs(
1686  UT_SymbolMap<VOP_Node *> *created_vops);
1687 
1688 
1689  /// Add entries to the string array for each struct member. These entries
1690  /// values come from the given parameter. The values use correct syntax
1691  /// for the given language.
1692  void getParmConstantStringForStruct(UT_StringArray &values,
1693  const VOP_TypeInfo &type_info,
1694  PRM_Parm &parm,
1695  const VOP_Language *language);
1696 
1697  /// Update our internal mapping of visible connectors to group names, input
1698  /// indices, etc.
1699  void updateVisibleConnectorInfo();
1700  void getParameterGroups(UT_StringMap<int> &group_map,
1701  UT_StringArray &group_names);
1702 
1703  const VOP_GlobalVarMap *myGlobalVariables;
1704  VOP_ParmGeneratorMap *myLocalVariables;
1705  VOP_LocalChannelMap *myLocalChannels;
1706  UT_UniquePtr<TIL_Thumbnail> myThumbnail;
1707  exint myLatestOpChangedId;
1708  unsigned int myMakingInputList : 1,
1709  myIsSearchingForParmInputs : 1,
1710  myInitialized : 1;
1711 
1712  static VOP_Node *theOriginalOpChanged;
1713  static exint theLatestOpChangedId;
1714  static int theLODPref;
1715  static bool theShowPreviewPref;
1716 
1717  using IntPair = std::pair<int, int>;
1718 
1719  VOP_AutoNodeInfoList myAutoVopNodeInfos;
1720  VOP_OutputInfoManager myOutputInfos;
1721  UT_Array<IntPair> myInputVariableOverrides;
1722 
1723  mutable UT_Lock myCachedDataLock;
1724  mutable int myCachedOutputNodeId;
1725  mutable UT_SymbolMap<int> myCachedOutputNames;
1726  mutable UT_ValArray< VOP_TypeInfo* > myCachedOutputTypeInfos;
1727 
1728  VOP_DataMicroNode myVopDataMicroNode;
1729  VOP_CodeGenerator *myAutoCodeGenerator;
1730  UT_Map<int, int> myVisibleInputIndexMap;
1731  vop_ConnectorArray myVisibleInputConnectors;
1732  UT_Map<int, int> myVisibleOutputIndexMap;
1733  vop_ConnectorArray myVisibleOutputConnectors;
1734  bool myVisibleConnectorsDirty;
1735 };
1736 
1737 #endif
virtual int saveCookedData(std::ostream &os, OP_Context &, int binary=0)=0
Reprsents a language for which VOPs can generate source code.
Definition: VOP_Language.h:27
UT_StringHolder myName
Definition: VOP_Node.h:108
virtual void buildVexScript(UT_String &script, fpreal t, OP_Node *owner, UT_Map< int, bool > *visitlist=0)
int getOutputIndex() const
Definition: VOP_Node.h:205
virtual bool getParameterOrProperty(const UT_StringRef &name, fpreal now, OP_Node *&op, PRM_Parm *&parm, bool create_missing_multiparms, PRM_ParmList *obsolete=0)
void adoptFromString(UT_String &str)
virtual bool updateParmsFlags()
fpreal getH() const override
Node position/scale is used by the UI.
VOP_ContextType myContextType
Definition: VOP_Node.h:110
std::pair< VOP_Node *, int > InputVariableOverride
Definition: VOP_Node.h:519
fpreal getW() const override
Node position/scale is used by the UI.
virtual void getInputName(UT_String &in, int idx) const
virtual bool willAutoconvertNamedInputType(const OP_ConnectorId &input_name)
Unsorted map container.
Definition: UT_Map.h:83
virtual bool isAutoVopNode() const
Definition: VOP_Node.h:981
#define SYS_VISIBILITY_EXPORT
const UT_StringHolder & getName() const
Definition: VOP_Node.h:185
#define VOP_IMPLEMENT_CASTS(NAME)
Definition: VOP_Node.h:360
void
Definition: png.h:1083
virtual void setFlag(char tag, int8 val)
bool myIsGroup
Definition: VOP_Node.h:251
UT_API UT_ErrorSeverity UTaddFatal(const char *type, int code, const char *msg=0, const UT_SourceLocation *loc=0)
const GLuint GLenum const void * binary
Definition: glcorearb.h:1923
GLsizei const GLchar *const * path
Definition: glcorearb.h:3340
const VOP_TypeInfo & getTypeInfo() const
Definition: VOP_Node.h:180
virtual void moveInput(int srcidx, int dstidx, bool forcesubnet=false)
int64 exint
Definition: SYS_Types.h:125
virtual bool preUpdateParmsFlags()
GLint level
Definition: glcorearb.h:107
vop_Connector(int groups_above, const UT_StringHolder &group_name, int index, bool expanded)
Definition: VOP_Node.h:234
virtual void finishedLoadingNetwork(bool is_child_call=false)
UT_ErrorSeverity
Definition: UT_Error.h:25
virtual bool isOutputVopNode() const
Definition: VOP_Node.h:976
Parameters for OP_Node::getInfoText()/OP_Node::getNodeSpecificInfoText()
UT_SymbolMap< VOP_ParmGeneratorList * > VOP_LocalChannelMap
Definition: VOP_Node.h:95
UT_SymbolMap< VOP_ParmGenerator * > VOP_ParmGeneratorMap
Definition: VOP_Node.h:94
GLuint const GLchar * name
Definition: glcorearb.h:785
virtual void getNodeSpecificInfoText(OP_Context &context, OP_NodeInfoParms &parms)
VOP_TypeInfo myTypeInfo
Definition: VOP_Node.h:112
UT_API UT_ErrorSeverity UTaddMessage(const char *type, int code, const char *msg=0, const UT_SourceLocation *loc=0)
GLdouble GLdouble t
Definition: glew.h:1403
GLuint buffer
Definition: glcorearb.h:659
virtual OP_ERROR cookMe(OP_Context &context)=0
GLuint in
Definition: glew.h:11552
GLdouble l
Definition: glew.h:9164
int VOP_ContextType
Definition: VOP_Types.h:151
void addFatal(VOP_ErrorCodes code, const char *msg=0, const UT_SourceLocation *loc=0)
Definition: VOP_Node.h:1551
static int & getLODPref()
Definition: VOP_Node.h:905
GLenum GLsizei GLsizei GLint * values
Definition: glcorearb.h:1601
std::unique_ptr< T, Deleter > UT_UniquePtr
A smart pointer for unique ownership of dynamically allocated objects.
Definition: UT_UniquePtr.h:33
virtual void clearInterrupted()
Definition: OP_Node.h:2462
virtual int getLatestVopVersion() const
Definition: VOP_Node.h:1582
virtual void saveDialogScriptExtraInfo(std::ostream &os)
GLenum array
Definition: glew.h:9108
GLuint64EXT * result
Definition: glew.h:14311
void stealGlobalErrors()
const VOP_Language * myLanguage
Definition: VOP_Node.h:1561
void(*)(VOP_Node *, UT_String &, fpreal, OP_Node *, UT_Map< int, bool > *) VexBuildFn1
Definition: VOP_Node.h:712
int myVopVersion
Definition: VOP_Node.h:1612
virtual void findSimpleInputCandidatesFromOutput(int output_index, UT_IntArray &input_indices)
Definition: VOP_Node.h:1254
GLint GLint GLsizei GLint GLenum GLenum type
Definition: glcorearb.h:107
virtual VOP_Node * getPreResolveVariableSrc() const
Definition: VOP_Node.h:966
#define VOP_API
Definition: VOP_API.h:10
bool isInitialized() const
Definition: VOP_Node.h:408
const VOP_TypeInfo & getAnyTypeInfo() const
Definition: VOP_Node.h:137
bool myIlluminanceVar
Definition: VOP_Node.h:115
std::shared_ptr< T > UT_SharedPtr
Wrapper around std::shared_ptr.
Definition: UT_SharedPtr.h:30
virtual OP_ERROR setInput(unsigned idx, OP_Node *op, unsigned outputIdx=0)
Sets a given input to connect to an output of a particular node.
const GLdouble * v
Definition: glcorearb.h:836
virtual OP_ERROR setNamedInput(const OP_ConnectorId &input_name, OP_Node *op, const OP_ConnectorId *output_name=nullptr)
New input functions that use names instead of indices.
void opChanged(OP_EventType reason, void *data=0) override
bool myIsExpanded
Definition: VOP_Node.h:250
virtual void preOpChanged(OP_EventType, void *)
Definition: VOP_Node.h:1438
virtual OP_ERROR saveIntrinsic(std::ostream &os, const OP_SaveFlags &flags)
virtual bool addOrMoveVisualizerToOutput(int outputidx)
Definition: OP_Node.h:3094
bool myWritable
Definition: VOP_Node.h:114
int myVarIndex
Definition: VOP_Node.h:111
GLuint GLsizei const GLchar * label
Definition: glcorearb.h:2544
const UT_StringHolder & getInitCodeStr() const
Definition: VOP_Node.h:195
virtual int getOutputFromName(const UT_String &out) const
virtual void userDataChanged(const UT_StringHolder &key)
UT_StringHolder myDescription
Definition: VOP_Node.h:109
UT_ValArray< VOP_ParmGenerator * > VOP_ParmGeneratorList
Definition: VOP_Node.h:91
virtual bool isSubnetInput() const
Returns true if the node is considered a subnet's input node.
Definition: VOP_Node.h:961
SYS_VISIBILITY_EXPORT void newVopOperator(OP_OperatorTable *table)
Definition: VOP_Switch.C:38
GLuint const GLuint * names
Definition: glew.h:2695
OP_OpTypeId
Definition: OP_OpTypeId.h:18
virtual bool getParameterOrPropertyByChannel(const UT_StringRef &chname, fpreal now, OP_Node *&op, PRM_Parm *&parm, int &vector_index, PRM_ParmList *obsolete=0)
GLenum GLenum GLenum GLenum mapping
Definition: glew.h:14162
int getInputIndex() const
Definition: VOP_Node.h:200
signed char int8
Definition: SYS_Types.h:35
bool evalVariableValue(fpreal &v, int i, int thr) override
For expanding compiler string used in auto code generator.
Definition: VOP_Node.h:687
GLbitfield flags
Definition: glcorearb.h:1595
bool myReadable
Definition: VOP_Node.h:113
virtual OP_DataType getCookedDataType() const =0
OSL_ContextType
RenderMan shader context types.
Definition: VEX_OslTypes.h:25
virtual OP_OpTypeId getOpTypeID() const
Definition: OP_Node.h:527
virtual void ensureErrorsAreUpdatedSubclass()
UT_Array< vop_Connector > vop_ConnectorArray
Definition: VOP_Node.h:253
virtual VOP_Node * findSimpleInputFromOutput(int output_index)
Definition: VOP_Node.h:1249
GLdouble n
Definition: glcorearb.h:2007
GLboolean * data
Definition: glcorearb.h:130
virtual bool getIsInputVisibleDefault(int idx)
virtual bool isAutoConvertNode() const
Retruns true if the node is an internal auto-convert node.
Definition: VOP_Node.h:985
virtual OP_ERROR setNamedInputReference(const OP_ConnectorId &input_name, const char *label, int, const OP_ConnectorId *output_name=nullptr)
virtual const char * getChildType() const
void addError(VOP_ErrorCodes code, const char *msg=0, const UT_SourceLocation *loc=0)
Definition: VOP_Node.h:1542
GLuint GLfloat * val
Definition: glcorearb.h:1607
**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
virtual VOP_OutputNameEditorSource * getOutputNameEditorSource()
Returns a pointer used by OPUI_OutputNameEditor to get and set data.
Definition: VOP_Node.h:943
virtual const char * getFileExtension(int binary) const =0
virtual int findParametersOrProperties(fpreal now, OP_PropertyLookupList &list)
virtual void getExtraNodesForCopyOrDelete(OP_NodeList &extras) const
void addWarning(VOP_ErrorCodes code, const char *msg=0, const UT_SourceLocation *loc=0)
Definition: VOP_Node.h:1548
Parameters for OP_Node::fillInfoTree()/OP_Node::fillInfoTreeNodeSpecific()
virtual void fillInfoTreeNodeSpecific(UT_InfoTree &tree, const OP_NodeInfoTreeParms &parms)
UT_ValArray< VOP_GlobalVarData * > VOP_GlobalVarList
Definition: VOP_Node.h:90
int myGroupsAbove
Definition: VOP_Node.h:248
void getInputName(UT_StringHolder &in, int idx) const
Definition: VOP_Node.h:462
fpreal64 fpreal
Definition: SYS_Types.h:277
OP_ERROR getErrorSeverity() override
GLuint index
Definition: glcorearb.h:785
virtual void referencedParmChanged(int pi)
void addMessage(VOP_ErrorCodes code, const char *msg=0, const UT_SourceLocation *loc=0)
Definition: VOP_Node.h:1545
vop_Connector(int groups_above, int index=-1)
Definition: VOP_Node.h:227
virtual const char * getOpType() const
UT_API UT_ErrorSeverity UTaddWarning(const char *type, int code, const char *msg=0, const UT_SourceLocation *loc=0)
virtual bool loadPacket(UT_IStream &is, short class_id, short sig, const char *path=0)
OP_EventType
Definition: OP_Value.h:22
virtual int getInputFromName(const UT_String &in) const
VOP_Type
Definition: VOP_Types.h:24
GLboolean GLuint group
Definition: glew.h:2750
UT_SharedPtr< const VOP_VariableTags > VOP_VariableTagsHandle
Definition: VOP_Node.h:83
GLsizei const GLfloat * value
Definition: glcorearb.h:823
OP_DataType
Definition: OP_DataTypes.h:28
virtual OP_OpTypeId getChildTypeID() const =0
const OP_DataMicroNode & dataMicroNodeConst() const override
Definition: VOP_Node.h:1331
virtual bool runCreateScript()
virtual bool evalVariableValue(UT_String &val, int index, int thread)
bool isExported() const
Definition: VOP_Node.h:210
constexpr T pi()
Pi constant taken from Boost to match old behaviour.
Definition: Math.h:118
VOP_ErrorCodes
Definition: VOP_Error.h:11
bool load(UT_IStream &is, const char *ext="", const char *path=0) override
virtual OP_ERROR save(std::ostream &os, const OP_SaveFlags &flags, const char *path_prefix="", const UT_String &name_override=UT_String())
VOP_ShaderNameStyle
The allowed name formats when asking for shader name.
Definition: VOP_Node.h:257
RSL_ContextType
RenderMan shader context types.
Definition: VEX_RslTypes.h:25
virtual void getOutputName(UT_String &out, int idx) const
virtual bool shouldPreResolveOutput(int output_index) const
Definition: VOP_Node.h:971
UT_SymbolMap< VOP_GlobalVarData * > VOP_GlobalVarMap
Definition: VOP_Node.h:93
UT_ValArray< VOP_Node * > VOP_NodeList
Definition: VOP_Node.h:87
virtual bool getDebug() const
Definition: OP_Node.h:1352
GLsizei GLenum GLenum * types
Definition: glcorearb.h:2541
virtual bool willAutoconvertInputType(int input_idx)
VOP_UIChangeType
Definition: VOP_Node.h:64
virtual VOP_CodeGenerator * getVopCodeGenerator()
Definition: OP_Node.h:2682
virtual void getAdditionalUndoNodes(const OP_NodeList &orig_list, OP_NodeList &nodes_for_input_undo)
Definition: OP_Network.h:902
void clear()
Resets list to an empty list.
Definition: UT_Array.h:549
VEX_ContextType
Definition: VEX_VexTypes.h:60
virtual VOP_Node * getRealDefinition()
Definition: VOP_Node.h:1072
void getOutputName(UT_StringHolder &out, int idx) const
Definition: VOP_Node.h:428
static const char * theChildTableName
Definition: VOP_Node.h:270
virtual void onInputAllocated(OP_Input *new_input, int index)
Overriden in VOPs.
Definition: OP_Node.h:3633
GLsizei GLuint * groups
Definition: glew.h:2749
const UT_StringHolder & getName() const
Definition: VOP_Node.h:126
UT_Array< VOP_AutoNodeInfo > VOP_AutoNodeInfoList
Definition: VOP_Node.h:102
virtual OP_ERROR bypassMe(OP_Context &context, int &copied_input)=0
const VOP_Language * getLanguage() const
Definition: VOP_Node.h:1075
GLenum GLsizei GLenum GLenum const void * table
Definition: glew.h:4970
virtual const PRM_Template * getShaderParmTemplates()
void stealGlobalErrorsForHelper()
Definition: VOP_Node.h:1336
UT_StringHolder myGroupName
Definition: VOP_Node.h:249
virtual VOP_CodeGenerator * getVopAutoCodeGenerator()
Definition: OP_Node.h:2683
UT_API UT_ErrorSeverity UTaddError(const char *type, int code, const char *msg=0, const UT_SourceLocation *loc=0)
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)
virtual void onCreated()
Overriden in VOPs.
Definition: OP_Node.h:3019
void setLanguage(const VOP_Language *language)
Definition: VOP_Node.h:1077
virtual bool setDebug(bool on_off)
Definition: OP_Node.h:1308
void(*)(VOP_Node *, UT_String &, fpreal, DEP_MicroNode *, UT_Map< int, bool > *) VexBuildFn2
Definition: VOP_Node.h:714
VOP_AutoNode * myAutoVopNode
Definition: VOP_Node.h:99
virtual void deleteCookedData()=0
InputParmGenType
Definition: VOP_Node.h:990
virtual OP_ERROR setInputReference(unsigned idx, const char *label, int keeppos, unsigned outputIdx=0)
Connects an input to particular node by name in the network.
virtual void postOpChanged(OP_EventType, void *)
Definition: VOP_Node.h:1440