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 
91  enum EMode
92  {
112  eModesCount
113  };
114 
120  enum EProtocol {eSMPTE, eFrameCount, eDefaultProtocol};
121 
127  static void SetGlobalTimeMode(EMode pTimeMode, double pFrameRate=0.0);
128 
133  static EMode GetGlobalTimeMode();
134 
139  static void SetGlobalTimeProtocol(EProtocol pTimeProtocol);
140 
145  static EProtocol GetGlobalTimeProtocol();
146 
151  static double GetFrameRate(EMode pTimeMode);
152 
159  static EMode ConvertFrameRateToTimeMode(double pFrameRate, double pPrecision=0.00000001);
161 
169  inline void Set(FbxLongLong pTime){ mTime = pTime; }
170 
174  inline FbxLongLong Get() const { return mTime; }
175 
179  inline void SetMilliSeconds(FbxLongLong pMilliSeconds){ mTime = pMilliSeconds * FBXSDK_TC_MILLISECOND; }
180 
184  inline FbxLongLong GetMilliSeconds() const { return mTime / FBXSDK_TC_MILLISECOND; }
185 
189  void SetSecondDouble(double pTime);
190 
194  double GetSecondDouble() const;
195 
207  void SetTime(int pHour, int pMinute, int pSecond, int pFrame=0, int pField=0, EMode pTimeMode=eDefaultMode);
208 
226  void SetTime(int pHour, int pMinute, int pSecond, int pFrame, int pField, int pResidual, EMode pTimeMode);
227 
239  bool GetTime(int& pHour, int& pMinute, int& pSecond, int& pFrame, int& pField, int& pResidual, EMode pTimeMode=eDefaultMode) const;
240 
245  FbxTime GetFramedTime(bool pRound=true) const;
246 
251  void SetFrame(FbxLongLong pFrames, EMode pTimeMode=eDefaultMode);
252 
257  void SetFramePrecise(FbxDouble pFrames, EMode pTimeMode=eDefaultMode);
258 
262  int GetHourCount() const;
263 
267  int GetMinuteCount() const;
268 
272  int GetSecondCount() const;
273 
278  FbxLongLong GetFrameCount(EMode pTimeMode=eDefaultMode) const;
279 
284  FbxDouble GetFrameCountPrecise(EMode pTimeMode=eDefaultMode) const;
285 
290  FbxLongLong GetFieldCount(EMode pTimeMode=eDefaultMode) const;
291 
296  int GetResidual(EMode pTimeMode=eDefaultMode) const;
297 
302  static bool IsDropFrame(EMode pTimeMode=eDefaultMode);
303 
308  char GetFrameSeparator(EMode pTimeMode=eDefaultMode) const;
309 
325  char* GetTimeString(char* pTimeString, const FbxUShort& pTimeStringSize, int pInfo=5, EMode pTimeMode=eDefaultMode, EProtocol pTimeFormat=eDefaultProtocol) const;
326 
327  enum EElement {eHours, eMinutes, eSeconds, eFrames, eField, eResidual};
328 
335  FbxString GetTimeString(EElement pStart=eHours, EElement pEnd=eResidual, EMode pTimeMode=eDefaultMode, EProtocol pTimeFormat=eDefaultProtocol) const;
336 
349  bool SetTimeString(const char* pTime, EMode pTimeMode=eDefaultMode, EProtocol pTimeFormat=eDefaultProtocol);
351 
360  inline bool operator==(const FbxTime& pTime) const { return mTime == pTime.mTime; }
361 
366  inline bool operator!=(const FbxTime& pTime) const { return mTime != pTime.mTime; }
367 
372  inline bool operator>=(const FbxTime& pTime) const { return mTime >= pTime.mTime; }
373 
378  inline bool operator<=(const FbxTime& pTime) const { return mTime <= pTime.mTime; }
379 
384  inline bool operator>(const FbxTime& pTime) const { return mTime > pTime.mTime; }
385 
390  inline bool operator<(const FbxTime& pTime) const { return mTime < pTime.mTime; }
391 
395  inline FbxTime& operator=(const FbxTime& pTime) { mTime = pTime.mTime; return *this; }
396 
401  inline FbxTime& operator+=(const FbxTime& pTime) { mTime += pTime.mTime; return *this; }
402 
407  inline FbxTime& operator-=(const FbxTime& pTime) { mTime -= pTime.mTime; return *this; }
408 
413  FbxTime operator+(const FbxTime& pTime) const;
414 
419  FbxTime operator-(const FbxTime& pTime) const;
420 
425  FbxTime operator*(const int Mult) const;
426 
431  FbxTime operator/(const FbxTime& pTime) const;
432 
437  FbxTime operator*(const FbxTime& pTime) const;
438 /*
440  inline FbxTime& operator++() { mTime += 1; return (*this); }
441 
443  inline const FbxTime operator++(int) { FbxTime lOld = *this; ++(*this); return lOld; }
444 
446  inline FbxTime& operator--() { mTime -= 1; return (*this); }
447 
449  inline const FbxTime operator--(int) { FbxTime lOld = *this; --(*this); return lOld; }*/
451 
456  static FbxLongLong GetOneFrameValue(EMode pTimeMode=eDefaultMode);
457 
458 /*****************************************************************************************************************************
459 ** WARNING! Anything beyond these lines is for internal use, may not be documented and is subject to change without notice! **
460 *****************************************************************************************************************************/
461 #ifndef DOXYGEN_SHOULD_SKIP_THIS
462  // Keep compatibility with old fbx format
463  enum EOldMode
464  {
465  eOLD_DEFAULT_MODE, //Default mode set using FbxTime::SetGlobalTimeMode(EMode pTimeMode)
466  eOLD_CINEMA, //24 frameOLD_s/s
467  eOLD_PAL, //25 frameOLD_s/s PAL/SECAM
468  eOLD_FRAMES30, //30 frameOLD_s/s BLACK & WHITE NTSC
469  eOLD_NTSC_DROP_FRAME, //29.97002617 frameOLD_s/s COLOR NTSC
470  eOLD_FRAMES50, //50 frameOLD_s/s
471  eOLD_FRAMES60, //60 frameOLD_s/s
472  eOLD_FRAMES100, //100 frameOLD_s/s
473  eOLD_FRAMES120, //120 frameOLD_s/s
474  eOLD_NTSC_FULL_FRAME, //29.97002617 frameOLD_s/s COLOR NTSC
475  eOLD_FRAMES30_DROP, //30 frameOLD_s/s
476  eOLD_FRAMES1000 //1000 frameOLD_s/s
477  };
478 
479 private:
480  FbxLongLong mTime; //In 1 / 46,186,158,000 Seconds
481 
482  static EMode gsGlobalTimeMode;
483  static EProtocol gsGlobalTimeProtocol;
484  static FbxTimeModeObject* gsTimeObject;
485 
486  void InternalSetTime(int pHour, int pMinute, int pSecond, FbxLongLong pFrame, int pField, EMode pTimeMode);
487 
489  friend FBXSDK_DLL FbxTimeModeObject* FbxGetGlobalTimeModeObject();
491  friend FBXSDK_DLL void FbxSetGlobalTimeMode(FbxTime::EMode pTimeMode, double pFrameRate);
492  friend FBXSDK_DLL void FbxSetGlobalTimeFormat(FbxTime::EProtocol pTimeFormat);
493 #endif /* !DOXYGEN_SHOULD_SKIP_THIS *****************************************************************************************/
494 };
495 
499 FBXSDK_DLL inline FbxTime FbxTimeSeconds(const FbxDouble& pTime=0.0)
500 {
501  FbxTime lTime;
502  lTime.SetSecondDouble(pTime);
503  return lTime;
504 }
505 
511 {
512 public:
515 
520  FbxTimeSpan(FbxTime pStart, FbxTime pStop){ mStart = pStart; mStop = pStop; }
521 
526  inline void Set(FbxTime pStart, FbxTime pStop){ mStart = pStart; mStop = pStop; }
527 
531  inline void SetStart(FbxTime pStart){ mStart = pStart; }
532 
536  inline void SetStop(FbxTime pStop){ mStop = pStop; }
537 
541  inline FbxTime GetStart() const { return mStart; }
542 
546  inline FbxTime GetStop() const { return mStop; }
547 
551  inline FbxTime GetDuration() const { if( mStop > mStart ) return mStop - mStart; else return mStart - mStop; }
552 
556  inline FbxTime GetSignedDuration() const { return mStop - mStart; }
557 
561  inline int GetDirection() const { if( mStop >= mStart ) return FBXSDK_TIME_FORWARD; else return FBXSDK_TIME_BACKWARD; }
562 
567  bool IsInside(FbxTime pTime) const;
568 
573  FbxTimeSpan Intersect(const FbxTimeSpan& pTime) const;
574 
579  bool operator!=(const FbxTimeSpan& pTime) const;
580 
585  bool operator==(const FbxTimeSpan& pTime) const;
586 
594  void UnionAssignment(const FbxTimeSpan& pSpan, int pDirection=FBXSDK_TIME_FORWARD);
595 
596 /*****************************************************************************************************************************
597 ** WARNING! Anything beyond these lines is for internal use, may not be documented and is subject to change without notice! **
598 *****************************************************************************************************************************/
599 #ifndef DOXYGEN_SHOULD_SKIP_THIS
600 private:
601  FbxTime mStart;
602  FbxTime mStop;
603 #endif /* !DOXYGEN_SHOULD_SKIP_THIS *****************************************************************************************/
604 };
605 
607 {
608 public:
609  FbxLocalTime();
610 
611  int mYear;
612  int mMonth;
613  int mDay;
614  int mHour;
615  int mMinute;
616  int mSecond;
618 };
619 
621 
623 FBXSDK_DLL FbxTimeModeObject* FbxGetGlobalTimeModeObject();
625 FBXSDK_DLL void FbxSetGlobalTimeMode(FbxTime::EMode pTimeMode, double pFrameRate=0.0);
627 
628 // Use those functions to keep the compatibility with old time mode since we added new time mode.
630 FBXSDK_DLL FbxTime::EMode FbxGetTimeModeFromOldValue(FbxTime::EOldMode pOldMode);
631 
632 // We now store the framerate instead of the time mode.
634 FBXSDK_DLL void FbxGetControlStringList(char* pControlString, FbxTime::EProtocol pTimeFormat);
637 FBXSDK_DLL double FbxGetFrameRate(FbxTime::EMode pTimeMode);
638 
639 // Time format
643 FBXSDK_DLL const char* FbxGetTimeModeName(FbxTime::EMode pTimeMode);
645 FBXSDK_DLL bool FbxIsValidCustomFrameRate(double pFramerate);
646 FBXSDK_DLL bool FbxGetNearestCustomFrameRate(double pFramerate, double& pNearestRate);
647 
648 #include <fbxsdk/fbxsdk_nsend.h>
649 
650 #endif /* _FBXSDK_CORE_BASE_TIME_H_ */
bool operator<=(const FbxTime &pTime) const
Inferior or equal to operator.
Definition: fbxtime.h:378
FbxString operator+(const FbxString &pString1, const FbxString &pString2)
FbxString concatenation.
void Set(FbxTime pStart, FbxTime pStop)
Set start and stop time.
Definition: fbxtime.h:526
bool FbxIsValidCustomFrameRate(double pFramerate)
void SetStart(FbxTime pStart)
Set start time.
Definition: fbxtime.h:531
void SetSecondDouble(double pTime)
Set time in seconds.
FBX SDK environment definition.
void Set(FbxLongLong pTime)
Set time in internal format.
Definition: fbxtime.h:169
int FbxGetFrameRateStringListIndex(FbxTime::EMode pTimeMode)
int mMonth
Definition: fbxtime.h:612
FbxTime & operator-=(const FbxTime &pTime)
Subtraction operator.
Definition: fbxtime.h:407
FbxLongLong GetMilliSeconds() const
Get time in milliseconds.
Definition: fbxtime.h:184
bool operator>=(const FbxTime &pTime) const
Superior or equal to operator.
Definition: fbxtime.h:372
bool FbxGetNearestCustomFrameRate(double pFramerate, double &pNearestRate)
EProtocol
Time protocols enumaration.
Definition: fbxtime.h:120
int mSecond
Definition: fbxtime.h:616
double FbxGetFrameRate(FbxTime::EMode pTimeMode)
Utility class to manipulate strings.
Definition: fbxstring.h:66
const char * FbxGetGlobalFrameRateString(FbxTime::EMode pTimeMode)
FbxTime(const FbxLongLong pTime=0)
Long long constructor.
Definition: fbxtime.h:50
void SetStop(FbxTime pStop)
Set stop time.
Definition: fbxtime.h:536
FbxTime::EOldMode FbxGetOldTimeModeCorrespondance(FbxTime::EMode pMode)
#define FBXSDK_TIME_FORWARD
Definition: fbxtime.h:31
FbxTimeSpan(FbxTime pStart, FbxTime pStop)
Constructor.
Definition: fbxtime.h:520
#define FBXSDK_TC_MILLISECOND
Definition: fbxtimecode.h:29
unsigned short FbxUShort
Definition: fbxtypes.h:38
FbxTime GetStop() const
Get stop time.
Definition: fbxtime.h:546
int mMinute
Definition: fbxtime.h:615
FbxTime GetSignedDuration() const
Get time interval.
Definition: fbxtime.h:556
double FbxDouble
Definition: fbxtypes.h:42
FbxTime::EMode FbxSelectionToTimeMode(int pSelection)
Class to encapsulate time units.
Definition: fbxtime.h:44
FbxTime::EMode FbxGetGlobalTimeMode()
FbxTime::EProtocol FbxGetGlobalTimeFormat()
int mMillisecond
Definition: fbxtime.h:617
FbxTime FbxTimeSeconds(const FbxDouble &pTime=0.0)
FbxTime in seconds constructor.
Definition: fbxtime.h:499
FbxTime & operator=(const FbxTime &pTime)
Assignment operator.
Definition: fbxtime.h:395
FbxTime::EProtocol FbxSelectionToTimeFormat(int pSelection)
EMode
Time modes.
Definition: fbxtime.h:91
EElement
Definition: fbxtime.h:327
void FbxSetGlobalTimeMode(FbxTime::EMode pTimeMode, double pFrameRate=0.0)
FbxTimeSpan()
Constructor.
Definition: fbxtime.h:514
void FbxSetGlobalTimeFormat(FbxTime::EProtocol pTimeFormat)
bool operator<(const FbxTime &pTime) const
Inferior to operator.
Definition: fbxtime.h:390
const char * FbxGetGlobalTimeModeString(FbxTime::EMode pTimeMode)
int GetDirection() const
Get direction of the time interval.
Definition: fbxtime.h:561
#define FBXSDK_DLL
Definition: fbxarch.h:176
void FbxGetControlStringList(char *pControlString, FbxTime::EProtocol pTimeFormat)
void FbxGetCurrentLocalTime(FbxLocalTime &pLocalTime)
bool operator!=(const FbxTime &pTime) const
Inequality operator.
Definition: fbxtime.h:366
Class to encapsulate time intervals.
Definition: fbxtime.h:510
FbxTime::EMode FbxGetTimeModeFromOldValue(FbxTime::EOldMode pOldMode)
bool operator==(const FbxTime &pTime) const
Equality operator.
Definition: fbxtime.h:360
bool operator>(const FbxTime &pTime) const
Superior to operator.
Definition: fbxtime.h:384
FbxTime::EMode FbxGetTimeModeFromFrameRate(char *pFrameRate)
void SetMilliSeconds(FbxLongLong pMilliSeconds)
Set time in milliseconds.
Definition: fbxtime.h:179
FbxInt64 FbxLongLong
Definition: fbxtypes.h:92
FbxTime GetDuration() const
Get time interval in absolute value.
Definition: fbxtime.h:551
int FbxTimeToSelection(FbxTime::EMode pTimeMode=FbxTime::eDefaultMode, int pTimeFormat=FbxTime::eDefaultProtocol)
FbxTimeModeObject * FbxGetGlobalTimeModeObject()
FbxTime & operator+=(const FbxTime &pTime)
Addition operator.
Definition: fbxtime.h:401
FbxLongLong Get() const
Get time in internal format.
Definition: fbxtime.h:174
#define FBXSDK_TIME_BACKWARD
Definition: fbxtime.h:32
const char * FbxGetTimeModeName(FbxTime::EMode pTimeMode)
FbxTime GetStart() const
Get start time.
Definition: fbxtime.h:541