All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
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_ScriptNode.h ( VOP Library, C++)
7  *
8  * COMMENTS: This is the meat & potatoes. Here we have an operator which is
9  * defined by a script.
10  */
12 #ifndef __VOP_ScriptNode__
13 #define __VOP_ScriptNode__
15 #include "VOP_API.h"
16 #include "VOP_Node.h"
18 class VOP_ScriptOperator;
21 public:
22  VOP_ScriptNode(OP_Network *dad, const char *name, OP_Operator *op);
23  ~VOP_ScriptNode() override;
25  static OP_Node *myConstructor(OP_Network *net, const char *name,
26  OP_Operator *op);
27  static PRM_Template myMultiInputSetTemplateList[];
29  void initMaterialFlag() override;
30  void getModulesToImport(UT_StringArray &modules,
31  const VOP_CodeGenContext &context) override;
32  void getOuterCode(UT_String &codestr,
33  const VOP_CodeGenContext &context) override;
34  void getCode(UT_String &codestr,
35  const VOP_CodeGenContext &context) override;
37  const char *parmname,
38  const VOP_TypeInfo &type_info,
39  UT_String &str,
40  bool expand_string,
41  const VOP_Language *language=0) override;
43  void ensureParametersAreValid() override;
45  const char *inputLabel(unsigned idx) const override;
46  const char *outputLabel(unsigned idx) const override;
48  int getSignatureCount() const override;
49  void getSignatureName(
50  UT_String &name, int index) const override;
51  void setCurrentSignature(const char *name) override;
52  bool getCurrentSignatureName(UT_String &name) override;
55  unsigned idx,
56  VOP_VopTypeInfoArray &voptypes) override;
58  bool isShader() const override;
59  bool isShader(VOP_Type shader_type) const override;
60  bool isCachedShader() const override;
62  std::ostream &os,
63  VOP_ContextType context_type) const override;
66  bool check_shader_context) const override;
68  void getParmNameFromInput(UT_String &parmname,
69  int inputidx) const override;
71  static void buildInputSetMenu(void *, PRM_Name *, int,
72  const PRM_SpareData *,
73  const PRM_Parm *);
74  int getCurrentInputSet() const;
76  /// Updates the opeartor information about inputs and outputs based on the
77  /// current state of the script node.
78  /// If 'keep_info' is true, most of the op_info is preserved (eg, input
79  /// order, input visibility flags, etc), and this method updates the data
80  /// that can be specifed only by the node itself (and not op type
81  /// properties editor). Otherwise, if false, node inptus will dictate
82  /// the saved order and flags.
83  void updateInputsAndOutputsInfo(VOP_OperatorInfo *op_info,
84  bool keep_info = false);
85  virtual bool getIsInputDefinedByParmChild(int idx) const;
86  virtual bool getIsOutputDefinedByParmChild(int idx) const;
88  void opChanged(OP_EventType reason, void *data=0) override;
90  bool definesShaderExtraParameters() const override;
93  UT_IntArray &doexport,
95  UT_StringArray &def,
96  VOP_Type shader_type = VOP_TYPE_UNDEF
97  ) const override;
98 protected:
99  void updateCurrentInputSet();
101  bool updateParmsFlags() override;
103  unsigned getNumScriptOpInputs() const;
104  const UT_StringHolder &getScriptOpInputName(int idx) const;
105  int findScriptOpInput(const char *input_name) const;
107  UT_String &in, int idx) const override;
109  const UT_String &in) const override;
111  VOP_TypeInfo &type_info, int idx) override;
112  bool getIsInputVisibleDefaultSubclass(int idx) override;
114  unsigned idx,
115  VOP_VopTypeInfoArray &voptypes) override;
117  unsigned getNumScriptOutputs() const;
118  int findScriptOpOutput(
119  const UT_StringRef &output_name) const;
121  UT_String &out, int idx) const override;
123  VOP_TypeInfo &type_info, int idx) override;
125  /// Returns true if output of a given index has an input by the same name.
126  virtual bool hasCorrespondingInput(int output_idx) const;
128  void getVopFunctionName(
129  UT_String &function_name) const override;
131 private:
132  bool getBestMatchingParameter(UT_WorkBuffer &parm,
133  const char *input, int inputidx) const;
134  bool getBestMatchingInput(int &input_index,
135  const UT_String &input_name) const;
136  bool shouldOutputNodeVariableDeclarations() const override;
138  bool getHideInputsUsingParameterVisibleState() const;
140 private:
141  VOP_ScriptOperator *myScript;
142  int myCurrentInputSet;
143  UT_IntArray myValidInputSets;
144  bool myUpdatingInputSetFlag;
145 };
147 #endif
virtual int getInputFromNameSubclass(const UT_String &in) const
Reprsents a language for which VOPs can generate source code.
Definition: VOP_Language.h:27
virtual void getOuterCode(UT_String &codestr, const VOP_CodeGenContext &context)
virtual void getVopFunctionName(UT_String &function_name) const
virtual void initMaterialFlag()
GLenum GLenum GLenum input
Definition: glew.h:13879
GLuint const GLchar * name
Definition: glew.h:1814
virtual bool getCurrentSignatureName(UT_String &name)
Obtains the current signature name.
virtual void setCurrentSignature(const char *name)
virtual bool getParmConstantString(const char *parmname, const VOP_TypeInfo &type_info, UT_String &str, bool expand_string, const VOP_Language *l=0)
Get the constant code that encodes the value of the node parameter.
virtual bool isCachedShader() const
GLuint index
Definition: glew.h:1814
virtual bool forceCodeGenerationOfInputs(const VOP_CodeGenContext &context, bool check_shader_context) const
virtual int getShaderExtraParameters(UT_Array< VOP_Type > &types, UT_IntArray &doexport, UT_StringArray &names, UT_StringArray &def, VOP_Type shader_type=VOP_TYPE_UNDEF) const
virtual bool getIsInputVisibleDefaultSubclass(int idx)
bool updateParmsFlags() override
virtual const char * inputLabel(unsigned idx) const
virtual void getSignatureName(UT_String &name, int index) const
virtual void getInputTypeInfoSubclass(VOP_TypeInfo &type_info, int idx)
virtual bool definesShaderExtraParameters() const
int VOP_ContextType
Definition: VOP_Types.h:151
GLsizei GLenum GLenum * types
Definition: glew.h:3954
virtual bool isShader() const
#define VOP_API
Definition: VOP_API.h:10
GLuint in
Definition: glew.h:11510
GLint GLenum GLsizei GLint GLsizei const void * data
Definition: glew.h:1379
virtual bool shouldOutputNodeVariableDeclarations() const
GLuint const GLuint * names
Definition: glew.h:2690
virtual void getParmNameFromInput(UT_String &parmname, int inputidx) const
virtual int getSignatureCount() const
virtual void getCode(UT_String &codestr, const VOP_CodeGenContext &context)
Get the code fragment to be included in the shader code.
virtual const char * outputLabel(unsigned idx) const
virtual void getOutputTypeInfoSubclass(VOP_TypeInfo &type_info, int idx)
virtual void getOutputNameSubclass(UT_String &out, int idx) const
Definition: OP_Value.h:22
Definition: VOP_Types.h:24
virtual void getModulesToImport(UT_StringArray &modules, const VOP_CodeGenContext &context)
If the node generates a shader call, get the modules names to import.
virtual void getInputNameSubclass(UT_String &in, int idx) const
virtual bool getCachedShaderCode(std::ostream &os, VOP_ContextType context_type) const
virtual void getAllowedInputTypeInfosSubclass(unsigned idx, VOP_VopTypeInfoArray &infos)
virtual void getAllowedInputTypeInfos(unsigned idx, VOP_VopTypeInfoArray &typeinfos)
virtual void ensureParametersAreValid()
void opChanged(OP_EventType reason, void *data=0) override