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 DEFAULT_INPUTSET_SCRIPT_NAME ""
23 #define VOP_MATERIAL_OP_SUBTYPE_NAME "material"
24 
25 class VOP_CodeGenContext;
26 
27 
29 {
30 public:
31  VOP_ScriptOperator(const char *path,
32  const char *name,
33  const char *label,
34  int minInputs, int maxInputs,
35  const char *vopnetMask,
36  OP_Constructor construct,
37  const char *child_table_name,
38  PRM_Template *multiInputSetTemplates,
39  bool is_subnet);
40  ~VOP_ScriptOperator() override;
41 
42  static bool isMaterialOperator(const OP_OTLDefinition &);
43  static OP_ScriptOperator *createScriptOperator(const OP_OTLDefinition &);
44 
46  { return &myOperatorInfo; }
47  const OP_SpecificData *getOpSpecificData() const override
48  { return &myOperatorInfo; }
50  { return &myOperatorInfo; }
52  { return &myOperatorInfo; }
53 
54  int updateParmTemplates() override;
55  unsigned maxOutputs() override;
56  unsigned maxScriptOutputs();
57  const UT_StringHolder &getOutputName(int idx);
58  const UT_StringHolder &getOutputLabel(int idx);
59  const VOP_TypeInfo &getOutputTypeInfo(int idx, int inputset);
60 
61  const UT_StringHolder &getInputName(int idx);
62  const UT_StringHolder &getInputLabel(int idx);
63  const VOP_TypeInfo &getInputTypeInfo(int idx, int inputset);
64  bool getIsInputVisible(int idx);
65 
67 
68  // True if op wants to triger code generation in a given context (
69  // eg surface, displacement, etc).
70  bool forceCodeGenerationOfInputs(
71  const VOP_CodeGenContext &ctx,
72  bool check_shader_context) const;
73 
74  const UT_String &getOuterCode() const;
75  const UT_String &getCode() const;
76 
77  bool wantsParametersAnimatable() const override;
78  bool wantsInputEditor() const override;
79  bool wantsParentInputs() const override;
80 
81  /// @{
82  /// Methods for querying the input sets (ie, operator signatures).
83  /// A VOP HDA may support inputs of different types (ints, floats),
84  /// and it can do it by defining a new input set (type signature) for
85  /// each such input type. On HDA it's done in Input/Output tab.
86  int getNumInputSets() const;
87  UT_StringHolder getInputSetName(int index) const;
88  UT_StringHolder getInputSetLabel(int index) const;
89  UT_StringHolder getInputSetScriptName(int index) const;
90  int getInputSetIndex(const char *name) const;
91  /// @}
92 
93  const PRM_Template *getBaseParmTemplates() override;
94 
95  void getAllowedInputTypes(unsigned idx, VOP_VopTypeArray &voptypes);
96  void getAllowedInputTypeInfos(unsigned idx, VOP_VopTypeInfoArray &voptypes);
97 
100 
103 protected:
104  const char *getAddedDSIncludePath() override;
106  UT_String &token) override;
107  bool addOutput(const UT_String &outtype,
108  const UT_String &name,
109  const UT_String &label);
110  bool addInput(const UT_String &intype,
111  const UT_String &name,
112  const UT_String &label);
114  UT_IStream &is,
115  const char *filename,
116  UT_String &scriptName,
117  PRM_ScriptImports *&imports) override;
118 
119 private:
120  // Just a convenience function that does something we need to do a lot.
121  // It checks if our .ds file is loaded yet, and loads it if required.
122  void ensureParmsAreLoaded();
123 
124  VOP_OperatorInfo myOperatorInfo;
125  PRM_Template *myMultiInputSetBase;
126  bool myIsSubnet;
127 };
128 
129 #endif
virtual bool wantsParametersAnimatable() const
const UT_StringHolder & getOutputLabel(int idx) const
const OP_SpecificData * getOpSpecificData() const override
std::function< OP_Ptr(OP_Network *, const char *, OP_Operator *)> OP_Constructor
Definition: OP_Operator.h:107
GT_API const UT_StringHolder filename
GLuint GLsizei const GLchar * label
Definition: glcorearb.h:2545
virtual bool wantsParentInputs() const
static const UT_StringHolder kShaderExtraParameter
virtual UT_StringArray getScriptSignatureFunctions() const
static const UT_StringHolder kPragmaHideInputUsingParameterVisibleState
GLsizei const GLchar *const * path
Definition: glcorearb.h:3341
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
GLuint const GLchar * name
Definition: glcorearb.h:786
static const UT_StringHolder kHideInputUsingParameterVisibleState
const UT_StringHolder & getInputName(int idx) const
Accessing operator inputs name, label, and reference flag.
virtual unsigned maxOutputs()
Definition: OP_Operator.h:417
virtual int handleUnknownToken(DS_Stream &is, UT_String &token)
GLuint index
Definition: glcorearb.h:786
virtual bool wantsInputEditor() const
virtual const PRM_Template * getBaseParmTemplates()
Definition: OP_Operator.h:450
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