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