00001
00002
00003
00004
00005
00006
00007
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_dimap.h"
00019 #include "qwt_scldraw.h"
00020 #include "qwt_sclif.h"
00021
00022
00067 class QWT_EXPORT QwtThermo: public QWidget, public QwtScaleIf
00068 {
00069 Q_OBJECT
00070
00071 Q_ENUMS( ScalePos )
00072
00073 Q_PROPERTY( QBrush alarmBrush READ alarmBrush WRITE setAlarmBrush )
00074 Q_PROPERTY( QColor alarmColor READ alarmColor WRITE setAlarmColor )
00075 Q_PROPERTY( bool alarmEnabled READ alarmEnabled WRITE setAlarmEnabled )
00076 Q_PROPERTY( double alarmLevel READ alarmLevel WRITE setAlarmLevel )
00077 Q_PROPERTY( ScalePos scalePosition READ scalePosition
00078 WRITE setScalePosition )
00079 Q_PROPERTY( int borderWidth READ borderWidth WRITE setBorderWidth )
00080 Q_PROPERTY( QBrush fillBrush READ fillBrush WRITE setFillBrush )
00081 Q_PROPERTY( QColor fillColor READ fillColor WRITE setFillColor )
00082 Q_PROPERTY( double maxValue READ maxValue WRITE setMaxValue )
00083 Q_PROPERTY( double minValue READ minValue WRITE setMinValue )
00084 Q_PROPERTY( int pipeWidth READ pipeWidth WRITE setPipeWidth )
00085 Q_PROPERTY( double value READ value WRITE setValue )
00086
00087 public:
00088
00089
00090
00091
00092
00093
00094
00095
00096 enum ScalePos {None, Left, Right, Top, Bottom};
00097
00098 QwtThermo(QWidget *parent = 0, const char *name = 0);
00099 virtual ~QwtThermo();
00100
00101 void setOrientation(Qt::Orientation o, ScalePos s);
00102
00103 void setScalePosition(ScalePos s);
00104 ScalePos scalePosition() const;
00105
00106 void setBorderWidth(int w);
00107 int borderWidth() const;
00108
00109 void setFillBrush(const QBrush &b);
00110 const QBrush &fillBrush() const;
00111
00112 void setFillColor(const QColor &c);
00113 const QColor &fillColor() const;
00114
00115 void setAlarmBrush(const QBrush &b);
00116 const QBrush &alarmBrush() const;
00117
00118 void setAlarmColor(const QColor &c);
00119 const QColor &alarmColor() const;
00120
00121 void setAlarmLevel(double v);
00122 double alarmLevel() const;
00123
00124 void setAlarmEnabled(bool tf);
00125 bool alarmEnabled() const;
00126
00127 void setPipeWidth(int w);
00128 int pipeWidth() const;
00129
00131 void setMaxValue(double v) { setRange(d_minValue, v); }
00133 double maxValue() const { return d_maxValue; }
00134
00136 void setMinValue(double v) { setRange(v, d_maxValue); }
00138 double minValue() const { return d_minValue; }
00139
00141 double value() const { return d_value; }
00142
00143 void setRange(double vmin, double vmax, bool lg = FALSE);
00144 void setMargin(int m);
00145
00146 virtual QSize sizeHint() const;
00147 virtual QSize minimumSizeHint() const;
00148 virtual QSizePolicy sizePolicy() const;
00149
00150 public slots:
00151 void setValue(double val);
00152
00153 protected:
00154 void draw(QPainter *p, const QRect& update_rect);
00155 void drawThermo(QPainter *p);
00156 void layoutThermo( bool update = TRUE );
00157 virtual void scaleChange();
00158 virtual void fontChange(const QFont &oldFont);
00159
00160 virtual void paintEvent(QPaintEvent *e);
00161 virtual void resizeEvent(QResizeEvent *e);
00162
00163 private:
00164 void init();
00165
00166 QwtDiMap d_map;
00167 QRect d_thermoRect;
00168 QBrush d_fillBrush;
00169 QBrush d_alarmBrush;
00170
00171 Qt::Orientation d_orient;
00172 ScalePos d_scalePos;
00173 int d_borderWidth;
00174 int d_scaleDist;
00175 int d_thermoWidth;
00176
00177 double d_minValue;
00178 double d_maxValue;
00179 double d_value;
00180 double d_alarmLevel;
00181 bool d_alarmEnabled;
00182 };
00183
00184 #endif
00185
00186
00187
00188
00189
00190