123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872 |
- /* -*- mode: C++ ; c-file-style: "stroustrup" -*- *****************************
- * Qwt Widget Library
- * Copyright (C) 1997 Josef Wilgen
- * Copyright (C) 2002 Uwe Rathmann
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the Qwt License, Version 1.0
- *****************************************************************************/
- #include "qwt_thermo.h"
- #include "qwt_math.h"
- #include "qwt_scale_engine.h"
- #include "qwt_scale_draw.h"
- #include "qwt_scale_map.h"
- #include <qpainter.h>
- #include <qevent.h>
- #include <qstyle.h>
- #include <qpixmap.h>
- #include <qdrawutil.h>
- #include <qalgorithms.h>
- #include <qmath.h>
- class QwtThermo::PrivateData
- {
- public:
- PrivateData():
- fillBrush( Qt::black ),
- alarmBrush( Qt::white ),
- orientation( Qt::Vertical ),
- scalePos( QwtThermo::LeftScale ),
- borderWidth( 2 ),
- scaleDist( 3 ),
- thermoWidth( 10 ),
- minValue( 0.0 ),
- maxValue( 1.0 ),
- value( 0.0 ),
- alarmLevel( 0.0 ),
- alarmEnabled( false )
- {
- map.setScaleInterval( minValue, maxValue );
- }
- QwtScaleMap map;
- QRect thermoRect;
- QBrush fillBrush;
- QBrush alarmBrush;
- Qt::Orientation orientation;
- ScalePos scalePos;
- int borderWidth;
- int scaleDist;
- int thermoWidth;
- double minValue;
- double maxValue;
- double value;
- double alarmLevel;
- bool alarmEnabled;
- };
- /*!
- Constructor
- \param parent Parent widget
- */
- QwtThermo::QwtThermo( QWidget *parent ):
- QWidget( parent )
- {
- initThermo();
- }
- void QwtThermo::initThermo()
- {
- d_data = new PrivateData;
- setRange( d_data->minValue, d_data->maxValue, false );
- QSizePolicy policy( QSizePolicy::MinimumExpanding, QSizePolicy::Fixed );
- if ( d_data->orientation == Qt::Vertical )
- policy.transpose();
- setSizePolicy( policy );
- setAttribute( Qt::WA_WState_OwnSizePolicy, false );
- }
- //! Destructor
- QwtThermo::~QwtThermo()
- {
- delete d_data;
- }
- /*!
- Set the maximum value.
- \param max Maximum value
- \sa maxValue(), setMinValue()
- */
- void QwtThermo::setMaxValue( double max )
- {
- setRange( d_data->minValue, max );
- }
- //! Return the maximum value.
- double QwtThermo::maxValue() const
- {
- return d_data->maxValue;
- }
- /*!
- Set the minimum value.
- \param min Minimum value
- \sa minValue(), setMaxValue()
- */
- void QwtThermo::setMinValue( double min )
- {
- setRange( min, d_data->maxValue );
- }
- //! Return the minimum value.
- double QwtThermo::minValue() const
- {
- return d_data->minValue;
- }
- /*!
- Set the current value.
- \param value New Value
- \sa value()
- */
- void QwtThermo::setValue( double value )
- {
- if ( d_data->value != value )
- {
- d_data->value = value;
- update();
- }
- }
- //! Return the value.
- double QwtThermo::value() const
- {
- return d_data->value;
- }
- /*!
- \brief Set a scale draw
- For changing the labels of the scales, it
- is necessary to derive from QwtScaleDraw and
- overload QwtScaleDraw::label().
- \param scaleDraw ScaleDraw object, that has to be created with
- new and will be deleted in ~QwtThermo or the next
- call of setScaleDraw().
- */
- void QwtThermo::setScaleDraw( QwtScaleDraw *scaleDraw )
- {
- setAbstractScaleDraw( scaleDraw );
- }
- /*!
- \return the scale draw of the thermo
- \sa setScaleDraw()
- */
- const QwtScaleDraw *QwtThermo::scaleDraw() const
- {
- return static_cast<const QwtScaleDraw *>( abstractScaleDraw() );
- }
- /*!
- \return the scale draw of the thermo
- \sa setScaleDraw()
- */
- QwtScaleDraw *QwtThermo::scaleDraw()
- {
- return static_cast<QwtScaleDraw *>( abstractScaleDraw() );
- }
- /*!
- Qt paint event.
- event Paint event
- */
- void QwtThermo::paintEvent( QPaintEvent *event )
- {
- // Use double-buffering
- const QRect &ur = event->rect();
- if ( ur.isValid() )
- {
- QPainter painter( this );
- draw( &painter, ur );
- }
- }
- /*!
- Draw the whole QwtThermo.
- \param painter Painter
- \param rect Update rectangle
- */
- void QwtThermo::draw( QPainter *painter, const QRect& rect )
- {
- if ( !d_data->thermoRect.contains( rect ) )
- {
- if ( d_data->scalePos != NoScale )
- scaleDraw()->draw( painter, palette() );
- qDrawShadePanel( painter,
- d_data->thermoRect.x() - d_data->borderWidth,
- d_data->thermoRect.y() - d_data->borderWidth,
- d_data->thermoRect.width() + 2 * d_data->borderWidth,
- d_data->thermoRect.height() + 2 * d_data->borderWidth,
- palette(), true, d_data->borderWidth, 0 );
- }
- drawThermo( painter );
- }
- //! Qt resize event handler
- void QwtThermo::resizeEvent( QResizeEvent * )
- {
- layoutThermo( false );
- }
- /*!
- Recalculate the QwtThermo geometry and layout based on
- the QwtThermo::rect() and the fonts.
- \param update_geometry notify the layout system and call update
- to redraw the scale
- */
- void QwtThermo::layoutThermo( bool update_geometry )
- {
- QRect r = rect();
- int mbd = 0;
- if ( d_data->scalePos != NoScale )
- {
- int d1, d2;
- scaleDraw()->getBorderDistHint( font(), d1, d2 );
- mbd = qMax( d1, d2 );
- }
- if ( d_data->orientation == Qt::Horizontal )
- {
- switch ( d_data->scalePos )
- {
- case TopScale:
- {
- d_data->thermoRect.setRect(
- r.x() + mbd + d_data->borderWidth,
- r.y() + r.height()
- - d_data->thermoWidth - 2*d_data->borderWidth,
- r.width() - 2*( d_data->borderWidth + mbd ),
- d_data->thermoWidth );
- scaleDraw()->setAlignment( QwtScaleDraw::TopScale );
- scaleDraw()->move( d_data->thermoRect.x(),
- d_data->thermoRect.y() - d_data->borderWidth
- - d_data->scaleDist );
- scaleDraw()->setLength( d_data->thermoRect.width() );
- break;
- }
- case BottomScale:
- case NoScale: // like Bottom but without scale
- default: // inconsistent orientation and scale position
- // Mapping between values and pixels requires
- // initialization of the scale geometry
- {
- d_data->thermoRect.setRect(
- r.x() + mbd + d_data->borderWidth,
- r.y() + d_data->borderWidth,
- r.width() - 2*( d_data->borderWidth + mbd ),
- d_data->thermoWidth );
- scaleDraw()->setAlignment( QwtScaleDraw::BottomScale );
- scaleDraw()->move(
- d_data->thermoRect.x(),
- d_data->thermoRect.y() + d_data->thermoRect.height()
- + d_data->borderWidth + d_data->scaleDist );
- scaleDraw()->setLength( d_data->thermoRect.width() );
- break;
- }
- }
- d_data->map.setPaintInterval( d_data->thermoRect.x(),
- d_data->thermoRect.x() + d_data->thermoRect.width() - 1 );
- }
- else // Qt::Vertical
- {
- switch ( d_data->scalePos )
- {
- case RightScale:
- {
- d_data->thermoRect.setRect(
- r.x() + d_data->borderWidth,
- r.y() + mbd + d_data->borderWidth,
- d_data->thermoWidth,
- r.height() - 2*( d_data->borderWidth + mbd ) );
- scaleDraw()->setAlignment( QwtScaleDraw::RightScale );
- scaleDraw()->move(
- d_data->thermoRect.x() + d_data->thermoRect.width()
- + d_data->borderWidth + d_data->scaleDist,
- d_data->thermoRect.y() );
- scaleDraw()->setLength( d_data->thermoRect.height() );
- break;
- }
- case LeftScale:
- case NoScale: // like Left but without scale
- default: // inconsistent orientation and scale position
- // Mapping between values and pixels requires
- // initialization of the scale geometry
- {
- d_data->thermoRect.setRect(
- r.x() + r.width() - 2*d_data->borderWidth - d_data->thermoWidth,
- r.y() + mbd + d_data->borderWidth,
- d_data->thermoWidth,
- r.height() - 2*( d_data->borderWidth + mbd ) );
- scaleDraw()->setAlignment( QwtScaleDraw::LeftScale );
- scaleDraw()->move(
- d_data->thermoRect.x() - d_data->scaleDist
- - d_data->borderWidth,
- d_data->thermoRect.y() );
- scaleDraw()->setLength( d_data->thermoRect.height() );
- break;
- }
- }
- d_data->map.setPaintInterval(
- d_data->thermoRect.y() + d_data->thermoRect.height() - 1,
- d_data->thermoRect.y() );
- }
- if ( update_geometry )
- {
- updateGeometry();
- update();
- }
- }
- /*!
- \brief Set the thermometer orientation and the scale position.
- The scale position NoScale disables the scale.
- \param o orientation. Possible values are Qt::Horizontal and Qt::Vertical.
- The default value is Qt::Vertical.
- \param s Position of the scale.
- The default value is NoScale.
- A valid combination of scale position and orientation is enforced:
- - a horizontal thermometer can have the scale positions TopScale,
- BottomScale or NoScale;
- - a vertical thermometer can have the scale positions LeftScale,
- RightScale or NoScale;
- - an invalid scale position will default to NoScale.
- \sa setScalePosition()
- */
- void QwtThermo::setOrientation( Qt::Orientation o, ScalePos s )
- {
- if ( o == d_data->orientation && s == d_data->scalePos )
- return;
- switch ( o )
- {
- case Qt::Horizontal:
- {
- if ( ( s == NoScale ) || ( s == BottomScale ) || ( s == TopScale ) )
- d_data->scalePos = s;
- else
- d_data->scalePos = NoScale;
- break;
- }
- case Qt::Vertical:
- {
- if ( ( s == NoScale ) || ( s == LeftScale ) || ( s == RightScale ) )
- d_data->scalePos = s;
- else
- d_data->scalePos = NoScale;
- break;
- }
- }
- if ( o != d_data->orientation )
- {
- if ( !testAttribute( Qt::WA_WState_OwnSizePolicy ) )
- {
- QSizePolicy sp = sizePolicy();
- sp.transpose();
- setSizePolicy( sp );
- setAttribute( Qt::WA_WState_OwnSizePolicy, false );
- }
- }
- d_data->orientation = o;
- layoutThermo();
- }
- /*!
- \brief Change the scale position (and thermometer orientation).
- \param scalePos Position of the scale.
- A valid combination of scale position and orientation is enforced:
- - if the new scale position is LeftScale or RightScale, the
- scale orientation will become Qt::Vertical;
- - if the new scale position is BottomScale or TopScale, the scale
- orientation will become Qt::Horizontal;
- - if the new scale position is NoScale, the scale orientation will not change.
- \sa setOrientation(), scalePosition()
- */
- void QwtThermo::setScalePosition( ScalePos scalePos )
- {
- if ( ( scalePos == BottomScale ) || ( scalePos == TopScale ) )
- setOrientation( Qt::Horizontal, scalePos );
- else if ( ( scalePos == LeftScale ) || ( scalePos == RightScale ) )
- setOrientation( Qt::Vertical, scalePos );
- else
- setOrientation( d_data->orientation, NoScale );
- }
- /*!
- Return the scale position.
- \sa setScalePosition()
- */
- QwtThermo::ScalePos QwtThermo::scalePosition() const
- {
- return d_data->scalePos;
- }
- //! Notify a font change.
- void QwtThermo::fontChange( const QFont &f )
- {
- QWidget::fontChange( f );
- layoutThermo();
- }
- //! Notify a scale change.
- void QwtThermo::scaleChange()
- {
- update();
- layoutThermo();
- }
- /*!
- Redraw the liquid in thermometer pipe.
- \param painter Painter
- */
- void QwtThermo::drawThermo( QPainter *painter )
- {
- int alarm = 0, taval = 0;
- QRect fRect;
- QRect aRect;
- QRect bRect;
- int inverted = ( d_data->maxValue < d_data->minValue );
- //
- // Determine if value exceeds alarm threshold.
- // Note: The alarm value is allowed to lie
- // outside the interval (minValue, maxValue).
- //
- if ( d_data->alarmEnabled )
- {
- if ( inverted )
- {
- alarm = ( ( d_data->alarmLevel >= d_data->maxValue )
- && ( d_data->alarmLevel <= d_data->minValue )
- && ( d_data->value >= d_data->alarmLevel ) );
- }
- else
- {
- alarm = ( ( d_data->alarmLevel >= d_data->minValue )
- && ( d_data->alarmLevel <= d_data->maxValue )
- && ( d_data->value >= d_data->alarmLevel ) );
- }
- }
- //
- // transform values
- //
- int tval = transform( d_data->value );
- if ( alarm )
- taval = transform( d_data->alarmLevel );
- //
- // calculate recangles
- //
- if ( d_data->orientation == Qt::Horizontal )
- {
- if ( inverted )
- {
- bRect.setRect( d_data->thermoRect.x(), d_data->thermoRect.y(),
- tval - d_data->thermoRect.x(),
- d_data->thermoRect.height() );
- if ( alarm )
- {
- aRect.setRect( tval, d_data->thermoRect.y(),
- taval - tval + 1,
- d_data->thermoRect.height() );
- fRect.setRect( taval + 1, d_data->thermoRect.y(),
- d_data->thermoRect.x() + d_data->thermoRect.width() - ( taval + 1 ),
- d_data->thermoRect.height() );
- }
- else
- {
- fRect.setRect( tval, d_data->thermoRect.y(),
- d_data->thermoRect.x() + d_data->thermoRect.width() - tval,
- d_data->thermoRect.height() );
- }
- }
- else
- {
- bRect.setRect( tval + 1, d_data->thermoRect.y(),
- d_data->thermoRect.width() - ( tval + 1 - d_data->thermoRect.x() ),
- d_data->thermoRect.height() );
- if ( alarm )
- {
- aRect.setRect( taval, d_data->thermoRect.y(),
- tval - taval + 1,
- d_data->thermoRect.height() );
- fRect.setRect( d_data->thermoRect.x(), d_data->thermoRect.y(),
- taval - d_data->thermoRect.x(),
- d_data->thermoRect.height() );
- }
- else
- {
- fRect.setRect( d_data->thermoRect.x(), d_data->thermoRect.y(),
- tval - d_data->thermoRect.x() + 1,
- d_data->thermoRect.height() );
- }
- }
- }
- else // Qt::Vertical
- {
- if ( tval < d_data->thermoRect.y() )
- tval = d_data->thermoRect.y();
- else
- {
- if ( tval > d_data->thermoRect.y() + d_data->thermoRect.height() )
- tval = d_data->thermoRect.y() + d_data->thermoRect.height();
- }
- if ( inverted )
- {
- bRect.setRect( d_data->thermoRect.x(), tval + 1,
- d_data->thermoRect.width(),
- d_data->thermoRect.height() - ( tval + 1 - d_data->thermoRect.y() ) );
- if ( alarm )
- {
- aRect.setRect( d_data->thermoRect.x(), taval,
- d_data->thermoRect.width(),
- tval - taval + 1 );
- fRect.setRect( d_data->thermoRect.x(), d_data->thermoRect.y(),
- d_data->thermoRect.width(),
- taval - d_data->thermoRect.y() );
- }
- else
- {
- fRect.setRect( d_data->thermoRect.x(), d_data->thermoRect.y(),
- d_data->thermoRect.width(),
- tval - d_data->thermoRect.y() + 1 );
- }
- }
- else
- {
- bRect.setRect( d_data->thermoRect.x(), d_data->thermoRect.y(),
- d_data->thermoRect.width(),
- tval - d_data->thermoRect.y() );
- if ( alarm )
- {
- aRect.setRect( d_data->thermoRect.x(), tval,
- d_data->thermoRect.width(),
- taval - tval + 1 );
- fRect.setRect( d_data->thermoRect.x(), taval + 1,
- d_data->thermoRect.width(),
- d_data->thermoRect.y() + d_data->thermoRect.height() - ( taval + 1 ) );
- }
- else
- {
- fRect.setRect( d_data->thermoRect.x(), tval,
- d_data->thermoRect.width(),
- d_data->thermoRect.y() + d_data->thermoRect.height() - tval );
- }
- }
- }
- //
- // paint thermometer
- //
- const QColor bgColor = palette().color( QPalette::Window );
- painter->fillRect( bRect, bgColor );
- if ( alarm )
- painter->fillRect( aRect, d_data->alarmBrush );
- painter->fillRect( fRect, d_data->fillBrush );
- }
- /*!
- Set the border width of the pipe.
- \param width Border width
- \sa borderWidth()
- */
- void QwtThermo::setBorderWidth( int width )
- {
- if ( ( width >= 0 ) && ( width < ( qMin( d_data->thermoRect.width(),
- d_data->thermoRect.height() ) + d_data->borderWidth ) / 2 - 1 ) )
- {
- d_data->borderWidth = width;
- layoutThermo();
- }
- }
- /*!
- Return the border width of the thermometer pipe.
- \sa setBorderWidth()
- */
- int QwtThermo::borderWidth() const
- {
- return d_data->borderWidth;
- }
- /*!
- \brief Set the range
- \param vmin value corresponding lower or left end of the thermometer
- \param vmax value corresponding to the upper or right end of the thermometer
- \param logarithmic logarithmic mapping, true or false
- */
- void QwtThermo::setRange( double vmin, double vmax, bool logarithmic )
- {
- d_data->minValue = vmin;
- d_data->maxValue = vmax;
- if ( logarithmic )
- setScaleEngine( new QwtLog10ScaleEngine );
- else
- setScaleEngine( new QwtLinearScaleEngine );
- /*
- There are two different maps, one for the scale, the other
- for the values. This is confusing and will be changed
- in the future. TODO ...
- */
- d_data->map.setTransformation( scaleEngine()->transformation() );
- d_data->map.setScaleInterval( d_data->minValue, d_data->maxValue );
- if ( autoScale() )
- rescale( d_data->minValue, d_data->maxValue );
- layoutThermo();
- }
- /*!
- \brief Change the brush of the liquid.
- \param brush New brush. The default brush is solid black.
- \sa fillBrush()
- */
- void QwtThermo::setFillBrush( const QBrush& brush )
- {
- d_data->fillBrush = brush;
- update();
- }
- /*!
- Return the liquid brush.
- \sa setFillBrush()
- */
- const QBrush& QwtThermo::fillBrush() const
- {
- return d_data->fillBrush;
- }
- /*!
- \brief Change the color of the liquid.
- \param c New color. The default color is black.
- \sa fillColor()
- */
- void QwtThermo::setFillColor( const QColor &c )
- {
- d_data->fillBrush.setColor( c );
- update();
- }
- /*!
- Return the liquid color.
- \sa setFillColor()
- */
- const QColor &QwtThermo::fillColor() const
- {
- return d_data->fillBrush.color();
- }
- /*!
- \brief Specify the liquid brush above the alarm threshold
- \param brush New brush. The default is solid white.
- \sa alarmBrush()
- */
- void QwtThermo::setAlarmBrush( const QBrush& brush )
- {
- d_data->alarmBrush = brush;
- update();
- }
- /*!
- Return the liquid brush above the alarm threshold.
- \sa setAlarmBrush()
- */
- const QBrush& QwtThermo::alarmBrush() const
- {
- return d_data->alarmBrush;
- }
- /*!
- \brief Specify the liquid color above the alarm threshold
- \param c New color. The default is white.
- */
- void QwtThermo::setAlarmColor( const QColor &c )
- {
- d_data->alarmBrush.setColor( c );
- update();
- }
- //! Return the liquid color above the alarm threshold.
- const QColor &QwtThermo::alarmColor() const
- {
- return d_data->alarmBrush.color();
- }
- /*!
- Specify the alarm threshold.
- \param level Alarm threshold
- \sa alarmLevel()
- */
- void QwtThermo::setAlarmLevel( double level )
- {
- d_data->alarmLevel = level;
- d_data->alarmEnabled = 1;
- update();
- }
- /*!
- Return the alarm threshold.
- \sa setAlarmLevel()
- */
- double QwtThermo::alarmLevel() const
- {
- return d_data->alarmLevel;
- }
- /*!
- Change the width of the pipe.
- \param width Width of the pipe
- \sa pipeWidth()
- */
- void QwtThermo::setPipeWidth( int width )
- {
- if ( width > 0 )
- {
- d_data->thermoWidth = width;
- layoutThermo();
- }
- }
- /*!
- Return the width of the pipe.
- \sa setPipeWidth()
- */
- int QwtThermo::pipeWidth() const
- {
- return d_data->thermoWidth;
- }
- /*!
- \brief Specify the distance between the pipe's endpoints
- and the widget's border
- The margin is used to leave some space for the scale
- labels. If a large font is used, it is advisable to
- adjust the margins.
- \param m New Margin. The default values are 10 for
- horizontal orientation and 20 for vertical
- orientation.
- \warning The margin has no effect if the scale is disabled.
- \warning This function is a NOOP because margins are determined
- automatically.
- */
- void QwtThermo::setMargin( int )
- {
- }
- /*!
- \brief Enable or disable the alarm threshold
- \param tf true (disabled) or false (enabled)
- */
- void QwtThermo::setAlarmEnabled( bool tf )
- {
- d_data->alarmEnabled = tf;
- update();
- }
- //! Return if the alarm threshold is enabled or disabled.
- bool QwtThermo::alarmEnabled() const
- {
- return d_data->alarmEnabled;
- }
- /*!
- \return the minimum size hint
- \sa minimumSizeHint()
- */
- QSize QwtThermo::sizeHint() const
- {
- return minimumSizeHint();
- }
- /*!
- \brief Return a minimum size hint
- \warning The return value depends on the font and the scale.
- \sa sizeHint()
- */
- QSize QwtThermo::minimumSizeHint() const
- {
- int w = 0, h = 0;
- if ( d_data->scalePos != NoScale )
- {
- const int sdExtent = qCeil( scaleDraw()->extent( font() ) );
- const int sdLength = scaleDraw()->minLength( font() );
- w = sdLength;
- h = d_data->thermoWidth + sdExtent +
- d_data->borderWidth + d_data->scaleDist;
- }
- else // no scale
- {
- w = 200;
- h = d_data->thermoWidth;
- }
- if ( d_data->orientation == Qt::Vertical )
- qSwap( w, h );
- w += 2 * d_data->borderWidth;
- h += 2 * d_data->borderWidth;
- return QSize( w, h );
- }
- int QwtThermo::transform( double value ) const
- {
- const double min = qMin( d_data->map.s1(), d_data->map.s2() );
- const double max = qMax( d_data->map.s1(), d_data->map.s2() );
- if ( value > max )
- value = max;
- if ( value < min )
- value = min;
- return qRound( d_data->map.transform( value ) );
- }
|