Public Member Functions | Static Public Member Functions | Friends

KTime Class Reference

This reference page is linked to from the following overview topics: Information and Technical Support, Transformation Data, List of Python FBX classes.


Search for all occurrences

Detailed Description

Class to encapsulate time units.

KTime can measure time in hour, minute, second, frame, field, residual and also combination of these units. It is recommended to use KTime for all time related operations. For example, currently it is used in KFbxGlobalSettings, KFbxGlobalTimeSettings, KFbxCache, all curve filters and all animation-related classes, etc. KTime is just used to represent a moment, to represent a period of time, KTimeSpan should be used.

See also:
KTimeSpan
Examples:

Animation/main.cxx, ExportScene01/main.cxx, ExportScene02/main.cxx, ExportScene03/main.cxx, ExportScene04/main.cxx, ImportScene/DisplayAnimation.cxx, ImportScene/DisplayGlobalSettings.cxx, Instances/main.cxx, Pivot/main.cxx, UIExamples/CubeCreator/SDK_Utility.cxx, UserProperties/main.cxx, ViewScene/DrawScene.cxx, ViewScene/DrawScene.h, ViewScene/GetPosition.cxx, ViewScene/GetPosition.h, ViewScene/main.cxx, ViewScene/SetCamera.cxx, and ViewScene/SetCamera.h.

Definition at line 71 of file ktime.h.

#include <ktime.h>

List of all members.

Public Member Functions

  KTime (kLongLong pTime=0)
  Constructor.

Static Public Member Functions

static KTime  GetSystemTimer ()

Friends

KFBX_DLL KTime::ETimeMode  KTime_GetGlobalTimeMode ()
KFBX_DLL HKTimeModeObject  KTime_GetGlobalTimeModeObject ()
KFBX_DLL KTime::ETimeProtocol  KTime_GetGlobalTimeFormat ()
KFBX_DLL void  KTime_SetGlobalTimeMode (KTime::ETimeMode pTimeMode, double pFrameRate=0.0)
KFBX_DLL void  KTime_SetGlobalTimeFormat (KTime::ETimeProtocol pTimeFormat)

Time Modes and Protocols

enum   ETimeMode {
  eDEFAULT_MODE = 0, eFRAMES120 = 1, eFRAMES100 = 2, eFRAMES60 = 3,
  eFRAMES50 = 4, eFRAMES48 = 5, eFRAMES30 = 6, eFRAMES30_DROP = 7,
  eNTSC_DROP_FRAME = 8, eNTSC_FULL_FRAME = 9, ePAL = 10, eCINEMA = 11,
  eFRAMES1000 = 12, eCINEMA_ND = 13, eCUSTOM = 14, eTIME_MODE_COUNT = 15
}
 

Time modes.

More...
enum   ETimeProtocol { eSMPTE, eFRAME, eDEFAULT_PROTOCOL, eTIME_PROTOCOL_COUNT }
 

Time protocols.

More...
static void  SetGlobalTimeMode (ETimeMode pTimeMode, double pFrameRate=0.0)
  Set default time mode.
static ETimeMode  GetGlobalTimeMode ()
  Get default time mode.
static void  SetGlobalTimeProtocol (ETimeProtocol pTimeProtocol)
  Set default time protocol.
static ETimeProtocol  GetGlobalTimeProtocol ()
  Get default time protocol.
static double  GetFrameRate (ETimeMode pTimeMode)
  Get frame rate associated with time mode, in frames per second.
static ETimeMode  ConvertFrameRateToTimeMode (double pFrameRate, double lPrecision=0.00000001)
  Get time mode associated with frame rate.

Time Conversion

void  Set (kLongLong pTime)
  Set time in internal format.
const kLongLong Get () const
  Get time in internal format.
void  SetMilliSeconds (kLongLong pMilliSeconds)
  Set time in milliseconds.
kLongLong  GetMilliSeconds () const
  Get time in milliseconds.
void  SetSecondDouble (double pTime)
  Set time in seconds.
double  GetSecondDouble () const
  Get time in seconds.
void  SetTime (int pHour, int pMinute, int pSecond, int pFrame=0, int pField=0, int pTimeMode=eDEFAULT_MODE, double pFramerate=0.0)
  Set time in hour/minute/second/frame/field format.
