HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros 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 OP_ScriptOperator *createScriptOperator(const OP_OTLDefinition &);
42 
44  { return &myOperatorInfo; }
45  virtual const OP_SpecificData *getOpSpecificData() const
46  { return &myOperatorInfo; }
48  { return &myOperatorInfo; }
50  { return &myOperatorInfo; }
51 
52  virtual int updateParmTemplates();
53  virtual unsigned maxOutputs();
54  unsigned maxScriptOutputs();
55  const UT_String &getOutputName(int idx);
56  const UT_String &getOutputLabel(int idx);
57  const VOP_TypeInfo &getOutputTypeInfo(int idx, int inputset);
58 
59  const UT_String &getInputName(int idx);
60  const UT_String &getInputLabel(int idx);
61  const VOP_TypeInfo &getInputTypeInfo(int idx, int inputset);
62  bool getIsInputVisible(int idx);
63 
64  // True if op wants to triger code generation in a given context (
65  // eg surface, displacement, etc).
66  bool forceCodeGenerationOfInputs(
67  const VOP_CodeGenContext &ctx,
68  bool check_shader_context) const;
69 
70  const UT_String &getOuterCode() const;
71  const UT_String &getCode() const;
72 
73  virtual bool wantsParametersAnimatable() const;
74  virtual bool wantsInputEditor() const;
75  virtual bool wantsParentInputs() const;
76 
77  /// @{
78  /// Methods for querying the input sets (ie, operator signatures).
79  /// A VOP HDA may support inputs of different types (ints, floats),
80  /// and it can do it by defining a new input set (type signature) for
81  /// each such input type. On HDA it's done in Input/Output tab.
82  int getNumInputSets() const;
83  const char *getInputSetName(int index) const;
84  const char *getInputSetLabel(int index) const;
85  int getInputSetIndex(const char *name) const;
86  /// @}
87 
88  virtual const PRM_Template *getBaseParmTemplates();
89 
90  void getAllowedInputTypes(unsigned idx, VOP_VopTypeArray &voptypes);
91  void getAllowedInputTypeInfos(unsigned idx, VOP_VopTypeInfoArray &voptypes);
92 
93 protected:
94  virtual const char *getAddedDSIncludePath();
95  virtual int handleUnknownToken(DS_Stream &ds,
96  UT_String &token);
97  bool addOutput(const UT_String &outtype,
98  const UT_String &name,
99  const UT_String &label);
100  bool addInput(const UT_String &intype,
101  const UT_String &name,
102  const UT_String &label);
104  const char *filename,
105  UT_String &scriptName,
106  PRM_ScriptImports *&imports);
107 
108 private:
109  // Just a convenience function that does something we need to do a lot.
110  // It checks if our .ds file is loaded yet, and loads it if required.
111  void ensureParmsAreLoaded();
112 
113  VOP_OperatorInfo myOperatorInfo;
114  PRM_Template *myMultiInputSetBase;
115  bool myIsSubnet;
116 };
117 
118 #endif
virtual bool wantsParametersAnimatable() const
const UT_StringHolder & getOutputLabel(int idx) const
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:88
virtual int updateParmTemplates()
virtual const OP_SpecificData * getOpSpecificData() const
virtual unsigned maxOutputs()
Definition: OP_Operator.h:368
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:401
virtual const char * getAddedDSIncludePath()