-
Notifications
You must be signed in to change notification settings - Fork 144
Expand file tree
/
Copy pathofxsParam.h
More file actions
1841 lines (1400 loc) · 69.3 KB
/
ofxsParam.h
File metadata and controls
1841 lines (1400 loc) · 69.3 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
#ifndef _ofxsParam_H_
#define _ofxsParam_H_
/*
OFX Support Library, a library that skins the OFX plug-in API with C++ classes.
Copyright (C) 2004-2005 The Open Effects Association Ltd
Author Bruno Nicoletti bruno@thefoundry.co.uk
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
* Neither the name The Open Effects Association Ltd, nor the names of its
contributors may be used to endorse or promote products derived from this
software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
The Open Effects Association Ltd
1 Wardour St
London W1D 6PA
England
*/
/** @file This file contains core code that wraps OFX parameters with C++ classes.
This file only holds code that is visible to a plugin implementation, and so hides much
of the direct OFX objects and any library side only functions.
The classes that skin parameters are broken into two sets, those used during the description phase,
eg OFX::IntParamDescriptor and those representing instances eg, OFX::IntParamInstance. The members on
each represent the actions that can be carried out on those particular OFX objects.
*/
#include <memory>
#include "ofxsCore.h"
#include "extensions/nuke/fnPublicOfxExtensions.h"
/** @brief Nasty macro used to define empty protected copy ctors and assign ops */
#define mDeclareProtectedAssignAndCC(CLASS) \
CLASS &operator=(const CLASS &) {assert(false); return *this;} \
CLASS(const CLASS &) {assert(false); }
#define mDeclareProtectedAssignAndCCBase(CLASS,BASE) \
CLASS &operator=(const CLASS &) {assert(false); return *this;} \
CLASS(const CLASS &c) : BASE(c) {assert(false); }
/** @brief The core 'OFX Support' namespace, used by plugin implementations. All code for these are defined in the common support libraries.
*/
namespace OFX {
class ParamInteractDescriptor;
/* forward class declarations of the descriptors */
class ParamDescriptor;
class ValueParamDescriptor;
class IntParamDescriptor;
class Int2DParamDescriptor;
class Int3DParamDescriptor;
class DoubleParamDescriptor;
class Double2DParamDescriptor;
class Double3DParamDescriptor;
class StringParamDescriptor;
class RGBAParamDescriptor;
class RGBParamDescriptor;
class BooleanParamDescriptor;
class ChoiceParamDescriptor;
class GroupParamDescriptor;
class PageParamDescriptor;
class PushButtonParamDescriptor;
class CustomParamDescriptor;
class ParamSetDescriptor;
/* forward class declarations of the instances */
class Param;
class ValueParam;
class IntParam;
class Int2DParam;
class Int3DParam;
class DoubleParam;
class Double2DParam;
class Double3DParam;
class RGBAParam;
class RGBParam;
class StringParam;
class BooleanParam;
class ChoiceParam;
class CustomParam;
class GroupParam;
class PageParam;
class PushButtonParam;
class ParamSet;
/** @brief Enumerates the different types of parameter */
enum ParamTypeEnum {eDummyParam,
eStringParam,
eIntParam,
eInt2DParam,
eInt3DParam,
eDoubleParam,
eDouble2DParam,
eDouble3DParam,
eRGBParam,
eRGBAParam,
eBooleanParam,
eChoiceParam,
eCustomParam,
eGroupParam,
ePageParam,
ePushButtonParam,
eParametricParam,
};
/** @brief Enumerates the different types of cache invalidation */
enum CacheInvalidationEnum {eCacheInvalidateValueChange,
eCacheInvalidateValueChangeToEnd,
eCacheInvalidateValueAll};
/** @brief Enumerates how we search for keys in an animating parameter */
enum KeySearchEnum {eKeySearchBackwards,
eKeySearchNear,
eKeySearchForwards};
/** @brief Enumerates the differing types of string params */
enum StringTypeEnum {
eStringTypeSingleLine,
eStringTypeMultiLine,
eStringTypeFilePath,
eStringTypeDirectoryPath,
eStringTypeLabel,
eStringTypeRichTextFormat
};
/** @brief Enumerates the differing types of double params */
enum DoubleTypeEnum {
eDoubleTypePlain, //!< parameter has no special interpretation
eDoubleTypeAngle, //!< parameter is to be interpretted as an angle
eDoubleTypeScale, //!< parameter is to be interpretted as a scale factor
eDoubleTypeTime, //!< parameter represents a time value (1D only)
eDoubleTypeAbsoluteTime, //!< parameter represents an absolute time value (1D only),
eDoubleTypeX, //!< a size in the X dimension dimension (1D only), new for 1.2
eDoubleTypeXAbsolute, //!< a position in the X dimension (1D only), new for 1.2
eDoubleTypeY, //!< a size in the Y dimension dimension (1D only), new for 1.2
eDoubleTypeYAbsolute, //!< a position in the X dimension (1D only), new for 1.2
eDoubleTypeXY, //!< a size in the X and Y dimension (2D only), new for 1.2
eDoubleTypeXYAbsolute, //!< a position in the X and Y dimension (2D only), new for 1.2
#ifdef kOfxParamDoubleTypeNormalisedX
eDoubleTypeNormalisedX, //!< normalised size with respect to the project's X dimension (1D only), deprecated for 1.2
eDoubleTypeNormalisedY, //!< normalised absolute position on the X axis (1D only), deprecated for 1.2
eDoubleTypeNormalisedXAbsolute, //!< normalised size wrt to the project's Y dimension (1D only), deprecated for 1.2
eDoubleTypeNormalisedYAbsolute, //!< normalised absolute position on the Y axis (1D only), deprecated for 1.2
eDoubleTypeNormalisedXY, //!< normalised to the project's X and Y size (2D only), deprecated for 1.2
eDoubleTypeNormalisedXYAbsolute, //!< normalised to the projects X and Y size, and is an absolute position on the image plane, deprecated for 1.2
#endif
};
enum LayoutHintEnum
{
eLayoutHintNormal = kOfxParamPropLayoutHintNormal,
eLayoutHintDivider = kOfxParamPropLayoutHintDivider,
eLayoutHintNoNewLine = kOfxParamPropLayoutHintNoNewLine
};
/** @brief Enumerates the differing types of coordinate system for default values */
enum DefaultCoordinateSystemEnum {
eCoordinatesCanonical, //!< canonical coordinate system
eCoordinatesNormalised, //!< normalized coordinate system
};
/** @brief turns a ParamTypeEnum into the char * that raw OFX uses */
const char *
mapParamTypeEnumToString(ParamTypeEnum v);
////////////////////////////////////////////////////////////////////////////////
/** @brief Base class for all param descriptors */
class ParamDescriptor {
protected :
mDeclareProtectedAssignAndCC(ParamDescriptor);
ParamDescriptor(void) {assert(false);}
protected :
std::string _paramName;
ParamTypeEnum _paramType;
PropertySet _paramProps;
/** @brief hidden constructors */
ParamDescriptor(const std::string &name, ParamTypeEnum type, OfxPropertySetHandle props);
friend class ParamSetDescriptor;
public :
/** @brief dtor */
virtual ~ParamDescriptor();
ParamTypeEnum getType(void) const {return _paramType;}
/** @brief name */
const std::string &getName(void) const {return _paramName;}
/** @brief Get the property set */
PropertySet &getPropertySet()
{
return _paramProps;
}
/** @brief set the label property in a param */
void setLabel(const std::string &label);
/** @brief set the label properties in a param */
void setLabels(const std::string &label, const std::string &shortLabel, const std::string &longLabel);
/** @brief set the param hint */
void setHint(const std::string &hint);
/** @brief set the script name, default is the name it was created with */
void setScriptName(const std::string &hint);
/** @brief set the secretness of the param, defaults to false */
void setIsSecret(bool v);
/** @brief set the group param that is the parent of this one, default is to be ungrouped at the root level */
void setParent(const GroupParamDescriptor &v);
/** @brief set the icon file name (SVG or PNG) */
void setIcon(const std::string &v, bool pngFormat);
/** @brief whether the param is enabled, defaults to true */
void setEnabled(bool v);
bool getHostHasNativeOverlayHandle() const;
void setUseHostNativeOverlayHandle(bool use);
void setLayoutHint(const LayoutHintEnum layoutHint);
};
////////////////////////////////////////////////////////////////////////////////
/** @brief Used to implement dummy parameters for page positioning commands */
class DummyParamDescriptor : public ParamDescriptor {
public :
/** @brief ctor */
DummyParamDescriptor(const std::string &name)
: ParamDescriptor(name, eDummyParam, 0)
{}
};
////////////////////////////////////////////////////////////////////////////////
/** @brief Wraps up a value holding param */
class ValueParamDescriptor : public ParamDescriptor {
protected :
mDeclareProtectedAssignAndCCBase(ValueParamDescriptor,ParamDescriptor);
ValueParamDescriptor(void) {assert(false);}
protected :
/** @brief hidden constructor */
ValueParamDescriptor(const std::string &name, ParamTypeEnum type, OfxPropertySetHandle props);
friend class ParamSetDescriptor;
std::auto_ptr<ParamInteractDescriptor> _interact;
public :
/** @brief dtor */
~ValueParamDescriptor();
/** @brief set whether the param can animate, defaults to true in most cases */
void setAnimates(bool v);
/** @brief set whether the param is persistant, defaults to true */
void setIsPersistant(bool v);
/** @brief Set's whether the value of the param is significant (ie: affects the rendered image), defaults to true */
void setEvaluateOnChange(bool v);
/** @brief Set's how any cache should be invalidated if the parameter is changed, defaults to eCacheInvalidateValueChange */
void setCacheInvalidation(CacheInvalidationEnum v);
/// @brief Set whether the param should appear on any undo stack
void setCanUndo(bool v);
void setInteractDescriptor(ParamInteractDescriptor* desc);
};
////////////////////////////////////////////////////////////////////////////////
/** @brief Wraps up a string param */
class StringParamDescriptor : public ValueParamDescriptor {
protected :
mDeclareProtectedAssignAndCCBase(StringParamDescriptor,ValueParamDescriptor);
StringParamDescriptor(void) {assert(false);}
protected :
/** @brief hidden constructor */
StringParamDescriptor(const std::string &name, OfxPropertySetHandle props);
friend class ParamSetDescriptor;
public :
/** @brief set the default value, default is 0 */
void setDefault(const std::string &v);
/** @brief sets the kind of the string param, defaults to eStringSingleLine */
void setStringType(StringTypeEnum v);
/** @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 */
void setFilePathExists(bool v);
};
////////////////////////////////////////////////////////////////////////////////
/** @brief Wraps up an integer param */
class IntParamDescriptor : public ValueParamDescriptor {
protected :
mDeclareProtectedAssignAndCCBase(IntParamDescriptor,ValueParamDescriptor);
IntParamDescriptor(void) {assert(false);}
protected :
/** @brief hidden constructor */
IntParamDescriptor(const std::string &name, OfxPropertySetHandle props);
friend class ParamSetDescriptor;
public :
/** @brief set the default value, default is 0 */
void setDefault(int v);
/** @brief set the hard min/max range, default is INT_MIN, INT_MAX */
void setRange(int min, int max);
/** @brief set the display min and max, default is to be the same as the range param */
void setDisplayRange(int min, int max);
};
////////////////////////////////////////////////////////////////////////////////
/** @brief Wraps up an 2d integer param */
class Int2DParamDescriptor : public ValueParamDescriptor {
protected :
mDeclareProtectedAssignAndCCBase(Int2DParamDescriptor,ValueParamDescriptor);
Int2DParamDescriptor(void) {assert(false);}
protected :
/** @brief hidden constructor */
Int2DParamDescriptor(const std::string &name, OfxPropertySetHandle props);
friend class ParamSetDescriptor;
public :
/** @brief set the dimension labels */
void setDimensionLabels(const std::string &x,
const std::string &y);
/** @brief set the default value, default is 0 */
void setDefault(int x, int y);
/** @brief set the hard min/max range, default is INT_MIN, INT_MAX */
void setRange(int minX, int minY,
int maxX, int maxY);
/** @brief set the display min and max, default is to be the same as the range param */
void setDisplayRange(int minX, int minY,
int maxX, int maxY);
};
////////////////////////////////////////////////////////////////////////////////
/** @brief Wraps up an 3d integer param */
class Int3DParamDescriptor : public ValueParamDescriptor {
protected :
mDeclareProtectedAssignAndCCBase(Int3DParamDescriptor,ValueParamDescriptor);
Int3DParamDescriptor(void) {assert(false);}
protected :
/** @brief hidden constructor */
Int3DParamDescriptor(const std::string &name, OfxPropertySetHandle props);
friend class ParamSetDescriptor;
public :
/** @brief set the dimension labels */
void setDimensionLabels(const std::string &x,
const std::string &y,
const std::string &z);
/** @brief set the default value, default is 0 */
void setDefault(int x, int y, int z);
/** @brief set the hard min/max range, default is INT_MIN, INT_MAX */
void setRange(int minX, int minY, int minZ,
int maxX, int maxY, int maxZ);
/** @brief set the display min and max, default is to be the same as the range param */
void setDisplayRange(int minX, int minY, int minZ,
int maxX, int maxY, int maxZ);
};
////////////////////////////////////////////////////////////////////////////////
/** @brief Common base to all double param types */
class BaseDoubleParamDescriptor : public ValueParamDescriptor {
protected :
mDeclareProtectedAssignAndCCBase(BaseDoubleParamDescriptor,ValueParamDescriptor);
BaseDoubleParamDescriptor(void) {assert(false);}
protected :
/** @brief hidden constructor */
BaseDoubleParamDescriptor(const std::string &name, ParamTypeEnum type, OfxPropertySetHandle props);
friend class ParamSetDescriptor;
public :
/** @brief set the type of the double param, defaults to eDoubleTypePlain */
void setDoubleType(DoubleTypeEnum v);
/** @brief set the type of coordinate system for default values */
void setDefaultCoordinateSystem(DefaultCoordinateSystemEnum v);
/** @brief set the sensitivity of any gui slider */
void setIncrement(double v);
/** @brief set the number of digits printed after a decimal point in any gui */
void setDigits(int v);
};
////////////////////////////////////////////////////////////////////////////////
/** @brief Wraps up a double param */
class DoubleParamDescriptor : public BaseDoubleParamDescriptor {
protected :
mDeclareProtectedAssignAndCCBase(DoubleParamDescriptor,BaseDoubleParamDescriptor);
DoubleParamDescriptor(void) {assert(false);}
protected :
/** @brief hidden constructor */
DoubleParamDescriptor(const std::string &name, OfxPropertySetHandle props);
friend class ParamSetDescriptor;
public :
/** @brief if the double type is Absolute time, show a time marker on the time line if possible */
void setShowTimeMarker(bool v);
/** @brief set the default value, default is 0 */
void setDefault(double v);
/** @brief set the hard min/max range, default is INT_MIN, INT_MAX */
void setRange(double min, double max);
/** @brief set the display min and max, default is to be the same as the range param */
void setDisplayRange(double min, double max);
};
////////////////////////////////////////////////////////////////////////////////
/** @brief Wraps up a 2D double param */
class Double2DParamDescriptor : public BaseDoubleParamDescriptor {
protected :
mDeclareProtectedAssignAndCCBase(Double2DParamDescriptor,BaseDoubleParamDescriptor);
Double2DParamDescriptor(void) {assert(false);}
protected :
/** @brief hidden constructor */
Double2DParamDescriptor(const std::string &name, OfxPropertySetHandle props);
friend class ParamSetDescriptor;
public :
/** @brief set the dimension labels */
void setDimensionLabels(const std::string &x,
const std::string &y);
/** @brief set kOfxParamPropUseHostOverlayHandle */
void setUseHostOverlayHandle(bool v);
/** @brief set the default value, default is 0 */
void setDefault(double x, double y);
/** @brief set the hard min/max range, default is INT_MIN, INT_MAX */
void setRange(double minX, double minY,
double maxX, double maxY);
/** @brief set the display min and max, default is to be the same as the range param */
void setDisplayRange(double minX, double minY,
double maxX, double maxY);
};
////////////////////////////////////////////////////////////////////////////////
/** @brief Wraps up a 3D double param */
class Double3DParamDescriptor : public BaseDoubleParamDescriptor {
protected :
mDeclareProtectedAssignAndCCBase(Double3DParamDescriptor,BaseDoubleParamDescriptor);
Double3DParamDescriptor(void) {assert(false);}
protected :
/** @brief hidden constructor */
Double3DParamDescriptor(const std::string &name, OfxPropertySetHandle props);
friend class ParamSetDescriptor;
public :
/** @brief set the dimension labels */
void setDimensionLabels(const std::string &x,
const std::string &y,
const std::string &z);
/** @brief set the default value, default is 0 */
void setDefault(double x, double y, double z);
/** @brief set the hard min/max range, default is -DBL_MAX, DBL_MAX */
void setRange(double minX, double minY, double minZ,
double maxX, double maxY, double maxZ);
/** @brief set the display min and max, default is to be the same as the range param */
void setDisplayRange(double minX, double minY, double minZ,
double maxX, double maxY, double maxZ);
};
////////////////////////////////////////////////////////////////////////////////
/** @brief Wraps up an RGB colour param */
class RGBParamDescriptor : public ValueParamDescriptor {
protected :
mDeclareProtectedAssignAndCCBase(RGBParamDescriptor,ValueParamDescriptor);
RGBParamDescriptor(void) {assert(false);}
protected :
/** @brief hidden constructor */
RGBParamDescriptor(const std::string &name, OfxPropertySetHandle props);
// so it can make one
friend class ParamSetDescriptor;
public :
/** @brief set the dimension labels */
void setDimensionLabels(const std::string &r,
const std::string &g,
const std::string &b);
/** @brief set the default value */
void setDefault(double r, double g, double b);
/** @brief set the hard min/max range, default is 0., 1. */
void setRange(double minR, double minG, double minB,
double maxR, double maxG, double maxB);
/** @brief set the display min and max, default is to be the same as the range param */
void setDisplayRange(double minR, double minG, double minB,
double maxR, double maxG, double maxB);
};
////////////////////////////////////////////////////////////////////////////////
/** @brief Wraps up an RGBA colour param */
class RGBAParamDescriptor : public ValueParamDescriptor {
protected :
mDeclareProtectedAssignAndCCBase(RGBAParamDescriptor,ValueParamDescriptor);
RGBAParamDescriptor(void) {assert(false);}
protected :
/** @brief hidden constructor */
RGBAParamDescriptor(const std::string &name, OfxPropertySetHandle props);
// so it can make one
friend class ParamSetDescriptor;
public :
/** @brief set the dimension labels */
void setDimensionLabels(const std::string &r,
const std::string &g,
const std::string &b,
const std::string &a);
/** @brief set the default value */
void setDefault(double r, double g, double b, double a);
/** @brief set the hard min/max range, default is 0., 1. */
void setRange(double minR, double minG, double minB, double minA,
double maxR, double maxG, double maxB, double maxA);
/** @brief set the display min and max, default is to be the same as the range param */
void setDisplayRange(double minR, double minG, double minB, double minA,
double maxR, double maxG, double maxB, double maxA);
};
////////////////////////////////////////////////////////////////////////////////
/** @brief Wraps up a boolean param */
class BooleanParamDescriptor : public ValueParamDescriptor {
protected :
mDeclareProtectedAssignAndCCBase(BooleanParamDescriptor,ValueParamDescriptor);
BooleanParamDescriptor(void) {assert(false);}
protected :
/** @brief hidden constructor */
BooleanParamDescriptor(const std::string &name, OfxPropertySetHandle props);
// so it can make one
friend class ParamSetDescriptor;
public :
/** @brief set the default value */
void setDefault(bool v);
};
////////////////////////////////////////////////////////////////////////////////
/** @brief Wraps up a choice param */
class ChoiceParamDescriptor : public ValueParamDescriptor {
protected :
mDeclareProtectedAssignAndCCBase(ChoiceParamDescriptor,ValueParamDescriptor);
ChoiceParamDescriptor(void) {assert(false);}
protected :
/** @brief hidden constructor */
ChoiceParamDescriptor(const std::string &name, OfxPropertySetHandle props);
// so it can make one
friend class ParamSetDescriptor;
public :
/** @brief set the default value */
void setDefault(int v);
/** @brief append an option, default is to have not there */
void appendOption(const std::string &v, const std::string& label = "");
/** @brief how many options do we have */
int getNOptions(void);
/** @brief clear all the options so as to add some new ones in */
void resetOptions(void);
};
////////////////////////////////////////////////////////////////////////////////
/** @brief Wraps up a group param, not much to it really */
class GroupParamDescriptor : public ParamDescriptor {
protected :
mDeclareProtectedAssignAndCCBase(GroupParamDescriptor,ParamDescriptor);
GroupParamDescriptor(void) {assert(false);}
protected :
/** @brief hidden constructor */
GroupParamDescriptor(const std::string &name, OfxPropertySetHandle props);
// so it can make one
friend class ParamSetDescriptor;
public :
/** @brief whether the initial state of a group is open or closed in a hierarchical layout, defaults to false */
void setOpen(const bool v);
void setAsTab();
};
////////////////////////////////////////////////////////////////////////////////
/** @brief Wraps up a page param, not much to it really */
class PageParamDescriptor : public ParamDescriptor {
protected :
mDeclareProtectedAssignAndCCBase(PageParamDescriptor,ParamDescriptor);
PageParamDescriptor(void) {assert(false);}
protected :
/** @brief hidden constructor */
PageParamDescriptor(const std::string &name, OfxPropertySetHandle props);
// so it can make one
friend class ParamSetDescriptor;
public :
/** @brief adds a child parameter. Note the two existing pseudo params, gColumnSkip and gRowSkip */
void addChild(const ParamDescriptor &p);
/** @brief dummy page positioning parameter to be passed to @ref OFX::PageParamDescriptor::addChild */
static DummyParamDescriptor gSkipRow;
/** @brief dummy page positioning parameter to be passed to @ref OFX::PageParamDescriptor::addChild */
static DummyParamDescriptor gSkipColumn;
};
////////////////////////////////////////////////////////////////////////////////
/** @brief Wraps up a push button param, not much to it at all */
class PushButtonParamDescriptor : public ParamDescriptor {
protected :
mDeclareProtectedAssignAndCCBase(PushButtonParamDescriptor,ParamDescriptor);
PushButtonParamDescriptor(void) {assert(false);}
protected :
/** @brief hidden constructor */
PushButtonParamDescriptor(const std::string &name, OfxPropertySetHandle props);
// so it can make one
friend class ParamSetDescriptor;
public :
};
////////////////////////////////////////////////////////////////////////////////
/** @brief Wraps up a push button param, not much to it at all */
class ParametricParamDescriptor : public ParamDescriptor
{
protected:
mDeclareProtectedAssignAndCCBase(ParametricParamDescriptor,ParamDescriptor);
ParametricParamDescriptor(void) {assert(false);}
protected:
/** @brief hidden constructor */
ParametricParamDescriptor(const std::string& name, OfxPropertySetHandle props);
OfxParamHandle _ofxParamHandle;
ParamSetDescriptor* _paramSet;
std::auto_ptr<ParamInteractDescriptor> _interact;
// so it can make one
friend class ParamSetDescriptor;
void setParamSet( ParamSetDescriptor& paramSet );
public:
void setDimension( const int dimension );
void setRange( const double min, const double max );
void setDimensionLabel( const std::string& label, const int id );
void setUIColour( const int id, const OfxRGBColourD& color );
void addControlPoint( const int id, const OfxTime time, const double x, const double y, const bool addKey );
void setIdentity( const int id );
void setIdentity();
void setInteractDescriptor( ParamInteractDescriptor* desc );
};
////////////////////////////////////////////////////////////////////////////////
/** @brief Wraps up a custom param, haven't added animation support yet */
class CustomParamDescriptor : public ValueParamDescriptor {
protected :
mDeclareProtectedAssignAndCCBase(CustomParamDescriptor,ValueParamDescriptor);
CustomParamDescriptor(void) {assert(false);}
protected :
/** @brief hidden constructor */
CustomParamDescriptor(const std::string &name, OfxPropertySetHandle props);
// so it can make one
friend class ParamSetDescriptor;
public :
/** @brief set the default value of the param */
void setDefault(const std::string &v);
void setCustomInterpolation(bool v);
};
////////////////////////////////////////////////////////////////////////////////
/** @brief Describes a set of properties */
class ParamSetDescriptor {
protected :
mDeclareProtectedAssignAndCC(ParamSetDescriptor);
/** @brief calls the raw OFX routine to define a param */
void defineRawParam(const std::string &name, ParamTypeEnum paramType, OfxPropertySetHandle &props);
/** @brief Define a param descriptor of the given type */
template <class T> bool
defineParamDescriptor(const std::string &name, ParamTypeEnum paramType, T * ¶mPtr)
{
paramPtr = NULL;
// have we made it already in this param set and is it of the correct type
if(ParamDescriptor *param = findPreviouslyDefinedParam(name)) {
if(param->getType() == paramType) {
paramPtr = (T *) param; // could be a dynamic cast here
return true;
}
else
return false; // SHOULD THROW SOMETHING HERE!!!!!!!
}
else {
// ok define one and add it in
OfxPropertySetHandle props;
defineRawParam(name, paramType, props);
// make out support descriptor class
paramPtr = new T(name, props);
// add it to our map of described ones
_definedParams[name] = paramPtr;
}
return true;
}
protected :
/** @brief Properties that belong to this param set */
PropertySet _paramSetProps;
/** @brief Parameter set handle */
OfxParamSetHandle _paramSetHandle;
/** @brief Set of all previously defined parameters, defined on demand */
std::map<std::string, ParamDescriptor *> _definedParams;
/** @brief Hidden ctor */
ParamSetDescriptor(void);
/** @brief set the param set handle */
void setParamSetHandle(OfxParamSetHandle h);
/** @brief find a param in the map */
ParamDescriptor *findPreviouslyDefinedParam(const std::string &name);
public :
OfxParamSetHandle getParamSetHandle()
{
return _paramSetHandle;
}
virtual ~ParamSetDescriptor();
/** @brief tries to fetch a ParamDescriptor, returns 0 if it isn't there*/
ParamDescriptor* getParamDescriptor(const std::string& name) const;
/** @brief estabilishes the order of page params. Do it by calling it in turn for each page */
void setPageParamOrder(PageParamDescriptor &p);
/** @brief Define an integer param */
IntParamDescriptor *defineIntParam(const std::string &name);
/** @brief Define a 2D integer param */
Int2DParamDescriptor *defineInt2DParam(const std::string &name);
/** @brief Define a 3D integer param */
Int3DParamDescriptor *defineInt3DParam(const std::string &name);
/** @brief Define an double param */
DoubleParamDescriptor *defineDoubleParam(const std::string &name);
/** @brief Define a 2D double param */
Double2DParamDescriptor *defineDouble2DParam(const std::string &name);
/** @brief Define a 3D double param */
Double3DParamDescriptor *defineDouble3DParam(const std::string &name);
/** @brief Define a string param */
StringParamDescriptor *defineStringParam(const std::string &name);
/** @brief Define a RGBA param */
RGBAParamDescriptor *defineRGBAParam(const std::string &name);
/** @brief Define an RGB param */
RGBParamDescriptor *defineRGBParam(const std::string &name);
/** @brief Define a Boolean param */
BooleanParamDescriptor *defineBooleanParam(const std::string &name);
/** @brief Define a Choice param */
ChoiceParamDescriptor *defineChoiceParam(const std::string &name);
/** @brief Define a group param */
GroupParamDescriptor *defineGroupParam(const std::string &name);
/** @brief Define a Page param */
PageParamDescriptor *definePageParam(const std::string &name);
/** @brief Define a push button param */
PushButtonParamDescriptor *definePushButtonParam(const std::string &name);
/** @brief Define a parametric param */
ParametricParamDescriptor* defineParametricParam(const std::string &name);
/** @brief Define a custom param */
CustomParamDescriptor *defineCustomParam(const std::string &name);
};
////////////////////////////////////////////////////////////////////////////////
/** @brief Base class for all param instances */
class Param {
protected :
// don't ever use these!
Param &operator=(const Param &/*v1*/) {assert(false); return *this;}
Param(const Param &v) : _paramSet(v._paramSet) {assert(false); }
Param(void) {assert(false);}
protected :
const ParamSet *_paramSet; // who do I belong to
std::string _paramName;
ParamTypeEnum _paramType;
PropertySet _paramProps;
OfxParamHandle _paramHandle;
/** @brief hidden constructor */
Param(const ParamSet *paramSet, const std::string &name, ParamTypeEnum type, OfxParamHandle handle);
friend class ParamSet;
public :
/** @brief dtor */
virtual ~Param();
/** @brief get name */
const std::string &getName(void) const;
/** @brief, set the label property in a param */
void setLabel(const std::string &label);
/** @brief, set the label properties in a param */
void setLabels(const std::string &label, const std::string &shortLabel, const std::string &longLabel);
/** @brief return the derived type of this parameter */
ParamTypeEnum getType(void) const {return _paramType;}
/** @brief set the secretness of the param, defaults to false */
void setIsSecret(bool v);
/** @brief set the param hint */
void setHint(const std::string &hint);
/** @brief whether the param is enabled */
void setEnabled(bool v);
/** @brief set the param data ptr */
void setDataPtr(void* ptr);
/** @brief fetch the label */
void getLabel(std::string &label) const;
/** @brief fetch the labels */
void getLabels(std::string &label, std::string &shortLabel, std::string &longLabel) const;
/** @brief get whether the param is secret */
bool getIsSecret(void) const;
/** @brief whether the param is enabled */
bool getIsEnable(void) const;
/** @brief get the param data ptr */
void* getDataPtr(void) const;
/** @brief get the param hint */
std::string getHint(void) const;
/** @brief get the script name */
std::string getScriptName(void) const;
/** @brief get the group param that is the parent of this one */
GroupParam *getParent(void) const;
/** @brief get the icon file name (SVG or PNG) */
std::string getIcon(bool pngFormat) const;
bool getHostHasNativeOverlayHandle() const;
};
////////////////////////////////////////////////////////////////////////////////
/** @brief Wraps up a value holding param */
class ValueParam : public Param {
protected :
mDeclareProtectedAssignAndCCBase(ValueParam,Param);
ValueParam(void) {assert(false);}
protected :
/** @brief hidden constructor */
ValueParam(const ParamSet *paramSet, const std::string &name, ParamTypeEnum type, OfxParamHandle handle);
friend class ParamSet;
public :
/** @brief dtor */
~ValueParam();
/** @brief Set's whether the value of the param is significant (ie: affects the rendered image) */
void setEvaluateOnChange(bool v);
/** @brief is the param animating */
bool getIsAnimating(void) const;
/** @brief is the param animating */
bool getIsAutoKeying(void) const;
/** @brief is the param animating */
bool getIsPersistant(void) const;
/** @brief Get's whether the value of the param is significant (ie: affects the rendered image) */
bool getEvaluateOnChange(void) const;
/** @brief Get's whether the value of the param is significant (ie: affects the rendered image) */
CacheInvalidationEnum getCacheInvalidation(void) const;
/** @brief if the param is animating, the number of keys in it, otherwise 0 */
unsigned int getNumKeys(void);
/** @brief get the time of the nth key, nth must be between 0 and getNumKeys-1 */
double getKeyTime(int nthKey) throw(OFX::Exception::Suite, std::out_of_range);
/** @brief find the index of a key by a time */
int getKeyIndex(double time,
KeySearchEnum searchDir);
/** @brief deletes a key at the given time */
void deleteKeyAtTime(double time);
/** @brief delete all the keys */
void deleteAllKeys(void);
/** @brief copy parameter from another, including any animation etc... */