1
/* -*- mode: C++ ; c-file-style: "stroustrup" -*- *****************************
3
* Copyright (C) 1997 Josef Wilgen
4
* Copyright (C) 2002 Uwe Rathmann
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
*****************************************************************************/
17
#include "qwt_global.h"
18
#include "qwt_abstract_scale.h"
23
\brief The Thermometer Widget
25
QwtThermo is a widget which displays a value in an interval. It supports:
26
- a horizontal or vertical layout;
31
\image html sysinfo.png
33
By default, the scale and range run over the same interval of values.
34
QwtAbstractScale::setScale() changes the interval of the scale and allows
35
easy conversion between physical units.
37
The example shows how to make the scale indicate in degrees Fahrenheit and
38
to set the value in degrees Kelvin:
40
#include <qapplication.h>
41
#include <qwt_thermo.h>
43
double Kelvin2Fahrenheit(double kelvin)
45
// see http://en.wikipedia.org/wiki/Kelvin
46
return 1.8*kelvin - 459.67;
49
int main(int argc, char **argv)
51
const double minKelvin = 0.0;
52
const double maxKelvin = 500.0;
54
QApplication a(argc, argv);
56
t.setRange(minKelvin, maxKelvin);
57
t.setScale(Kelvin2Fahrenheit(minKelvin), Kelvin2Fahrenheit(maxKelvin));
58
// set the value in Kelvin but the scale displays in Fahrenheit
59
// 273.15 Kelvin = 0 Celsius = 32 Fahrenheit
67
\todo Improve the support for a logarithmic range and/or scale.
69
class QWT_EXPORT QwtThermo: public QWidget, public QwtAbstractScale
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 )
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
96
\sa setOrientation, setScalePosition
107
explicit QwtThermo(QWidget *parent = NULL);
108
#if QT_VERSION < 0x040000
109
explicit QwtThermo(QWidget *parent, const char *name);
111
virtual ~QwtThermo();
113
void setOrientation(Qt::Orientation o, ScalePos s);
115
void setScalePosition(ScalePos s);
116
ScalePos scalePosition() const;
118
void setBorderWidth(int w);
119
int borderWidth() const;
121
void setFillBrush(const QBrush &b);
122
const QBrush &fillBrush() const;
124
void setFillColor(const QColor &c);
125
const QColor &fillColor() const;
127
void setAlarmBrush(const QBrush &b);
128
const QBrush &alarmBrush() const;
130
void setAlarmColor(const QColor &c);
131
const QColor &alarmColor() const;
133
void setAlarmLevel(double v);
134
double alarmLevel() const;
136
void setAlarmEnabled(bool tf);
137
bool alarmEnabled() const;
139
void setPipeWidth(int w);
140
int pipeWidth() const;
142
void setMaxValue(double v);
143
double maxValue() const;
145
void setMinValue(double v);
146
double minValue() const;
148
double value() const;
150
void setRange(double vmin, double vmax, bool lg = false);
151
void setMargin(int m);
153
virtual QSize sizeHint() const;
154
virtual QSize minimumSizeHint() const;
156
void setScaleDraw(QwtScaleDraw *);
157
const QwtScaleDraw *scaleDraw() const;
160
void setValue(double val);
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);
169
virtual void paintEvent(QPaintEvent *e);
170
virtual void resizeEvent(QResizeEvent *e);
172
QwtScaleDraw *scaleDraw();
176
int transform(double v) const;