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  virtual ~VOP_ScriptNode();
25  static OP_Node *myConstructor(OP_Network *net, const char *name,
26  OP_Operator *op);
27  static PRM_Template myMultiInputSetTemplateList[];
29  virtual void initMaterialFlag();
30  virtual void getModulesToImport(UT_StringArray &modules,
31  const VOP_CodeGenContext &context);
32  virtual void getOuterCode(UT_String &codestr,
33  const VOP_CodeGenContext &context);
34  virtual void getCode(UT_String &codestr,
35  const VOP_CodeGenContext &context);
36  virtual bool getParmConstantString(const char *parmname,
37  const VOP_TypeInfo &type_info,
38  UT_String &str,
39  bool expand_string,
40  const VOP_Language *language=0);
44  virtual const char *inputLabel(unsigned idx) const;
45  virtual const char *outputLabel(unsigned idx) const;
47  virtual int getSignatureCount() const;
48  virtual void getSignatureName(UT_String &name, int index) const;
49  virtual void setCurrentSignature(const char *name);
50  virtual bool getCurrentSignatureName(UT_String &name);
52  virtual void getAllowedInputTypeInfos(unsigned idx,
53  VOP_VopTypeInfoArray &voptypes);
55  virtual bool isShader() const;
56  virtual bool isShader(VOP_Type shader_type) const;
57  virtual bool isCachedShader() const;
58  virtual bool getCachedShaderCode(std::ostream &os,
59  VOP_ContextType context_type) const;
60  virtual bool forceCodeGenerationOfInputs(
61  const VOP_CodeGenContext &context,
62  bool check_shader_context) const;
64  virtual void getParmNameFromInput(UT_String &parmname,
65  int inputidx) const;
67  static void buildInputSetMenu(void *, PRM_Name *, int,
68  const PRM_SpareData *,
69  const PRM_Parm *);
70  int getCurrentInputSet() const;
72  /// Updates the opeartor information about inputs and outputs based on the
73  /// current state of the script node.
74  /// If 'keep_info' is true, most of the op_info is preserved (eg, input
75  /// order, input visibility flags, etc), and this method updates the data
76  /// that can be specifed only by the node itself (and not op type
77  /// properties editor). Otherwise, if false, node inptus will dictate
78  /// the saved order and flags.
79  void updateInputsAndOutputsInfo(VOP_OperatorInfo *op_info,
80  bool keep_info = false);
81  virtual bool getIsInputDefinedByParmChild(int idx) const;
82  virtual bool getIsOutputDefinedByParmChild(int idx) const;
84  virtual void opChanged(OP_EventType reason, void *data=0);
86 protected:
87  void updateCurrentInputSet();
89  virtual bool updateParmsFlags();
91  unsigned getNumScriptOpInputs() const;
92  const UT_StringHolder &getScriptOpInputName(int idx) const;
93  int findScriptOpInput(const char *input_name) const;
94  virtual void getInputNameSubclass(UT_String &in, int idx) const;
95  virtual int getInputFromNameSubclass(const UT_String &in) const;
96  virtual void getInputTypeInfoSubclass(VOP_TypeInfo &type_info,
97  int idx);
98  virtual bool getIsInputVisibleDefaultSubclass(int idx);
99  virtual void getAllowedInputTypeInfosSubclass(unsigned idx,
100  VOP_VopTypeInfoArray &voptypes);
102  unsigned getNumScriptOutputs() const;
103  int findScriptOpOutput(const UT_StringRef &output_name) const;
104  virtual void getOutputNameSubclass(UT_String &out, int idx) const;
105  virtual void getOutputTypeInfoSubclass(VOP_TypeInfo &type_info,
106  int idx);
108  /// Returns true if output of a given index has an input by the same name.
109  virtual bool hasCorrespondingInput(int output_idx) const;
111  virtual void getVopFunctionName(UT_String &function_name) const;
113 private:
114  bool getBestMatchingParameter(UT_WorkBuffer &parm,
115  const char *input, int inputidx) const;
116  bool getBestMatchingInput(int &input_index,
117  const UT_String &input_name) const;
118  virtual bool shouldOutputNodeVariableDeclarations() const;
120 private:
121  VOP_ScriptOperator *myScript;
122  int myCurrentInputSet;
123  UT_IntArray myValidInputSets;
124  bool myUpdatingInputSetFlag;
125 };
127 #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()
virtual bool updateParmsFlags()
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
virtual bool forceCodeGenerationOfInputs(const VOP_CodeGenContext &context, bool check_shader_context) const
virtual bool getIsInputVisibleDefaultSubclass(int idx)
virtual const char * inputLabel(unsigned idx) const
virtual void getSignatureName(UT_String &name, int index) const
virtual void opChanged(OP_EventType reason, void *data=0)
virtual void getInputTypeInfoSubclass(VOP_TypeInfo &type_info, int idx)
int VOP_ContextType
Definition: VOP_Types.h:149
virtual bool isShader() const
#define VOP_API
Definition: VOP_API.h:10
virtual bool shouldOutputNodeVariableDeclarations() const
virtual void getParmNameFromInput(UT_String &parmname, int inputidx) const
virtual int getSignatureCount() const
GLboolean * data
Definition: glcorearb.h:130
GLuint const GLchar * name
Definition: glcorearb.h:785
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
GLuint index
Definition: glcorearb.h:785
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()