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