HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
VOP_OperatorInfo.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_OperatorInfo.h ( VOP Library, C++)
7  *
8  * COMMENTS: This is additional information available via every VOP
9  * operator.
10  */
11 
12 #ifndef __VOP_OperatorInfo__
13 #define __VOP_OperatorInfo__
14 
15 #include "VOP_API.h"
16 #include "VOP_Types.h"
17 #include <UT/UT_String.h>
18 #include <UT/UT_StringArray.h>
19 #include <UT/UT_StringHolder.h>
20 #include <UT/UT_Array.h>
21 #include <OP/OP_Operator.h>
22 #include <iosfwd>
23 
28 
30 {
31  VOP_CONNECTOR_FLAG_HIDDEN = 0x0001, // initially hidden
32  VOP_CONNECTOR_FLAG_PARMGEN_CHILD = 0x0002 // defined by Parm VOP child
33 };
34 
35 
36 /// Class containing tags for an input or an output.
38 {
39 public:
40  const VOP_InOutTagMap& operator=(const VOP_InOutTagMap &other);
41 
42  void setTag(const char* name, const char* value);
43  UT_StringHolder getTag(const char* name) const;
44  bool hasTag(const char *name) const;
45 
46  void getTagNames(UT_StringArray &names) const;
47 
48 private:
50  UT_UniquePtr<MapType> myTags;
51 };
52 
53 /// Class containing information about node's input or output connector port.
55 {
56 public:
58  const VOP_TypeInfo &type_info);
59  VOP_InOutInfo(const VOP_InOutInfo &other);
60  ~VOP_InOutInfo();
61 
62  const UT_StringHolder &getName() const
63  { return myName; }
64  void setName(const UT_StringHolder &name)
65  { myName = name; }
66  const UT_StringHolder &getLabel() const
67  { return myLabel; }
68  void setLabel(const UT_StringHolder &label)
69  { myLabel = label; }
70 
71  void addTypeInfo(const VOP_TypeInfo &type_info);
72  void insertTypeInfo(const VOP_TypeInfo &newtype, int i);
73  void setTypeInfo(int i, const VOP_TypeInfo &newtype);
74  void removeTypeInfo(int i);
75 
76  const VOP_TypeInfo &getTypeInfo(int i) const;
77  VOP_Type getType(int i) const;
78 
79  void addInputName(const char* name)
80  { myDefaultInputNames.append(name); }
81  void insertInputName(const char *name, int i)
82  { myDefaultInputNames.insert(name, i); }
83  void removeInputName(int i)
84  { myDefaultInputNames.remove(i); }
85 
86  const UT_StringHolder &getInputName(int i) const
87  { return myDefaultInputNames(i); }
88  void setInputName(int i, const char *new_name)
89  { myDefaultInputNames(i) = new_name; }
90 
91  void addValueOption(const VOP_TypeInfo &type_info);
92  void insertValueOption(
93  const VOP_TypeInfo &type_info, int i);
94  void removeValueOption(int i);
95  UT_Options &getValueOption(int i);
96  void changeValueOption(int i, const VOP_TypeInfo &type_info,
97  const char *new_val = NULL);
98 
99  int getNumTypes() const
100  { return myTypeInfos.entries(); }
101  int getNumNames() const
102  { return myDefaultInputNames.entries();}
103  int getNumOptions() const
104  { return myValueOptions.entries();}
105 
106  void setTag(const char* name, const char* value)
107  { myTags.setTag(name, value); }
108  UT_StringHolder getTag(const char* name) const
109  { return myTags.getTag(name); }
110  bool hasTag(const char *name) const
111  { return myTags.hasTag(name); }
113  { return myTags; }
114  void copyTagsFrom(VOP_InOutInfo& src_info)
115  { myTags = src_info.myTags; }
116 
117  void setFlag(VOP_ConnectorFlagType flag_type, bool value)
118  {
119  if(value)
120  myFlags |= flag_type;
121  else
122  myFlags &= ~flag_type;
123  }
124 
126  {
127  return ((myFlags & flag_type) != 0);
128  }
129 
130  void copyFlagsFrom(VOP_InOutInfo& src_info)
131  {
132  myFlags = src_info.myFlags;
133  }
134 
135  void setAllFlags(int flags)
136  {
137  myFlags = flags;
138  }
139 
141  {
142  return myFlags;
143  }
144 
145 private:
146  UT_StringHolder myName;
147  UT_StringHolder myLabel;
148  UT_ValArray<VOP_TypeInfo*> myTypeInfos;
149  UT_StringArray myDefaultInputNames;
150  UT_Array<UT_Options> myValueOptions;
151  VOP_InOutTagMap myTags;
152 
153  int myFlags;
154 };
155 
157 {
158 public:
160  ~VOP_OperatorInfo() override;
161 
162  const VOP_OperatorInfo & operator=(const VOP_OperatorInfo &other);
163 
164  void setCode(const UT_String &code);
165  const UT_String &getCode() const
166  { return myCode; }
167  void setOuterCode(const UT_String &code);
168  const UT_String &getOuterCode() const
169  { return myOuterCode; }
170  void setVopnetMask(const char *mask);
171  const UT_String &getVopnetMask() const
172  { return myVopnetMask; }
173  void setRenderMask(const char *mask);
174  const UT_String &getRenderMask() const
175  { return myRenderMask; }
177  { return myOutputInfos; }
179  { return myOutputInfos; }
181  { return myInputInfos; }
183  { return myInputInfos; }
185  { return myInputSetNames; }
187  { return myInputSetNames; }
189  { return myInputSetLabels; }
191  { return myInputSetLabels; }
193  { return myInputSetScriptNames; }
195  { return myInputSetScriptNames; }
197  { return myForceCodeGeneration; }
198  const bool &getForceCodeGeneration() const
199  { return myForceCodeGeneration; }
201  { return myExternalShader; }
202  const bool &getExternalShader() const
203  { return myExternalShader; }
205  { return myShaderType; }
207  { myShaderType = t; }
208 
209  void clearInOutInfo();
210  void saveToDialogScript(std::ostream &os) const override;
212  OP_ExtraInfoBuffer &b) const override;
213 
214  /// Obtains a name of a node parameter that corresponds to a given
215  /// input name when the node uses the given signature.
216  /// @{
217  UT_StringHolder getParmNameFromInput(
218  const char *input_name, int input_set_index) const;
219  void getParmNameFromInput(UT_String &parm_name,
220  const char *input_name, int input_set_index) const;
221  void getParmNameFromInput(UT_WorkBuffer &parm_name,
222  const char *input_name, int input_set_index) const;
223  /// @}
224 
225  /// @{ Returns an input and a signature names, given parameter name,
226  /// considering the available signatures in this class.
227  UT_StringHolder getInputNameFromParm(
228  const UT_StringRef &parm_name) const;
229  UT_StringHolder getInputSetNameFromParm(
230  const UT_StringRef &parm_name) const;
231  /// @}
232 
233  /// Returns a new language context object based on this operator info.
234  /// Caller is responsible for deleting the returned object.
235  VOP_LanguageContextTypeList *newLanguageContextTypeList() const;
236 
237  /// Check if the code has extra parameters
238  bool hasExtraParameters() const
239  { return myExtraParametersFormat.size()>0; }
240 
241  /// Returns the extra parameters tokens parsed from the code string
243  { return myExtraParametersFormat; }
244 
245  /// Returns true if the scripted vop node uses the parameter visible state
246  // driven by the hidewhen conditional to also control the visibility of
247  // its vop inputs.
248  // You must add "#pragma ophidewhen" to the outercode to enable this.
250  { return myHideInputsUsingParameterVisibleState; }
251 protected:
252  static void saveInOutInfoToDialogScript(std::ostream &os,
253  const UT_ValArray<VOP_InOutInfo *> &infoarray,
254  const char *infotype);
255  static void saveInputFlags(std::ostream &os,
256  const UT_ValArray<VOP_InOutInfo *> &inoutarray,
257  const char *token, bool only_nonzero_flags);
258 
259 private:
260  UT_ValArray<VOP_InOutInfo *> myOutputInfos;
261  UT_ValArray<VOP_InOutInfo *> myInputInfos;
262  UT_StringArray myInputSetNames;
263  UT_StringArray myInputSetLabels;
264  UT_StringArray myInputSetScriptNames;
265  UT_StringArray myExtraParametersFormat;
266  UT_String myVopnetMask;
267  UT_String myRenderMask;
268  UT_String myOuterCode;
269  UT_String myCode;
270  VOP_Type myShaderType;
271  bool myForceCodeGeneration;
272  bool myExternalShader;
273  bool myHideInputsUsingParameterVisibleState;
274 };
275 
276 #endif
277 
const UT_String & getOuterCode() const
void setLabel(const UT_StringHolder &label)
const UT_StringArray & getInputSetLabels() const
GLbitfield flags
Definition: glcorearb.h:1596
VOP_ConnectorFlagType
GLuint GLsizei const GLchar * label
Definition: glcorearb.h:2545
void setTag(const char *name, const char *value)
int getNumNames() const
UT_ValArray< VOP_InOutInfo * > & getInputInfos()
void copyTagsFrom(VOP_InOutInfo &src_info)
Class containing information about node's input or output connector port.
bool getHideInputsUsingParameterVisibleState() const
Returns true if the scripted vop node uses the parameter visible state.
int getNumTypes() const
UT_StringArray & getInputSetScriptNames()
const UT_StringHolder & getInputName(int i) const
bool hasTag(const char *name) const
UT_Array< VOP_Type > VOP_VopTypeArray
const UT_StringArray & getInputSetScriptNames() const
const bool & getForceCodeGeneration() const
std::unique_ptr< T, Deleter > UT_UniquePtr
A smart pointer for unique ownership of dynamically allocated objects.
Definition: UT_UniquePtr.h:39
void copyFlagsFrom(VOP_InOutInfo &src_info)
virtual void updateExtraInfoBuffer(OP_ExtraInfoBuffer &b) const
Definition: OP_Operator.h:120
UT_ValArray< VOP_InOutInfo * > & getOutputInfos()
bool & getExternalShader()
void setShaderType(VOP_Type t)
UT_StringArray & getInputSetLabels()
#define VOP_API
Definition: VOP_API.h:10
const UT_String & getCode() const
void setAllFlags(int flags)
GLint GLuint mask
Definition: glcorearb.h:124
void setInputName(int i, const char *new_name)
const bool & getExternalShader() const
const UT_StringArray & getExtraParametersFormat() const
Returns the extra parameters tokens parsed from the code string.
const VOP_InOutTagMap & getTagsMap() const
GLuint const GLchar * name
Definition: glcorearb.h:786
GLboolean GLboolean GLboolean b
Definition: glcorearb.h:1222
GLdouble t
Definition: glad.h:2397
virtual void saveToDialogScript(std::ostream &os) const =0
void removeInputName(int i)
const UT_StringHolder & getLabel() const
A map of string to various well defined value types.
Definition: UT_Options.h:84
void insertInputName(const char *name, int i)
void setName(const UT_StringHolder &name)
bool hasExtraParameters() const
Check if the code has extra parameters.
int getNumOptions() const
bool & getForceCodeGeneration()
VOP_Type
Enumeration of the built-in (basic) VOP data types.
Definition: VOP_Types.h:25
Class containing tags for an input or an output.
VOP_Type getShaderType() const
const UT_StringHolder & getName() const
const UT_ValArray< VOP_InOutInfo * > & getInputInfos() const
Definition: core.h:1131
const UT_String & getRenderMask() const
UT_StringHolder getTag(const char *name) const
bool hasFlag(VOP_ConnectorFlagType flag_type)
const UT_ValArray< VOP_InOutInfo * > & getOutputInfos() const
UT_Array< VOP_TypeInfo > VOP_VopTypeInfoArray
UT_StringArray & getInputSetNames()
const UT_String & getVopnetMask() const
void setFlag(VOP_ConnectorFlagType flag_type, bool value)
void addInputName(const char *name)
const UT_StringArray & getInputSetNames() const