void  SetTime (int pHour, int pMinute, int pSecond, int pFrame, int pField, int pResidual, int pTimeMode, double pFramerate=0.0)
  Set time in hour/minute/second/frame/field/residual format.
bool  GetTime (kLongLong &pHour, kLongLong &pMinute, kLongLong &pSecond, kLongLong &pFrame, kLongLong &pField, kLongLong &pResidual, int pTimeMode=eDEFAULT_MODE, double pFramerate=0.0) const
  Get time in hour/minute/second/frame/field/residual format.
KTime  GetFramedTime (bool pRound=true)
  Snaps a time value to the time value associated with the nearest frame.
kLongLong  GetHour (bool pCummul=false, int pTimeMode=eDEFAULT_MODE, double pFramerate=0.0) const
  Get number of hours in time.
kLongLong  GetMinute (bool pCummul=false, int pTimeMode=eDEFAULT_MODE, double pFramerate=0.0) const
  Get number of minutes in time.
kLongLong  GetSecond (bool pCummul=false, int pTimeMode=eDEFAULT_MODE, double pFramerate=0.0) const
  Get number of seconds in time.
kLongLong  GetFrame (bool pCummul=false, int pTimeMode=eDEFAULT_MODE, double pFramerate=0.0) const
  Get number of frames in time.
kLongLong  GetField (bool pCummul=false, int pTimeMode=eDEFAULT_MODE, double pFramerate=0.0) const
  Get number of fields in time.
kLongLong  GetResidual (int pTimeMode=eDEFAULT_MODE, double pFramerate=0.0) const
  Get residual time exceeding last full field.
char *  GetTimeString (char *pTimeString, int pInfo=5, int pTimeMode=eDEFAULT_MODE, int pTimeFormat=eDEFAULT_PROTOCOL, double pFramerate=0.0) const
  Get time in a human readable format.
void  SetTimeString (char *pTime, int pTimeMode=eDEFAULT_MODE, int pTimeFormat=eDEFAULT_PROTOCOL, double pFramerate=0.0)
  Set time in a human readable format.

Time Operators

bool  operator== (const KTime &pTime) const
  Equality operator.
bool  operator!= (const KTime &pTime) const
  Inequality operator.
bool  operator>= (const KTime &pTime) const
  Superior or equal to operator.
bool  operator<= (const KTime &pTime) const
  Inferior or equal to operator.
bool  operator> (const KTime &pTime) const
  Superior to operator.
bool  operator< (const KTime &pTime) const
  Inferior to operator.
KTime operator= (const KTime &pTime)
  Assignment operator.
KTime operator+= (const KTime &pTime)
  Addition operator.
KTime operator-= (const KTime &pTime)
  Subtraction operator.
KTime  operator+ (const KTime &pTime) const
  Addition operator.
KTime  operator- (const KTime &pTime) const
  Subtraction operator.
KTime  operator* (const int Mult) const
  Multiplication operator.
KTime  operator/ (const KTime &pTime) const
  Division operator.
KTime  operator* (const KTime &pTime) const
  Multiplication operator.
KTime operator++ ()
  Increment time of one unit of the internal format (prefix form).
const KTime  operator++ (int)
  Increment time of one unit of the internal format (postfix form).
KTime operator-- ()
  Decrement time of one unit of the internal format (prefix form).
const KTime  operator-- (int)
  Decrement time of one unit of the internal format (postfix form).

Member Enumeration Documentation

enum ETimeMode

Time modes.

