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_abstract_scale.h"
00019
00064 class QWT_EXPORT QwtThermo: public QWidget, public QwtAbstractScale
00065 {
00066 Q_OBJECT
00067
00068 Q_ENUMS( ScalePos )
00069
00070 Q_PROPERTY( QBrush alarmBrush READ alarmBrush WRITE setAlarmBrush )
00071 Q_PROPERTY( QColor alarmColor READ alarmColor WRITE setAlarmColor )
00072 Q_PROPERTY( bool alarmEnabled READ alarmEnabled WRITE setAlarmEnabled )
00073 Q_PROPERTY( double alarmLevel READ alarmLevel WRITE setAlarmLevel )
00074 Q_PROPERTY( ScalePos scalePosition READ scalePosition
00075 WRITE setScalePosition )
00076 Q_PROPERTY( int borderWidth READ borderWidth WRITE setBorderWidth )
00077 Q_PROPERTY( QBrush fillBrush READ fillBrush WRITE setFillBrush )
00078 Q_PROPERTY( QColor fillColor READ fillColor WRITE setFillColor )
00079 Q_PROPERTY( double maxValue READ maxValue WRITE setMaxValue )
00080 Q_PROPERTY( double minValue READ minValue WRITE setMinValue )
00081 Q_PROPERTY( int pipeWidth READ pipeWidth WRITE setPipeWidth )
00082 Q_PROPERTY( double value READ value WRITE setValue )
00083
00084 public:
00085
00086
00087
00088
00089
00090
00091
00092
00093 enum ScalePos {None, Left, Right, Top, Bottom};
00094
00095 explicit QwtThermo(QWidget *parent = NULL);
00096 virtual ~QwtThermo();
00097
00098 void setOrientation(Qt::Orientation o, ScalePos s);
00099
00100 void setScalePosition(ScalePos s);
00101 ScalePos scalePosition() const;
00102
00103 void setBorderWidth(int w);
00104 int borderWidth() const;
00105
00106 void setFillBrush(const QBrush &b);
00107 const QBrush &fillBrush() const;
00108
00109 void setFillColor(const QColor &c);
00110 const QColor &fillColor() const;
00111
00112 void setAlarmBrush(const QBrush &b);
00113 const QBrush &alarmBrush() const;
00114
00115 void setAlarmColor(const QColor &c);
00116 const QColor &alarmColor() const;
00117
00118 void setAlarmLevel(double v);
00119 double alarmLevel() const;
00120
00121 void setAlarmEnabled(bool tf);
00122 bool alarmEnabled() const;
00123
00124 void setPipeWidth(int w);
00125 int pipeWidth() const;
00126
00127 void setMaxValue(double v);
00128 double maxValue() const;
00129
00130 void setMinValue(double v);
00131 double minValue() const;
00132
00133 double value() const;
00134
00135 void setRange(double vmin, double vmax, bool lg = false);
00136 void setMargin(int m);
00137
00138 virtual QSize sizeHint() const;
00139 virtual QSize minimumSizeHint() const;
00140
00141 public slots:
00142 void setValue(double val);
00143
00144 protected:
00145 void draw(QPainter *p, const QRect& update_rect);
00146 void drawThermo(QPainter *p);
00147 void layoutThermo( bool update = true );
00148 virtual void scaleChange();
00149 virtual void fontChange(const QFont &oldFont);
00150
00151 virtual void paintEvent(QPaintEvent *e);
00152 virtual void resizeEvent(QResizeEvent *e);
00153
00154 private:
00155 int transform(double v) const;
00156
00157 class PrivateData;
00158 PrivateData *d_data;
00159 };
00160
00161 #endif