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