Remarks:
Mode eNTSC_DROP_FRAME is used for broadcasting operations where clock time must be (almost) in sync with time code. To bring back color NTSC time code with clock time, this mode drops 2 frames per minute except for every 10 minutes (00, 10, 20, 30, 40, 50). 108 frames are dropped per hour. Over 24 hours the error is 2 frames and 1/4 of a frame.
Mode eNTSC_FULL_FRAME represents a time address and therefore is NOT IN SYNC with clock time. A time code of 01:00:00:00 equals a clock time of 01:00:03:18.
Mode eFRAMES30_DROP drops 2 frames every minutes except for every 10 minutes (00, 10, 20, 30, 40, 50). This time code represents a time address and is therefore NOT IN SYNC with clock time. A time code of 01:00:03:18 equals a clock time of 01:00:00:00. It is the close counterpart of mode eNTSC_FULL_FRAME. Time modes.
  • eDEFAULT_MODE
  • eFRAMES120 120 frames/s
  • eFRAMES100 100 frames/s
  • eFRAMES60 60 frames/s
  • eFRAMES50 50 frames/s
  • eFRAMES48 48 frame/s
  • eFRAMES30 30 frames/s BLACK & WHITE NTSC
  • eFRAMES30_DROP 30 frames/s use when display in frame is selected(equivalent to NTSC_DROP)
  • eNTSC_DROP_FRAME 29.97002617 frames/s drop COLOR NTSC
  • eNTSC_FULL_FRAME 29.97002617 frames/s COLOR NTSC
  • ePAL 25 frames/s PAL/SECAM
  • eCINEMA 24 frames/s
  • eFRAMES1000 1000 milli/s (use for date time)
  • eCINEMA_ND 23.976 frames/s
  • eCUSTOM Custom Framerate value
  • eTIME_MODE_COUNT Number of time modes.
Enumerator:
eDEFAULT_MODE 
eFRAMES120 
eFRAMES100 
eFRAMES60 
eFRAMES50 
eFRAMES48 
eFRAMES30 
eFRAMES30_DROP 
eNTSC_DROP_FRAME 
eNTSC_FULL_FRAME 
ePAL 
eCINEMA 
eFRAMES1000 
eCINEMA_ND 
eCUSTOM 
eTIME_MODE_COUNT 

Definition at line 128 of file ktime.h.

Time protocols.

  • eSMPTE SMPTE Protocol
  • eFRAME Frame count
  • eDEFAULT_PROTOCOL Default protocol (initialized to eFRAMES)
  • eTIME_PROTOCOL_COUNT Number of time protocols.
Enumerator:
eSMPTE 
eFRAME 
eDEFAULT_PROTOCOL 
eTIME_PROTOCOL_COUNT 

Definition at line 154 of file ktime.h.


Constructor & Destructor Documentation

KTime ( kLongLong  pTime = 0 ) [inline]

Constructor.

Parameters:
pTime Initial value.

Definition at line 77 of file ktime.h.

{mTime=pTime;}

Member Function Documentation

static void SetGlobalTimeMode ( ETimeMode  pTimeMode,
double  pFrameRate = 0.0 
) [static]

Set default time mode.

Parameters:
pTimeMode Time mode identifier.
pFrameRate Custom framerate, only have effect in case of pTimeMode = KTime::eCUSTOM
Remarks:
It is meaningless to set default time mode to eDEFAULT_MODE.
static ETimeMode GetGlobalTimeMode ( ) [static]

Get default time mode.

Returns:
Currently set time mode identifier.
Remarks:
Default time mode initial value is eFRAMES30.
static void SetGlobalTimeProtocol ( ETimeProtocol  pTimeProtocol ) [static]

Set default time protocol.

Parameters:
pTimeProtocol Time protocol identifier.
Remarks:
It is meaningless to set default time protocol to eDEFAULT_PROTOCOL.
static ETimeProtocol GetGlobalTimeProtocol ( ) [static]

Get default time protocol.

Returns:
Currently set time protocol identifier.
Remarks:
Default time protocol initial value is eSMPTE.
static double GetFrameRate ( ETimeMode  pTimeMode ) [static]

Get frame rate associated with time mode, in frames per second.

Parameters:
pTimeMode Time mode identifier.
Returns:
Frame rate value.
Examples:
ExportScene03/main.cxx, and ViewScene/InitScene.cxx.
static ETimeMode ConvertFrameRateToTimeMode ( double  pFrameRate,
double  lPrecision = 0.00000001 
) [static]

Get time mode associated with frame rate.

Parameters:
pFrameRate The frame rate value.
lPrecision The tolerance value.
Returns:
The corresponding time mode identifier or eDEFAULT_MODE if no time mode associated to the given frame rate is found.
void Set ( kLongLong  pTime ) [inline]

Set time in internal format.

Parameters:
pTime Time value to set.

Definition at line 211 of file ktime.h.

{mTime = pTime;}
const kLongLong& Get ( ) const [inline]

Get time in internal format.

Returns:
Time value.
Examples:
ExportScene03/main.cxx.

