qwt_compass.h 2.02 KB
Newer Older
pixhawk's avatar
pixhawk committed
1
2
3
4
5
6
7
8
9
10
11
12
/* -*- 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
 *****************************************************************************/

#ifndef QWT_COMPASS_H
#define QWT_COMPASS_H 1

Bryant's avatar
Bryant committed
13
14
15
#include "qwt_global.h"
#include "qwt_dial.h"
#include "qwt_round_scale_draw.h"
pixhawk's avatar
pixhawk committed
16
17
18
#include <qstring.h>
#include <qmap.h>

Bryant's avatar
Bryant committed
19
20
21
22
class QwtCompassRose;

/*!
  \brief A special scale draw made for QwtCompass
pixhawk's avatar
pixhawk committed
23

Bryant's avatar
Bryant committed
24
25
26
27
28
29
  QwtCompassScaleDraw maps values to strings using
  a special map, that can be modified by the application

  The default map consists of the labels N, NE, E, SE, S, SW, W, NW.

  \sa QwtCompass
pixhawk's avatar
pixhawk committed
30
*/
Bryant's avatar
Bryant committed
31
32
33
34
35
class QWT_EXPORT QwtCompassScaleDraw: public QwtRoundScaleDraw
{
public:
    explicit QwtCompassScaleDraw();
    explicit QwtCompassScaleDraw( const QMap<double, QString> &map );
pixhawk's avatar
pixhawk committed
36

Bryant's avatar
Bryant committed
37
38
    void setLabelMap( const QMap<double, QString> &map );
    QMap<double, QString> labelMap() const;
pixhawk's avatar
pixhawk committed
39

Bryant's avatar
Bryant committed
40
    virtual QwtText label( double value ) const;
pixhawk's avatar
pixhawk committed
41

Bryant's avatar
Bryant committed
42
43
44
private:
    QMap<double, QString> d_labelMap;
};
pixhawk's avatar
pixhawk committed
45
46
47
48
49

/*!
  \brief A Compass Widget

  QwtCompass is a widget to display and enter directions. It consists
50
  of a scale, an optional needle and rose.
pixhawk's avatar
pixhawk committed
51

52
  \image html dials1.png
pixhawk's avatar
pixhawk committed
53
54
55
56

  \note The examples/dials example shows how to use QwtCompass.
*/

57
class QWT_EXPORT QwtCompass: public QwtDial
pixhawk's avatar
pixhawk committed
58
59
60
61
{
    Q_OBJECT

public:
Bryant's avatar
Bryant committed
62
    explicit QwtCompass( QWidget* parent = NULL );
pixhawk's avatar
pixhawk committed
63
64
    virtual ~QwtCompass();

Bryant's avatar
Bryant committed
65
    void setRose( QwtCompassRose *rose );
pixhawk's avatar
pixhawk committed
66
67
68
69
    const QwtCompassRose *rose() const;
    QwtCompassRose *rose();

protected:
Bryant's avatar
Bryant committed
70
71
    virtual void drawRose( QPainter *, const QPointF &center,
        double radius, double north, QPalette::ColorGroup ) const;
pixhawk's avatar
pixhawk committed
72

Bryant's avatar
Bryant committed
73
74
    virtual void drawScaleContents( QPainter *,
        const QPointF &center, double radius ) const;
pixhawk's avatar
pixhawk committed
75

Bryant's avatar
Bryant committed
76
    virtual void keyPressEvent( QKeyEvent * );
pixhawk's avatar
pixhawk committed
77
78
79
80
81
82
83

private:
    class PrivateData;
    PrivateData *d_data;
};

#endif