HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
PRM_Parm.h
Go to the documentation of this file.
1 /*
2  * PROPRIETARY INFORMATION. This software is proprietary to
3  * Side Effects Software Inc., and is not to be reproduced,
4  * transmitted, or disclosed in any way without written permission.
5  *
6  * NAME: PRM_Parm.h (Parameter Library)
7  *
8  * COMMENTS:
9  * PRM_Parm is the class which contains all the information
10  * about a parameter. A parameter is any value or set of
11  * values that are used in the Houdini world. It may contain
12  * expressions, channels, or simple values.
13  *
14  * It is divided into two part, the parameter's type
15  * definition, stored in the PRM_Template, and the
16  * parameter's actual data, stored in the PRM_Instance.
17  * Each PRM_Parm contains all the information it needs to
18  * perform its functions independently of other objects.
19  */
20 
21 #ifndef __PRM_Parm__
22 #define __PRM_Parm__
23 
24 #include "PRM_API.h"
25 #include "PRM_ChanState.h"
26 #include "PRM_Default.h"
27 #include "PRM_KeySetType.h"
28 #include "PRM_ParmOwner.h"
29 #include "PRM_Template.h"
30 #include "PRM_Type.h"
31 
32 #include <CH/CH_Types.h>
33 #include <DEP/DEP_MicroNode.h>
34 
35 #include <UT/UT_IntArray.h>
36 #include <UT/UT_NonCopyable.h>
37 #include <UT/UT_SharedPtr.h>
38 #include <UT/UT_SmallObject.h>
39 #include <UT/UT_StringHolder.h>
40 #include <SYS/SYS_Types.h>
41 
42 #include <iosfwd>
43 
44 class PRM_Instance;
45 class PRM_Multi;
46 class PRM_ParmList;
47 class PRM_Range;
48 class PRM_RefId;
49 class PRM_Value;
50 class CH_Channel;
51 class CH_Collection;
52 class CH_FullKey;
53 class UT_JSONValueMap;
54 class UT_String;
55 class UT_StringHolder;
56 class UT_TokenString;
57 
58 
59 /// An enumeration specifying how, if wanted, keys are set when values are
60 /// set.
62 {
63  PRM_AK_MARK_PENDING, ///< Keys are not immediately added for the value
64  /// being but marked as pending.
65  PRM_AK_SET_KEY, ///< Keys are added if the current value differs
66  /// from the value being set.
67  PRM_AK_FORCE_KEY ///< Keys are added even if the current value
68  /// matches the value being set.
69 };
70 
71 
73 {
76 };
77 
79 {
80 public:
81  PRM_DataItem() = default;
82  virtual ~PRM_DataItem() = default;
83 
85 
86  virtual PRM_Type::PRM_DataType getDataType() const = 0;
87  virtual const char *getDataTypeToken() const = 0;
88  virtual bool saveAscii(std::ostream &os) const = 0;
89  virtual bool saveBinary(std::ostream &os) const = 0;
90  virtual int64 getMemoryUsage() const = 0;
91 
92  // Override to return true only when getDataTypeToken() and saveAscii()
93  // are guaranteed to not contain any characters that require escaping or
94  // insertion of quotes to protect.
95  //
96  // For example, this will typically be the case for saveAscii() if it is
97  // UT_Base64 encoded.
98  virtual bool canSaveAsUnprotectedString() const { return false; }
99 
100  // Data accessors.
101  virtual UT_JSONValueMap *getKeyValueDict() const { return nullptr; }
102 };
104 
106 {
107 public:
108  PRM_DataFactory() = default;
109  virtual ~PRM_DataFactory() = default;
110 
112 
113  virtual const char *getDataTypeToken() const = 0;
114  virtual PRM_DataItemHandle loadBinary(UT_IStream &is) const = 0;
115  virtual PRM_DataItemHandle loadAscii(UT_IStream &is) const = 0;
116 
117  static void install(const char *type, PRM_DataFactory *factory);
118  static PRM_DataItemHandle parseAscii(const char *type, UT_IStream &is);
119  static PRM_DataItemHandle parseBinary(const char *type, UT_IStream &is);
120 
121  /// Loads a type:data string, the type determines which datafactory
122  /// which then calls parseAscii(type, is);
123  static PRM_DataItemHandle loadTypedAscii(UT_IStream &is);
124  /// Saves type:data. Empty data doesn't write anything.
125  static void saveTypedAscii(
126  const PRM_DataItemHandle &item,
127  std::ostream &os);
128 };
129 
131 {
132 public:
133  PRM_UndoData() = default;
134  virtual ~PRM_UndoData() = default;
135 
137 
138  virtual const char *getDataType() const = 0;
139  virtual int64 getMemoryUsage() const = 0;
140 };
141 
144 
145 class PRM_API PRM_Parm : public UT_SmallObject<PRM_Parm,
146  UT_SMALLOBJECT_CLEANPAGES_DEFAULT,
147  UT_SMALLOBJECT_PAGESIZE_DEFAULT,
148  UT_SMALLOBJECT_THREADSAFE_OFF>
149 {
150 public:
151  // for these constructors, a nil CH_Collection is invalid
152  // only PRM_ParmList handles a nil correctly
153  PRM_Parm(PRM_Template *thetemplate,
154  PRM_ParmList *owner);
155  PRM_Parm(PRM_Parm *theprm,
156  PRM_ParmList *owner);
157  ~PRM_Parm();
158 
160 
161  void adopt(PRM_Parm &thesrcparm);
162  void adoptOverrides(PRM_Parm &srcparm);
163 
164  void revertToDefaults(fpreal time);
165  void revertToDefault(fpreal time, int index, bool propagate=true);
166  void restoreFactoryDefaults();
167  void restoreFactoryDefault(int index);
168 
170  { return myDestructiveRevertToDefaultFlag; }
172  { myDestructiveRevertToDefaultFlag = v; }
173 
175  { return myRevertInvisibleToDefaultsFlag; }
177  { myRevertInvisibleToDefaultsFlag = v; }
178 
180  { return myMakeSpareParmsForUnknownChannelsFlag; }
182  { myMakeSpareParmsForUnknownChannelsFlag = v; }
183 
184  // Static functions to access PRM_Instance subclass static functions.
185  static bool isStringThatCanExpand(const char *str);
186  static bool isOrdinalExpression(const char *str,
187  const PRM_Template *tplate = nullptr);
188  static bool isOrdinalExpression(const PRM_Default &dflt,
189  const PRM_Template *tplate = nullptr);
190 
191  // Static functions to convert string parm values to and from
192  // expressions.
193  static void convertStringToExprLanguage(const char *str,
194  UT_String &expr,
195  PRM_Template *tplate = nullptr);
196  static void convertStringFromExprLanguage(const char *str,
197  UT_String &expr);
198 
199  // Static functions to access PRM_Multi static functions.
200  static bool getIsAddingOrRemovingMultiParms();
201  // Instance a string, replacing all '#' marks with integers from the
202  // index list.
203  // WARNING: These two functions behave differently!
204  // see PRM_Multi::instanceString (PRM_Multi.h)
205  static void instanceMultiString(UT_String &token,
206  const UT_IntArray &indexlist,
207  bool fill_remaining=true);
208  static void instanceMultiString(UT_String &token,
209  const int *indexlist, int num,
210  bool fill_remaining=true);
211  static void instanceMultiString(UT_StringHolder &token,
212  const UT_IntArray &indexlist,
213  bool fill_remaining=true);
214  static void instanceMultiString(UT_StringHolder &token,
215  const int *indexlist, int num,
216  bool fill_remaining=true);
217 
218  static bool getAlwaysHardenFlag() { return myAlwaysHardenFlag; }
219  static void setAlwaysHardenFlag(bool o) { myAlwaysHardenFlag = o; }
220 
221  int isDefault() const;
222  int isDefault(int index) const;
223  int isFactoryDefault() const;
224  int isFactoryDefault(int index) const;
225 
226  // isTrueFactoryDefault differs from isFactoryDefault in that it
227  // will do a string compare on the expression if there is one, thus
228  // an expression that evaluates to the default value will still not be a
229  // "true" factory default.
230  int isTrueFactoryDefault(int index) const;
231  int isTrueFactoryDefault() const;
232 
233  // These are exactly like isTrueFactoryDefault() except that it excludes
234  // the checking of the lock flag. This is because we don't want locked
235  // parms to show up bolded in the parameters pane.
236  int isFactoryDefaultUI(int index) const;
237  int isFactoryDefaultUI() const;
238 
239  void overwriteDefaults(fpreal time);
240  void overwriteDefault(fpreal time, int index);
241 
242  void buildOpDependencies(const PRM_RefId &ref_id, int thread);
243  void changeOpRef(const char *new_fullpath, const char *old_fullpath,
244  const char *old_cwd, const char *chan_name,
245  const char *old_chan_name,
246  void (*undo_callback)(void *), void *undo_data,
247  int thread);
248 
249  void getValue(fpreal time, int32 &value, int index,
250  int thread) const;
251  void getValue(fpreal time, int64 &value, int index,
252  int thread) const;
253  void getValue(fpreal time, fpreal &value, int index,
254  int thread) const;
255  void getValue(fpreal time, UT_String &value, int index,
256  bool expand, int thread) const;
257  void getValue(fpreal time, UT_StringHolder &value, int index,
258  bool expand, int thread) const;
259  void getValue(fpreal time, PRM_DataItemHandle &value, int index,
260  int thread) const;
261 
262  // Specialized variant for Key-Value Dictionary data parameters.
263  // Return either an expanded or unexpanded JSON map.
264  void getValue(fpreal time, UT_JSONValueMap &value, int index,
265  bool expand, int thread) const;
266 
267  void getValues(fpreal time, fpreal32 *value, int thread) const;
268  void getValues(fpreal time, fpreal64 *value, int thread) const;
269  void getValues(fpreal time, int32 *value, int thread) const;
270  void getValues(fpreal time, int64 *value, int thread) const;
271  void getDefaultValue(fpreal &value, int index) const;
272  void getDefaultValue(UT_String &value, int index) const;
273 
274  // The following method is very similar to getExpressionOrValue() except
275  // that it returns a custom string when the parameter is overridden by a
276  // CHOP.
277  void getExpressionStringForUI(fpreal time, UT_String &value,
278  int index, int thread) const;
279 
280  // The following method, unlike getExpressionOnly(), will convert the
281  // value to a string and return that if there is no channel.
282  void getExpressionOrValue(fpreal time, UT_String &value,
283  int index, int thread) const;
284  void getExpressionOrValue(fpreal time, UT_StringHolder &value,
285  int index, int thread) const;
286 
287  // The following method returns the expression string, returning an empty
288  // string in the case of a parameter with no channel/expression.
289  void getExpressionOnly(fpreal time, UT_String &value,
290  int index, int thread) const;
291 
292  bool setExpression(fpreal time, const char *value,
293  CH_ExprLanguage language,
294  int index, bool evaluate = true,
295  bool rmchannel = false, bool propagate = true);
296 
297  /// @{ Sets the new value of the parameter.
298  /// @return @c true if the value was set; false otherwise (eg, parm locked).
299  /// @note
300  /// These methods don't save the old value ont the undo stack.
301  /// For that, use OP_Parameters::setString(), or alternatively
302  /// explicitly call UTaddToUndoBlock(OP_UndoParm()) yourself.
303  bool setValue(fpreal time, const char *value,
304  CH_StringMeaning meaning,
305  bool kill_expr = false, int index = 0,
307  bool propagate = true);
308 
309  bool setValue(fpreal time, fpreal value,
310  bool kill_expr = false, int index = 0,
312  bool propagate = true);
313 
314  bool setValue(fpreal time, int32 value,
315  bool kill_expr = false, int index = 0,
317  bool propagate = true);
318 
319  bool setValue(fpreal time, int64 value,
320  bool kill_expr = false, int index = 0,
322  bool propagate = true);
323 
324  bool setValue(fpreal time, const PRM_DataItemHandle &value,
325  bool kill_expr = false, int index = 0,
327  bool propagate = true);
328  /// @}
329 
330  //
331  // The setValues methods set all entries in the vector at once...
332  // returns true if the values were set, of false otherwise (eg, parm locked)
333  //
334  bool setValues(fpreal time, const fpreal32 *values,
335  bool kill_expr = false,
337  bool propagate = true);
338  bool setValues(fpreal time, const fpreal64 *values,
339  bool kill_expr = false,
341  bool propagate = true);
342  bool setValues(fpreal time, const int32 *values,
343  bool kill_expr = false,
345  bool propagate = true);
346 
347  bool setValues(fpreal time, const int64 *values,
348  bool kill_expr = false,
350  bool propagate = true);
351 
352  //
353  // Multi Parms methods.
354  //
355 
356  // Returns true if the parm is a multi parm
357  bool isMultiParm() const;
358 
359  // Insert a new Multi Parm Instance before index.
360  // If index equals zero, the parm instance can be added at the start of the
361  // list.
362  // If index equals MultiParmNumItems(), the parm instance is added at the
363  // end of the list.
364  void insertMultiParmItem(int index, bool propagate = 1);
365 
366  // Remove Multi Parm Instance at index.
367  void removeMultiParmItem(int index, bool propagate = 1);
368 
369  // Revert Multi Parm Instance at index.
370  void revertMultiParmItem(int index);
371 
372  // Revert all the multi parm instances. This is has different behaviour for
373  // ramps in that it will revert to the initialized state.
374  void revertAllMultiParmItems();
375 
376  // Copy all the Parm Values under the Multi Parm Instance from index 'from'
377  // to index 'to'.
378  void assignMultiParmItem(int from, int to);
379 
380  // Swap 2 Multi Parm instances.
381  // This can be used to move up and down param instances in the list.
382  void swapMultiParmItem(int from, int to);
383 
384  // Move Multi Parm instances give a list of move operations.
385  // @moves is an array of from and to pair<int,int> representing the move
386  // operations to perform.
387  void moveMultiParmItems(
388  const UT_Array<std::pair<int,int>> &moves);
389 
390  // Returns the number of instance parameters.
391  int getMultiParmNumItems() const;
392 
393  // Returns the number of parameters within an instance parameter.
394  // It returns 1 for array of simple types ( int, float, string ).
395  // It returns the number of parameters within the struct for array of
396  // structs.
397  int getMultiParmInstancesPerItem() const;
398 
399  // Returns the param token for an instance parm at 'index' and child parm
400  // at 'p'.
401  const char* getMultiParmToken(int p, int index) const;
402 
403  // Returns the number of UI Parms Entries.
404  // A float3 or color4 will account for a single parameter.
405  // An int, string or float will account for one parm as well.
406  int getMultiParmUIEntries() const;
407 
408  // Returns the PRM_Template at index 'idx'
409  const PRM_Template *getMultiParmTemplate(int idx) const;
410  PRM_Template *getMultiParmTemplate(int idx);
411 
412  // These functions allow a linear traversal of all multiparm instance
413  // parameters.
414  PRM_Parm *getMultiParm(int idx) const;
415  int getMultiParmCount() const;
416 
417  // The only difference between the next two functions is that the
418  // second sends the change notification without question. The first
419  // calls the second, but only if the parm isn't a PRM_CALLBACK. In
420  // those cases we usually don't want to actually send out change
421  // notifications. The notable exception is the opparm -c command.
422  void valueChanged(int vec_idx, bool propagate)
423  { privateValueChanged(vec_idx, propagate,
424  /*update_multi*/true); }
425  void sendValueChanged(int vec_idx, bool propagate);
426  void indirectChange(int vec_idx, bool expr_changed,
427  bool update_multi = true);
428 
429  PRM_Callback getCallback() { return getTemplatePtr()->getCallback(); }
430  int setOverride(int index, int data_idx, const char *source,
432  const char *getOverride(int index) const;
433  int getOverrideDataIndex(int index) const;
434  bool getOverrideNodePath(int index, UT_String &path) const;
435  bool getOverrideTrackName(int index, UT_String &trackname) const;
436  bool getOverrideType(int index, PRM_OverrideType &type) const;
437  int setOverrideDisable(int index, int onoff);
438  int getIsOverrideActive(int index) const;
439 
440  /// copyParm() copies the value of an entire parm, including channels. If
441  /// it is a multi-parm, then all instance parameters will be also be
442  /// copied. If the they are a mismatch of vector sizes, the smaller of the
443  /// two sizes will be used.
444  ///
445  /// If current_value_only is true, then only the value evaluated at time t
446  /// will be copied. Otherwise, any channels in the src_parm will be copied
447  /// wholesale.
448  void copyParm(const PRM_Parm &src,
449  bool current_value_only = false,
450  fpreal t = 0.0);
451 
452  /// copyValue copies the value for a particular parm component. If
453  /// current_value_only is true, then only the value evaluated at time t
454  /// will be copied. Otherwise, any channels in the src_parm will be copied
455  /// wholesale.
456  void copyValue(fpreal t, int dest_vi,
457  const PRM_Parm &src_parm, int src_vi,
458  bool set_name_alias,
459  bool current_value_only,
460  bool set_value_to_default = false,
462  PRM_KeySetType key_set_type = PRM_USE_PREFERENCES);
463 
464  void addChannels();
465  void addChannel(int index, bool propagate = true);
466  void addChannel(int index, const char *theexpr,
467  CH_ExprLanguage language, bool propagate = true);
468  int addChannel(const char *name);
469  int addChannel(const char *name, const char *expr,
470  CH_ExprLanguage language);
471 
472  void clearAndDestroyChannels(bool force = false);
473  void removeChannel(int index, bool propagage = true);
474 
475  // Destroy and clear references to those channels not referenced by the
476  // supplied replacement parameter.
477  void clearAndDestroyUnrefChannels(const PRM_Parm &repl_parm);
478 
479  CH_Channel *getChannel(int subindex) const;
480  int getChannelCount() const;
481 
482  void reloadChannelPtrs();
483  int channelPtrModified(const char *name);
484 
485  int isTimeDependent() const;
486  bool isTimeDependent(int subindex) const;
487  int isDataDependent(fpreal gtime) const;
488  bool isDataDependent(fpreal gtime, int subindex) const;
489  void forceTimeDependent(int subindex);
490 
491  bool hasContextOptionDeps(int subindex) const;
492  const DEP_ContextOptionDeps &getContextOptionDeps(int subindex) const;
493  bool hasGlobalContextOptionDependency(int subindex,
494  const UT_StringRef &opt) const;
495  void forceContextOptionDep(int subindex,
496  const UT_StringHolder &opt,
497  bool set_dependency_on_global,
498  bool node_is_cooking);
499 
500  const PRM_Type &getType() const;
501  PRM_TypeExtended getTypeExtended() const;
502  PRM_MultiType getMultiType() const;
503  fpreal getMultiSize() const;
504  int getMultiStartOffset() const;
505 
506  bool isRampType() const;
507  bool isRampTypeColor() const;
508 
509  int getVectorSize() const
510  { return getTemplatePtr()->getVectorSize(); }
511 
512  /// Can be the PRM_Template's range or a range owned by the instance.
513  /// Note: resetRange() or setRange() will invalidate the resulting pointer.
514  const PRM_Range *getRangePtr() const;
515 
516  /// Set the parameter's custom range.
517  /// Parameter evaluation must be constrained by both the parameter's range
518  /// and the PRM_Template's range.
519  void setRange(const PRM_Range *range);
520  void setRange(fpreal min, fpreal max);
521 
522  /// Returns true if the instance's range is that of its PRM_Template.
523  bool isRangeDefault() const;
524 
525  /// Set the instance's range to that of its PRM_Template.
526  void setRangeToDefault();
527 
528  void getChannelToken(UT_String &thestrref, int index = 0) const;
529  void getChannelLabel(UT_String &thestrref, int index = 0) const;
530  void getToken(UT_String &thestrref) const;
531  void getLabel(UT_String &thestrref) const;
532  void getHelpText(UT_String &helptext) const;
533  void getHelpUrl(UT_String &helptext) const;
534  void getHelpTitle(UT_String &helptext) const;
535 
536  const char *getToken() const;
537  const char *getLabel() const;
538 
539  const UT_StringRef &
540  getTokenRef() const
541  { return getTemplatePtr()->getTokenRef(); }
542 
543  const UT_StringHolder &
544  getChannelToken(int vi = 0) const
545  { return getTemplatePtr()->getChannelToken(vi); }
546 
547  const UT_StringHolder &
548  getDecodedChannelToken(int vi = 0) const
549  { return getTemplatePtr()->getDecodedChannelToken(vi); }
550 
551  void getChannelLabelForUI(UT_String &thestrref, int vec_idx) const;
552 
553  const PRM_SpareData *getSparePtr() const;
554 
555  unsigned getTokenHash() const;
556 
557  bool hasChannelAlias(int subindex) const ;
558  void getChannelAlias(UT_String &stringref, int subindex) const;
559  const UT_StringHolder &
560  getChannelAlias(int subindex) const;
561 
562  // This performs all the checks to verify that a parameter can be accessed
563  bool canAccess(uint mask) const;
564 
565  // Sets a channel alias.
566  // Do not use this call -- use the OP_Node version to ensure that all
567  // dependencies and symbol tables are updated correctly.
568  bool setChannelAlias(const char *token_alias, int subindex);
569 
570  PRM_ChoiceList *getChoiceListPtr();
571  const PRM_ChoiceList *getChoiceListPtr() const;
572 
573  // Return the group input notify value. It is nil by default, but
574  // can be created by calling createInputNotifyValue.
575  PRM_Value *inputNotifyValue();
576  void createInputNotifyValue();
577 
578  DEP_MicroNode & microNode(int vi);
579  bool hasMicroNodes() const;
580 
581  // A parameter becomes dirty whenever its value is set.
582  int isDirty(int vector_idx=0) const;
583  int areAllFlagsClean() const;
584  void clearAllDirtyFlags();
585 
586  // mySendExtraFlags is a per-component bitfield that has its bit set
587  // if it needs to be dirty propagated.
588  bool isSendExtra(int vi) const;
589  bool hasAnySendExtraFlags() const;
590 
591  int findSubIndex(const char *thechannelname, bool allow_alias) const;
592 
593  const PRM_Template *getTemplatePtr() const;
594  PRM_Template *getTemplatePtr();
595 
596  const PRM_Instance *getInstancePtr() const;
597  PRM_Instance *getInstancePtr();
598 
599  CH_Collection *getChannelGroupPtr() const;
600 
601  unsigned getEnableState(int comp = -1) const;
602  unsigned getInstanceEnableState(int comp = -1) const;
603  int setEnableState(int thestate, int comp = -1);
604 
605  bool getActiveTakeFlag() const;
606  bool getAlwaysTakeFlag() const;
607  void setActiveTakeFlag(int onoff);
608  bool getBypassFlag() const;
609  void setBypassFlag(bool v);
610 
611  bool getVisibleState(int comp = -1) const;
612  bool setVisibleState(bool f, int comp = -1);
613 
614  int getExpressionState();
615  void setExpressionState(int state);
616  int getValueState();
617  void setValueState(int state);
618 
619  // Query whether a parameter dialog should call setValue() to record any
620  // changes made by the user. Note that this does not control whether or
621  // not the field should be disabled.
622  bool isValueEditableByUI(fpreal time, int index) const;
623 
624  // Query whether a parameter dialog should call setExpression() to record
625  // any changes made by the user. Note that this does not control whether
626  // or not the field should be disabled.
627  bool isExpressionEditableByUI(fpreal time, int index) const;
628 
629  // hardenChanges() will create keys if the parm already has channels
630  void hardenChanges(fpreal time, bool forceflag = 0,
631  const char *patt = nullptr,
632  CH_ChannelRefList *list = nullptr);
633  void hardenChanges(fpreal time, int index, bool forceflag = 0,
634  const char *patt = nullptr,
635  CH_ChannelRefList *list = nullptr);
636  // setKey() will create keys even if the parm has no channels
637  void setKey(fpreal time, int index);
638  void setKey(fpreal time, int index, const char *exp,
639  CH_ExprLanguage language,
640  const char *patt = nullptr,
641  CH_ChannelRefList *list = nullptr);
642 
643  void setFullKey(fpreal gtime, int index, CH_FullKey const& key,
644  bool accel_ratios = true);
645 
646  CH_StringMeaning getStringMeaning(fpreal time, int index) const;
647 
648  // If this parm contains an expression this function returns that
649  // expression's language. Otherwise, it returns the language that it
650  // would be if it was turned into an expression.
651  CH_ExprLanguage getExprLanguageIfMadeAnExpression(fpreal time, int index) const;
652 
653  // If there is an expression, this function returns whether the
654  // expression's language for the segment at the given time is old Expr.
655  // If there is no expression, this function returns true.
656  bool isLanguageOldExprOrLiteral(fpreal time, int index);
657 
658  int changePending(int index);
659  PRM_ChanState getChanState(fpreal time) const;
660  PRM_ChanState getChanState(fpreal time, int index) const;
661 
662  void save(std::ostream &os, int binary, bool compiled) const;
663  bool load(UT_IStream &is);
664 
665  void saveUndoData(PRM_UndoDataHandle &data) const;
666  bool loadUndoData(const PRM_UndoDataHandle &data);
667 
668  void saveCommand(std::ostream &os, int values=0, int index=-1) const;
669  int loadCommand(int argc, const char *const argv[], int index,
670  bool values_only, PRM_KeySetType set_type);
671 
672  fpreal findNextKey(fpreal theoldtime, int index = -1);
673  fpreal findPrevKey(fpreal theoldtime, int index = -1);
674 
675  int findString(const char *str, bool fullword,
676  bool usewildcards) const;
677  int changeString(const char *from, const char *to, bool fullword);
678 
679  bool notifyVarChange(const char *varname);
680 
681  bool getUndoSavedFlag();
682 
683  // WARNING: the setUndoSavedFlag method should only be called from
684  // OP_Parameters. Calling it from anywhere else can cause undo errors.
685  void setUndoSavedFlag(bool f);
686 
687  bool getAutoTakeUndoSavedFlag();
688 
689  // WARNING: the setAutoTakeUndoSavedFlag method should only be called from
690  // OP_Parameters. Calling it from anywhere else can cause undo errors.
691  void setAutoTakeUndoSavedFlag(bool f);
692 
693  bool getLockedFlag(int vec_idx) const;
694  bool areAllComponentsLocked() const;
695  void setLockedFlag(int vec_idx, bool f);
696  unsigned int getLockedField() const;
697  bool getAutoScopedFlag(int vec_idx) const;
698  void setAutoScopedFlag(int vec_idx, bool f);
699  unsigned int getAutoScopedField() const;
700 
701 
702  bool getMagicString(UT_TokenString &string, fpreal t,
703  int parm_group_mask /*=1*/,
704  bool add_if_default /*= true*/,
705  bool ignore_group /*= false*/,
706  int thread);
707 
708  void destroyChildParms();
709 
711  { return myOwner; }
712 
713  PRM_ParmOwner *getParmOwner() const;
714 
715  // Returns true if this parm is compatible with other_parm. Being
716  // compatible means that the two parms have the same token string,
717  // the same size and are of the same type.
718  bool isCompatible(const PRM_Parm &other_parm) const;
719 
720  // Returns true if the parm is of the basic type check_type, as defined
721  // in PRM_Type.h as basic types.
722  bool isOfBasicType(const PRM_Type &check_type) const;
723 
724  // Returns true if this parm and other_parm are of the same basic type,
725  // and have equal values (including evaluated expressions), and false
726  // otherwise.
727  bool isParmValueEqual(PRM_Parm &other_parm, int vec_index,
728  fpreal time, int thread) const;
729  bool isParmValueEqual(int vec_index, PRM_Parm &other_parm,
730  int other_index, fpreal time,
731  int thread) const;
732 
733  // Returns true if the channame is the token (or alias) of the channel at
734  // vec_index, and returns false otherwise.
735  // The length of channame can be given in channamelen to spped up rejections
736  // if the caller caches the string length.
737  bool hasChannelName(const UT_StringRef &channame,
738  int vec_index) const;
739 
740  // Returns the aliases of all the channels in this parm in one string
741  // separated by the character sep.
742  void getAllChannelAliases(UT_String &aliasstring,
743  char sep ='/') const;
744 
745  // Methods for accessing and setting the active handle binding flag
746  bool isActive(const int index) const;
747  void setActive(const int index, const bool active);
748 
749  int64 getMemoryUsage(bool inclusive) const;
750 
751  bool isSpareParm() const;
752  void setSpareParm(bool sp) const;
753 
754  const PRM_Instance *getMultiParmOwner() const;
755  void setMultiParmOwner(const PRM_Multi *multiparmowner);
756 
757  /// Returns the multi-parm template for this child parm. Returns nullptr
758  /// if this parm is not part of a multi-parm
759  const PRM_Template *findMultiParmTemplate() const;
760 
761  /// Return the list of instance indicies for this parameter.
762  /// If this parameter is part of a multi-parameter, then its index in the
763  /// multi-parm array will be inserted into the indices array. If the
764  /// multi-parm is nested in other multi-parms, then the indices array will
765  /// have multiple entries (with the outer multi-parm listed first, and the
766  /// inner-most multi-parm last in the array).
767  /// \param indices The list of index instances.
768  /// \param instance_index Each multi-parm can have multiple parameters in
769  /// each instance. If instance_index is true, the instance number will be
770  /// returned. Otherwise the raw offset into the multi-parm will be
771  /// extracted.
772  int getMultiInstanceIndex(UT_IntArray &indices,
773  bool instance_index=true) const;
774 
775  void rebuildParmDependency();
776 
777  bool isRotationParm() const;
778 
779  // For explanations of path vs ch_name, see comment for
780  // constructChannelReference
781  void setChannelReference(fpreal time,
782  int index,
783  const char *path,
784  const char *ch_name=nullptr,
785  bool evaluate=true,
786  bool rmchannel=false);
787 
788  // Construct the string representing reference to the channel given by
789  // path/name from this parameter.
790  // If name == nullptr, path is assumed to be (node path + channel name)
791  // If name not nullptr, path is assumed to be a path without channel name,
792  // name is assumed to be channel name without the path.
793  void constructChannelReference(UT_String &reference,
794  CH_ExprLanguage language,
795  const char *path,
796  const char *ch_name=nullptr);
797 
798  static bool isChanRefString(const char *str, bool is_expr,
799  UT_String *chref = nullptr);
800 
801  bool getHaveCompiledExpressions() const;
802 
803 
804  // Set a flag to have the label persisted with the parm.
805  // This is used to set a label on multi params
806  void setSaveLabelFlag(bool f);
807 
808  // Custom Channel Color that persists when set.
809  bool hasChannelCustomColor(int index) const;
810  const UT_Color &getChannelCustomColor(int index) const;
811  void setChannelCustomColor(int index, const UT_Color &c);
812  void resetChannelCustomColor(int index);
813 
814  bool getAutoSelectFlag(int vec_idx) const;
815  void setAutoSelectFlag(int vec_idx, bool f);
816  unsigned int getAutoSelectField() const;
817 
818  void setTimeDependentMicroNode(int subindex, bool timedep) const;
819 private:
820  void privateValueChanged(
821  int vec_idx,
822  bool propagate,
823  bool update_multi);
824 
825  template <typename DstT, typename SrcT>
826  bool setValuesT(
827  const fpreal time,
828  const SrcT *values,
829  bool kill_expr,
830  PRM_AddKeyType add_key,
831  bool propagate);
832 
833  static PRM_AddKeyType getAddKeyValue(PRM_AddKeyType add_key);
834 
835 private:
836  PRM_Instance *myInstancePtr;
837  PRM_ParmList *myOwner;
838 
839  static bool myAlwaysHardenFlag;
840  static bool myDestructiveRevertToDefaultFlag;
841  static bool myRevertInvisibleToDefaultsFlag;
842  static bool myMakeSpareParmsForUnknownChannelsFlag;
843 
844  friend class PRM_ParmList;
845 };
846 
847 // UTformat support.
848 PRM_API size_t
849 UTformatBuffer(char *buffer, size_t buffer_size, const PRM_Parm &v);
850 
851 #endif
CE_API bool evaluate(const CE_OSDRefinement &topo, const CE_OSDEvaluator &eval, const cl::Buffer &coarse, const CE_OSDPatchCoords &patch_coords, const CE_FloatArray *refined_data, cl::Buffer &out, cl::Buffer *du, cl::Buffer *dv)
PRM_OverrideType
Definition: PRM_Parm.h:72
PRM_AddKeyType
Definition: PRM_Parm.h:61
GLsizei GLenum const void * indices
Definition: glcorearb.h:406
UT_JSONValueMap stores a map/dictionary of UT_JSONValue objects.
bool isDefault(const cgltf_texture_view &tv)
int int32
Definition: SYS_Types.h:39
GLenum GLint * range
Definition: glcorearb.h:1925
const UT_StringRef & getTokenRef() const
Definition: PRM_Parm.h:540
static bool getDestructiveRevertToDefaultFlag()
Definition: PRM_Parm.h:169
CH_ExprLanguage
CH_StringMeaning
GT_API const UT_StringHolder time
const GLdouble * v
Definition: glcorearb.h:837
static bool getMakeSpareParmsForUnknownChannelsFlag()
Definition: PRM_Parm.h:179
UT_SharedPtr< PRM_UndoData > PRM_UndoDataHandle
Definition: PRM_Parm.h:142
int getVectorSize() const
Definition: PRM_Parm.h:509
GLsizei const GLfloat * value
Definition: glcorearb.h:824
const GLuint GLenum const void * binary
Definition: glcorearb.h:1924
UT_ConcurrentSet< UT_StringHolder > DEP_ContextOptionDeps
UT_Array< std::pair< UT_StringHolder, PRM_UndoDataHandle > > PRM_UndoDataList
Definition: PRM_Parm.h:143
GLsizei const GLchar *const * path
Definition: glcorearb.h:3341
virtual bool canSaveAsUnprotectedString() const
Definition: PRM_Parm.h:98
PRM_KeySetType
ImageBuf OIIO_API min(Image_or_Const A, Image_or_Const B, ROI roi={}, int nthreads=0)
static void setMakeSpareParmsForUnknownChannelsFlag(bool v)
Definition: PRM_Parm.h:181
float fpreal32
Definition: SYS_Types.h:200
virtual UT_JSONValueMap * getKeyValueDict() const
Definition: PRM_Parm.h:101
GLuint buffer
Definition: glcorearb.h:660
static bool getRevertInvisibleToDefaultsFlag()
Definition: PRM_Parm.h:174
__hostdev__ float getValue(uint32_t i) const
Definition: NanoVDB.h:5578
double fpreal64
Definition: SYS_Types.h:201
UT_SharedPtr< const PRM_DataItem > PRM_DataItemHandle
Definition: APEX_Include.h:55
GLfloat f
Definition: glcorearb.h:1926
GLint GLint GLsizei GLint GLenum GLenum type
Definition: glcorearb.h:108
const UT_StringHolder & getDecodedChannelToken(int vi=0) const
Definition: PRM_Parm.h:548
std::shared_ptr< T > UT_SharedPtr
Wrapper around std::shared_ptr.
Definition: UT_SharedPtr.h:36
static void setAlwaysHardenFlag(bool o)
Definition: PRM_Parm.h:219
PRM_ChanState
Definition: PRM_ChanState.h:14
GLsizei GLsizei GLchar * source
Definition: glcorearb.h:803
#define UT_NON_COPYABLE(CLASS)
Define deleted copy constructor and assignment operator inside a class.
GLint GLuint mask
Definition: glcorearb.h:124
void valueChanged(int vec_idx, bool propagate)
Definition: PRM_Parm.h:422
long long int64
Definition: SYS_Types.h:116
PRM_Callback getCallback()
Definition: PRM_Parm.h:429
GLuint const GLchar * name
Definition: glcorearb.h:786
const UT_StringHolder & getChannelToken(int vi=0) const
Definition: PRM_Parm.h:544
static void setRevertInvisibleToDefaultsFlag(bool v)
Definition: PRM_Parm.h:176
SYS_FORCE_INLINE UT_StringHolder getToken(Add enum_value)
Definition: SOP_Add.proto.h:35
that also have some descendant prim *whose name begins with which in turn has a child named baz where *the predicate active
GLdouble t
Definition: glad.h:2397
static bool getAlwaysHardenFlag()
Definition: PRM_Parm.h:218
**Note that the tasks the is the thread number *for the or if it s being executed by a non pool thread(this *can happen in cases where the whole pool is occupied and the calling *thread contributes to running the work load).**Thread pool.Have fun
SIM_API const UT_StringHolder force
GLenum GLsizei GLsizei GLint * values
Definition: glcorearb.h:1602
PRM_TypeExtended
Definition: PRM_Type.h:521
fpreal64 fpreal
Definition: SYS_Types.h:283
GLuint index
Definition: glcorearb.h:786
ImageBuf OIIO_API max(Image_or_Const A, Image_or_Const B, ROI roi={}, int nthreads=0)
PRM_DataType
Definition: PRM_Type.h:116
PRM_ParmList * getOwner() const
Definition: PRM_Parm.h:710
PRM_API size_t UTformatBuffer(char *buffer, size_t buffer_size, const PRM_Parm &v)
that also have some descendant prim *whose name begins with which in turn has a child named baz where *the predicate and *a name There is also one special expression reference
#define PRM_API
Definition: PRM_API.h:10
unsigned int uint
Definition: SYS_Types.h:45
state
Definition: core.h:2289
static void setDestructiveRevertToDefaultFlag(bool v)
Definition: PRM_Parm.h:171
UT_SharedPtr< const PRM_DataItem > PRM_DataItemHandle
Definition: PRM_Parm.h:103
Definition: format.h:1821
PRM_MultiType
This type enum defines the different types of multi (dynamic) parameters.
Definition: PRM_Type.h:426
GLenum src
Definition: glcorearb.h:1793