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