# qwt_thermo.h

    00001 /* -*- mode: C++ ; c-file-style: "stroustrup" -*- *****************************
    00002  * Qwt Widget Library
    00003  * Copyright (C) 1997   Josef Wilgen
    00004  * Copyright (C) 2002   Uwe Rathmann
    00005  *
    00006  * This library is free software; you can redistribute it and/or
    00007  * modify it under the terms of the Qwt License, Version 1.0
    00008  *****************************************************************************/
    00009
    00010 #ifndef QWT_THERMO_H
    00011 #define QWT_THERMO_H
    00012
    00013 #include <qwidget.h>
    00014 #include <qcolor.h>
    00015 #include <qfont.h>
    00016 #include <qrect.h>
    00017 #include "qwt_global.h"
    00018 #include "qwt_abstract_scale.h"
    00019
    00020 class QwtScaleDraw;
    00021
    00069 class QWT_EXPORT QwtThermo: public QWidget, public QwtAbstractScale
    00070 {
    00071     Q_OBJECT
    00072
    00073     Q_ENUMS( ScalePos )
    00074
    00075     Q_PROPERTY( QBrush alarmBrush READ alarmBrush WRITE setAlarmBrush )
    00076     Q_PROPERTY( QColor alarmColor READ alarmColor WRITE setAlarmColor )
    00077     Q_PROPERTY( bool alarmEnabled READ alarmEnabled WRITE setAlarmEnabled )
    00078     Q_PROPERTY( double alarmLevel READ alarmLevel WRITE setAlarmLevel )
    00079     Q_PROPERTY( ScalePos scalePosition READ scalePosition
    00080         WRITE setScalePosition )
    00081     Q_PROPERTY( int borderWidth READ borderWidth WRITE setBorderWidth )
    00082     Q_PROPERTY( QBrush fillBrush READ fillBrush WRITE setFillBrush )
    00083     Q_PROPERTY( QColor fillColor READ fillColor WRITE setFillColor )
    00084     Q_PROPERTY( double maxValue READ maxValue WRITE setMaxValue )
    00085     Q_PROPERTY( double minValue READ minValue WRITE setMinValue )
    00086     Q_PROPERTY( int pipeWidth READ pipeWidth WRITE setPipeWidth )
    00087     Q_PROPERTY( double value READ value WRITE setValue )
    00088
    00089 public:
    00090     /*
    00091       Scale position. QwtThermo tries to enforce valid combinations of its
    00092       orientation and scale position:
    00093       - Qt::Horizonal combines with NoScale, TopScale and BottomScale
    00094       - Qt::Vertical combines with NoScale, LeftScale and RightScale
    00095
    00096       \sa setOrientation, setScalePosition
    00097     */
    00098     enum ScalePos
    00099     {
    00100         NoScale,
    00101         LeftScale,
    00102         RightScale,
    00103         TopScale,
    00104         BottomScale
    00105     };
    00106
    00107     explicit QwtThermo(QWidget *parent = NULL);
    00108 #if QT_VERSION < 0x040000
    00109     explicit QwtThermo(QWidget *parent, const char *name);
    00110 #endif
    00111     virtual ~QwtThermo();
    00112
    00113     void setOrientation(Qt::Orientation o, ScalePos s);
    00114
    00115     void setScalePosition(ScalePos s);
    00116     ScalePos scalePosition() const;
    00117
    00118     void setBorderWidth(int w);
    00119     int borderWidth() const;
    00120
    00121     void setFillBrush(const QBrush &b);
    00122     const QBrush &fillBrush() const;
    00123
    00124     void setFillColor(const QColor &c);
    00125     const QColor &fillColor() const;
    00126
    00127     void setAlarmBrush(const QBrush &b);
    00128     const QBrush &alarmBrush() const;
    00129
    00130     void setAlarmColor(const QColor &c);
    00131     const QColor &alarmColor() const;
    00132
    00133     void setAlarmLevel(double v);
    00134     double alarmLevel() const;
    00135
    00136     void setAlarmEnabled(bool tf);
    00137     bool alarmEnabled() const;
    00138
    00139     void setPipeWidth(int w);
    00140     int pipeWidth() const;
    00141
    00142     void setMaxValue(double v);
    00143     double maxValue() const;
    00144
    00145     void setMinValue(double v);
    00146     double minValue() const;
    00147
    00148     double value() const;
    00149
    00150     void setRange(double vmin, double vmax, bool lg = false);
    00151     void setMargin(int m);
    00152
    00153     virtual QSize sizeHint() const;
    00154     virtual QSize minimumSizeHint() const;
    00155
    00156     void setScaleDraw(QwtScaleDraw *);
    00157     const QwtScaleDraw *scaleDraw() const;
    00158
    00159 public slots:
    00160     void setValue(double val);
    00161
    00162 protected:
    00163     void draw(QPainter *p, const QRect& update_rect);
    00164     void drawThermo(QPainter *p);
    00165     void layoutThermo( bool update = true );
    00166     virtual void scaleChange();
    00167     virtual void fontChange(const QFont &oldFont);
    00168
    00169     virtual void paintEvent(QPaintEvent *e);
    00170     virtual void resizeEvent(QResizeEvent *e);
    00171
    00172     QwtScaleDraw *scaleDraw();
    00173
    00174 private:
    00175     void initThermo();
    00176     int transform(double v) const;
    00177
    00178     class PrivateData;
    00179     PrivateData *d_data;
    00180 };
    00181
    00182 #endif