forked from NatronGitHub/Natron
-
Notifications
You must be signed in to change notification settings - Fork 0
/
PyParameter.h
1202 lines (938 loc) · 36.2 KB
/
PyParameter.h
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
/* ***** BEGIN LICENSE BLOCK *****
* This file is part of Natron <https://natrongithub.github.io/>,
* (C) 2018-2021 The Natron developers
* (C) 2013-2018 INRIA and Alexandre Gauthier-Foichat
*
* Natron is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* Natron is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Natron. If not, see <http://www.gnu.org/licenses/gpl-2.0.html>
* ***** END LICENSE BLOCK ***** */
#ifndef Engine_ParameterWrapper_h
#define Engine_ParameterWrapper_h
// ***** BEGIN PYTHON BLOCK *****
// from <https://docs.python.org/3/c-api/intro.html#include-files>:
// "Since Python may define some pre-processor definitions which affect the standard headers on some systems, you must include Python.h before any standard headers are included."
#include <Python.h>
// ***** END PYTHON BLOCK *****
#include "Global/Macros.h"
/**
* @brief Simple wrap for the Knob class that is the API we want to expose to the Python
* Engine module.
**/
#if !defined(Q_MOC_RUN) && !defined(SBK_RUN)
#include <boost/shared_ptr.hpp>
#include <boost/weak_ptr.hpp>
#endif
#include "Engine/KnobTypes.h"
#include "Engine/KnobFile.h"
#include "Engine/EngineFwd.h"
NATRON_NAMESPACE_ENTER;
NATRON_PYTHON_NAMESPACE_ENTER;
class Param
{
protected:
KnobIWPtr _knob;
public:
Param(const KnobIPtr& knob);
virtual ~Param();
KnobIPtr getInternalKnob() const { return _knob.lock(); }
/**
* @brief Returns the parent of this parameter if any. If the parameter has no parent it is assumed to be a top-level
* param of the effect.
**/
Param* getParent() const;
/**
* @brief Returns the number of dimensions that the parameter have.
* For example a size integer parameter could have 2 dimensions: width and height.
**/
int getNumDimensions() const;
/**
* @brief Returns the name of the Param internally. This is the identifier that allows the Python programmer
* to find and identify a specific Param.
**/
QString getScriptName() const;
/**
* @brief Returns the label of the Param as shown on the GUI.
**/
QString getLabel() const;
/**
* @brief Set the icon file-path that should be used for the button.
* This can only be called right away after the parameter has been created.
**/
void setIconFilePath(const QString& icon);
/**
* @brief Returns the type of the parameter. The list of known type is:
* "Int" "Bool" "Double" "Button" "Choice" "Color" "String" "Group" "Page" "Parametric" "InputFile" "OutputFile" "Path"
**/
QString getTypeName() const;
/**
* @brief Returns the help that describes the parameter, its effect, etc...
**/
QString getHelp() const;
void setHelp(const QString& help);
/**
* @brief Returns true if this parameter is visible in the user interface, false if it is hidden.
**/
bool getIsVisible() const;
/**
* @brief Set the visibility of the parameter
**/
void setVisible(bool visible);
void setVisibleByDefault(bool visible);
/**
* @brief Returns whether the given dimension is enabled, i.e: whether the user can interact with it or not.
**/
bool getIsEnabled(int dimension = 0) const;
/**
* @brief Set the given dimension enabledness
**/
void setEnabled(bool enabled, int dimension = 0);
void setEnabledByDefault(bool enabled = 0);
/**
* @brief Returns whether this parameter is persistent or not. A persistent parameter will be saved into the project.
**/
bool getIsPersistent() const;
/**
* @brief Set the parameter persistency.
**/
void setPersistent(bool persistent);
/**
* @brief Returns whether the parameter forces a new evaluation when its value changes. An evaluation is typically
* a request for a re-render of the current frame.
**/
bool getEvaluateOnChange() const;
/**
* @brief Set whether this Param evaluates on change.
**/
void setEvaluateOnChange(bool eval);
/**
* @brief Returns whether the parameter type can animate or not. For example a button parameter cannot animate.
* This is "static" (per parameter type property) and does not mean the same thing that getIsAnimationEnabled().
* A parameter can have the function getCanAnimate() return true but getIsAnimationEnabled() return false.
**/
bool getCanAnimate() const;
/**
* @brief Returns whether this parameter can animate.
**/
bool getIsAnimationEnabled() const;
void setAnimationEnabled(bool e);
/**
* @brief Controls whether the next parameter defined after this parameter should add a new line or not.
**/
bool getAddNewLine();
void setAddNewLine(bool a);
/**
* @brief Copies all the content of the other param: animation, expression and value.
* The parameters must be compatible types. E.g: you cannot copy
* a StringParam to an IntParam but you can convert a Doubleparam to an IntParam.
**/
bool copy(Param* other, int dimension = -1);
bool slaveTo(Param* other, int thisDimension, int otherDimension);
void unslave(int dimension);
/**
* @brief Returns a pseudo-random number. This will always be the same for the same time on the timeline.
* The version with the seed can be used to retrieve the same value for 2 successive randoms, or at different time frames.
**/
double random(double min = 0., double max = 1.) const;
double random(double min, double max, double time, unsigned int seed = 0) const;
int randomInt(int min, int max);
int randomInt(int min, int max, double time, unsigned int seed = 0) const;
/**
* @brief Returns the raw value of the curve at the given dimension at the given time. Note that
* if there's an expression this will not return the value of the expression but the value of the animation curve
* if there is any.
**/
double curve(double time, int dimension = 0) const;
bool setAsAlias(Param* other);
protected:
/**
* @brief Adds this Param as a dependency of the given Param. This is used mainly by the GUI to notify the user
* when a dependency (through expressions) is destroyed (because the holding node has been removed).
* You should not call this directly.
**/
void _addAsDependencyOf(int fromExprDimension, Param* param, int thisDimension);
};
class AnimatedParam
: public Param
{
public:
AnimatedParam(const KnobIPtr& knob);
virtual ~AnimatedParam();
/**
* @brief Returns whether the given dimension has animation or not. A dimension is considered to have an animation when it has
* at least 1 keyframe.
**/
bool getIsAnimated(int dimension = 0) const;
/**
* @brief Returns the number of keyframes for the given dimension.
**/
int getNumKeys(int dimension = 0) const;
/**
* @brief Returns the index of the keyframe at the given time for the given dimension.
* Returns -1 if no keyframe could be found at the given time.
**/
int getKeyIndex(double time, int dimension = 0) const;
/**
* @brief Set in 'time' the time of the keyframe at the given index for the given dimension.
* This function returns true if a keyframe was found at the given index, false otherwise.
**/
bool getKeyTime(int index, int dimension, double* time) const;
/**
* @brief Removes the keyframe at the given time and dimension if it matches any.
**/
void deleteValueAtTime(double time, int dimension = 0);
/**
* @brief Removes all animation for the given dimension.
**/
void removeAnimation(int dimension = 0);
/**
* @brief Compute the derivative at time as a double
**/
double getDerivativeAtTime(double time, int dimension = 0) const;
/**
* @brief Compute the integral of dimension from time1 to time2 as a double
**/
double getIntegrateFromTimeToTime(double time1, double time2, int dimension = 0) const;
/**
* @brief Get the current global time in the parameter context. Most generally this is the time on the timeline,
* but when multiple frames are being rendered at different times, this is the time of the frame being rendered
* by the caller thread.
**/
int getCurrentTime() const;
/**
* @brief Set an expression on the Param. This is a Python script, see documentation for more infos.
**/
bool setExpression(const QString& expr, bool hasRetVariable, int dimension = 0);
QString getExpression(int dimension, bool* hasRetVariable) const;
bool setInterpolationAtTime(double time, NATRON_NAMESPACE::KeyframeTypeEnum interpolation, int dimension = 0);
};
/**
* @brief Small helper struct that is returned by the get() function of all params type
* so the user can write stuff like myParam.get().x
**/
struct Int2DTuple
{
int x, y;
};
struct Int3DTuple
{
int x, y, z;
};
struct Double2DTuple
{
double x, y;
};
struct Double3DTuple
{
double x, y, z;
};
struct ColorTuple
{
double r, g, b, a; //< Color params are 4-dimensional
};
class IntParam
: public AnimatedParam
{
protected:
KnobIntWPtr _intKnob;
public:
IntParam(const KnobIntPtr& knob);
virtual ~IntParam();
/**
* @brief Convenience function that calls getValue() for all dimensions and store them in a tuple-like struct.
**/
int get() const;
int get(double frame) const;
/**
* @brief Convenience functions for multi-dimensional setting of values
**/
void set(int x);
void set(int x, double frame);
/**
* @brief Returns the value held by the parameter. If it is animated, getValueAtTime
* will be called instead at the current's timeline position.
**/
int getValue(int dimension = 0) const;
/**
* @brief Set the value held by the parameter. If it is animated
* this function will either add a new keyframe or modify a keyframe already existing at the current time.
**/
void setValue(int value, int dimension = 0);
/**
* @brief If this parameter is animated for the given dimension, this function returns a value interpolated between the
* 2 keyframes surrounding the given time. If time is exactly one keyframe then the value of the keyframe is returned.
* If this parameter is not animated for the given dimension, then this function returns the same as getValue(int)
**/
int getValueAtTime(double time, int dimension = 0) const;
/**
* @brief Set a new keyframe on the parameter at the given time. If a keyframe already exists, it will modify it.
**/
void setValueAtTime(int value, double time, int dimension = 0);
/**
* @brief Set the default value for the given dimension
**/
void setDefaultValue(int value, int dimension = 0);
/**
* @brief Return the default value for the given dimension
**/
int getDefaultValue(int dimension = 0) const;
/**
* @brief Restores the default value for the given dimension
**/
void restoreDefaultValue(int dimension = 0);
/**
* @brief Set the minimum possible value for the given dimension. The minimum will not limit the user on the GUI, i.e: he/she
* will still be able to input values smaller than the minimum, but values returned by getValue() or getValueAtTime() will
* return a value clamped to it.
**/
void setMinimum(int minimum, int dimension = 0);
/**
* @brief Get the minimum for the given dimension.
**/
int getMinimum(int dimension = 0) const;
/**
* @brief Set the maximum possible value for the given dimension. The maximum will not limit the user on the GUI, i.e: he/she
* will still be able to input values greater than the maximum, but values returned by getValue() or getValueAtTime() will
* return a value clamped to it.
**/
void setMaximum(int maximum, int dimension = 0);
/**
* @brief Get the minimum for the given dimension.
**/
int getMaximum(int dimension = 0) const;
/**
* @brief Set the minimum to be displayed on a slider if this parameter has a slider.
**/
void setDisplayMinimum(int minimum, int dimension = 0);
/**
* @brief Get the display minimum for the given dimension
**/
int getDisplayMinimum(int dimension) const;
/**
* @brief Set the maximum to be displayed on a slider if this parameter has a slider.
**/
void setDisplayMaximum(int maximum, int dimension = 0);
/**
* @brief Get the display maximum for the given dimension
**/
int getDisplayMaximum(int dimension) const;
/**
* @brief Adds this Param as a dependency of the given Param. This is used mainly by the GUI to notify the user
* when a dependency (through expressions) is destroyed (because the holding node has been removed).
* You should not call this directly.
**/
int addAsDependencyOf(int fromExprDimension, Param* param, int thisDimension);
};
class Int2DParam
: public IntParam
{
public:
Int2DParam(const KnobIntPtr& knob)
: IntParam(knob) {}
virtual ~Int2DParam() {}
Int2DTuple get() const;
Int2DTuple get(double frame) const;
void set(int x, int y);
void set(int x, int y, double frame);
};
class Int3DParam
: public Int2DParam
{
public:
Int3DParam(const KnobIntPtr& knob)
: Int2DParam(knob) {}
virtual ~Int3DParam() {}
Int3DTuple get() const;
Int3DTuple get(double frame) const;
void set(int x, int y, int z);
void set(int x, int y, int z, double frame);
};
class DoubleParam
: public AnimatedParam
{
protected:
KnobDoubleWPtr _doubleKnob;
public:
DoubleParam(const KnobDoublePtr& knob);
virtual ~DoubleParam();
/**
* @brief Convenience function that calls getValue() for all dimensions and store them in a tuple-like struct.
**/
double get() const;
double get(double frame) const;
/**
* @brief Convenience functions for multi-dimensional setting of values
**/
void set(double x);
void set(double x, double frame);
/**
* @brief Returns the value held by the parameter. If it is animated, getValueAtTime
* will be called instead at the current's timeline position.
**/
double getValue(int dimension = 0) const;
/**
* @brief Set the value held by the parameter. If it is animated
* this function will either add a new keyframe or modify a keyframe already existing at the current time.
**/
void setValue(double value, int dimension = 0);
/**
* @brief If this parameter is animated for the given dimension, this function returns a value interpolated between the
* 2 keyframes surrounding the given time. If time is exactly one keyframe then the value of the keyframe is returned.
* If this parameter is not animated for the given dimension, then this function returns the same as getValue(int)
**/
double getValueAtTime(double time, int dimension = 0) const;
/**
* @brief Set a new keyframe on the parameter at the given time. If a keyframe already exists, it will modify it.
**/
void setValueAtTime(double value, double time, int dimension = 0);
/**
* @brief Set the default value for the given dimension
**/
void setDefaultValue(double value, int dimension = 0);
/**
* @brief Return the default value for the given dimension
**/
double getDefaultValue(int dimension = 0) const;
/**
* @brief Restores the default value for the given dimension
**/
void restoreDefaultValue(int dimension = 0);
/**
* @brief Set the minimum possible value for the given dimension. The minimum will not limit the user on the GUI, i.e: he/she
* will still be able to input values smaller than the minimum, but values returned by getValue() or getValueAtTime() will
* return a value clamped to it.
**/
void setMinimum(double minimum, int dimension = 0);
/**
* @brief Get the minimum for the given dimension.
**/
double getMinimum(int dimension = 0) const;
/**
* @brief Set the maximum possible value for the given dimension. The maximum will not limit the user on the GUI, i.e: he/she
* will still be able to input values greater than the maximum, but values returned by getValue() or getValueAtTime() will
* return a value clamped to it.
**/
void setMaximum(double maximum, int dimension = 0);
/**
* @brief Get the minimum for the given dimension.
**/
double getMaximum(int dimension = 0) const;
/**
* @brief Set the minimum to be displayed on a slider if this parameter has a slider.
**/
void setDisplayMinimum(double minimum, int dimension = 0);
/**
* @brief Get the display minimum for the given dimension
**/
double getDisplayMinimum(int dimension) const;
/**
* @brief Set the maximum to be displayed on a slider if this parameter has a slider.
**/
void setDisplayMaximum(double maximum, int dimension = 0);
/**
* @brief Get the display maximum for the given dimension
**/
double getDisplayMaximum(int dimension) const;
/**
* @brief Adds this Param as a dependency of the given Param. This is used mainly by the GUI to notify the user
* when a dependency (through expressions) is destroyed (because the holding node has been removed).
* You should not call this directly.
**/
double addAsDependencyOf(int fromExprDimension, Param* param, int thisDimension);
};
class Double2DParam
: public DoubleParam
{
public:
Double2DParam(const KnobDoublePtr& knob)
: DoubleParam(knob) {}
virtual ~Double2DParam() {}
Double2DTuple get() const;
Double2DTuple get(double frame) const;
void set(double x, double y);
void set(double x, double y, double frame);
void setUsePointInteract(bool use);
void setCanAutoFoldDimensions(bool can);
};
class Double3DParam
: public Double2DParam
{
public:
Double3DParam(const KnobDoublePtr& knob)
: Double2DParam(knob) {}
virtual ~Double3DParam() {}
Double3DTuple get() const;
Double3DTuple get(double frame) const;
void set(double x, double y, double z);
void set(double x, double y, double z, double frame);
};
class ColorParam
: public AnimatedParam
{
protected:
KnobColorWPtr _colorKnob;
public:
ColorParam(const KnobColorPtr& knob);
virtual ~ColorParam();
/**
* @brief Convenience function that calls getValue() for all dimensions and store them in a tuple-like struct.
**/
ColorTuple get() const;
ColorTuple get(double frame) const;
/**
* @brief Convenience functions for multi-dimensional setting of values
**/
void set(double r, double g, double b, double a);
void set(double r, double g, double b, double a, double frame);
/**
* @brief Returns the value held by the parameter. If it is animated, getValueAtTime
* will be called instead at the current's timeline position.
**/
double getValue(int dimension = 0) const;
/**
* @brief Set the value held by the parameter. If it is animated
* this function will either add a new keyframe or modify a keyframe already existing at the current time.
**/
void setValue(double value, int dimension = 0);
/**
* @brief If this parameter is animated for the given dimension, this function returns a value interpolated between the
* 2 keyframes surrounding the given time. If time is exactly one keyframe then the value of the keyframe is returned.
* If this parameter is not animated for the given dimension, then this function returns the same as getValue(int)
**/
double getValueAtTime(double time, int dimension = 0) const;
/**
* @brief Set a new keyframe on the parameter at the given time. If a keyframe already exists, it will modify it.
**/
void setValueAtTime(double value, double time, int dimension = 0);
/**
* @brief Set the default value for the given dimension
**/
void setDefaultValue(double value, int dimension = 0);
/**
* @brief Return the default value for the given dimension
**/
double getDefaultValue(int dimension = 0) const;
/**
* @brief Restores the default value for the given dimension
**/
void restoreDefaultValue(int dimension = 0);
/**
* @brief Set the minimum possible value for the given dimension. The minimum will not limit the user on the GUI, i.e: he/she
* will still be able to input values smaller than the minimum, but values returned by getValue() or getValueAtTime() will
* return a value clamped to it.
**/
void setMinimum(double minimum, int dimension = 0);
/**
* @brief Get the minimum for the given dimension.
**/
double getMinimum(int dimension = 0) const;
/**
* @brief Set the maximum possible value for the given dimension. The maximum will not limit the user on the GUI, i.e: he/she
* will still be able to input values greater than the maximum, but values returned by getValue() or getValueAtTime() will
* return a value clamped to it.
**/
void setMaximum(double maximum, int dimension = 0);
/**
* @brief Get the minimum for the given dimension.
**/
double getMaximum(int dimension = 0) const;
/**
* @brief Set the minimum to be displayed on a slider if this parameter has a slider.
**/
void setDisplayMinimum(double minimum, int dimension = 0);
/**
* @brief Get the display minimum for the given dimension
**/
double getDisplayMinimum(int dimension) const;
/**
* @brief Set the maximum to be displayed on a slider if this parameter has a slider.
**/
void setDisplayMaximum(double maximum, int dimension = 0);
/**
* @brief Get the display maximum for the given dimension
**/
double getDisplayMaximum(int dimension) const;
/**
* @brief Adds this Param as a dependency of the given Param. This is used mainly by the GUI to notify the user
* when a dependency (through expressions) is destroyed (because the holding node has been removed).
* You should not call this directly.
**/
double addAsDependencyOf(int fromExprDimension, Param* param, int thisDimension);
};
class ChoiceParam
: public AnimatedParam
{
protected:
KnobChoiceWPtr _choiceKnob;
public:
ChoiceParam(const KnobChoicePtr& knob);
virtual ~ChoiceParam();
/**
* @brief Convenience function that calls getValue() for all dimensions and store them in a tuple-like struct.
**/
int get() const;
int get(double frame) const;
/**
* @brief Convenience functions for multi-dimensional setting of values
**/
void set(int x);
void set(int x, double frame);
/*
* @brief Set the value from label if it exists.
* The label will be compared without case sensitivity to existing entries. If it's not found, nothing is done.
*/
void set(const QString& label);
/**
* @brief Returns the value held by the parameter. If it is animated, getValueAtTime
* will be called instead at the current's timeline position.
**/
int getValue() const;
/**
* @brief Set the value held by the parameter. If it is animated
* this function will either add a new keyframe or modify a keyframe already existing at the current time.
**/
void setValue(int value);
void setValue(const QString& label);
/**
* @brief If this parameter is animated for the given dimension, this function returns a value interpolated between the
* 2 keyframes surrounding the given time. If time is exactly one keyframe then the value of the keyframe is returned.
* If this parameter is not animated for the given dimension, then this function returns the same as getValue(int)
**/
int getValueAtTime(double time) const;
/**
* @brief Set a new keyframe on the parameter at the given time. If a keyframe already exists, it will modify it.
**/
void setValueAtTime(int value, double time);
/**
* @brief Set the default value for the given dimension
**/
void setDefaultValue(int value);
/**
* @brief Set the default value from an existing entry. If it does not match (without case sensitivity) an existing entry, nothing is done.
**/
void setDefaultValue(const QString& value);
/**
* @brief Return the default value for the given dimension
**/
int getDefaultValue() const;
/**
* @brief Restores the default value for the given dimension
**/
void restoreDefaultValue();
/**
* @brief Add a new option to the drop-down menu
**/
void addOption(const QString& option, const QString& help);
/**
* @brief Set all options at once
**/
void setOptions(const std::list<std::pair<QString, QString> >& options);
/**
* @brief Returns the option at the given index
**/
QString getOption(int index) const;
/**
* @brief Returns the count of options
**/
int getNumOptions() const;
/**
* @brief Returns all options
**/
QStringList getOptions() const;
/**
* @brief Adds this Param as a dependency of the given Param. This is used mainly by the GUI to notify the user
* when a dependency (through expressions) is destroyed (because the holding node has been removed).
* You should not call this directly.
**/
int addAsDependencyOf(int fromExprDimension, Param* param, int thisDimension);
};
class BooleanParam
: public AnimatedParam
{
protected:
KnobBoolWPtr _boolKnob;
public:
BooleanParam(const KnobBoolPtr& knob);
virtual ~BooleanParam();
/**
* @brief Convenience function that calls getValue() for all dimensions and store them in a tuple-like struct.
**/
bool get() const;
bool get(double frame) const;
/**
* @brief Convenience functions for multi-dimensional setting of values
**/
void set(bool x);
void set(bool x, double frame);
/**
* @brief Returns the value held by the parameter. If it is animated, getValueAtTime
* will be called instead at the current's timeline position.
**/
bool getValue() const;
/**
* @brief Set the value held by the parameter. If it is animated
* this function will either add a new keyframe or modify a keyframe already existing at the current time.
**/
void setValue(bool value);
/**
* @brief If this parameter is animated for the given dimension, this function returns a value interpolated between the
* 2 keyframes surrounding the given time. If time is exactly one keyframe then the value of the keyframe is returned.
* If this parameter is not animated for the given dimension, then this function returns the same as getValue(int)
**/
bool getValueAtTime(double time) const;
/**
* @brief Set a new keyframe on the parameter at the given time. If a keyframe already exists, it will modify it.
**/
void setValueAtTime(bool value, double time);
/**
* @brief Set the default value for the given dimension
**/
void setDefaultValue(bool value);
/**
* @brief Return the default value for the given dimension
**/
bool getDefaultValue() const;
/**
* @brief Restores the default value for the given dimension
**/
void restoreDefaultValue();
/**
* @brief Adds this Param as a dependency of the given Param. This is used mainly by the GUI to notify the user
* when a dependency (through expressions) is destroyed (because the holding node has been removed).
* You should not call this directly.
**/
bool addAsDependencyOf(int fromExprDimension, Param* param, int thisDimension);
};
/////////////StringParam
class StringParamBase
: public AnimatedParam
{
protected:
KnobStringBaseWPtr _stringKnob;
public:
StringParamBase(const KnobStringBasePtr& knob);
virtual ~StringParamBase();
/**
* @brief Convenience function that calls getValue() for all dimensions and store them in a tuple-like struct.
**/
QString get() const;
QString get(double frame) const;
/**
* @brief Convenience functions for multi-dimensional setting of values
**/
void set(const QString& x);
void set(const QString& x, double frame);
/**
* @brief Returns the value held by the parameter. If it is animated, getValueAtTime
* will be called instead at the current's timeline position.
**/
QString getValue() const;
/**
* @brief Set the value held by the parameter. If it is animated
* this function will either add a new keyframe or modify a keyframe already existing at the current time.
**/
void setValue(const QString& value);
/**
* @brief If this parameter is animated for the given dimension, this function returns a value interpolated between the
* 2 keyframes surrounding the given time. If time is exactly one keyframe then the value of the keyframe is returned.
* If this parameter is not animated for the given dimension, then this function returns the same as getValue(int)
**/
QString getValueAtTime(double time) const;
/**
* @brief Set a new keyframe on the parameter at the given time. If a keyframe already exists, it will modify it.
**/
void setValueAtTime(const QString& value, double time);
/**
* @brief Set the default value for the given dimension
**/
void setDefaultValue(const QString& value);
/**
* @brief Return the default value for the given dimension
**/
QString getDefaultValue() const;
/**
* @brief Restores the default value for the given dimension
**/
void restoreDefaultValue();
/**
* @brief Adds this Param as a dependency of the given Param. This is used mainly by the GUI to notify the user
* when a dependency (through expressions) is destroyed (because the holding node has been removed).
* You should not call this directly.
**/
QString addAsDependencyOf(int fromExprDimension, Param* param, int thisDimension);
};
class StringParam
: public StringParamBase
{
KnobStringWPtr _sKnob;
public:
enum TypeEnum
{
eStringTypeLabel = 0, //< A label shown on gui, cannot animate
eStringTypeMultiLine, //< A text area in plain text
eStringTypeRichTextMultiLine, //< A text area with Qt Html support
eStringTypeCustom, //< A custom string where anything can be passed, it animates but is not editable by the user
eStringTypeDefault, //< Same as custom except that it is editable
};
StringParam(const KnobStringPtr& knob);
virtual ~StringParam();
/**
* @brief Set the type of the string, @see TypeEnum.
* This is not dynamic and has to be called right away after creating the parameter!
**/
void setType(TypeEnum type);
};
class FileParam
: public StringParamBase