Classes | Public Types | Public Slots | Public Member Functions | Protected Member Functions | Properties

QwtThermo Class Reference

The Thermometer Widget. More...

#include <qwt_thermo.h>

Inheritance diagram for QwtThermo:
Inheritance graph
[legend]
Collaboration diagram for QwtThermo:
Collaboration graph
[legend]

List of all members.

Classes

class  PrivateData

Public Types

enum  ScalePos {
  NoScale, LeftScale, RightScale, TopScale,
  BottomScale
}

Public Slots

void setValue (double val)

Public Member Functions

 QwtThermo (QWidget *parent=NULL)
 QwtThermo (QWidget *parent, const char *name)
virtual ~QwtThermo ()
 Destructor.
void setOrientation (Qt::Orientation o, ScalePos s)
 Set the thermometer orientation and the scale position.
void setScalePosition (ScalePos s)
 Change the scale position (and thermometer orientation).
ScalePos scalePosition () const
void setBorderWidth (int w)
int borderWidth () const
void setFillBrush (const QBrush &b)
 Change the brush of the liquid.
const QBrush & fillBrush () const
void setFillColor (const QColor &c)
 Change the color of the liquid.
const QColor & fillColor () const
void setAlarmBrush (const QBrush &b)
 Specify the liquid brush above the alarm threshold.
const QBrush & alarmBrush () const
void setAlarmColor (const QColor &c)
 Specify the liquid color above the alarm threshold.
const QColor & alarmColor () const
void setAlarmLevel (double v)
double alarmLevel () const
void setAlarmEnabled (bool tf)
 Enable or disable the alarm threshold.
bool alarmEnabled () const
void setPipeWidth (int w)
int pipeWidth () const
void setMaxValue (double v)
double maxValue () const
void setMinValue (double v)
double minValue () const
double value () const
void setRange (double vmin, double vmax, bool lg=false)
 Set the range.
void setMargin (int m)
 Specify the distance between the pipe's endpoints and the widget's border.
virtual QSize sizeHint () const
virtual QSize minimumSizeHint () const
 Return a minimum size hint.
void setScaleDraw (QwtScaleDraw *)
 Set a scale draw.
const QwtScaleDrawscaleDraw () const

Protected Member Functions

void draw (QPainter *p, const QRect &update_rect)
void drawThermo (QPainter *p)
void layoutThermo (bool update=true)
virtual void scaleChange ()
 Notify a scale change.
virtual void fontChange (const QFont &oldFont)
 Notify a font change.
virtual void paintEvent (QPaintEvent *e)
virtual void resizeEvent (QResizeEvent *e)
 Qt resize event handler.
QwtScaleDrawscaleDraw ()

Properties

QBrush alarmBrush
QColor alarmColor
 Return the liquid color above the alarm threshold.
bool alarmEnabled
 Return if the alarm threshold is enabled or disabled.
double alarmLevel
ScalePos scalePosition
int borderWidth
QBrush fillBrush
QColor fillColor
double maxValue
 Return the maximum value.
double minValue
 Return the minimum value.
int pipeWidth
double value
 Return the value.

Detailed Description

The Thermometer Widget.

QwtThermo is a widget which displays a value in an interval. It supports:

sysinfo.png

By default, the scale and range run over the same interval of values. QwtAbstractScale::setScale() changes the interval of the scale and allows easy conversion between physical units.

The example shows how to make the scale indicate in degrees Fahrenheit and to set the value in degrees Kelvin:

#include <qapplication.h>
#include <qwt_thermo.h>

double Kelvin2Fahrenheit(double kelvin)
{
    // see http://en.wikipedia.org/wiki/Kelvin
    return 1.8*kelvin - 459.67;
}

int main(int argc, char **argv)
{
    const double minKelvin = 0.0;
    const double maxKelvin = 500.0;

    QApplication a(argc, argv);
    QwtThermo t;
    t.setRange(minKelvin, maxKelvin);
    t.setScale(Kelvin2Fahrenheit(minKelvin), Kelvin2Fahrenheit(maxKelvin));
    // set the value in Kelvin but the scale displays in Fahrenheit
    // 273.15 Kelvin = 0 Celsius = 32 Fahrenheit
    t.setValue(273.15);
    a.setMainWidget(&t);
    t.show();
    return a.exec();
}

Definition at line 69 of file qwt_thermo.h.


