All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros 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 getModulesToImport(UT_StringArray &modules,
30  const VOP_CodeGenContext &context);
31  virtual void getOuterCode(UT_String &codestr,
32  const VOP_CodeGenContext &context);
33  virtual void getCode(UT_String &codestr,
34  const VOP_CodeGenContext &context);
35  virtual bool getParmConstantString(const char *parmname,
36  const VOP_TypeInfo &type_info,
37  UT_String &str,
38  bool expand_string,
39  const VOP_Language *language=0);
43  virtual const char *inputLabel(unsigned idx) const;
44  virtual const char *outputLabel(unsigned idx) const;
46  virtual int getSignatureCount() const;
47  virtual void getSignatureName(UT_String &name, int index) const;
48  virtual void setCurrentSignature(const char *name);
49  virtual bool getCurrentSignatureName(UT_String &name);
51  virtual void getAllowedInputTypeInfos(unsigned idx,
52  VOP_VopTypeInfoArray &voptypes);
54  virtual bool isShader() const;
55  virtual bool isShader(VOP_Type shader_type) const;
56  virtual bool isCachedShader() const;
57  virtual bool getCachedShaderCode(std::ostream &os,
58  VOP_ContextType context_type) const;
59  virtual bool forceCodeGenerationOfInputs(
60  const VOP_CodeGenContext &context,
61  bool check_shader_context) const;
63  virtual void getParmNameFromInput(UT_String &parmname,
64  int inputidx) const;
66  static void buildInputSetMenu(void *, PRM_Name *, int,
67  const PRM_SpareData *,
68  const PRM_Parm *);
69  int getCurrentInputSet() const;
71  /// Updates the opeartor information about inputs and outputs based on the
72  /// current state of the script node.
73  /// If 'keep_info' is true, most of the op_info is preserved (eg, input
74  /// order, input visibility flags, etc), and this method updates the data
75  /// that can be specifed only by the node itself (and not op type
76  /// properties editor). Otherwise, if false, node inptus will dictate
77  /// the saved order and flags.
78  void updateInputsAndOutputsInfo(VOP_OperatorInfo *op_info,
79  bool keep_info = false);
80  virtual bool getIsInputDefinedByParmChild(int idx) const;
81  virtual bool getIsOutputDefinedByParmChild(int idx) const;
83  virtual void opChanged(OP_EventType reason, void *data=0);
85 protected:
86  void updateCurrentInputSet();
88  virtual bool updateParmsFlags();
90  unsigned getNumScriptOpInputs() const;
91  const UT_String & getScriptOpInputName(int idx) const;
92  int findScriptOpInput(const char *input_name) const;
93  virtual void getInputNameSubclass(UT_String &in, int idx) const;
94  virtual int getInputFromNameSubclass(const UT_String &in) const;
95  virtual void getInputTypeInfoSubclass(VOP_TypeInfo &type_info,
96  int idx);
97  virtual bool getIsInputVisibleDefaultSubclass(int idx);
98  virtual void getAllowedInputTypeInfosSubclass(unsigned idx,
99  VOP_VopTypeInfoArray &voptypes);
101  unsigned getNumScriptOutputs() const;
102  int findScriptOpOutput(const char *output_name) const;
103  virtual void getOutputNameSubclass(UT_String &out, int idx) const;
104  virtual void getOutputTypeInfoSubclass(VOP_TypeInfo &type_info,
105  int idx);
107  /// Returns true if output of a given index has an input by the same name.
108  virtual bool hasCorrespondingInput(int output_idx) const;
110  virtual void getVopFunctionName(UT_String &function_name) const;
112 private:
113  bool getBestMatchingParameter(UT_WorkBuffer &parm,
114  const char *input, int inputidx) const;
115  bool getBestMatchingInput(int &input_index,
116  const UT_String &input_name) const;
117  virtual bool shouldOutputNodeVariableDeclarations() const;
119 private:
120  VOP_ScriptOperator *myScript;
121  int myCurrentInputSet;
122  UT_IntArray myValidInputSets;
123  bool myUpdatingInputSetFlag;
124 };
126 #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 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()