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 
76  /// Utility function for setting options based on channel names of a
77  /// parameter. This splits up a single parameter tuple into multiple
78  /// scalar options.
79  void setOptionFromParm(const OP_Node *node, int pi, int vi,
80  fpreal time);
81 
82  /// Utility function for setting an options based on the default value
83  /// stored in a parm template. This is used to gather default values
84  /// for initializing a OP_Data type. The parameter defaults are
85  /// gethered into a OP_Options data structure which is passed to
86  /// OP_Data::setParameters().
87  void setOptionFromTemplateDefault(const PRM_Template &tp);
88 
89  /// Returns how to interepret this template as an option type.
90  /// UT_OPTION_INVALID if unsupported.
91  static UT_OptionType getOptionTypeFromTemplate(const PRM_Template &tp);
92 
93  /// Sets an option based on strings coming from a command. This is
94  /// used by the dopsolvesetoption command. This funtion returns true
95  /// if the parameters make sense together and result in setting an
96  /// option. Otherwise false is returned.
97  bool setOptionFromCommand(const char *optionname,
98  const char *optionvalue,
99  fpreal optionvaluefloat,
100  UT_OptionType optiontype);
101 
102  /// Calculates a transform matrix based on standard transform options
103  /// like t, r, s, etc.
104  UT_DMatrix4 getTransformFromOptions() const;
105 
106  /// Set one OP_Options equal to another.
107  const OP_Options &operator=(const UT_Options &src);
108 
109 protected:
110  /// This function is called whenever data is added, removed, or changed.
111  /// If the name parameter is null, then multiple pieces of data were
112  /// changed simultaneously (probably through a load or assignment
113  /// operation). This function just calls OP_OptionsUser::optionChanged()
114  /// on each user of this data.
115  void optionChanged(const char *name) override;
116 
117  /// These functions perform the actual interpolation of each data type.
118  void getInterpolatedInt(int64 &value,
119  int64 source1,
120  int64 source2,
121  fpreal interp) const;
122  void getInterpolatedBool(bool &value,
123  bool source1,
124  bool source2,
125  fpreal interp) const;
126  void getInterpolatedFpreal(fpreal64 &value,
127  fpreal source1,
128  fpreal source2,
129  fpreal interp) const;
130  void getInterpolatedString(UT_StringHolder &value,
131  const UT_StringHolder &source1,
132  const UT_StringHolder &source2,
133  fpreal interp) const;
134  void getInterpolatedDict(UT_OptionsHolder &value,
135  const UT_OptionsHolder &source1,
136  const UT_OptionsHolder &source2,
137  fpreal interp) const;
138  void getInterpolatedVector2(UT_Vector2D &value,
139  const UT_Vector2D &source1,
140  const UT_Vector2D &source2,
141  fpreal interp) const;
142  void getInterpolatedVector3(UT_Vector3D &value,
143  const UT_Vector3D &source1,
144  const UT_Vector3D &source2,
145  fpreal interp) const;
146  void getInterpolatedVector4(UT_Vector4D &value,
147  const UT_Vector4D &source1,
148  const UT_Vector4D &source2,
149  fpreal interp) const;
150  void getInterpolatedQuaternion(UT_QuaternionD &value,
151  const UT_QuaternionD &source1,
152  const UT_QuaternionD &source2,
153  fpreal interp) const;
154  void getInterpolatedMatrix2(UT_Matrix2D &value,
155  const UT_Matrix2D &source1,
156  const UT_Matrix2D &source2,
157  fpreal interp) const;
158  void getInterpolatedMatrix3(UT_Matrix3D &value,
159  const UT_Matrix3D &source1,
160  const UT_Matrix3D &source2,
161  fpreal interp) const;
162  void getInterpolatedMatrix4(UT_Matrix4D &value,
163  const UT_Matrix4D &source1,
164  const UT_Matrix4D &source2,
165  fpreal interp) const;
166  void getInterpolatedIntArray(UT_Int64Array &value,
167  const UT_Int64Array &source1,
168  const UT_Int64Array &source2,
169  fpreal interp);
170  void getInterpolatedFprealArray(UT_Fpreal64Array &value,
171  const UT_Fpreal64Array &source1,
172  const UT_Fpreal64Array &source2,
173  fpreal interp);
174  void getInterpolatedStringArray(UT_StringArray &value,
175  const UT_StringArray &source1,
176  const UT_StringArray &source2,
177  fpreal interp);
178  void getInterpolatedDictArray(UT_Array<UT_OptionsHolder> &value,
179  const UT_Array<UT_OptionsHolder> &source1,
180  const UT_Array<UT_OptionsHolder> &source2,
181  fpreal interp);
182 };
183 
184 #endif
const UT_Options & operator=(const UT_Options &src)
Assignment operator.
GT_API const UT_StringHolder time
UT_OptionType
Definition: UT_Options.h:44
GLuint const GLchar * name
Definition: glcorearb.h:785
GLenum src
Definition: glcorearb.h:1792
double fpreal64
Definition: SYS_Types.h:201
GLuint interp
Definition: glew.h:8307
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
GLsizei const GLfloat * value
Definition: glcorearb.h:823
constexpr T pi()
Pi constant taken from Boost to match old behaviour.
Definition: Math.h:118
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)