Member Enumeration Documentation

Enumerator:
NoScale 
LeftScale 
RightScale 
TopScale 
BottomScale 

Definition at line 98 of file qwt_thermo.h.


Constructor & Destructor Documentation

QwtThermo::QwtThermo ( QWidget *  parent = NULL ) [explicit]

Constructor

Parameters:
parentParent widget

Definition at line 64 of file qwt_thermo.cpp.

                                   : 
    QWidget(parent)
{
    initThermo();
}
QwtThermo::QwtThermo ( QWidget *  parent,
const char *  name 
) [explicit]

Constructor

Parameters:
parentParent widget
nameObject name

Definition at line 76 of file qwt_thermo.cpp.

                                                     : 
    QWidget(parent, name)
{
    initThermo();
}
QwtThermo::~QwtThermo (  ) [virtual]

Destructor.

Definition at line 105 of file qwt_thermo.cpp.

{
    delete d_data;
}

Member Function Documentation

const QBrush& QwtThermo::alarmBrush (  ) const
const QColor& QwtThermo::alarmColor (  ) const
bool QwtThermo::alarmEnabled (  ) const
double QwtThermo::alarmLevel (  ) const
int QwtThermo::borderWidth (  ) const
void QwtThermo::draw ( QPainter *  painter,
const QRect &  rect 
) [protected]

Draw the whole QwtThermo.

Parameters:
painterPainter
rectUpdate rectangle

Definition at line 225 of file qwt_thermo.cpp.

References QwtThermo::PrivateData::borderWidth, QwtAbstractScaleDraw::draw(), drawThermo(), NoScale, scaleDraw(), QwtThermo::PrivateData::scalePos, and QwtThermo::PrivateData::thermoRect.

Referenced by paintEvent().

{
    if ( !d_data->thermoRect.contains(rect) )
    {
        if (d_data->scalePos != NoScale)
        {
#if QT_VERSION < 0x040000
            scaleDraw()->draw(painter, colorGroup());
#else
            scaleDraw()->draw(painter, palette());
#endif
        }

        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,
#if QT_VERSION < 0x040000
            colorGroup(), 
#else
            palette(), 
#endif
            true, d_data->borderWidth, 0);
    }
    drawThermo(painter);
}
void QwtThermo::drawThermo ( QPainter *  painter ) [protected]

Redraw the liquid in thermometer pipe.

Parameters:
painterPainter

Definition at line 489 of file qwt_thermo.cpp.

References QwtThermo::PrivateData::alarmBrush, QwtThermo::PrivateData::alarmEnabled, QwtThermo::PrivateData::alarmLevel, QwtThermo::PrivateData::fillBrush, QwtThermo::PrivateData::maxValue, QwtThermo::PrivateData::minValue, QwtThermo::PrivateData::orientation, QwtThermo::PrivateData::thermoRect, and QwtThermo::PrivateData::value.

Referenced by draw().

{
    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 =
#if QT_VERSION < 0x040000
        colorGroup().color(QColorGroup::Background);
#else
        palette().color(QPalette::Background);
#endif
    painter->fillRect(bRect, bgColor);

    if (alarm)
       painter->fillRect(aRect, d_data->alarmBrush);

    painter->fillRect(fRect, d_data->fillBrush);
}
const QBrush& QwtThermo::fillBrush (  ) const
const QColor& QwtThermo::fillColor (  ) const
void QwtThermo::fontChange ( const QFont &  oldFont ) [protected, virtual]

Notify a font change.

Definition at line 472 of file qwt_thermo.cpp.

References layoutThermo().

void QwtThermo::layoutThermo ( bool  update_geometry = true ) [protected]

Recalculate the QwtThermo geometry and layout based on the QwtThermo::rect() and the fonts.

Parameters:
update_geometrynotify the layout system and call update to redraw the scale

Definition at line 266 of file qwt_thermo.cpp.

References QwtThermo::PrivateData::borderWidth, QwtScaleDraw::BottomScale, BottomScale, QwtScaleDraw::getBorderDistHint(), QwtScaleDraw::LeftScale, LeftScale, QwtThermo::PrivateData::map, QwtScaleDraw::move(), NoScale, QwtThermo::PrivateData::orientation, qwtMax, QwtScaleDraw::RightScale, RightScale, QwtThermo::PrivateData::scaleDist, scaleDraw(), QwtThermo::PrivateData::scalePos, QwtScaleDraw::setAlignment(), QwtScaleDraw::setLength(), QwtScaleMap::setPaintInterval(), QwtThermo::PrivateData::thermoRect, QwtThermo::PrivateData::thermoWidth, QwtScaleDraw::TopScale, and TopScale.

