source: pacpusframework/branches/2.0-beta1/include/extlib/qwt-5.2.1/qwt_thermo.h@ 89

Last change on this file since 89 was 89, checked in by morasjul, 11 years ago

PACPUS 2.0 Beta deployed in new branch

Major changes:
-Add communication interface between components
-Add examples for communications interface (TestComponents)
-Move to Qt5 support

  • Property svn:executable set to *
File size: 5.1 KB
Line 
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
20class QwtScaleDraw;
21
22/*!
23 \brief The Thermometer Widget
24
25 QwtThermo is a widget which displays a value in an interval. It supports:
26 - a horizontal or vertical layout;
27 - a range;
28 - a scale;
29 - an alarm level.
30
31 \image html sysinfo.png
32
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.
36
37 The example shows how to make the scale indicate in degrees Fahrenheit and
38 to set the value in degrees Kelvin:
39\code
40#include <qapplication.h>
41#include <qwt_thermo.h>
42
43double Kelvin2Fahrenheit(double kelvin)
44{
45 // see http://en.wikipedia.org/wiki/Kelvin
46 return 1.8*kelvin - 459.67;
47}
48
49int main(int argc, char **argv)
50{
51 const double minKelvin = 0.0;
52 const double maxKelvin = 500.0;
53
54 QApplication a(argc, argv);
55 QwtThermo t;
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
60 t.setValue(273.15);
61 a.setMainWidget(&t);
62 t.show();
63 return a.exec();
64}
65\endcode
66
67 \todo Improve the support for a logarithmic range and/or scale.
68*/
69class 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
89public:
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
159public slots:
160 void setValue(double val);
161
162protected:
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
174private:
175 void initThermo();
176 int transform(double v) const;
177
178 class PrivateData;
179 PrivateData *d_data;
180};
181
182#endif
Note: See TracBrowser for help on using the repository browser.