HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
PRM_Instance.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_Instance.h (Parameter Library)
7  *
8  * COMMENTS:
9  * A PRM_Instance contains all the variable data relating to
10  * parameters. In other words it contains the actual values
11  * of the parameter. The types and format of the values are
12  * specified in the PRM_Template portion of a parameter. A
13  * PRM_Instance is to a PRM_Template as an object is to a
14  * class in C++.
15  */
16 
17 #ifndef __PRM_Instance_h__
18 #define __PRM_Instance_h__
19 
20 #include "PRM_API.h"
21 #include "PRM_Callback.h"
22 #include "PRM_ChanState.h"
23 #include "PRM_Default.h"
24 #include "PRM_Error.h"
25 #include "PRM_KeySetType.h"
26 #include "PRM_Parm.h"
27 #include "PRM_ParmList.h"
28 #include "PRM_Template.h"
29 #include "PRM_Type.h"
30 
31 #include <CH/CH_Collection.h>
32 #include <CH/CH_ExprLanguage.h>
33 #include <CH/CH_Manager.h>
34 #include <CH/CH_Types.h>
35 #include <DEP/DEP_MicroNode.h>
36 
37 #include <EXPR/EX_Error.h>
38 #include <UT/UT_Assert.h>
39 #include <UT/UT_Color.h>
40 #include <UT/UT_ValArray.h>
41 #include <UT/UT_String.h>
42 #include <UT/UT_StringHolder.h>
43 #include <UT/UT_SmallObject.h>
44 #include <UT/UT_TBBSpinLock.h>
45 #include <UT/UT_UniquePtr.h>
46 #include <UT/UT_VectorTypes.h>
47 #include <SYS/SYS_Inline.h>
48 #include <SYS/SYS_Types.h>
49 
50 #include <iosfwd>
51 
52 
53 class PRM_ChoiceList;
54 class PRM_Multi;
55 class PRM_ParmMicroNode;
56 class PRM_ParmOwner;
57 class PRM_Range;
58 class PRM_RefId;
59 class PRM_Value;
60 class CH_Channel;
61 class CH_FullKey;
62 class UT_IStream;
63 class UT_JSONValueMap;
64 class UT_Packet;
65 class UT_TokenString;
67 
68 
70 
71 class PRM_API PRM_Instance : public UT_SmallObject<PRM_Instance,
72  UT_SMALLOBJECT_CLEANPAGES_DEFAULT,
73  UT_SMALLOBJECT_PAGESIZE_DEFAULT,
74  UT_SMALLOBJECT_THREADSAFE_OFF>
75 {
76 public:
77  PRM_Instance(PRM_Template *thetemplateptr,
78  PRM_Parm *parm);
79  PRM_Instance(PRM_Instance *thesrcptr,
80  PRM_Parm *parm);
81  virtual ~PRM_Instance();
82 
83  virtual void adopt(PRM_Instance &thesrcinstance);
84  virtual void adoptOverrides(PRM_Instance &thesrcinstance);
85 
86  virtual PRM_Instance *duplicateSelf(PRM_Parm *node) = 0;
87 
88  virtual void setValueToDefault(fpreal time, int index,
89  PRM_AddKeyType add_key) = 0;
90  virtual void revertToDefault(int index) = 0;
91  virtual void revertToDefaults(bool clear_channels =true) = 0;
92  virtual void restoreFactoryDefault(int index) = 0;
93  virtual void overwriteDefault(fpreal time, int index) = 0;
94  virtual void overwriteDefaults(fpreal time) = 0;
95  virtual int isDefault(int index, enum PRM_DefaultType deftype,
96  bool basiccheck = true) const;
97  bool isAllDefault(enum PRM_DefaultType deftype) const;
98 
99  virtual void save(std::ostream &os, int binary, bool compiled) const=0;
100  virtual bool load(UT_IStream &is) = 0;
101 
102  virtual void saveUndoData(PRM_UndoDataHandle &data) const;
103  virtual bool loadUndoData(const PRM_UndoDataHandle &data);
104 
105  virtual void saveCommand(std::ostream &os, int values=0, int index = -1)
106  const = 0;
107  virtual int loadCommand(int argc, const char *const argv[],
108  int index,
109  bool values_only,
110  PRM_AddKeyType add_key,
111  PRM_KeySetType set_type) = 0;
112 
113  virtual void getValue(PRM_ParmList *parm_list, fpreal time,
114  int32 &value, int index,
115  int thread) const = 0;
116  virtual void getValue(PRM_ParmList *parm_list, fpreal time,
117  int64 &value, int index,
118  int thread) const = 0;
119  virtual void getValue(PRM_ParmList *parm_list, fpreal time,
120  fpreal &value, int index,
121  int thread) const = 0;
122  virtual void getValue(PRM_ParmList *parm_list, fpreal time,
123  UT_String &value, int index,
124  bool expand, int thread) const = 0;
125  virtual void getValue(PRM_ParmList *parm_list, fpreal time,
126  PRM_DataItemHandle &value, int index,
127  int thread) const = 0;
128  virtual void getValue(PRM_ParmList *parm_list, fpreal time,
129  UT_JSONValueMap &value, int index,
130  bool expand, int thread) const = 0;
131  virtual void getValues(PRM_ParmList *parm_list, fpreal time,
132  fpreal32 *value, int thread) const;
133  virtual void getValues(PRM_ParmList *parm_list, fpreal time,
134  fpreal64 *value, int thread) const;
135  virtual void getValues(PRM_ParmList *parm_list, fpreal time,
136  int32 *theints, int thread) const;
137  virtual void getValues(PRM_ParmList *parm_list, fpreal time,
138  int64 *theints, int thread) const;
139  virtual void getDefaultValue(fpreal &value, int index) const;
140  virtual void getDefaultValue(int32 &value, int index) const;
141  virtual void getDefaultValue(int64 &value, int index) const;
142  virtual void getDefaultValue(UT_String &value, int index) const;
143 
144  virtual void getExpressionStringForUI(fpreal time,
145  UT_String &value,
146  int index,
147  int thread) const = 0;
148  virtual void getExpression(fpreal time, UT_String &value,
149  int index, bool allow_value,
150  int thread) const = 0;
151  virtual void setExpression(fpreal time,
152  const char *value,
153  CH_ExprLanguage language,
154  int index, bool evaluate = true,
155  bool rmchannel = false);
156 
157  CH_StringMeaning getStringMeaning(fpreal time, int index) const;
158 
159  // If this parm contains an expression this function returns that
160  // expression's language. Otherwise, it returns the language that it
161  // would be if it was turned into an expression.
162  CH_ExprLanguage getExprLanguageIfMadeAnExpression(fpreal time,
163  int index) const;
164 
165  // If there is an expression, this function returns whether the
166  // expression's language for the segment at the given time is the same as
167  // the node's langauge. If there is no expression, this function returns
168  // true.
169  bool languageIsNodesLanguage(fpreal time, int index) const;
170 
171  // set value of a parameter
172  // setkey - determines how the value is set at keyframes.
173  // Whether the preference is used or always set as pending
174  virtual void setValue(fpreal time,
175  const char *value,
176  CH_StringMeaning meaning,
177  bool kill_expr = false,
178  int index = 0,
181 
182  virtual void setValue(fpreal time,
183  fpreal value,
184  bool kill_expr = false,
185  const int index = 0,
188 
189  virtual void setValue(fpreal time,
190  int32 value,
191  bool kill_expr = false,
192  const int index = 0,
195 
196  virtual void setValue(fpreal time,
197  int64 value,
198  bool kill_expr = false,
199  const int index = 0,
202 
203  virtual void setValue(fpreal time,
204  const PRM_DataItemHandle &value,
205  bool kill_expr = false,
206  const int index = 0,
209 
210  //
211  // The setValues methods set all entries in the vector...
212  //
213  virtual void setValues(fpreal time,
214  const fpreal *values,
215  bool kill_expr = false,
218 
219  virtual void setValues(fpreal time,
220  const int32 *values,
221  bool kill_expr = false,
224 
225  virtual void setValues(fpreal time,
226  const int64 *values,
227  bool kill_expr = false,
230 
231  virtual void setDefaultChannelValue(CH_Channel *channelptr,
232  int index = 0) = 0;
233 
234  virtual bool isMultiParm() const;
235  virtual int getMultiParmNumItems() const;
236  virtual int getMultiParmInstancesPerItem() const;
237  virtual const char *getMultiParmToken(int p, int index) const;
238  // Only PRM_ParmList should directly call these insert/remove methods.
239  // All other users, should use the insert/remove methods in OP_Parameter.
240  virtual void insertMultiParmItem(int index);
241  virtual void removeMultiParmItem(int index);
242 
243  virtual void buildOpDependencies(const PRM_RefId &ref, int thread);
244  virtual void changeOpRef(const char *new_fullpath,
245  const char *old_fullpath,
246  const char *old_cwd,
247  const char *chan_name,
248  const char *old_chan_name,
249  void (*undo_callback)(void *),
250  void *undo_data,
251  int thread);
252 
253  fpreal findNextKey(fpreal theoldtime, int index=-1);
254  fpreal findPrevKey(fpreal theoldtime, int index=-1);
255 
256  virtual int findString(const char *str, bool fullword,
257  bool usewildcards) const;
258  virtual int changeString(const char *from, const char *to,
259  bool fullword);
260 
261  virtual bool notifyVarChange(int subindex, const char *varname);
262 
263  virtual bool getMagicString(UT_TokenString &magic,
264  PRM_ParmList *list, int size,
265  fpreal t, bool add_if_default /*=true*/,
266  int thread) = 0;
267 
268  unsigned getEnableState(int comp = -1) const;
269  bool setEnableState(bool f, int comp = -1);
270 
271  int getExpressionState() const
272  {
273  return myBitField & BITFLAG_EXPRESSIONSTATE;
274  }
275  void setExpressionState(int state)
276  {
277  if (state)
278  myBitField |= BITFLAG_EXPRESSIONSTATE;
279  else
280  myBitField &= ~BITFLAG_EXPRESSIONSTATE;
281  }
282  int getValueState() const
283  {
284  return myBitField & BITFLAG_VALUESTATE;
285  }
286  void setValueState(int state)
287  {
288  if (state)
289  myBitField |= BITFLAG_VALUESTATE;
290  else
291  myBitField &= ~BITFLAG_VALUESTATE;
292  }
293 
294  virtual bool isEditable(PRM_ParmList *thelist, fpreal time,
295  int index) const { return true; }
296  virtual bool isEditableByUI(PRM_ParmList *thelist, fpreal time,
297  int index) const { return true; }
298 
300  {
301  return getParmList()
302  ? getParmList()->getChannelGroupPtr()
303  : nullptr;
304  }
305  fpreal getEvalTime(int thread) const
306  {
307  CH_Collection *coll = getChannelGroupPtr();
308  if (!coll)
309  return 0.0;
310  return coll->getManager()
311  ->getEvaluateTime(thread);
312  }
314  {
315  CH_Collection *coll = getChannelGroupPtr();
316  if (!coll)
317  return 0.0;
318  return coll->getManager()->getGlobalStart();
319  }
320 
321  CH_Channel *getChannel(int subindex) const
322  {
323  UT_ASSERT(subindex >= 0
324  && subindex < getVectorSize());
325  return myChannelPtrs[subindex];
326  }
327  void setChannel(int subindex, CH_Channel *chp)
328  {
329  myChannelPtrs[subindex] = chp;
330  }
331 
332  void reloadChannelPtrs();
333  int channelPtrModified(const UT_StringRef &name);
334  void internalAddChannel(int index,
335  const char *theexpr,
336  CH_ExprLanguage language,
337  bool add_seg = true);
338  void addChannel(int index);
339  int addChannel(const UT_StringRef &name);
340  void addChannel(int index, const char *theexpr,
341  CH_ExprLanguage language);
342  int addChannel(const UT_StringRef &name, const char *expr,
343  CH_ExprLanguage language);
344  bool removeChannel(int index);
345  int getChannelCount() const;
346 
347  // Determine if a given component if time/data dependent. Use -1 if you
348  // want to know this for any of the components in the parm.
349  virtual bool isTimeDependent(int subindex) const;
350  virtual bool isDataDependent(fpreal gtime, int subindex) const;
351 
352  virtual void setTimeDependent(int subindex, bool timedep);
353  // Form for setTimeDependent() for the evaluation code path
354  void setTimeDependentForEval(int vi, bool timedep) const
355  { SYSconst_cast(this)->setTimeDependent(vi, timedep);}
356 
357  bool hasContextOptionDeps(int subindex) const;
358  const DEP_ContextOptionDeps &getContextOptionDeps(int subindex) const;
359  void addContextOptionDep(int subindex,
360  const UT_StringHolder &opt);
361 
362  int changePending(int index);
363  virtual PRM_ChanState getChanState(fpreal time, int index) const;
364  virtual PRM_ChanState getChanState(fpreal time) const;
365 
366  // add keyframes if changes are pending
367  virtual void hardenChanges(fpreal time,
368  int index,
369  bool theforceflag,
370  const char *patt = 0,
371  CH_ChannelRefList *list = 0) = 0;
372 
373  // sets a key even if no channel exists
374  void setKey(fpreal time, int index);
375  void setKey(fpreal time, int index, const char *expr,
376  CH_ExprLanguage language,
377  const char *patt = 0,
378  CH_ChannelRefList *list = 0);
379 
380  void setFullKey(fpreal gtime, int index,
381  CH_FullKey const& key,
382  bool accel_ratios = true);
383 
384  unsigned int getSaveFlags() const
385  { return myBitField & BITFLAG_SAVE_MASK; }
386  void setSaveFlags(unsigned int f)
387  { myBitField |= (f & BITFLAG_SAVE_MASK); }
388 
389  bool getActiveTakeFlag() const
390  { return myBitField & BITFLAG_ACTIVETAKE; }
391  bool getAlwaysTakeFlag() const
392  { return myBitField & BITFLAG_TAKEALWAYSACTIVE; }
393  void setActiveTakeFlag(int onoff)
394  {
395  if (onoff) myBitField |= BITFLAG_ACTIVETAKE;
396  else
397  {
398  if (!(myBitField & BITFLAG_TAKEALWAYSACTIVE))
399  myBitField &= ~BITFLAG_ACTIVETAKE;
400  else myBitField |= BITFLAG_ACTIVETAKE;
401  }
402  }
403 
404  bool getBypassFlag() const
405  { return myBitField & BITFLAG_BYPASS; }
406  void setBypassFlag(bool onoff)
407  {
408  // Only allow bypass on spare parameters
409  if (isSpareParm() && onoff)
410  myBitField |= BITFLAG_BYPASS;
411  else
412  myBitField &= ~BITFLAG_BYPASS;
413  }
414 
415  bool getVisibleState(int comp = -1) const;
416  void setVisibleState(bool f, int comp = -1);
417 
419  { return myBitField & BITFLAG_UNDOSAVED; }
420  void setUndoSavedFlag(bool f)
421  { if (f) myBitField |= BITFLAG_UNDOSAVED;
422  else myBitField &= ~BITFLAG_UNDOSAVED;}
424  { return myBitField & BITFLAG_AUTOTAKEUNDOSAVED; }
426  { if (f) myBitField |= BITFLAG_AUTOTAKEUNDOSAVED;
427  else myBitField &= ~BITFLAG_AUTOTAKEUNDOSAVED;}
428 
429  bool getSaveAutoScopeFlag() const
430  { return myBitField & BITFLAG_SAVEAUTOSCOPE; }
431 
433  { return myBitField & BITFLAG_SAVEAUTOSELECT; }
434 
435  void setSaveLabelFlag(bool f);
436  bool getSaveLabelFlag() const
437  { return myBitField & BITFLAG_SAVELABEL; }
438 
439  bool getLockedFlag(int vec_idx) const;
440  bool areAllComponentsLocked() const;
441  void setLockedFlag(int vec_idx, bool f);
442  bool getAutoScopedFlag(int vec_idx) const;
443  void setAutoScopedFlag(int vec_idx, bool f);
444 
445  bool getDefaultsInitFlag() const
446  { return (myBitField & BITFLAG_DEFAULTSINIT) != 0; }
447  void setDefaultsInitFlag(bool f)
448  { if (f) myBitField |= BITFLAG_DEFAULTSINIT;
449  else myBitField &= ~BITFLAG_DEFAULTSINIT;}
450 
451  unsigned int getLockField() const
452  { return myLockField; }
453  unsigned int getAutoScopeField() const
454  { return myAutoScopeField; }
455 
456  virtual int setOverride(int index, int data_idx,
457  const char *source,
459  virtual int setOverrideDisable(int index, int onoff);
460  virtual const char *getOverride(int index) const;
461  virtual bool getOverrideType(int index,
462  PRM_OverrideType& type) const;
463  virtual int getOverrideDataIndex(int index) const;
464 
465  ///Sometimes we may want to make an existing and enabled override
466  ///temporarily inactive, so that we can "shut off" the override without
467  ///losing any dependencies between the parm and the source of its exported
468  ///override values. (e.g. might want to temporarily change the parm's
469  ///display colour)
470  virtual int getIsOverrideActive(int index) const;
471 
472  virtual void destroyChildParms() { }
473 
474  // A parameter becomes dirty whenever its value is set.
475  bool isDirty(int vec_idx) const
476  { return getFieldBit(myDirtyParmFlags, vec_idx); }
477  bool areAllFlagsClean() const
478  { return !myDirtyParmFlags; }
480  { myDirtyParmFlags = 0; }
481  void setDirtyFlags(int vec_idx)
482  {
483  setFieldBit(myDirtyParmFlags, vec_idx, true);
484  setSendExtra(vec_idx);
485  }
486 
487  // mySendExtraFlags is a per-component bitfield that has its bit set
488  // if it needs to be dirty propagated.
489  bool isSendExtra(int vi) const
490  { return getFieldBit(mySendExtraFlags, vi); }
491  bool hasAnySendExtraFlags() const
492  { return (mySendExtraFlags != 0); }
493  void setSendExtra(int vi)
494  {
495  if (!getFieldBit(mySendExtraFlags, vi))
496  {
497  setFieldBit(mySendExtraFlags, vi, true);
498  getParmList()->bumpNumSendExtra(
499  vi < 0 ? getVectorSize() : +1);
500  }
501  }
502 
503  // The input notify value is not created by default. Call
504  // createInputNotifyValue when you need it. Handles use this
505  // notify value to add an interest in input fields so they can know
506  // when the input has changed. Op's trigger this notify value when
507  // they generate their input groups, if this value exists.
508  void createInputNotifyValue();
509  PRM_Value *inputNotifyValue() { return myNotifyValue; }
510  const PRM_Value *inputNotifyValue() const { return myNotifyValue; }
511 
512  const PRM_Type &getType() const
513  { return myTemplatePtr->getType(); }
515  { return myTemplatePtr->getTypeExtended(); }
517  { return myTemplatePtr->getMultiType(); }
519  { return myTemplatePtr->getMultiSize(); }
521  { return myTemplatePtr->getMultiStartOffset(); }
523  { return myTemplatePtr->getMultiParmTemplate(); }
525  { return myTemplatePtr->getMultiParmTemplate(); }
526  const char *getToken() const
527  { return myTemplatePtr->getToken(); }
528  const char *getLabel() const
529  { return myTemplatePtr->getLabel(); }
531  { return myTemplatePtr->getCallback(); }
532  int getVectorSize() const
533  { return myTemplatePtr->getVectorSize(); }
534  const PRM_Range * getRangePtr() const
535  { return myTemplatePtr->getRangePtr(); }
536  void getChannelToken(UT_String &chname, int i) const
537  { myTemplatePtr->getChannelToken(chname, i); }
538  const UT_StringHolder& getChannelToken(int i) const
539  { return myTemplatePtr->getChannelToken(i); }
541  { return myTemplatePtr->getChoiceListPtr(); }
542 
543  const PRM_Template *getTemplatePtr() const { return myTemplatePtr; }
544  PRM_Template *getTemplatePtr() { return myTemplatePtr; }
545 
546  // get/setChannelAlias allow the manipulation of channel aliases.
547  // setChannelAlias will return false if the operation fails and true
548  // otherwise. Do not use the set method directly, only PRM_ParmList should
549  // do that. To set a channel alias, use the OP_Node method.
550  bool hasChannelAlias(int index) const;
551  void getChannelAlias(UT_String &strref, int index) const;
552  const UT_StringHolder& getChannelAlias(int index) const;
553  bool setChannelAlias(const UT_StringHolder &token_alias,
554  int index);
555 
556  // Returns the sub-index of the parm given by the name thechannelname. If
557  // allow_alias is true, the channel name aliases are also searched,
558  // otherwise they are ignored.
559  int findSubIndex(const UT_StringRef &thechannelname,
560  bool allow_alias) const;
561 
563  { return myParm->getParmOwner(); }
565  { return myParm->getOwner(); }
566  PRM_Parm *getParm() const
567  { return myParm; }
568 
569  static bool isChanRefString(const char *str, bool is_expr,
570  UT_String *chref = 0);
571  static bool isObsoleteDirectChanRefString(const char *str,
572  UT_String *chref = 0);
573 
574  // Returns true if the channame is the token (or alias) of the channel at
575  // vec_index, and returns false otherwise.
576  // The length of channame can be given in channamelen to speed up rejections
577  // if the caller caches the string length.
578  bool hasChannelName(const UT_StringRef &s, int vi) const;
579 
580  // Methods for accessing and setting the active handle binding flag
581  bool isActive(const int index) const;
582  void setActive(const int index, const bool active);
583 
584  // Spare parameter flag
585  bool isSpareParm() const;
586  void setSpareParm(bool spare);
587 
588  // Multiparm instance information
589  const PRM_Instance *getMultiParmOwner() const;
590  void setMultiParmOwner(const PRM_Multi *multiparmowner);
591 
592  /// Returns the multi-parm template for this child parm. Returns nullptr
593  /// if this parm is not part of a multi-parm
594  const PRM_Template *findMultiParmTemplate() const;
595 
596  /// Return the list of instance indicies for this parameter.
597  /// If this parameter is part of a multi-parameter, then its index in the
598  /// multi-parm array will be inserted into the indices array. If the
599  /// multi-parm is nested in other multi-parms, then the indices array will
600  /// have multiple entries (with the outer multi-parm listed first, and the
601  /// inner-most multi-parm last in the array).
602  /// \param indices The list of index instances.
603  /// \param instance_index Each multi-parm can have multiple parameters in
604  /// each instance. If instance_index is true, the instance number will be
605  /// returned. Otherwise the raw offset into the multi-parm will be
606  /// extracted.
607  int getMultiInstanceIndex(UT_IntArray &indices,
608  bool instance_index=true) const;
609 
610  bool validIndex(int index) const;
611 
612  virtual int64 getMemoryUsage(bool inclusive) const;
613 
614  virtual bool isRotationParm() const
615  { return false; }
616 
617  /// During loading we need to validate that the channels tied to the
618  /// parameter indices are correclty mapped.
619  void validateChannelNames(PRM_ParmList &list);
620 
621  /// Thread-safe access to get or create a micronode
622  DEP_MicroNode & microNode(int vi);
623 
624  /// Thread-safe access to get micronodes
625  void getMicroNodes(DEP_MicroNodeList &micronodes) const;
626 
627  /// Return true if this parameter has micronodes, NOT thread-safe
628  bool hasMicroNodes() const
629  { return (myMicroNodes != nullptr); }
630 
631  void clearMicroNodeInputs();
632  void getMicroNodeInputList(DEP_MicroNodeList &inputs) const;
633  int getMicroNodeNumInputs() const;
634  void getMicroNodeOutputList(DEP_MicroNodeList &outputs) const;
635 
636  void propagateDirty(
637  DEP_MicroNode::Visitor client_visit,
638  DEP_MicroNode *parmlist_micronode,
639  bool force,
640  bool *dirtied_data = nullptr);
641  void dumpMicroNodes(
642  std::ostream &os,
643  bool as_DOT,
644  int indent_level) const;
645  int64 getMicroNodesMemoryUsage() const;
646 
647  /// Custom Channel Color
648  bool hasChannelCustomColor(int index) const;
649  const UT_Color &getChannelCustomColor(int index) const;
650  void setChannelCustomColor(int index, const UT_Color &c);
651  void resetChannelCustomColor(int index);
652 
653  bool getAutoSelectFlag(int vec_idx) const;
654  void setAutoSelectFlag(int vec_idx, bool f);
655  unsigned int getAutoSelectField() const
656  { return myAutoSelectField; }
657 
658  void setTimeDependentMicroNode(int subindex, bool timedep);
659 protected:
660  void clearAndDestroyChannels();
661 
662  void addParmWarning(PRM_ErrorCode code) const;
663  void indexError(int index);
664 
665  void setLockField(unsigned int locks)
666  { myLockField = locks; }
667  void setAutoScopeField(unsigned int field)
668  {
669  myAutoScopeField = field;
670  myBitField |= BITFLAG_SAVEAUTOSCOPE;
671  }
672 
673  void setAutoSelectField(unsigned int field)
674  {
675  myAutoSelectField = field;
676  myBitField |= BITFLAG_SAVEAUTOSELECT;
677  }
678 
679  SYS_FORCE_INLINE void
681  const PRM_ParmList *thelist, int vector_index, int thread) const
682  {
683  int err;
684  err = ev_GetErrNo(thread);
685  if (err != EV_NOERROR)
686  evaluationError(thelist, vector_index, err, thread);
687  }
688 
689  bool validateAccess();
690 
691  // This helper method is called by loadCommand() in derived classes to
692  // load the token either as a reference to our channel, or failing that,
693  // as an expression.
694  void loadTokenAsChannelNameOrExpression(
695  const UT_String &token, int index);
696 
697  // This method loads the options of the parm that are within '[]' before
698  // the parm value. The istream must be positioned after the first '['
699  // and this method will leave it after the ']' and return true. If it
700  // could not correctly parse the options, it will return false.
701  bool loadAsciiOptions(UT_IStream &is, uint &pending_mask);
702 
703  // This method checks the given binary packet id against the list of
704  // options it supports, if successful, it loads the packet and returns
705  // true, otherwise returns false.
706  bool loadBinaryOption(UT_IStream &is, short packet_id);
707 
708  // This method will save the options of the parm if there are any to set.
709  // Currently, only the locked flag is saved. If the parm is not locked,
710  // this method won't do anything in an effort to maintain forwards
711  // compatibility with older versions of Houdini.
712  // Returns true if anything was written to the stream.
713  void saveAsciiOptions(std::ostream &os) const;
714  bool saveBinaryOptions(int class_packet_id,
715  UT_Packet &packet,
716  std::ostream &os) const;
717 
718  CH_ExprLanguage stringMeaningToExprLanguage(
719  CH_StringMeaning meaning) const;
720 
732  PRM_IO_TOKEN_NUM
733  };
734 
735  // Returns the token used in parm IO.
736  static const char *getPacketIOToken(PRM_ParmIOToken token);
737  static int getPacketIOTokenLen(PRM_ParmIOToken token);
738  static int getPacketIOBinaryId(PRM_ParmIOToken token);
739 
740  // Compares if the given text matches a given token. You
741  // must provide the length of the text, which has the virtue
742  // of avoiding having to harden buffers!
743  static bool comparePacketIOToken(PRM_ParmIOToken token,
744  const char *text,
745  int textlen);
746 
747  // returns true if myData should be saved. Used for caching just within a
748  // session or preventing expensive copy/pastes.
749  bool shouldSaveData() const;
750 
751 private:
752 
753  inline bool getFieldBit(unsigned int field, int i) const
754  {
755  if (i < 0)
756  return (field != 0);
757  else
758  return ((field & (1 << (unsigned)i)) != 0);
759  }
760  inline void setFieldBit(unsigned int &field, int i, bool f)
761  {
762  if (i < 0)
763  {
764  if (f) // enable lowermost vector size bits
765  field = (1<<(unsigned)getVectorSize()) - 1;
766  else
767  field = 0;
768  }
769  else
770  {
771  if (f)
772  field |= (1 << (unsigned)i);
773  else
774  field &= ~(1 << (unsigned)i);
775  }
776  }
777 
778  void getFullParmPath(UT_WorkBuffer &path) const;
779 
780  /// When loading a file, it's possible that the channel mapping doesn't
781  /// match the expected channel name. In this case, we want to either
782  /// rename the channel, or delete the channel (if there are name
783  /// collisions).
784  void validateChannelName(PRM_ParmList &list, int subindex);
785 
786  void evaluationError(
787  const PRM_ParmList *thelist,
788  int vector_index, int err, int thread) const;
789 
790  // This method is *NOT* thread-safe wrt microNode() so do not access the
791  // source and destination PRM_Instance pointers from multiple threads when
792  // calling this.
793  void adoptMicroNodes(PRM_Instance &thesrcinstance);
794 
795  /// Thread-safe version of hasMicroNodes() that can be called at the same
796  /// time as microNode().
797  inline PRM_ParmMicroNode *threadSafeMicroNodes() const;
798 
799 private:
800 
801  enum { // bitflags for myBitField
802  /*BITFLAG_UNUSED_BIT = 0x0002,*/
803  /*BITFLAG_UNUSED_BIT = 0x0004,*/
804  BITFLAG_EXPRESSIONSTATE = 0x0008,
805  BITFLAG_UNDOSAVED = 0x0010,
806  BITFLAG_ACTIVETAKE = 0x0020,
807  BITFLAG_TAKEALWAYSACTIVE = 0x0040,
808  BITFLAG_SAVEAUTOSCOPE = 0x0080,
809  BITFLAG_SPAREPARM = 0x0100,
810  BITFLAG_AUTOTAKEUNDOSAVED = 0x0400,
811  BITFLAG_DEFAULTSINIT = 0x0800,
812  BITFLAG_VALUESTATE = 0x1000,
813  BITFLAG_BYPASS = 0x2000,
814  BITFLAG_SAVELABEL = 0x4000,
815  BITFLAG_SAVEAUTOSELECT = 0x8000,
816 
817  // Flags that should be saved
818  BITFLAG_SAVE_MASK = (BITFLAG_EXPRESSIONSTATE)
819  };
820 
821  unsigned int myBitField;
822  unsigned int myEnableField;
823  unsigned int myLockField;
824  unsigned int myAutoScopeField;
825  unsigned int myVisibleField;
826  unsigned int myAutoSelectField;
827 
828  // Flag to indicate that the handle binded to this parm is active
829  unsigned int myActiveField;
830 
831  PRM_Template *myTemplatePtr;
832 
833  PRM_Value *myNotifyValue;
834  unsigned myDirtyParmFlags;
835  unsigned mySendExtraFlags;
836 
837  CH_Channel **myChannelPtrs;
839  myChannelAliases;
840 
841  struct ChannelCustomColor
842  {
843  ChannelCustomColor()
844  { myHasCustomColor = false; }
845  UT_Color myColor;
846  bool myHasCustomColor;
847  };
848  ChannelCustomColor *myChannelColors;
849 
850  PRM_Parm *myParm;
851  const PRM_Multi *myMultiParmOwner;
852 
853  PRM_ParmMicroNode *myMicroNodes;
854  mutable UT_TBBSpinLock myMicroNodesLock;
855 };
856 
857 inline int
859  bool allow_alias) const
860 {
861  int size = myTemplatePtr->getVectorSize();
862  int retval = -1;
863  int i = 0;
864 
865  if (allow_alias && myChannelAliases)
866  {
867  for (i = 0; i < size; i++)
868  {
869  if (myChannelAliases[i] == thechannelname)
870  {
871  retval = i;
872  break;
873  }
874  }
875  }
876 
877  if (retval == -1)
878  retval = myTemplatePtr->findSubIndex(thechannelname);
879 
880  return retval;
881 }
882 
883 inline unsigned
885 {
886  if(comp < 0)
887  return myEnableField;
888 
889  return ( myEnableField & (1<<comp) ) ? 1 : 0;
890 }
891 
892 inline bool
894 {
895  // Separators, labels and headings have no values, so we use the entire
896  // visible field for them.
897  if (!getVectorSize())
898  return (myVisibleField != 0);
899 
900  return getFieldBit(myVisibleField, comp);
901 }
902 
903 inline void
905 {
906  if (getVectorSize())
907  setFieldBit(myVisibleField, comp, f);
908  else
909  myVisibleField = f ? SYS_UINT32_MAX : 0;
910 }
911 
912 #endif
GLdouble s
Definition: glew.h:1390
CH_Manager * getManager() const
unsigned int getSaveFlags() const
Definition: PRM_Instance.h:384
bool getVisibleState(int comp=-1) const
Definition: PRM_Instance.h:893
PRM_OverrideType
Definition: PRM_Parm.h:69
PRM_AddKeyType
Definition: PRM_Parm.h:58
std::function< void(DEP_MicroNode &, DEP_MicroNode &) > Visitor
bool isSendExtra(int vi) const
Definition: PRM_Instance.h:489
#define EV_NOERROR
Definition: EX_Error.h:18
void setUndoSavedFlag(bool f)
Definition: PRM_Instance.h:420
const PRM_Template * getTemplatePtr() const
Definition: PRM_Instance.h:543
GLsizeiptr size
Definition: glew.h:1681
UT_JSONValueMap stores a map/dictionary of UT_JSONValue objects.
int int32
Definition: SYS_Types.h:39
GLenum GLint ref
Definition: glew.h:1845
GLuint const GLchar * name
Definition: glew.h:1814
void setAutoScopeField(unsigned int field)
Definition: PRM_Instance.h:667
void setSaveFlags(unsigned int f)
Definition: PRM_Instance.h:386
CH_ExprLanguage
const UT_StringHolder & getChannelToken(int i) const
Definition: PRM_Instance.h:538
CH_StringMeaning
GT_API const UT_StringHolder time
GLuint index
Definition: glew.h:1814
UT_SharedPtr< PRM_UndoData > PRM_UndoDataHandle
Definition: PRM_Parm.h:114
const PRM_Template * getMultiParmTemplate() const
Definition: PRM_Template.h:275
bool isDirty(int vec_idx) const
Definition: PRM_Instance.h:475
const PRM_ChoiceList * getChoiceListPtr() const
Definition: PRM_Instance.h:540
UT_ConcurrentSet< UT_StringHolder > DEP_ContextOptionDeps
SYS_FORCE_INLINE T * SYSconst_cast(const T *foo)
Definition: SYS_Types.h:136
GLint GLsizei const GLuint64 * values
Definition: glew.h:3612
PRM_DefaultType
Definition: PRM_Default.h:19
int getExpressionState() const
Definition: PRM_Instance.h:271
bool getSaveAutoSelectFlag() const
Definition: PRM_Instance.h:432
PRM_KeySetType
GLsizei GLsizei GLchar * source
Definition: glew.h:1832
const char * getToken() const
Definition: PRM_Instance.h:526
int getVectorSize() const
Definition: PRM_Instance.h:532
unsigned getEnableState(int comp=-1) const
Definition: PRM_Instance.h:884
const PRM_Value * inputNotifyValue() const
Definition: PRM_Instance.h:510
bool getSaveLabelFlag() const
Definition: PRM_Instance.h:436
bool hasAnySendExtraFlags() const
Definition: PRM_Instance.h:491
float fpreal32
Definition: SYS_Types.h:200
void setChannel(int subindex, CH_Channel *chp)
Definition: PRM_Instance.h:327
void setDefaultsInitFlag(bool f)
Definition: PRM_Instance.h:447
std::unique_ptr< T, Deleter > UT_UniquePtr
A smart pointer for unique ownership of dynamically allocated objects.
Definition: UT_UniquePtr.h:33
virtual bool isRotationParm() const
Definition: PRM_Instance.h:614
double fpreal64
Definition: SYS_Types.h:201
PRM_TypeExtended getTypeExtended() const
Definition: PRM_Instance.h:514
CH_Channel * getChannel(int subindex) const
Definition: PRM_Instance.h:321
void clearAllDirtyFlags()
Definition: PRM_Instance.h:479
PRM_Template * getTemplatePtr()
Definition: PRM_Instance.h:544
int findSubIndex(const UT_StringRef &thechannelname, bool allow_alias) const
Definition: PRM_Instance.h:858
void setDirtyFlags(int vec_idx)
Definition: PRM_Instance.h:481
bool getDefaultsInitFlag() const
Definition: PRM_Instance.h:445
virtual bool isEditable(PRM_ParmList *thelist, fpreal time, int index) const
Definition: PRM_Instance.h:294
bool getBypassFlag() const
Definition: PRM_Instance.h:404
fpreal getGlobalStart() const
Definition: CH_Manager.h:998
GLclampf f
Definition: glew.h:3499
void setVisibleState(bool f, int comp=-1)
Definition: PRM_Instance.h:904
GLint GLenum GLsizei GLint GLsizei const void * data
Definition: glew.h:1379
const GLuint GLenum const void * binary
Definition: glew.h:3502
PRM_ChanState
Definition: PRM_ChanState.h:14
SYS_FORCE_INLINE void checkForExpressionErrors(const PRM_ParmList *thelist, int vector_index, int thread) const
Definition: PRM_Instance.h:680
GLuint GLuint GLsizei GLenum const void * indices
Definition: glew.h:1253
PRM_Template * getMultiParmTemplate()
Definition: PRM_Instance.h:524
#define SYS_FORCE_INLINE
Definition: SYS_Inline.h:45
fpreal getMultiSize() const
Definition: PRM_Instance.h:518
bool getUndoSavedFlag()
Definition: PRM_Instance.h:418
const GLfloat * c
Definition: glew.h:16296
void setLockField(unsigned int locks)
Definition: PRM_Instance.h:665
void setActiveTakeFlag(int onoff)
Definition: PRM_Instance.h:393
PRM_ErrorCode
Definition: PRM_Error.h:21
const char * getLabel() const
Definition: PRM_Instance.h:528
long long int64
Definition: SYS_Types.h:116
void setBypassFlag(bool onoff)
Definition: PRM_Instance.h:406
*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
bool getAlwaysTakeFlag() const
Definition: PRM_Instance.h:391
GLuint GLuint GLsizei GLenum type
Definition: glew.h:1253
#define SYS_UINT32_MAX
Definition: SYS_Types.h:172
unsigned int getAutoScopeField() const
Definition: PRM_Instance.h:453
const PRM_Type & getType() const
Definition: PRM_Instance.h:512
virtual void destroyChildParms()
Definition: PRM_Instance.h:472
unsigned int getLockField() const
Definition: PRM_Instance.h:451
UT_ValArray< CH_Channel * > CH_ChannelList
Definition: PRM_Instance.h:66
GLsizei const GLchar *const * path
Definition: glew.h:6461
PRM_Callback getCallback() const
Definition: PRM_Instance.h:530
GLfloat GLfloat p
Definition: glew.h:16321
fpreal getEvaluateTime(int thread) const
Functions for obtaining and setting the current evaluation time.
Definition: CH_Manager.h:1228
PRM_MultiType getMultiType() const
Definition: PRM_Instance.h:516
bool getSaveAutoScopeFlag() const
Definition: PRM_Instance.h:429
const PRM_Template * getMultiParmTemplate() const
Definition: PRM_Instance.h:522
virtual bool isEditableByUI(PRM_ParmList *thelist, fpreal time, int index) const
Definition: PRM_Instance.h:296
const PRM_Range * getRangePtr() const
Definition: PRM_Instance.h:534
PRM_TypeExtended
Definition: PRM_Type.h:508
fpreal64 fpreal
Definition: SYS_Types.h:277
PRM_ParmOwner * getParmOwner() const
Definition: PRM_Instance.h:562
bool areAllFlagsClean() const
Definition: PRM_Instance.h:477
PRM_Parm * getParm() const
Definition: PRM_Instance.h:566
int getValueState() const
Definition: PRM_Instance.h:282
void setExpressionState(int state)
Definition: PRM_Instance.h:275
bool getAutoTakeUndoSavedFlag()
Definition: PRM_Instance.h:423
fpreal getGlobalStartTime() const
Definition: PRM_Instance.h:313
void getChannelToken(UT_String &chname, int i) const
Definition: PRM_Instance.h:536
void setTimeDependentForEval(int vi, bool timedep) const
Definition: PRM_Instance.h:354
void setSendExtra(int vi)
Definition: PRM_Instance.h:493
#define UT_ASSERT(ZZ)
Definition: UT_Assert.h:135
unsigned int getAutoSelectField() const
Definition: PRM_Instance.h:655
bool hasMicroNodes() const
Return true if this parameter has micronodes, NOT thread-safe.
Definition: PRM_Instance.h:628
CH_Collection * getChannelGroupPtr() const
Definition: PRM_Instance.h:299
void setAutoTakeUndoSavedFlag(bool f)
Definition: PRM_Instance.h:425
#define PRM_API
Definition: PRM_API.h:10
GLsizei const GLfloat * value
Definition: glew.h:1849
unsigned int uint
Definition: SYS_Types.h:45
int getMultiStartOffset() const
Definition: PRM_Instance.h:520
void setAutoSelectField(unsigned int field)
Definition: PRM_Instance.h:673
void setValueState(int state)
Definition: PRM_Instance.h:286
GLdouble GLdouble t
Definition: glew.h:1398
UT_SharedPtr< const PRM_DataItem > PRM_DataItemHandle
Definition: PRM_Parm.h:89
PRM_Value * inputNotifyValue()
Definition: PRM_Instance.h:509
PRM_MultiType
This type enum defines the different types of multi (dynamic) parameters.
Definition: PRM_Type.h:417
bool getActiveTakeFlag() const
Definition: PRM_Instance.h:389
fpreal getEvalTime(int thread) const
Definition: PRM_Instance.h:305
PRM_ParmList * getParmList() const
Definition: PRM_Instance.h:564