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