00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 #ifndef __CH_Manager_h__
00021 #define __CH_Manager_h__
00022
00023 #include "CH_API.h"
00024 #include "CH_KeyState.h"
00025 #include "CH_ChannelRefHashTable.h"
00026 #include "CH_ExprLanguage.h"
00027 #include "CH_Types.h"
00028 #include <iostream.h>
00029 #include <SYS/SYS_Types.h>
00030 #include <UT/UT_Assert.h>
00031 #include <UT/UT_HashTable.h>
00032 #include <UT/UT_IntArray.h>
00033 #include <UT/UT_PtrArray.h>
00034 #include <UT/UT_Math.h>
00035 #include <UT/UT_Floor.h>
00036 #include <UT/UT_String.h>
00037 #include <UT/UT_StringArray.h>
00038 #include <UT/UT_Thread.h>
00039 #include <UT/UT_ThreadSpecificValue.h>
00040
00041 class CH_Collection;
00042 class CH_Channel;
00043 class CH_ChannelRef;
00044 class CH_ExprDefine;
00045 class CH_LocalVariable;
00046 class CH_Group;
00047 class CH_TimeGroup;
00048 class CH_ScriptAccessManager;
00049 class UT_StringArray;
00050 class UT_HashTable;
00051 class UT_WorkBuffer;
00052 class UT_SuperInterval;
00053 class chParamData;
00054
00055
00056 class CH_API CH_LoadInfo
00057 {
00058 public:
00059 bool use_load_range;
00060 float load_start;
00061 float load_end;
00062 float file_start;
00063 float file_end;
00064 bool full_replace;
00065 };
00066
00067 class CH_API CH_Manager
00068 {
00069 public:
00070 typedef enum {
00071
00072 CH_ON_COLLISION_RENAME,
00073 CH_ON_COLLISION_MERGE,
00074 CH_ON_COLLISION_REPLACE,
00075 CH_ON_COLLISION_ASSERT
00076 } CollisionBehaviour;
00077
00078 typedef enum {
00079 CH_EXPANSION_TYPE_EXPRESSION = 1,
00080 CH_EXPANSION_TYPE_VARIABLE = 1 << 1,
00081 CH_EXPANSION_TYPE_DEFAULT = CH_EXPANSION_TYPE_EXPRESSION |
00082 CH_EXPANSION_TYPE_VARIABLE,
00083 } ExpansionType;
00084
00085 typedef CollisionBehaviour (*CBCallback)( CH_Group *source,
00086 CH_Group *target );
00087
00088 CH_Manager(int initTheExpressionLibrary = 1);
00089 virtual ~CH_Manager();
00090
00091
00092 static CH_Manager *getContext()
00093 {
00094 UT_ASSERT( theManager );
00095 return theManager;
00096 }
00097 static bool getContextExists() { return (bool)theManager; }
00098 virtual void setContext();
00099
00100 int condenseCommon(UT_String &path);
00101
00102 void resetPlayback();
00103
00104 void resetChannelOptions();
00105 bool loadChannelOptions( const char *filename );
00106 bool saveChannelOptions( const char *filename );
00107
00108 void setDefaultExpression(const char *s)
00109 {
00110 if( s && *s )
00111 myDefaultExpression.harden( s );
00112 }
00113 const char *getDefaultExpression() const
00114 { return (const char *)myDefaultExpression; }
00115 void setDefaultRotationExpression(const char *s)
00116 {
00117 if (s)
00118 myDefaultRotationExpression.harden(s);
00119 }
00120 const char *getDefaultRotationExpression() const
00121 { return (const char *)myDefaultRotationExpression;}
00122 void setAutoSlope(bool onoff)
00123 { myAutoSlope = onoff; }
00124 bool getAutoSlope() const
00125 { return myAutoSlope; }
00126 void setDefaultSlope(float slope)
00127 { myDefaultSlope = slope; }
00128 float getDefaultSlope() const
00129 { return myDefaultSlope; }
00130 void setAutoSplit(bool onoff)
00131 { myAutoSplit = onoff; }
00132 bool getAutoSplit() const
00133 { return myAutoSplit; }
00134 void setDefaultSplitExpression(const char *expr)
00135 { myDefaultSplitExpression.harden(
00136 expr ? expr : "" ); }
00137 const char *getDefaultSplitExpression() const
00138 { return (const char *)myDefaultSplitExpression; }
00139
00140 void setHoldLastKey(bool onoff)
00141 { myHoldLastKey = onoff; }
00142 int getHoldLastKey() const
00143 { return myHoldLastKey; }
00144 const char *getChanCreateKeyExpression() const
00145 { return (const char *)myChanCreateKeyExpression; }
00146 void setChanCreateKeyExpression(const char *s)
00147 { myChanCreateKeyExpression.harden(s ? s : ""); }
00148 bool getAlwaysCommitKeyChange() const
00149 { return myAlwaysCommitKey; }
00150 void setAlwaysCommitKeyChange( bool onoff )
00151 { myAlwaysCommitKey = onoff; }
00152 bool getSegCacheStatus() const
00153 { return mySegCacheStatus; }
00154 void setSegCacheStatus(bool onoff)
00155 { mySegCacheStatus = onoff; }
00156
00157
00158
00159
00160 void clearChannelScope();
00161
00162
00163 void getScopedChannels(CH_ChannelList &channels, bool sorted=false);
00164
00165
00166 int getNumScopedChanRefs() const
00167 { return myScopedChannelsTable.entries(); }
00168
00169
00170
00171
00172 void getScopedChanRefs(CH_ChannelRefList &chanrefs,
00173 unsigned mask = 0,
00174 bool sorted=false) const;
00175 void getSelectedScopedChanRefs(CH_ChannelRefList &chanrefs,
00176 bool sorted=false, int operateOn=CH_SELECTED);
00177
00178
00179
00180
00181
00182 void getScopedChannelsKeyFrames( UT_IntArray &frames,
00183 int minframe, int maxframe);
00184
00185
00186
00187 void blockModifyScope(int on_off);
00188
00189
00190
00191
00192 void scopeChannel(const CH_ChannelRef &chref, bool on_off);
00193 void scopeChannel(const char *full_chan_path, bool on_off);
00194 bool scopeChannelInternal(CH_Channel *chp, bool on_off);
00195 bool scopeChannelInternal(const CH_ChannelRef &chref, bool on_off);
00196 void unscopeChannelsWithNodeId(int node_id, bool force=false);
00197
00198
00199 void scopeChanged( unsigned flags, bool propagate=true );
00200
00201
00202 bool isChannelScoped(CH_Channel *chp) const;
00203 bool isChannelScoped(const char *full_chan_path) const;
00204 bool isChannelScoped(const CH_ChannelRef &chref) const;
00205
00206
00207
00208
00209 void clearPendingChannels();
00210 void getPendingChannels(CH_ChannelList &channels);
00211
00212
00213 void addPendingChannel( CH_Channel *chp );
00214 void removePendingChannel( CH_Channel *chp );
00215
00216
00217
00218
00219 bool isChannelDisplayed( const CH_ChannelRef &chref ) const;
00220 bool isChannelDisplayed( const char *full_chan_path ) const;
00221 void clearDisplayedChannels( bool propagate = true );
00222 void displayAllScopedChannels( bool propagate = true );
00223 void displaySelectedScopedChannels( bool propagate = true );
00224
00225 void displayChannel( const CH_ChannelRef &chref,
00226 bool propagate = true );
00227 void displayChannel( const char *full_chan_path,
00228 bool propagate = true );
00229 void undisplayChannel( const CH_ChannelRef &chref,
00230 bool propagate = true );
00231 void undisplayChannel( const char *full_chan_path,
00232 bool propagate = true );
00233
00234
00235
00236
00237 bool isChannelSelected( const CH_ChannelRef &chref ) const;
00238 bool isChannelSelected( const char *full_chan_path ) const;
00239 void clearSelectedChannels( bool propagate = true );
00240 void selectAllScopedChannels(bool propagate = true );
00241
00242 void selectChannel( const CH_ChannelRef &chref,
00243 bool propagate = true );
00244 void selectChannel( const char *full_chan_path,
00245 bool propagate = true );
00246 void deselectChannel( const CH_ChannelRef &chref,
00247 bool propagate = true );
00248 void deselectChannel( const char *full_chan_path,
00249 bool propagate = true );
00250
00251
00252
00253
00254 void togglePinAllScopedChannels();
00255 void togglePinScopedChannels( CH_ChannelRefList chanrefs );
00256 void pinAllScopedChannels( bool propagate = true );
00257 void unpinAllScopedChannels( bool propagate = true );
00258 void pinSelectedChannels( bool propagate = true,
00259 int operateOn = CH_SELECTED );
00260 void unpinSelectedChannels( bool propagate = true,
00261 int operateOn = CH_SELECTED );
00262 void pinChannels( CH_ChannelRefList chanrefs,
00263 bool propagate = true );
00264 void unpinChannels( CH_ChannelRefList chanrefs,
00265 bool propagate = true );
00266
00267
00268
00269 void setChannelFlags( const CH_ChannelRef &chref,
00270 unsigned flags,
00271 bool on_off,
00272 bool propagate = true );
00273 unsigned getChannelFlags( const CH_ChannelRef &chref ) const;
00274
00275
00276
00277
00278
00279
00280
00281
00282
00283 int expandString(const char *string, UT_String &expanded,
00284 float time, CH_Collection *local = 0,
00285 int thread = 0,
00286 int expansion_type = CH_EXPANSION_TYPE_DEFAULT);
00287
00288 void buildStringOpDependencies( const char *str, void *ref_id,
00289 CH_Collection *locals, int thread );
00290 bool changeStringOpRef( UT_String &str,
00291 const char *new_fullpath,
00292 const char *old_fullpath,
00293 const char *old_cwd,
00294 const char *chan_name,
00295 const char *old_chan_name,
00296 CH_Collection *locals,
00297 int thread );
00298
00299
00300
00301 float evaluate(const char *expr, float now,
00302 CH_Collection *local=0, int *frame_dep=0,
00303 int thread = 0,
00304 CH_ExprLanguage language=CH_OLD_EXPR_LANGUAGE);
00305 int evaluateString(const char *expr, UT_String &result,
00306 float now, CH_Collection *local=0,
00307 int thread = 0,
00308 CH_ExprLanguage language=CH_OLD_EXPR_LANGUAGE);
00309
00310
00311
00312
00313
00314
00315
00316
00317
00318
00319
00320
00321 bool getIsSettingGlobalParam() const;
00322 void setIsSettingGlobalParam(bool val);
00323 void getGlobalParamF(const char *token, CH_Collection *scope,
00324 fpreal &result, fpreal def, int thread,
00325 bool add_dependencies );
00326 void getGlobalParamS(const char *token, CH_Collection *scope,
00327 UT_String &result, const char *def,
00328 int thread, bool add_dependencies );
00329
00330 int setGlobalFloatParam(const char *token,
00331 float val,
00332 CH_Collection *&owner);
00333 int setGlobalStringParam(const char *token,
00334 const char *strval,
00335 CH_Collection *&owner);
00336
00337 int removeGlobalParamOwner(CH_Collection *owner);
00338 void dumpGlobalParams(ostream &out) const;
00339
00340
00341
00342 void dirtyOrphanGlobalParamDependents(const char *token,
00343 CH_Collection *scope,
00344 bool recurse,
00345 UT_HashTable *dependents);
00346
00347
00348
00349 bool getIsSettingGuideParam() const;
00350 void setIsSettingGuideParam(bool val);
00351
00352 static CH_KeyState getKeyState(float gtime,
00353 const CH_ChannelList &channels,
00354 bool loose=false);
00355
00356 static void getUniqueCollections(
00357 const CH_ChannelList &channels,
00358 CH_CollectionList &collections);
00359
00360
00361
00362
00363
00364
00365 void addGroup(CH_Group *group, int doRename=1);
00366 void renameOpInGroups( const char *full_from,
00367 const char *full_to );
00368 void sortGroups();
00369
00370
00371
00372 CH_Group *getTopGroup() const;
00373 CH_Group *findGroup(const char *const_path, bool create = false,
00374 CH_Group *head=0);
00375 void findGroups( CH_GroupList &groups,
00376 const char *pattern, bool minimal );
00377 void findChannelsFromGroups( CH_ChannelList &channels,
00378 const char *pattern );
00379 void findChanRefsFromGroups( CH_ChannelRefList &chanrefs,
00380 const char *pattern );
00381 static bool makeGroupPathValid( UT_String &path );
00382 static bool makeGroupNameValid( UT_String &path );
00383
00384 CH_GroupList getSelectedGroups();
00385 CH_Group *getCurrentGroup();
00386 void updateGroupSelection(const CH_GroupList &groups,
00387 void *by,
00388 bool propagate = true);
00389 void updateGroupSelectionFromScoped(void *by,
00390 bool propagate = true);
00391 void updateCurrentGroup(CH_Group *group,
00392 void *by,
00393 bool propagate = true);
00394 void enforceLeafOnlyChannels(CH_Group *group,
00395 const char *name="new_group");
00396
00397
00398 CH_Group *createGroup(const char *const_path,
00399 bool doRename = true, CH_Group *head=0);
00400 void renameGroup(CH_Group *group, const char *newname);
00401 void deleteGroup(CH_Group *group);
00402
00403
00404 void extractGroup( CH_Group *group, CollisionBehaviour cb );
00405 CH_Group *collapseGroups( CH_GroupList const& groups,
00406 const char *name );
00407 void collapseChildren( CH_Group *parent );
00408
00409
00410
00411
00412 void copyIntoGroup( CH_Group *source, CH_Group *target,
00413 CollisionBehaviour cb,
00414 const char *new_name = 0 );
00415 void moveIntoGroup( CH_Group *source, CH_Group *target,
00416 CollisionBehaviour cb,
00417 const char *new_name = 0 );
00418 void addToGroup( CH_Group *source, CH_Group *target,
00419 CollisionBehaviour cb );
00420 void mergeWithGroup( CH_Group *source, CH_Group *target,
00421 CollisionBehaviour cb );
00422
00423
00424
00425
00426 void channelCreated( const CH_Channel *chp );
00427 void channelDeleted( const CH_Channel *chp );
00428
00429
00430 void saveGroup( CH_Group *g, ostream &os, int binary );
00431 CH_Group *loadGroup( UT_IStream &is );
00432
00433
00434
00435
00436
00437 static bool couldExpandString(const char *str);
00438
00439
00440 CH_ExprLanguage getDefaultExprLanguage()
00441 { return myDefaultExprLanguage; }
00442 void setDefaultExprLanguage(CH_ExprLanguage language)
00443 { myDefaultExprLanguage = language; }
00444
00445
00446 private:
00447 void handleGroupCollision( CH_Group *new_group,
00448 CH_Group *existing,
00449 CollisionBehaviour cb );
00450 public:
00451
00452
00453
00454
00455 void timeGroupsChanged();
00456 void addTimeGroup(CH_TimeGroup *group,
00457 bool doRename=true,
00458 bool force=false);
00459 void destroyTimeGroup(const CH_TimeGroup *group);
00460 void destroyTimeGroup(int i);
00461 void renameTimeGroup(CH_TimeGroup *group,
00462 const char *newname,
00463 bool force=false);
00464 int getNTimeGroups() const {return myTimeGroups.entries();}
00465 CH_TimeGroup *getTimeGroup(int i) { return myTimeGroups(i); }
00466 const CH_TimeGroup *getTimeGroup(int i) const { return myTimeGroups(i); }
00467 CH_TimeGroup *getTimeGroup(const char *name);
00468 const CH_TimeGroup *getTimeGroup(const char *name) const;
00469 int getTimeGroupIdx( const char *name ) const;
00470
00471
00472
00473
00474 static float niceNumber(float num, int digits=3);
00475
00476
00477
00478
00479
00480 int niceFrameSeparation(float initialSep,
00481 int minimumSep = 1) const;
00482
00483
00484
00485
00486
00487 void stretchCollections(CH_Collection *from, float ostart,
00488 float oend);
00489
00490 static float getDefaultFPS();
00491 static float getDefaultLength(float fps);
00492 static float getDefaultLengthFrames(float fps);
00493
00494 float getNumSamples() const { return mySampleCount; }
00495 void setRawNumSamples(int n);
00496 float getSamplesPerSec() const { return myFPS; }
00497 void setSamplesPerSec(float fps);
00498 float getSecsPerSample() const { return 1.0 / myFPS; }
00499 void setRawSamplesPerSec(float fps);
00500
00501 float getGlobalStart() const { return myStart; }
00502 float getGlobalEnd() const { return myEnd; }
00503 int getGlobalStartFrame() const
00504 { return getFrame( myStart ); }
00505 int getGlobalEndFrame() const
00506 { return getFrame( myEnd ); }
00507
00508 void setGlobalTime(float start, float end);
00509
00510 void setRawInterpolation(int state) { myRawInterpFlag = state; }
00511 int getRawInterpolation() { return myRawInterpFlag; }
00512
00513
00514 float getTolerance() const { return myTimeTolerance; }
00515
00516 float getTime(float sample) const
00517 {
00518 return ((sample-1.0f)/myFPS);
00519 }
00520
00521 float getSampleRaw(float t) const
00522 {
00523 return t*myFPS+1.0f;
00524 }
00525
00526 float getSample(float t) const
00527 {
00528 return niceNumber(getSampleRaw(t));
00529 }
00530
00531 int getFrame(float t) const
00532 {
00533 return (int)SYSfloor(getSampleRaw(t+getTolerance()));
00534 }
00535
00536 float getTimeDelta(float sample_delta) const
00537 {
00538 return sample_delta/myFPS;
00539 }
00540
00541 float getSampleDelta(float time_delta) const
00542 {
00543 return time_delta*myFPS;
00544 }
00545
00546 float getSnapToFrameTime( float t ) const
00547 {
00548 return getTime( SYSrint( getSampleRaw(t) ) );
00549 }
00550
00551
00552 float getSnapSample(float frame) const
00553 {
00554 return SYSrint(frame);
00555 }
00556
00557
00558
00559
00560
00561
00562 float getSnapToFrameDelta( float base_time, float time_delta ) const;
00563
00564 bool getIsAtFrame( float t ) const
00565 {
00566 float snaptime;
00567
00568 snaptime = getSnapToFrameTime( t );
00569 return UTisEqual(t, snaptime, getTolerance());
00570 }
00571
00572
00573 void getTimeCode(char *buf, float t);
00574 int setTimeCode(const char *buf, float &t);
00575 void setTimeCodeOffset(float t) { myTimeCodeOffset = t; }
00576 float getTimeCodeOffset(float ) const { return myTimeCodeOffset; }
00577
00578 int getIntegerFrameFlag() const { return myIntegerFrames; }
00579 void setIntegerFrameFlag(int flag) { myIntegerFrames = flag; }
00580
00581 int getRestrictRangeFlag() const { return myRestrictRange; }
00582 void setRestrictRangeFlag(int flag) { myRestrictRange = flag; }
00583
00584 int getShowRangeFlag() const { return myShowRange; }
00585 void setShowRangeFlag(int flag) { myShowRange = flag; }
00586
00587 int getShowTicksFlag() const { return myShowTicks; }
00588 void setShowTicksFlag(int flag) { myShowTicks = flag; }
00589
00590 int getShowAudioFlag() const { return myShowAudio; }
00591 void setShowAudioFlag(int flag) { myShowAudio = flag; }
00592
00593 int getShowKeysFlag() const { return myShowKeys; }
00594 void setShowKeysFlag(int flag) { myShowKeys = flag; }
00595
00596 float getAudioLevel() const { return myAudioLevel; }
00597 void setAudioLevel(float lvl) { myAudioLevel = lvl; }
00598
00599 float getUnitLength() const { return myUnitLength; }
00600 void setUnitLength(float unitlength) { myUnitLength = unitlength; }
00601 float getUnitMass() const { return myUnitMass; }
00602 void setUnitMass(float unitmass) { myUnitMass = unitmass; }
00603 void parseUnitsString(const char *units,
00604 fpreal &distexp,
00605 fpreal &massexp) const;
00606 fpreal scaleToMKS(const char *fromunits) const;
00607 fpreal scaleFromMKS(const char *tounits) const;
00608
00609 int getRealTimeFlag() const { return myRealTimePlay; }
00610 void setRealTimeFlag(int flag) { myRealTimePlay = flag; }
00611 float getRealTimeFactor() const { return myRealTimeFactor; }
00612 void setRealTimeFactor(float f) { myRealTimeFactor = f; }
00613 bool getRealTimeDisableSkip() const { return myRealTimeDisableSkip; }
00614 void setRealTimeDisableSkip(bool b) { myRealTimeDisableSkip = b; }
00615 float getSampleStep() const { return mySampleStep; }
00616 void setSampleStep(float s) { mySampleStep = s; }
00617
00618 void getSampleRange(float &start, float &end)
00619 {
00620 start = myRangeStart;
00621 end = myRangeEnd;
00622 }
00623 void setSampleRange(float start, float end)
00624 {
00625 if (start > end) { myRangeEnd = start; myRangeStart = end; }
00626 else { myRangeEnd = end; myRangeStart = start; }
00627 }
00628
00629 int getHoldFlag() const { return myHoldFlag; }
00630 void setHoldFlag( int flag ) { myHoldFlag = flag; }
00631
00632
00633 int saveChannels(const char *filename, bool binary, bool compiled,
00634 const CH_ChannelList &channels,
00635 bool displayed = false) const;
00636 int loadChannels(const char *filename,
00637 const char *src_pattern,
00638 const char *dest_pattern,
00639 bool use_range,
00640 const float *tstart,
00641 const float *tend,
00642 CH_CollectionList &parents,
00643 bool delete_keys = false,
00644 CH_ChannelRefList *displayed_parms = NULL);
00645 static bool readCHNFileHeader(UT_IStream &is, bool quiet,
00646 float &version, int &binary,
00647 float &tstart, float &tend);
00648 static bool skipCHNFileHeaderForCollection(UT_IStream &is);
00649 static bool getFileType( const char *filename, int &raw, int &binary );
00650 static bool printFileInfo( ostream &os, const char *filename,
00651 CH_Collection *load_coll );
00652
00653
00654
00655 void addExpressionDefine(CH_ExprDefine *def);
00656
00657
00658
00659
00660 void setEvalCollection(CH_Collection *g, int thread)
00661 {
00662
00663
00664
00665
00666
00667
00668
00669
00670
00671
00672
00673
00674 myEvalCollection.getValueForThread(thread) = g;
00675 }
00676 CH_Collection *getEvalCollection(int thread) const
00677 {
00678
00679
00680
00681
00682
00683
00684 return myEvalCollection.getValueForThread(
00685 thread);
00686 }
00687
00688
00689
00690
00691
00692
00693 void setRootCollection(CH_Collection *root)
00694 {
00695 myRootCollection = root;
00696 }
00697 CH_Collection *getRootCollection() const { return myRootCollection; }
00698
00699 virtual CH_ScriptAccessManager *getAccessManager(int ) { return 0; }
00700
00701
00702
00703
00704 CH_LocalVariable *getLocalVariableTable() const;
00705 void getVariableValue(int i, UT_String &str, int thread) const;
00706 float getVariableValue(int i, int thread) const;
00707 void *getVariableData(int i) const;
00708
00709
00710
00711 int getIntegerVariableValue(int i, int thread) const;
00712
00713
00714
00715 fpreal64 getEvaluateTime(int thread) const
00716 { return myEvalTime.getValueForThread(thread); }
00717 void setEvaluateTime(float time, int thread)
00718 { myEvalTime.getValueForThread(thread) = time; }
00719
00720
00721
00722
00723
00724
00725
00726
00727 SYS_DEPRECATED fpreal64 getEvaluateTime() const
00728 { return getEvaluateTime(UTgetSTID()); }
00729
00730
00731 virtual bool getVariableString(const char *name,
00732 UT_String &value,
00733 int &timeDepend,
00734 int thread);
00735
00736 static void lookupVariable(const char *name, UT_String &val,
00737 int thread);
00738 static void lookupVariableNoThread(const char *name,
00739 UT_String &val);
00740 static void lookupExpression(const char *name, UT_String &val,
00741 int thread);
00742 static void lookupExpressionNoThread(const char *name,
00743 UT_String &val);
00744
00745
00746 void removeParamDependency(CH_Collection *coll);
00747
00748
00749
00750
00751
00752 virtual CH_Channel *getChRefChannel(const CH_ChannelRef &r) const;
00753
00754
00755
00756 virtual bool isOwnerExposed(const CH_ChannelRef &r) const;
00757
00758
00759 virtual bool buildChanRef(CH_ChannelRef &r,
00760 const CH_Channel *chp) const;
00761
00762
00763 virtual bool buildChanRef(CH_ChannelRef &r,
00764 const char *path) const;
00765
00766 bool buildChannelRefs( CH_ChannelRefList &reflist,
00767 const CH_ChannelList &chlist );
00768
00769 bool buildChannelRefs( CH_ChannelRefList &reflist,
00770 const UT_StringArray &chlist );
00771
00772
00773
00774 virtual int compareChanRefs(const CH_ChannelRef &r1,
00775 const CH_ChannelRef &r2) const;
00776
00777
00778 virtual void getChanRefPath(const CH_ChannelRef &r,
00779 UT_String &path,
00780 bool use_alias=false) const;
00781
00782 void changeReferencesToNodeId(int old_id, int new_id);
00783
00784
00785
00786
00787 void removeReferencesToNodeId(int node_id);
00788
00789 void displayScope() const;
00790
00791
00792
00793
00794 float evalBezierFunc(int thread);
00795 float evalConstantFunc(int thread);
00796 float evalCubicFunc(int thread);
00797 float evalCycleFunc(float start_frame, float end_frame,
00798 int thread);
00799 float evalCycletFunc(float start_frame, float end_frame,
00800 int thread);
00801 float evalEaseFunc(int thread);
00802 float evalEaseinFunc(int thread);
00803 float evalEaseinpFunc(float ease_speed, int thread);
00804 float evalEaseoutFunc(int thread);
00805 float evalEaseoutpFunc(float ease_speed, int thread);
00806 float evalEasepFunc(float ease_speed, int thread);
00807 float evalLinearFunc(int thread);
00808 float evalMatchFunc(int thread);
00809 float evalMatchinFunc(int thread);
00810 float evalMatchoutFunc(int thread);
00811 float evalQcubicFunc(int thread);
00812 float evalQlinearFunc(int thread);
00813 float evalQuinticFunc(int thread);
00814 float evalRepeatFunc(float start_frame, float end_frame,
00815 int thread);
00816 float evalRepeattFunc(float start_frame, float end_frame,
00817 int thread);
00818 float evalSplineFunc(int thread);
00819 float evalVmatchFunc(int thread);
00820 float evalVmatchinFunc(int thread);
00821 float evalVmatchoutFunc(int thread);
00822
00823 protected:
00824 void initExpressionLibrary();
00825
00826
00827
00828 void initLibraryGlue();
00829
00830 private:
00831 int internalSetGlobalParam(const char *token,
00832 float val, const char *strval,
00833 CH_Collection *&owner);
00834 int internalSetGlobalParam(const char *token,
00835 float val, const char *strvel,
00836 CH_Collection *&owner, CH_Collection *scope);
00837 void internalDirtyOrphanGlobalParamDependents(
00838 const char *token, CH_Collection *scope,
00839 UT_HashTable *dependents);
00840 void stretchCollection(CH_Collection *grp,
00841 float os, float ns, float stretch);
00842 static char *chExprExpander(const char *str, int thread);
00843
00844 UT_ThreadSpecificValue<CH_Collection *> myEvalCollection;
00845 UT_ThreadSpecificValue<fpreal64> myEvalTime;
00846
00847 CH_Group *myTopGroup;
00848 UT_StringArray mySelectedGroupPaths;
00849 UT_String myCurrentGroupPath;
00850 UT_PtrArray<CH_TimeGroup *> myTimeGroups;
00851 CH_Collection *myRootCollection;
00852 float mySampleCount;
00853 float myFPS;
00854 float myStart, myEnd;
00855
00856 float myRangeStart;
00857 float myRangeEnd;
00858 float myRealTimeFactor;
00859 float mySampleStep;
00860 float myTimeTolerance;
00861 float myTimeCodeOffset;
00862
00863 chParamData *findGlobalParam(const char *token,
00864 CH_Collection *scope);
00865 chParamData *findOrCreateGlobalParam(
00866 const char *token, CH_Collection *scope,
00867 fpreal fval, const char *sval);
00868 UT_HashTable *myGlobalParams;
00869 chParamData *myLastGlobalParam;
00870 bool mySettingGlobalParam;
00871
00872 bool mySettingGuideParam;
00873
00874 unsigned myGroupsSorted:1,
00875 myIntegerFrames:1,
00876 myRealTimePlay:1,
00877 myRealTimeDisableSkip:1,
00878 myHoldFlag:1,
00879 myRestrictRange:1,
00880 myShowRange:1,
00881 myShowTicks:1,
00882 myShowAudio:1,
00883 myShowKeys:1;
00884
00885 short myRawInterpFlag;
00886
00887 UT_String myDefaultExpression;
00888 UT_String myDefaultRotationExpression;
00889 bool myAutoSplit;
00890 UT_String myDefaultSplitExpression;
00891 bool myAutoSlope;
00892 float myDefaultSlope;
00893 bool myHoldLastKey;
00894 bool myAlwaysCommitKey;
00895 bool mySegCacheStatus;
00896 UT_String myChanCreateKeyExpression;
00897 float myAudioLevel;
00898 float myUnitLength;
00899 float myUnitMass;
00900
00901 CH_ChannelRefHashTable myScopedChannelsTable;
00902 CH_ChannelList mySortedScopedChannels;
00903 bool myScopedChannelsSorted;
00904 UT_HashTable myPendingChannelsTable;
00905
00906 CH_ExprLanguage myDefaultExprLanguage;
00907
00908 int myBlockModifyScope;
00909 unsigned myPendingScopeChange;
00910
00911 static CH_Manager *theManager;
00912 };
00913
00914 CH_API void CHsortChannels( CH_ChannelList &channels );
00915 CH_API void CHsortChannelRefs( CH_ChannelRefList &channels );
00916 CH_API void CHsortChannelPaths( UT_StringArray &channel_paths );
00917
00918 CH_API void CHchannelsToCollections( CH_ChannelList const& channels,
00919 CH_CollectionList &collections );
00920
00921 inline
00922 CH_Manager *CHgetManager()
00923 {
00924 return CH_Manager::getContext();
00925 }
00926
00927 inline float CHgetEvalTime()
00928 {
00929 return CH_Manager::getContext()->getEvaluateTime(UTgetSTID());
00930 }
00931
00932 CH_API extern float CHgetTimeFromFrame( float frame );
00933 CH_API extern int CHgetFrameFromTime( float time );
00934 CH_API extern float CHgetSampleFromTime( float time );
00935 CH_API extern void CHbuildRange(int start, int end, UT_SuperInterval &r);
00936
00937
00938
00939
00940
00941 CH_API extern void CHoutputChannelList(UT_WorkBuffer &info,
00942 CH_ChannelList &channels);
00943 CH_API extern void CHoutputChannelList(UT_WorkBuffer &info,
00944 UT_StringArray &channel_paths);
00945
00946 CH_API extern void CHdisplayFlags( unsigned flags, ostream &s );
00947
00948 #endif