Skip to content
Snippets Groups Projects
qwt_compass.h 2.02 KiB
Newer Older
  • Learn to ignore specific revisions
  • pixhawk's avatar
    pixhawk committed
    /* -*- 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
    #include "qwt_global.h"
    #include "qwt_dial.h"
    #include "qwt_round_scale_draw.h"
    
    pixhawk's avatar
    pixhawk committed
    #include <qstring.h>
    #include <qmap.h>
    
    
    Bryant's avatar
    Bryant committed
    class QwtCompassRose;
    
    /*!
      \brief A special scale draw made for QwtCompass
    
    pixhawk's avatar
    pixhawk committed
    
    
    Bryant's avatar
    Bryant committed
      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
    */
    
    Bryant's avatar
    Bryant committed
    class QWT_EXPORT QwtCompassScaleDraw: public QwtRoundScaleDraw
    {
    public:
        explicit QwtCompassScaleDraw();
        explicit QwtCompassScaleDraw( const QMap<double, QString> &map );
    
    pixhawk's avatar
    pixhawk committed
    
    
    Bryant's avatar
    Bryant committed
        void setLabelMap( const QMap<double, QString> &map );
        QMap<double, QString> labelMap() const;
    
    pixhawk's avatar
    pixhawk committed
    
    
    Bryant's avatar
    Bryant committed
        virtual QwtText label( double value ) const;
    
    pixhawk's avatar
    pixhawk committed
    
    
    Bryant's avatar
    Bryant committed
    private:
        QMap<double, QString> d_labelMap;
    };
    
    pixhawk's avatar
    pixhawk committed
    
    /*!
      \brief A Compass Widget
    
      QwtCompass is a widget to display and enter directions. It consists
    
      of a scale, an optional needle and rose.
    
    pixhawk's avatar
    pixhawk committed
    
    
      \image html dials1.png
    
    pixhawk's avatar
    pixhawk committed
    
      \note The examples/dials example shows how to use QwtCompass.
    */
    
    
    class QWT_EXPORT QwtCompass: public QwtDial
    
    pixhawk's avatar
    pixhawk committed
    {
        Q_OBJECT
    
    public:
    
    Bryant's avatar
    Bryant committed
        explicit QwtCompass( QWidget* parent = NULL );
    
    pixhawk's avatar
    pixhawk committed
        virtual ~QwtCompass();
    
    
    Bryant's avatar
    Bryant committed
        void setRose( QwtCompassRose *rose );
    
    pixhawk's avatar
    pixhawk committed
        const QwtCompassRose *rose() const;
        QwtCompassRose *rose();
    
    protected:
    
    Bryant's avatar
    Bryant committed
        virtual void drawRose( QPainter *, const QPointF &center,
            double radius, double north, QPalette::ColorGroup ) const;
    
    pixhawk's avatar
    pixhawk committed
    
    
    Bryant's avatar
    Bryant committed
        virtual void drawScaleContents( QPainter *,
            const QPointF &center, double radius ) const;
    
    pixhawk's avatar
    pixhawk committed
    
    
    Bryant's avatar
    Bryant committed
        virtual void keyPressEvent( QKeyEvent * );
    
    pixhawk's avatar
    pixhawk committed
    
    private:
        class PrivateData;
        PrivateData *d_data;
    };
    
    #endif