HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros 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  virtual ~SOP_NodeParmsOptions();
27 
28  virtual void loadFromOpSubclass(const LoadParms &loadparms);
29 
30  virtual void copyFrom(const SOP_NodeParms *src);
31 
32  /// Marshalling interface to rest of world
33  /// These all use index based notation.
34  virtual exint getNumParms() const;
35  virtual const char *getParmName(exint idx) const;
36  virtual ParmType getParmType(exint idx) const;
37 
38  virtual void getParmValue(exint idx, exint &value) const;
39  virtual void getParmValue(exint idx, fpreal &value) const;
40  virtual void getParmValue(exint idx, UT_Vector2D &value) const;
41  virtual void getParmValue(exint idx, UT_Vector3D &value) const;
42  virtual void getParmValue(exint idx, UT_Vector4D &value) const;
43  virtual void getParmValue(exint idx, UT_Matrix2D &value) const;
44  virtual void getParmValue(exint idx, UT_Matrix3D &value) const;
45  virtual void getParmValue(exint idx, UT_Matrix4D &value) const;
46  virtual void getParmValue(exint idx, UT_StringHolder &value) const;
47  virtual void getParmValue(exint idx, UT_SharedPtr<UT_Ramp> &value) const;
48  virtual void getParmValue(exint idx, PRM_DataItemHandle &value) const;
49 
50  virtual void setParmValue(exint idx, const exint &value);
51  virtual void setParmValue(exint idx, const fpreal &value);
52  virtual void setParmValue(exint idx, const UT_Vector2D &value);
53  virtual void setParmValue(exint idx, const UT_Vector3D &value);
54  virtual void setParmValue(exint idx, const UT_Vector4D &value);
55  virtual void setParmValue(exint idx, const UT_Matrix2D &value);
56  virtual void setParmValue(exint idx, const UT_Matrix3D &value);
57  virtual void setParmValue(exint idx, const UT_Matrix4D &value);
58  virtual void setParmValue(exint idx, const UT_StringHolder &value);
59  virtual void setParmValue(exint idx, const UT_SharedPtr<UT_Ramp> &value);
60  virtual void setParmValue(exint idx, const PRM_DataItemHandle &value);
61 
63  { return myOptions.getOptionEntry(name); }
64 
65  const PRM_Template *getTemplates() const
66  { return myTemplates; }
67 
68 protected:
74  friend class SOP_NodeCacheOptions;
75 };
76 
77 ///
78 /// Provides a mostly drop-in replacement for SOP_Node, along with a
79 /// local GU_Detail * to write to.
80 ///
82 {
83 public:
85  virtual ~SOP_NodeCacheOptions();
86 
87  void doCook(const SOP_NodeVerb *verb, const SOP_NodeVerb::CookParms &cookparms);
88 
89  // Wrappers for OP_Parameter() functions.
90  // Note time is unused as we've already hardened time in loadFromOp!
91  fpreal evalFloat(const char *parm, int vi, fpreal time) const;
92  exint evalInt(const char *parm, int vi, fpreal time) const;
93  void evalString(UT_String &value, const char *parm, int vi, fpreal time) const;
94 
95  fpreal evalFloatInst(const char *parm, const int *instance, int vi, fpreal time, int nestlevel = 1) const;
96  exint evalIntInst(const char *parm, const int *instance, int vi, fpreal time, int nestlevel = 1) const;
97  void evalStringInst(const char *parm, const int *instance, UT_String &val, int vi, fpreal time, int nestlevel = 1) const;
98 
99  exint nInputs() const
100  { return myCookParms->nInputs(); }
101  bool hasInput(exint idx) const
102  { return myCookParms->hasInput(idx); }
103  const GU_Detail *inputGeo(exint idx, const OP_Context &context) const
104  { return inputGeo(idx); }
105  const GU_Detail *inputGeo(exint idx) const
106  { return myCookParms->inputGeo(idx); }
107 
108  OP_ERROR error();
109  void addError(int code, const char *msg = 0)
110  { myCookParms->sopAddError(code, msg); }
111  void addWarning(int code, const char *msg = 0)
112  { myCookParms->sopAddWarning(code, msg); }
113  void addMessage(int code, const char *msg = 0)
114  { myCookParms->sopAddMessage(code, msg); }
115 
116  /// Registers an error for cooking the given node's transform. If label is
117  /// supplied, then it will be used as a label of the transform error.
118  void addTransformError(const OP_Node &node,
119  const char *label=0) const
120  {
121  UT_String path;
122 
123  node.getFullPath(path);
124  if (UTisstring(label))
125  {
126  path += " (as ";
127  path += label;
128  path += ")";
129  }
130 
131  myCookParms->addError("OP", OP_ERR_TRANSFORM, path);
132  }
133 
134  void notifyGroupParmListeners(int groupparm_idx,
135  int grouptype_idx,
136  const GU_Detail *parm_gdp,
137  const GA_Group *parm_group) const
138  { myVerb->notifyGroupParmListeners(myCookParms->getNode(),
139  groupparm_idx, grouptype_idx, parm_gdp, parm_group); }
140 
142  { myCookParms->select(gtype); }
143 
144  void select(GU_SelectionHandle selection,
145  bool add_to_sel = false)
146  { myCookParms->select(selection, add_to_sel); }
147 
148  // Select the group. opt use its type as sel type
149  void select(const GA_Group &group, bool use_gtype = true,
150  bool add_to_sel = false)
151  { myCookParms->select(group, use_gtype, add_to_sel); }
152 
153  void select(const GEO_Primitive &prim, bool sel_prim = true,
154  bool add_to_sel = false)
155  { myCookParms->select(prim, sel_prim, add_to_sel); }
156  void selectPoint(GA_Offset ptoff, bool point_sel = true,
157  bool add_to_sel = false)
158  { myCookParms->selectPoint(ptoff, point_sel, add_to_sel); }
159  void selectFrom(const GEO_Primitive &prim, bool sel_prim = true,
160  bool add_to_sel = false)
161  { myCookParms->selectFrom(prim, sel_prim, add_to_sel); }
162  void selectPointsFrom(GA_Offset ptoff, bool point_sel = true,
163  bool add_to_sel = false)
164  { myCookParms->selectPointsFrom(ptoff, point_sel, add_to_sel); }
165  void select(const GA_Range &range, bool use_rtype = true,
166  bool add_to_sel = false)
167  { myCookParms->select(range, use_rtype, add_to_sel); }
168 
169  // Selects input based on the group supplied and the group type. If
170  // group is not null, then it's type is used, otherwise the group type
171  // is used.
172  void selectInputGroup(const GA_Group *group,
173  GA_GroupType grouptype)
174  { myCookParms->selectInputGroup(group, grouptype); }
175 
176  // If no selection is present, then create a new empty primitive cook
177  // selection group. Otherwise, clear the selection.
179  { myCookParms->clearSelection(); }
180 
181  /// If the cook selection group is not of the given type, create an empty
182  /// cook selection group of that type. Otherwise, clear the existing cook
183  /// selection group.
185  { myCookParms->clearSelection(gtype); }
186 
187  // Blow away the selection and reinitialize it to 0. Much more radical
188  // than clearSelection(), which leaves behind a clean, empty selection.
189  // This method returns 1 if it had anything to destroy, else 0.
191  { return myCookParms->destroySelection(); }
192 
193  // Return 1 if selection is enabled, 0 if false.
194  bool selectionEnabled() const
195  { return myCookParms->selectionEnabled(); }
196 
197  /// Typedef to help make use of GroupCreator less verbose.
199 
201  {
202  UT_ASSERT(type == OP_INTEREST_DATA);
203  if (type == OP_INTEREST_DATA && op && myCookParms->depnode())
204  myCookParms->depnode()->addExplicitInput(op->dataMicroNode());
205  }
206 
207 protected:
208  // Note this context has no valid time!
209  virtual OP_ERROR cook(OP_Context &context) = 0;
210 
211 
212  /// These are transitory for the duration of the cook.
214 
215  const SOP_NodeVerb::CookParms *cookparms() const { return myCookParms; }
216 
217 private:
218  const SOP_NodeParmsOptions *myOptions;
219  const SOP_NodeVerb::CookParms *myCookParms;
220  const SOP_NodeVerb *myVerb;
221 };
222 
223 #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)
GLenum GLint * range
Definition: glcorearb.h:1924
GLuint GLsizei const GLchar * label
Definition: glcorearb.h:2544
virtual void setParmValue(exint idx, const exint &value)
Definition: SOP_NodeVerb.h:223
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)
UT_ErrorSeverity
Definition: UT_Error.h:25
virtual ParmType getParmType(exint idx) const
Definition: SOP_NodeVerb.h:209
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:617
const char * getFullPath(UT_String &str) const
Definition: PRM_ParmOwner.h:47
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
#define UT_ASSERT(ZZ)
Definition: UT_Assert.h:102
UT_Array< ParmType > myParmTypes
int64 exint
Definition: SYS_Types.h:109
void select(GA_GroupType gtype=GA_GROUP_PRIMITIVE)
virtual exint getNumParms() const
Definition: SOP_NodeVerb.h:207
virtual void loadFromOpSubclass(const LoadParms &loadparms)=0
virtual void getParmValue(exint idx, exint &value) const
Definition: SOP_NodeVerb.h:211
GLuint const GLchar * name
Definition: glcorearb.h:785
GU_Detail * gdp
These are transitory for the duration of the cook.
bool hasInput(exint idx) const
void clearSelection(GA_GroupType gtype)
GLsizei const GLfloat * value
Definition: glcorearb.h:823
double fpreal
Definition: SYS_Types.h:263
SYS_FORCE_INLINE bool UTisstring(const char *s)
Definition: UT_String.h:58
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:138
virtual const char * getParmName(exint idx) const
Definition: SOP_NodeVerb.h:208
GLuint GLfloat * val
Definition: glcorearb.h:1607
const PRM_Template * myTemplates
#define SOP_API
Definition: SOP_API.h:10
GLint GLint GLsizei GLint GLenum GLenum type
Definition: glcorearb.h:107
OP_DataMicroNode & dataMicroNode()
Definition: OP_Node.h:1510
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)
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:186
void addTransformError(const OP_Node &node, const char *label=0) const
GLenum src
Definition: glcorearb.h:1792
void select(const GA_Range &range, bool use_rtype=true, bool add_to_sel=false)