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 
25 /// This class stores a set of name/value pairs. Each value can be one of
26 /// several different data types. No automatic conversion between data types
27 /// is provided, so accessing existing data requires knowledge of both the
28 /// data name and the data type.
30 {
31 public:
32  explicit OP_Options();
33  virtual ~OP_Options();
34 
35  /// Set the data in this OP_Options to be an interpolation of the data
36  /// in two other OP_Options. The actual interpolation of each piece of
37  /// data is performed by the OP_OptionInterpolator, which allows
38  /// the interpolation behavior to be customized.
39  void interpolate(const OP_Options &source1,
40  const OP_Options &source2,
41  fpreal interp);
42 
43 
44  /// Utility function for setting an option based on a parm template.
45  /// This is useful for gathering information from operator parameters
46  /// to be passed on to OP_Data::setParameters().
47  /// This will harden op references to full paths, add parameter
48  /// tuples as vector2/vector3/etc options, and also build ramp
49  /// and multiparms. Ramps become strings and multiparms are
50  /// recursed and all their implied parms added.
51  void setOptionFromTemplate(const OP_Node *node,
52  const PRM_Template &tplate,
53  int pi, fpreal time);
54  void setOptionFromTemplate(const OP_Node *node,
55  const PRM_Parm &parm,
56  const PRM_Template &tplate,
57  fpreal time);
58 
59  /// Utility function for setting options based on channel names of a
60  /// parameter. This splits up a single parameter tuple into multiple
61  /// scalar options.
62  void setOptionFromParm(const OP_Node *node, int pi, int vi,
63  fpreal time);
64 
65  /// Utility function for setting an options based on the default value
66  /// stored in a parm template. This is used to gather default values
67  /// for initializing a OP_Data type. The parameter defaults are
68  /// gethered into a OP_Options data structure which is passed to
69  /// OP_Data::setParameters().
70  void setOptionFromTemplateDefault(const PRM_Template &tp);
71 
72  /// Sets an option based on strings coming from a command. This is
73  /// used by the dopsolvesetoption command. This funtion returns true
74  /// if the parameters make sense together and result in setting an
75  /// option. Otherwise false is returned.
76  bool setOptionFromCommand(const char *optionname,
77  const char *optionvalue,
78  fpreal optionvaluefloat,
79  UT_OptionType optiontype);
80 
81  /// Calculates a transform matrix based on standard transform options
82  /// like t, r, s, etc.
83  UT_DMatrix4 getTransformFromOptions() const;
84 
85  /// Set one OP_Options equal to another.
86  const OP_Options &operator=(const UT_Options &src);
87 
88 protected:
89  /// This function is called whenever data is added, removed, or changed.
90  /// If the name parameter is null, then multiple pieces of data were
91  /// changed simultaneously (probably through a load or assignment
92  /// operation). This function just calls OP_OptionsUser::optionChanged()
93  /// on each user of this data.
94  virtual void optionChanged(const char *name);
95 
96  /// These functions perform the actual interpolation of each data type.
97  void getInterpolatedInt(int64 &value,
98  int source1,
99  int source2,
100  fpreal interp) const;
101  void getInterpolatedBool(bool &value,
102  bool source1,
103  bool source2,
104  fpreal interp) const;
105  void getInterpolatedFpreal(fpreal64 &value,
106  fpreal source1,
107  fpreal source2,
108  fpreal interp) const;
109  void getInterpolatedString(UT_StringHolder &value,
110  const UT_StringHolder &source1,
111  const UT_StringHolder &source2,
112  fpreal interp) const;
113  void getInterpolatedVector2(UT_Vector2D &value,
114  const UT_Vector2D &source1,
115  const UT_Vector2D &source2,
116  fpreal interp) const;
117  void getInterpolatedVector3(UT_Vector3D &value,
118  const UT_Vector3D &source1,
119  const UT_Vector3D &source2,
120  fpreal interp) const;
121  void getInterpolatedVector4(UT_Vector4D &value,
122  const UT_Vector4D &source1,
123  const UT_Vector4D &source2,
124  fpreal interp) const;
125  void getInterpolatedQuaternion(UT_QuaternionD &value,
126  const UT_QuaternionD &source1,
127  const UT_QuaternionD &source2,
128  fpreal interp) const;
129  void getInterpolatedMatrix2(UT_Matrix2D &value,
130  const UT_Matrix2D &source1,
131  const UT_Matrix2D &source2,
132  fpreal interp) const;
133  void getInterpolatedMatrix3(UT_Matrix3D &value,
134  const UT_Matrix3D &source1,
135  const UT_Matrix3D &source2,
136  fpreal interp) const;
137  void getInterpolatedMatrix4(UT_Matrix4D &value,
138  const UT_Matrix4D &source1,
139  const UT_Matrix4D &source2,
140  fpreal interp) const;
141  void getInterpolatedIntArray(UT_Int64Array &value,
142  const UT_Int64Array &source1,
143  const UT_Int64Array &source2,
144  fpreal interp);
145  void getInterpolatedFprealArray(UT_Fpreal64Array &value,
146  const UT_Fpreal64Array &source1,
147  const UT_Fpreal64Array &source2,
148  fpreal interp);
149  void getInterpolatedStringArray(UT_StringArray &value,
150  const UT_StringArray &source1,
151  const UT_StringArray &source2,
152  fpreal interp);
153 
154 private:
155  explicit OP_Options(const OP_Options &src);
156 };
157 
158 #endif
const UT_Options & operator=(const UT_Options &src)
Assignment operator.
GT_API const UT_StringHolder time
UT_OptionType
long long int64
Definition: SYS_Types.h:107
double fpreal64
Definition: SYS_Types.h:192
virtual void optionChanged(const char *name)
GLuint const GLchar * name
Definition: glcorearb.h:785
GLsizei const GLfloat * value
Definition: glcorearb.h:823
double fpreal
Definition: SYS_Types.h:270
A map of string to various well defined value types.
Definition: UT_Options.h:42
#define OP_API
Definition: OP_API.h:10
GLenum src
Definition: glcorearb.h:1792