Changeset 8127 in ntrip for trunk/BNC/qwt/qwt_scale_widget.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_scale_widget.cpp

    r4271 r8127  
    1515#include "qwt_scale_div.h"
    1616#include "qwt_text.h"
     17#include "qwt_scale_engine.h"
    1718#include <qpainter.h>
    1819#include <qevent.h>
     
    107108    d_data->scaleDraw->setLength( 10 );
    108109
     110    d_data->scaleDraw->setScaleDiv(
     111        QwtLinearScaleEngine().divideScale( 0.0, 100.0, 10, 5 ) );
     112
    109113    d_data->colorBar.colorMap = new QwtLinearColorMap();
    110114    d_data->colorBar.isEnabled = false;
     
    202206void QwtScaleWidget::setAlignment( QwtScaleDraw::Alignment alignment )
    203207{
     208    if ( d_data->scaleDraw )
     209        d_data->scaleDraw->setAlignment( alignment );
     210
    204211    if ( !testAttribute( Qt::WA_WState_OwnSizePolicy ) )
    205212    {
     
    208215        if ( d_data->scaleDraw->orientation() == Qt::Vertical )
    209216            policy.transpose();
     217
    210218        setSizePolicy( policy );
    211219
     
    213221    }
    214222
    215     if ( d_data->scaleDraw )
    216         d_data->scaleDraw->setAlignment( alignment );
    217223    layoutScale();
    218224}
     
    305311/*!
    306312  Set a scale draw
    307   sd has to be created with new and will be deleted in
     313
     314  scaleDraw has to be created with new and will be deleted in
    308315  ~QwtScaleWidget() or the next call of setScaleDraw().
    309 
    310   \param sd ScaleDraw object
     316  scaleDraw will be initialized with the attributes of
     317  the previous scaleDraw object.
     318
     319  \param scaleDraw ScaleDraw object
    311320  \sa scaleDraw()
    312321*/
    313 void QwtScaleWidget::setScaleDraw( QwtScaleDraw *sd )
    314 {
    315     if ( sd == NULL || sd == d_data->scaleDraw )
     322void QwtScaleWidget::setScaleDraw( QwtScaleDraw *scaleDraw )
     323{
     324    if ( ( scaleDraw == NULL ) || ( scaleDraw == d_data->scaleDraw ) )
    316325        return;
    317326
    318     if ( d_data->scaleDraw )
    319         sd->setAlignment( d_data->scaleDraw->alignment() );
     327    const QwtScaleDraw* sd = d_data->scaleDraw;
     328    if ( sd )
     329    {
     330        scaleDraw->setAlignment( sd->alignment() );
     331        scaleDraw->setScaleDiv( sd->scaleDiv() );
     332
     333        QwtTransform *transform = NULL;
     334        if ( sd->scaleMap().transformation() )
     335            transform = sd->scaleMap().transformation()->copy();
     336
     337        scaleDraw->setTransformation( transform );
     338    }
    320339
    321340    delete d_data->scaleDraw;
    322     d_data->scaleDraw = sd;
     341    d_data->scaleDraw = scaleDraw;
    323342
    324343    layoutScale();
     
    326345
    327346/*!
    328     scaleDraw of this scale
     347    \return scaleDraw of this scale
    329348    \sa setScaleDraw(), QwtScaleDraw::setScaleDraw()
    330349*/
     
    335354
    336355/*!
    337     scaleDraw of this scale
     356    \return scaleDraw of this scale
    338357    \sa QwtScaleDraw::setScaleDraw()
    339358*/
     
    436455
    437456  \param rect Bounding rectangle for all components of the scale
    438   \return Rectabgle for the color bar
     457  \return Rectangle for the color bar
    439458*/
    440459QRectF QwtScaleWidget::colorBarRect( const QRectF& rect ) const
     
    490509
    491510/*!
    492   Event handler for resize event
     511  Event handler for resize events
    493512  \param event Resize event
    494513*/
     
    501520/*!
    502521  Recalculate the scale's geometry and layout based on
    503   the current rect and fonts.
     522  the current geometry and fonts.
    504523
    505524  \param update_geometry Notify the layout system and call update
     
    646665    QwtText title = d_data->title;
    647666    title.setRenderFlags( flags );
    648     title.draw( painter, QRect( 0, 0, r.width(), r.height() ) );
     667    title.draw( painter, QRectF( 0.0, 0.0, r.width(), r.height() ) );
    649668
    650669    painter->restore();
     
    713732int QwtScaleWidget::titleHeightForWidth( int width ) const
    714733{
    715     return d_data->title.heightForWidth( width, font() );
     734    return qCeil( d_data->title.heightForWidth( width, font() ) );
    716735}
    717736
     
    749768  is returned.
    750769
     770  \param start Return parameter for the border width at
     771               the beginning of the scale
     772  \param end Return parameter for the border width at the
     773             end of the scale
     774
    751775  \warning
    752776  <ul> <li>The minimum border distance depends on the font.</ul>
     
    784808  the widget borders.
    785809
     810  \param start Return parameter for the border width at
     811               the beginning of the scale
     812  \param end Return parameter for the border width at the
     813             end of the scale
     814
    786815  \sa setMinBorderDist(), getBorderDistHint()
    787816*/
     
    797826  The scale division determines where to set the tick marks.
    798827
    799   \param transformation Transformation, needed to translate between
    800                         scale and pixal values
    801828  \param scaleDiv Scale Division
    802829  \sa For more information about scale divisions, see QwtScaleDiv.
    803830*/
    804 void QwtScaleWidget::setScaleDiv(
    805     QwtScaleTransformation *transformation,
    806     const QwtScaleDiv &scaleDiv )
     831void QwtScaleWidget::setScaleDiv( const QwtScaleDiv &scaleDiv )
    807832{
    808833    QwtScaleDraw *sd = d_data->scaleDraw;
    809     if ( sd->scaleDiv() != scaleDiv ||
    810         sd->scaleMap().transformation()->type() != transformation->type() )
    811     {
    812         sd->setTransformation( transformation );
     834    if ( sd->scaleDiv() != scaleDiv )
     835    {
    813836        sd->setScaleDiv( scaleDiv );
    814837        layoutScale();
     
    816839        Q_EMIT scaleDivChanged();
    817840    }
    818     else
    819     {
    820         /*
    821           The transformation doesn't anything different as the
    822           previous one. So we better throw it silently away instead of
    823           initiating heavy updates
    824          */
    825 
    826         delete transformation;
    827     }
     841}
     842
     843/*!
     844  Set the transformation
     845
     846  \param transformation Transformation
     847  \sa QwtAbstractScaleDraw::scaleDraw(), QwtScaleMap
     848 */
     849void QwtScaleWidget::setTransformation( QwtTransform *transformation )
     850{
     851    d_data->scaleDraw->setTransformation( transformation );
     852    layoutScale();
    828853}
    829854
Note: See TracChangeset for help on using the changeset viewer.