HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
SOP_NodeParmsOptions.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: SOP_NodeParmsOptions.h ( SOP Library, C++)
7  *
8  * COMMENTS:
9  * SOP_NodeParms packet that can stores its structure in a UT_Options.
10  * This allows for automatic definition at the expense of performance.
11  */
12 
13 #ifndef __SOP_NodeParmsOptions_h__
14 #define __SOP_NodeParmsOptions_h__
15 
16 #include "SOP_API.h"
17 #include "SOP_Node.h"
18 #include "SOP_NodeVerb.h"
19 
20 #include <OP/OP_Options.h>
21 
23 {
24 public:
26  ~SOP_NodeParmsOptions() override;
27 
28  void loadFromOpSubclass(const LoadParms &loadparms) override;
29 
30  void copyFrom(const SOP_NodeParms *src) override;
31 
32  /// Marshalling interface to rest of world
33  /// These all use index based notation.
34  exint getNestNumParms(TempIndex idx) const override;
35  const char *getNestParmName(TempIndex idx) const override;
36  ParmType getNestParmType(TempIndex idx) const override;
37 
38  void getNestParmValue(TempIndex idx, TempIndex instance, exint &value) const override;
39  void getNestParmValue(TempIndex idx, TempIndex instance, fpreal &value) const override;
40  void getNestParmValue(TempIndex idx, TempIndex instance, UT_Vector2D &value) const override;
41  void getNestParmValue(TempIndex idx, TempIndex instance, UT_Vector3D &value) const override;
42  void getNestParmValue(TempIndex idx, TempIndex instance, UT_Vector4D &value) const override;
43  void getNestParmValue(TempIndex idx, TempIndex instance, UT_Matrix2D &value) const override;
44  void getNestParmValue(TempIndex idx, TempIndex instance, UT_Matrix3D &value) const override;
45  void getNestParmValue(TempIndex idx, TempIndex instance, UT_Matrix4D &value) const override;
46  void getNestParmValue(TempIndex idx, TempIndex instance, UT_StringHolder &value) const override;
47  void getNestParmValue(TempIndex idx, TempIndex instance, UT_SharedPtr<UT_Ramp> &value) const override;
48  void getNestParmValue(TempIndex idx, TempIndex instance, PRM_DataItemHandle &value) const override;
49 
50  void setNestParmValue(TempIndex idx, TempIndex instance, const exint &value) override;
51  void setNestParmValue(TempIndex idx, TempIndex instance, const fpreal &value) override;
52  void setNestParmValue(TempIndex idx, TempIndex instance, const UT_Vector2D &value) override;
53  void setNestParmValue(TempIndex idx, TempIndex instance, const UT_Vector3D &value) override;
54  void setNestParmValue(TempIndex idx, TempIndex instance, const UT_Vector4D &value) override;
55  void setNestParmValue(TempIndex idx, TempIndex instance, const UT_Matrix2D &value) override;
56  void setNestParmValue(TempIndex idx, TempIndex instance, const UT_Matrix3D &value) override;
57  void setNestParmValue(TempIndex idx, TempIndex instance, const UT_Matrix4D &value) override;
58  void setNestParmValue(TempIndex idx, TempIndex instance, const UT_StringHolder &value) override;
59  void setNestParmValue(TempIndex idx, TempIndex instance, const UT_SharedPtr<UT_Ramp> &value) override;
60  void setNestParmValue(TempIndex idx, TempIndex instance, const PRM_DataItemHandle &value) override;
61 
63  { return myOptions.getOptionEntry(name); }
64 
65  const PRM_Template *getTemplates() const
66  { return myTemplates; }
67 
68  class ParmDescr
69  {
70  public:
75  };
76 
77 protected:
78 
79  template <typename T> void internalGetNestParmValue(TempIndex idx, TempIndex instance, T &value) const;
80 
85  friend class SOP_NodeCacheOptions;
86 };
87 
88 ///
89 /// Provides a mostly drop-in replacement for SOP_Node, along with a
90 /// local GU_Detail * to write to.
91 ///
93 {
94 public:
96  ~SOP_NodeCacheOptions() override;
97 
98  void doCook(const SOP_NodeVerb *verb, const SOP_NodeVerb::CookParms &cookparms);
99 
100  // Wrappers for OP_Parameter() functions.
101  // Note time is unused as we've already hardened time in loadFromOp!
102  fpreal evalFloat(const char *parm, int vi, fpreal time) const;
103  exint evalInt(const char *parm, int vi, fpreal time) const;
104  void evalString(UT_String &value, const char *parm, int vi, fpreal time) const;
105 
106  fpreal evalFloatInst(const char *parm, const int *instance, int vi, fpreal time, int nestlevel = 1) const;
107  exint evalIntInst(const char *parm, const int *instance, int vi, fpreal time, int nestlevel = 1) const;
108  void evalStringInst(const char *parm, const int *instance, UT_String &val, int vi, fpreal time, int nestlevel = 1) const;
109 
110  exint nInputs() const
111  { return myCookParms->nInputs(); }
112  bool hasInput(exint idx) const
113  { return myCookParms->hasInput(idx); }
114  const GU_Detail *inputGeo(exint idx, const OP_Context &context) const
115  { return inputGeo(idx); }
116  const GU_Detail *inputGeo(exint idx) const
117  { return myCookParms->inputGeo(idx); }
118 
119  OP_ERROR error();
120  void addError(int code, const char *msg = 0)
121  { myCookParms->sopAddError(code, msg); }
122  void addWarning(int code, const char *msg = 0)
123  { myCookParms->sopAddWarning(code, msg); }
124  void addMessage(int code, const char *msg = 0)
125  { myCookParms->sopAddMessage(code, msg); }
126 
127  /// Registers an error for cooking the given node's transform. If label is
128  /// supplied, then it will be used as a label of the transform error.
129  void addTransformError(const OP_Node &node,
130  const char *label=0) const
131  {
132  UT_String path;
133 
134  node.getFullPath(path);
135  if (UTisstring(label))
136  {
137  path += " (as ";
138  path += label;
139  path += ")";
140  }
141 
142  myCookParms->addError("OP", OP_ERR_TRANSFORM, path);
143  }
144 
145  void notifyGroupParmListeners(int groupparm_idx,
146  int grouptype_idx,
147  const GU_Detail *parm_gdp,
148  const GA_Group *parm_group) const
149  { myVerb->notifyGroupParmListeners(myCookParms->getNode(),
150  groupparm_idx, grouptype_idx, parm_gdp, parm_group); }
151 
153  { myCookParms->select(gtype); }
154 
156  bool add_to_sel = false)
157  { myCookParms->select(selection, add_to_sel); }
158 
159  // Select the group. opt use its type as sel type
160  void select(const GA_Group &group, bool use_gtype = true,
161  bool add_to_sel = false)
162  { myCookParms->select(group, use_gtype, add_to_sel); }
163 
164  void select(const GEO_Primitive &prim, bool sel_prim = true,
165  bool add_to_sel = false)
166  { myCookParms->select(prim, sel_prim, add_to_sel); }
167  void selectPoint(GA_Offset ptoff, bool point_sel = true,
168  bool add_to_sel = false)
169  { myCookParms->selectPoint(ptoff, point_sel, add_to_sel); }
170  void selectFrom(const GEO_Primitive &prim, bool sel_prim = true,
171  bool add_to_sel = false)
172  { myCookParms->selectFrom(prim, sel_prim, add_to_sel); }
173  void selectPointsFrom(GA_Offset ptoff, bool point_sel = true,
174  bool add_to_sel = false)
175  { myCookParms->selectPointsFrom(ptoff, point_sel, add_to_sel); }
176  void select(const GA_Range &range, bool use_rtype = true,
177  bool add_to_sel = false)
178  { myCookParms->select(range, use_rtype, add_to_sel); }
179 
180  // Selects input based on the group supplied and the group type. If
181  // group is not null, then it's type is used, otherwise the group type
182  // is used.
184  GA_GroupType grouptype)
185  { myCookParms->selectInputGroup(group, grouptype); }
186 
187  // If no selection is present, then create a new empty primitive cook
188  // selection group. Otherwise, clear the selection.
190  { myCookParms->clearSelection(); }
191 
192  /// If the cook selection group is not of the given type, create an empty
193  /// cook selection group of that type. Otherwise, clear the existing cook
194  /// selection group.
196  { myCookParms->clearSelection(gtype); }
197 
198  // Blow away the selection and reinitialize it to 0. Much more radical
199  // than clearSelection(), which leaves behind a clean, empty selection.
200  // This method returns 1 if it had anything to destroy, else 0.
202  { return myCookParms->destroySelection(); }
203 
204  // Return 1 if selection is enabled, 0 if false.
205  bool selectionEnabled() const
206  { return myCookParms->selectionEnabled(); }
207 
208  /// Typedef to help make use of GroupCreator less verbose.
210 
212  {
213  UT_ASSERT(type == OP_INTEREST_DATA);
214  if (type == OP_INTEREST_DATA && op && myCookParms->depnode())
215  myCookParms->depnode()->addExplicitInput(op->dataMicroNode());
216  }
217 
218 protected:
219  // Note this context has no valid time!
220  virtual OP_ERROR cook(OP_Context &context) = 0;
221 
222 
223  /// These are transitory for the duration of the cook.
225 
226  const SOP_NodeVerb::CookParms *cookparms() const { return myCookParms; }
227 
228 private:
229  const SOP_NodeParmsOptions *myOptions;
230  const SOP_NodeVerb::CookParms *myCookParms;
231  const SOP_NodeVerb *myVerb;
232 };
233 
234 #endif
void selectFrom(const GEO_Primitive &prim, bool sel_prim=true, bool add_to_sel=false)
void selectPoint(GA_Offset ptoff, bool point_sel=true, bool add_to_sel=false)
const GU_Detail * inputGeo(exint idx) const
void select(const GEO_Primitive &prim, bool sel_prim=true, bool add_to_sel=false)
GT_API const UT_StringHolder selection
virtual ParmType getNestParmType(TempIndex idx) const
Definition: SOP_NodeVerb.h:286
GT_API const UT_StringHolder time
GLsizei const GLchar *const * path
Definition: glcorearb.h:3340
const UT_OptionEntry * getOptionEntry(const UT_StringRef &name) const
const SOP_NodeVerb::CookParms * cookparms() const
void select(GU_SelectionHandle selection, bool add_to_sel=false)
int64 exint
Definition: SYS_Types.h:125
UT_ErrorSeverity
Definition: UT_Error.h:25
GLuint const GLchar * name
Definition: glcorearb.h:785
GLenum src
Definition: glcorearb.h:1792
GOP_Manager::GroupCreator GroupCreator
Typedef to help make use of GroupCreator less verbose.
A range of elements in an index-map.
Definition: GA_Range.h:42
GA_Size GA_Offset
Definition: GA_Types.h:640
const char * getFullPath(UT_String &str) const
Definition: PRM_ParmOwner.h:46
void selectInputGroup(const GA_Group *group, GA_GroupType grouptype)
void addExtraInput(OP_Node *op, OP_InterestType type)
OP_InterestType
Definition: OP_DataTypes.h:44
void notifyGroupParmListeners(int groupparm_idx, int grouptype_idx, const GU_Detail *parm_gdp, const GA_Group *parm_group) const
GLint GLint GLsizei GLint GLenum GLenum type
Definition: glcorearb.h:107
std::shared_ptr< T > UT_SharedPtr
Wrapper around std::shared_ptr.
Definition: UT_SharedPtr.h:30
virtual const char * getNestParmName(TempIndex idx) const
Definition: SOP_NodeVerb.h:285
void select(GA_GroupType gtype=GA_GROUP_PRIMITIVE)
GLuint GLsizei const GLchar * label
Definition: glcorearb.h:2544
virtual exint getNestNumParms(TempIndex idx) const
Definition: SOP_NodeVerb.h:284
virtual void loadFromOpSubclass(const LoadParms &loadparms)=0
GU_Detail * gdp
These are transitory for the duration of the cook.
UT_SharedPtr< GU_Selection > GU_SelectionHandle
virtual void setNestParmValue(TempIndex idx, TempIndex instance, const exint &value)
Definition: SOP_NodeVerb.h:300
bool hasInput(exint idx) const
void clearSelection(GA_GroupType gtype)
GLuint GLfloat * val
Definition: glcorearb.h:1607
virtual void getNestParmValue(TempIndex idx, TempIndex instance, exint &value) const
Definition: SOP_NodeVerb.h:288
fpreal64 fpreal
Definition: SYS_Types.h:277
void addMessage(int code, const char *msg=0)
void select(const GA_Group &group, bool use_gtype=true, bool add_to_sel=false)
GA_GroupType
An ordinal enum for the different types of groups in GA.
Definition: GA_Types.h:159
SYS_FORCE_INLINE bool UTisstring(const char *s)
const PRM_Template * myTemplates
#define SOP_API
Definition: SOP_API.h:10
GLboolean GLuint group
Definition: glew.h:2750
GLsizei const GLfloat * value
Definition: glcorearb.h:823
UT_Array< ParmDescr > myParmDescr
GLenum GLint * range
Definition: glcorearb.h:1924
#define UT_ASSERT(ZZ)
Definition: UT_Assert.h:171
OP_DataMicroNode & dataMicroNode()
Definition: OP_Node.h:1601
const GU_Detail * inputGeo(exint idx, const OP_Context &context) const
const PRM_Template * getTemplates() const
void addWarning(int code, const char *msg=0)
void addError(int code, const char *msg=0)
UT_SharedPtr< const PRM_DataItem > PRM_DataItemHandle
Definition: PRM_Parm.h:89
void selectPointsFrom(GA_Offset ptoff, bool point_sel=true, bool add_to_sel=false)
virtual void copyFrom(const SOP_NodeParms *src)
Definition: SOP_NodeVerb.h:180
void addTransformError(const OP_Node &node, const char *label=0) const
void select(const GA_Range &range, bool use_rtype=true, bool add_to_sel=false)