Referenced by fontChange(), resizeEvent(), scaleChange(), setBorderWidth(), setOrientation(), setPipeWidth(), and setRange().

{
    QRect r = rect();
    int mbd = 0;
    if ( d_data->scalePos != NoScale )
    {
        int d1, d2;
        scaleDraw()->getBorderDistHint(font(), d1, d2);
        mbd = qwtMax(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();
    }
}
double QwtThermo::maxValue (  ) const
QSize QwtThermo::minimumSizeHint (  ) const [virtual]

Return a minimum size hint.

Warning:
The return value depends on the font and the scale.
See also:
sizeHint()

Definition at line 879 of file qwt_thermo.cpp.

References QwtThermo::PrivateData::borderWidth, QwtScaleDraw::extent(), QwtScaleDraw::minLength(), NoScale, QwtThermo::PrivateData::orientation, QwtThermo::PrivateData::scaleDist, scaleDraw(), QwtThermo::PrivateData::scalePos, and QwtThermo::PrivateData::thermoWidth.

Referenced by sizeHint().

{
    int w = 0, h = 0;

    if ( d_data->scalePos != NoScale )
    {
        const int sdExtent = scaleDraw()->extent( QPen(), font() );
        const int sdLength = scaleDraw()->minLength( QPen(), 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 );
}
double QwtThermo::minValue (  ) const
void QwtThermo::paintEvent ( QPaintEvent *  event ) [protected, virtual]

Qt paint event. event Paint event

Definition at line 203 of file qwt_thermo.cpp.

References draw(), and QwtPaintBuffer::painter().

{
    // Use double-buffering
    const QRect &ur = event->rect();
    if ( ur.isValid() )
    {
#if QT_VERSION < 0x040000
        QwtPaintBuffer paintBuffer(this, ur);
        draw(paintBuffer.painter(), ur);
#else
        QPainter painter(this);
        draw(&painter, ur);
#endif
    }
}
int QwtThermo::pipeWidth (  ) const
void QwtThermo::resizeEvent ( QResizeEvent *  e ) [protected, virtual]

Qt resize event handler.

Definition at line 254 of file qwt_thermo.cpp.

References layoutThermo().

{
    layoutThermo( false );
}
void QwtThermo::scaleChange (  ) [protected, virtual]

Notify a scale change.

Reimplemented from QwtAbstractScale.

Definition at line 479 of file qwt_thermo.cpp.

References layoutThermo().

{
    update();
    layoutThermo();
}
QwtScaleDraw * QwtThermo::scaleDraw (  ) [protected]
Returns:
the scale draw of the thermo
See also:
setScaleDraw()

Definition at line 194 of file qwt_thermo.cpp.

References QwtAbstractScale::abstractScaleDraw().

const QwtScaleDraw * QwtThermo::scaleDraw (  ) const
Returns:
the scale draw of the thermo
See also:
setScaleDraw()

Definition at line 185 of file qwt_thermo.cpp.

References QwtAbstractScale::abstractScaleDraw().

Referenced by draw(), layoutThermo(), and minimumSizeHint().

ScalePos QwtThermo::scalePosition (  ) const
void QwtThermo::setAlarmBrush ( const QBrush &  brush )

Specify the liquid brush above the alarm threshold.

Parameters:
brushNew brush. The default is solid white.
See also:
alarmBrush()

Definition at line 752 of file qwt_thermo.cpp.

References QwtThermo::PrivateData::alarmBrush.

{
    d_data->alarmBrush = brush;
    update();
}
void QwtThermo::setAlarmColor ( const QColor &  c )

Specify the liquid color above the alarm threshold.

Parameters:
cNew color. The default is white.

Definition at line 771 of file qwt_thermo.cpp.

References QwtThermo::PrivateData::alarmBrush.

{
    d_data->alarmBrush.setColor(c);
    update();
}
void QwtThermo::setAlarmEnabled ( bool  tf )

Enable or disable the alarm threshold.

Parameters:
tftrue (disabled) or false (enabled)

Definition at line 853 of file qwt_thermo.cpp.

References QwtThermo::PrivateData::alarmEnabled.

{
    d_data->alarmEnabled = tf;
    update();
}
void QwtThermo::setAlarmLevel ( double  level )

Specify the alarm threshold.

Parameters:
levelAlarm threshold
See also:
alarmLevel()

Definition at line 789 of file qwt_thermo.cpp.

References QwtThermo::PrivateData::alarmEnabled, and QwtThermo::PrivateData::alarmLevel.

{
    d_data->alarmLevel = level;
    d_data->alarmEnabled = 1;
    update();
}
void QwtThermo::setBorderWidth ( int  width )

Set the border width of the pipe.

Parameters:
widthBorder width
See also:
borderWidth()

Definition at line 657 of file qwt_thermo.cpp.

References QwtThermo::PrivateData::borderWidth, layoutThermo(), qwtMin, and QwtThermo::PrivateData::thermoRect.

{
    if ((width >= 0) && (width < (qwtMin(d_data->thermoRect.width(), 
        d_data->thermoRect.height()) + d_data->borderWidth) / 2  - 1))
    {
        d_data->borderWidth = width;
        layoutThermo();
    }
}
void QwtThermo::setFillBrush ( const QBrush &  brush )

Change the brush of the liquid.

Parameters:
brushNew brush. The default brush is solid black.
See also:
fillBrush()

Definition at line 712 of file qwt_thermo.cpp.

References QwtThermo::PrivateData::fillBrush.

{
    d_data->fillBrush = brush;
    update();
}
void QwtThermo::setFillColor ( const QColor &  c )

Change the color of the liquid.

Parameters:
cNew color. The default color is black.
See also:
fillColor()

Definition at line 732 of file qwt_thermo.cpp.

References QwtThermo::PrivateData::fillBrush.

{
    d_data->fillBrush.setColor(c);
    update();
}
void QwtThermo::setMargin ( int  m )

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.

Parameters:
mNew 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.
This function is a NOOP because margins are determined automatically.

Definition at line 844 of file qwt_thermo.cpp.

{
}
void QwtThermo::setMaxValue ( double  max )

Set the maximum value.

Parameters:
maxMaximum value
See also:
maxValue(), setMinValue()

Definition at line 116 of file qwt_thermo.cpp.

References QwtThermo::PrivateData::minValue, and setRange().

{ 
    setRange(d_data->minValue, max); 
}
void QwtThermo::setMinValue ( double  min )

Set the minimum value.

Parameters:
minMinimum value
See also:
minValue(), setMaxValue()

Definition at line 133 of file qwt_thermo.cpp.

References QwtThermo::PrivateData::maxValue, and setRange().

{ 
    setRange(min, d_data->maxValue); 
}
void QwtThermo::setOrientation ( Qt::Orientation  o,
ScalePos  s 
)

Set the thermometer orientation and the scale position.

The scale position NoScale disables the scale.

Parameters:
oorientation. Possible values are Qt::Horizontal and Qt::Vertical. The default value is Qt::Vertical.
sPosition 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.
See also:
setScalePosition()

Definition at line 389 of file qwt_thermo.cpp.

References BottomScale, layoutThermo(), LeftScale, NoScale, QwtThermo::PrivateData::orientation, RightScale, QwtThermo::PrivateData::scalePos, and TopScale.

Referenced by setScalePosition().

{
    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 QT_VERSION >= 0x040000
        if ( !testAttribute(Qt::WA_WState_OwnSizePolicy) )
#else
        if ( !testWState( WState_OwnSizePolicy ) )
#endif
        {
            QSizePolicy sp = sizePolicy();
            sp.transpose();
            setSizePolicy(sp);

#if QT_VERSION >= 0x040000
            setAttribute(Qt::WA_WState_OwnSizePolicy, false);
#else
            clearWState( WState_OwnSizePolicy );
#endif
        }
    }

    d_data->orientation = o;
    layoutThermo();
}
void QwtThermo::setPipeWidth ( int  width )

Change the width of the pipe.

Parameters:
widthWidth of the pipe
See also:
pipeWidth()

Definition at line 811 of file qwt_thermo.cpp.

References layoutThermo(), and QwtThermo::PrivateData::thermoWidth.

{
    if (width > 0)
    {
        d_data->thermoWidth = width;
        layoutThermo();
    }
}
void QwtThermo::setRange ( double  vmin,
double  vmax,
bool  logarithmic = false 
)

Set the range.

Parameters:
vminvalue corresponding lower or left end of the thermometer
vmaxvalue corresponding to the upper or right end of the thermometer
logarithmiclogarithmic mapping, true or false

Definition at line 682 of file qwt_thermo.cpp.

References QwtAbstractScale::autoScale(), layoutThermo(), QwtThermo::PrivateData::map, QwtThermo::PrivateData::maxValue, QwtThermo::PrivateData::minValue, QwtAbstractScale::rescale(), QwtAbstractScale::scaleEngine(), QwtAbstractScale::setScaleEngine(), QwtScaleMap::setScaleInterval(), and QwtScaleMap::setTransformation().

Referenced by setMaxValue(), and setMinValue().

{
    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();
}
void QwtThermo::setScaleDraw ( QwtScaleDraw scaleDraw )

Set a scale draw.

For changing the labels of the scales, it is necessary to derive from QwtScaleDraw and overload QwtScaleDraw::label().

Parameters:
scaleDrawScaleDraw object, that has to be created with new and will be deleted in ~QwtThermo or the next call of setScaleDraw().

Definition at line 176 of file qwt_thermo.cpp.

References QwtAbstractScale::setAbstractScaleDraw().

{
    setAbstractScaleDraw(scaleDraw);
}
void QwtThermo::setScalePosition ( ScalePos  scalePos )

Change the scale position (and thermometer orientation).

Parameters:
scalePosPosition 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.
See also:
setOrientation(), scalePosition()

Definition at line 452 of file qwt_thermo.cpp.

References BottomScale, LeftScale, NoScale, QwtThermo::PrivateData::orientation, RightScale, setOrientation(), and TopScale.

{
    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);
}
void QwtThermo::setValue ( double  value ) [slot]

