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