TuttleOFX  1
ofxParametricParam.h
Go to the documentation of this file.
00001 #ifndef _ofxParametricParam_h_
00002 #define _ofxParametricParam_h_
00003 
00004 /*
00005 Software License :
00006 
00007 Copyright (c) 2009, The Open Effects Association Ltd. All rights reserved.
00008 
00009 Redistribution and use in source and binary forms, with or without
00010 modification, are permitted provided that the following conditions are met:
00011 
00012     * Redistributions of source code must retain the above copyright notice,
00013       this list of conditions and the following disclaimer.
00014     * Redistributions in binary form must reproduce the above copyright notice,
00015       this list of conditions and the following disclaimer in the documentation
00016       and/or other materials provided with the distribution.
00017     * Neither the name The Open Effects Association Ltd, nor the names of its 
00018       contributors may be used to endorse or promote products derived from this
00019       software without specific prior written permission.
00020 
00021 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
00022 ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
00023 WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
00024 DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
00025 ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
00026 (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
00027 LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
00028 ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
00029 (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
00030 SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
00031 */
00032 
00033 /** @file ofxParametricParam.h
00034  
00035 This header file defines the optional OFX extension to define and manipulate parametric
00036 parameters.
00037 
00038 */
00039 
00040 #include "ofxParam.h"
00041 
00042 #ifdef __cplusplus
00043 extern "C" {
00044 #endif
00045 
00046 /** @brief string value to the ::kOfxPropType property for all parameters */
00047 #define kOfxParametricParameterSuite "OfxParametricParameterSuite"
00048 
00049 
00050 /**
00051    \defgroup ParamTypeDefines Parameter Type definitions 
00052 
00053 These strings are used to identify the type of the parameter when it is defined, they are also on the ::kOfxParamPropType in any parameter instance.
00054 */
00055 /*@{*/
00056 
00057 /** @brief String to identify a param as a single valued integer */
00058 #define kOfxParamTypeParametric "OfxParamTypeParametric"
00059 
00060 /*@}*/
00061 
00062 /**
00063    \addtogroup PropertiesAll
00064 */
00065 /*@{*/
00066 /**
00067    \defgroup ParamPropDefines Parameter Property Definitions 
00068 
00069 These are the list of properties used by the parameters suite.
00070 */
00071 /*@{*/
00072 
00073 /** @brief The dimension of a parametric param
00074 
00075     - Type - int X 1
00076     - Property Set - parametric param descriptor (read/write) and instance (read only)
00077     - default - 1
00078     - Value Values - greater than 0
00079 
00080 This indicates the dimension of the parametric param.
00081 */
00082 #define kOfxParamPropParametricDimension "OfxParamPropParametricDimension"
00083 
00084 /** @brief The colour of parametric param curve interface in any UI.
00085 
00086     - Type - double X N
00087     - Property Set - parametric param descriptor (read/write) and instance (read only)
00088     - default - unset, 
00089     - Value Values - three values for each dimension (see ::kOfxParamPropParametricDimension)
00090       being interpretted as R, G and B of the colour for each curve drawn in the UI.
00091 
00092 This sets the colour of a parametric param curve drawn a host user interface. A colour triple
00093 is needed for each dimension of the oparametric param. 
00094 
00095 If not set, the host should generally draw these in white.
00096 */
00097 #define kOfxParamPropParametricUIColour "OfxParamPropParametricUIColour"
00098 
00099 /** @brief Interact entry point to draw the background of a parametric parameter.
00100  
00101     - Type - pointer X 1
00102     - Property Set - plug-in parametric parameter descriptor (read/write) and instance (read only),
00103     - Default - NULL, which implies the host should draw its default background.
00104  
00105 Defines a pointer to an interact which will be used to draw the background of a parametric 
00106 parameter's user interface.  None of the pen or keyboard actions can ever be called on the interact.
00107  
00108 The openGL transform will be set so that it is an orthographic transform that maps directly to the
00109 'parametric' space, so that 'x' represents the parametric position and 'y' represents the evaluated
00110 value.
00111 */
00112 #define kOfxParamPropParametricInteractBackground "OfxParamPropParametricInteractBackground"
00113 
00114 /** @brief Property on the host to indicate support for parametric parameter animation.
00115  
00116     - Type - int X 1
00117     - Property Set - host descriptor (read only)
00118     - Valid Values 
00119       - 0 indicating the host does not support animation of parmetric params,
00120       - 1 indicating the host does support animation of parmetric params,
00121 */
00122 #define kOfxParamHostPropSupportsParametricAnimation "OfxParamHostPropSupportsParametricAnimation"
00123 
00124 /** @brief Property to indicate the min and max range of the parametric input value.
00125  
00126     - Type - double X 2
00127     - Property Set - parameter descriptor (read/write only), and instance (read only)
00128     - Default Value - (0, 1)
00129     - Valid Values - any pair of numbers so that  the first is less than the second.
00130 
00131 This controls the min and max values that the parameter will be evaluated at.
00132 */
00133 #define kOfxParamPropParametricRange "OfxParamPropParametricRange"
00134 
00135 /*@}*/
00136 /*@}*/
00137 
00138 
00139 /** @brief The OFX suite used to define and manipulate 'parametric' parameters.
00140 
00141 This is an optional suite.
00142 
00143 Parametric parameters are in effect 'functions' a plug-in can ask a host to arbitrarily 
00144 evaluate for some value 'x'. A classic use case would be for constructing look-up tables, 
00145 a plug-in would ask the host to evaluate one at multiple values from 0 to 1 and use that 
00146 to fill an array.
00147 
00148 A host would probably represent this to a user as a cubic curve in a standard curve editor 
00149 interface, or possibly through scripting. The user would then use this to define the 'shape'
00150 of the parameter.
00151 
00152 The evaluation of such params is not the same as animation, they are returning values based 
00153 on some arbitrary argument orthogonal to time, so to evaluate such a param, you need to pass
00154 a parametric position and time.
00155 
00156 Often, you would want such a parametric parameter to be multi-dimensional, for example, a
00157 colour look-up table might want three values, one for red, green and blue. Rather than 
00158 declare three separate parametric parameters, it would be better to have one such parameter 
00159 with multiple values in it.
00160 
00161 The major complication with these parameters is how to allow a plug-in to set values, and 
00162 defaults. The default default value of a parametric curve is to be an identity lookup. If
00163 a plugin wishes to set a different default value for a curve, it can use the suite to set
00164 key/value pairs on the \em descriptor of the param. When a new instance is made, it will
00165 have these curve values as a default.
00166 */
00167 typedef struct OfxParametricParameterSuiteV1 {
00168   
00169   /** @brief Evaluates a parametric parameter
00170  
00171       \arg param                 handle to the parametric parameter
00172       \arg curveIndex            which dimension to evaluate
00173       \arg time                  the time to evaluate to the parametric param at
00174       \arg parametricPosition    the position to evaluate the parametric param at
00175       \arg returnValue           pointer to a double where a value is returned
00176  
00177       @returns
00178         - ::kOfxStatOK            - all was fine 
00179         - ::kOfxStatErrBadHandle  - if the paramter handle was invalid
00180         - ::kOfxStatErrBadIndex   - the curve index was invalid
00181   */
00182   OfxStatus (*parametricParamGetValue)(OfxParamHandle param,
00183                                        int   curveIndex,
00184                                        OfxTime time,
00185                                        double parametricPosition,
00186                                        double *returnValue);
00187 
00188 
00189   /** @brief Returns the number of control points in the parametric param.
00190 
00191       \arg param                 handle to the parametric parameter
00192       \arg curveIndex            which dimension to check
00193       \arg time                  the time to check
00194       \arg returnValue           pointer to an integer where the value is returned.
00195       
00196       @returns
00197         - ::kOfxStatOK            - all was fine 
00198         - ::kOfxStatErrBadHandle  - if the paramter handle was invalid
00199         - ::kOfxStatErrBadIndex   - the curve index was invalid
00200    */
00201   OfxStatus (*parametricParamGetNControlPoints)(OfxParamHandle param,
00202                                                 int   curveIndex,
00203                                                 double time,
00204                                                 int *returnValue);
00205  
00206   /** @brief Returns the key/value pair of the nth control point.
00207 
00208       \arg param                 handle to the parametric parameter
00209       \arg curveIndex            which dimension to check
00210       \arg time                  the time to check
00211       \arg nthCtl                the nth control point to get the value of
00212       \arg key                   pointer to a double where the key will be returned
00213       \arg value                 pointer to a double where the value will be returned 
00214             
00215       @returns
00216         - ::kOfxStatOK            - all was fine 
00217         - ::kOfxStatErrBadHandle  - if the paramter handle was invalid
00218         - ::kOfxStatErrUnknown    - if the type is unknown
00219    */
00220   OfxStatus (*parametricParamGetNthControlPoint)(OfxParamHandle param,
00221                                                  int    curveIndex,
00222                                                  double time,
00223                                                  int    nthCtl,
00224                                                  double *key,
00225                                                  double *value);
00226  
00227   /** @brief Modifies an existing control point on a curve
00228 
00229       \arg param                 handle to the parametric parameter
00230       \arg curveIndex            which dimension to set
00231       \arg time                  the time to set the value at 
00232       \arg nthCtl                the control point to modify
00233       \arg key                   key of the control point
00234       \arg value                 value of the control point
00235       \arg addAnimationKey       if the param is an animatable, setting this to true will 
00236                                  force an animation keyframe to be set as well as a curve key,
00237                                  otherwise if false, a key will only be added if the curve is already
00238                                  animating.
00239 
00240       @returns
00241         - ::kOfxStatOK            - all was fine 
00242         - ::kOfxStatErrBadHandle  - if the paramter handle was invalid
00243         - ::kOfxStatErrUnknown    - if the type is unknown
00244 
00245       This modifies an existing control point. Note that by changing key, the order of the
00246       control point may be modified (as you may move it before or after anther point). So be
00247       careful when iterating over a curves control points and you change a key.
00248    */
00249   OfxStatus (*parametricParamSetNthControlPoint)(OfxParamHandle param,
00250                                                  int   curveIndex,
00251                                                  double time,
00252                                                  int   nthCtl,
00253                                                  double key,
00254                                                  double value,
00255                                                  bool addAnimationKey);
00256 
00257   /** @brief Adds a control point to the curve.
00258 
00259       \arg param                 handle to the parametric parameter
00260       \arg curveIndex            which dimension to set
00261       \arg time                  the time to set the value at
00262       \arg key                   key of the control point
00263       \arg value                 value of the control point
00264       \arg addAnimationKey       if the param is an animatable, setting this to true will 
00265                                  force an animation keyframe to be set as well as a curve key,
00266                                  otherwise if false, a key will only be added if the curve is already
00267                                  animating.
00268 
00269       @returns
00270         - ::kOfxStatOK            - all was fine 
00271         - ::kOfxStatErrBadHandle  - if the paramter handle was invalid
00272         - ::kOfxStatErrUnknown    - if the type is unknown
00273 
00274       This will add a new control point to the given dimension of a parametric parameter. If a key exists
00275       sufficiently close to 'key', then it will be set to the indicated control point.
00276    */
00277   OfxStatus (*parametricParamAddControlPoint)(OfxParamHandle param,
00278                                               int   curveIndex,
00279                                               double time,
00280                                               double key,
00281                                               double value,
00282                                               bool addAnimationKey);
00283   
00284   /** @brief Deletes the nth control point from a parametric param.
00285 
00286       \arg param                 handle to the parametric parameter
00287       \arg curveIndex            which dimension to delete
00288       \arg nthCtl                the control point to delete
00289    */
00290   OfxStatus (*parametricParamDeleteControlPoint)(OfxParamHandle param,
00291                                                  int   curveIndex,
00292                                                  int   nthCtl);
00293 
00294   /** @brief Delete all curve control points on the given param.
00295 
00296       \arg param                 handle to the parametric parameter
00297       \arg curveIndex            which dimension to clear
00298    */
00299   OfxStatus (*parametricParamDeleteAllControlPoints)(OfxParamHandle param,
00300                                                      int   curveIndex);
00301  } OfxParametricParameterSuiteV1;
00302 
00303 #ifdef __cplusplus
00304 }
00305 #endif
00306 
00307 
00308 
00309 
00310 #endif