Set the current value.

Parameters:
valueNew Value
See also:
value()

Definition at line 150 of file qwt_thermo.cpp.

References value(), and QwtThermo::PrivateData::value.

{
    if (d_data->value != value)
    {
        d_data->value = value;
        update();
    }
}
QSize QwtThermo::sizeHint (  ) const [virtual]
Returns:
the minimum size hint
See also:
minimumSizeHint()

Definition at line 869 of file qwt_thermo.cpp.

References minimumSizeHint().

{
    return minimumSizeHint();
}
double QwtThermo::value (  ) const

Referenced by setValue().


Property Documentation

const QBrush & QwtThermo::alarmBrush [read, write]

Return the liquid brush above the alarm threshold.

See also:
setAlarmBrush()

Definition at line 75 of file qwt_thermo.h.

const QColor & QwtThermo::alarmColor [read, write]

Return the liquid color above the alarm threshold.

Definition at line 76 of file qwt_thermo.h.

bool QwtThermo::alarmEnabled [read, write]

Return if the alarm threshold is enabled or disabled.

Definition at line 77 of file qwt_thermo.h.

double QwtThermo::alarmLevel [read, write]

Return the alarm threshold.

See also:
setAlarmLevel()

Definition at line 78 of file qwt_thermo.h.

int QwtThermo::borderWidth [read, write]

Return the border width of the thermometer pipe.

See also:
setBorderWidth()

Definition at line 81 of file qwt_thermo.h.

const QBrush & QwtThermo::fillBrush [read, write]

Return the liquid brush.

See also:
setFillBrush()

Definition at line 82 of file qwt_thermo.h.

const QColor & QwtThermo::fillColor [read, write]

Return the liquid color.

See also:
setFillColor()

Definition at line 83 of file qwt_thermo.h.

double QwtThermo::maxValue [read, write]

Return the maximum value.

Definition at line 84 of file qwt_thermo.h.

double QwtThermo::minValue [read, write]

Return the minimum value.

Definition at line 85 of file qwt_thermo.h.

int QwtThermo::pipeWidth [read, write]

Return the width of the pipe.

See also:
setPipeWidth()

Definition at line 86 of file qwt_thermo.h.

QwtThermo::ScalePos QwtThermo::scalePosition [read, write]

Return the scale position.

See also:
setScalePosition()

Definition at line 80 of file qwt_thermo.h.

double QwtThermo::value [read, write]

Return the value.

Definition at line 87 of file qwt_thermo.h.


The documentation for this class was generated from the following files:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Defines