00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029 #ifndef __PRM_Parm__
00030 #define __PRM_Parm__
00031
00032 #include "PRM_API.h"
00033 #include <iostream.h>
00034 #include <UT/UT_Defines.h>
00035 #include <UT/UT_IntArray.h>
00036 #include <UT/UT_SmallObject.h>
00037 #include "PRM_Default.h"
00038 #include "PRM_KeySetType.h"
00039 #include "PRM_Type.h"
00040 #include "PRM_Template.h"
00041 #include "PRM_ParmList.h"
00042
00043 class UT_String;
00044 class UT_TokenString;
00045 class CH_Channel;
00046 class CH_FullKey;
00047 class CH_Collection;
00048 class PRM_Instance;
00049 class PRM_Value;
00050 class PRM_Multi;
00051
00052 class PRM_API PRM_Parm : public UT_SmallObject<PRM_Parm,
00053 UT_SMALLOBJECT_CLEANPAGES_DEFAULT,
00054 UT_SMALLOBJECT_PAGESIZE_DEFAULT,
00055 UT_SMALLOBJECT_THREADSAFE_OFF>
00056 {
00057 public:
00058
00059
00060 PRM_Parm(PRM_Template *thetemplate,
00061 CH_Collection *thechgroupptr,
00062 PRM_ParmList *owner,
00063 PRM_ParmOwner *node);
00064 PRM_Parm(PRM_Parm *theprm,
00065 CH_Collection *thechgroupptr,
00066 PRM_ParmList *owner,
00067 PRM_ParmOwner *node);
00068 ~PRM_Parm();
00069
00070 void adopt(PRM_Parm &thesrcparm);
00071 void adoptOverrides(PRM_Parm &srcparm);
00072
00073 void revertToDefaults(float time);
00074 void revertToDefault(float time, int index, bool propagate=true);
00075 void restoreFactoryDefaults();
00076 void restoreFactoryDefault(int index);
00077
00078 static bool getDestructiveRevertToDefaultFlag()
00079 { return myDestructiveRevertToDefaultFlag; }
00080 static void setDestructiveRevertToDefaultFlag(bool v)
00081 { myDestructiveRevertToDefaultFlag = v; }
00082
00083 static bool getRevertInvisibleToDefaultsFlag()
00084 { return myRevertInvisibleToDefaultsFlag; }
00085 static void setRevertInvisibleToDefaultsFlag(bool v)
00086 { myRevertInvisibleToDefaultsFlag = v; }
00087
00088 static bool getMakeSpareParmsForUnknownChannelsFlag()
00089 { return myMakeSpareParmsForUnknownChannelsFlag; }
00090 static void setMakeSpareParmsForUnknownChannelsFlag(bool v)
00091 { myMakeSpareParmsForUnknownChannelsFlag = v; }
00092
00093
00094 static bool isFloatExpression(const char *str);
00095 static bool isStringExpression(const char *str,
00096 CH_StringMeaning meaning,
00097 PRM_Template *tplate = NULL);
00098 static bool isOrdinalExpression(const char *str,
00099 const PRM_Template *tplate = NULL);
00100 static bool isOrdinalExpression(const PRM_Default &dflt,
00101 const PRM_Template *tplate = NULL);
00102
00103
00104
00105 static void convertStringToExprLanguage(const char *str,
00106 UT_String &expr,
00107 PRM_Template *tplate = NULL);
00108 static void convertStringFromExprLanguage(const char *str,
00109 UT_String &expr);
00110
00111
00112 static bool getIsAddingOrRemovingMultiParms();
00113
00114
00115 static bool replaceMultiNumber(UT_String &str, const char *replace);
00116
00117
00118 static bool replaceRemainingMultiNumbers(UT_String &str);
00119
00120
00121 static void instanceMultiString(UT_String &token,
00122 const UT_IntArray &indexlist,
00123 bool fill_remaining=true);
00124 static void instanceMultiString(UT_String &token,
00125 const int *indexlist, int num,
00126 bool fill_remaining=true);
00127
00128 static int getAlwaysHardenFlag() { return myAlwaysHardenFlag; }
00129 static void setAlwaysHardenFlag(int o) { myAlwaysHardenFlag = o; }
00130
00131 int isDefault() const;
00132 int isDefault(int index) const;
00133 int isFactoryDefault() const;
00134 int isFactoryDefault(int index) const;
00135
00136
00137
00138
00139
00140 int isTrueFactoryDefault(int index) const;
00141 int isTrueFactoryDefault() const;
00142
00143
00144
00145
00146 int isFactoryDefaultUI(int index) const;
00147 int isFactoryDefaultUI() const;
00148
00149 void overwriteDefaults(float time);
00150 void overwriteDefault(float time, int index);
00151
00152 CH_Channel *getChannel(int subindex) const;
00153
00154 void buildOpDependencies(void *ref_id, int thread);
00155 void changeOpRef(const char *new_fullpath, const char *old_fullpath,
00156 const char *old_cwd, const char *chan_name,
00157 const char *old_chan_name,
00158 void (*undo_callback)(void *), void *undo_data,
00159 int thread);
00160
00161 void getValue(float time, int &intref, int index,
00162 int thread) const;
00163 void getValue(float time, float &floatref, int index,
00164 int thread) const;
00165 void getValue(float time, UT_String &strref, int index,
00166 bool expand, int thread) const;
00167 void getValues(float time, float *floatref, int thread) const;
00168 void getValues(float time, int *intref, int thread) const;
00169 void getDefaultValue(float &floatref, int index) const;
00170
00171
00172
00173
00174 void getExpressionStringForUI(float thetime, UT_String &thestrref,
00175 int theindex, int thread) const;
00176
00177
00178
00179 void getExpressionOrValue(float thetime, UT_String &thestrref,
00180 int theindex, int thread) const;
00181
00182
00183
00184 void getExpressionOnly(float thetime, UT_String &thestrref,
00185 int theindex, int thread) const;
00186
00187 bool setExpression(float thetime, const UT_String &thestrref,
00188 CH_ExprLanguage language,
00189 int theindex, bool evaluate = true,
00190 bool rmchannel = false, bool propagate = true);
00191
00192 int addChannel(const char *name);
00193 int addChannel(const char *name, const char *expr,
00194 CH_ExprLanguage language);
00195 void reloadChannelPtrs();
00196 int channelPtrModified(const char *name);
00197
00198
00199
00200
00201
00202
00203
00204
00205
00206 bool setValue(const float thetime, const UT_String &thestrref,
00207 CH_StringMeaning meaning,
00208 const int thekillexprflag = 0, const int theindex=0,
00209 const int thehardenflag = 0, bool propagate = 1);
00210
00211 bool setValue(const float thetime, const float thefloat,
00212 const int thekillexprflag = 0, const int theindex=0,
00213 const int thehardenflag = 0, bool propagate = 1);
00214
00215 bool setValue(const float thetime, const int theint,
00216 const int thekillexprflag = 0, const int theindex=0,
00217 const int thehardenflag = 0, bool propagate = 1);
00218
00219
00220
00221
00222
00223 bool setValues(const float thetime, const float *thefloats,
00224 const int thekillexprflag = 0,
00225 const int thehardenFlag = 0, bool propagate = 1);
00226
00227 bool setValues(const float thetime, const int *theints,
00228 const int thekillexprflag = 0,
00229 const int thehardenFlag = 0, bool propagate = 1);
00230
00231 bool isMultiParm() const;
00232 void insertMultiParmItem(int index, bool propagate = 1);
00233 void removeMultiParmItem(int index, bool propagate = 1);
00234 void revertMultiParmItem(int index);
00235 void assignMultiParmItem(int from, int to);
00236 int getMultiParmNumItems() const;
00237 int getMultiParmInstancesPerItem() const;
00238 const char *getMultiParmToken(int p, int index) const;
00239 int getMultiParmUIEntries() const;
00240 const PRM_Template *getMultiParmTemplate(int idx) const;
00241 PRM_Template *getMultiParmTemplate(int idx);
00242 void copyMultiParm(PRM_Parm *src);
00243
00244
00245
00246 PRM_Parm *getMultiParm(int idx) const;
00247 int getMultiParmCount() const;
00248
00249
00250
00251
00252
00253
00254 void valueChanged(int propagate = 1)
00255 { privateValueChanged(propagate, 1); }
00256 void sendValueChanged(int propagate = 1);
00257 void indirectChange(bool expr_changed = false);
00258
00259 PRM_Callback getCallback() { return getTemplatePtr()->getCallback(); }
00260 int setOverride(int theindex, int data_idx, const char *source);
00261 const char *getOverride(int theindex) const;
00262 int getOverrideDataIndex(int theindex) const;
00263 bool getOverrideNodePath(int theindex, UT_String &path) const;
00264 bool getOverrideTrackName(int theindex, UT_String &trackname) const;
00265 int setOverrideDisable(int theindex, int onoff);
00266 int getIsOverrideActive(int theindex) const;
00267
00268 void copyValue(float t, int dest_vi,
00269 const PRM_Parm &src_parm, int src_vi,
00270 bool set_name_alias,
00271 bool current_value_only);
00272
00273 void addChannels();
00274 void addChannel(int theindex);
00275 void addChannel(int theindex, const char *theexpr,
00276 CH_ExprLanguage language);
00277 void removeChannel(int theindex);
00278
00279 void clearAndDestroyChannels();
00280
00281 int getChannelCount() const;
00282 int isTimeDependent() const;
00283 bool isTimeDependent(int subindex) const;
00284 int isDataDependent(float gtime) const;
00285 bool isDataDependent(float gtime, int subindex) const;
00286 void forceTimeDependent(void);
00287
00288 const PRM_Type &getType() const;
00289 PRM_TypeExtended getTypeExtended() const;
00290 PRM_MultiType getMultiType() const;
00291 float getMultiSize() const;
00292 int getMultiStartOffset() const;
00293
00294 bool isRampType() const;
00295 bool isRampTypeColor() const;
00296
00297 int getVectorSize() const;
00298 void getChannelToken(UT_String &thestrref, int theindex = 0) const;
00299 void getChannelLabel(UT_String &thestrref, int theindex = 0) const;
00300 void getToken(UT_String &thestrref) const;
00301 void getLabel(UT_String &thestrref) const;
00302 void getHelpText(UT_String &helptext) const;
00303
00304 const char *getToken() const;
00305 const char *getLabel() const;
00306
00307 void getChannelLabelForUI(UT_String &thestrref, int vec_idx) const;
00308
00309 const PRM_SpareData *getSparePtr() const;
00310
00311 unsigned getTokenHash() const;
00312
00313 bool hasChannelAlias(int subindex) const ;
00314 void getChannelAlias(UT_String &stringref, int subindex) const;
00315
00316
00317 bool canAccess(uint mask) const;
00318
00319
00320
00321
00322 bool setChannelAlias(const char *token_alias, int subindex);
00323
00324 PRM_ChoiceList *getChoiceListPtr();
00325 const PRM_ChoiceList *getChoiceListPtr() const;
00326
00327
00328
00329 PRM_Value *inputNotifyValue();
00330 void createInputNotifyValue();
00331
00332
00333 int isDirty(int vector_idx=0) const;
00334 int areAllFlagsClean() const;
00335 void clearAllDirtyFlags();
00336
00337 int findParmIndex(const char *thechannelname, bool allow_alias);
00338
00339 const PRM_Template *getTemplatePtr() const;
00340 PRM_Template *getTemplatePtr();
00341
00342 PRM_Instance *getInstancePtr();
00343
00344
00345 void setChannelGroupPtr(CH_Collection *thechgroupptr);
00346 CH_Collection *getChannelGroupPtr() const;
00347
00348 unsigned getEnableState(int comp = -1) const;
00349 unsigned getInstanceEnableState(int comp = -1) const;
00350 bool getActiveTakeFlag() const;
00351 bool getAlwaysTakeFlag() const;
00352 void setActiveTakeFlag(int onoff);
00353 int setEnableState(int thestate, int comp = -1);
00354 bool getBypassFlag() const;
00355 void setBypassFlag(bool v);
00356
00357 int getExpressionState();
00358 void setExpressionState(int state);
00359 int getValueState();
00360 void setValueState(int state);
00361
00362
00363 void hardenChanges(float time, char forceflag = 0,
00364 const char *patt = 0,
00365 CH_ChannelRefList *list = 0);
00366 void hardenChanges(float time, char forceflag, int index,
00367 const char *patt = 0,
00368 CH_ChannelRefList *list = 0);
00369
00370 void setKey(float time, int index);
00371 void setKey(float time, int index, const char *exp,
00372 CH_ExprLanguage language,
00373 const char *patt = 0, CH_ChannelRefList *list = 0);
00374
00375 void setFullKey(float gtime, int index, CH_FullKey const& key,
00376 bool accel_ratios = true);
00377
00378 CH_StringMeaning getStringMeaning(float time, int index) const;
00379
00380
00381
00382
00383 CH_ExprLanguage getExprLanguageIfMadeAnExpression(float time, int index);
00384
00385
00386
00387
00388
00389 bool languageIsNodesLanguage(float time, int index);
00390
00391 int changePending(int index);
00392 PRM_ChanState getChanState(float thetime) const;
00393 PRM_ChanState getChanState(float time, int index) const;
00394
00395 void save(ostream &os, int binary, bool compiled) const;
00396 bool load(UT_IStream &is);
00397 void saveCommand(ostream &os, int values=0, int index=-1) const;
00398 int loadCommand(int argc, char *argv[], int theindex, int vonly,
00399 PRM_KeySetType set_type);
00400
00401 float findNextKey(float theoldtime, int theindex = -1);
00402 float findPrevKey(float theoldtime, int theindex = -1);
00403
00404 int findString(const char *str, bool fullword,
00405 bool usewildcards) const;
00406 int changeString(const char *from, const char *to, bool fullword);
00407
00408 int getInterestDirtyFlag();
00409 void setInterestDirtyFlag();
00410 void clearInterestDirtyFlag();
00411
00412 int getExtraInterestFlag();
00413 void setExtraInterestFlag();
00414 void clearExtraInterestFlag();
00415
00416 bool getUndoSavedFlag();
00417
00418
00419
00420 void setUndoSavedFlag(bool f);
00421
00422 bool getAutoTakeUndoSavedFlag();
00423
00424
00425
00426 void setAutoTakeUndoSavedFlag(bool f);
00427
00428 bool getLockedFlag(int vec_idx) const;
00429 bool areAllComponentsLocked() const;
00430 void setLockedFlag(int vec_idx, bool f);
00431 unsigned int getLockedField() const;
00432 bool getAutoScopedFlag(int vec_idx) const;
00433 void setAutoScopedFlag(int vec_idx, bool f);
00434 unsigned int getAutoScopedField() const;
00435
00436 bool getMagicString(UT_TokenString &string, float t,
00437 int parm_group_mask ,
00438 bool add_if_default ,
00439 bool ignore_group ,
00440 int thread);
00441
00442 void destroyChildParms();
00443
00444 PRM_ParmList *getOwner() const;
00445
00446 void setMostRecentCallbackValue(int value);
00447 int getMostRecentCallbackValue() const;
00448
00449 PRM_ParmOwner *getParmOwner() const;
00450 void clearParmOwner();
00451
00452
00453
00454
00455 bool isCompatible(const PRM_Parm &other_parm) const;
00456
00457
00458
00459 bool isOfBasicType(PRM_Type check_type) const;
00460
00461
00462
00463
00464 bool isParmValueEqual(PRM_Parm &other_parm, int vec_index,
00465 float time, int thread) const;
00466 bool isParmValueEqual(int vec_index, PRM_Parm &other_parm,
00467 int other_index, float time,
00468 int thread) const;
00469
00470
00471
00472 bool hasChannelName(const char *channame,
00473 int vec_index) const;
00474
00475
00476
00477 void getAllChannelAliases(UT_String &aliasstring,
00478 char sep ='/') const;
00479
00480
00481 bool isActive(const int index) const;
00482 void setActive(const int index, const bool active);
00483
00484 int64 getMemUsage(UT_Bool onlythis) const;
00485
00486 bool isSpareParm() const;
00487 void setSpareParm(bool sp) const;
00488
00489 const PRM_Instance *getMultiParmOwner() const;
00490 void setMultiParmOwner(const PRM_Multi *multiparmowner);
00491
00492
00493
00494
00495
00496
00497
00498
00499
00500
00501
00502
00503 int getMultiInstanceIndex(UT_IntArray &indices,
00504 bool instance_index=true) const;
00505
00506 void rebuildParmDependency();
00507
00508 bool isRotationParm() const;
00509
00510
00511
00512 void setChannelReference(float thetime,
00513 int theindex,
00514 const char *path,
00515 const char *ch_name=NULL,
00516 bool evaluate=true,
00517 bool rmchannel=false);
00518
00519
00520
00521
00522
00523
00524 void constructChannelReference(UT_String &reference,
00525 CH_ExprLanguage language,
00526 const char *path,
00527 const char *ch_name=NULL);
00528
00529 private:
00530 void privateValueChanged(int propagate, int update_multi);
00531
00532 private:
00533 PRM_Instance *myInstancePtr;
00534 PRM_ParmList *myOwner;
00535 int myMostRecentCallbackValue;
00536
00537 static int myAlwaysHardenFlag;
00538 static bool myDestructiveRevertToDefaultFlag;
00539 static bool myRevertInvisibleToDefaultsFlag;
00540 static bool myMakeSpareParmsForUnknownChannelsFlag;
00541 };
00542
00543 #endif