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  virtual ~VOP_ScriptOperator();
40 
41  static bool isMaterialOperator(const OP_OTLDefinition &);
42  static OP_ScriptOperator *createScriptOperator(const OP_OTLDefinition &);
43 
45  { return &myOperatorInfo; }
46  virtual const OP_SpecificData *getOpSpecificData() const
47  { return &myOperatorInfo; }
49  { return &myOperatorInfo; }
51  { return &myOperatorInfo; }
52 
53  virtual int updateParmTemplates();
54  virtual unsigned maxOutputs();
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  virtual bool wantsParametersAnimatable() const;
75  virtual bool wantsInputEditor() const;
76  virtual bool wantsParentInputs() const;
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  virtual const PRM_Template *getBaseParmTemplates();
90 
91  void getAllowedInputTypes(unsigned idx, VOP_VopTypeArray &voptypes);
92  void getAllowedInputTypeInfos(unsigned idx, VOP_VopTypeInfoArray &voptypes);
93 
94 protected:
95  virtual const char *getAddedDSIncludePath();
96  virtual int handleUnknownToken(DS_Stream &ds,
97  UT_String &token);
98  bool addOutput(const UT_String &outtype,
99  const UT_String &name,
100  const UT_String &label);
101  bool addInput(const UT_String &intype,
102  const UT_String &name,
103  const UT_String &label);
105  const char *filename,
106  UT_String &scriptName,
107  PRM_ScriptImports *&imports);
108 
109 private:
110  // Just a convenience function that does something we need to do a lot.
111  // It checks if our .ds file is loaded yet, and loads it if required.
112  void ensureParmsAreLoaded();
113 
114  VOP_OperatorInfo myOperatorInfo;
115  PRM_Template *myMultiInputSetBase;
116  bool myIsSubnet;
117 };
118 
119 #endif
virtual bool wantsParametersAnimatable() const
const UT_StringHolder & getOutputLabel(int idx) const
GT_API const UT_StringHolder filename
GLuint GLsizei const GLchar * label
Definition: glcorearb.h:2544
virtual bool wantsParentInputs() const
virtual PRM_Template * loadParmTemplates(UT_IStream &is, const char *filename, UT_String &scriptName, PRM_ScriptImports *&imports)
GLsizei const GLchar *const * path
Definition: glcorearb.h:3340
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:785
const UT_StringHolder & getInputName(int idx) const
Accessing operator inputs name, label, and reference flag.
OP_Node *(* OP_Constructor)(OP_Network *, const char *, OP_Operator *)
Definition: OP_Operator.h:90
virtual int updateParmTemplates()
virtual const OP_SpecificData * getOpSpecificData() const
virtual unsigned maxOutputs()
Definition: OP_Operator.h:386
virtual int handleUnknownToken(DS_Stream &is, UT_String &token)
GLuint index
Definition: glcorearb.h:785
virtual bool wantsInputEditor() const
virtual OP_SpecificData * getOpSpecificData()
virtual const PRM_Template * getBaseParmTemplates()
Definition: OP_Operator.h:419
virtual const char * getAddedDSIncludePath()