Qwt User's Guide: qwt_thermo.h Source File

Qwt User's Guide 5.2.3

- Main Page
- Related Pages
- Classes

qwt_thermo.h
1 /* -*- mode: C++ ; c-file-style: "stroustrup" -*- *****************************
2 * Qwt Widget Library
3 * Copyright (C) 1997 Josef Wilgen
4 * Copyright (C) 2002 Uwe Rathmann
5 *
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the Qwt License, Version 1.0
8 *****************************************************************************/
9
10 #ifndef QWT_THERMO_H
11 #define QWT_THERMO_H
12
13 #include <qwidget.h>
14 #include <qcolor.h>
15 #include <qfont.h>
16 #include <qrect.h>
17 #include "qwt_global.h"
18 #include "qwt_abstract_scale.h"
19
20 class QwtScaleDraw;
21
69 class QWT_EXPORT QwtThermo: public QWidget, public QwtAbstractScale
70 {
71 Q_OBJECT
72
73 Q_ENUMS( ScalePos )
74
75 Q_PROPERTY( QBrush alarmBrush READ alarmBrush WRITE setAlarmBrush )
76 Q_PROPERTY( QColor alarmColor READ alarmColor WRITE setAlarmColor )
77 Q_PROPERTY( bool alarmEnabled READ alarmEnabled WRITE setAlarmEnabled )
78 Q_PROPERTY( double alarmLevel READ alarmLevel WRITE setAlarmLevel )
79 Q_PROPERTY( ScalePos scalePosition READ scalePosition
80 WRITE setScalePosition )
81 Q_PROPERTY( int borderWidth READ borderWidth WRITE setBorderWidth )
82 Q_PROPERTY( QBrush fillBrush READ fillBrush WRITE setFillBrush )
83 Q_PROPERTY( QColor fillColor READ fillColor WRITE setFillColor )
84 Q_PROPERTY( double maxValue READ maxValue WRITE setMaxValue )
85 Q_PROPERTY( double minValue READ minValue WRITE setMinValue )
86 Q_PROPERTY( int pipeWidth READ pipeWidth WRITE setPipeWidth )
87 Q_PROPERTY( double value READ value WRITE setValue )
88
89 public:
90 /*
91 Scale position. QwtThermo tries to enforce valid combinations of its
92 orientation and scale position:
93 - Qt::Horizonal combines with NoScale, TopScale and BottomScale
94 - Qt::Vertical combines with NoScale, LeftScale and RightScale
95
96 \sa setOrientation(), setScalePosition()
97 */
98 enum ScalePos
99 {
100 NoScale,
101 LeftScale,
102 RightScale,
103 TopScale,
104 BottomScale
105 };
106
107 explicit QwtThermo(QWidget *parent = NULL);
108 #if QT_VERSION < 0x040000
109 explicit QwtThermo(QWidget *parent, const char *name);
110 #endif
111 virtual ~QwtThermo();
112
113 void setOrientation(Qt::Orientation o, ScalePos s);
114
115 void setScalePosition(ScalePos s);
116 ScalePos scalePosition() const;
117
118 void setBorderWidth(int w);
119 int borderWidth() const;
120
121 void setFillBrush(const QBrush &b);
122 const QBrush &fillBrush() const;
123
124 void setFillColor(const QColor &c);
125 const QColor &fillColor() const;
126
127 void setAlarmBrush(const QBrush &b);
128 const QBrush &alarmBrush() const;
129
130 void setAlarmColor(const QColor &c);
131 const QColor &alarmColor() const;
132
133 void setAlarmLevel(double v);
134 double alarmLevel() const;
135
136 void setAlarmEnabled(bool tf);
137 bool alarmEnabled() const;
138
139 void setPipeWidth(int w);
140 int pipeWidth() const;
141
142 void setMaxValue(double v);
143 double maxValue() const;
144
145 void setMinValue(double v);
146 double minValue() const;
147
148 double value() const;
149
150 void setRange(double vmin, double vmax, bool lg = false);
151 void setMargin(int m);
152
153 virtual QSize sizeHint() const;
154 virtual QSize minimumSizeHint() const;
155
156 void setScaleDraw(QwtScaleDraw *);
157 const QwtScaleDraw *scaleDraw() const;
158
159 public slots:
160 void setValue(double val);
161
162 protected:
163 void draw(QPainter *p, const QRect& update_rect);
164 void drawThermo(QPainter *p);
165 void layoutThermo( bool update = true );
166 virtual void scaleChange();
167 virtual void fontChange(const QFont &oldFont);
168
169 virtual void paintEvent(QPaintEvent *e);
170 virtual void resizeEvent(QResizeEvent *e);
171
172 QwtScaleDraw *scaleDraw();
173
174 private:
175 void initThermo();
176 int transform(double v) const;
177
178 class PrivateData;
179 PrivateData *d_data;
180 };
181
182 #endif