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 setManagesDataIDs(bool manages) { myManagesDataIDs = manages; }
29  bool getManagesDataIDs() const { return myManagesDataIDs; }
30 
31  void loadFromOpSubclass(const LoadParms &loadparms) override;
32 
33  void copyFrom(const OP_NodeParms *src) override;
34 
35  /// Marshalling interface to rest of world
36  /// These all use index based notation.
37  exint getNestNumParms(TempIndex idx) const override;
38  const char *getNestParmName(TempIndex idx) const override;
39  ParmType getNestParmType(TempIndex idx) const override;
40 
41  void getNestParmValue(TempIndex idx, TempIndex instance, exint &value) const override;
42  void getNestParmValue(TempIndex idx, TempIndex instance, fpreal &value) const override;
43  void getNestParmValue(TempIndex idx, TempIndex instance, UT_Vector2D &value) const override;
44  void getNestParmValue(TempIndex idx, TempIndex instance, UT_Vector3D &value) const override;
45  void getNestParmValue(TempIndex idx, TempIndex instance, UT_Vector4D &value) const override;
46  void getNestParmValue(TempIndex idx, TempIndex instance, UT_Matrix2D &value) const override;
47  void getNestParmValue(TempIndex idx, TempIndex instance, UT_Matrix3D &value) const override;
48  void getNestParmValue(TempIndex idx, TempIndex instance, UT_Matrix4D &value) const override;
49  void getNestParmValue(TempIndex idx, TempIndex instance, UT_StringHolder &value) const override;
50  void getNestParmValue(TempIndex idx, TempIndex instance, UT_SharedPtr<UT_Ramp> &value) const override;
51  void getNestParmValue(TempIndex idx, TempIndex instance, PRM_DataItemHandle &value) const override;
52 
53  void setNestParmValue(TempIndex idx, TempIndex instance, const exint &value) override;
54  void setNestParmValue(TempIndex idx, TempIndex instance, const fpreal &value) override;
55  void setNestParmValue(TempIndex idx, TempIndex instance, const UT_Vector2D &value) override;
56  void setNestParmValue(TempIndex idx, TempIndex instance, const UT_Vector3D &value) override;
57  void setNestParmValue(TempIndex idx, TempIndex instance, const UT_Vector4D &value) override;
58  void setNestParmValue(TempIndex idx, TempIndex instance, const UT_Matrix2D &value) override;
59  void setNestParmValue(TempIndex idx, TempIndex instance, const UT_Matrix3D &value) override;
60  void setNestParmValue(TempIndex idx, TempIndex instance, const UT_Matrix4D &value) override;
61  void setNestParmValue(TempIndex idx, TempIndex instance, const UT_StringHolder &value) override;
62  void setNestParmValue(TempIndex idx, TempIndex instance, const UT_SharedPtr<UT_Ramp> &value) override;
63  void setNestParmValue(TempIndex idx, TempIndex instance, const PRM_DataItemHandle &value) override;
64 
66  { return myOptions.getOptionEntry(name); }
67 
68  const PRM_Template *getTemplates() const
69  { return myTemplates; }
70 
71  class ParmDescr
72  {
73  public:
78  };
79 
80 protected:
81 
82  template <typename T> void internalGetNestParmValue(TempIndex idx, TempIndex instance, T &value) const;
83 
89  friend class SOP_NodeCacheOptions;
90 };
91 
92 ///
93 /// Provides a mostly drop-in replacement for SOP_Node, along with a
94 /// local GU_Detail * to write to.
95 ///
97 {
98 public:
100  ~SOP_NodeCacheOptions() override;
101 
102  void doCook(const SOP_NodeVerb *verb, const SOP_NodeVerb::CookParms &cookparms);
103 
104  // Wrappers for OP_Parameter() functions.
105  // Note time is unused as we've already hardened time in loadFromOp!
106  fpreal evalFloat(const char *parm, int vi, fpreal time) const;
107  exint evalInt(const char *parm, int vi, fpreal time) const;
108  void evalString(UT_String &value, const char *parm, int vi, fpreal time) const;
109  void evalString(UT_StringHolder &value, const char *parm, int vi, fpreal time) const;
110 
111  fpreal evalFloatInst(const char *parm, const int *instance, int vi, fpreal time, int nestlevel = 1) const;
112  exint evalIntInst(const char *parm, const int *instance, int vi, fpreal time, int nestlevel = 1) const;
113  void evalStringInst(const char *parm, const int *instance, UT_String &val, int vi, fpreal time, int nestlevel = 1) const;
114  void evalStringInst(const char *parm, const int *instance, UT_StringHolder &val, int vi, fpreal time, int nestlevel = 1) const;
115 
116  exint nInputs() const
117  { return myCookParms->nInputs(); }
118  bool hasInput(exint idx) const
119  { return myCookParms->hasInput(idx); }
120  const GU_Detail *inputGeo(exint idx, const OP_Context &context) const
121  { return inputGeo(idx); }
122  const GU_Detail *inputGeo(exint idx) const
123  { return myCookParms->inputGeo(idx); }
124 
125  OP_ERROR error();
126  void addError(int code, const char *msg = 0)
127  { myCookParms->sopAddError(code, msg); }
128  void addWarning(int code, const char *msg = 0)
129  { myCookParms->sopAddWarning(code, msg); }
130  void addMessage(int code, const char *msg = 0)
131  { myCookParms->sopAddMessage(code, msg); }
132 
133  /// Registers an error for cooking the given node's transform. If label is
134  /// supplied, then it will be used as a label of the transform error.
135  void addTransformError(const OP_Node &node,
136  const char *label=0) const
137  {
138  UT_String path;
139 
140  node.getFullPath(path);
141  if (UTisstring(label))
142  {
143  path += " (as ";
144  path += label;
145  path += ")";
146  }
147 
148  myCookParms->addError("OP", OP_ERR_TRANSFORM, path);
149  }
150 
151  void notifyGroupParmListeners(int groupparm_idx,
152  int grouptype_idx,
153  const GU_Detail *parm_gdp,
154  const GA_Group *parm_group) const
155  { myVerb->notifyGroupParmListeners(myCookParms->getNode(),
156  groupparm_idx, grouptype_idx, parm_gdp, parm_group); }
157 
159  { myCookParms->select(gtype); }
160 
162  bool add_to_sel = false)
163  { myCookParms->select(selection, add_to_sel); }
164 
165  // Select the group. opt use its type as sel type
166  void select(const GA_Group &group, bool use_gtype = true,
167  bool add_to_sel = false)
168  { myCookParms->select(group, use_gtype, add_to_sel); }
169 
170  void select(const GEO_Primitive &prim, bool sel_prim = true,
171  bool add_to_sel = false)
172  { myCookParms->select(prim, sel_prim, add_to_sel); }
173  void selectPoint(GA_Offset ptoff, bool point_sel = true,
174  bool add_to_sel = false)
175  { myCookParms->selectPoint(ptoff, point_sel, add_to_sel); }
176  void selectFrom(const GEO_Primitive &prim, bool sel_prim = true,
177  bool add_to_sel = false)
178  { myCookParms->selectFrom(prim, sel_prim, add_to_sel); }
179  void selectPointsFrom(GA_Offset ptoff, bool point_sel = true,
180  bool add_to_sel = false)
181  { myCookParms->selectPointsFrom(ptoff, point_sel, add_to_sel); }
182  void select(const GA_Range &range, bool use_rtype = true,
183  bool add_to_sel = false)
184  { myCookParms->select(range, use_rtype, add_to_sel); }
185 
186  // Selects input based on the group supplied and the group type. If
187  // group is not null, then it's type is used, otherwise the group type
188  // is used.
189  void selectInputGroup(const GA_Group *group,
190  GA_GroupType grouptype)
191  { myCookParms->selectInputGroup(group, grouptype); }
192 
193  // If no selection is present, then create a new empty primitive cook
194  // selection group. Otherwise, clear the selection.
196  { myCookParms->clearSelection(); }
197 
198  /// If the cook selection group is not of the given type, create an empty
199  /// cook selection group of that type. Otherwise, clear the existing cook
200  /// selection group.
202  { myCookParms->clearSelection(gtype); }
203 
204  // Blow away the selection and reinitialize it to 0. Much more radical
205  // than clearSelection(), which leaves behind a clean, empty selection.
206  // This method returns 1 if it had anything to destroy, else 0.
208  { return myCookParms->destroySelection(); }
209 
210  // Return 1 if selection is enabled, 0 if false.
211  bool selectionEnabled() const
212  { return myCookParms->selectionEnabled(); }
213 
214  /// Typedef to help make use of GroupCreator less verbose.
216 
218  {
219  UT_ASSERT(type == OP_INTEREST_DATA);
220  if (type == OP_INTEREST_DATA && op && myCookParms->depnode())
221  myCookParms->depnode()->addExplicitInput(op->dataMicroNode());
222  }
223 
224 protected:
225  // Note this context has no valid time!
226  virtual OP_ERROR cook(OP_Context &context) = 0;
227 
228 
229  /// These are transitory for the duration of the cook.
231 
232  const SOP_NodeVerb::CookParms *cookparms() const { return myCookParms; }
233 
234 private:
235  const SOP_NodeParmsOptions *myOptions;
236  const SOP_NodeVerb::CookParms *myCookParms;
237  const SOP_NodeVerb *myVerb;
238 };
239 
240 #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
GLenum GLint * range
Definition: glcorearb.h:1925
GLuint GLsizei const GLchar * label
Definition: glcorearb.h:2545
GT_API const UT_StringHolder time
virtual void setNestParmValue(TempIndex idx, TempIndex instance, const exint &value)
Definition: OP_NodeParms.h:277
GLsizei const GLchar *const * path
Definition: glcorearb.h:3341
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
virtual ParmType getNestParmType(TempIndex idx) const
Definition: OP_NodeParms.h:263
GOP_Manager::GroupCreator GroupCreator
Typedef to help make use of GroupCreator less verbose.
virtual void loadFromOpSubclass(const LoadParms &loadparms)=0
A range of elements in an index-map.
Definition: GA_Range.h:42
< returns > If no error
Definition: snippets.dox:2
GA_Size GA_Offset
Definition: GA_Types.h:641
const char * getFullPath(UT_String &str) const
Definition: PRM_ParmOwner.h:52
void selectInputGroup(const GA_Group *group, GA_GroupType grouptype)
virtual exint getNestNumParms(TempIndex idx) const
Definition: OP_NodeParms.h:261
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
std::shared_ptr< T > UT_SharedPtr
Wrapper around std::shared_ptr.
Definition: UT_SharedPtr.h:36
void setManagesDataIDs(bool manages)
void select(GA_GroupType gtype=GA_GROUP_PRIMITIVE)
bool getManagesDataIDs() const
GLuint const GLchar * name
Definition: glcorearb.h:786
GU_Detail * gdp
These are transitory for the duration of the cook.
UT_SharedPtr< GU_Selection > GU_SelectionHandle
bool hasInput(exint idx) const
void clearSelection(GA_GroupType gtype)
virtual void copyFrom(const OP_NodeParms *src)
Definition: OP_NodeParms.h:155
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:160
SYS_FORCE_INLINE bool UTisstring(const char *s)
GLuint GLfloat * val
Definition: glcorearb.h:1608
const PRM_Template * myTemplates
#define SOP_API
Definition: SOP_API.h:10
UT_Array< ParmDescr > myParmDescr
virtual void getNestParmValue(TempIndex idx, TempIndex instance, exint &value) const
Definition: OP_NodeParms.h:265
#define UT_ASSERT(ZZ)
Definition: UT_Assert.h:156
Definition: core.h:1131
OP_DataMicroNode & dataMicroNode()
Definition: OP_Node.h:1596
const GU_Detail * inputGeo(exint idx, const OP_Context &context) const
const PRM_Template * getTemplates() const
type
Definition: core.h:1059
void addWarning(int code, const char *msg=0)
virtual const char * getNestParmName(TempIndex idx) const
Definition: OP_NodeParms.h:262
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)
void addTransformError(const OP_Node &node, const char *label=0) const
GLenum src
Definition: glcorearb.h:1793
void select(const GA_Range &range, bool use_rtype=true, bool add_to_sel=false)