Changeset 8127 in ntrip for trunk/BNC/qwt/qwt_system_clock.cpp


Ignore:
Timestamp:
May 10, 2017, 3:20:54 PM (7 years ago)
Author:
stoecker
Message:

update qwt and qwtpolar, many QT5 fixes (unfinished)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/BNC/qwt/qwt_system_clock.cpp

    r4271 r8127  
    99
    1010#include "qwt_system_clock.h"
     11
     12#if QT_VERSION >= 0x040800
     13#define USE_ELAPSED_TIMER 1
     14#endif
     15
     16#if USE_ELAPSED_TIMER
     17
     18#include <qelapsedtimer.h>
     19
     20class QwtSystemClock::PrivateData
     21{
     22public:
     23    QElapsedTimer timer;
     24};
     25
     26QwtSystemClock::QwtSystemClock()
     27{
     28    d_data = new PrivateData();
     29}
     30
     31QwtSystemClock::~QwtSystemClock()
     32{
     33    delete d_data;
     34}
     35   
     36bool QwtSystemClock::isNull() const
     37{
     38    return d_data->timer.isValid();
     39}
     40       
     41void QwtSystemClock::start()
     42{
     43    d_data->timer.start();
     44}
     45
     46double QwtSystemClock::restart()
     47{
     48    const qint64 nsecs = d_data->timer.restart();
     49    return nsecs / 1e6;
     50}
     51
     52double QwtSystemClock::elapsed() const
     53{
     54    const qint64 nsecs = d_data->timer.nsecsElapsed();
     55    return nsecs / 1e6;
     56}
     57   
     58#else // !USE_ELAPSED_TIMER
     59
    1160#include <qdatetime.h>
    1261
     
    111160        kern_return_t err = mach_timebase_info( &info );
    112161
    113         //Convert the timebase into ms
     162        // convert the timebase into ms
    114163        if ( err == 0  )
    115164            conversion = 1e-6 * ( double ) info.numer / ( double ) info.denom;
     
    308357
    309358/*!
    310   The start time to the current time and
    311   return the time, that is elapsed since the
    312   previous start time.
     359  Set the start time to the current time
     360  \return Time, that is elapsed since the previous start time.
    313361*/
    314362double QwtSystemClock::restart()
     
    346394}
    347395
    348 /*!
    349   \return Accuracy of the system clock in milliseconds.
    350 */
    351 double QwtSystemClock::precision()
    352 {
    353     static double prec = 0.0;
    354     if ( prec <= 0.0 )
    355     {
    356 #if defined(QWT_HIGH_RESOLUTION_CLOCK)
    357         prec = QwtHighResolutionClock::precision();
    358 #endif
    359         if ( prec <= 0.0 )
    360             prec = 1.0; // QTime offers 1 ms
    361     }
    362 
    363     return prec;
    364 }
     396#endif
Note: See TracChangeset for help on using the changeset viewer.