TuttleOFX
1
|
00001 #ifndef _ofxsParam_H_ 00002 #define _ofxsParam_H_ 00003 00004 /* 00005 * OFX Support Library, a library that skins the OFX plug-in API with C++ classes. 00006 * Copyright (C) 2004-2005 The Open Effects Association Ltd 00007 * Author Bruno Nicoletti bruno@thefoundry.co.uk 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 * The Open Effects Association Ltd 00033 * 1 Wardour St 00034 * London W1D 6PA 00035 * England 00036 * 00037 * 00038 * 00039 */ 00040 00041 /** @file This file contains core code that wraps OFX parameters with C++ classes. 00042 * 00043 * This file only holds code that is visible to a plugin implementation, and so hides much 00044 * of the direct OFX objects and any library side only functions. 00045 * 00046 * The classes that skin parameters are broken into two sets, those used during the description phase, 00047 * eg OFX::IntParamDescriptor and those representing instances eg, OFX::IntParamInstance. The members on 00048 * each represent the actions that can be carried out on those particular OFX objects. 00049 * 00050 */ 00051 00052 #include "ofxsCore.h" 00053 #include "ofxsInteract.h" 00054 #include "ofxsUtilities.h" 00055 00056 #include <extensions/nuke/camera.h> 00057 #include <extensions/nuke/fnPublicOfxExtensions.h> 00058 00059 #include <boost/throw_exception.hpp> 00060 #include <boost/assert.hpp> 00061 00062 #include <memory> 00063 #include <iostream> 00064 00065 00066 /** @brief Nasty macro used to define empty protected copy ctors and assign ops */ 00067 #define mDeclareProtectedAssignAndCC( CLASS ) \ 00068 CLASS& operator=( const CLASS& ) { assert( false ); return *this; } \ 00069 CLASS( const CLASS & ) { assert( false ); } 00070 00071 /** @brief The core 'OFX Support' namespace, used by plugin implementations. All code for these are defined in the common support libraries. 00072 */ 00073 namespace OFX { 00074 00075 /* forward class declarations of the descriptors */ 00076 class ParamDescriptor; 00077 class ValueParamDescriptor; 00078 class IntParamDescriptor; 00079 class Int2DParamDescriptor; 00080 class Int3DParamDescriptor; 00081 class DoubleParamDescriptor; 00082 class Double2DParamDescriptor; 00083 class Double3DParamDescriptor; 00084 class StringParamDescriptor; 00085 class RGBAParamDescriptor; 00086 class RGBParamDescriptor; 00087 class BooleanParamDescriptor; 00088 class ChoiceParamDescriptor; 00089 class GroupParamDescriptor; 00090 class PageParamDescriptor; 00091 class PushButtonParamDescriptor; 00092 class CustomParamDescriptor; 00093 class ParamSetDescriptor; 00094 00095 /* forward class declarations of the instances */ 00096 class Param; 00097 class ValueParam; 00098 class IntParam; 00099 class Int2DParam; 00100 class Int3DParam; 00101 class DoubleParam; 00102 class Double2DParam; 00103 class Double3DParam; 00104 class RGBAParam; 00105 class RGBParam; 00106 class StringParam; 00107 class BooleanParam; 00108 class ChoiceParam; 00109 class CustomParam; 00110 class GroupParam; 00111 class PageParam; 00112 class PushButtonParam; 00113 class ParamSet; 00114 00115 /** @brief Enumerates the different types of parameter */ 00116 enum ParamTypeEnum 00117 { 00118 eDummyParam, 00119 eStringParam, 00120 eIntParam, 00121 eInt2DParam, 00122 eInt3DParam, 00123 eDoubleParam, 00124 eDouble2DParam, 00125 eDouble3DParam, 00126 eRGBParam, 00127 eRGBAParam, 00128 eBooleanParam, 00129 eChoiceParam, 00130 eCustomParam, 00131 eGroupParam, 00132 ePageParam, 00133 ePushButtonParam, 00134 eParametricParam, 00135 eCameraParam 00136 }; 00137 00138 /** @brief Enumerates the different types of cache invalidation */ 00139 enum CacheInvalidationEnum 00140 { 00141 eCacheInvalidateValueChange, 00142 eCacheInvalidateValueChangeToEnd, 00143 eCacheInvalidateValueAll 00144 }; 00145 00146 /** @brief Enumerates how we search for keys in an animating parameter */ 00147 enum KeySearchEnum 00148 { 00149 eKeySearchBackwards, 00150 eKeySearchNear, 00151 eKeySearchForwards 00152 }; 00153 00154 /** @brief Enumerates the differing types of string params */ 00155 enum StringTypeEnum 00156 { 00157 eStringTypeSingleLine, 00158 eStringTypeMultiLine, 00159 eStringTypeFilePath, 00160 eStringTypeDirectoryPath, 00161 eStringTypeLabel 00162 }; 00163 00164 /** @brief Enumerates the differing types of double params */ 00165 enum DoubleTypeEnum 00166 { 00167 eDoubleTypePlain, 00168 eDoubleTypeAngle, 00169 eDoubleTypeScale, 00170 eDoubleTypeTime, 00171 eDoubleTypeAbsoluteTime, 00172 eDoubleTypeNormalisedX, 00173 eDoubleTypeNormalisedY, 00174 eDoubleTypeNormalisedXAbsolute, 00175 eDoubleTypeNormalisedYAbsolute, 00176 eDoubleTypeNormalisedXY, 00177 eDoubleTypeNormalisedXYAbsolute 00178 }; 00179 00180 enum ELayoutHint 00181 { 00182 eLayoutHintNormal = kOfxParamPropLayoutHintNormal, 00183 eLayoutHintDivider = kOfxParamPropLayoutHintDivider, 00184 eLayoutHintNoNewLine = kOfxParamPropLayoutHintNoNewLine 00185 }; 00186 00187 /** @brief turns a ParamTypeEnum into the char * that raw OFX uses */ 00188 const char* mapParamTypeEnumToString( ParamTypeEnum v ); 00189 00190 //////////////////////////////////////////////////////////////////////////////// 00191 /** @brief Base class for all param descriptors */ 00192 class ParamDescriptor 00193 { 00194 protected: 00195 mDeclareProtectedAssignAndCC( ParamDescriptor ); 00196 ParamDescriptor( void ) { assert( false ); } 00197 00198 protected: 00199 std::string _paramName; 00200 ParamTypeEnum _paramType; 00201 PropertySet _paramProps; 00202 00203 /** @brief hidden constructors */ 00204 ParamDescriptor( const std::string& name, ParamTypeEnum type, OfxPropertySetHandle props ); 00205 00206 friend class ParamSetDescriptor; 00207 00208 public: 00209 /** @brief dtor */ 00210 virtual ~ParamDescriptor(); 00211 00212 inline ParamTypeEnum getType( void ) const { return _paramType; } 00213 00214 inline PropertySet& getProps() { return _paramProps; } 00215 inline const PropertySet& getProps() const { return _paramProps; } 00216 00217 /** @brief name */ 00218 inline const std::string& getName( void ) const { return _paramName; } 00219 00220 /** @brief Get the property set */ 00221 inline PropertySet& getPropertySet() { return _paramProps; } 00222 inline const PropertySet& getPropertySet() const { return _paramProps; } 00223 00224 /** @brief set the label properties in a plugin */ 00225 void setLabels( const std::string& label, const std::string& shortLabel, const std::string& longLabel ); 00226 void setLabel(const std::string &label){ setLabels(label, label, label); } 00227 00228 /** @brief set the param hint */ 00229 void setHint( const std::string& hint ); 00230 00231 /** @brief set the script name, default is the name it was created with */ 00232 void setScriptName( const std::string& hint ); 00233 00234 /** @brief set the secretness of the param, defaults to false */ 00235 void setIsSecret( bool v ); 00236 00237 /** @brief set the group param that is the parent of this one, default is to be ungrouped at the root level */ 00238 void setParent( const GroupParamDescriptor& v ); 00239 inline void setParent( const GroupParamDescriptor* v ) { setParent(*v); } 00240 00241 /** @brief whether the param is enabled, defaults to true */ 00242 void setEnabled( bool v ); 00243 00244 void setLayoutHint( const ELayoutHint layoutHint ); 00245 }; 00246 00247 //////////////////////////////////////////////////////////////////////////////// 00248 /** @brief Used to implement dummy parameters for page positioning commands */ 00249 class DummyParamDescriptor : public ParamDescriptor 00250 { 00251 public: 00252 /** @brief ctor */ 00253 DummyParamDescriptor( const std::string& name ) 00254 : ParamDescriptor( name, eDummyParam, 0 ) 00255 {} 00256 }; 00257 00258 //////////////////////////////////////////////////////////////////////////////// 00259 /** @brief Wraps up a value holding param */ 00260 class ValueParamDescriptor : public ParamDescriptor 00261 { 00262 protected: 00263 mDeclareProtectedAssignAndCC( ValueParamDescriptor ); 00264 ValueParamDescriptor( void ) { assert( false ); } 00265 00266 protected: 00267 /** @brief hidden constructor */ 00268 ValueParamDescriptor( const std::string& name, ParamTypeEnum type, OfxPropertySetHandle props ); 00269 00270 friend class ParamSetDescriptor; 00271 std::auto_ptr<ParamInteractWrap> _interact; 00272 00273 public: 00274 /** @brief dtor */ 00275 virtual ~ValueParamDescriptor(); 00276 00277 /** @brief set whether the param can animate, defaults to true in most cases */ 00278 void setAnimates( bool v ); 00279 00280 /** @brief set whether the param is persistant, defaults to true */ 00281 void setIsPersistant( bool v ); 00282 00283 /** @brief Set's whether the value of the param is significant (ie: affects the rendered image), defaults to true */ 00284 void setEvaluateOnChange( bool v ); 00285 00286 /** @brief Set's how any cache should be invalidated if the parameter is changed, defaults to eCacheInvalidateValueChange */ 00287 void setCacheInvalidation( CacheInvalidationEnum v ); 00288 00289 /// @brief Set whether the param should appear on any undo stack 00290 void setCanUndo( bool v ); 00291 00292 void setInteractDescriptor( ParamInteractWrap* desc ); 00293 }; 00294 00295 //////////////////////////////////////////////////////////////////////////////// 00296 /** @brief Wraps up a string param */ 00297 class StringParamDescriptor : public ValueParamDescriptor 00298 { 00299 protected: 00300 mDeclareProtectedAssignAndCC( StringParamDescriptor ); 00301 StringParamDescriptor( void ) { assert( false ); } 00302 00303 protected: 00304 /** @brief hidden constructor */ 00305 StringParamDescriptor( const std::string& name, OfxPropertySetHandle props ); 00306 00307 friend class ParamSetDescriptor; 00308 00309 public: 00310 /** @brief set the default value, default is 0 */ 00311 void setDefault( const std::string& v ); 00312 00313 /** @brief sets the kind of the string param, defaults to eStringSingleLine */ 00314 void setStringType( StringTypeEnum v ); 00315 00316 /** @brief if the string param is a file path, say that we are picking an existing file, rather than posibly specifying a new one, defaults to true */ 00317 void setFilePathExists( bool v ); 00318 }; 00319 00320 //////////////////////////////////////////////////////////////////////////////// 00321 /** @brief Wraps up an integer param */ 00322 class IntParamDescriptor : public ValueParamDescriptor 00323 { 00324 protected: 00325 mDeclareProtectedAssignAndCC( IntParamDescriptor ); 00326 IntParamDescriptor( void ) { assert( false ); } 00327 00328 protected: 00329 /** @brief hidden constructor */ 00330 IntParamDescriptor( const std::string& name, OfxPropertySetHandle props ); 00331 00332 friend class ParamSetDescriptor; 00333 00334 public: 00335 /** @brief set the default value, default is 0 */ 00336 void setDefault( int v ); 00337 00338 /** @brief set the hard min/max range, default is INT_MIN, INT_MAX */ 00339 void setRange( int min, int max ); 00340 00341 /** @brief set the display min and max, default is to be the same as the range param */ 00342 void setDisplayRange( int min, int max ); 00343 }; 00344 00345 //////////////////////////////////////////////////////////////////////////////// 00346 /** @brief Wraps up an 2d integer param */ 00347 class Int2DParamDescriptor : public ValueParamDescriptor 00348 { 00349 protected: 00350 mDeclareProtectedAssignAndCC( Int2DParamDescriptor ); 00351 Int2DParamDescriptor( void ) { assert( false ); } 00352 00353 protected: 00354 /** @brief hidden constructor */ 00355 Int2DParamDescriptor( const std::string& name, OfxPropertySetHandle props ); 00356 00357 friend class ParamSetDescriptor; 00358 00359 public: 00360 /** @brief set the dimension labels */ 00361 void setDimensionLabels( const std::string& x, 00362 const std::string& y ); 00363 00364 /** @brief set the default value, default is 0 */ 00365 void setDefault( int x, int y ); 00366 00367 /** @brief set the hard min/max range, default is INT_MIN, INT_MAX */ 00368 void setRange( int minX, int minY, 00369 int maxX, int maxY ); 00370 00371 /** @brief set the display min and max, default is to be the same as the range param */ 00372 void setDisplayRange( int minX, int minY, 00373 int maxX, int maxY ); 00374 }; 00375 00376 //////////////////////////////////////////////////////////////////////////////// 00377 /** @brief Wraps up an 3d integer param */ 00378 class Int3DParamDescriptor : public ValueParamDescriptor 00379 { 00380 protected: 00381 mDeclareProtectedAssignAndCC( Int3DParamDescriptor ); 00382 Int3DParamDescriptor( void ) { assert( false ); } 00383 00384 protected: 00385 /** @brief hidden constructor */ 00386 Int3DParamDescriptor( const std::string& name, OfxPropertySetHandle props ); 00387 00388 friend class ParamSetDescriptor; 00389 00390 public: 00391 /** @brief set the dimension labels */ 00392 void setDimensionLabels( const std::string& x, 00393 const std::string& y, 00394 const std::string& z ); 00395 00396 /** @brief set the default value, default is 0 */ 00397 void setDefault( int x, int y, int z ); 00398 00399 /** @brief set the hard min/max range, default is INT_MIN, INT_MAX */ 00400 void setRange( int minX, int minY, int minZ, 00401 int maxX, int maxY, int maxZ ); 00402 00403 /** @brief set the display min and max, default is to be the same as the range param */ 00404 void setDisplayRange( int minX, int minY, int minZ, 00405 int maxX, int maxY, int maxZ ); 00406 }; 00407 00408 //////////////////////////////////////////////////////////////////////////////// 00409 /** @brief Common base to all double param types */ 00410 class BaseDoubleParamDescriptor : public ValueParamDescriptor 00411 { 00412 protected: 00413 mDeclareProtectedAssignAndCC( BaseDoubleParamDescriptor ); 00414 BaseDoubleParamDescriptor( void ) { assert( false ); } 00415 00416 protected: 00417 /** @brief hidden constructor */ 00418 BaseDoubleParamDescriptor( const std::string& name, ParamTypeEnum type, OfxPropertySetHandle props ); 00419 00420 friend class ParamSetDescriptor; 00421 00422 public: 00423 /** @brief set the type of the double param, defaults to eDoubleTypePlain */ 00424 void setDoubleType( DoubleTypeEnum v ); 00425 00426 /** @brief set the sensitivity of any gui slider */ 00427 void setIncrement( double v ); 00428 00429 /** @brief set the number of digits printed after a decimal point in any gui */ 00430 void setDigits( int v ); 00431 }; 00432 00433 //////////////////////////////////////////////////////////////////////////////// 00434 /** @brief Wraps up a double param */ 00435 class DoubleParamDescriptor : public BaseDoubleParamDescriptor 00436 { 00437 protected: 00438 mDeclareProtectedAssignAndCC( DoubleParamDescriptor ); 00439 DoubleParamDescriptor( void ) { assert( false ); } 00440 00441 protected: 00442 /** @brief hidden constructor */ 00443 DoubleParamDescriptor( const std::string& name, OfxPropertySetHandle props ); 00444 00445 friend class ParamSetDescriptor; 00446 00447 public: 00448 /** @brief if the double type is Absolute time, show a time marker on the time line if possible */ 00449 void setShowTimeMarker( bool v ); 00450 00451 /** @brief set the default value, default is 0 */ 00452 void setDefault( double v ); 00453 00454 /** @brief set the hard min/max range, default is INT_MIN, INT_MAX */ 00455 void setRange( double min, double max ); 00456 00457 /** @brief set the display min and max, default is to be the same as the range param */ 00458 void setDisplayRange( double min, double max ); 00459 }; 00460 00461 //////////////////////////////////////////////////////////////////////////////// 00462 /** @brief Wraps up a 2D double param */ 00463 class Double2DParamDescriptor : public BaseDoubleParamDescriptor 00464 { 00465 protected: 00466 mDeclareProtectedAssignAndCC( Double2DParamDescriptor ); 00467 Double2DParamDescriptor( void ) { assert( false ); } 00468 00469 protected: 00470 /** @brief hidden constructor */ 00471 Double2DParamDescriptor( const std::string& name, OfxPropertySetHandle props ); 00472 00473 friend class ParamSetDescriptor; 00474 00475 public: 00476 /** @brief set the dimension labels */ 00477 void setDimensionLabels( const std::string& x, 00478 const std::string& y ); 00479 00480 /** @brief set the default value, default is 0 */ 00481 void setDefault( double x, double y ); 00482 00483 /** @brief set the hard min/max range, default is INT_MIN, INT_MAX */ 00484 void setRange( double minX, double minY, 00485 double maxX, double maxY ); 00486 00487 /** @brief set the display min and max, default is to be the same as the range param */ 00488 void setDisplayRange( double minX, double minY, 00489 double maxX, double maxY ); 00490 }; 00491 00492 //////////////////////////////////////////////////////////////////////////////// 00493 /** @brief Wraps up a 3D double param */ 00494 class Double3DParamDescriptor : public BaseDoubleParamDescriptor 00495 { 00496 protected: 00497 mDeclareProtectedAssignAndCC( Double3DParamDescriptor ); 00498 Double3DParamDescriptor( void ) { assert( false ); } 00499 00500 protected: 00501 /** @brief hidden constructor */ 00502 Double3DParamDescriptor( const std::string& name, OfxPropertySetHandle props ); 00503 00504 friend class ParamSetDescriptor; 00505 00506 public: 00507 /** @brief set the dimension labels */ 00508 void setDimensionLabels( const std::string& x, 00509 const std::string& y, 00510 const std::string& z ); 00511 00512 /** @brief set the default value, default is 0 */ 00513 void setDefault( double x, double y, double z ); 00514 00515 /** @brief set the hard min/max range, default is INT_MIN, INT_MAX */ 00516 void setRange( double minX, double minY, double minZ, 00517 double maxX, double maxY, double maxZ ); 00518 00519 /** @brief set the display min and max, default is to be the same as the range param */ 00520 void setDisplayRange( double minX, double minY, double minZ, 00521 double maxX, double maxY, double maxZ ); 00522 }; 00523 00524 //////////////////////////////////////////////////////////////////////////////// 00525 /** @brief Wraps up an RGB colour param */ 00526 class RGBParamDescriptor : public ValueParamDescriptor 00527 { 00528 protected: 00529 mDeclareProtectedAssignAndCC( RGBParamDescriptor ); 00530 RGBParamDescriptor( void ) { assert( false ); } 00531 00532 protected: 00533 /** @brief hidden constructor */ 00534 RGBParamDescriptor( const std::string& name, OfxPropertySetHandle props ); 00535 00536 // so it can make one 00537 friend class ParamSetDescriptor; 00538 00539 public: 00540 /** @brief set the default value */ 00541 void setDefault( double r, double g, double b ); 00542 }; 00543 00544 //////////////////////////////////////////////////////////////////////////////// 00545 /** @brief Wraps up an RGBA colour param */ 00546 class RGBAParamDescriptor : public ValueParamDescriptor 00547 { 00548 protected: 00549 mDeclareProtectedAssignAndCC( RGBAParamDescriptor ); 00550 RGBAParamDescriptor( void ) { assert( false ); } 00551 00552 protected: 00553 /** @brief hidden constructor */ 00554 RGBAParamDescriptor( const std::string& name, OfxPropertySetHandle props ); 00555 00556 // so it can make one 00557 friend class ParamSetDescriptor; 00558 00559 public: 00560 /** @brief set the default value */ 00561 void setDefault( double r, double g, double b, double a ); 00562 }; 00563 00564 //////////////////////////////////////////////////////////////////////////////// 00565 /** @brief Wraps up a boolean param */ 00566 class BooleanParamDescriptor : public ValueParamDescriptor 00567 { 00568 protected: 00569 mDeclareProtectedAssignAndCC( BooleanParamDescriptor ); 00570 BooleanParamDescriptor( void ) { assert( false ); } 00571 00572 protected: 00573 /** @brief hidden constructor */ 00574 BooleanParamDescriptor( const std::string& name, OfxPropertySetHandle props ); 00575 00576 // so it can make one 00577 friend class ParamSetDescriptor; 00578 00579 public: 00580 /** @brief set the default value */ 00581 void setDefault( bool v ); 00582 }; 00583 00584 //////////////////////////////////////////////////////////////////////////////// 00585 /** @brief Wraps up a choice param */ 00586 class ChoiceParamDescriptor : public ValueParamDescriptor 00587 { 00588 protected: 00589 mDeclareProtectedAssignAndCC( ChoiceParamDescriptor ); 00590 ChoiceParamDescriptor( void ) { assert( false ); } 00591 00592 protected: 00593 /** @brief hidden constructor */ 00594 ChoiceParamDescriptor( const std::string& name, OfxPropertySetHandle props ); 00595 00596 // so it can make one 00597 friend class ParamSetDescriptor; 00598 00599 public: 00600 /** @brief set the default value */ 00601 void setDefault( int v ); 00602 00603 /** @brief append an option, default is to have not there */ 00604 void appendOption( const std::string& scriptName, const std::string& label = "" ); 00605 00606 /** @brief how many options do we have */ 00607 int getNOptions( void ) const; 00608 00609 /** @brief clear all the options so as to add some new ones in */ 00610 void resetOptions( void ); 00611 }; 00612 00613 //////////////////////////////////////////////////////////////////////////////// 00614 /** @brief Wraps up a group param, not much to it really */ 00615 class GroupParamDescriptor : public ParamDescriptor 00616 { 00617 protected: 00618 mDeclareProtectedAssignAndCC( GroupParamDescriptor ); 00619 GroupParamDescriptor( void ) { assert( false ); } 00620 00621 protected: 00622 /** @brief hidden constructor */ 00623 GroupParamDescriptor( const std::string& name, OfxPropertySetHandle props ); 00624 00625 // so it can make one 00626 friend class ParamSetDescriptor; 00627 00628 public: 00629 void setOpen( const bool open = true ); 00630 00631 void setAsTab(); 00632 }; 00633 00634 //////////////////////////////////////////////////////////////////////////////// 00635 /** @brief Wraps up a page param, not much to it really */ 00636 class PageParamDescriptor : public ParamDescriptor 00637 { 00638 protected: 00639 mDeclareProtectedAssignAndCC( PageParamDescriptor ); 00640 PageParamDescriptor( void ) { assert( false ); } 00641 00642 protected: 00643 /** @brief hidden constructor */ 00644 PageParamDescriptor( const std::string& name, OfxPropertySetHandle props ); 00645 00646 // so it can make one 00647 friend class ParamSetDescriptor; 00648 00649 public: 00650 /** @brief adds a child parameter. Note the two existing pseudo params, gColumnSkip and gRowSkip */ 00651 void addChild( const ParamDescriptor& p ); 00652 00653 /** @brief dummy page positioning parameter to be passed to @ref OFX::PageParamDescriptor::addChild */ 00654 static DummyParamDescriptor gSkipRow; 00655 00656 /** @brief dummy page positioning parameter to be passed to @ref OFX::PageParamDescriptor::addChild */ 00657 static DummyParamDescriptor gSkipColumn; 00658 }; 00659 00660 //////////////////////////////////////////////////////////////////////////////// 00661 /** @brief Wraps up a push button param, not much to it at all */ 00662 class PushButtonParamDescriptor : public ParamDescriptor 00663 { 00664 protected: 00665 mDeclareProtectedAssignAndCC( PushButtonParamDescriptor ); 00666 PushButtonParamDescriptor( void ) { assert( false ); } 00667 00668 protected: 00669 /** @brief hidden constructor */ 00670 PushButtonParamDescriptor( const std::string& name, OfxPropertySetHandle props ); 00671 00672 // so it can make one 00673 friend class ParamSetDescriptor; 00674 00675 public: 00676 }; 00677 00678 //////////////////////////////////////////////////////////////////////////////// 00679 /** @brief Wraps up a push button param, not much to it at all */ 00680 class ParametricParamDescriptor : public ParamDescriptor 00681 { 00682 protected: 00683 mDeclareProtectedAssignAndCC( ParametricParamDescriptor ); 00684 ParametricParamDescriptor( void ) { assert( false ); } 00685 00686 protected: 00687 /** @brief hidden constructor */ 00688 ParametricParamDescriptor( const std::string& name, OfxPropertySetHandle props ); 00689 00690 OfxParamHandle _ofxParamHandle; 00691 ParamSetDescriptor* _paramSet; 00692 std::auto_ptr<ParamInteractWrap> _interact; 00693 00694 // so it can make one 00695 friend class ParamSetDescriptor; 00696 void setParamSet( ParamSetDescriptor& paramSet ); 00697 00698 public: 00699 void setDimension( const int dimension ); 00700 00701 void setRange( const double min, const double max ); 00702 00703 void setLabel( const std::string& label ); 00704 00705 void setDimensionLabel( const std::string& label, const int id ); 00706 00707 void setUIColour( const int id, const OfxRGBColourD& color ); 00708 00709 void addControlPoint( const int id, const OfxTime time, const double x, const double y, const bool addKey ); 00710 00711 void setIdentity( const int id ); 00712 00713 void setIdentity(); 00714 00715 void setInteractDescriptor( ParamInteractWrap* desc ); 00716 00717 }; 00718 00719 //////////////////////////////////////////////////////////////////////////////// 00720 /** @brief Wraps up a custom param, haven't added animation support yet */ 00721 class CustomParamDescriptor : public ValueParamDescriptor 00722 { 00723 protected: 00724 mDeclareProtectedAssignAndCC( CustomParamDescriptor ); 00725 CustomParamDescriptor( void ) { assert( false ); } 00726 00727 protected: 00728 /** @brief hidden constructor */ 00729 CustomParamDescriptor( const std::string& name, OfxPropertySetHandle props ); 00730 00731 // so it can make one 00732 friend class ParamSetDescriptor; 00733 00734 public: 00735 /** @brief set the default value of the param */ 00736 void setDefault( const std::string& v ); 00737 }; 00738 00739 //////////////////////////////////////////////////////////////////////////////// 00740 /** @brief Describes a set of properties */ 00741 class ParamSetDescriptor 00742 { 00743 protected: 00744 mDeclareProtectedAssignAndCC( ParamSetDescriptor ); 00745 00746 /** @brief calls the raw OFX routine to define a param */ 00747 void defineRawParam( const std::string& name, ParamTypeEnum paramType, OfxPropertySetHandle& props ); 00748 00749 /** @brief Define a param descriptor of the given type */ 00750 template <class T> 00751 bool defineParamDescriptor( const std::string& name, ParamTypeEnum paramType, T*& paramPtr ) 00752 { 00753 paramPtr = NULL; 00754 // have we made it already in this param set and is it of the correct type 00755 if( ParamDescriptor * param = findPreviouslyDefinedParam( name ) ) 00756 { 00757 if( param->getType() == paramType ) 00758 { 00759 #ifdef _DEBUG 00760 OFXS_COUT_WARNING( "Parameter already defined ! (" + name + ")" ); 00761 #endif 00762 paramPtr = (T*) param; // could be a dynamic cast here 00763 return true; 00764 } 00765 else 00766 { 00767 BOOST_THROW_EXCEPTION( OFX::Exception::Suite( kOfxStatErrExists, "Parameter already defined with another type ! (" + name + ")" ) ); 00768 return false; 00769 } 00770 } 00771 else 00772 { 00773 // ok define one and add it in 00774 OfxPropertySetHandle props; 00775 defineRawParam( name, paramType, props ); 00776 00777 // make out support descriptor class 00778 paramPtr = new T( name, props ); 00779 00780 // add it to our map of described ones 00781 _definedParams[name] = paramPtr; 00782 } 00783 return true; 00784 } 00785 00786 protected: 00787 /** @brief Properties that belong to this param set */ 00788 PropertySet _paramSetProps; 00789 00790 /** @brief Parameter set handle */ 00791 OfxParamSetHandle _paramSetHandle; 00792 00793 /** @brief Set of all previously defined parameters, defined on demand */ 00794 std::map<std::string, ParamDescriptor*> _definedParams; 00795 00796 /** @brief Hidden ctor */ 00797 ParamSetDescriptor( void ); 00798 00799 /** @brief find a param in the map */ 00800 ParamDescriptor* findPreviouslyDefinedParam( const std::string& name ); 00801 00802 /** @brief set the param set handle */ 00803 void setOfxParamSetHandle( OfxParamSetHandle h ); 00804 00805 public: 00806 00807 OfxParamSetHandle getOfxParamSetHandle() 00808 { 00809 return _paramSetHandle; 00810 } 00811 00812 virtual ~ParamSetDescriptor(); 00813 /** @brief tries to fetch a ParamDescriptor, returns 0 if it isn't there*/ 00814 ParamDescriptor* getParamDescriptor( const std::string& name ) const; 00815 00816 /** @brief estabilishes the order of page params. Do it by calling it in turn for each page */ 00817 void setPageParamOrder( PageParamDescriptor& p ); 00818 00819 /** @brief Define an integer param */ 00820 IntParamDescriptor* defineIntParam( const std::string& name ); 00821 00822 /** @brief Define a 2D integer param */ 00823 Int2DParamDescriptor* defineInt2DParam( const std::string& name ); 00824 00825 /** @brief Define a 3D integer param */ 00826 Int3DParamDescriptor* defineInt3DParam( const std::string& name ); 00827 00828 /** @brief Define an double param */ 00829 DoubleParamDescriptor* defineDoubleParam( const std::string& name ); 00830 00831 /** @brief Define a 2D double param */ 00832 Double2DParamDescriptor* defineDouble2DParam( const std::string& name ); 00833 00834 /** @brief Define a 3D double param */ 00835 Double3DParamDescriptor* defineDouble3DParam( const std::string& name ); 00836 00837 /** @brief Define a string param */ 00838 StringParamDescriptor* defineStringParam( const std::string& name ); 00839 00840 /** @brief Define a RGBA param */ 00841 RGBAParamDescriptor* defineRGBAParam( const std::string& name ); 00842 00843 /** @brief Define an RGB param */ 00844 RGBParamDescriptor* defineRGBParam( const std::string& name ); 00845 00846 /** @brief Define a Boolean param */ 00847 BooleanParamDescriptor* defineBooleanParam( const std::string& name ); 00848 00849 /** @brief Define a Choice param */ 00850 ChoiceParamDescriptor* defineChoiceParam( const std::string& name ); 00851 00852 /** @brief Define a group param */ 00853 GroupParamDescriptor* defineGroupParam( const std::string& name ); 00854 00855 /** @brief Define a Page param */ 00856 PageParamDescriptor* definePageParam( const std::string& name ); 00857 00858 /** @brief Define a push button param */ 00859 PushButtonParamDescriptor* definePushButtonParam( const std::string& name ); 00860 00861 /** @brief Define a parametric param */ 00862 ParametricParamDescriptor* defineParametricParam( const std::string& name ); 00863 00864 /** @brief Define a custom param */ 00865 CustomParamDescriptor* defineCustomParam( const std::string& name ); 00866 }; 00867 00868 //////////////////////////////////////////////////////////////////////////////// 00869 class Attribute 00870 { 00871 private: 00872 Attribute( const Attribute& v ) { assert( false ); } 00873 Attribute& operator=( const Attribute& ) { assert( false ); return *this; } 00874 protected: 00875 Attribute() { assert( false ); } 00876 00877 public: 00878 Attribute( const std::string& name ) 00879 : _name(name) 00880 {} 00881 00882 /** @brief get name */ 00883 inline const std::string& getName() const { return _name; } 00884 00885 inline PropertySet& getProps() { return _props; } 00886 inline const PropertySet& getProps() const { return _props; } 00887 00888 protected: 00889 std::string _name; 00890 PropertySet _props; 00891 }; 00892 00893 /** @brief Base class for all param instances */ 00894 class Param : public Attribute 00895 { 00896 private: 00897 // don't ever use these! 00898 Param& operator=( const Param& ) { assert( false ); return *this; } 00899 Param( const Param& v ) : _paramSet( v._paramSet ) { assert( false ); } 00900 protected: 00901 Param() { assert( false ); } 00902 00903 protected: 00904 ParamTypeEnum _paramType; 00905 OfxParamHandle _paramHandle; 00906 const ParamSet* _paramSet; // who do I belong to 00907 00908 /** @brief hidden constructor */ 00909 Param( const ParamSet* paramSet, const std::string& name, ParamTypeEnum type, OfxParamHandle handle ); 00910 00911 friend class ParamSet; 00912 00913 OfxParamHandle getOfxHandle() { return _paramHandle; } 00914 00915 public: 00916 /** @brief dtor */ 00917 virtual ~Param() = 0; 00918 00919 /** @brief, set the label properties in a plugin */ 00920 void setLabels( const std::string& label, const std::string& shortLabel, const std::string& longLabel ); 00921 00922 /** @brief return the derived type of this parameter */ 00923 ParamTypeEnum getParamType() const { return _paramType; } 00924 00925 /** @brief set the secretness of the param, defaults to false */ 00926 void setIsSecret( bool v ); 00927 00928 /** @brief set the param hint */ 00929 void setHint( const std::string& hint ); 00930 00931 /** @brief whether the param is enabled */ 00932 void setEnabled( bool v ); 00933 00934 void setIsSecretAndDisabled( bool v ) { setEnabled(!v); setIsSecret(v); } 00935 00936 /** @brief fetch the labels */ 00937 void getLabels( std::string& label, std::string& shortLabel, std::string& longLabel ) const; 00938 00939 /** @brief get whether the param is secret */ 00940 bool getIsSecret( void ) const; 00941 00942 /** @brief whether the param is enabled */ 00943 bool getIsEnable( void ) const; 00944 00945 /** @brief get the param hint */ 00946 std::string getHint( void ) const; 00947 00948 /** @brief get the script name */ 00949 std::string getScriptName( void ) const; 00950 00951 /** @brief get the group param that is the parent of this one */ 00952 const GroupParam* getParent( void ) const; 00953 }; 00954 00955 //////////////////////////////////////////////////////////////////////////////// 00956 /** @brief Wraps up a value holding param */ 00957 class ValueParam : public Param 00958 { 00959 protected: 00960 mDeclareProtectedAssignAndCC( ValueParam ); 00961 ValueParam( void ) { assert( false ); } 00962 00963 protected: 00964 /** @brief hidden constructor */ 00965 ValueParam( const ParamSet* paramSet, const std::string& name, ParamTypeEnum type, OfxParamHandle handle ); 00966 00967 friend class ParamSet; 00968 00969 public: 00970 /** @brief dtor */ 00971 virtual ~ValueParam() = 0; 00972 00973 /** @brief Set's whether the value of the param is significant (ie: affects the rendered image) */ 00974 void setEvaluateOnChange( bool v ); 00975 00976 /** @brief is the param animating */ 00977 bool getIsAnimating( void ) const; 00978 00979 /** @brief is the param animating */ 00980 bool getIsAutoKeying( void ) const; 00981 00982 /** @brief is the param animating */ 00983 bool getIsPersistant( void ) const; 00984 00985 /** @brief Get's whether the value of the param is significant (ie: affects the rendered image) */ 00986 bool getEvaluateOnChange( void ) const; 00987 00988 /** @brief Get's whether the value of the param is significant (ie: affects the rendered image) */ 00989 CacheInvalidationEnum getCacheInvalidation( void ) const; 00990 00991 /** @brief if the param is animating, the number of keys in it, otherwise 0 */ 00992 unsigned int getNumKeys( void ) const; 00993 00994 /** @brief get the time of the nth key, nth must be between 0 and getNumKeys-1 */ 00995 double getKeyTime( int nthKey ) const; 00996 00997 /** @brief find the index of a key by a time */ 00998 int getKeyIndex( double time, 00999 KeySearchEnum searchDir ) const; 01000 01001 /** @brief deletes a key at the given time */ 01002 void deleteKeyAtTime( double time ); 01003 01004 /** @brief delete all the keys */ 01005 void deleteAllKeys( void ); 01006 }; 01007 01008 //////////////////////////////////////////////////////////////////////////////// 01009 /** @brief Wraps up an integer param */ 01010 class IntParam : public ValueParam 01011 { 01012 private: 01013 mDeclareProtectedAssignAndCC( IntParam ); 01014 IntParam( void ) { assert( false ); } 01015 01016 protected: 01017 /** @brief hidden constructor */ 01018 IntParam( const ParamSet* paramSet, const std::string& name, OfxParamHandle handle ); 01019 01020 friend class ParamSet; 01021 01022 public: 01023 /** @brief set the default value */ 01024 void setDefault( int v ); 01025 01026 /** @brief set the hard min/max range, default is INT_MIN, INT_MAX */ 01027 void setRange( int min, int max ); 01028 01029 /** @brief set the display min and max, default is to be the same as the range param */ 01030 void setDisplayRange( int min, int max ); 01031 01032 /** @brief het the default value */ 01033 void getDefault( int& v ) const; 01034 01035 /** @brief het the default value */ 01036 int getDefault( void ) const { int v; getDefault( v ); return v; } 01037 01038 /** @brief set the hard min/max range, default is INT_MIN, INT_MAX */ 01039 void getRange( int& min, int& max ) const; 01040 01041 /** @brief set the display min and max, default is to be the same as the range param */ 01042 void getDisplayRange( int& min, int& max ) const; 01043 01044 /** @brief get value */ 01045 void getValue( int& v ) const; 01046 01047 /** @brief and a nicer one */ 01048 int getValue( void ) const { int v; getValue( v ); return v; } 01049 01050 /** @brief get the value at a time */ 01051 void getValueAtTime( double t, int& v ) const; 01052 01053 /** @brief and a nicer one */ 01054 int getValueAtTime( double t ) const { int v; getValueAtTime( t, v ); return v; } 01055 01056 /** @brief set value */ 01057 void setValue( int v ); 01058 01059 /** @brief set the value at a time, implicitly adds a keyframe */ 01060 void setValueAtTime( double t, int v ); 01061 }; 01062 01063 //////////////////////////////////////////////////////////////////////////////// 01064 /** @brief Wraps up an integer param */ 01065 class Int2DParam : public ValueParam 01066 { 01067 private: 01068 mDeclareProtectedAssignAndCC( Int2DParam ); 01069 Int2DParam( void ) { assert( false ); } 01070 01071 protected: 01072 /** @brief hidden constructor */ 01073 Int2DParam( const ParamSet* paramSet, const std::string& name, OfxParamHandle handle ); 01074 01075 friend class ParamSet; 01076 01077 public: 01078 /** @brief set the default value, default is 0 */ 01079 void setDefault( int x, int y ); 01080 01081 /** @brief set the default value, default is 0 */ 01082 void setDefault( const OfxPointI& v ) { setDefault( v.x, v.y ); } 01083 01084 /** @brief set the hard min/max range, default is INT_MIN, INT_MAX */ 01085 void setRange( int minX, int minY, 01086 int maxX, int maxY ); 01087 01088 /** @brief set the display min and max, default is to be the same as the range param */ 01089 void setDisplayRange( int minX, int minY, 01090 int maxX, int maxY ); 01091 01092 /** @brief het the default value */ 01093 void getDefault( int& x, int& y ) const; 01094 01095 /** @brief get the default value */ 01096 OfxPointI getDefault( void ) const { OfxPointI v; getDefault( v.x, v.y ); return v; } 01097 01098 /** @brief set the hard min/max range, default is INT_MIN, INT_MAX */ 01099 void getRange( int& minX, int& minY, 01100 int& maxX, int& maxY ) const; 01101 01102 /** @brief set the display min and max, default is to be the same as the range param */ 01103 void getDisplayRange( int& minX, int& minY, 01104 int& maxX, int& maxY ) const; 01105 01106 /** @brief get value */ 01107 void getValue( int& x, int& y ) const; 01108 01109 /** @brief get the value */ 01110 OfxPointI getValue( void ) const { OfxPointI v; getValue( v.x, v.y ); return v; } 01111 01112 /** @brief get the value at a time */ 01113 void getValueAtTime( double t, int& x, int& y ) const; 01114 01115 /** @brief get the value */ 01116 OfxPointI getValueAtTime( double t ) const { OfxPointI v; getValueAtTime( t, v.x, v.y ); return v; } 01117 01118 /** @brief set value */ 01119 void setValue( int x, int y ); 01120 01121 /** @brief set the current value */ 01122 void setValue( const OfxPointI& v ) { setValue( v.x, v.y ); } 01123 01124 /** @brief set the value at a time, implicitly adds a keyframe */ 01125 void setValueAtTime( double t, int x, int y ); 01126 01127 /** @brief set the current value */ 01128 void setValueAtTime( double t, const OfxPointI& v ) { setValueAtTime( t, v.x, v.y ); } 01129 }; 01130 01131 //////////////////////////////////////////////////////////////////////////////// 01132 /** @brief Wraps up an integer param */ 01133 class Int3DParam : public ValueParam 01134 { 01135 private: 01136 mDeclareProtectedAssignAndCC( Int3DParam ); 01137 Int3DParam( void ) { assert( false ); } 01138 01139 protected: 01140 /** @brief hidden constructor */ 01141 Int3DParam( const ParamSet* paramSet, const std::string& name, OfxParamHandle handle ); 01142 01143 friend class ParamSet; 01144 01145 public: 01146 /** @brief set the default value, default is 0 */ 01147 void setDefault( int x, int y, int z ); 01148 01149 /** @brief set the hard min/max range, default is INT_MIN, INT_MAX */ 01150 void setRange( int minX, int minY, int minZ, 01151 int maxX, int maxY, int maxZ ); 01152 01153 /** @brief set the display min and max, default is to be the same as the range param */ 01154 void setDisplayRange( int minX, int minY, int minZ, 01155 int maxX, int maxY, int maxZ ); 01156 01157 /** @brief het the default value */ 01158 void getDefault( int& x, int& y, int& z ) const; 01159 01160 /** @brief set the hard min/max range, default is INT_MIN, INT_MAX */ 01161 void getRange( int& minX, int& minY, int& minZ, 01162 int& maxX, int& maxY, int& maxZ ) const; 01163 01164 /** @brief set the display min and max, default is to be the same as the range param */ 01165 void getDisplayRange( int& minX, int& minY, int& minZ, 01166 int& maxX, int& maxY, int& maxZ ) const; 01167 01168 /** @brief get value */ 01169 void getValue( int& x, int& y, int& z ) const; 01170 01171 /** @brief get the value at a time */ 01172 void getValueAtTime( double t, int& x, int& y, int& z ) const; 01173 01174 /** @brief set value */ 01175 void setValue( int x, int y, int z ); 01176 01177 /** @brief set the value at a time, implicitly adds a keyframe */ 01178 void setValueAtTime( double t, int x, int y, int z ); 01179 }; 01180 01181 //////////////////////////////////////////////////////////////////////////////// 01182 /** @brief Common base to all double param types */ 01183 class BaseDoubleParam : public ValueParam 01184 { 01185 protected: 01186 mDeclareProtectedAssignAndCC( BaseDoubleParam ); 01187 BaseDoubleParam( void ) { assert( false ); } 01188 01189 protected: 01190 /** @brief hidden constructor */ 01191 BaseDoubleParam( const ParamSet* paramSet, const std::string& name, ParamTypeEnum type, OfxParamHandle handle ); 01192 01193 friend class ParamSet; 01194 01195 public: 01196 virtual ~BaseDoubleParam() = 0; 01197 01198 /** @brief set the sensitivity of any gui slider */ 01199 void setIncrement( double v ); 01200 01201 /** @brief set the number of digits printed after a decimal point in any gui */ 01202 void setDigits( int v ); 01203 01204 /** @brief get the sensitivity of any gui slider */ 01205 void getIncrement( double& v ) const; 01206 01207 /** @brief get the number of digits printed after a decimal point in any gui */ 01208 void getDigits( int& v ) const; 01209 01210 /** @brief get the type of the double param */ 01211 void getDoubleType( DoubleTypeEnum& v ) const; 01212 }; 01213 01214 //////////////////////////////////////////////////////////////////////////////// 01215 /** @brief Wraps up an doubleeger param */ 01216 class DoubleParam : public BaseDoubleParam 01217 { 01218 private: 01219 mDeclareProtectedAssignAndCC( DoubleParam ); 01220 DoubleParam( void ) { assert( false ); } 01221 01222 protected: 01223 /** @brief hidden constructor */ 01224 DoubleParam( const ParamSet* paramSet, const std::string& name, OfxParamHandle handle ); 01225 01226 friend class ParamSet; 01227 01228 public: 01229 /** @brief set the default value */ 01230 void setDefault( double v ); 01231 01232 /** @brief if the double type is Absolute time, show a time marker on the time line if possible */ 01233 void setShowTimeMarker( bool v ); 01234 01235 /** @brief set the hard min/max range, default is DOUBLE_MIN, DOUBLE_MAX */ 01236 void setRange( double min, double max ); 01237 01238 /** @brief set the display min and max, default is to be the same as the range param */ 01239 void setDisplayRange( double min, double max ); 01240 01241 /** @brief het the default value */ 01242 void getDefault( double& v ) const; 01243 01244 /** @brief het the default value */ 01245 double getDefault( void ) const { double v; getDefault( v ); return v; } 01246 01247 /** @brief set the hard min/max range, default is DOUBLE_MIN, DOUBLE_MAX */ 01248 void getRange( double& min, double& max ) const; 01249 01250 /** @brief set the display min and max, default is to be the same as the range param */ 01251 void getDisplayRange( double& min, double& max ) const; 01252 01253 /** @brief get value */ 01254 void getValue( double& v ) const; 01255 01256 /** @brief get value */ 01257 double getValue( void ) const { double v; getValue( v ); return v; } 01258 01259 /** @brief get the value at a time */ 01260 void getValueAtTime( double t, double& v ) const; 01261 01262 /** @brief get value */ 01263 double getValueAtTime( double t ) const { double v; getValueAtTime( t, v ); return v; } 01264 01265 /** @brief set value */ 01266 void setValue( double v ); 01267 01268 /** @brief set the value at a time, implicitly adds a keyframe */ 01269 void setValueAtTime( double t, double v ); 01270 01271 /** @brief differentiate the param */ 01272 void differentiate( double t, double& v ) const; 01273 01274 /** @brief differentiate the param */ 01275 double differentiate( double t ) const { double v; differentiate( t, v ); return v; } 01276 01277 /** @brief integrate the param */ 01278 void integrate( double t1, double t2, double& v ) const; 01279 01280 /** @brief integrate the param */ 01281 double integrate( double t1, double t2 ) const { double v; integrate( t1, t2, v ); return v; } 01282 }; 01283 01284 //////////////////////////////////////////////////////////////////////////////// 01285 /** @brief Wraps up an doubleeger param */ 01286 class Double2DParam : public BaseDoubleParam 01287 { 01288 private: 01289 mDeclareProtectedAssignAndCC( Double2DParam ); 01290 Double2DParam( void ) { assert( false ); } 01291 01292 protected: 01293 /** @brief hidden constructor */ 01294 Double2DParam( const ParamSet* paramSet, const std::string& name, OfxParamHandle handle ); 01295 01296 friend class ParamSet; 01297 01298 public: 01299 /** @brief set the default value, default is 0 */ 01300 void setDefault( double x, double y ); 01301 01302 /** @brief set the hard min/max range, default is DOUBLE_MIN, DOUBLE_MAX */ 01303 void setRange( double minX, double minY, 01304 double maxX, double maxY ); 01305 01306 /** @brief set the display min and max, default is to be the same as the range param */ 01307 void setDisplayRange( double minX, double minY, 01308 double maxX, double maxY ); 01309 01310 /** @brief get the default value */ 01311 void getDefault( double& x, double& y ) const; 01312 01313 /** @brief get the default value */ 01314 inline OfxPointD getDefault() const { OfxPointD v; getDefault( v.x, v.y ); return v; } 01315 01316 /** @brief set the hard min/max range, default is DOUBLE_MIN, DOUBLE_MAX */ 01317 void getRange( double& minX, double& minY, 01318 double& maxX, double& maxY ) const; 01319 01320 /** @brief set the display min and max, default is to be the same as the range param */ 01321 void getDisplayRange( double& minX, double& minY, 01322 double& maxX, double& maxY ) const; 01323 01324 /** @brief get value */ 01325 void getValue( double& x, double& y ) const; 01326 01327 /** @brief get value */ 01328 inline OfxPointD getValue() const { OfxPointD v; getValue( v.x, v.y ); return v; } 01329 01330 /** @brief get the value at a time */ 01331 void getValueAtTime( double t, double& x, double& y ) const; 01332 01333 /** @brief set value */ 01334 void setValue( double x, double y ); 01335 01336 /** @brief set value */ 01337 inline void setValue( const OfxPointD& p ) { setValue( p.x, p.y ); } 01338 01339 /** @brief set the value at a time, implicitly adds a keyframe */ 01340 void setValueAtTime( double t, double x, double y ); 01341 01342 /** @brief set the value at a time, implicitly adds a keyframe */ 01343 inline void setValueAtTime( double t, const OfxPointD& p ) { setValueAtTime( t, p.x, p.y ); } 01344 01345 /** @brief differentiate the param */ 01346 void differentiate( double t, double& x, double& y ) const; 01347 01348 /** @brief differentiate the param */ 01349 OfxPointD differentiate( double t ) const { OfxPointD v; differentiate( t, v.x, v.y ); return v; } 01350 01351 /** @brief integrate the param */ 01352 void integrate( double t1, double t2, double& x, double& y ) const; 01353 01354 /** @brief integrate the param */ 01355 OfxPointD integrate( double t1, double t2 ) const { OfxPointD v; integrate( t1, t2, v.x, v.y ); return v; } 01356 }; 01357 01358 //////////////////////////////////////////////////////////////////////////////// 01359 /** @brief Wraps up an doubleeger param */ 01360 class Double3DParam : public BaseDoubleParam 01361 { 01362 private: 01363 mDeclareProtectedAssignAndCC( Double3DParam ); 01364 Double3DParam( void ) { assert( false ); } 01365 01366 protected: 01367 /** @brief hidden constructor */ 01368 Double3DParam( const ParamSet* paramSet, const std::string& name, OfxParamHandle handle ); 01369 01370 friend class ParamSet; 01371 01372 public: 01373 /** @brief set the default value, default is 0 */ 01374 void setDefault( double x, double y, double z ); 01375 01376 /** @brief set the hard min/max range, default is DOUBLE_MIN, DOUBLE_MAX */ 01377 void setRange( double minX, double minY, double minZ, 01378 double maxX, double maxY, double maxZ ); 01379 01380 /** @brief set the display min and max, default is to be the same as the range param */ 01381 void setDisplayRange( double minX, double minY, double minZ, 01382 double maxX, double maxY, double maxZ ); 01383 01384 /** @brief het the default value */ 01385 void getDefault( double& x, double& y, double& z ) const; 01386 01387 /** @brief set the hard min/max range, default is DOUBLE_MIN, DOUBLE_MAX */ 01388 void getRange( double& minX, double& minY, double& minZ, 01389 double& maxX, double& maxY, double& maxZ ) const; 01390 01391 /** @brief set the display min and max, default is to be the same as the range param */ 01392 void getDisplayRange( double& minX, double& minY, double& minZ, 01393 double& maxX, double& maxY, double& maxZ ) const; 01394 01395 /** @brief get value */ 01396 void getValue( double& x, double& y, double& z ) const; 01397 01398 /** @brief get the value at a time */ 01399 void getValueAtTime( double t, double& x, double& y, double& z ) const; 01400 01401 /** @brief set value */ 01402 void setValue( double x, double y, double z ); 01403 01404 /** @brief set the value at a time, implicitly adds a keyframe */ 01405 void setValueAtTime( double t, double x, double y, double z ); 01406 01407 /** @brief differentiate the param */ 01408 void differentiate( double t, double& x, double& y, double& z ) const; 01409 01410 /** @brief differentiate the param */ 01411 Ofx3DPointD differentiate( double t ) const { Ofx3DPointD v; differentiate( t, v.x, v.y, v.z ); return v; } 01412 01413 /** @brief integrate the param */ 01414 void integrate( double t1, double t2, double& x, double& y, double& z ) const; 01415 01416 /** @brief integrate the param */ 01417 Ofx3DPointD integrate( double t1, double t2 ) const { Ofx3DPointD v; integrate( t1, t2, v.x, v.y, v.z ); return v; } 01418 }; 01419 01420 //////////////////////////////////////////////////////////////////////////////// 01421 /** @brief Wraps up an RGB param */ 01422 class RGBParam : public ValueParam 01423 { 01424 private: 01425 mDeclareProtectedAssignAndCC( RGBParam ); 01426 RGBParam( void ) { assert( false ); } 01427 01428 protected: 01429 /** @brief hidden constructor */ 01430 RGBParam( const ParamSet* paramSet, const std::string& name, OfxParamHandle handle ); 01431 01432 friend class ParamSet; 01433 01434 public: 01435 /** @brief set the default value, default is 0 */ 01436 void setDefault( double r, double g, double b ); 01437 01438 /** @brief get default value */ 01439 void getDefault( double& r, double& g, double& b ) const; 01440 01441 /** @brief get value */ 01442 void getValue( double& r, double& g, double& b ) const; 01443 OfxRGBColourD getValue() const { OfxRGBColourD c; getValue(c.r, c.g, c.b); return c; } 01444 01445 /** @brief get the value at a time */ 01446 void getValueAtTime( double t, double& r, double& g, double& b ) const; 01447 OfxRGBColourD getValueAtTime( double t ) const { OfxRGBColourD c; getValueAtTime(t, c.r, c.g, c.b); return c; } 01448 01449 /** @brief set value */ 01450 void setValue( double r, double g, double b ); 01451 01452 /** @brief set the value at a time, implicitly adds a keyframe */ 01453 void setValueAtTime( double t, double r, double g, double b ); 01454 }; 01455 01456 //////////////////////////////////////////////////////////////////////////////// 01457 /** @brief Wraps up an RGB param */ 01458 class RGBAParam : public ValueParam 01459 { 01460 private: 01461 mDeclareProtectedAssignAndCC( RGBAParam ); 01462 RGBAParam( void ) { assert( false ); } 01463 01464 protected: 01465 /** @brief hidden constructor */ 01466 RGBAParam( const ParamSet* paramSet, const std::string& name, OfxParamHandle handle ); 01467 01468 friend class ParamSet; 01469 01470 public: 01471 /** @brief set the default value, default is 0 */ 01472 void setDefault( double r, double g, double b, double a ); 01473 01474 /** @brief get default value */ 01475 void getDefault( double& r, double& g, double& b, double& a ) const; 01476 OfxRGBAColourD getDefault() const { OfxRGBAColourD c; getDefault(c.r, c.g, c.b, c.a); return c; } 01477 01478 /** @brief get value */ 01479 void getValue( double& r, double& g, double& b, double& a ) const; 01480 OfxRGBAColourD getValue() const { OfxRGBAColourD c; getValue(c.r, c.g, c.b, c.a); return c; } 01481 01482 /** @brief get the value at a time */ 01483 void getValueAtTime( double t, double& r, double& g, double& b, double& a ) const; 01484 OfxRGBAColourD getValueAtTime( double t ) const { OfxRGBAColourD c; getValueAtTime(t, c.r, c.g, c.b, c.a); return c; } 01485 01486 /** @brief set value */ 01487 void setValue( double r, double g, double b, double a ); 01488 01489 /** @brief set the value at a time, implicitly adds a keyframe */ 01490 void setValueAtTime( double t, double r, double g, double b, double a ); 01491 }; 01492 01493 //////////////////////////////////////////////////////////////////////////////// 01494 /** @brief Wraps up a string param */ 01495 class StringParam : public ValueParam 01496 { 01497 private: 01498 mDeclareProtectedAssignAndCC( StringParam ); 01499 StringParam( void ) { assert( false ); } 01500 01501 protected: 01502 /** @brief hidden constructor */ 01503 StringParam( const ParamSet* paramSet, const std::string& name, OfxParamHandle handle ); 01504 01505 friend class ParamSet; 01506 01507 public: 01508 /** @brief get the default value */ 01509 void getDefault( std::string& v ) const; 01510 std::string getDefault() const { std::string s; getDefault(s); return s; } 01511 01512 /** @brief set the default value */ 01513 void setDefault( const std::string& v ); 01514 01515 /** @brief get value */ 01516 void getPointerValue( char** cStr ) const; 01517 01518 void getValue( std::string& v ) const; 01519 std::string getValue() const { std::string s; getValue(s); return s; } 01520 01521 /** @brief set value */ 01522 void setValue( const std::string& v ); 01523 01524 /** @brief get the value at a time */ 01525 void getPointerValueAtTime( OfxTime time, char** cStr ) const; 01526 01527 /** @brief get the value at a time */ 01528 void getValueAtTime( OfxTime time, std::string& v ) const; 01529 std::string getValueAtTime( OfxTime time ) const { std::string s; getValueAtTime( time, s ); return s; } 01530 01531 /** @brief set the value at a time, implicitly adds a keyframe */ 01532 void setValueAtTime( OfxTime time, const std::string& v ); 01533 01534 StringTypeEnum getStringType() const; 01535 }; 01536 01537 //////////////////////////////////////////////////////////////////////////////// 01538 /** @brief Wraps up a choice param */ 01539 class ChoiceParam : public ValueParam 01540 { 01541 private: 01542 mDeclareProtectedAssignAndCC( ChoiceParam ); 01543 ChoiceParam( void ) { assert( false ); } 01544 01545 protected: 01546 /** @brief hidden constructor */ 01547 ChoiceParam( const ParamSet* paramSet, const std::string& name, OfxParamHandle handle ); 01548 01549 // so it can make one 01550 friend class ParamSet; 01551 public: 01552 /** @brief set the default value */ 01553 void setDefault( int v ); 01554 01555 /** @brief get the default value */ 01556 void getDefault( int& v ) const; 01557 01558 /** @brief how many options do we have */ 01559 int getNOptions( void ) const; 01560 01561 /** @brief append an option, default is to have not there */ 01562 void appendOption( const std::string& shortName, const std::string& label = "" ); 01563 01564 /** @brief clear all the options so as to add some new ones in */ 01565 void resetOptions( void ); 01566 01567 /** @brief get value */ 01568 void getValue( int& v ) const; 01569 01570 /** @brief get value */ 01571 inline int getValue() const { int v; getValue( v ); return v; } 01572 01573 /** @brief get the value at a time */ 01574 void getValueAtTime( double t, int& v ) const; 01575 01576 /** @brief set value */ 01577 void setValue( int v ); 01578 01579 /** @brief set the value at a time, implicitly adds a keyframe */ 01580 void setValueAtTime( double t, int v ); 01581 }; 01582 01583 //////////////////////////////////////////////////////////////////////////////// 01584 /** @brief Wraps up a boolean param */ 01585 class BooleanParam : public ValueParam 01586 { 01587 private: 01588 mDeclareProtectedAssignAndCC( BooleanParam ); 01589 BooleanParam( void ) { assert( false ); } 01590 01591 protected: 01592 /** @brief hidden constructor */ 01593 BooleanParam( const ParamSet* paramSet, const std::string& name, OfxParamHandle handle ); 01594 01595 // so it can make one 01596 friend class ParamSet; 01597 01598 public: 01599 /** @brief set the default value */ 01600 void setDefault( bool v ); 01601 01602 /** @brief get the default value */ 01603 void getDefault( bool& v ) const; 01604 01605 /** @brief get the default value */ 01606 bool getDefault( void ) const { bool v; getDefault( v ); return v; } 01607 01608 /** @brief get value */ 01609 void getValue( bool& v ) const; 01610 01611 /** @brief get value */ 01612 bool getValue( void ) const { bool v; getValue( v ); return v; } 01613 01614 /** @brief get the value at a time */ 01615 void getValueAtTime( double t, bool& v ) const; 01616 01617 /** @brief get value */ 01618 bool getValueAtTime( double t ) const { bool v; getValueAtTime( t, v ); return v; } 01619 01620 /** @brief set value */ 01621 void setValue( bool v ); 01622 01623 /** @brief set the value at a time, implicitly adds a keyframe */ 01624 void setValueAtTime( double t, bool v ); 01625 }; 01626 01627 //////////////////////////////////////////////////////////////////////////////// 01628 /** @brief Wraps up a group param */ 01629 class GroupParam : public Param 01630 { 01631 private: 01632 mDeclareProtectedAssignAndCC( GroupParam ); 01633 GroupParam( void ) { assert( false ); } 01634 01635 protected: 01636 /** @brief hidden constructor */ 01637 GroupParam( const ParamSet* paramSet, const std::string& name, OfxParamHandle handle ); 01638 01639 // so it can make one 01640 friend class ParamSet; 01641 }; 01642 01643 //////////////////////////////////////////////////////////////////////////////// 01644 /** @brief Wraps up a group param */ 01645 class PageParam : public Param 01646 { 01647 private: 01648 mDeclareProtectedAssignAndCC( PageParam ); 01649 PageParam( void ) { assert( false ); } 01650 01651 protected: 01652 /** @brief hidden constructor */ 01653 PageParam( const ParamSet* paramSet, const std::string& name, OfxParamHandle handle ); 01654 01655 // so it can make one 01656 friend class ParamSet; 01657 01658 public: 01659 }; 01660 01661 //////////////////////////////////////////////////////////////////////////////// 01662 /** @brief Wraps up a custom param, not animation support yet */ 01663 class CustomParam : public ValueParam 01664 { 01665 private: 01666 mDeclareProtectedAssignAndCC( CustomParam ); 01667 CustomParam( void ) { assert( false ); } 01668 01669 protected: 01670 /** @brief hidden constructor */ 01671 CustomParam( const ParamSet* paramSet, const std::string& name, OfxParamHandle handle ); 01672 01673 // so it can make one 01674 friend class ParamSet; 01675 01676 public: 01677 /** @brief set the default value of the param */ 01678 void setDefault( const std::string& v ); 01679 01680 /** @brief get the default value of the param */ 01681 void getDefault( std::string& v ) const; 01682 01683 /** @brief get value */ 01684 void getValue( std::string& v ) const; 01685 01686 /** @brief get value */ 01687 inline std::string getValue() const { std::string v; getValue( v ); return v; } 01688 01689 /** @brief get the value at a time */ 01690 void getValueAtTime( double t, std::string& v ) const; 01691 01692 /** @brief get the value at a time */ 01693 inline std::string getValueAtTime( double t ) const { std::string v; getValueAtTime( t, v ); return v; } 01694 01695 /** @brief set value */ 01696 void setValue( const std::string& v ); 01697 01698 /** @brief set the value at a time, implicitly adds a keyframe */ 01699 void setValueAtTime( double t, const std::string& v ); 01700 }; 01701 01702 //////////////////////////////////////////////////////////////////////////////// 01703 /** @brief Wraps up a push button param, not much to it at all */ 01704 class PushButtonParam : public Param 01705 { 01706 private: 01707 mDeclareProtectedAssignAndCC( PushButtonParam ); 01708 PushButtonParam( void ) { assert( false ); } 01709 01710 protected: 01711 /** @brief hidden constructor */ 01712 PushButtonParam( const ParamSet* paramSet, const std::string& name, OfxParamHandle handle ); 01713 01714 // so it can make one 01715 friend class ParamSet; 01716 01717 public: 01718 }; 01719 01720 //////////////////////////////////////////////////////////////////////////////// 01721 /** @brief Wraps up a parametric param */ 01722 class ParametricParam : public Param 01723 { 01724 private: 01725 mDeclareProtectedAssignAndCC( ParametricParam ); 01726 ParametricParam( void ) { assert( false ); } 01727 01728 protected: 01729 /** @brief hidden constructor */ 01730 ParametricParam( const ParamSet* paramSet, const std::string& name, OfxParamHandle handle ); 01731 01732 // so it can make one 01733 friend class ParamSet; 01734 01735 public: 01736 double getValue( const int curveIndex, 01737 const OfxTime time, 01738 const double parametricPosition ); 01739 int getNControlPoints( const int curveIndex, 01740 const OfxTime time ); 01741 std::pair<double, double> getNthControlPoints( const int curveIndex, 01742 const OfxTime time, 01743 const int nthCtl ); 01744 void setNthControlPoints( const int curveIndex, 01745 const OfxTime time, 01746 const int nthCtl, 01747 const double key, 01748 const double value, 01749 const bool addAnimationKey ); 01750 void setNthControlPoints( const int curveIndex, 01751 const OfxTime time, 01752 const int nthCtl, 01753 const std::pair<double, double> ctrlPoint, 01754 const bool addAnimationKey ); 01755 void addControlPoint( const int curveIndex, 01756 const OfxTime time, 01757 const double key, 01758 const double value, 01759 const bool addAnimationKey ); 01760 void deleteControlPoint( const int curveIndex, 01761 const int nthCtl ); 01762 void deleteControlPoint( const int curveIndex ); 01763 }; 01764 01765 //////////////////////////////////////////////////////////////////////////////// 01766 /** @brief Wraps up a camera param */ 01767 class CameraParam : public Param 01768 { 01769 private: 01770 mDeclareProtectedAssignAndCC( CameraParam ); 01771 CameraParam( void ) { assert( false ); } 01772 01773 protected: 01774 /** @brief hidden constructor */ 01775 CameraParam( OfxImageEffectHandle imageEffectHandle, const ParamSet* paramSet, const std::string& name, NukeOfxCameraHandle handle ); 01776 01777 // so it can make one 01778 friend class ParamSet; 01779 01780 public: 01781 Param& getParameter( const std::string& name ); 01782 01783 private: 01784 OfxImageEffectHandle _imageEffectHandle; 01785 }; 01786 01787 template<class ParamType> 01788 inline ParamTypeEnum mapParamTypeToEnum() 01789 { 01790 return eDummyParam; // as default value... 01791 } 01792 template<> 01793 inline ParamTypeEnum mapParamTypeToEnum<StringParam>() 01794 { 01795 return eStringParam; 01796 } 01797 template<> 01798 inline ParamTypeEnum mapParamTypeToEnum<IntParam>() 01799 { 01800 return eIntParam; 01801 } 01802 template<> 01803 inline ParamTypeEnum mapParamTypeToEnum<Int2DParam>() 01804 { 01805 return eInt2DParam; 01806 } 01807 template<> 01808 inline ParamTypeEnum mapParamTypeToEnum<Int3DParam>() 01809 { 01810 return eInt3DParam; 01811 } 01812 template<> 01813 inline ParamTypeEnum mapParamTypeToEnum<DoubleParam>() 01814 { 01815 return eDoubleParam; 01816 } 01817 template<> 01818 inline ParamTypeEnum mapParamTypeToEnum<Double2DParam>() 01819 { 01820 return eDouble2DParam; 01821 } 01822 template<> 01823 inline ParamTypeEnum mapParamTypeToEnum<Double3DParam>() 01824 { 01825 return eDouble3DParam; 01826 } 01827 template<> 01828 inline ParamTypeEnum mapParamTypeToEnum<RGBParam>() 01829 { 01830 return eRGBParam; 01831 } 01832 template<> 01833 inline ParamTypeEnum mapParamTypeToEnum<RGBAParam>() 01834 { 01835 return eRGBAParam; 01836 } 01837 template<> 01838 inline ParamTypeEnum mapParamTypeToEnum<BooleanParam>() 01839 { 01840 return eBooleanParam; 01841 } 01842 template<> 01843 inline ParamTypeEnum mapParamTypeToEnum<ChoiceParam>() 01844 { 01845 return eChoiceParam; 01846 } 01847 template<> 01848 inline ParamTypeEnum mapParamTypeToEnum<CustomParam>() 01849 { 01850 return eCustomParam; 01851 } 01852 template<> 01853 inline ParamTypeEnum mapParamTypeToEnum<GroupParam>() 01854 { 01855 return eGroupParam; 01856 } 01857 template<> 01858 inline ParamTypeEnum mapParamTypeToEnum<PageParam>() 01859 { 01860 return ePageParam; 01861 } 01862 template<> 01863 inline ParamTypeEnum mapParamTypeToEnum<PushButtonParam>() 01864 { 01865 return ePushButtonParam; 01866 } 01867 template<> 01868 inline ParamTypeEnum mapParamTypeToEnum<ParametricParam>() 01869 { 01870 return eParametricParam; 01871 } 01872 template<> 01873 inline ParamTypeEnum mapParamTypeToEnum<CameraParam>() 01874 { 01875 return eCameraParam; 01876 } 01877 01878 template<class ParamType> 01879 inline ParamTypeEnum mapParamTypeToEnumFrom( const ParamType& ) 01880 { 01881 return mapParamTypeToEnum<ParamType>(); 01882 } 01883 template<class ParamType> 01884 inline ParamTypeEnum mapParamTypeToEnumFrom( const ParamType* ) 01885 { 01886 return mapParamTypeToEnum<ParamType>(); 01887 } 01888 01889 //////////////////////////////////////////////////////////////////////////////// 01890 /** @brief A set of parameters in a plugin instance */ 01891 class ParamSet 01892 { 01893 public: 01894 typedef ParamSet This; 01895 protected: 01896 mDeclareProtectedAssignAndCC( ParamSet ); 01897 ParamTypeEnum getParamType( const std::string& name ) const; 01898 01899 private: 01900 /** @brief Properties that belong to this param set */ 01901 PropertySet _paramSetProps; 01902 01903 /** @brief Parameter set handle */ 01904 OfxParamSetHandle _paramSetHandle; 01905 01906 /** @brief Set of all previously fetched parameters, created on demand */ 01907 mutable std::map<std::string, Param*> _fetchedParams; 01908 01909 /** @brief see if we have a param of the given name in out map */ 01910 Param* findPreviouslyFetchedParam( const std::string& name ); 01911 01912 /** @brief calls the raw OFX routine to define a param */ 01913 void fetchRawParam( const std::string& name, ParamTypeEnum paramType, OfxParamHandle& handle ); 01914 void fetchRawCameraParam( OfxImageEffectHandle pluginHandle, const std::string& name, NukeOfxCameraHandle& handle ); 01915 01916 /** @brief Fetch a param of the given name and type */ 01917 template <class T> 01918 T* fetchParam( const std::string& name ) 01919 { 01920 ParamTypeEnum paramType = mapParamTypeToEnum<T>(); 01921 T* paramPtr = NULL; 01922 01923 // have we made it already in this param set and is it an int? 01924 if( Param * param = findPreviouslyFetchedParam( name ) ) 01925 { 01926 if( param->getParamType() == paramType ) 01927 { 01928 paramPtr = (T*) param; // could be a dynamic cast here 01929 } 01930 else 01931 BOOST_THROW_EXCEPTION( OFX::Exception::TypeRequest( "Fetching param and attempting to return the wrong type" ) ); 01932 } 01933 else 01934 { 01935 // ok define one and add it in 01936 OfxParamHandle paramHandle; 01937 fetchRawParam( name, paramType, paramHandle ); 01938 01939 // make out support descriptor class 01940 paramPtr = new T( this, name, paramHandle ); 01941 01942 // add it to our map of described ones 01943 _fetchedParams[name] = paramPtr; 01944 } 01945 return paramPtr; 01946 } 01947 01948 protected: 01949 template<class T> 01950 inline T* fetchAttribute( OfxImageEffectHandle pluginHandle, const std::string& name ) 01951 { 01952 // maybe the correct fonction you want to use is fetchParam(std::string) 01953 // if you use this function you need to redefine it for each type 01954 // because we need OfxImageEffectHandle because we use specific suites 01955 BOOST_ASSERT( false ); 01956 } 01957 01958 protected: 01959 /** @brief Hidden ctor */ 01960 ParamSet( void ); 01961 01962 /** @brief set the param set handle */ 01963 void setParamSetHandle( OfxParamSetHandle h ); 01964 01965 public: 01966 virtual ~ParamSet(); 01967 01968 bool paramExists( const std::string& name ) const; 01969 01970 /// open an undoblock 01971 void beginEditBlock( const std::string& name ); 01972 01973 /// close an undoblock 01974 void endEditBlock(); 01975 01976 Param* getParam( const std::string& name ); 01977 01978 /** @brief Fetch an integer param */ 01979 IntParam* fetchIntParam( const std::string& name ); 01980 01981 /** @brief Fetch a 2D integer param */ 01982 Int2DParam* fetchInt2DParam( const std::string& name ); 01983 01984 /** @brief Fetch a 3D integer param */ 01985 Int3DParam* fetchInt3DParam( const std::string& name ); 01986 01987 /** @brief Fetch an double param */ 01988 DoubleParam* fetchDoubleParam( const std::string& name ); 01989 01990 /** @brief Fetch a 2D double param */ 01991 Double2DParam* fetchDouble2DParam( const std::string& name ); 01992 01993 /** @brief Fetch a 3D double param */ 01994 Double3DParam* fetchDouble3DParam( const std::string& name ); 01995 01996 /** @brief Fetch a string param */ 01997 StringParam* fetchStringParam( const std::string& name ); 01998 01999 /** @brief Fetch a RGBA param */ 02000 RGBAParam* fetchRGBAParam( const std::string& name ); 02001 02002 /** @brief Fetch an RGB param */ 02003 RGBParam* fetchRGBParam( const std::string& name ); 02004 02005 /** @brief Fetch a Boolean param */ 02006 BooleanParam* fetchBooleanParam( const std::string& name ); 02007 02008 /** @brief Fetch a Choice param */ 02009 ChoiceParam* fetchChoiceParam( const std::string& name ); 02010 02011 /** @brief Fetch a group param */ 02012 GroupParam* fetchGroupParam( const std::string& name ); 02013 const GroupParam* fetchGroupParam( const std::string& name ) const { return const_cast<This&>(*this).fetchGroupParam(name); } 02014 02015 /** @brief Fetch a page param */ 02016 PageParam* fetchPageParam( const std::string& name ); 02017 02018 /** @brief Fetch a push button param */ 02019 PushButtonParam* fetchPushButtonParam( const std::string& name ); 02020 02021 /** @brief Fetch a custom param */ 02022 CustomParam* fetchCustomParam( const std::string& name ); 02023 02024 /** @brief Fetch a parametric param */ 02025 ParametricParam* fetchParametricParam( const std::string& name ); 02026 }; 02027 02028 /** @brief Fetch a parametric param */ 02029 template<> 02030 inline CameraParam* ParamSet::fetchAttribute<CameraParam>( OfxImageEffectHandle pluginHandle, const std::string& name ) 02031 { 02032 typedef CameraParam T; 02033 const ParamTypeEnum paramType = mapParamTypeToEnum<T>(); 02034 T* paramPtr = NULL; 02035 02036 // have we made it already in this param set and is it an int? 02037 if( Param * param = findPreviouslyFetchedParam( name ) ) 02038 { 02039 if( param->getParamType() == paramType ) 02040 { 02041 paramPtr = (T*) param; // could be a dynamic cast here 02042 } 02043 else 02044 { 02045 BOOST_THROW_EXCEPTION( OFX::Exception::TypeRequest( "Fetching param and attempting to return the wrong type" ) ); 02046 } 02047 } 02048 else 02049 { 02050 // ok define one and add it in 02051 NukeOfxCameraHandle paramHandle; 02052 fetchRawCameraParam( pluginHandle, name, paramHandle ); 02053 02054 // make out support descriptor class 02055 paramPtr = new T( pluginHandle, this, name, paramHandle ); 02056 02057 // add it to our map of described ones 02058 _fetchedParams[name] = paramPtr; 02059 } 02060 return paramPtr; 02061 } 02062 02063 } 02064 02065 // undeclare the protected assign and CC macro 02066 #undef mDeclareProtectedAssignAndCC 02067 02068 #endif