Definition at line 216 of file ktime.h.

{return mTime;}
void SetMilliSeconds ( kLongLong  pMilliSeconds ) [inline]

Set time in milliseconds.

Parameters:
pMilliSeconds Time value to set.

Definition at line 221 of file ktime.h.

{mTime = pMilliSeconds * K_LONGLONG(46186158);}
kLongLong GetMilliSeconds ( ) const [inline]

Get time in milliseconds.

Returns:
Time value.
Examples:
ViewScene/main.cxx.

Definition at line 226 of file ktime.h.

{return mTime / K_LONGLONG(46186158);}
void SetSecondDouble ( double  pTime )
double GetSecondDouble ( ) const

Get time in seconds.

Returns:
Time value.
Examples:
ExportScene03/main.cxx, and ViewScene/main.cxx.
void SetTime ( int  pHour,
int  pMinute,
int  pSecond,
int  pFrame = 0,
int  pField = 0,
int  pTimeMode = eDEFAULT_MODE,
double  pFramerate = 0.0 
)

Set time in hour/minute/second/frame/field format.

Parameters:
pHour The hours value.
pMinute The minutes value.
pSecond The seconds value.
pFrame The frames values.
pField The field value.
pTimeMode Time mode identifier.
pFramerate Custom framerate in case of pTimeMode = KTime::eCUSTOM
Remarks:
Parameters pHour, pMinute, pSecond, pFrame and pField are summed together. For example, it is possible to set the time to 83 seconds in the following ways: SetTime(0,1,23) or SetTime(0,0,83).
Examples:
ExportScene03/main.cxx, and ViewScene/main.cxx.
void SetTime ( int  pHour,
int  pMinute,
int  pSecond,
int  pFrame,
int  pField,
int  pResidual,
int  pTimeMode,
double  pFramerate = 0.0 
)

Set time in hour/minute/second/frame/field/residual format.

Parameters:
pHour The hours value.
pMinute The minutes value.
pSecond The seconds value.
pFrame The frames values.
pField The field value.
pResidual The hundredths of frame value.
pTimeMode Time mode identifier.
pFramerate Custom framerate in case of pTimeMode = KTime::eCUSTOM
Remarks:
Parameters pHour, pMinute, pSecond, pFrame, pField and pResidual are summed together, just like above. pResidual represents hundredths of frame, and won't necessarily correspond to an exact internal value.
The time mode can't have a default value, because otherwise SetTime(int, int, int, int, int, int) would be ambiguous. Please specify DEFAULT_MODE.
bool GetTime ( kLongLong pHour,
kLongLong pMinute,
kLongLong pSecond,
kLongLong pFrame,
kLongLong pField,
kLongLong pResidual,
int  pTimeMode = eDEFAULT_MODE,
double  pFramerate = 0.0 
) const

Get time in hour/minute/second/frame/field/residual format.

Parameters:
pHour The returned hours value.
pMinute The returned minutes value.
pSecond The returned seconds value.
pFrame The returned frames values.
pField The returned field value.
pResidual The returned hundredths of frame value.
pTimeMode The time mode identifier which will dictate the extraction algorithm.
pFramerate Custom framerate in case of pTimeMode = KTime::eCUSTOM
Returns:
true if the pTimeMode parameter is a valid identifier and thus the extraction succeeded. If the function returns false, all the values are set to 0.
KTime GetFramedTime ( bool  pRound = true )

Snaps a time value to the time value associated with the nearest frame.

Parameters:
pRound If true the return value is rounded to the nearest integer.
Returns:
The snapped time value.
kLongLong GetHour ( bool  pCummul = false,
int  pTimeMode = eDEFAULT_MODE,
double  pFramerate = 0.0 
) const

Get number of hours in time.

Parameters:
pCummul This parameter has no effect.
pTimeMode Time mode identifier.
pFramerate Custom framerate in case of pTimeMode = KTime::eCUSTOM
Returns:
Hours value.
kLongLong GetMinute ( bool  pCummul = false,
int  pTimeMode = eDEFAULT_MODE,
double  pFramerate = 0.0 
) const

Get number of minutes in time.

