00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00013 #ifndef _FBXSDK_CORE_BASE_TIME_H_
00014 #define _FBXSDK_CORE_BASE_TIME_H_
00015
00016 #include <fbxsdk/fbxsdk_def.h>
00017
00018 #include <fbxsdk/core/base/fbxtimecode.h>
00019
00020 #include <fbxsdk/fbxsdk_nsbegin.h>
00021
00022 #define FBXSDK_TIME_INFINITE FbxTime(FBXSDK_TC_INFINITY)
00023 #define FBXSDK_TIME_MINUS_INFINITE FbxTime(FBXSDK_TC_MINFINITY)
00024 #define FBXSDK_TIME_ZERO FbxTime(FBXSDK_TC_ZERO)
00025 #define FBXSDK_TIME_EPSILON FbxTime(FBXSDK_TC_EPSILON)
00026 #define FBXSDK_TIME_ONE_SECOND FbxTime(FBXSDK_TC_SECOND)
00027 #define FBXSDK_TIME_ASSERT_EPSILON 0.5
00028 #define FBXSDK_TIME_FORWARD 1
00029 #define FBXSDK_TIME_BACKWARD -1
00030
00031 class FbxTimeModeObject;
00032
00041 class FBXSDK_DLL FbxTime
00042 {
00043 public:
00047 FbxTime(const FbxLongLong pTime=0){ mTime = pTime; }
00048
00087 enum EMode
00088 {
00089 eDefaultMode,
00090 eFrames120,
00091 eFrames100,
00092 eFrames60,
00093 eFrames50,
00094 eFrames48,
00095 eFrames30,
00096 eFrames30Drop,
00097 eNTSCDropFrame,
00098 eNTSCFullFrame,
00099 ePAL,
00100 eFrames24,
00101 eFrames1000,
00102 eFilmFullFrame,
00103 eCustom,
00104 eFrames96,
00105 eFrames72,
00106 eFrames59dot94,
00107 eModesCount
00108 };
00109
00115 enum EProtocol {eSMPTE, eFrameCount, eDefaultProtocol};
00116
00122 static void SetGlobalTimeMode(EMode pTimeMode, double pFrameRate=0.0);
00123
00128 static EMode GetGlobalTimeMode();
00129
00134 static void SetGlobalTimeProtocol(EProtocol pTimeProtocol);
00135
00140 static EProtocol GetGlobalTimeProtocol();
00141
00146 static double GetFrameRate(EMode pTimeMode);
00147
00154 static EMode ConvertFrameRateToTimeMode(double pFrameRate, double pPrecision=0.00000001);
00156
00164 inline void Set(FbxLongLong pTime){ mTime = pTime; }
00165
00169 inline FbxLongLong Get() const { return mTime; }
00170
00174 inline void SetMilliSeconds(FbxLongLong pMilliSeconds){ mTime = pMilliSeconds * FBXSDK_TC_MILLISECOND; }
00175
00179 inline FbxLongLong GetMilliSeconds() const { return mTime / FBXSDK_TC_MILLISECOND; }
00180
00184 void SetSecondDouble(double pTime);
00185
00189 double GetSecondDouble() const;
00190
00202 void SetTime(int pHour, int pMinute, int pSecond, int pFrame=0, int pField=0, EMode pTimeMode=eDefaultMode);
00203
00221 void SetTime(int pHour, int pMinute, int pSecond, int pFrame, int pField, int pResidual, EMode pTimeMode);
00222
00234 bool GetTime(int& pHour, int& pMinute, int& pSecond, int& pFrame, int& pField, int& pResidual, EMode pTimeMode=eDefaultMode) const;
00235
00240 FbxTime GetFramedTime(bool pRound=true);
00241
00246 void SetFrame(FbxLongLong pFrames, EMode pTimeMode=eDefaultMode);
00247
00251 int GetHourCount() const;
00252
00256 int GetMinuteCount() const;
00257
00261 int GetSecondCount() const;
00262
00268 FbxLongLong GetFrameCount(EMode pTimeMode=eDefaultMode) const;
00269
00274 FbxLongLong GetFieldCount(EMode pTimeMode=eDefaultMode) const;
00275
00280 int GetResidual(EMode pTimeMode=eDefaultMode) const;
00281
00286 static bool IsDropFrame(EMode pTimeMode=eDefaultMode);
00287
00292 char GetFrameSeparator(EMode pTimeMode=eDefaultMode) const;
00293
00309 FBX_DEPRECATED char* GetTimeString(char* pTimeString, int pInfo=5, EMode pTimeMode=eDefaultMode, EProtocol pTimeFormat=eDefaultProtocol) const;
00310
00326 char* GetTimeString(char* pTimeString, const FbxUShort& pTimeStringSize, int pInfo=5, EMode pTimeMode=eDefaultMode, EProtocol pTimeFormat=eDefaultProtocol) const;
00327
00340 bool SetTimeString(const char* pTime, EMode pTimeMode=eDefaultMode, EProtocol pTimeFormat=eDefaultProtocol);
00342
00351 inline bool operator==(const FbxTime& pTime) const { return mTime == pTime.mTime; }
00352
00357 inline bool operator!=(const FbxTime& pTime) const { return mTime != pTime.mTime; }
00358
00363 inline bool operator>=(const FbxTime& pTime) const { return mTime >= pTime.mTime; }
00364
00369 inline bool operator<=(const FbxTime& pTime) const { return mTime <= pTime.mTime; }
00370
00375 inline bool operator>(const FbxTime& pTime) const { return mTime > pTime.mTime; }
00376
00381 inline bool operator<(const FbxTime& pTime) const { return mTime < pTime.mTime; }
00382
00386 inline FbxTime& operator=(const FbxTime& pTime) { mTime = pTime.mTime; return *this; }
00387
00392 inline FbxTime& operator+=(const FbxTime& pTime) { mTime += pTime.mTime; return *this; }
00393
00398 inline FbxTime& operator-=(const FbxTime& pTime) { mTime -= pTime.mTime; return *this; }
00399
00404 FbxTime operator+(const FbxTime& pTime) const;
00405
00410 FbxTime operator-(const FbxTime& pTime) const;
00411
00416 FbxTime operator*(const int Mult) const;
00417
00422 FbxTime operator/(const FbxTime& pTime) const;
00423
00428 FbxTime operator*(const FbxTime& pTime) const;
00429
00431
00432
00434
00435
00437
00438
00440
00442
00447 static FbxLongLong GetOneFrameValue(EMode pTimeMode=eDefaultMode);
00448
00449
00450
00451
00452 #ifndef DOXYGEN_SHOULD_SKIP_THIS
00453
00454 enum EOldMode
00455 {
00456 eOLD_DEFAULT_MODE,
00457 eOLD_CINEMA,
00458 eOLD_PAL,
00459 eOLD_FRAMES30,
00460 eOLD_NTSC_DROP_FRAME,
00461 eOLD_FRAMES50,
00462 eOLD_FRAMES60,
00463 eOLD_FRAMES100,
00464 eOLD_FRAMES120,
00465 eOLD_NTSC_FULL_FRAME,
00466 eOLD_FRAMES30_DROP,
00467 eOLD_FRAMES1000
00468 };
00469
00470 private:
00471 FbxLongLong mTime;
00472
00473 static EMode gsGlobalTimeMode;
00474 static EProtocol gsGlobalTimeProtocol;
00475 static FbxTimeModeObject* gsTimeObject;
00476
00477 void InternalSetTime(int pHour, int pMinute, int pSecond, FbxLongLong pFrame, int pField, EMode pTimeMode);
00478
00479 friend FBXSDK_DLL FbxTime::EMode FbxGetGlobalTimeMode();
00480 friend FBXSDK_DLL FbxTimeModeObject* FbxGetGlobalTimeModeObject();
00481 friend FBXSDK_DLL FbxTime::EProtocol FbxGetGlobalTimeFormat();
00482 friend FBXSDK_DLL void FbxSetGlobalTimeMode(FbxTime::EMode pTimeMode, double pFrameRate);
00483 friend FBXSDK_DLL void FbxSetGlobalTimeFormat(FbxTime::EProtocol pTimeFormat);
00484 #endif
00485 };
00486
00490 FBXSDK_DLL inline FbxTime FbxTimeSeconds(const FbxDouble& pTime=0.0)
00491 {
00492 FbxTime lTime;
00493 lTime.SetSecondDouble(pTime);
00494 return lTime;
00495 }
00496
00501 class FBXSDK_DLL FbxTimeSpan
00502 {
00503 public:
00505 FbxTimeSpan() {}
00506
00511 FbxTimeSpan(FbxTime pStart, FbxTime pStop){ mStart = pStart; mStop = pStop; }
00512
00517 inline void Set(FbxTime pStart, FbxTime pStop){ mStart = pStart; mStop = pStop; }
00518
00522 inline void SetStart(FbxTime pStart){ mStart = pStart; }
00523
00527 inline void SetStop(FbxTime pStop){ mStop = pStop; }
00528
00532 inline FbxTime GetStart() const { return mStart; }
00533
00537 inline FbxTime GetStop() const { return mStop; }
00538
00542 inline FbxTime GetDuration() const { if( mStop > mStart ) return mStop - mStart; else return mStart - mStop; }
00543
00547 inline FbxTime GetSignedDuration() const { return mStop - mStart; }
00548
00552 inline int GetDirection() const { if( mStop >= mStart ) return FBXSDK_TIME_FORWARD; else return FBXSDK_TIME_BACKWARD; }
00553
00558 bool IsInside(FbxTime pTime) const;
00559
00564 FbxTimeSpan Intersect(const FbxTimeSpan& pTime) const;
00565
00570 bool operator!=(const FbxTimeSpan& pTime) const;
00571
00576 bool operator==(const FbxTimeSpan& pTime) const;
00577
00585 void UnionAssignment(const FbxTimeSpan& pSpan, int pDirection=FBXSDK_TIME_FORWARD);
00586
00587
00588
00589
00590 #ifndef DOXYGEN_SHOULD_SKIP_THIS
00591 private:
00592 FbxTime mStart;
00593 FbxTime mStop;
00594 #endif
00595 };
00596
00597 class FBXSDK_DLL FbxLocalTime
00598 {
00599 public:
00600 FbxLocalTime();
00601
00602 int mYear;
00603 int mMonth;
00604 int mDay;
00605 int mHour;
00606 int mMinute;
00607 int mSecond;
00608 int mMillisecond;
00609 };
00610
00611 FBXSDK_DLL void FbxGetCurrentLocalTime(FbxLocalTime& pLocalTime);
00612
00613 FBXSDK_DLL FbxTime::EMode FbxGetGlobalTimeMode();
00614 FBXSDK_DLL FbxTimeModeObject* FbxGetGlobalTimeModeObject();
00615 FBXSDK_DLL FbxTime::EProtocol FbxGetGlobalTimeFormat();
00616 FBXSDK_DLL void FbxSetGlobalTimeMode(FbxTime::EMode pTimeMode, double pFrameRate=0.0);
00617 FBXSDK_DLL void FbxSetGlobalTimeFormat(FbxTime::EProtocol pTimeFormat);
00618
00619
00620 FBXSDK_DLL FbxTime::EOldMode FbxGetOldTimeModeCorrespondance(FbxTime::EMode pMode);
00621 FBXSDK_DLL FbxTime::EMode FbxGetTimeModeFromOldValue(FbxTime::EOldMode pOldMode);
00622
00623
00624 FBXSDK_DLL FbxTime::EMode FbxGetTimeModeFromFrameRate(char* pFrameRate);
00625 FBXSDK_DLL void FbxGetControlStringList(char* pControlString, FbxTime::EProtocol pTimeFormat);
00626 FBXSDK_DLL const char* FbxGetGlobalFrameRateString(FbxTime::EMode pTimeMode);
00627 FBXSDK_DLL const char* FbxGetGlobalTimeModeString(FbxTime::EMode pTimeMode);
00628 FBXSDK_DLL double FbxGetFrameRate(FbxTime::EMode pTimeMode);
00629
00630
00631 FBXSDK_DLL FbxTime::EProtocol FbxSelectionToTimeFormat(int pSelection);
00632 FBXSDK_DLL FbxTime::EMode FbxSelectionToTimeMode(int pSelection);
00633 FBXSDK_DLL int FbxTimeToSelection(FbxTime::EMode pTimeMode=FbxTime::eDefaultMode, int pTimeFormat=FbxTime::eDefaultProtocol);
00634 FBXSDK_DLL const char* FbxGetTimeModeName(FbxTime::EMode pTimeMode);
00635 FBXSDK_DLL int FbxGetFrameRateStringListIndex(FbxTime::EMode pTimeMode);
00636 FBXSDK_DLL bool FbxIsValidCustomFrameRate(double pFramerate);
00637 FBXSDK_DLL bool FbxGetNearestCustomFrameRate(double pFramerate, double& pNearestRate);
00638
00639 #include <fbxsdk/fbxsdk_nsend.h>
00640
00641 #endif