HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
OP_Options.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: OP_Options.h (C++, Utility Library)
7  *
8  * COMMENTS: Subclass of UT_Options to provide some special functionality
9  * used by the SIM library.
10  *
11  */
12 
13 #ifndef _OP_OPTIONS_H_
14 #define _OP_OPTIONS_H_
15 
16 #include "OP_API.h"
17 #include <UT/UT_Matrix4.h>
18 #include <UT/UT_Options.h>
19 #include <SYS/SYS_Types.h>
20 
21 class OP_Node;
22 class PRM_Template;
23 class PRM_Parm;
24 class DEP_MicroNode;
25 
26 /// This class stores a set of name/value pairs. Each value can be one of
27 /// several different data types. No automatic conversion between data types
28 /// is provided, so accessing existing data requires knowledge of both the
29 /// data name and the data type.
31 {
32 public:
33  explicit OP_Options();
34  ~OP_Options() override;
35 
36  // Delete the copy-ctor, but we still require the = operator
37  OP_Options(const OP_Options &) = delete;
38 
39  /// Set the data in this OP_Options to be an interpolation of the data
40  /// in two other OP_Options. The actual interpolation of each piece of
41  /// data is performed by the OP_OptionInterpolator, which allows
42  /// the interpolation behavior to be customized.
43  void interpolate(const OP_Options &source1,
44  const OP_Options &source2,
45  fpreal interp);
46 
47 
48  /// Utility function for setting an option based on a parm template.
49  /// This is useful for gathering information from operator parameters
50  /// to be passed on to OP_Data::setParameters().
51  /// This will harden op references to full paths, add parameter
52  /// tuples as vector2/vector3/etc options, and also build ramp
53  /// and multiparms. Ramps become strings and multiparms are
54  /// recursed and all their implied parms added.
55  /// Additionally, a dependency sink can be provided for all the
56  /// evaluated parameters to be added to.
57  /// Recursed multiparms may be added as option arrays rather
58  /// than as a list of parameters
59  void setOptionFromTemplate(const OP_Node *node,
60  const PRM_Template &tplate,
61  int pi, fpreal time,
62  bool usetemplatetoken = false,
63  DEP_MicroNode *depnode = 0);
64  void setOptionFromTemplate(const OP_Node *node,
65  const PRM_Parm &parm,
66  const PRM_Template &tplate,
67  fpreal time,
68  bool usetemplatetoken = false,
69  DEP_MicroNode *depnode = 0);
70 
71  /// Utility function for setting options based on channel names of a
72  /// parameter. This splits up a single parameter tuple into multiple
73  /// scalar options.
74  void setOptionFromParm(const OP_Node *node, int pi, int vi,
75  fpreal time);
76 
77  /// Utility function for setting an options based on the default value
78  /// stored in a parm template. This is used to gather default values
79  /// for initializing a OP_Data type. The parameter defaults are
80  /// gethered into a OP_Options data structure which is passed to
81  /// OP_Data::setParameters().
82  void setOptionFromTemplateDefault(const PRM_Template &tp);
83 
84  /// Returns how to interepret this template as an option type.
85  /// UT_OPTION_INVALID if unsupported.
86  static UT_OptionType getOptionTypeFromTemplate(const PRM_Template &tp);
87 
88  /// Sets an option based on strings coming from a command. This is
89  /// used by the dopsolvesetoption command. This funtion returns true
90  /// if the parameters make sense together and result in setting an
91  /// option. Otherwise false is returned.
92  bool setOptionFromCommand(const char *optionname,
93  const char *optionvalue,
94  fpreal optionvaluefloat,
95  UT_OptionType optiontype);
96 
97  /// Calculates a transform matrix based on standard transform options
98  /// like t, r, s, etc.
99  UT_DMatrix4 getTransformFromOptions() const;
100 
101  /// Set one OP_Options equal to another.
102  const OP_Options &operator=(const UT_Options &src);
103 
104 protected:
105  /// This function is called whenever data is added, removed, or changed.
106  /// If the name parameter is null, then multiple pieces of data were
107  /// changed simultaneously (probably through a load or assignment
108  /// operation). This function just calls OP_OptionsUser::optionChanged()
109  /// on each user of this data.
110  void optionChanged(const char *name) override;
111 
112  /// These functions perform the actual interpolation of each data type.
113  void getInterpolatedInt(int64 &value,
114  int64 source1,
115  int64 source2,
116  fpreal interp) const;
117  void getInterpolatedBool(bool &value,
118  bool source1,
119  bool source2,
120  fpreal interp) const;
121  void getInterpolatedFpreal(fpreal64 &value,
122  fpreal source1,
123  fpreal source2,
124  fpreal interp) const;
125  void getInterpolatedString(UT_StringHolder &value,
126  const UT_StringHolder &source1,
127  const UT_StringHolder &source2,
128  fpreal interp) const;
129  void getInterpolatedDict(UT_OptionsHolder &value,
130  const UT_OptionsHolder &source1,
131  const UT_OptionsHolder &source2,
132  fpreal interp) const;
133  void getInterpolatedVector2(UT_Vector2D &value,
134  const UT_Vector2D &source1,
135  const UT_Vector2D &source2,
136  fpreal interp) const;
137  void getInterpolatedVector3(UT_Vector3D &value,
138  const UT_Vector3D &source1,
139  const UT_Vector3D &source2,
140  fpreal interp) const;
141  void getInterpolatedVector4(UT_Vector4D &value,
142  const UT_Vector4D &source1,
143  const UT_Vector4D &source2,
144  fpreal interp) const;
145  void getInterpolatedQuaternion(UT_QuaternionD &value,
146  const UT_QuaternionD &source1,
147  const UT_QuaternionD &source2,
148  fpreal interp) const;
149  void getInterpolatedMatrix2(UT_Matrix2D &value,
150  const UT_Matrix2D &source1,
151  const UT_Matrix2D &source2,
152  fpreal interp) const;
153  void getInterpolatedMatrix3(UT_Matrix3D &value,
154  const UT_Matrix3D &source1,
155  const UT_Matrix3D &source2,
156  fpreal interp) const;
157  void getInterpolatedMatrix4(UT_Matrix4D &value,
158  const UT_Matrix4D &source1,
159  const UT_Matrix4D &source2,
160  fpreal interp) const;
161  void getInterpolatedIntArray(UT_Int64Array &value,
162  const UT_Int64Array &source1,
163  const UT_Int64Array &source2,
164  fpreal interp);
165  void getInterpolatedFprealArray(UT_Fpreal64Array &value,
166  const UT_Fpreal64Array &source1,
167  const UT_Fpreal64Array &source2,
168  fpreal interp);
169  void getInterpolatedStringArray(UT_StringArray &value,
170  const UT_StringArray &source1,
171  const UT_StringArray &source2,
172  fpreal interp);
173  void getInterpolatedDictArray(UT_Array<UT_OptionsHolder> &value,
174  const UT_Array<UT_OptionsHolder> &source1,
175  const UT_Array<UT_OptionsHolder> &source2,
176  fpreal interp);
177 };
178 
179 #endif
const UT_Options & operator=(const UT_Options &src)
Assignment operator.
GLenum src
Definition: glew.h:2410
GLuint const GLchar * name
Definition: glew.h:1814
GT_API const UT_StringHolder time
UT_OptionType
Definition: UT_Options.h:44
double fpreal64
Definition: SYS_Types.h:201
GLuint interp
Definition: glew.h:8277
virtual void optionChanged(const char *name)
long long int64
Definition: SYS_Types.h:116
A map of string to various well defined value types.
Definition: UT_Options.h:84
fpreal64 fpreal
Definition: SYS_Types.h:277
#define OP_API
Definition: OP_API.h:10
constexpr T pi()
Pi constant taken from Boost to match old behaviour.
Definition: Math.h:108
GLsizei const GLfloat * value
Definition: glew.h:1849