Parameters:
pCummul If true, get total number of minutes. If false, get number of minutes exceeding last full hour.
pTimeMode Time mode identifier.
pFramerate Custom framerate in case of pTimeMode = KTime::eCUSTOM
Returns:
Minutes value.
kLongLong GetSecond ( bool  pCummul = false,
int  pTimeMode = eDEFAULT_MODE,
double  pFramerate = 0.0 
) const

Get number of seconds in time.

Parameters:
pCummul If true, get total number of seconds. If false, get number of seconds exceeding last full minute.
pTimeMode Time mode identifier.
pFramerate Custom framerate in case of pTimeMode = KTime::eCUSTOM
Returns:
Seconds value.
kLongLong GetFrame ( bool  pCummul = false,
int  pTimeMode = eDEFAULT_MODE,
double  pFramerate = 0.0 
) const

Get number of frames in time.

Parameters:
pCummul If true, get total number of frames. If false, get number of frames exceeding last full second.
pTimeMode Time mode identifier.
pFramerate Custom framerate in case of pTimeMode = KTime::eCUSTOM
Returns:
Frames values.
Examples:
ViewScene/DrawScene.cxx.
kLongLong GetField ( bool  pCummul = false,
int  pTimeMode = eDEFAULT_MODE,
double  pFramerate = 0.0 
) const

Get number of fields in time.

Parameters:
pCummul If true, get total number of fields. If false, get number of fields exceeding last full frame.
pTimeMode Time mode identifier.
pFramerate Custom framerate in case of pTimeMode = KTime::eCUSTOM
Returns:
Fields value.
kLongLong GetResidual ( int  pTimeMode = eDEFAULT_MODE,
double  pFramerate = 0.0 
) const

Get residual time exceeding last full field.

Parameters:
pTimeMode Time mode identifier.
pFramerate Custom framerate in case of pTimeMode = KTime::eCUSTOM
Returns:
Residual value.
char* GetTimeString ( char *  pTimeString,
int  pInfo = 5,
int  pTimeMode = eDEFAULT_MODE,
int  pTimeFormat = eDEFAULT_PROTOCOL,
double  pFramerate = 0.0 
) const

Get time in a human readable format.

Parameters:
pTimeString An array large enough to contain a minimum of 19 characters.
pInfo The amount of information if time protocol is eSMPTE:
  • 1 means hours only
  • 2 means hours and minutes
  • 3 means hours, minutes and seconds
  • 4 means hours, minutes, seconds and frames
  • 5 means hours, minutes, seconds, frames and field
  • 6 means hours, minutes, seconds, frames, field and residual value
pTimeMode Requested time mode.
pTimeFormat Requested time protocol.
pFramerate Custom framerate in case of pTimeMode = KTime::eCUSTOM
Returns:
pTimeString parameter filled with a time value or set to a empty string if parameter pInfo is not valid.
Examples:
ImportScene/DisplayAnimation.cxx, and ImportScene/DisplayGlobalSettings.cxx.
void SetTimeString ( char *  pTime,
int  pTimeMode = eDEFAULT_MODE,
int  pTimeFormat = eDEFAULT_PROTOCOL,
double  pFramerate = 0.0 
)

Set time in a human readable format.

Parameters:
pTime An array of a maximum of 18 characters. If time protocol is eSMPTE, pTimeString must be formatted this way: "[hours:]minutes[:seconds[.frames[.fields]]]". Hours, minutes, seconds, frames and fields are parsed as integers and brackets indicate optional parts. If time protocol is eFRAME, pTimeString must be formatted this way: "frames". Frames is parsed as a 64 bits integer.
pTimeMode Given time mode.
pTimeFormat Given time protocol.
pFramerate Custom framerate in case of pTimeMode = KTime::eCUSTOM
bool operator== ( const KTime pTime ) const [inline]

Equality operator.

Parameters:
pTime The KTime to be compared.
Returns:
true if equal, false otherwise.

Definition at line 422 of file ktime.h.

{return mTime == pTime.mTime;}
bool operator!= ( const KTime pTime ) const [inline]

Inequality operator.

Parameters:
pTime The KTime to be compared.
Returns:
true if unequal, false otherwise.

Definition at line 428 of file ktime.h.

{return mTime != pTime.mTime;}
bool operator>= ( const KTime pTime ) const [inline]

Superior or equal to operator.

