HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
VOP_ScriptOperator.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_ScriptOperator.h ( VOP Library, C++)
7  *
8  * COMMENTS: OP_Operator for VOP classes.
9  */
10 
11 #ifndef __VOP_ScriptOperator__
12 #define __VOP_ScriptOperator__
13 
14 #include "VOP_API.h"
15 #include <UT/UT_String.h>
16 #include <UT/UT_Array.h>
17 #include <PI/PI_ScriptOperator.h>
18 #include "VOP_OperatorInfo.h"
19 
20 #define DEFAULT_INPUTSET_NAME "default"
21 #define DEFAULT_INPUTSET_LABEL "Default Inputs"
22 #define VOP_MATERIAL_OP_SUBTYPE_NAME "material"
23 
24 class VOP_CodeGenContext;
25 
26 
28 {
29 public:
30  VOP_ScriptOperator(const char *path,
31  const char *name,
32  const char *label,
33  int minInputs, int maxInputs,
34  const char *vopnetMask,
35  OP_Constructor construct,
36  const char *child_table_name,
37  PRM_Template *multiInputSetTemplates,
38  bool is_subnet);
39  ~VOP_ScriptOperator() override;
40 
41  static bool isMaterialOperator(const OP_OTLDefinition &);
42  static OP_ScriptOperator *createScriptOperator(const OP_OTLDefinition &);
43 
45  { return &myOperatorInfo; }
46  const OP_SpecificData *getOpSpecificData() const override
47  { return &myOperatorInfo; }
49  { return &myOperatorInfo; }
51  { return &myOperatorInfo; }
52 
53  int updateParmTemplates() override;
54  unsigned maxOutputs() override;
55  unsigned maxScriptOutputs();
56  const UT_StringHolder &getOutputName(int idx);
57  const UT_StringHolder &getOutputLabel(int idx);
58  const VOP_TypeInfo &getOutputTypeInfo(int idx, int inputset);
59 
60  const UT_StringHolder &getInputName(int idx);
61  const UT_StringHolder &getInputLabel(int idx);
62  const VOP_TypeInfo &getInputTypeInfo(int idx, int inputset);
63  bool getIsInputVisible(int idx);
64 
65  // True if op wants to triger code generation in a given context (
66  // eg surface, displacement, etc).
67  bool forceCodeGenerationOfInputs(
68  const VOP_CodeGenContext &ctx,
69  bool check_shader_context) const;
70 
71  const UT_String &getOuterCode() const;
72  const UT_String &getCode() const;
73 
74  bool wantsParametersAnimatable() const override;
75  bool wantsInputEditor() const override;
76  bool wantsParentInputs() const override;
77 
78  /// @{
79  /// Methods for querying the input sets (ie, operator signatures).
80  /// A VOP HDA may support inputs of different types (ints, floats),
81  /// and it can do it by defining a new input set (type signature) for
82  /// each such input type. On HDA it's done in Input/Output tab.
83  int getNumInputSets() const;
84  const char *getInputSetName(int index) const;
85  const char *getInputSetLabel(int index) const;
86  int getInputSetIndex(const char *name) const;
87  /// @}
88 
89  const PRM_Template *getBaseParmTemplates() override;
90 
91  void getAllowedInputTypes(unsigned idx, VOP_VopTypeArray &voptypes);
92  void getAllowedInputTypeInfos(unsigned idx, VOP_VopTypeInfoArray &voptypes);
93 
96 
99 protected:
100  const char *getAddedDSIncludePath() override;
102  UT_String &token) override;
103  bool addOutput(const UT_String &outtype,
104  const UT_String &name,
105  const UT_String &label);
106  bool addInput(const UT_String &intype,
107  const UT_String &name,
108  const UT_String &label);
110  UT_IStream &is,
111  const char *filename,
112  UT_String &scriptName,
113  PRM_ScriptImports *&imports) override;
114 
115 private:
116  // Just a convenience function that does something we need to do a lot.
117  // It checks if our .ds file is loaded yet, and loads it if required.
118  void ensureParmsAreLoaded();
119 
120  VOP_OperatorInfo myOperatorInfo;
121  PRM_Template *myMultiInputSetBase;
122  bool myIsSubnet;
123 };
124 
125 #endif
virtual bool wantsParametersAnimatable() const
const UT_StringHolder & getOutputLabel(int idx) const
const OP_SpecificData * getOpSpecificData() const override
GT_API const UT_StringHolder filename
GLuint const GLchar * name
Definition: glew.h:1814
virtual bool wantsParentInputs() const
GLuint index
Definition: glew.h:1814
static const UT_StringHolder kShaderExtraParameter
static const UT_StringHolder kPragmaHideInputUsingParameterVisibleState
int updateParmTemplates() override
const UT_StringHolder & getInputLabel(int idx) const
Accessing operator inputs name, label, and reference flag.
#define VOP_API
Definition: VOP_API.h:10
VOP_OperatorInfo * getVopOperatorInfo()
const VOP_OperatorInfo * getVopOperatorInfo() const
static const UT_StringHolder kHideInputUsingParameterVisibleState
const UT_StringHolder & getInputName(int idx) const
Accessing operator inputs name, label, and reference flag.
GLuint GLsizei GLsizei GLchar * label
Definition: glew.h:8986
OP_Node *(* OP_Constructor)(OP_Network *, const char *, OP_Operator *)
Definition: OP_Operator.h:104
GLsizei const GLchar *const * path
Definition: glew.h:6461
virtual unsigned maxOutputs()
Definition: OP_Operator.h:386
virtual int handleUnknownToken(DS_Stream &is, UT_String &token)
virtual bool wantsInputEditor() const
virtual const PRM_Template * getBaseParmTemplates()
Definition: OP_Operator.h:419
static const UT_StringHolder kPragmaShaderExtraParameter
OP_SpecificData * getOpSpecificData() override
virtual const char * getAddedDSIncludePath()
PRM_Template * loadParmTemplates(UT_IStream &is, const char *filename, UT_String &scriptName, PRM_ScriptImports *&imports) override