Newer
Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
/* -*- mode: C++ ; c-file-style: "stroustrup" -*- *****************************
* Qwt Widget Library
* Copyright (C) 1997 Josef Wilgen
* Copyright (C) 2002 Uwe Rathmann
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the Qwt License, Version 1.0
*****************************************************************************/
#include <math.h>
#include <qpainter.h>
#if QT_VERSION >= 0x040000
#include <qbitmap.h>
#include <qpalette.h>
#endif
#include <qpixmap.h>
#include <qevent.h>
#include "qwt_math.h"
#include "qwt_scale_engine.h"
#include "qwt_scale_map.h"
#include "qwt_paint_buffer.h"
#include "qwt_painter.h"
#include "qwt_dial_needle.h"
#include "qwt_dial.h"
class QwtDial::PrivateData
{
public:
PrivateData():
visibleBackground(true),
frameShadow(Sunken),
lineWidth(0),
mode(RotateNeedle),
origin(90.0),
minScaleArc(0.0),
maxScaleArc(0.0),
scaleDraw(0),
maxMajIntv(36),
maxMinIntv(10),
scaleStep(0.0),
needle(0)
{
}
~PrivateData()
{
delete scaleDraw;
delete needle;
}
bool visibleBackground;
Shadow frameShadow;
int lineWidth;
QwtDial::Mode mode;
double origin;
double minScaleArc;
double maxScaleArc;
QwtDialScaleDraw *scaleDraw;
int maxMajIntv;
int maxMinIntv;
double scaleStep;
QwtDialNeedle *needle;
static double previousDir;
};
double QwtDial::PrivateData::previousDir = -1.0;
/*!
Constructor
\param parent Parent dial widget
*/
QwtDialScaleDraw::QwtDialScaleDraw(QwtDial *parent):
d_parent(parent),
d_penWidth(1)
{
}
/*!
Set the pen width used for painting the scale
\param penWidth Pen width
\sa penWidth(), QwtDial::drawScale()
*/
void QwtDialScaleDraw::setPenWidth(uint penWidth)
{
d_penWidth = penWidth;
}
/*!
\return Pen width used for painting the scale
\sa setPenWidth, QwtDial::drawScale()
*/
uint QwtDialScaleDraw::penWidth() const
{
return d_penWidth;
}
/*!
Call QwtDial::scaleLabel of the parent dial widget.
\param value Value to display
\sa QwtDial::scaleLabel
*/
QwtText QwtDialScaleDraw::label(double value) const
{
if ( d_parent == NULL )
return QwtRoundScaleDraw::label(value);
return d_parent->scaleLabel(value);
}
/*!
\brief Constructor
\param parent Parent widget
Create a dial widget with no scale and no needle.
The default origin is 90.0 with no valid value. It accepts
mouse and keyboard inputs and has no step size. The default mode
is QwtDial::RotateNeedle.
*/
QwtDial::QwtDial(QWidget* parent):
QwtAbstractSlider(Qt::Horizontal, parent)
{
initDial();
}
#if QT_VERSION < 0x040000
/*!
\brief Constructor
\param parent Parent widget
\param name Object name
Create a dial widget with no scale and no needle.
The default origin is 90.0 with no valid value. It accepts
mouse and keyboard inputs and has no step size. The default mode
is QwtDial::RotateNeedle.
*/
QwtDial::QwtDial(QWidget* parent, const char *name):
QwtAbstractSlider(Qt::Horizontal, parent)
{
setName(name);
initDial();
}
#endif
void QwtDial::initDial()
{
d_data = new PrivateData;
#if QT_VERSION < 0x040000
setWFlags(Qt::WNoAutoErase);
#endif
#if QT_VERSION >= 0x040000
using namespace Qt;
#endif
setFocusPolicy(TabFocus);
QPalette p = palette();
for ( int i = 0; i < QPalette::NColorGroups; i++ )
{
const QPalette::ColorGroup cg = (QPalette::ColorGroup)i;
// Base: background color of the circle inside the frame.
// Foreground: background color of the circle inside the scale
#if QT_VERSION < 0x040000
p.setColor(cg, QColorGroup::Foreground,
p.color(cg, QColorGroup::Base));
#else
p.setColor(cg, QPalette::Foreground,
p.color(cg, QPalette::Base));
#endif
}
setPalette(p);
d_data->scaleDraw = new QwtDialScaleDraw(this);
d_data->scaleDraw->setRadius(0);
setScaleArc(0.0, 360.0); // scale as a full circle
setRange(0.0, 360.0, 1.0, 10); // degrees as deafult
}
//! Destructor
QwtDial::~QwtDial()
{
delete d_data;
}
/*!
Show/Hide the area outside of the frame
\param show Show if true, hide if false
Loading
Loading full blame...