00001
00002
00003
00004
00005
00006
00007
00008
00009
00010 #ifndef QWT_THERMO_H
00011 #define QWT_THERMO_H
00012
00013 #include "qwt_global.h"
00014 #include "qwt_abstract_scale.h"
00015 #include <qwidget.h>
00016 #include <qcolor.h>
00017 #include <qfont.h>
00018 #include <qrect.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
00092
00093
00094
00095
00096
00097
00098 enum ScalePos
00099 {
00100 NoScale,
00101 LeftScale,
00102 RightScale,
00103 TopScale,
00104 BottomScale
00105 };
00106
00107 explicit QwtThermo(QWidget *parent = NULL);
00108 virtual ~QwtThermo();
00109
00110 void setOrientation(Qt::Orientation o, ScalePos s);
00111
00112 void setScalePosition(ScalePos s);
00113 ScalePos scalePosition() const;
00114
00115 void setBorderWidth(int w);
00116 int borderWidth() const;
00117
00118 void setFillBrush(const QBrush &b);
00119 const QBrush &fillBrush() const;
00120
00121 void setFillColor(const QColor &c);
00122 const QColor &fillColor() const;
00123
00124 void setAlarmBrush(const QBrush &b);
00125 const QBrush &alarmBrush() const;
00126
00127 void setAlarmColor(const QColor &c);
00128 const QColor &alarmColor() const;
00129
00130 void setAlarmLevel(double v);
00131 double alarmLevel() const;
00132
00133 void setAlarmEnabled(bool tf);
00134 bool alarmEnabled() const;
00135
00136 void setPipeWidth(int w);
00137 int pipeWidth() const;
00138
00139 void setMaxValue(double v);
00140 double maxValue() const;
00141
00142 void setMinValue(double v);
00143 double minValue() const;
00144
00145 double value() const;
00146
00147 void setRange(double vmin, double vmax, bool lg = false);
00148 void setMargin(int m);
00149
00150 virtual QSize sizeHint() const;
00151 virtual QSize minimumSizeHint() const;
00152
00153 void setScaleDraw(QwtScaleDraw *);
00154 const QwtScaleDraw *scaleDraw() const;
00155
00156 public Q_SLOTS:
00157 void setValue(double val);
00158
00159 protected:
00160 void draw(QPainter *p, const QRect& update_rect);
00161 void drawThermo(QPainter *p);
00162 void layoutThermo( bool update = true );
00163 virtual void scaleChange();
00164 virtual void fontChange(const QFont &oldFont);
00165
00166 virtual void paintEvent(QPaintEvent *e);
00167 virtual void resizeEvent(QResizeEvent *e);
00168
00169 QwtScaleDraw *scaleDraw();
00170
00171 private:
00172 void initThermo();
00173 int transform(double v) const;
00174
00175 class PrivateData;
00176 PrivateData *d_data;
00177 };
00178
00179 #endif