Parameters:
pTime The KTime to be compared.
Returns:
true if this KTime is superior or equal to the passed KTime, false otherwise.

Definition at line 434 of file ktime.h.

{return mTime >= pTime.mTime;}
bool operator<= ( const KTime pTime ) const [inline]

Inferior or equal to operator.

Parameters:
pTime The KTime to be compared.
Returns:
true if this KTime is inferior or equal to the passed KTime, false otherwise.

Definition at line 440 of file ktime.h.

{return mTime <= pTime.mTime;}
bool operator> ( const KTime pTime ) const [inline]

Superior to operator.

Parameters:
pTime The KTime to be compared.
Returns:
true if this KTime is superior to the passed KTime, false otherwise.

Definition at line 446 of file ktime.h.

{return mTime > pTime.mTime;}
bool operator< ( const KTime pTime ) const [inline]

Inferior to operator.

Parameters:
pTime The KTime to be compared.
Returns:
true if this KTime is inferior to the passed KTime, false otherwise.

Definition at line 452 of file ktime.h.

{return mTime < pTime.mTime;} 
KTime& operator= ( const KTime pTime ) [inline]

Assignment operator.

Parameters:
pTime The KTime to be assigned.

Definition at line 457 of file ktime.h.

{mTime = pTime.mTime; return *this;}
KTime& operator+= ( const KTime pTime ) [inline]

Addition operator.

Parameters:
pTime The KTime to be added.
Returns:
This KTime after addition.

Definition at line 463 of file ktime.h.

{mTime += pTime.mTime; return *this;}
KTime& operator-= ( const KTime pTime ) [inline]

Subtraction operator.

Parameters:
pTime The KTime to be subtracted.
Returns:
This KTime after subtraction.

Definition at line 469 of file ktime.h.

{mTime -= pTime.mTime; return *this;}
KTime operator+ ( const KTime pTime ) const

Addition operator.

Parameters:
pTime The KTime to be added.
Returns:
A temporary KTime after addition.
KTime operator- ( const KTime pTime ) const

Subtraction operator.

Parameters:
pTime The KTime to be subtracted.
Returns:
A temporary KTime after subtraction.
KTime operator* ( const int  Mult ) const

Multiplication operator.

Parameters:
Mult Multiply this KTime by int Mult.
Returns:
A temporary KTime after multiplication.
KTime operator/ ( const KTime pTime ) const

Division operator.

Parameters:
pTime Divide this KTime by pTime.
Returns:
A temporary KTime after division.
KTime operator* ( const KTime pTime ) const

Multiplication operator.

Parameters:
pTime Multiply this KTime by pTime.
Returns:
A temporary KTime after multiplication.
KTime& operator++ ( ) [inline]

Increment time of one unit of the internal format (prefix form).

Definition at line 502 of file ktime.h.

{mTime += 1; return (*this);}
const KTime operator++ ( int  ) [inline]

Increment time of one unit of the internal format (postfix form).

Definition at line 505 of file ktime.h.

{KTime lOld = *this; ++(*this); return lOld;}
KTime& operator-- ( ) [inline]

Decrement time of one unit of the internal format (prefix form).

Definition at line 508 of file ktime.h.

{mTime -= 1; return (*this);}
const KTime operator-- ( int  ) [inline]

Decrement time of one unit of the internal format (postfix form).

Definition at line 511 of file ktime.h.

{KTime lOld = *this; --(*this); return lOld;}
static KTime GetSystemTimer ( ) [static]

Friends And Related Function Documentation

KFBX_DLL KTime::ETimeMode KTime_GetGlobalTimeMode ( ) [friend]
KFBX_DLL HKTimeModeObject KTime_GetGlobalTimeModeObject ( ) [friend]
KFBX_DLL KTime::ETimeProtocol KTime_GetGlobalTimeFormat ( ) [friend]
KFBX_DLL void KTime_SetGlobalTimeMode ( KTime::ETimeMode  pTimeMode,
double  pFrameRate = 0.0 
) [friend]
KFBX_DLL void KTime_SetGlobalTimeFormat ( KTime::ETimeProtocol  pTimeFormat ) [friend]

The documentation for this class was generated from the following file:

KTime KTime KTime KTime KTime KTime KTime KTime KTime KTime
KTime KTime KTime KTime KTime KTime KTime KTime KTime KTime