1 #ifndef _ofxsParam_H_ 2 #define _ofxsParam_H_ 3 4 /* 5 OFX Support Library, a library that skins the OFX plug-in API with C++ classes. 6 Copyright (C) 2004-2005 The Open Effects Association Ltd 7 Author Bruno Nicoletti bruno@thefoundry.co.uk 8 9 Redistribution and use in source and binary forms, with or without 10 modification, are permitted provided that the following conditions are met: 11 12 * Redistributions of source code must retain the above copyright notice, 13 this list of conditions and the following disclaimer. 14 * Redistributions in binary form must reproduce the above copyright notice, 15 this list of conditions and the following disclaimer in the documentation 16 and/or other materials provided with the distribution. 17 * Neither the name The Open Effects Association Ltd, nor the names of its 18 contributors may be used to endorse or promote products derived from this 19 software without specific prior written permission. 20 21 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 22 ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 23 WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 24 DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR 25 ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 26 (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 27 LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON 28 ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 29 (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 30 SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 31 32 The Open Effects Association Ltd 33 1 Wardour St 34 London W1D 6PA 35 England 36 37 38 39 */ 40 41 42 /** @file This file contains core code that wraps OFX parameters with C++ classes. 43 44 This file only holds code that is visible to a plugin implementation, and so hides much 45 of the direct OFX objects and any library side only functions. 46 47 The classes that skin parameters are broken into two sets, those used during the description phase, 48 eg OFX::IntParamDescriptor and those representing instances eg, OFX::IntParamInstance. The members on 49 each represent the actions that can be carried out on those particular OFX objects. 50 51 */ 52 53 #include <memory> 54 #include "ofxsCore.h" 55 56 #ifdef OFX_EXTENSIONS_NUKE 57 #include "nuke/camera.h" 58 #include "nuke/fnPublicOfxExtensions.h" 59 #endif 60 #ifdef OFX_EXTENSIONS_NATRON 61 #include "ofxNatron.h" 62 #endif 63 #include "ofxOld.h" // required for kOfxParamDoubleTypeNormalised* 64 65 /** @brief Nasty macro used to define empty protected copy ctors and assign ops */ 66 #define mDeclareProtectedAssignAndCC(CLASS) \ 67 CLASS &operator=(const CLASS &) {assert(false); return *this;} \ 68 CLASS(const CLASS &) {assert(false); } 69 #define mDeclareProtectedAssignAndCCBase(CLASS,BASE) \ 70 CLASS &operator=(const CLASS &) {assert(false); return *this;} \ 71 CLASS(const CLASS &c) : BASE(c) {assert(false); } 72 73 /** @brief The core 'OFX Support' namespace, used by plugin implementations. All code for these are defined in the common support libraries. 74 */ 75 namespace OFX { 76 77 class ParamInteractDescriptor; 78 /* forward class declarations of the descriptors */ 79 class ParamDescriptor; 80 class ValueParamDescriptor; 81 class IntParamDescriptor; 82 class Int2DParamDescriptor; 83 class Int3DParamDescriptor; 84 class DoubleParamDescriptor; 85 class Double2DParamDescriptor; 86 class Double3DParamDescriptor; 87 class StringParamDescriptor; 88 class RGBAParamDescriptor; 89 class RGBParamDescriptor; 90 class BooleanParamDescriptor; 91 class ChoiceParamDescriptor; 92 #ifdef OFX_EXTENSIONS_RESOLVE 93 class StrChoiceParamDescriptor; 94 #endif 95 class GroupParamDescriptor; 96 class PageParamDescriptor; 97 class PushButtonParamDescriptor; 98 class CustomParamDescriptor; 99 class ParamSetDescriptor; 100 101 /* forward class declarations of the instances */ 102 class Param; 103 class ValueParam; 104 class IntParam; 105 class Int2DParam; 106 class Int3DParam; 107 class DoubleParam; 108 class Double2DParam; 109 class Double3DParam; 110 class RGBAParam; 111 class RGBParam; 112 class StringParam; 113 class BooleanParam; 114 class ChoiceParam; 115 #ifdef OFX_EXTENSIONS_RESOLVE 116 class StrChoiceParam; 117 #endif 118 class CustomParam; 119 class GroupParam; 120 class PageParam; 121 class PushButtonParam; 122 class ParamSet; 123 124 125 /** @brief Enumerates the different types of parameter */ 126 enum ParamTypeEnum {eDummyParam, 127 eStringParam, 128 eIntParam, 129 eInt2DParam, 130 eInt3DParam, 131 eDoubleParam, 132 eDouble2DParam, 133 eDouble3DParam, 134 eRGBParam, 135 eRGBAParam, 136 eBooleanParam, 137 eChoiceParam, 138 #ifdef OFX_EXTENSIONS_RESOLVE 139 eStrChoiceParam, 140 #endif 141 eCustomParam, 142 eGroupParam, 143 ePageParam, 144 ePushButtonParam, 145 eParametricParam, 146 }; 147 148 /** @brief Enumerates the different types of cache invalidation */ 149 enum CacheInvalidationEnum {eCacheInvalidateValueChange, 150 eCacheInvalidateValueChangeToEnd, 151 eCacheInvalidateValueAll}; 152 153 /** @brief Enumerates how we search for keys in an animating parameter */ 154 enum KeySearchEnum {eKeySearchBackwards, 155 eKeySearchNear, 156 eKeySearchForwards}; 157 158 /** @brief Enumerates the differing types of string params */ 159 enum StringTypeEnum { 160 eStringTypeSingleLine, 161 eStringTypeMultiLine, 162 eStringTypeFilePath, 163 eStringTypeDirectoryPath, 164 eStringTypeLabel, 165 eStringTypeRichTextFormat 166 }; 167 168 /** @brief Enumerates the differing types of double params */ 169 enum DoubleTypeEnum { 170 eDoubleTypePlain, //!< parameter has no special interpretation 171 eDoubleTypeAngle, //!< parameter is to be interpretted as an angle 172 eDoubleTypeScale, //!< parameter is to be interpretted as a scale factor 173 eDoubleTypeTime, //!< parameter represents a time value (1D only) 174 eDoubleTypeAbsoluteTime, //!< parameter represents an absolute time value (1D only), 175 eDoubleTypeX, //!< a size in the X dimension dimension (1D only), new for 1.2 176 eDoubleTypeXAbsolute, //!< a position in the X dimension (1D only), new for 1.2 177 eDoubleTypeY, //!< a size in the Y dimension dimension (1D only), new for 1.2 178 eDoubleTypeYAbsolute, //!< a position in the X dimension (1D only), new for 1.2 179 eDoubleTypeXY, //!< a size in the X and Y dimension (2D only), new for 1.2 180 eDoubleTypeXYAbsolute, //!< a position in the X and Y dimension (2D only), new for 1.2 181 #ifdef kOfxParamDoubleTypeNormalisedX 182 eDoubleTypeNormalisedX, //!< normalised size with respect to the project's X dimension (1D only), deprecated for 1.2 183 eDoubleTypeNormalisedY, //!< normalised absolute position on the X axis (1D only), deprecated for 1.2 184 eDoubleTypeNormalisedXAbsolute, //!< normalised size wrt to the project's Y dimension (1D only), deprecated for 1.2 185 eDoubleTypeNormalisedYAbsolute, //!< normalised absolute position on the Y axis (1D only), deprecated for 1.2 186 eDoubleTypeNormalisedXY, //!< normalised to the project's X and Y size (2D only), deprecated for 1.2 187 eDoubleTypeNormalisedXYAbsolute, //!< normalised to the projects X and Y size, and is an absolute position on the image plane, deprecated for 1.2 188 #endif 189 #ifdef OFX_EXTENSIONS_VEGAS 190 eDoubleTypePolar, 191 eDoubleTypeChrominance 192 #endif 193 }; 194 195 /** @brief Enumerates the differing types of coordinate system for default values */ 196 enum DefaultCoordinateSystemEnum { 197 eCoordinatesCanonical, //!< canonical coordinate system 198 eCoordinatesNormalised, //!< normalized coordinate system 199 }; 200 201 #ifdef OFX_EXTENSIONS_NUKE 202 enum ELayoutHint { 203 eLayoutHintNormal = kOfxParamPropLayoutHintNormal, 204 eLayoutHintDivider = kOfxParamPropLayoutHintDivider, 205 eLayoutHintNoNewLine = kOfxParamPropLayoutHintNoNewLine 206 }; 207 #endif 208 209 #ifdef OFX_EXTENSIONS_VEGAS 210 /** @brief Enumerates the types of interpolation for vegas keyframes */ 211 enum VegasInterpolationEnum { 212 eVegasInterpolationUnknown, 213 eVegasInterpolationLinear, 214 eVegasInterpolationFast, 215 eVegasInterpolationSlow, 216 eVegasInterpolationSmooth, 217 eVegasInterpolationSharp, 218 eVegasInterpolationHold, 219 eVegasInterpolationManual, 220 eVegasInterpolationSplit 221 }; 222 223 /** @brief Enumerates the types of color spaces vegas uses in color UI parameters */ 224 enum ColorSpaceEnum { 225 eColorSpaceRGB, 226 eColorSpaceHSV, 227 eColorSpaceHSL, 228 eColorSpaceLab 229 }; 230 #endif 231 232 /** @brief turns a ParamTypeEnum into the char * that raw OFX uses */ 233 const char * 234 mapParamTypeEnumToString(ParamTypeEnum v); 235 236 #ifdef OFX_EXTENSIONS_VEGAS 237 VegasInterpolationEnum 238 mapToInterpolationEnum(const std::string &s) OFX_THROW(std::invalid_argument); 239 240 const char* 241 mapToInterpolationTypeEnum(OFX::VegasInterpolationEnum type); 242 #endif 243 244 //////////////////////////////////////////////////////////////////////////////// 245 /** @brief Base class for all param descriptors */ 246 class ParamDescriptor { 247 protected : 248 mDeclareProtectedAssignAndCC(ParamDescriptor); ParamDescriptor(void)249 ParamDescriptor(void) {assert(false);} 250 251 protected : 252 std::string _paramName; 253 ParamTypeEnum _paramType; 254 PropertySet _paramProps; 255 256 /** @brief hidden constructors */ 257 ParamDescriptor(const std::string &name, ParamTypeEnum type, OfxPropertySetHandle props); 258 259 friend class ParamSetDescriptor; 260 public : 261 /** @brief dtor */ 262 virtual ~ParamDescriptor(); 263 getType(void)264 ParamTypeEnum getType(void) const {return _paramType;} 265 266 /** @brief name */ getName(void)267 const std::string &getName(void) const {return _paramName;} 268 269 /** @brief Get the property set */ getPropertySet()270 PropertySet &getPropertySet() 271 { 272 return _paramProps; 273 } 274 275 276 /** @brief set the label property in a param */ 277 void setLabel(const std::string &label); 278 279 /** @brief set the label properties in a param */ 280 void setLabels(const std::string &label, const std::string &shortLabel, const std::string &longLabel); 281 282 /** @brief set the param hint */ 283 void setHint(const std::string &hint); 284 285 /** @brief set the param label and hint */ 286 void setLabelAndHint(const std::string &label, const std::string &hint); 287 288 /** @brief set the script name, default is the name it was created with */ 289 void setScriptName(const std::string &hint); 290 291 /** @brief set the secretness of the param, defaults to false */ 292 void setIsSecret(bool v); 293 294 /** @brief whether the param is secret and disabled, defaults to false */ setIsSecretAndDisabled(bool v)295 void setIsSecretAndDisabled(bool v) { setEnabled(!v); setIsSecret(v); } 296 297 #ifdef OFX_EXTENSIONS_VEGAS 298 /** @brief set the default expanded of the param, defaults to false */ 299 void setParameterExpanded(bool v); 300 #endif 301 302 /** @brief set the group param that is the parent of this one, default is to be ungrouped at the root level */ 303 void setParent(const GroupParamDescriptor &v); 304 305 /** @brief set the icon file name (SVG or PNG) */ 306 void setIcon(const std::string &v, bool pngFormat); 307 308 /** @brief whether the param is enabled, defaults to true */ 309 void setEnabled(bool v); 310 311 #ifdef OFX_EXTENSIONS_NUKE 312 /** @brief Layout hint 313 314 @param layoutHint @see kOfxParamPropLayoutHint 315 eLayoutHintNormal - for a new line after the parameter (default) 316 eLayoutHintDivider - for a separator between this parameter and the one to follow 317 eLayoutHintNoNewLine - for no new line, continue the next parameter on the same horizontal level 318 319 @param padWidth @see kOfxParamPropLayoutPadWidth 320 It tells the host how much space (in pixels) to leave between the current parameter and the next parameter in 321 horizontal layouts. A value of 0 (default) corresponds to stretchable space. 322 */ 323 void setLayoutHint(const ELayoutHint layoutHint, int padWidth = 0); 324 #endif 325 326 #ifdef OFX_EXTENSIONS_NATRON 327 /** @brief When set to true, the parameter is specific to an effect instance of the plug-in and should have a 328 unique representation for each instance. See descripton of kNatronOfxImageEffectContextTracker for more details 329 on multiple instances and difference between shared and specific parameters.*/ 330 void setInstanceSpecific(bool isSpecific); 331 332 /*Indicates if the parameter description is written in markdown or plain-text otherwise */ 333 void setDescriptionIsMarkdown(bool markdown); 334 335 /** @brief Layout hint for the host viewport 336 337 @param layoutHint @see kOfxParamPropLayoutHint 338 eLayoutHintNormal - for a new line after the parameter (default) 339 eLayoutHintDivider - for a separator between this parameter and the one to follow 340 eLayoutHintNoNewLine - for no new line, continue the next parameter on the same horizontal level 341 342 @param padWidth @see kOfxParamPropLayoutPadWidth 343 It tells the host how much space (in pixels) to leave between the current parameter and the next parameter in 344 horizontal layouts. A value of 0 (default) corresponds to stretchable space. 345 */ 346 void setInViewportLayoutHint(const ELayoutHint layoutHint, int padWidth = 0); 347 348 /*Set the label of the parameter that should be displayed on the host viewport*/ 349 void setInViewportLabel(const std::string& label); 350 351 /*Set whether the parameter should be secret or not in the host viewport. This is only relevant if the parameter has been added to the kNatronOfxImageEffectPropInViewerContextParamsOrder property on the image effect descriptor.*/ 352 void setInViewportIsSecret(bool secret); 353 #endif 354 355 bool getHostHasNativeOverlayHandle() const; 356 357 void setUseHostNativeOverlayHandle(bool use); 358 }; 359 360 //////////////////////////////////////////////////////////////////////////////// 361 /** @brief Used to implement dummy parameters for page positioning commands */ 362 class DummyParamDescriptor : public ParamDescriptor { 363 public : 364 /** @brief ctor */ DummyParamDescriptor(const std::string & name)365 DummyParamDescriptor(const std::string &name) 366 : ParamDescriptor(name, eDummyParam, 0) 367 {} 368 }; 369 370 //////////////////////////////////////////////////////////////////////////////// 371 /** @brief Wraps up a value holding param */ 372 class ValueParamDescriptor : public ParamDescriptor { 373 protected : 374 mDeclareProtectedAssignAndCCBase(ValueParamDescriptor,ParamDescriptor); ValueParamDescriptor(void)375 ValueParamDescriptor(void) {assert(false);} 376 377 protected : 378 /** @brief hidden constructor */ 379 ValueParamDescriptor(const std::string &name, ParamTypeEnum type, OfxPropertySetHandle props); 380 381 friend class ParamSetDescriptor; 382 auto_ptr<ParamInteractDescriptor> _interact; 383 public : 384 /** @brief dtor */ 385 ~ValueParamDescriptor(); 386 387 /** @brief set whether the param can animate, defaults to true in most cases */ 388 void setAnimates(bool v); 389 390 /** @brief set whether the param is persistent, defaults to true */ 391 void setIsPersistent(bool v); 392 393 /** @brief Set's whether the value of the param is significant (ie: affects the rendered image), defaults to true */ 394 void setEvaluateOnChange(bool v); 395 396 /** @brief Set's how any cache should be invalidated if the parameter is changed, defaults to eCacheInvalidateValueChange */ 397 void setCacheInvalidation(CacheInvalidationEnum v); 398 399 /// @brief Set whether the param should appear on any undo stack 400 void setCanUndo(bool v); 401 402 void setInteractDescriptor(ParamInteractDescriptor* desc); 403 }; 404 405 //////////////////////////////////////////////////////////////////////////////// 406 /** @brief Wraps up a string param */ 407 class StringParamDescriptor : public ValueParamDescriptor { 408 protected : 409 mDeclareProtectedAssignAndCCBase(StringParamDescriptor,ValueParamDescriptor); StringParamDescriptor(void)410 StringParamDescriptor(void) {assert(false);} 411 412 protected : 413 /** @brief hidden constructor */ 414 StringParamDescriptor(const std::string &name, OfxPropertySetHandle props); 415 416 friend class ParamSetDescriptor; 417 418 public : 419 /** @brief set the default value, default is 0 */ 420 void setDefault(const std::string &v); 421 422 /** @brief sets the kind of the string param, defaults to eStringSingleLine */ 423 void setStringType(StringTypeEnum v); 424 425 /** @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 */ 426 void setFilePathExists(bool v); 427 }; 428 429 //////////////////////////////////////////////////////////////////////////////// 430 /** @brief Wraps up an integer param */ 431 class IntParamDescriptor : public ValueParamDescriptor { 432 protected : 433 mDeclareProtectedAssignAndCCBase(IntParamDescriptor,ValueParamDescriptor); IntParamDescriptor(void)434 IntParamDescriptor(void) {assert(false);} 435 436 protected : 437 /** @brief hidden constructor */ 438 IntParamDescriptor(const std::string &name, OfxPropertySetHandle props); 439 440 friend class ParamSetDescriptor; 441 442 public : 443 /** @brief set the default value, default is 0 */ 444 void setDefault(int v); 445 446 /** @brief set the hard min/max range, default is INT_MIN, INT_MAX */ 447 void setRange(int min, int max); 448 449 /** @brief set the display min and max, default is to be the same as the range param */ 450 void setDisplayRange(int min, int max); 451 }; 452 453 //////////////////////////////////////////////////////////////////////////////// 454 /** @brief Wraps up an 2d integer param */ 455 class Int2DParamDescriptor : public ValueParamDescriptor { 456 protected : 457 mDeclareProtectedAssignAndCCBase(Int2DParamDescriptor,ValueParamDescriptor); Int2DParamDescriptor(void)458 Int2DParamDescriptor(void) {assert(false);} 459 460 protected : 461 /** @brief hidden constructor */ 462 Int2DParamDescriptor(const std::string &name, OfxPropertySetHandle props); 463 464 friend class ParamSetDescriptor; 465 466 public : 467 /** @brief set the dimension labels */ 468 void setDimensionLabels(const std::string &x, 469 const std::string &y); 470 471 /** @brief set the default value, default is 0 */ 472 void setDefault(int x, int y); 473 474 /** @brief set the hard min/max range, default is INT_MIN, INT_MAX */ 475 void setRange(int minX, int minY, 476 int maxX, int maxY); 477 478 /** @brief set the display min and max, default is to be the same as the range param */ 479 void setDisplayRange(int minX, int minY, 480 int maxX, int maxY); 481 }; 482 483 //////////////////////////////////////////////////////////////////////////////// 484 /** @brief Wraps up an 3d integer param */ 485 class Int3DParamDescriptor : public ValueParamDescriptor { 486 protected : 487 mDeclareProtectedAssignAndCCBase(Int3DParamDescriptor,ValueParamDescriptor); Int3DParamDescriptor(void)488 Int3DParamDescriptor(void) {assert(false);} 489 490 protected : 491 /** @brief hidden constructor */ 492 Int3DParamDescriptor(const std::string &name, OfxPropertySetHandle props); 493 494 friend class ParamSetDescriptor; 495 496 public : 497 /** @brief set the dimension labels */ 498 void setDimensionLabels(const std::string &x, 499 const std::string &y, 500 const std::string &z); 501 502 /** @brief set the default value, default is 0 */ 503 void setDefault(int x, int y, int z); 504 505 /** @brief set the hard min/max range, default is INT_MIN, INT_MAX */ 506 void setRange(int minX, int minY, int minZ, 507 int maxX, int maxY, int maxZ); 508 509 /** @brief set the display min and max, default is to be the same as the range param */ 510 void setDisplayRange(int minX, int minY, int minZ, 511 int maxX, int maxY, int maxZ); 512 }; 513 514 //////////////////////////////////////////////////////////////////////////////// 515 /** @brief Common base to all double param types */ 516 class BaseDoubleParamDescriptor : public ValueParamDescriptor { 517 protected : 518 mDeclareProtectedAssignAndCCBase(BaseDoubleParamDescriptor,ValueParamDescriptor); BaseDoubleParamDescriptor(void)519 BaseDoubleParamDescriptor(void) {assert(false);} 520 521 protected : 522 /** @brief hidden constructor */ 523 BaseDoubleParamDescriptor(const std::string &name, ParamTypeEnum type, OfxPropertySetHandle props); 524 525 friend class ParamSetDescriptor; 526 public : 527 /** @brief set the type of the double param, defaults to eDoubleTypePlain */ 528 void setDoubleType(DoubleTypeEnum v); 529 530 /** @brief returns true if the param descriptor prop kOfxParamPropDefaultCoordinateSystem is present */ 531 bool supportsDefaultCoordinateSystem(); 532 533 /** @brief set the type of coordinate system for default values */ 534 void setDefaultCoordinateSystem(DefaultCoordinateSystemEnum v); 535 536 /** @brief set the sensitivity of any gui slider */ 537 void setIncrement(double v); 538 539 /** @brief set the number of digits printed after a decimal point in any gui */ 540 void setDigits(int v); 541 }; 542 543 //////////////////////////////////////////////////////////////////////////////// 544 /** @brief Wraps up a double param */ 545 class DoubleParamDescriptor : public BaseDoubleParamDescriptor { 546 protected : 547 mDeclareProtectedAssignAndCCBase(DoubleParamDescriptor,BaseDoubleParamDescriptor); DoubleParamDescriptor(void)548 DoubleParamDescriptor(void) {assert(false);} 549 550 protected : 551 /** @brief hidden constructor */ 552 DoubleParamDescriptor(const std::string &name, OfxPropertySetHandle props); 553 554 friend class ParamSetDescriptor; 555 556 public : 557 /** @brief if the double type is Absolute time, show a time marker on the time line if possible */ 558 void setShowTimeMarker(bool v); 559 560 /** @brief set the default value, default is 0 */ 561 void setDefault(double v); 562 563 /** @brief set the hard min/max range, default is INT_MIN, INT_MAX */ 564 void setRange(double min, double max); 565 566 /** @brief set the display min and max, default is to be the same as the range param */ 567 void setDisplayRange(double min, double max); 568 }; 569 570 //////////////////////////////////////////////////////////////////////////////// 571 /** @brief Wraps up a 2D double param */ 572 class Double2DParamDescriptor : public BaseDoubleParamDescriptor { 573 protected : 574 mDeclareProtectedAssignAndCCBase(Double2DParamDescriptor,BaseDoubleParamDescriptor); Double2DParamDescriptor(void)575 Double2DParamDescriptor(void) {assert(false);} 576 577 protected : 578 /** @brief hidden constructor */ 579 Double2DParamDescriptor(const std::string &name, OfxPropertySetHandle props); 580 581 friend class ParamSetDescriptor; 582 583 public : 584 585 586 #ifdef OFX_EXTENSIONS_NATRON 587 enum RectangleParamPartEnum 588 { 589 eRectangleParamPartNone, 590 eRectangleParamPartPosition, 591 eRectangleParamPartSize 592 }; 593 594 /** 595 * @brief Set as the 596 **/ 597 void setRectanglePart(RectangleParamPartEnum rectanglePart); 598 #endif 599 600 /** @brief set the dimension labels */ 601 void setDimensionLabels(const std::string &x, 602 const std::string &y); 603 604 /** @brief set the default value, default is 0 */ 605 void setDefault(double x, double y); 606 607 /** @brief set the hard min/max range, default is INT_MIN, INT_MAX */ 608 void setRange(double minX, double minY, 609 double maxX, double maxY); 610 611 /** @brief set the display min and max, default is to be the same as the range param */ 612 void setDisplayRange(double minX, double minY, 613 double maxX, double maxY); 614 615 #ifdef OFX_EXTENSIONS_VEGAS 616 /** @brief set the color wheel level value, default is 0.75 */ 617 void setColorWheelLevel(double x); 618 #endif 619 }; 620 621 //////////////////////////////////////////////////////////////////////////////// 622 /** @brief Wraps up a 3D double param */ 623 class Double3DParamDescriptor : public BaseDoubleParamDescriptor { 624 protected : 625 mDeclareProtectedAssignAndCCBase(Double3DParamDescriptor,BaseDoubleParamDescriptor); Double3DParamDescriptor(void)626 Double3DParamDescriptor(void) {assert(false);} 627 628 protected : 629 /** @brief hidden constructor */ 630 Double3DParamDescriptor(const std::string &name, OfxPropertySetHandle props); 631 632 friend class ParamSetDescriptor; 633 634 public : 635 636 #ifdef OFX_EXTENSIONS_NATRON 637 /** 638 * @brief Set the (1-based) matrix row 639 **/ 640 void setMatrixRow(int rowIndex); 641 #endif 642 643 /** @brief set the dimension labels */ 644 void setDimensionLabels(const std::string &x, 645 const std::string &y, 646 const std::string &z); 647 648 /** @brief set the default value, default is 0 */ 649 void setDefault(double x, double y, double z); 650 651 /** @brief set the hard min/max range, default is -DBL_MAX, DBL_MAX */ 652 void setRange(double minX, double minY, double minZ, 653 double maxX, double maxY, double maxZ); 654 655 /** @brief set the display min and max, default is to be the same as the range param */ 656 void setDisplayRange(double minX, double minY, double minZ, 657 double maxX, double maxY, double maxZ); 658 }; 659 660 //////////////////////////////////////////////////////////////////////////////// 661 /** @brief Wraps up an RGB colour param */ 662 class RGBParamDescriptor : public ValueParamDescriptor { 663 protected : 664 mDeclareProtectedAssignAndCCBase(RGBParamDescriptor,ValueParamDescriptor); RGBParamDescriptor(void)665 RGBParamDescriptor(void) {assert(false);} 666 667 protected : 668 /** @brief hidden constructor */ 669 RGBParamDescriptor(const std::string &name, OfxPropertySetHandle props); 670 671 // so it can make one 672 friend class ParamSetDescriptor; 673 public : 674 /** @brief set the dimension labels */ 675 void setDimensionLabels(const std::string &r, 676 const std::string &g, 677 const std::string &b); 678 679 /** @brief set the default value */ 680 void setDefault(double r, double g, double b); 681 682 /** @brief set the hard min/max range, default is 0., 1. */ 683 void setRange(double minR, double minG, double minB, 684 double maxR, double maxG, double maxB); 685 686 /** @brief set the display min and max, default is to be the same as the range param */ 687 void setDisplayRange(double minR, double minG, double minB, 688 double maxR, double maxG, double maxB); 689 #ifdef OFX_EXTENSIONS_VEGAS 690 /** @brief set the default UI color space of the RGB param, defaults to eColorSpaceHSV */ 691 void setDefaultColorSpace(ColorSpaceEnum v); 692 #endif 693 }; 694 695 //////////////////////////////////////////////////////////////////////////////// 696 /** @brief Wraps up an RGBA colour param */ 697 class RGBAParamDescriptor : public ValueParamDescriptor { 698 protected : 699 mDeclareProtectedAssignAndCCBase(RGBAParamDescriptor,ValueParamDescriptor); RGBAParamDescriptor(void)700 RGBAParamDescriptor(void) {assert(false);} 701 702 protected : 703 /** @brief hidden constructor */ 704 RGBAParamDescriptor(const std::string &name, OfxPropertySetHandle props); 705 706 // so it can make one 707 friend class ParamSetDescriptor; 708 public : 709 /** @brief set the dimension labels */ 710 void setDimensionLabels(const std::string &r, 711 const std::string &g, 712 const std::string &b, 713 const std::string &a); 714 715 /** @brief set the default value */ 716 void setDefault(double r, double g, double b, double a); 717 718 /** @brief set the hard min/max range, default is 0., 1. */ 719 void setRange(double minR, double minG, double minB, double minA, 720 double maxR, double maxG, double maxB, double maxA); 721 722 /** @brief set the display min and max, default is to be the same as the range param */ 723 void setDisplayRange(double minR, double minG, double minB, double minA, 724 double maxR, double maxG, double maxB, double maxA); 725 #ifdef OFX_EXTENSIONS_VEGAS 726 /** @brief set the default UI color space of the RGB param, defaults to eColorSpaceHSV */ 727 void setDefaultColorSpace(ColorSpaceEnum v); 728 #endif 729 }; 730 731 //////////////////////////////////////////////////////////////////////////////// 732 /** @brief Wraps up a boolean param */ 733 class BooleanParamDescriptor : public ValueParamDescriptor { 734 protected : 735 mDeclareProtectedAssignAndCCBase(BooleanParamDescriptor,ValueParamDescriptor); BooleanParamDescriptor(void)736 BooleanParamDescriptor(void) {assert(false);} 737 738 protected : 739 /** @brief hidden constructor */ 740 BooleanParamDescriptor(const std::string &name, OfxPropertySetHandle props); 741 742 // so it can make one 743 friend class ParamSetDescriptor; 744 public : 745 /** @brief set the default value */ 746 void setDefault(bool v); 747 748 #ifdef OFX_EXTENSIONS_NATRON 749 /*If called, the parameter will be defined as an action in the host viewport toolbar. The parameter should be added to a group on which the property kNatronOfxParamPropInViewerContextIsInToolbar was set to 1 */ 750 void setAsInViewportToolbuttonAction(); 751 752 /*If called, the boolean parameter will be represented as a toggable button instead of a checkbox*/ 753 void setAsToggableButton(); 754 755 /*If called, the host can add an entry in the shortcut editor for this parameter when the user is using the viewport. 756 The default value for the shortcut may be specified on the ImageEffectDescriptor by calling the function setDefaultParamInViewportShortcut()*/ 757 void setInViewportCanHaveShortcut(); 758 #endif 759 }; 760 761 //////////////////////////////////////////////////////////////////////////////// 762 /** @brief Wraps up a choice param */ 763 class ChoiceParamDescriptor : public ValueParamDescriptor { 764 protected : 765 mDeclareProtectedAssignAndCCBase(ChoiceParamDescriptor,ValueParamDescriptor); ChoiceParamDescriptor(void)766 ChoiceParamDescriptor(void) {assert(false);} 767 768 protected : 769 /** @brief hidden constructor */ 770 ChoiceParamDescriptor(const std::string &name, OfxPropertySetHandle props); 771 772 // so it can make one 773 friend class ParamSetDescriptor; 774 public : 775 /** @brief set the default value */ 776 void setDefault(int v); 777 778 /** @brief append an option 779 @param label The label of the option as it should appear on the GUI 780 @param hint A hint for the option that could be displayed by the host in a tooltip 781 @param name The unique identifier for that option. If empty this is by default set to the label. 782 */ 783 void appendOption(const std::string &label, const std::string& hint = "", const std::string& name = ""); 784 785 /** @brief how many options do we have */ 786 int getNOptions(void); 787 788 /** @brief clear all the options so as to add some new ones in */ 789 void resetOptions(void); 790 791 /** @brief clear all the options so as to add some new ones in */ 792 void resetOptions(const std::vector<std::string>& newEntries, 793 const std::vector<std::string>& newEntriesLabels = std::vector<std::string>(), 794 const std::vector<std::string>& newEntriesIDS = std::vector<std::string>()); 795 796 #ifdef OFX_EXTENSIONS_NATRON 797 /** @brief whether the menu should be cascading, and each option contains a slash-separated path to the item, defaults to false. */ 798 void setCascading(const bool v); 799 800 #endif 801 }; 802 803 #ifdef OFX_EXTENSIONS_RESOLVE 804 //////////////////////////////////////////////////////////////////////////////// 805 /** @brief Wraps up a string choice param */ 806 class StrChoiceParamDescriptor : public ValueParamDescriptor 807 { 808 protected : 809 mDeclareProtectedAssignAndCCBase(StrChoiceParamDescriptor, ValueParamDescriptor); StrChoiceParamDescriptor()810 StrChoiceParamDescriptor() { assert(false); } 811 812 protected : 813 /** @brief hidden constructor */ 814 StrChoiceParamDescriptor(const std::string& p_Name, OfxPropertySetHandle p_Props); 815 816 // so it can make one 817 friend class ParamSetDescriptor; 818 819 public : 820 /** @brief set the default value */ 821 void setDefault(const std::string& p_DefaultValue); 822 823 /** @brief append an option */ 824 void appendOption(const std::string& p_Enum, const std::string& p_Option); 825 826 /** @brief how many options do we have */ 827 int getNOptions(); 828 829 /** @brief clear all the options so as to add some new ones in */ 830 void resetOptions(); 831 }; 832 #endif 833 834 //////////////////////////////////////////////////////////////////////////////// 835 /** @brief Wraps up a group param, not much to it really */ 836 class GroupParamDescriptor : public ParamDescriptor { 837 protected : 838 mDeclareProtectedAssignAndCCBase(GroupParamDescriptor,ParamDescriptor); GroupParamDescriptor(void)839 GroupParamDescriptor(void) {assert(false);} 840 841 protected : 842 /** @brief hidden constructor */ 843 GroupParamDescriptor(const std::string &name, OfxPropertySetHandle props); 844 845 // so it can make one 846 friend class ParamSetDescriptor; 847 public : 848 /** @brief whether the initial state of a group is open or closed in a hierarchical layout, defaults to false */ 849 void setOpen(const bool v); 850 851 #ifdef OFX_EXTENSIONS_NUKE 852 void setAsTab(); 853 #endif 854 855 #ifdef OFX_EXTENSIONS_NATRON 856 /*tells if a group parameter can be displayed as a dialog by the host when its kOfxParamPropGroupOpen 857 property is set to 1.*/ 858 void setAsDialog(); 859 860 /*If called, the group will be defined as a Toolbutton in the host viewport toolbar. 861 @param canHaveShortcut If true, the host can add an entry in the shortcut editor for this toolbutton when the user is using the viewport. 862 The default value for the shortcut may be specified on the ImageEffectDescriptor by calling the function setDefaultParamInViewportShortcut()*/ 863 void setAsInViewportToolbutton(bool canHaveShortcut); 864 865 #endif 866 }; 867 868 //////////////////////////////////////////////////////////////////////////////// 869 /** @brief Wraps up a page param, not much to it really */ 870 class PageParamDescriptor : public ParamDescriptor { 871 protected : 872 mDeclareProtectedAssignAndCCBase(PageParamDescriptor,ParamDescriptor); PageParamDescriptor(void)873 PageParamDescriptor(void) {assert(false);} 874 875 protected : 876 /** @brief hidden constructor */ 877 PageParamDescriptor(const std::string &name, OfxPropertySetHandle props); 878 879 // so it can make one 880 friend class ParamSetDescriptor; 881 public : 882 883 /** @brief adds a child parameter. Note the two existing pseudo params, gColumnSkip and gRowSkip */ 884 void addChild(const ParamDescriptor &p); 885 886 /** @brief dummy page positioning parameter to be passed to @ref OFX::PageParamDescriptor::addChild */ 887 static DummyParamDescriptor gSkipRow; 888 889 /** @brief dummy page positioning parameter to be passed to @ref OFX::PageParamDescriptor::addChild */ 890 static DummyParamDescriptor gSkipColumn; 891 892 #ifdef OFX_EXTENSIONS_NATRON 893 /*If called, the page will be defined as a Toolbar in the host viewport.*/ 894 void setAsInViewportToolbar(); 895 #endif 896 }; 897 898 //////////////////////////////////////////////////////////////////////////////// 899 /** @brief Wraps up a push button param, not much to it at all */ 900 class PushButtonParamDescriptor : public ParamDescriptor { 901 protected : 902 mDeclareProtectedAssignAndCCBase(PushButtonParamDescriptor,ParamDescriptor); PushButtonParamDescriptor(void)903 PushButtonParamDescriptor(void) {assert(false);} 904 905 protected : 906 /** @brief hidden constructor */ 907 PushButtonParamDescriptor(const std::string &name, OfxPropertySetHandle props); 908 909 // so it can make one 910 friend class ParamSetDescriptor; 911 public : 912 913 #ifdef OFX_EXTENSIONS_NATRON 914 /*If called, the host can add an entry in the shortcut editor for this parameter when the user is using the viewport. 915 The default value for the shortcut may be specified on the ImageEffectDescriptor by calling the function setDefaultParamInViewportShortcut()*/ 916 void setInViewportCanHaveShortcut(); 917 #endif 918 }; 919 920 //////////////////////////////////////////////////////////////////////////////// 921 /** @brief Wraps up a push button param, not much to it at all */ 922 class ParametricParamDescriptor : public ParamDescriptor 923 { 924 protected: 925 mDeclareProtectedAssignAndCCBase(ParametricParamDescriptor,ParamDescriptor); ParametricParamDescriptor(void)926 ParametricParamDescriptor(void) {assert(false);} 927 928 protected: 929 /** @brief hidden constructor */ 930 ParametricParamDescriptor(const std::string& name, OfxPropertySetHandle props); 931 932 OfxParamHandle _ofxParamHandle; 933 ParamSetDescriptor* _paramSet; 934 auto_ptr<ParamInteractDescriptor> _interact; 935 936 // so it can make one 937 friend class ParamSetDescriptor; 938 void setParamSet( ParamSetDescriptor& paramSet ); 939 940 public: 941 void setDimension( const int dimension ); 942 943 void setRange( const double min, const double max ); 944 945 void setDimensionLabel( const std::string& label, const int id ); 946 947 void setDimensionRange( double min, double max, const int id ); 948 949 void setDimensionDisplayRange( double min, double max, const int id ); 950 951 void setUIColour( const int id, const OfxRGBColourD& color ); 952 953 void addControlPoint( const int id, const OfxTime time, const double x, const double y, const bool addKey ); 954 955 void setIdentity( const int id ); 956 957 void setIdentity(); 958 959 void setInteractDescriptor(ParamInteractDescriptor* desc); 960 961 #ifdef OFX_EXTENSIONS_NATRON 962 bool supportsPeriodic(); 963 964 void setPeriodic(bool periodic); 965 #endif 966 }; 967 968 //////////////////////////////////////////////////////////////////////////////// 969 /** @brief Wraps up a custom param, haven't added animation support yet */ 970 class CustomParamDescriptor : public ValueParamDescriptor { 971 protected : 972 mDeclareProtectedAssignAndCCBase(CustomParamDescriptor,ValueParamDescriptor); CustomParamDescriptor(void)973 CustomParamDescriptor(void) {assert(false);} 974 975 protected : 976 /** @brief hidden constructor */ 977 CustomParamDescriptor(const std::string &name, OfxPropertySetHandle props); 978 979 // so it can make one 980 friend class ParamSetDescriptor; 981 public : 982 /** @brief set the default value of the param */ 983 void setDefault(const std::string &v); 984 985 void setCustomInterpolation(bool v); 986 }; 987 988 //////////////////////////////////////////////////////////////////////////////// 989 /** @brief Describes a set of properties */ 990 class ParamSetDescriptor { 991 protected : 992 mDeclareProtectedAssignAndCC(ParamSetDescriptor); 993 994 /** @brief calls the raw OFX routine to define a param */ 995 void defineRawParam(const std::string &name, ParamTypeEnum paramType, OfxPropertySetHandle &props); 996 997 /** @brief Define a param descriptor of the given type */ 998 template <class T> bool defineParamDescriptor(const std::string & name,ParamTypeEnum paramType,T * & paramPtr)999 defineParamDescriptor(const std::string &name, ParamTypeEnum paramType, T * ¶mPtr) 1000 { 1001 paramPtr = NULL; 1002 1003 // have we made it already in this param set and is it of the correct type 1004 if(ParamDescriptor *param = findPreviouslyDefinedParam(name)) { 1005 if(param->getType() == paramType) { 1006 # ifdef DEBUG 1007 throw std::logic_error("Trying to redefine existing param '" + name + "'"); 1008 # else 1009 paramPtr = (T *) param; // could be a dynamic cast here 1010 return true; 1011 # endif 1012 } else { 1013 # ifdef DEBUG 1014 throw std::logic_error("Trying to redefine existing param '" + name + "' with a different type"); 1015 # else 1016 return false; // SHOULD THROW SOMETHING HERE!!!!!!! 1017 # endif 1018 } 1019 } 1020 else { 1021 // ok define one and add it in 1022 OfxPropertySetHandle props; 1023 defineRawParam(name, paramType, props); 1024 1025 // make out support descriptor class 1026 paramPtr = new T(name, props); 1027 1028 // add it to our map of described ones 1029 _definedParams[name] = paramPtr; 1030 } 1031 return true; 1032 } 1033 1034 /** @brief Fetch a param of the given name and type */ 1035 template <class T> void fetchParamDescriptor(const std::string & name,ParamTypeEnum paramType,T * & paramPtr)1036 fetchParamDescriptor(const std::string &name, ParamTypeEnum paramType, T * ¶mPtr) const 1037 { 1038 paramPtr = NULL; 1039 1040 // have we made it already in this param set and is it an int? 1041 if(ParamDescriptor *param = findPreviouslyDefinedParam(name)) { 1042 if(param->getType() == paramType) { 1043 paramPtr = (T *) param; // could be a dynamic cast here 1044 } 1045 else 1046 throw OFX::Exception::TypeRequest("Fetching param and attempting to return the wrong type"); 1047 } 1048 else { 1049 throw std::logic_error("Trying to fetch inexistant param descriptor '" + name + "'"); 1050 } 1051 } 1052 1053 protected : 1054 /** @brief Properties that belong to this param set */ 1055 PropertySet _paramSetProps; 1056 1057 /** @brief Parameter set handle */ 1058 OfxParamSetHandle _paramSetHandle; 1059 1060 /** @brief Set of all previously defined parameters, defined on demand */ 1061 std::map<std::string, ParamDescriptor *> _definedParams; 1062 1063 /** @brief Hidden ctor */ 1064 ParamSetDescriptor(void); 1065 1066 /** @brief set the param set handle */ 1067 void setParamSetHandle(OfxParamSetHandle h); 1068 1069 /** @brief find a param in the map */ 1070 ParamDescriptor *findPreviouslyDefinedParam(const std::string &name) const; 1071 1072 public : getParamSetHandle()1073 OfxParamSetHandle getParamSetHandle() 1074 { 1075 return _paramSetHandle; 1076 } 1077 1078 virtual ~ParamSetDescriptor(); 1079 /** @brief tries to fetch a ParamDescriptor, returns 0 if it isn't there*/ 1080 ParamDescriptor* getParamDescriptor(const std::string& name) const; 1081 1082 /** @brief estabilishes the order of page params. Do it by calling it in turn for each page */ 1083 void setPageParamOrder(PageParamDescriptor &p); 1084 1085 /** @brief Define an integer param */ 1086 IntParamDescriptor *defineIntParam(const std::string &name); 1087 1088 /** @brief Define a 2D integer param */ 1089 Int2DParamDescriptor *defineInt2DParam(const std::string &name); 1090 1091 /** @brief Define a 3D integer param */ 1092 Int3DParamDescriptor *defineInt3DParam(const std::string &name); 1093 1094 /** @brief Define an double param */ 1095 DoubleParamDescriptor *defineDoubleParam(const std::string &name); 1096 1097 /** @brief Define a 2D double param */ 1098 Double2DParamDescriptor *defineDouble2DParam(const std::string &name); 1099 1100 /** @brief Define a 3D double param */ 1101 Double3DParamDescriptor *defineDouble3DParam(const std::string &name); 1102 1103 /** @brief Define a string param */ 1104 StringParamDescriptor *defineStringParam(const std::string &name); 1105 1106 /** @brief Define a RGBA param */ 1107 RGBAParamDescriptor *defineRGBAParam(const std::string &name); 1108 1109 /** @brief Define an RGB param */ 1110 RGBParamDescriptor *defineRGBParam(const std::string &name); 1111 1112 /** @brief Define a Boolean param */ 1113 BooleanParamDescriptor *defineBooleanParam(const std::string &name); 1114 1115 /** @brief Define a Choice param */ 1116 ChoiceParamDescriptor *defineChoiceParam(const std::string &name); 1117 1118 #ifdef OFX_EXTENSIONS_RESOLVE 1119 /** @brief Define a String Choice param */ 1120 StrChoiceParamDescriptor* defineStrChoiceParam(const std::string& p_Name); 1121 #endif 1122 1123 /** @brief Define a group param */ 1124 GroupParamDescriptor *defineGroupParam(const std::string &name); 1125 1126 /** @brief Define a Page param */ 1127 PageParamDescriptor *definePageParam(const std::string &name); 1128 1129 /** @brief Define a push button param */ 1130 PushButtonParamDescriptor *definePushButtonParam(const std::string &name); 1131 1132 /** @brief Define a parametric param */ 1133 ParametricParamDescriptor* defineParametricParam(const std::string &name); 1134 1135 /** @brief Define a custom param */ 1136 CustomParamDescriptor *defineCustomParam(const std::string &name); 1137 1138 1139 /** @brief Fetch an integer param */ 1140 IntParamDescriptor *fetchIntParam(const std::string &name) const; 1141 1142 /** @brief Fetch a 2D integer param */ 1143 Int2DParamDescriptor *fetchInt2DParam(const std::string &name) const; 1144 1145 /** @brief Fetch a 3D integer param */ 1146 Int3DParamDescriptor *fetchInt3DParam(const std::string &name) const; 1147 1148 /** @brief Fetch an double param */ 1149 DoubleParamDescriptor *fetchDoubleParam(const std::string &name) const; 1150 1151 /** @brief Fetch a 2D double param */ 1152 Double2DParamDescriptor *fetchDouble2DParam(const std::string &name) const; 1153 1154 /** @brief Fetch a 3D double param */ 1155 Double3DParamDescriptor *fetchDouble3DParam(const std::string &name) const; 1156 1157 /** @brief Fetch a string param */ 1158 StringParamDescriptor *fetchStringParam(const std::string &name) const; 1159 1160 /** @brief Fetch a RGBA param */ 1161 RGBAParamDescriptor *fetchRGBAParam(const std::string &name) const; 1162 1163 /** @brief Fetch an RGB param */ 1164 RGBParamDescriptor *fetchRGBParam(const std::string &name) const; 1165 1166 /** @brief Fetch a Boolean param */ 1167 BooleanParamDescriptor *fetchBooleanParam(const std::string &name) const; 1168 1169 /** @brief Fetch a Choice param */ 1170 ChoiceParamDescriptor *fetchChoiceParam(const std::string &name) const; 1171 1172 /** @brief Fetch a group param */ 1173 GroupParamDescriptor *fetchGroupParam(const std::string &name) const; 1174 1175 /** @brief Fetch a page param */ 1176 PageParamDescriptor *fetchPageParam(const std::string &name) const; 1177 1178 /** @brief Fetch a push button param */ 1179 PushButtonParamDescriptor *fetchPushButtonParam(const std::string &name) const; 1180 1181 /** @brief Fetch a custom param */ 1182 CustomParamDescriptor *fetchCustomParam(const std::string &name) const; 1183 1184 /** @brief Fetch a parametric param */ 1185 ParametricParamDescriptor *fetchParametricParam(const std::string &name) const; 1186 }; 1187 1188 //////////////////////////////////////////////////////////////////////////////// 1189 /** @brief Base class for all param instances */ 1190 class Param { 1191 protected : 1192 // don't ever use these! 1193 Param &operator=(const Param &/*v1*/) {assert(false); return *this;} Param(const Param & v)1194 Param(const Param &v) : _paramSet(v._paramSet) {assert(false); } Param(void)1195 Param(void) {assert(false);} 1196 1197 protected : 1198 const ParamSet *_paramSet; // who do I belong to 1199 std::string _paramName; 1200 ParamTypeEnum _paramType; 1201 PropertySet _paramProps; 1202 OfxParamHandle _paramHandle; 1203 1204 /** @brief hidden constructor */ 1205 Param(const ParamSet *paramSet, const std::string &name, ParamTypeEnum type, OfxParamHandle handle); 1206 1207 friend class ParamSet; 1208 public : 1209 /** @brief dtor */ 1210 virtual ~Param(); 1211 1212 /** @brief get name */ 1213 const std::string &getName(void) const; 1214 1215 /** @brief, set the label property in a param */ 1216 void setLabel(const std::string &label); 1217 1218 /** @brief, set the label properties in a param */ 1219 void setLabels(const std::string &label, const std::string &shortLabel, const std::string &longLabel); 1220 1221 /** @brief return the derived type of this parameter */ getType(void)1222 ParamTypeEnum getType(void) const {return _paramType;} 1223 1224 /** @brief set the secretness of the param, defaults to false */ 1225 void setIsSecret(bool v); 1226 1227 /** @brief whether the param is secret and disabled, defaults to false */ setIsSecretAndDisabled(bool v)1228 void setIsSecretAndDisabled(bool v) { setEnabled(!v); setIsSecret(v); } 1229 1230 /** @brief set the param hint */ 1231 void setHint(const std::string &hint); 1232 1233 /** @brief whether the param is enabled */ 1234 void setEnabled(bool v); 1235 1236 /** @brief set the param data ptr */ 1237 void setDataPtr(void* ptr); 1238 1239 /** @brief fetch the label */ 1240 void getLabel(std::string &label) const; 1241 1242 /** @brief fetch the labels */ 1243 void getLabels(std::string &label, std::string &shortLabel, std::string &longLabel) const; 1244 1245 /** @brief get whether the param is secret */ 1246 bool getIsSecret(void) const; 1247 1248 /** @brief whether the param is enabled */ 1249 bool getIsEnable(void) const; 1250 1251 /** @brief get the param data ptr */ 1252 void* getDataPtr(void) const; 1253 1254 /** @brief get the param hint */ 1255 std::string getHint(void) const; 1256 1257 /** @brief get the script name */ 1258 std::string getScriptName(void) const; 1259 1260 /** @brief get the group param that is the parent of this one */ 1261 GroupParam *getParent(void) const; 1262 1263 /** @brief get the icon file name (SVG or PNG) */ 1264 std::string getIcon(bool pngFormat) const; 1265 1266 bool getHostHasNativeOverlayHandle() const; 1267 1268 #ifdef OFX_EXTENSIONS_NATRON 1269 /*Set the label of the parameter that should be displayed on the host viewport*/ 1270 void setInViewportLabel(const std::string& label); 1271 1272 /*Set whether the parameter should be secret or not in the host viewport. This is only relevant if the parameter has been added to the kNatronOfxImageEffectPropInViewerContextParamsOrder property on the image effect descriptor.*/ 1273 void setInViewportIsSecret(bool secret); 1274 #endif 1275 1276 }; 1277 1278 //////////////////////////////////////////////////////////////////////////////// 1279 /** @brief Wraps up a value holding param */ 1280 class ValueParam : public Param { 1281 protected : 1282 mDeclareProtectedAssignAndCCBase(ValueParam,Param); ValueParam(void)1283 ValueParam(void) {assert(false);} 1284 protected : 1285 /** @brief hidden constructor */ 1286 ValueParam(const ParamSet *paramSet, const std::string &name, ParamTypeEnum type, OfxParamHandle handle); 1287 1288 friend class ParamSet; 1289 public : 1290 /** @brief dtor */ 1291 ~ValueParam(); 1292 1293 /** @brief Set's whether the value of the param is significant (ie: affects the rendered image) */ 1294 void setEvaluateOnChange(bool v); 1295 1296 /** @brief is the param animating */ 1297 bool getIsAnimating(void) const; 1298 1299 /** @brief is the param animating */ 1300 bool getIsAutoKeying(void) const; 1301 1302 /** @brief is the param animating */ 1303 bool getIsPersistent(void) const; 1304 1305 /** @brief Get's whether the value of the param is significant (ie: affects the rendered image) */ 1306 bool getEvaluateOnChange(void) const; 1307 1308 /** @brief Get's whether the value of the param is significant (ie: affects the rendered image) */ 1309 CacheInvalidationEnum getCacheInvalidation(void) const; 1310 1311 /** @brief if the param is animating, the number of keys in it, otherwise 0 */ 1312 unsigned int getNumKeys(void); 1313 1314 /** @brief get the time of the nth key, nth must be between 0 and getNumKeys-1 */ 1315 double getKeyTime(int nthKey) OFX_THROW2(OFX::Exception::Suite, std::out_of_range); 1316 1317 /** @brief find the index of a key by a time */ 1318 int getKeyIndex(double time, 1319 KeySearchEnum searchDir); 1320 1321 /** @brief deletes a key at the given time */ 1322 void deleteKeyAtTime(double time); 1323 1324 /** @brief delete all the keys */ 1325 void deleteAllKeys(void); 1326 1327 /** @brief copy parameter from another, including any animation etc... */ 1328 void copyFrom(const ValueParam& from, OfxTime dstOffset, const OfxRangeD *frameRange); 1329 1330 #ifdef OFX_EXTENSIONS_VEGAS 1331 /** @brief gets the interpolation type of a key at the given time */ 1332 VegasInterpolationEnum getKeyInterpolation(double time); 1333 1334 /** @brief sets the interpolation type of a key at the given time */ 1335 void setKeyInterpolation(double time, VegasInterpolationEnum interpolation); 1336 #endif 1337 }; 1338 1339 //////////////////////////////////////////////////////////////////////////////// 1340 /** @brief Wraps up an integer param */ 1341 class IntParam : public ValueParam { 1342 protected : 1343 mDeclareProtectedAssignAndCCBase(IntParam,ValueParam); IntParam(void)1344 IntParam(void) {assert(false);} 1345 1346 protected : 1347 /** @brief hidden constructor */ 1348 IntParam(const ParamSet *paramSet, const std::string &name, OfxParamHandle handle); 1349 1350 friend class ParamSet; 1351 public : 1352 /** @brief set the default value */ 1353 void setDefault(int v); 1354 1355 /** @brief set the hard min/max range, default is INT_MIN, INT_MAX */ 1356 void setRange(int min, int max); 1357 1358 /** @brief set the display min and max, default is to be the same as the range param */ 1359 void setDisplayRange(int min, int max); 1360 1361 /** @brief get the default value */ 1362 void getDefault(int &v); 1363 1364 /** @brief get the default value */ getDefault(void)1365 int getDefault(void) {int v; getDefault(v); return v;} 1366 1367 /** @brief set the hard min/max range, default is INT_MIN, INT_MAX */ 1368 void getRange(int &min, int &max); 1369 1370 /** @brief set the display min and max, default is to be the same as the range param */ 1371 void getDisplayRange(int &min, int &max); 1372 1373 /** @brief get value */ 1374 void getValue(int &v) const; 1375 1376 /** @brief and a nicer one */ getValue(void)1377 int getValue(void) const {int v; getValue(v); return v;} 1378 1379 /** @brief get the value at a time */ 1380 void getValueAtTime(double t, int &v) const; 1381 1382 /** @brief and a nicer one */ getValueAtTime(double t)1383 int getValueAtTime(double t) const {int v; getValueAtTime(t, v); return v;} 1384 1385 /** @brief set value */ 1386 void setValue(int v); 1387 1388 /** @brief set the value at a time, implicitly adds a keyframe */ 1389 void setValueAtTime(double t, int v); 1390 1391 /** @brief delete all keys and set to default value */ 1392 void resetToDefault(); 1393 }; 1394 1395 //////////////////////////////////////////////////////////////////////////////// 1396 /** @brief Wraps up an integer param */ 1397 class Int2DParam : public ValueParam { 1398 protected : 1399 mDeclareProtectedAssignAndCCBase(Int2DParam,ValueParam); Int2DParam(void)1400 Int2DParam(void) {assert(false);} 1401 1402 protected : 1403 /** @brief hidden constructor */ 1404 Int2DParam(const ParamSet *paramSet, const std::string &name, OfxParamHandle handle); 1405 1406 friend class ParamSet; 1407 public : 1408 /** @brief set the default value, default is 0 */ 1409 void setDefault(int x, int y); 1410 1411 /** @brief set the default value, default is 0 */ setDefault(const OfxPointI & v)1412 void setDefault(const OfxPointI &v) {setDefault(v.x, v.y);} 1413 1414 /** @brief set the hard min/max range, default is INT_MIN, INT_MAX */ 1415 void setRange(int minX, int minY, 1416 int maxX, int maxY); 1417 1418 /** @brief set the display min and max, default is to be the same as the range param */ 1419 void setDisplayRange(int minX, int minY, 1420 int maxX, int maxY); 1421 1422 /** @brief get the default value */ 1423 void getDefault(int &x, int &y); 1424 1425 /** @brief get the default value */ getDefault(void)1426 OfxPointI getDefault(void) {OfxPointI v; getDefault(v.x, v.y); return v;} 1427 1428 /** @brief set the hard min/max range, default is INT_MIN, INT_MAX */ 1429 void getRange(int &minX, int &minY, 1430 int& maxX, int &maxY); 1431 1432 /** @brief set the display min and max, default is to be the same as the range param */ 1433 void getDisplayRange(int &minX, int &minY, 1434 int &maxX, int &maxY); 1435 1436 /** @brief get value */ 1437 void getValue(int &x, int &y) const; 1438 1439 /** @brief get the value */ getValue(void)1440 OfxPointI getValue(void) const {OfxPointI v; getValue(v.x, v.y); return v;} 1441 1442 /** @brief get the value at a time */ 1443 void getValueAtTime(double t, int &x, int &y) const; 1444 1445 /** @brief get the value */ getValueAtTime(double t)1446 OfxPointI getValueAtTime(double t) const {OfxPointI v; getValueAtTime(t, v.x, v.y); return v;} 1447 1448 /** @brief set value */ 1449 void setValue(int x, int y); 1450 1451 /** @brief set the current value */ setValue(const OfxPointI & v)1452 void setValue(const OfxPointI &v) {setValue(v.x, v.y);} 1453 1454 /** @brief set the value at a time, implicitly adds a keyframe */ 1455 void setValueAtTime(double t, int x, int y); 1456 1457 /** @brief set the current value */ setValueAtTime(double t,const OfxPointI & v)1458 void setValueAtTime(double t, const OfxPointI &v) {setValueAtTime(t, v.x, v.y);} 1459 1460 /** @brief delete all keys and set to default value */ 1461 void resetToDefault(); 1462 }; 1463 1464 //////////////////////////////////////////////////////////////////////////////// 1465 /** @brief Wraps up an integer param */ 1466 class Int3DParam : public ValueParam { 1467 protected : 1468 mDeclareProtectedAssignAndCCBase(Int3DParam,ValueParam); Int3DParam(void)1469 Int3DParam(void) {assert(false);} 1470 1471 protected : 1472 /** @brief hidden constructor */ 1473 Int3DParam(const ParamSet *paramSet, const std::string &name, OfxParamHandle handle); 1474 1475 friend class ParamSet; 1476 public : 1477 /** @brief set the default value, default is 0 */ 1478 void setDefault(int x, int y, int z); 1479 1480 /** @brief set the hard min/max range, default is INT_MIN, INT_MAX */ 1481 void setRange(int minX, int minY, int minZ, 1482 int maxX, int maxY, int maxZ); 1483 1484 /** @brief set the display min and max, default is to be the same as the range param */ 1485 void setDisplayRange(int minX, int minY, int minZ, 1486 int maxX, int maxY, int maxZ); 1487 1488 /** @brief get the default value */ 1489 void getDefault(int &x, int &y, int &z); 1490 1491 /** @brief set the hard min/max range, default is INT_MIN, INT_MAX */ 1492 void getRange(int &minX, int &minY, int &minZ, 1493 int& maxX, int &maxY, int &maxZ); 1494 1495 /** @brief set the display min and max, default is to be the same as the range param */ 1496 void getDisplayRange(int &minX, int &minY, int &minZ, 1497 int& maxX, int &maxY, int &maxZ); 1498 1499 /** @brief get value */ 1500 void getValue(int &x, int &y, int &z) const; 1501 1502 /** @brief get the value */ getValue(void)1503 Ofx3DPointI getValue(void) const {Ofx3DPointI v; getValue(v.x, v.y, v.z); return v;} 1504 1505 /** @brief get the value at a time */ 1506 void getValueAtTime(double t, int &x, int &y, int &z) const; 1507 1508 /** @brief get the value at a time */ getValueAtTime(double t)1509 Ofx3DPointI getValueAtTime(double t) const {Ofx3DPointI v; getValueAtTime(t, v.x, v.y, v.z); return v;} 1510 1511 /** @brief set value */ 1512 void setValue(int x, int y, int z); 1513 1514 /** @brief set the value at a time, implicitly adds a keyframe */ 1515 void setValueAtTime(double t, int x, int y, int z); 1516 1517 /** @brief delete all keys and set to default value */ 1518 void resetToDefault(); 1519 }; 1520 1521 //////////////////////////////////////////////////////////////////////////////// 1522 /** @brief Common base to all double param types */ 1523 class BaseDoubleParam : public ValueParam { 1524 protected : 1525 mDeclareProtectedAssignAndCCBase(BaseDoubleParam,ValueParam); BaseDoubleParam(void)1526 BaseDoubleParam(void) {assert(false);} 1527 1528 protected : 1529 /** @brief hidden constructor */ 1530 BaseDoubleParam(const ParamSet *paramSet, const std::string &name, ParamTypeEnum type, OfxParamHandle handle); 1531 1532 friend class ParamSet; 1533 public : 1534 /** @brief set the sensitivity of any gui slider */ 1535 void setIncrement(double v); 1536 1537 /** @brief set the number of digits printed after a decimal point in any gui */ 1538 void setDigits(int v); 1539 1540 /** @brief get the sensitivity of any gui slider */ 1541 void getIncrement(double &v); 1542 1543 /** @brief get the number of digits printed after a decimal point in any gui */ 1544 void getDigits(int &v); 1545 1546 /** @brief get the type of the double param */ 1547 void getDoubleType(DoubleTypeEnum &v); 1548 1549 /** @brief get the type of coordinate system for default values */ 1550 void getDefaultCoordinateSystem(DefaultCoordinateSystemEnum &v); 1551 }; 1552 1553 //////////////////////////////////////////////////////////////////////////////// 1554 /** @brief Wraps up an doubleeger param */ 1555 class DoubleParam : public BaseDoubleParam { 1556 protected : 1557 mDeclareProtectedAssignAndCCBase(DoubleParam,BaseDoubleParam); DoubleParam(void)1558 DoubleParam(void) {assert(false);} 1559 1560 protected : 1561 /** @brief hidden constructor */ 1562 DoubleParam(const ParamSet *paramSet, const std::string &name, OfxParamHandle handle); 1563 1564 friend class ParamSet; 1565 public : 1566 /** @brief set the default value */ 1567 void setDefault(double v); 1568 1569 /** @brief if the double type is Absolute time, show a time marker on the time line if possible */ 1570 void setShowTimeMarker(bool v); 1571 1572 /** @brief set the hard min/max range, default is DOUBLE_MIN, DOUBLE_MAX */ 1573 void setRange(double min, double max); 1574 1575 /** @brief set the display min and max, default is to be the same as the range param */ 1576 void setDisplayRange(double min, double max); 1577 1578 /** @brief get the default value */ 1579 void getDefault(double &v); 1580 1581 /** @brief get the default value */ getDefault(void)1582 double getDefault(void) {double v; getDefault(v); return v;} 1583 1584 /** @brief set the hard min/max range, default is DOUBLE_MIN, DOUBLE_MAX */ 1585 void getRange(double &min, double &max); 1586 1587 /** @brief set the display min and max, default is to be the same as the range param */ 1588 void getDisplayRange(double &min, double &max); 1589 1590 /** @brief get value */ 1591 void getValue(double &v) const; 1592 1593 /** @brief get value */ getValue(void)1594 double getValue(void) const {double v; getValue(v); return v;} 1595 1596 /** @brief get the value at a time */ 1597 void getValueAtTime(double t, double &v) const; 1598 1599 /** @brief get value */ getValueAtTime(double t)1600 double getValueAtTime(double t) const {double v; getValueAtTime(t, v); return v;} 1601 1602 /** @brief set value */ 1603 void setValue(double v); 1604 1605 /** @brief set the value at a time, implicitly adds a keyframe */ 1606 void setValueAtTime(double t, double v); 1607 1608 /** @brief differentiate the param */ 1609 void differentiate(double t, double &v); 1610 1611 /** @brief differentiate the param */ differentiate(double t)1612 double differentiate(double t) {double v; differentiate(t, v); return v;} 1613 1614 /** @brief integrate the param */ 1615 void integrate(double t1, double t2, double &v); 1616 1617 /** @brief integrate the param */ integrate(double t1,double t2)1618 double integrate(double t1, double t2) {double v; integrate(t1, t2, v); return v;} 1619 1620 /** @brief delete all keys and set to default value */ 1621 void resetToDefault(); 1622 }; 1623 1624 //////////////////////////////////////////////////////////////////////////////// 1625 /** @brief Wraps up an doubleeger param */ 1626 class Double2DParam : public BaseDoubleParam { 1627 protected : 1628 mDeclareProtectedAssignAndCCBase(Double2DParam,BaseDoubleParam); Double2DParam(void)1629 Double2DParam(void) {assert(false);} 1630 1631 protected : 1632 /** @brief hidden constructor */ 1633 Double2DParam(const ParamSet *paramSet, const std::string &name, OfxParamHandle handle); 1634 1635 friend class ParamSet; 1636 public : 1637 /** @brief set the default value, default is 0 */ 1638 void setDefault(double x, double y); 1639 1640 /** @brief set the hard min/max range, default is DOUBLE_MIN, DOUBLE_MAX */ 1641 void setRange(double minX, double minY, 1642 double maxX, double maxY); 1643 1644 /** @brief set the display min and max, default is to be the same as the range param */ 1645 void setDisplayRange(double minX, double minY, 1646 double maxX, double maxY); 1647 1648 /** @brief get the default value */ 1649 void getDefault(double &x, double &y); 1650 1651 /** @brief set the hard min/max range, default is DOUBLE_MIN, DOUBLE_MAX */ 1652 void getRange(double &minX, double &minY, 1653 double& maxX, double &maxY); 1654 1655 /** @brief set the display min and max, default is to be the same as the range param */ 1656 void getDisplayRange(double &minX, double &minY, 1657 double &maxX, double &maxY); 1658 1659 /** @brief get value */ 1660 void getValue(double &x, double &y) const; 1661 1662 /** @brief get value */ getValue(void)1663 OfxPointD getValue(void) const {OfxPointD v; getValue(v.x, v.y); return v;} 1664 1665 /** @brief get the value at a time */ 1666 void getValueAtTime(double t, double &x, double &y) const; 1667 1668 /** @brief get the value */ getValueAtTime(double t)1669 OfxPointD getValueAtTime(double t) const {OfxPointD v; getValueAtTime(t, v.x, v.y); return v;} 1670 1671 /** @brief set value */ 1672 void setValue(double x, double y); 1673 1674 /** @brief set the current value */ setValue(const OfxPointD & v)1675 void setValue(const OfxPointD &v) {setValue(v.x, v.y);} 1676 1677 /** @brief set the value at a time, implicitly adds a keyframe */ 1678 void setValueAtTime(double t, double x, double y); 1679 1680 /** @brief set the value at a time, implicitly adds a keyframe */ setValueAtTime(double t,const OfxPointD & v)1681 void setValueAtTime(double t, const OfxPointD &v) {setValueAtTime(t, v.x, v.y);} 1682 1683 /** @brief differentiate the param */ 1684 void differentiate(double t, double &x, double &y); 1685 1686 /** @brief differentiate the param */ differentiate(double t)1687 OfxPointD differentiate(double t) {OfxPointD v; differentiate(t, v.x, v.y); return v;} 1688 1689 /** @brief integrate the param */ 1690 void integrate(double t1, double t2, double &x, double &y); 1691 1692 /** @brief integrate the param */ integrate(double t1,double t2)1693 OfxPointD integrate(double t1, double t2) {OfxPointD v; integrate(t1, t2, v.x, v.y); return v;} 1694 1695 /** @brief delete all keys and set to default value */ 1696 void resetToDefault(); 1697 }; 1698 1699 //////////////////////////////////////////////////////////////////////////////// 1700 /** @brief Wraps up an doubleeger param */ 1701 class Double3DParam : public BaseDoubleParam { 1702 protected : 1703 mDeclareProtectedAssignAndCCBase(Double3DParam,BaseDoubleParam); Double3DParam(void)1704 Double3DParam(void) {assert(false);} 1705 1706 protected : 1707 /** @brief hidden constructor */ 1708 Double3DParam(const ParamSet *paramSet, const std::string &name, OfxParamHandle handle); 1709 1710 friend class ParamSet; 1711 public : 1712 /** @brief set the default value, default is 0 */ 1713 void setDefault(double x, double y, double z); 1714 1715 /** @brief set the hard min/max range, default is DOUBLE_MIN, DOUBLE_MAX */ 1716 void setRange(double minX, double minY, double minZ, 1717 double maxX, double maxY, double maxZ); 1718 1719 /** @brief set the display min and max, default is to be the same as the range param */ 1720 void setDisplayRange(double minX, double minY, double minZ, 1721 double maxX, double maxY, double maxZ); 1722 1723 /** @brief get the default value */ 1724 void getDefault(double &x, double &y, double &z); 1725 1726 /** @brief set the hard min/max range, default is DOUBLE_MIN, DOUBLE_MAX */ 1727 void getRange(double &minX, double &minY, double &minZ, 1728 double& maxX, double &maxY, double &maxZ); 1729 1730 /** @brief set the display min and max, default is to be the same as the range param */ 1731 void getDisplayRange(double &minX, double &minY, double &minZ, 1732 double& maxX, double &maxY, double &maxZ); 1733 1734 /** @brief get value */ 1735 void getValue(double &x, double &y, double &z) const; 1736 1737 /** @brief get the value */ getValue(void)1738 Ofx3DPointD getValue(void) const {Ofx3DPointD v; getValue(v.x, v.y, v.z); return v;} 1739 1740 /** @brief get the value at a time */ 1741 void getValueAtTime(double t, double &x, double &y, double &z) const; 1742 1743 /** @brief get the value at a time */ getValueAtTime(double t)1744 Ofx3DPointD getValueAtTime(double t) const {Ofx3DPointD v; getValueAtTime(t, v.x, v.y, v.z); return v;} 1745 1746 /** @brief set value */ 1747 void setValue(double x, double y, double z); 1748 1749 /** @brief set the value at a time, implicitly adds a keyframe */ 1750 void setValueAtTime(double t, double x, double y, double z); 1751 1752 /** @brief differentiate the param */ 1753 void differentiate(double t, double &x, double &y, double &z); 1754 1755 /** @brief differentiate the param */ differentiate(double t)1756 Ofx3DPointD differentiate(double t) {Ofx3DPointD v; differentiate(t, v.x, v.y, v.z); return v;} 1757 1758 /** @brief integrate the param */ 1759 void integrate(double t1, double t2, double &x, double &y, double &z); 1760 1761 /** @brief integrate the param */ integrate(double t1,double t2)1762 Ofx3DPointD integrate(double t1, double t2) {Ofx3DPointD v; integrate(t1, t2, v.x, v.y, v.z); return v;} 1763 1764 /** @brief delete all keys and set to default value */ 1765 void resetToDefault(); 1766 }; 1767 1768 //////////////////////////////////////////////////////////////////////////////// 1769 /** @brief Wraps up an RGB param */ 1770 class RGBParam : public ValueParam { 1771 protected : 1772 mDeclareProtectedAssignAndCCBase(RGBParam,ValueParam); RGBParam(void)1773 RGBParam(void) {assert(false);} 1774 1775 protected : 1776 /** @brief hidden constructor */ 1777 RGBParam(const ParamSet *paramSet, const std::string &name, OfxParamHandle handle); 1778 1779 friend class ParamSet; 1780 public : 1781 /** @brief set the default value, default is 0 */ 1782 void setDefault(double r, double g, double b); 1783 1784 /** @brief get default value */ 1785 void getDefault(double &r, double &g, double &b); 1786 1787 /** @brief get value */ 1788 void getValue(double &r, double &g, double &b) const; 1789 1790 /** @brief get value */ getValue()1791 OfxRGBColourD getValue() const { OfxRGBColourD v; getValue(v.r, v.g, v.b); return v; } 1792 1793 /** @brief get the value at a time */ 1794 void getValueAtTime(double t, double &r, double &g, double &b) const; 1795 1796 /** @brief get the value at a time */ getValueAtTime(double t)1797 OfxRGBColourD getValueAtTime(double t) const { OfxRGBColourD v; getValueAtTime(t, v.r, v.g, v.b); return v; } 1798 1799 /** @brief set value */ 1800 void setValue(double r, double g, double b); 1801 1802 /** @brief set the value at a time, implicitly adds a keyframe */ 1803 void setValueAtTime(double t, double r, double g, double b); 1804 1805 /** @brief delete all keys and set to default value */ 1806 void resetToDefault(); 1807 }; 1808 1809 1810 //////////////////////////////////////////////////////////////////////////////// 1811 /** @brief Wraps up an RGB param */ 1812 class RGBAParam : public ValueParam { 1813 protected : 1814 mDeclareProtectedAssignAndCCBase(RGBAParam,ValueParam); RGBAParam(void)1815 RGBAParam(void) {assert(false);} 1816 1817 protected : 1818 /** @brief hidden constructor */ 1819 RGBAParam(const ParamSet *paramSet, const std::string &name, OfxParamHandle handle); 1820 1821 friend class ParamSet; 1822 public : 1823 /** @brief set the default value, default is 0 */ 1824 void setDefault(double r, double g, double b, double a); 1825 1826 /** @brief get default value */ 1827 void getDefault(double &r, double &g, double &b, double &a); 1828 1829 /** @brief get value */ 1830 void getValue(double &r, double &g, double &b, double &a) const; 1831 1832 /** @brief get value */ getValue()1833 OfxRGBAColourD getValue() const { OfxRGBAColourD v; getValue(v.r, v.g, v.b, v.a); return v; } 1834 1835 /** @brief get the value at a time */ 1836 void getValueAtTime(double t, double &r, double &g, double &b, double &a) const; 1837 1838 /** @brief get the value at a time */ getValueAtTime(double t)1839 OfxRGBAColourD getValueAtTime(double t) const { OfxRGBAColourD v; getValueAtTime(t, v.r, v.g, v.b, v.a); return v; } 1840 1841 /** @brief set value */ 1842 void setValue(double r, double g, double b, double a); 1843 1844 /** @brief set the value at a time, implicitly adds a keyframe */ 1845 void setValueAtTime(double t, double r, double g, double b, double a); 1846 1847 /** @brief delete all keys and set to default value */ 1848 void resetToDefault(); 1849 }; 1850 1851 //////////////////////////////////////////////////////////////////////////////// 1852 /** @brief Wraps up a string param */ 1853 class StringParam : public ValueParam { 1854 protected : 1855 mDeclareProtectedAssignAndCCBase(StringParam,ValueParam); StringParam(void)1856 StringParam(void) {assert(false);} 1857 1858 protected : 1859 /** @brief hidden constructor */ 1860 StringParam(const ParamSet *paramSet, const std::string &name, OfxParamHandle handle); 1861 1862 friend class ParamSet; 1863 1864 public : 1865 /** @brief set the default value */ 1866 void setDefault(const std::string &v); 1867 1868 /** @brief get the default value */ 1869 void getDefault(std::string &v); 1870 1871 /** @brief get value */ 1872 void getValue(std::string &v) const; 1873 1874 /** @brief get value */ getValue()1875 std::string getValue() const { std::string v; getValue( v ); return v; } 1876 1877 /** @brief get the value at a time */ 1878 void getValueAtTime(double t, std::string &v) const; 1879 1880 /** @brief get the value at a time */ getValueAtTime(double t)1881 std::string getValueAtTime( double t ) const { std::string v; getValueAtTime( t, v ); return v; } 1882 1883 /** @brief set value */ 1884 void setValue(const std::string &v); 1885 1886 /** @brief set the value at a time, implicitly adds a keyframe */ 1887 void setValueAtTime(double t, const std::string &v); 1888 1889 /** @brief delete all keys and set to default value */ 1890 void resetToDefault(); 1891 }; 1892 1893 //////////////////////////////////////////////////////////////////////////////// 1894 /** @brief Wraps up a choice param */ 1895 class ChoiceParam : public ValueParam { 1896 protected : 1897 mDeclareProtectedAssignAndCCBase(ChoiceParam,ValueParam); ChoiceParam(void)1898 ChoiceParam(void) {assert(false);} 1899 1900 protected : 1901 /** @brief hidden constructor */ 1902 ChoiceParam(const ParamSet *paramSet, const std::string &name, OfxParamHandle handle); 1903 1904 // so it can make one 1905 friend class ParamSet; 1906 public : 1907 /** @brief set the default value */ 1908 void setDefault(int v); 1909 1910 /** @brief get the default value */ 1911 void getDefault(int &v); 1912 1913 /** @brief how many options do we have */ 1914 int getNOptions(void); 1915 1916 /** @brief append an option, default is to have not there */ 1917 void appendOption(const std::string &label, const std::string& hint = "", const std::string& name = ""); 1918 1919 /** @brief set an option label */ 1920 void setOption(int item, const std::string &str); 1921 1922 /** @brief get the option label */ 1923 void getOption(int ix, std::string &v); 1924 1925 #ifdef OFX_EXTENSIONS_NATRON 1926 1927 /** @brief set an option enum */ 1928 void setEnum(int item, const std::string &name); 1929 1930 /** @brief get the option enum */ 1931 void getEnum(int ix, std::string &name); 1932 #endif 1933 1934 /** @brief get all options at once. Optionally, the label of the options can be retrieved at the same time*/ 1935 void getOptions(std::vector<std::string>* options,std::vector<std::string>* optionsHints = 0, std::vector<std::string>* optionsNames = 0); 1936 1937 /** @brief clear all the options so as to add some new ones in */ 1938 void resetOptions(const std::vector<std::string>& newEntries = std::vector<std::string>(), 1939 const std::vector<std::string>& newEntriesHint = std::vector<std::string>(), 1940 const std::vector<std::string>& newEntriesEnum = std::vector<std::string>()); 1941 1942 #ifdef OFX_EXTENSIONS_NATRON 1943 /** @brief whether the menu should be cascading, and each option contains a slash-separated path to the item, defaults to false. */ 1944 bool getIsCascading(void); 1945 1946 /** @brief Indicate whether the host can add a new choice on its own (probably via a GUI specific to this parameter). */ 1947 bool getHostCanAddOptions(); 1948 #endif 1949 1950 /** @brief get value */ 1951 void getValue(int &v) const; 1952 1953 /** @brief get value */ getValue(void)1954 int getValue(void) const {int v; getValue(v); return v;} 1955 1956 /** @brief get the value at a time */ 1957 void getValueAtTime(double t, int &v) const; 1958 1959 /** @brief get the value at a time */ getValueAtTime(double t)1960 int getValueAtTime(double t) const {int v; getValueAtTime(t, v); return v;} 1961 1962 /** @brief set value */ 1963 void setValue(int v); 1964 1965 /** @brief set the value at a time, implicitly adds a keyframe */ 1966 void setValueAtTime(double t, int v); 1967 1968 /** @brief delete all keys and set to default value */ 1969 void resetToDefault(); 1970 }; 1971 1972 #ifdef OFX_EXTENSIONS_RESOLVE 1973 //////////////////////////////////////////////////////////////////////////////// 1974 /** @brief Wraps up a string choice param */ 1975 class StrChoiceParam : public StringParam 1976 { 1977 protected : 1978 mDeclareProtectedAssignAndCCBase(StrChoiceParam, StringParam); StrChoiceParam()1979 StrChoiceParam() { assert(false); } 1980 1981 protected : 1982 /** @brief hidden constructor */ 1983 StrChoiceParam(const ParamSet* p_ParamSet, const std::string& p_Name, OfxParamHandle p_Handle); 1984 1985 // so it can make one 1986 friend class ParamSet; 1987 1988 public : 1989 /** @brief how many options do we have */ 1990 int getNOptions(); 1991 1992 /** @brief append an option */ 1993 void appendOption(const std::string& p_Enum, const std::string& p_Option); 1994 1995 /** @brief set an option */ 1996 void setOption(const std::string& p_Index, const std::string& p_Option); 1997 1998 /** @brief get the option value */ 1999 void getOption(const std::string& p_Index, std::string& p_Option); 2000 2001 /** @brief clear all the options so as to add some new ones in */ 2002 void resetOptions(); 2003 }; 2004 #endif 2005 2006 //////////////////////////////////////////////////////////////////////////////// 2007 /** @brief Wraps up a boolean param */ 2008 class BooleanParam : public ValueParam { 2009 protected : 2010 mDeclareProtectedAssignAndCCBase(BooleanParam,ValueParam); BooleanParam(void)2011 BooleanParam(void) {assert(false);} 2012 2013 protected : 2014 /** @brief hidden constructor */ 2015 BooleanParam(const ParamSet *paramSet, const std::string &name, OfxParamHandle handle); 2016 2017 // so it can make one 2018 friend class ParamSet; 2019 public : 2020 /** @brief set the default value */ 2021 void setDefault(bool v); 2022 2023 /** @brief get the default value */ 2024 void getDefault(bool &v); 2025 2026 /** @brief get the default value */ getDefault(void)2027 bool getDefault(void) {bool v; getDefault(v); return v;} 2028 2029 /** @brief get value */ 2030 void getValue(bool &v) const; 2031 2032 /** @brief get value */ getValue(void)2033 bool getValue(void) const {bool v; getValue(v); return v;} 2034 2035 /** @brief get the value at a time */ 2036 void getValueAtTime(double t, bool &v) const; 2037 2038 /** @brief get value */ getValueAtTime(double t)2039 bool getValueAtTime(double t) const {bool v; getValueAtTime(t, v); return v;} 2040 2041 /** @brief set value */ 2042 void setValue(bool v); 2043 2044 /** @brief set the value at a time, implicitly adds a keyframe */ 2045 void setValueAtTime(double t, bool v); 2046 2047 /** @brief delete all keys and set to default value */ 2048 void resetToDefault(); 2049 }; 2050 2051 //////////////////////////////////////////////////////////////////////////////// 2052 /** @brief Wraps up a group param */ 2053 class GroupParam : public Param { 2054 protected : 2055 mDeclareProtectedAssignAndCCBase(GroupParam,Param); GroupParam(void)2056 GroupParam(void) {assert(false);} 2057 2058 protected : 2059 /** @brief hidden constructor */ 2060 GroupParam(const ParamSet *paramSet, const std::string &name, OfxParamHandle handle); 2061 2062 // so it can make one 2063 friend class ParamSet; 2064 public : 2065 /** @brief check whether the group is open or closed in a hierarchical layout, defaults to true */ 2066 bool getIsOpen(); 2067 /** @brief whether the group is open or closed in a hierarchical layout */ 2068 void setOpen(const bool v); 2069 }; 2070 2071 //////////////////////////////////////////////////////////////////////////////// 2072 /** @brief Wraps up a group param */ 2073 class PageParam : public Param { 2074 protected : 2075 mDeclareProtectedAssignAndCCBase(PageParam,Param); PageParam(void)2076 PageParam(void) {assert(false);} 2077 2078 protected : 2079 /** @brief hidden constructor */ 2080 PageParam(const ParamSet *paramSet, const std::string &name, OfxParamHandle handle); 2081 2082 // so it can make one 2083 friend class ParamSet; 2084 public : 2085 }; 2086 2087 //////////////////////////////////////////////////////////////////////////////// 2088 /** @brief Wraps up a custom param, not animation support yet */ 2089 class CustomParam : public ValueParam { 2090 protected : 2091 mDeclareProtectedAssignAndCCBase(CustomParam,ValueParam); CustomParam(void)2092 CustomParam(void) {assert(false);} 2093 2094 protected : 2095 /** @brief hidden constructor */ 2096 CustomParam(const ParamSet *paramSet, const std::string &name, OfxParamHandle handle); 2097 2098 // so it can make one 2099 friend class ParamSet; 2100 public : 2101 /** @brief set the default value of the param */ 2102 void setDefault(const std::string &v); 2103 2104 /** @brief get the default value of the param */ 2105 void getDefault(std::string &v); 2106 2107 /** @brief get value */ 2108 void getValue(std::string &v) const; 2109 2110 /** @brief get value */ getValue()2111 std::string getValue() const { std::string v; getValue( v ); return v; } 2112 2113 /** @brief get the value at a time */ 2114 void getValueAtTime(double t, std::string &v) const; 2115 2116 /** @brief get the value at a time */ getValueAtTime(double t)2117 std::string getValueAtTime(double t) const { std::string v; getValueAtTime(t, v); return v; } 2118 2119 /** @brief set value */ 2120 void setValue(const std::string &v); 2121 2122 /** @brief set value */ 2123 void setValue(const char* str); 2124 2125 /** @brief set the value at a time, implicitly adds a keyframe */ 2126 void setValueAtTime(double t, const std::string &v); 2127 2128 /** @brief delete all keys and set to default value */ 2129 void resetToDefault(); 2130 }; 2131 2132 //////////////////////////////////////////////////////////////////////////////// 2133 /** @brief Wraps up a push button param, not much to it at all */ 2134 class PushButtonParam : public Param { 2135 protected : 2136 mDeclareProtectedAssignAndCCBase(PushButtonParam,Param); PushButtonParam(void)2137 PushButtonParam(void) {assert(false);} 2138 2139 protected : 2140 /** @brief hidden constructor */ 2141 PushButtonParam(const ParamSet *paramSet, const std::string &name, OfxParamHandle handle); 2142 2143 // so it can make one 2144 friend class ParamSet; 2145 public : 2146 }; 2147 2148 //////////////////////////////////////////////////////////////////////////////// 2149 /** @brief Wraps up a parametric param */ 2150 class ParametricParam : public Param { 2151 private: 2152 mDeclareProtectedAssignAndCCBase(ParametricParam,Param); ParametricParam(void)2153 ParametricParam(void) {assert( false);} 2154 2155 protected: 2156 /** @brief hidden constructor */ 2157 ParametricParam(const ParamSet* paramSet, const std::string& name, OfxParamHandle handle); 2158 2159 // so it can make one 2160 friend class ParamSet; 2161 2162 public: 2163 2164 /** @brief get the parametric range */ 2165 void getRange(double &min, double &max); 2166 2167 /** @brief set the hard min/max range, default is -DBL_MAX, DBL_MAX */ 2168 void setDimensionRange(int curveIndex, double min, double max); 2169 2170 /** @brief set the display min and max, default is to be the same as the range param */ 2171 void setDimensionDisplayRange(int curveIndex, double min, double max); 2172 2173 /** @brief set the hard min/max range, default is -DBL_MAX, DBL_MAX */ 2174 void getDimensionRange(int curveIndex, double &min, double &max); 2175 2176 /** @brief set the display min and max, default is to be the same as the range param */ 2177 void getDimensionDisplayRange(int curveIndex, double &min, double &max); 2178 2179 double getValue(int curveIndex, 2180 OfxTime time, 2181 double parametricPosition) const; 2182 2183 int getNControlPoints(int curveIndex, 2184 OfxTime time) const; 2185 2186 std::pair<double, double> getNthControlPoint(int curveIndex, 2187 OfxTime time, 2188 int nthCtl) const; 2189 2190 void setNthControlPoints(int curveIndex, 2191 OfxTime time, 2192 int nthCtl, 2193 double key, 2194 double value, 2195 bool addAnimationKey); 2196 2197 void setNthControlPoints(int curveIndex, 2198 OfxTime time, 2199 int nthCtl, 2200 std::pair<double, double> ctrlPoint, 2201 bool addAnimationKey); 2202 2203 void addControlPoint(int curveIndex, 2204 OfxTime time, 2205 double key, 2206 double value, 2207 bool addAnimationKey); 2208 2209 void deleteControlPoint(int curveIndex, 2210 int nthCtl); 2211 2212 void deleteControlPoint(int curveIndex); 2213 }; 2214 2215 #ifdef OFX_EXTENSIONS_NUKE 2216 //////////////////////////////////////////////////////////////////////////////// 2217 /** @brief Wraps up a camera param */ 2218 class CameraParam : public Param { 2219 private: 2220 mDeclareProtectedAssignAndCCBase(CameraParam,Param); CameraParam(void)2221 CameraParam(void) {assert(false);} 2222 2223 protected: 2224 /** @brief hidden constructor */ 2225 CameraParam(/*OfxImageEffectHandle imageEffectHandle, */const ParamSet* paramSet, const std::string& name, NukeOfxCameraHandle handle); 2226 2227 // so it can make one 2228 friend class ParamSet; 2229 2230 public: 2231 Param* getParameter( const std::string& name ); 2232 2233 private: 2234 //OfxImageEffectHandle _imageEffectHandle; 2235 }; 2236 #endif 2237 2238 //////////////////////////////////////////////////////////////////////////////// 2239 /** @brief A set of parameters in a plugin instance */ 2240 class ParamSet { 2241 protected : 2242 mDeclareProtectedAssignAndCC(ParamSet); 2243 ParamTypeEnum getParamType(const std::string& name) const; 2244 private : 2245 /** @brief Properties that belong to this param set */ 2246 PropertySet _paramSetProps; 2247 2248 /** @brief Parameter set handle */ 2249 OfxParamSetHandle _paramSetHandle; 2250 2251 /** @brief Set of all previously fetched parameters, created on demand */ 2252 mutable std::map<std::string, Param *> _fetchedParams; 2253 2254 /** @brief see if we have a param of the given name in out map */ 2255 Param *findPreviouslyFetchedParam(const std::string &name) const; 2256 2257 /** @brief calls the raw OFX routine to define a param */ 2258 void fetchRawParam(const std::string &name, ParamTypeEnum paramType, OfxParamHandle &handle) const; 2259 2260 /** @brief Fetch a param of the given name and type */ 2261 template <class T> void fetchParam(const std::string & name,ParamTypeEnum paramType,T * & paramPtr)2262 fetchParam(const std::string &name, ParamTypeEnum paramType, T * ¶mPtr) const 2263 { 2264 paramPtr = NULL; 2265 2266 // have we made it already in this param set and is it an int? 2267 if(Param *param = findPreviouslyFetchedParam(name)) { 2268 if(param->getType() == paramType) { 2269 paramPtr = (T *) param; // could be a dynamic cast here 2270 } 2271 else 2272 throw OFX::Exception::TypeRequest("Fetching param and attempting to return the wrong type"); 2273 } 2274 else { 2275 // ok define one and add it in 2276 OfxParamHandle paramHandle; 2277 fetchRawParam(name, paramType, paramHandle); 2278 2279 // make out support descriptor class 2280 paramPtr = new T(this, name, paramHandle); 2281 2282 // add it to our map of described ones 2283 _fetchedParams[name] = paramPtr; 2284 } 2285 } 2286 2287 protected : 2288 /** @brief Hidden ctor */ 2289 ParamSet(void); 2290 2291 /** @brief set the param set handle */ 2292 void setParamSetHandle(OfxParamSetHandle h); 2293 2294 public : 2295 virtual ~ParamSet(); 2296 2297 bool paramExists(const std::string& name) const; 2298 2299 /// open an undoblock 2300 void beginEditBlock(const std::string &name); 2301 2302 /// close an undoblock 2303 void endEditBlock(); 2304 2305 Param* getParam(const std::string& name) const; 2306 2307 /** @brief Fetch an integer param */ 2308 IntParam *fetchIntParam(const std::string &name) const; 2309 2310 /** @brief Fetch a 2D integer param */ 2311 Int2DParam *fetchInt2DParam(const std::string &name) const; 2312 2313 /** @brief Fetch a 3D integer param */ 2314 Int3DParam *fetchInt3DParam(const std::string &name) const; 2315 2316 /** @brief Fetch an double param */ 2317 DoubleParam *fetchDoubleParam(const std::string &name) const; 2318 2319 /** @brief Fetch a 2D double param */ 2320 Double2DParam *fetchDouble2DParam(const std::string &name) const; 2321 2322 /** @brief Fetch a 3D double param */ 2323 Double3DParam *fetchDouble3DParam(const std::string &name) const; 2324 2325 /** @brief Fetch a string param */ 2326 StringParam *fetchStringParam(const std::string &name) const; 2327 2328 /** @brief Fetch a RGBA param */ 2329 RGBAParam *fetchRGBAParam(const std::string &name) const; 2330 2331 /** @brief Fetch an RGB param */ 2332 RGBParam *fetchRGBParam(const std::string &name) const; 2333 2334 /** @brief Fetch a Boolean param */ 2335 BooleanParam *fetchBooleanParam(const std::string &name) const; 2336 2337 /** @brief Fetch a Choice param */ 2338 ChoiceParam *fetchChoiceParam(const std::string &name) const; 2339 2340 #ifdef OFX_EXTENSIONS_RESOLVE 2341 /** @brief Fetch a String Choice param */ 2342 StrChoiceParam* fetchStrChoiceParam(const std::string& p_Name) const; 2343 #endif 2344 2345 /** @brief Fetch a group param */ 2346 GroupParam *fetchGroupParam(const std::string &name) const; 2347 2348 /** @brief Fetch a page param */ 2349 PageParam *fetchPageParam(const std::string &name) const; 2350 2351 /** @brief Fetch a push button param */ 2352 PushButtonParam *fetchPushButtonParam(const std::string &name) const; 2353 2354 /** @brief Fetch a custom param */ 2355 CustomParam *fetchCustomParam(const std::string &name) const; 2356 2357 /** @brief Fetch a parametric param */ 2358 ParametricParam* fetchParametricParam(const std::string &name) const; 2359 }; 2360 }; 2361 2362 // undeclare the protected assign and CC macro 2363 #undef mDeclareProtectedAssignAndCC 2364 #undef mDeclareProtectedAssignAndCCBase 2365 2366 #endif 2367