FBX C++ API Reference
fbxtime.h
Go to the documentation of this file.
1 /****************************************************************************************
2 
3  Copyright (C) 2015 Autodesk, Inc.
4  All rights reserved.
5 
6  Use of this software is subject to the terms of the Autodesk license agreement
7  provided at the time of installation or download, or which otherwise accompanies
8  this software in either electronic or hard copy form.
9 
10 ****************************************************************************************/
11 
13 #ifndef _FBXSDK_CORE_BASE_TIME_H_
14 #define _FBXSDK_CORE_BASE_TIME_H_
15 
16 #include <fbxsdk/fbxsdk_def.h>
17 
20 
21 #include <fbxsdk/fbxsdk_nsbegin.h>
22 
23 #define FBXSDK_TIME_INFINITE FbxTime(FBXSDK_TC_INFINITY)
24 #define FBXSDK_TIME_MINUS_INFINITE FbxTime(FBXSDK_TC_MINFINITY)
25 #define FBXSDK_TIME_ZERO FbxTime(FBXSDK_TC_ZERO)
26 #define FBXSDK_TIME_EPSILON FbxTime(FBXSDK_TC_EPSILON)
27 #define FBXSDK_TIME_ONE_SECOND FbxTime(FBXSDK_TC_SECOND)
28 #define FBXSDK_TIME_ONE_MINUTE FbxTime(FBXSDK_TC_MINUTE)
29 #define FBXSDK_TIME_ONE_HOUR FbxTime(FBXSDK_TC_HOUR)
30 #define FBXSDK_TIME_ASSERT_EPSILON 0.5
31 #define FBXSDK_TIME_FORWARD 1
32 #define FBXSDK_TIME_BACKWARD -1
33 
34 class FbxTimeModeObject;
35 
45 {
46 public:
50  FbxTime(const FbxLongLong pTime=0){ mTime = pTime; }
51 
90  enum EMode
91  {
110  eModesCount
111  };
112 
118  enum EProtocol {eSMPTE, eFrameCount, eDefaultProtocol};
119 
125  static void SetGlobalTimeMode(EMode pTimeMode, double pFrameRate=0.0);
126 
131  static EMode GetGlobalTimeMode();
132 
137  static void SetGlobalTimeProtocol(EProtocol pTimeProtocol);
138 
143  static EProtocol GetGlobalTimeProtocol();
144 
149  static double GetFrameRate(EMode pTimeMode);
150 
157  static EMode ConvertFrameRateToTimeMode(double pFrameRate, double pPrecision=0.00000001);
159 
167  inline void Set(FbxLongLong pTime){ mTime = pTime; }
168 
172  inline FbxLongLong Get() const { return mTime; }
173 
177  inline void SetMilliSeconds(FbxLongLong pMilliSeconds){ mTime = pMilliSeconds * FBXSDK_TC_MILLISECOND; }
178 
182  inline FbxLongLong GetMilliSeconds() const { return mTime / FBXSDK_TC_MILLISECOND; }
183 
187  void SetSecondDouble(double pTime);
188 
192  double GetSecondDouble() const;
193 
205  void SetTime(int pHour, int pMinute, int pSecond, int pFrame=0, int pField=0, EMode pTimeMode=eDefaultMode);
206 
224  void SetTime(int pHour, int pMinute, int pSecond, int pFrame, int pField, int pResidual, EMode pTimeMode);
225 
237  bool GetTime(int& pHour, int& pMinute, int& pSecond, int& pFrame, int& pField, int& pResidual, EMode pTimeMode=eDefaultMode) const;
238 
243  FbxTime GetFramedTime(bool pRound=true) const;
244 
249  void SetFrame(FbxLongLong pFrames, EMode pTimeMode=eDefaultMode);
250 
255  void SetFramePrecise(FbxDouble pFrames, EMode pTimeMode=eDefaultMode);
256 
260  int GetHourCount() const;
261 
265  int GetMinuteCount() const;
266 
270  int GetSecondCount() const;
271 
276  FbxLongLong GetFrameCount(EMode pTimeMode=eDefaultMode) const;
277 
282  FbxDouble GetFrameCountPrecise(EMode pTimeMode=eDefaultMode) const;
283 
288  FbxLongLong GetFieldCount(EMode pTimeMode=eDefaultMode) const;
289 
294  int GetResidual(EMode pTimeMode=eDefaultMode) const;
295 
300  static bool IsDropFrame(EMode pTimeMode=eDefaultMode);
301 
306  char GetFrameSeparator(EMode pTimeMode=eDefaultMode) const;
307 
323  char* GetTimeString(char* pTimeString, const FbxUShort& pTimeStringSize, int pInfo=5, EMode pTimeMode=eDefaultMode, EProtocol pTimeFormat=eDefaultProtocol) const;
324 
325  enum EElement {eHours, eMinutes, eSeconds, eFrames, eField, eResidual};
326 
333  FbxString GetTimeString(EElement pStart=eHours, EElement pEnd=eResidual, EMode pTimeMode=eDefaultMode, EProtocol pTimeFormat=eDefaultProtocol) const;
334 
347  bool SetTimeString(const char* pTime, EMode pTimeMode=eDefaultMode, EProtocol pTimeFormat=eDefaultProtocol);
349 
358  inline bool operator==(const FbxTime& pTime) const { return mTime == pTime.mTime; }
359 
364  inline bool operator!=(const FbxTime& pTime) const { return mTime != pTime.mTime; }
365 
370  inline bool operator>=(const FbxTime& pTime) const { return mTime >= pTime.mTime; }
371 
376  inline bool operator<=(const FbxTime& pTime) const { return mTime <= pTime.mTime; }
377 
382  inline bool operator>(const FbxTime& pTime) const { return mTime > pTime.mTime; }
383 
388  inline bool operator<(const FbxTime& pTime) const { return mTime < pTime.mTime; }
389 
393  inline FbxTime& operator=(const FbxTime& pTime) { mTime = pTime.mTime; return *this; }
394 
399  inline FbxTime& operator+=(const FbxTime& pTime) { mTime += pTime.mTime; return *this; }
400 
405  inline FbxTime& operator-=(const FbxTime& pTime) { mTime -= pTime.mTime; return *this; }
406 
411  FbxTime operator+(const FbxTime& pTime) const;
412 
417  FbxTime operator-(const FbxTime& pTime) const;
418 
423  FbxTime operator*(const int Mult) const;
424 
429  FbxTime operator/(const FbxTime& pTime) const;
430 
435  FbxTime operator*(const FbxTime& pTime) const;
436 /*
438  inline FbxTime& operator++() { mTime += 1; return (*this); }
439 
441  inline const FbxTime operator++(int) { FbxTime lOld = *this; ++(*this); return lOld; }
442 
444  inline FbxTime& operator--() { mTime -= 1; return (*this); }
445 
447  inline const FbxTime operator--(int) { FbxTime lOld = *this; --(*this); return lOld; }*/
449 
454  static FbxLongLong GetOneFrameValue(EMode pTimeMode=eDefaultMode);
455 
456 /*****************************************************************************************************************************
457 ** WARNING! Anything beyond these lines is for internal use, may not be documented and is subject to change without notice! **
458 *****************************************************************************************************************************/
459 #ifndef DOXYGEN_SHOULD_SKIP_THIS
460  // Keep compatibility with old fbx format
461  enum EOldMode
462  {
463  eOLD_DEFAULT_MODE, //Default mode set using FbxTime::SetGlobalTimeMode(EMode pTimeMode)
464  eOLD_CINEMA, //24 frameOLD_s/s
465  eOLD_PAL, //25 frameOLD_s/s PAL/SECAM
466  eOLD_FRAMES30, //30 frameOLD_s/s BLACK & WHITE NTSC
467  eOLD_NTSC_DROP_FRAME, //29.97002617 frameOLD_s/s COLOR NTSC
468  eOLD_FRAMES50, //50 frameOLD_s/s
469  eOLD_FRAMES60, //60 frameOLD_s/s
470  eOLD_FRAMES100, //100 frameOLD_s/s
471  eOLD_FRAMES120, //120 frameOLD_s/s
472  eOLD_NTSC_FULL_FRAME, //29.97002617 frameOLD_s/s COLOR NTSC
473  eOLD_FRAMES30_DROP, //30 frameOLD_s/s
474  eOLD_FRAMES1000 //1000 frameOLD_s/s
475  };
476 
477 private:
478  FbxLongLong mTime; //In 1 / 46,186,158,000 Seconds
479 
480  static EMode gsGlobalTimeMode;
481  static EProtocol gsGlobalTimeProtocol;
482  static FbxTimeModeObject* gsTimeObject;
483 
484  void InternalSetTime(int pHour, int pMinute, int pSecond, FbxLongLong pFrame, int pField, EMode pTimeMode);
485 
487  friend FBXSDK_DLL FbxTimeModeObject* FbxGetGlobalTimeModeObject();
489  friend FBXSDK_DLL void FbxSetGlobalTimeMode(FbxTime::EMode pTimeMode, double pFrameRate);
490  friend FBXSDK_DLL void FbxSetGlobalTimeFormat(FbxTime::EProtocol pTimeFormat);
491 #endif /* !DOXYGEN_SHOULD_SKIP_THIS *****************************************************************************************/
492 };
493 
497 FBXSDK_DLL inline FbxTime FbxTimeSeconds(const FbxDouble& pTime=0.0)
498 {
499  FbxTime lTime;
500  lTime.SetSecondDouble(pTime);
501  return lTime;
502 }
503 
509 {
510 public:
513 
518  FbxTimeSpan(FbxTime pStart, FbxTime pStop){ mStart = pStart; mStop = pStop; }
519 
524  inline void Set(FbxTime pStart, FbxTime pStop){ mStart = pStart; mStop = pStop; }
525 
529  inline void SetStart(FbxTime pStart){ mStart = pStart; }
530 
534  inline void SetStop(FbxTime pStop){ mStop = pStop; }
535 
539  inline FbxTime GetStart() const { return mStart; }
540 
544  inline FbxTime GetStop() const { return mStop; }
545 
549  inline FbxTime GetDuration() const { if( mStop > mStart ) return mStop - mStart; else return mStart - mStop; }
550 
554  inline FbxTime GetSignedDuration() const { return mStop - mStart; }
555 
559  inline int GetDirection() const { if( mStop >= mStart ) return FBXSDK_TIME_FORWARD; else return FBXSDK_TIME_BACKWARD; }
560 
565  bool IsInside(FbxTime pTime) const;
566 
571  FbxTimeSpan Intersect(const FbxTimeSpan& pTime) const;
572 
577  bool operator!=(const FbxTimeSpan& pTime) const;
578 
583  bool operator==(const FbxTimeSpan& pTime) const;
584 
592  void UnionAssignment(const FbxTimeSpan& pSpan, int pDirection=FBXSDK_TIME_FORWARD);
593 
594 /*****************************************************************************************************************************
595 ** WARNING! Anything beyond these lines is for internal use, may not be documented and is subject to change without notice! **
596 *****************************************************************************************************************************/
597 #ifndef DOXYGEN_SHOULD_SKIP_THIS
598 private:
599  FbxTime mStart;
600  FbxTime mStop;
601 #endif /* !DOXYGEN_SHOULD_SKIP_THIS *****************************************************************************************/
602 };
603 
605 {
606 public:
607  FbxLocalTime();
608 
609  int mYear;
610  int mMonth;
611  int mDay;
612  int mHour;
613  int mMinute;
614  int mSecond;
616 };
617 
619 
621 FBXSDK_DLL FbxTimeModeObject* FbxGetGlobalTimeModeObject();
623 FBXSDK_DLL void FbxSetGlobalTimeMode(FbxTime::EMode pTimeMode, double pFrameRate=0.0);
625 
626 // Use those functions to keep the compatibility with old time mode since we added new time mode.
628 FBXSDK_DLL FbxTime::EMode FbxGetTimeModeFromOldValue(FbxTime::EOldMode pOldMode);
629 
630 // We now store the framerate instead of the time mode.
632 FBXSDK_DLL void FbxGetControlStringList(char* pControlString, FbxTime::EProtocol pTimeFormat);
635 FBXSDK_DLL double FbxGetFrameRate(FbxTime::EMode pTimeMode);
636 
637 // Time format
641 FBXSDK_DLL const char* FbxGetTimeModeName(FbxTime::EMode pTimeMode);
643 FBXSDK_DLL bool FbxIsValidCustomFrameRate(double pFramerate);
644 FBXSDK_DLL bool FbxGetNearestCustomFrameRate(double pFramerate, double& pNearestRate);
645 
646 #include <fbxsdk/fbxsdk_nsend.h>
647 
648 #endif /* _FBXSDK_CORE_BASE_TIME_H_ */
FbxString operator+(const FbxString &pString1, const FbxString &pString2)
FbxString concatenation.
void Set(FbxTime pStart, FbxTime pStop)
Set start and stop time.
Definition: fbxtime.h:524
bool FbxIsValidCustomFrameRate(double pFramerate)
FbxTime GetStop() const
Get stop time.
Definition: fbxtime.h:544
void SetStart(FbxTime pStart)
Set start time.
Definition: fbxtime.h:529
void SetSecondDouble(double pTime)
Set time in seconds.
FBX SDK environment definition.
void Set(FbxLongLong pTime)
Set time in internal format.
Definition: fbxtime.h:167
int FbxGetFrameRateStringListIndex(FbxTime::EMode pTimeMode)
int mMonth
Definition: fbxtime.h:610
FbxTime & operator-=(const FbxTime &pTime)
Subtraction operator.
Definition: fbxtime.h:405
bool FbxGetNearestCustomFrameRate(double pFramerate, double &pNearestRate)
EProtocol
Time protocols enumaration.
Definition: fbxtime.h:118
int mSecond
Definition: fbxtime.h:614
double FbxGetFrameRate(FbxTime::EMode pTimeMode)
FbxTime GetDuration() const
Get time interval in absolute value.
Definition: fbxtime.h:549
Utility class to manipulate strings.
Definition: fbxstring.h:66
const char * FbxGetGlobalFrameRateString(FbxTime::EMode pTimeMode)
int GetDirection() const
Get direction of the time interval.
Definition: fbxtime.h:559
FbxTime GetSignedDuration() const
Get time interval.
Definition: fbxtime.h:554
bool operator<=(const FbxTime &pTime) const
Inferior or equal to operator.
Definition: fbxtime.h:376
FbxTime(const FbxLongLong pTime=0)
Long long constructor.
Definition: fbxtime.h:50
void SetStop(FbxTime pStop)
Set stop time.
Definition: fbxtime.h:534
FbxTime::EOldMode FbxGetOldTimeModeCorrespondance(FbxTime::EMode pMode)
#define FBXSDK_TIME_FORWARD
Definition: fbxtime.h:31
FbxTimeSpan(FbxTime pStart, FbxTime pStop)
Constructor.
Definition: fbxtime.h:518
#define FBXSDK_TC_MILLISECOND
Definition: fbxtimecode.h:26
unsigned short FbxUShort
Definition: fbxtypes.h:38
int mMinute
Definition: fbxtime.h:613
double FbxDouble
Definition: fbxtypes.h:42
FbxTime::EMode FbxSelectionToTimeMode(int pSelection)
FbxTime GetStart() const
Get start time.
Definition: fbxtime.h:539
bool operator<(const FbxTime &pTime) const
Inferior to operator.
Definition: fbxtime.h:388
Class to encapsulate time units.
Definition: fbxtime.h:44
FbxTime::EMode FbxGetGlobalTimeMode()
FbxTime::EProtocol FbxGetGlobalTimeFormat()
bool operator>=(const FbxTime &pTime) const
Superior or equal to operator.
Definition: fbxtime.h:370
int mMillisecond
Definition: fbxtime.h:615
FbxTime FbxTimeSeconds(const FbxDouble &pTime=0.0)
FbxTime in seconds constructor.
Definition: fbxtime.h:497
FbxTime & operator=(const FbxTime &pTime)
Assignment operator.
Definition: fbxtime.h:393
FbxTime::EProtocol FbxSelectionToTimeFormat(int pSelection)
FbxLongLong GetMilliSeconds() const
Get time in milliseconds.
Definition: fbxtime.h:182
bool operator>(const FbxTime &pTime) const
Superior to operator.
Definition: fbxtime.h:382
EMode
Time modes.
Definition: fbxtime.h:90
EElement
Definition: fbxtime.h:325
void FbxSetGlobalTimeMode(FbxTime::EMode pTimeMode, double pFrameRate=0.0)
FbxTimeSpan()
Constructor.
Definition: fbxtime.h:512
bool operator!=(const FbxTime &pTime) const
Inequality operator.
Definition: fbxtime.h:364
void FbxSetGlobalTimeFormat(FbxTime::EProtocol pTimeFormat)
const char * FbxGetGlobalTimeModeString(FbxTime::EMode pTimeMode)
#define FBXSDK_DLL
Definition: fbxarch.h:173
void FbxGetControlStringList(char *pControlString, FbxTime::EProtocol pTimeFormat)
void FbxGetCurrentLocalTime(FbxLocalTime &pLocalTime)
Class to encapsulate time intervals.
Definition: fbxtime.h:508
FbxTime::EMode FbxGetTimeModeFromOldValue(FbxTime::EOldMode pOldMode)
FbxLongLong Get() const
Get time in internal format.
Definition: fbxtime.h:172
bool operator==(const FbxTime &pTime) const
Equality operator.
Definition: fbxtime.h:358
FbxTime::EMode FbxGetTimeModeFromFrameRate(char *pFrameRate)
void SetMilliSeconds(FbxLongLong pMilliSeconds)
Set time in milliseconds.
Definition: fbxtime.h:177
FbxInt64 FbxLongLong
Definition: fbxtypes.h:92
int FbxTimeToSelection(FbxTime::EMode pTimeMode=FbxTime::eDefaultMode, int pTimeFormat=FbxTime::eDefaultProtocol)
FbxTimeModeObject * FbxGetGlobalTimeModeObject()
FbxTime & operator+=(const FbxTime &pTime)
Addition operator.
Definition: fbxtime.h:399
#define FBXSDK_TIME_BACKWARD
Definition: fbxtime.h:32
const char * FbxGetTimeModeName(FbxTime::EMode pTimeMode)