17 #ifndef __PRM_Instance_h__
18 #define __PRM_Instance_h__
73 UT_SMALLOBJECT_CLEANPAGES_DEFAULT,
74 UT_SMALLOBJECT_PAGESIZE_DEFAULT,
75 UT_SMALLOBJECT_THREADSAFE_OFF>
85 virtual void adoptOverrides(
PRM_Instance &thesrcinstance);
91 virtual void revertToDefault(
int index) = 0;
92 virtual void revertToDefaults(
bool clear_channels =
true) = 0;
93 virtual void restoreFactoryDefault(
int index) = 0;
94 virtual void overwriteDefault(
fpreal time,
int index) = 0;
95 virtual void overwriteDefaults(
fpreal time) = 0;
97 bool basiccheck =
true)
const;
100 virtual void save(std::ostream &os,
int binary,
bool compiled)
const=0;
106 virtual void saveCommand(std::ostream &os,
int values=0,
int index = -1)
108 virtual int loadCommand(
int argc,
const char *
const argv[],
118 int64 &value,
int index,
119 int thread)
const = 0;
122 int thread)
const = 0;
125 bool expand,
int thread)
const = 0;
128 int thread)
const = 0;
131 bool expand,
int thread)
const = 0;
137 int32 *theints,
int thread)
const;
139 int64 *theints,
int thread)
const;
140 virtual void getDefaultValue(
fpreal &value,
int index)
const;
141 virtual void getDefaultValue(
int32 &value,
int index)
const;
142 virtual void getDefaultValue(
int64 &value,
int index)
const;
143 virtual void getDefaultValue(
UT_String &value,
int index)
const;
145 virtual void getExpressionStringForUI(
fpreal time,
148 int thread)
const = 0;
150 int index,
bool allow_value,
151 int thread)
const = 0;
152 virtual void setExpression(
fpreal time,
155 int index,
bool evaluate =
true,
156 bool rmchannel =
false);
170 bool languageIsNodesLanguage(
fpreal time,
int index)
const;
175 virtual void setValue(
fpreal time,
178 bool kill_expr =
false,
183 virtual void setValue(
fpreal time,
185 bool kill_expr =
false,
190 virtual void setValue(
fpreal time,
192 bool kill_expr =
false,
197 virtual void setValue(
fpreal time,
199 bool kill_expr =
false,
204 virtual void setValue(
fpreal time,
206 bool kill_expr =
false,
214 virtual void setValues(
fpreal time,
216 bool kill_expr =
false,
220 virtual void setValues(
fpreal time,
222 bool kill_expr =
false,
226 virtual void setValues(
fpreal time,
228 bool kill_expr =
false,
232 virtual void setDefaultChannelValue(
CH_Channel *channelptr,
235 virtual bool isMultiParm()
const;
236 virtual int getMultiParmNumItems()
const;
237 virtual int getMultiParmInstancesPerItem()
const;
238 virtual const char *getMultiParmToken(
int p,
int index)
const;
241 virtual void insertMultiParmItem(
int index);
242 virtual void removeMultiParmItem(
int index);
244 virtual void buildOpDependencies(
const PRM_RefId &
ref,
int thread);
245 virtual void changeOpRef(
const char *new_fullpath,
246 const char *old_fullpath,
248 const char *chan_name,
249 const char *old_chan_name,
250 void (*undo_callback)(
void *),
257 virtual int findString(
const char *str,
bool fullword,
258 bool usewildcards)
const;
259 virtual int changeString(
const char *from,
const char *to,
262 virtual bool notifyVarChange(
int subindex,
const char *varname);
266 fpreal t,
bool add_if_default ,
269 unsigned getEnableState(
int comp = -1)
const;
270 bool setEnableState(
bool f,
int comp = -1);
274 return myBitField & BITFLAG_EXPRESSIONSTATE;
279 myBitField |= BITFLAG_EXPRESSIONSTATE;
281 myBitField &= ~BITFLAG_EXPRESSIONSTATE;
285 return myBitField & BITFLAG_VALUESTATE;
290 myBitField |= BITFLAG_VALUESTATE;
292 myBitField &= ~BITFLAG_VALUESTATE;
296 int index)
const {
return true; }
298 int index)
const {
return true; }
303 ? getParmList()->getChannelGroupPtr()
325 && subindex < getVectorSize());
326 return myChannelPtrs[subindex];
330 myChannelPtrs[subindex] = chp;
333 void reloadChannelPtrs();
335 void internalAddChannel(
int index,
338 bool add_seg =
true);
339 void addChannel(
int index);
341 void addChannel(
int index,
const char *theexpr,
345 bool removeChannel(
int index);
346 int getChannelCount()
const;
350 virtual bool isTimeDependent(
int subindex)
const;
351 virtual bool isDataDependent(
fpreal gtime,
int subindex)
const;
353 virtual void setTimeDependent(
int subindex,
bool timedep);
358 bool hasContextOptionDeps(
int subindex)
const;
360 void addContextOptionDep(
int subindex,
363 int changePending(
int index);
368 virtual void hardenChanges(
fpreal time,
371 const char *patt = 0,
375 void setKey(
fpreal time,
int index);
376 void setKey(
fpreal time,
int index,
const char *expr,
378 const char *patt = 0,
381 void setFullKey(
fpreal gtime,
int index,
383 bool accel_ratios =
true);
386 {
return myBitField & BITFLAG_SAVE_MASK; }
388 { myBitField |= (f & BITFLAG_SAVE_MASK); }
391 {
return myBitField & BITFLAG_ACTIVETAKE; }
393 {
return myBitField & BITFLAG_TAKEALWAYSACTIVE; }
396 if (onoff) myBitField |= BITFLAG_ACTIVETAKE;
399 if (!(myBitField & BITFLAG_TAKEALWAYSACTIVE))
400 myBitField &= ~BITFLAG_ACTIVETAKE;
401 else myBitField |= BITFLAG_ACTIVETAKE;
406 {
return myBitField & BITFLAG_BYPASS; }
410 if (isSpareParm() && onoff)
411 myBitField |= BITFLAG_BYPASS;
413 myBitField &= ~BITFLAG_BYPASS;
416 bool getVisibleState(
int comp = -1)
const;
417 void setVisibleState(
bool f,
int comp = -1);
420 {
return myBitField & BITFLAG_UNDOSAVED; }
422 {
if (f) myBitField |= BITFLAG_UNDOSAVED;
423 else myBitField &= ~BITFLAG_UNDOSAVED;}
425 {
return myBitField & BITFLAG_AUTOTAKEUNDOSAVED; }
427 {
if (f) myBitField |= BITFLAG_AUTOTAKEUNDOSAVED;
428 else myBitField &= ~BITFLAG_AUTOTAKEUNDOSAVED;}
431 {
return myBitField & BITFLAG_SAVEAUTOSCOPE; }
434 {
return myBitField & BITFLAG_SAVEAUTOSELECT; }
436 void setSaveLabelFlag(
bool f);
438 {
return myBitField & BITFLAG_SAVELABEL; }
440 bool getLockedFlag(
int vec_idx)
const;
441 bool areAllComponentsLocked()
const;
442 void setLockedFlag(
int vec_idx,
bool f);
443 bool getAutoScopedFlag(
int vec_idx)
const;
444 void setAutoScopedFlag(
int vec_idx,
bool f);
447 {
return (myBitField & BITFLAG_DEFAULTSINIT) != 0; }
449 {
if (f) myBitField |= BITFLAG_DEFAULTSINIT;
450 else myBitField &= ~BITFLAG_DEFAULTSINIT;}
453 {
return myLockField; }
455 {
return myAutoScopeField; }
457 virtual int setOverride(
int index,
int data_idx,
460 virtual int setOverrideDisable(
int index,
int onoff);
461 virtual const char *getOverride(
int index)
const;
462 virtual bool getOverrideType(
int index,
464 virtual int getOverrideDataIndex(
int index)
const;
471 virtual int getIsOverrideActive(
int index)
const;
477 {
return getFieldBit(myDirtyParmFlags, vec_idx); }
479 {
return !myDirtyParmFlags; }
481 { myDirtyParmFlags = 0; }
484 setFieldBit(myDirtyParmFlags, vec_idx,
true);
485 setSendExtra(vec_idx);
491 {
return getFieldBit(mySendExtraFlags, vi); }
493 {
return (mySendExtraFlags != 0); }
496 if (!getFieldBit(mySendExtraFlags, vi))
498 setFieldBit(mySendExtraFlags, vi,
true);
499 getParmList()->bumpNumSendExtra(
500 vi < 0 ? getVectorSize() : +1);
509 void createInputNotifyValue();
514 {
return myTemplatePtr->getType(); }
516 {
return myTemplatePtr->getTypeExtended(); }
518 {
return myTemplatePtr->getMultiType(); }
520 {
return myTemplatePtr->getMultiSize(); }
522 {
return myTemplatePtr->getMultiStartOffset(); }
528 {
return myTemplatePtr->getToken(); }
530 {
return myTemplatePtr->getLabel(); }
532 {
return myTemplatePtr->getCallback(); }
534 {
return myTemplatePtr->getVectorSize(); }
536 {
return myTemplatePtr->getRangePtr(); }
538 { myTemplatePtr->getChannelToken(chname, i); }
540 {
return myTemplatePtr->getChannelToken(i); }
542 {
return myTemplatePtr->getChoiceListPtr(); }
551 bool hasChannelAlias(
int index)
const;
552 void getChannelAlias(
UT_String &strref,
int index)
const;
561 bool allow_alias)
const;
564 {
return myParm->getParmOwner(); }
566 {
return myParm->getOwner(); }
570 static bool isChanRefString(
const char *str,
bool is_expr,
572 static bool isObsoleteDirectChanRefString(
const char *str,
582 bool isActive(
const int index)
const;
583 void setActive(
const int index,
const bool active);
586 bool isSpareParm()
const;
587 void setSpareParm(
bool spare);
591 void setMultiParmOwner(
const PRM_Multi *multiparmowner);
609 bool instance_index=
true)
const;
611 bool validIndex(
int index)
const;
613 virtual int64 getMemoryUsage(
bool inclusive)
const;
631 {
return (myMicroNodes !=
nullptr); }
633 void clearMicroNodeInputs();
635 int getMicroNodeNumInputs()
const;
642 bool *dirtied_data =
nullptr);
646 int indent_level)
const;
647 int64 getMicroNodesMemoryUsage()
const;
650 bool hasChannelCustomColor(
int index)
const;
651 const UT_Color &getChannelCustomColor(
int index)
const;
652 void setChannelCustomColor(
int index,
const UT_Color &
c);
653 void resetChannelCustomColor(
int index);
655 bool getAutoSelectFlag(
int vec_idx)
const;
656 void setAutoSelectFlag(
int vec_idx,
bool f);
658 {
return myAutoSelectField; }
660 void setTimeDependentMicroNode(
int subindex,
bool timedep);
669 void clearAndDestroyChannels();
672 void indexError(
int index);
675 { myLockField = locks; }
678 myAutoScopeField = field;
679 myBitField |= BITFLAG_SAVEAUTOSCOPE;
684 myAutoSelectField = field;
685 myBitField |= BITFLAG_SAVEAUTOSELECT;
690 const PRM_ParmList *thelist,
int vector_index,
int thread)
const
693 err = ev_GetErrNo(thread);
695 evaluationError(thelist, vector_index, err, thread);
698 bool validateAccess();
703 void loadTokenAsChannelNameOrExpression(
715 bool loadBinaryOption(
UT_IStream &is,
short packet_id);
722 void saveAsciiOptions(std::ostream &os)
const;
723 bool saveBinaryOptions(
int class_packet_id,
725 std::ostream &os)
const;
745 static const char *getPacketIOToken(PRM_ParmIOToken token);
746 static int getPacketIOTokenLen(PRM_ParmIOToken token);
747 static int getPacketIOBinaryId(PRM_ParmIOToken token);
752 static bool comparePacketIOToken(PRM_ParmIOToken token,
758 bool shouldSaveData()
const;
762 inline bool getFieldBit(
unsigned int field,
int i)
const
767 return ((field & (1 << (
unsigned)i)) != 0);
769 inline void setFieldBit(
unsigned int &field,
int i,
bool f)
774 field = (1<<(unsigned)getVectorSize()) - 1;
781 field |= (1 << (unsigned)i);
783 field &= ~(1 << (unsigned)i);
793 void validateChannelName(
PRM_ParmList &list,
int subindex);
795 void evaluationError(
797 int vector_index,
int err,
int thread)
const;
813 BITFLAG_EXPRESSIONSTATE = 0x0008,
814 BITFLAG_UNDOSAVED = 0x0010,
815 BITFLAG_ACTIVETAKE = 0x0020,
816 BITFLAG_TAKEALWAYSACTIVE = 0x0040,
817 BITFLAG_SAVEAUTOSCOPE = 0x0080,
818 BITFLAG_SPAREPARM = 0x0100,
819 BITFLAG_AUTOTAKEUNDOSAVED = 0x0400,
820 BITFLAG_DEFAULTSINIT = 0x0800,
821 BITFLAG_VALUESTATE = 0x1000,
822 BITFLAG_BYPASS = 0x2000,
823 BITFLAG_SAVELABEL = 0x4000,
824 BITFLAG_SAVEAUTOSELECT = 0x8000,
827 BITFLAG_SAVE_MASK = (BITFLAG_EXPRESSIONSTATE)
830 unsigned int myBitField;
831 unsigned int myEnableField;
832 unsigned int myLockField;
833 unsigned int myAutoScopeField;
834 unsigned int myVisibleField;
835 unsigned int myAutoSelectField;
838 unsigned int myActiveField;
843 unsigned myDirtyParmFlags;
844 unsigned mySendExtraFlags;
850 struct ChannelCustomColor
853 { myHasCustomColor =
false; }
855 bool myHasCustomColor;
857 ChannelCustomColor *myChannelColors;
860 const PRM_Multi *myMultiParmOwner;
869 bool allow_alias)
const
871 int size = myTemplatePtr->getVectorSize();
875 if (allow_alias && myChannelAliases)
877 for (i = 0; i <
size; i++)
879 if (myChannelAliases[i] == thechannelname)
888 retval = myTemplatePtr->findSubIndex(thechannelname);
897 return myEnableField;
899 return ( myEnableField & (1<<comp) ) ? 1 : 0;
907 if (!getVectorSize())
908 return (myVisibleField != 0);
910 return getFieldBit(myVisibleField, comp);
917 setFieldBit(myVisibleField, comp, f);
CH_Manager * getManager() const
unsigned int getSaveFlags() const
bool getVisibleState(int comp=-1) const
std::function< void(DEP_MicroNode &, DEP_MicroNode &) > Visitor
bool isSendExtra(int vi) const
void setUndoSavedFlag(bool f)
const PRM_Template * getTemplatePtr() const
UT_JSONValueMap stores a map/dictionary of UT_JSONValue objects.
void setAutoScopeField(unsigned int field)
void setSaveFlags(unsigned int f)
const UT_StringHolder & getChannelToken(int i) const
GT_API const UT_StringHolder time
UT_SharedPtr< PRM_UndoData > PRM_UndoDataHandle
const PRM_Template * getMultiParmTemplate() const
bool isDirty(int vec_idx) const
const PRM_ChoiceList * getChoiceListPtr() const
const GLuint GLenum const void * binary
UT_ConcurrentSet< UT_StringHolder > DEP_ContextOptionDeps
GLsizei const GLchar *const * path
SYS_FORCE_INLINE T * SYSconst_cast(const T *foo)
int getExpressionState() const
bool getSaveAutoSelectFlag() const
const char * getToken() const
int getVectorSize() const
unsigned getEnableState(int comp=-1) const
GLuint const GLchar * name
const PRM_Value * inputNotifyValue() const
bool getSaveLabelFlag() const
bool hasAnySendExtraFlags() const
void setChannel(int subindex, CH_Channel *chp)
void setDefaultsInitFlag(bool f)
GLenum GLsizei GLsizei GLint * values
std::unique_ptr< T, Deleter > UT_UniquePtr
A smart pointer for unique ownership of dynamically allocated objects.
virtual bool isRotationParm() const
PRM_TypeExtended getTypeExtended() const
CH_Channel * getChannel(int subindex) const
void clearAllDirtyFlags()
PRM_Template * getTemplatePtr()
int findSubIndex(const UT_StringRef &thechannelname, bool allow_alias) const
void setDirtyFlags(int vec_idx)
bool getDefaultsInitFlag() const
GLint GLint GLsizei GLint GLenum GLenum type
virtual bool isEditable(PRM_ParmList *thelist, fpreal time, int index) const
bool getBypassFlag() const
fpreal getGlobalStart() const
void setVisibleState(bool f, int comp=-1)
SYS_FORCE_INLINE void checkForExpressionErrors(const PRM_ParmList *thelist, int vector_index, int thread) const
GLsizei GLsizei GLchar * source
PRM_Template * getMultiParmTemplate()
fpreal getMultiSize() const
GLsizei GLenum const void * indices
void setLockField(unsigned int locks)
void setActiveTakeFlag(int onoff)
const char * getLabel() const
void setBypassFlag(bool onoff)
bool getAlwaysTakeFlag() const
unsigned int getAutoScopeField() const
const PRM_Type & getType() const
virtual void destroyChildParms()
unsigned int getLockField() const
UT_ValArray< CH_Channel * > CH_ChannelList
PRM_Callback getCallback() const
fpreal getEvaluateTime(int thread) const
Functions for obtaining and setting the current evaluation time.
**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_MultiType getMultiType() const
bool getSaveAutoScopeFlag() const
const PRM_Template * getMultiParmTemplate() const
virtual bool isEditableByUI(PRM_ParmList *thelist, fpreal time, int index) const
const PRM_Range * getRangePtr() const
PRM_ParmOwner * getParmOwner() const
bool areAllFlagsClean() const
PRM_Parm * getParm() const
int getValueState() const
void setExpressionState(int state)
GLsizei const GLfloat * value
bool getAutoTakeUndoSavedFlag()
fpreal getGlobalStartTime() const
void getChannelToken(UT_String &chname, int i) const
void setTimeDependentForEval(int vi, bool timedep) const
void setSendExtra(int vi)
unsigned int getAutoSelectField() const
bool hasMicroNodes() const
Return true if this parameter has micronodes, NOT thread-safe.
CH_Collection * getChannelGroupPtr() const
void setAutoTakeUndoSavedFlag(bool f)
int getMultiStartOffset() const
void setAutoSelectField(unsigned int field)
void setValueState(int state)
UT_SharedPtr< const PRM_DataItem > PRM_DataItemHandle
PRM_Value * inputNotifyValue()
PRM_MultiType
This type enum defines the different types of multi (dynamic) parameters.
bool getActiveTakeFlag() const
fpreal getEvalTime(int thread) const
PRM_ParmList * getParmList() const