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