source: ntrip/branches/BNC_2.13.beta/qwt/qwt_dial.h@ 10204

Last change on this file since 10204 was 9383, checked in by stoecker, 4 years ago

update to qwt verion 6.1.1 to fix build with newer Qt5

File size: 4.8 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_DIAL_H
11#define QWT_DIAL_H 1
12
13#include "qwt_global.h"
14#include "qwt_abstract_slider.h"
15#include "qwt_abstract_scale_draw.h"
16#include <qframe.h>
17#include <qpalette.h>
18
19class QwtDialNeedle;
20class QwtRoundScaleDraw;
21
22/*!
23 \brief QwtDial class provides a rounded range control.
24
25 QwtDial is intended as base class for dial widgets like
26 speedometers, compass widgets, clocks ...
27
28 \image html dials2.png
29
30 A dial contains a scale and a needle indicating the current value
31 of the dial. Depending on Mode one of them is fixed and the
32 other is rotating. If not isReadOnly() the
33 dial can be rotated by dragging the mouse or using keyboard inputs
34 (see QwtAbstractSlider::keyPressEvent()). A dial might be wrapping, what means
35 a rotation below/above one limit continues on the other limit (f.e compass).
36 The scale might cover any arc of the dial, its values are related to
37 the origin() of the dial.
38
39 Often dials have to be updated very often according to values from external
40 devices. For these high refresh rates QwtDial caches as much as possible.
41 For derived classes it might be necessary to clear these caches manually
42 according to attribute changes using invalidateCache().
43
44 \sa QwtCompass, QwtAnalogClock, QwtDialNeedle
45 \note The controls and dials examples shows different types of dials.
46 \note QDial is more similar to QwtKnob than to QwtDial
47*/
48
49class QWT_EXPORT QwtDial: public QwtAbstractSlider
50{
51 Q_OBJECT
52
53 Q_ENUMS( Shadow Mode Direction )
54
55 Q_PROPERTY( int lineWidth READ lineWidth WRITE setLineWidth )
56 Q_PROPERTY( Shadow frameShadow READ frameShadow WRITE setFrameShadow )
57 Q_PROPERTY( Mode mode READ mode WRITE setMode )
58 Q_PROPERTY( double origin READ origin WRITE setOrigin )
59 Q_PROPERTY( double minScaleArc READ minScaleArc WRITE setMinScaleArc )
60 Q_PROPERTY( double maxScaleArc READ maxScaleArc WRITE setMaxScaleArc )
61
62public:
63
64 /*!
65 \brief Frame shadow
66
67 Unfortunately it is not possible to use QFrame::Shadow
68 as a property of a widget that is not derived from QFrame.
69 The following enum is made for the designer only. It is safe
70 to use QFrame::Shadow instead.
71 */
72 enum Shadow
73 {
74 //! QFrame::Plain
75 Plain = QFrame::Plain,
76
77 //! QFrame::Raised
78 Raised = QFrame::Raised,
79
80 //! QFrame::Sunken
81 Sunken = QFrame::Sunken
82 };
83
84 //! Mode controlling whether the needle or the scale is rotating
85 enum Mode
86 {
87 //! The needle is rotating
88 RotateNeedle,
89
90 //! The needle is fixed, the scales are rotating
91 RotateScale
92 };
93
94 explicit QwtDial( QWidget *parent = NULL );
95 virtual ~QwtDial();
96
97 void setFrameShadow( Shadow );
98 Shadow frameShadow() const;
99
100 void setLineWidth( int );
101 int lineWidth() const;
102
103 void setMode( Mode );
104 Mode mode() const;
105
106 void setScaleArc( double minArc, double maxArc );
107
108 void setMinScaleArc( double );
109 double minScaleArc() const;
110
111 void setMaxScaleArc( double );
112 double maxScaleArc() const;
113
114 virtual void setOrigin( double );
115 double origin() const;
116
117 void setNeedle( QwtDialNeedle * );
118 const QwtDialNeedle *needle() const;
119 QwtDialNeedle *needle();
120
121 QRect boundingRect() const;
122 QRect innerRect() const;
123
124 virtual QRect scaleInnerRect() const;
125
126 virtual QSize sizeHint() const;
127 virtual QSize minimumSizeHint() const;
128
129 void setScaleDraw( QwtRoundScaleDraw * );
130
131 QwtRoundScaleDraw *scaleDraw();
132 const QwtRoundScaleDraw *scaleDraw() const;
133
134protected:
135 virtual void wheelEvent( QWheelEvent * );
136 virtual void paintEvent( QPaintEvent * );
137 virtual void changeEvent( QEvent * );
138
139 virtual void drawFrame( QPainter * );
140 virtual void drawContents( QPainter * ) const;
141 virtual void drawFocusIndicator( QPainter * ) const;
142
143 void invalidateCache();
144
145 virtual void drawScale( QPainter *,
146 const QPointF &center, double radius ) const;
147
148 virtual void drawScaleContents( QPainter *painter,
149 const QPointF &center, double radius ) const;
150
151 virtual void drawNeedle( QPainter *, const QPointF &,
152 double radius, double direction, QPalette::ColorGroup ) const;
153
154 virtual double scrolledTo( const QPoint & ) const;
155 virtual bool isScrollPosition( const QPoint & ) const;
156
157 virtual void sliderChange();
158 virtual void scaleChange();
159
160private:
161 void setAngleRange( double angle, double span );
162 void drawNeedle( QPainter * ) const;
163
164 class PrivateData;
165 PrivateData *d_data;
166};
167
168#endif
Note: See TracBrowser for help on using the repository browser.