10#include "qwt_compass.h"
11#include "qwt_compass_rose.h"
17class QwtCompassScaleDraw::PrivateData
30 m_data =
new PrivateData;
37 map.insert( 0.0, QString::fromLatin1(
"N" ) );
38 map.insert( 45.0, QString::fromLatin1(
"NE" ) );
39 map.insert( 90.0, QString::fromLatin1(
"E" ) );
40 map.insert( 135.0, QString::fromLatin1(
"SE" ) );
41 map.insert( 180.0, QString::fromLatin1(
"S" ) );
42 map.insert( 225.0, QString::fromLatin1(
"SW" ) );
43 map.insert( 270.0, QString::fromLatin1(
"W" ) );
44 map.insert( 315.0, QString::fromLatin1(
"NW" ) );
47 map.insert( 22.5, QString::fromLatin1(
"NNE" ) );
48 map.insert( 67.5, QString::fromLatin1(
"NEE" ) );
49 map.insert( 112.5, QString::fromLatin1(
"SEE" ) );
50 map.insert( 157.5, QString::fromLatin1(
"SSE" ) );
51 map.insert( 202.5, QString::fromLatin1(
"SSW" ) );
52 map.insert( 247.5, QString::fromLatin1(
"SWW" ) );
53 map.insert( 292.5, QString::fromLatin1(
"NWW" ) );
54 map.insert( 337.5, QString::fromLatin1(
"NNW" ) );
65 m_data =
new PrivateData;
66 m_data->labelMap = map;
92 m_data->labelMap = map;
101 return m_data->labelMap;
118 if ( qFuzzyCompare( value + 1.0, 1.0 ) )
125 m_data->labelMap.constFind( value );
127 if ( it != m_data->labelMap.constEnd() )
133class QwtCompass::PrivateData
161 m_data =
new PrivateData;
190 const QPointF& center,
double radius )
const
192 QPalette::ColorGroup cg;
194 cg = hasFocus() ? QPalette::Active : QPalette::Inactive;
196 cg = QPalette::Disabled;
205 const int margin = 4;
206 drawRose( painter, center, radius - margin, 360.0 - north, cg );
219 double radius,
double north, QPalette::ColorGroup cg )
const
222 m_data->rose->
draw( painter, center, radius, north, cg );
234 if (
rose != m_data->rose )
277 if ( kev->key() == Key_5 )
284 double newValue =
value();
286 if ( kev->key() >= Qt::Key_1 && kev->key() <= Qt::Key_9 )
291 switch ( kev->key() )
294 newValue = 180.0 * 0.0;
297 newValue = 180.0 * 0.25;
300 newValue = 180.0 * 0.5;
303 newValue = 180.0 * 0.75;
306 newValue = 180.0 * 1.0;
309 newValue = 180.0 * 1.25;
312 newValue = 180.0 * 1.5;
315 newValue = 180.0 * 1.75;
327#include "moc_qwt_compass.cpp"
@ Backbone
Backbone = the line where the ticks are located.
void enableComponent(ScaleComponent, bool enable=true)
void setScaleMaxMajor(int ticks)
Set the maximum number of major tick intervals.
void setScaleMaxMinor(int ticks)
Set the maximum number of minor tick intervals.
void setScale(double lowerBound, double upperBound)
Specify a scale.
virtual void keyPressEvent(QKeyEvent *) override
void setTotalSteps(uint)
Set the number of steps.
void setValue(double value)
double value() const
Returns the current value.
QwtCompass(QWidget *parent=NULL)
Constructor.
void setRose(QwtCompassRose *rose)
virtual void keyPressEvent(QKeyEvent *) override
virtual void drawRose(QPainter *, const QPointF ¢er, double radius, double north, QPalette::ColorGroup) const
virtual void drawScaleContents(QPainter *, const QPointF ¢er, double radius) const override
virtual ~QwtCompass()
Destructor.
const QwtCompassRose * rose() const
Abstract base class for a compass rose.
virtual void draw(QPainter *painter, const QPointF ¢er, double radius, double north, QPalette::ColorGroup colorGroup=QPalette::Active) const =0
A special scale draw made for QwtCompass.
virtual QwtText label(double value) const override
void setLabelMap(const QMap< double, QString > &map)
Set a map, mapping values to labels.
virtual ~QwtCompassScaleDraw()
Destructor.
QMap< double, QString > labelMap() const
QwtCompassScaleDraw()
Constructor.
QwtDial class provides a rounded range control.
void setScaleDraw(QwtRoundScaleDraw *)
virtual void setOrigin(double)
Change the origin.
@ RotateScale
The needle is fixed, the scales are rotating.
@ RotateNeedle
The needle is rotating.
A class representing a text.