Ignore:
Timestamp:
Mar 19, 2021, 9:15:03 AM (3 years ago)
Author:
stoecker
Message:

update to qwt verion 6.1.1 to fix build with newer Qt5

File:
1 edited

Legend:

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

    r8127 r9383  
    1414#include <limits.h>
    1515
    16 static inline double qwtMsecsForType( QwtDate::IntervalType type )
     16static inline double qwtMsecsForType( int type )
    1717{
    1818    static const double msecs[] =
     
    4444
    4545static double qwtIntervalWidth( const QDateTime &minDate,
    46     const QDateTime &maxDate, QwtDate::IntervalType intervalType ) 
     46    const QDateTime &maxDate, QwtDate::IntervalType intervalType )
    4747{
    4848    switch( intervalType )
     
    8080        case QwtDate::Month:
    8181        {
    82             const double years = 
     82            const double years =
    8383                double( maxDate.date().year() ) - minDate.date().year();
    8484
     
    9191        case QwtDate::Year:
    9292        {
    93             double years = 
     93            double years =
    9494                double( maxDate.date().year() ) - minDate.date().year();
    9595
     
    104104}
    105105
    106 static double qwtRoundedIntervalWidth( 
    107     const QDateTime &minDate, const QDateTime &maxDate, 
    108     QwtDate::IntervalType intervalType ) 
     106static double qwtRoundedIntervalWidth(
     107    const QDateTime &minDate, const QDateTime &maxDate,
     108    QwtDate::IntervalType intervalType )
    109109{
    110110    const QDateTime minD = QwtDate::floor( minDate, intervalType );
     
    131131}
    132132
    133 static int qwtStepSize( int intervalSize, int maxSteps, uint base ) 
     133static int qwtStepSize( int intervalSize, int maxSteps, uint base )
    134134{
    135135    if ( maxSteps <= 0 )
     
    162162}
    163163
    164 static int qwtDivideInterval( double intervalSize, int numSteps, 
     164static int qwtDivideInterval( double intervalSize, int numSteps,
    165165    const int limits[], size_t numLimits )
    166166{
     
    181181    if ( intervalType != QwtDate::Day )
    182182    {
    183         if ( ( intervalSize > numSteps ) && 
     183        if ( ( intervalSize > numSteps ) &&
    184184            ( intervalSize <= 2 * numSteps ) )
    185185        {
     
    196196        {
    197197            static int limits[] = { 1, 2, 5, 10, 15, 20, 30, 60 };
    198    
     198
    199199            stepSize = qwtDivideInterval( intervalSize, numSteps,
    200200                limits, sizeof( limits ) / sizeof( int ) );
     
    205205        {
    206206            static int limits[] = { 1, 2, 3, 4, 6, 12, 24 };
    207    
     207
    208208            stepSize = qwtDivideInterval( intervalSize, numSteps,
    209209                limits, sizeof( limits ) / sizeof( int ) );
     
    274274            if ( stepSize > maxMinSteps )
    275275            {
    276                 numSteps = qwtStepCount( stepSize, maxMinSteps, 
     276                numSteps = qwtStepCount( stepSize, maxMinSteps,
    277277                    limits, sizeof( limits ) / sizeof( int ) );
    278278
     
    280280            else
    281281            {
    282                 numSteps = qwtStepCount( stepSize * 60, maxMinSteps, 
     282                numSteps = qwtStepCount( stepSize * 60, maxMinSteps,
    283283                    limits, sizeof( limits ) / sizeof( int ) );
    284284            }
     
    359359                else
    360360                {
    361                     minStepSize = QwtScaleArithmetic::divideInterval( 
     361                    minStepSize = QwtScaleArithmetic::divideInterval(
    362362                        stepSizeInWeeks, maxMinSteps, 10 );
    363363                }
     
    401401                    minStepSize = double( stepSize ) / numSteps;
    402402            }
    403                
     403
    404404            break;
    405405        }
     
    445445}
    446446
    447 static QwtScaleDiv qwtDivideToSeconds( 
     447static QwtScaleDiv qwtDivideToSeconds(
    448448    const QDateTime &minDate, const QDateTime &maxDate,
    449449    double stepSize, int maxMinSteps,
    450     QwtDate::IntervalType intervalType ) 
     450    QwtDate::IntervalType intervalType )
    451451{
    452452    // calculate the min step size
    453453    double minStepSize = 0;
    454454
    455     if ( maxMinSteps > 1 ) 
    456     {
    457         minStepSize = qwtDivideMajorStep( stepSize, 
     455    if ( maxMinSteps > 1 )
     456    {
     457        minStepSize = qwtDivideMajorStep( stepSize,
    458458            maxMinSteps, intervalType );
    459459    }
     
    472472    const int secondsMajor = static_cast<int>( stepSize * s );
    473473    const double secondsMinor = minStepSize * s;
    474    
     474
    475475    // UTC excludes daylight savings. So from the difference
    476476    // of a date and its UTC counterpart we can find out
     
    484484    QList<double> minorTicks;
    485485
    486     for ( QDateTime dt = minDate; dt <= maxDate; 
     486    for ( QDateTime dt = minDate; dt <= maxDate;
    487487        dt = dt.addSecs( secondsMajor ) )
    488488    {
     
    501501                // we add some minor ticks for the DST hour,
    502502                // otherwise the ticks will be unaligned: 0, 2, 3, 5 ...
    503                 minorTicks += qwtDstTicks( 
     503                minorTicks += qwtDstTicks(
    504504                    dt, secondsMajor, qRound( secondsMinor ) );
    505505            }
     
    517517            for ( int i = 1; i < numMinorSteps; i++ )
    518518            {
    519                 const QDateTime mt = dt.addMSecs( 
     519                const QDateTime mt = dt.addMSecs(
    520520                    qRound64( i * secondsMinor * 1000 ) );
    521521
     
    529529                if ( minorTicks.isEmpty() || minorTicks.last() != minorValue )
    530530                {
    531                     const bool isMedium = ( numMinorSteps % 2 == 0 ) 
     531                    const bool isMedium = ( numMinorSteps % 2 == 0 )
    532532                        && ( i != 1 ) && ( i == numMinorSteps / 2 );
    533533
     
    553553}
    554554
    555 static QwtScaleDiv qwtDivideToMonths( 
     555static QwtScaleDiv qwtDivideToMonths(
    556556    QDateTime &minDate, const QDateTime &maxDate,
    557     double stepSize, int maxMinSteps ) 
    558 {
    559     // months are intervals with non 
    560     // equidistant ( in ms ) steps: we have to build the 
     557    double stepSize, int maxMinSteps )
     558{
     559    // months are intervals with non
     560    // equidistant ( in ms ) steps: we have to build the
    561561    // scale division manually
    562562
    563563    int minStepDays = 0;
    564     int minStepSize = 0.0; 
     564    int minStepSize = 0.0;
    565565
    566566    if ( maxMinSteps > 1 )
     
    579579        else
    580580        {
    581             minStepSize = qwtDivideMajorStep( 
     581            minStepSize = qwtDivideMajorStep(
    582582                stepSize, maxMinSteps, QwtDate::Month );
    583583        }
     
    588588    QList<double> minorTicks;
    589589
    590     for ( QDateTime dt = minDate; 
     590    for ( QDateTime dt = minDate;
    591591        dt <= maxDate; dt = dt.addMonths( stepSize ) )
    592592    {
     
    598598        if ( minStepDays > 0 )
    599599        {
    600             for ( int days = minStepDays; 
     600            for ( int days = minStepDays;
    601601                days < 30; days += minStepDays )
    602602            {
     
    637637}
    638638
    639 static QwtScaleDiv qwtDivideToYears( 
     639static QwtScaleDiv qwtDivideToYears(
    640640    const QDateTime &minDate, const QDateTime &maxDate,
    641     double stepSize, int maxMinSteps ) 
     641    double stepSize, int maxMinSteps )
    642642{
    643643    QList<double> majorTicks;
     
    649649    if ( maxMinSteps > 1 )
    650650    {
    651         minStepSize = qwtDivideMajorStep( 
     651        minStepSize = qwtDivideMajorStep(
    652652            stepSize, maxMinSteps, QwtDate::Year );
    653653    }
     
    702702            break;
    703703        }
    704     }   
     704    }
    705705
    706706    QwtScaleDiv scaleDiv;
     
    730730    QwtDate::Week0Type week0Type;
    731731    int maxWeeks;
    732 };     
     732};
    733733
    734734
     
    736736  \brief Constructor
    737737
    738   The engine is initialized to build scales for the 
     738  The engine is initialized to build scales for the
    739739  given time specification. It classifies intervals > 4 weeks
    740740  as >= Qt::Month. The first week of a year is defined like
     
    811811  \sa week0Type(), setMaxWeeks()
    812812  \note week0Type has no effect beside for intervals classified as
    813         QwtDate::Week. 
     813        QwtDate::Week.
    814814 */
    815815void QwtDateScaleEngine::setWeek0Type( QwtDate::Week0Type week0Type )
     
    819819
    820820/*!
    821   \return Setting how to identify the first week of a year. 
     821  \return Setting how to identify the first week of a year.
    822822  \sa setWeek0Type(), maxWeeks()
    823823 */
     
    835835  \param weeks Upper limit for the number of weeks
    836836
    837   \note In business charts a year is often devided
     837  \note In business charts a year is often divided
    838838        into weeks [1-52]
    839   \sa maxWeeks(), setWeek0Type() 
     839  \sa maxWeeks(), setWeek0Type()
    840840 */
    841841void QwtDateScaleEngine::setMaxWeeks( int weeks )
     
    863863  \return Interval classification
    864864 */
    865 QwtDate::IntervalType QwtDateScaleEngine::intervalType( 
    866     const QDateTime &minDate, const QDateTime &maxDate, 
     865QwtDate::IntervalType QwtDateScaleEngine::intervalType(
     866    const QDateTime &minDate, const QDateTime &maxDate,
    867867    int maxSteps ) const
    868868{
     
    910910  Align and divide an interval
    911911
    912   The algorithm aligns and divides the interval into steps. 
     912  The algorithm aligns and divides the interval into steps.
    913913
    914914  Datetime interval divisions are usually not equidistant and the
    915915  calculated stepSize can only be used as an approximation
    916   for the steps calculated by divideScale(). 
     916  for the steps calculated by divideScale().
    917917
    918918  \param maxNumSteps Max. number of steps
     
    951951            maxNumSteps = 1;
    952952
    953         const QwtDate::IntervalType intvType = 
     953        const QwtDate::IntervalType intvType =
    954954            intervalType( from, to, maxNumSteps );
    955955
     
    10151015    }
    10161016
    1017     const QwtDate::IntervalType intvType = 
     1017    const QwtDate::IntervalType intvType =
    10181018        intervalType( from, to, maxMajorSteps );
    10191019
     
    10311031        const QDateTime maxDate = QwtDate::ceil( to, intvType );
    10321032
    1033         scaleDiv = buildScaleDiv( minDate, maxDate, 
     1033        scaleDiv = buildScaleDiv( minDate, maxDate,
    10341034            maxMajorSteps, maxMinorSteps, intvType );
    10351035
     
    10461046}
    10471047
    1048 QwtScaleDiv QwtDateScaleEngine::buildScaleDiv( 
     1048QwtScaleDiv QwtDateScaleEngine::buildScaleDiv(
    10491049    const QDateTime &minDate, const QDateTime &maxDate,
    10501050    int maxMajorSteps, int maxMinorSteps,
     
    10521052{
    10531053    // calculate the step size
    1054     const double stepSize = qwtDivideScale( 
    1055         qwtIntervalWidth( minDate, maxDate, intervalType ), 
     1054    const double stepSize = qwtDivideScale(
     1055        qwtIntervalWidth( minDate, maxDate, intervalType ),
    10561056        maxMajorSteps, intervalType );
    10571057
     
    10601060    if ( !dt0.isValid() )
    10611061    {
    1062         // the floored date is out of the range of a 
     1062        // the floored date is out of the range of a
    10631063        // QDateTime - we ceil instead.
    10641064        dt0 = alignDate( minDate, stepSize, intervalType, true );
     
    10691069    if ( intervalType <= QwtDate::Week )
    10701070    {
    1071         scaleDiv = qwtDivideToSeconds( dt0, maxDate, 
     1071        scaleDiv = qwtDivideToSeconds( dt0, maxDate,
    10721072            stepSize, maxMinorSteps, intervalType );
    10731073    }
     
    10941094
    10951095  For Qt::Day alignments there is no "natural day 0" -
    1096   instead the first day of the year is used to avoid jumping 
     1096  instead the first day of the year is used to avoid jumping
    10971097  major ticks positions when panning a scale. For other alignments
    10981098  ( f.e according to the first day of the month ) alignDate()
     
    11061106  \return Aligned date/time value
    11071107 */
    1108 QDateTime QwtDateScaleEngine::alignDate( 
    1109     const QDateTime &dateTime, double stepSize, 
     1108QDateTime QwtDateScaleEngine::alignDate(
     1109    const QDateTime &dateTime, double stepSize,
    11101110    QwtDate::IntervalType intervalType, bool up ) const
    11111111{
     
    11231123        case QwtDate::Millisecond:
    11241124        {
    1125             const int ms = qwtAlignValue( 
     1125            const int ms = qwtAlignValue(
    11261126                dt.time().msec(), stepSize, up ) ;
    11271127
     
    12931293    if ( !dt.isValid() )
    12941294    {
    1295         const QDate date = ( value <= 0.0 ) 
     1295        const QDate date = ( value <= 0.0 )
    12961296            ? QwtDate::minDate() : QwtDate::maxDate();
    12971297
Note: See TracChangeset for help on using the changeset viewer.