qwt_wheel.h 4.76 KB
Newer Older
pixhawk's avatar
pixhawk committed
1 2 3 4 5 6 7 8 9 10 11 12 13
/* -*- 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_WHEEL_H
#define QWT_WHEEL_H

#include "qwt_global.h"
Bryant's avatar
Bryant committed
14
#include <qwidget.h>
pixhawk's avatar
pixhawk committed
15 16 17 18 19

/*!
  \brief The Wheel Widget

  The wheel widget can be used to change values over a very large range
Bryant's avatar
Bryant committed
20 21 22 23
  in very small steps. Using the setMass() member, it can be configured
  as a flying wheel.

  The default range of the wheel is [0.0, 100.0]
pixhawk's avatar
pixhawk committed
24 25 26

  \sa The radio example.
*/
Bryant's avatar
Bryant committed
27
class QWT_EXPORT QwtWheel: public QWidget
pixhawk's avatar
pixhawk committed
28
{
29
    Q_OBJECT
Bryant's avatar
Bryant committed
30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48

    Q_PROPERTY( Qt::Orientation orientation
                READ orientation WRITE setOrientation )

    Q_PROPERTY( double value READ value WRITE setValue )
    Q_PROPERTY( double minimum READ minimum WRITE setMinimum )
    Q_PROPERTY( double maximum READ maximum WRITE setMaximum )

    Q_PROPERTY( double singleStep READ singleStep WRITE setSingleStep )
    Q_PROPERTY( int pageStepCount READ pageStepCount WRITE setPageStepCount )
    Q_PROPERTY( bool stepAlignment READ stepAlignment WRITE setStepAlignment )

    Q_PROPERTY( bool tracking READ isTracking WRITE setTracking )
    Q_PROPERTY( bool wrapping READ wrapping WRITE setWrapping )
    Q_PROPERTY( bool inverted READ isInverted WRITE setInverted )

    Q_PROPERTY( double mass READ mass WRITE setMass )
    Q_PROPERTY( int updateInterval READ updateInterval WRITE setUpdateInterval )

pixhawk's avatar
pixhawk committed
49 50
    Q_PROPERTY( double totalAngle READ totalAngle WRITE setTotalAngle )
    Q_PROPERTY( double viewAngle READ viewAngle WRITE setViewAngle )
Bryant's avatar
Bryant committed
51 52 53 54
    Q_PROPERTY( int tickCount READ tickCount WRITE setTickCount )
    Q_PROPERTY( int wheelWidth READ wheelWidth WRITE setWheelWidth )
    Q_PROPERTY( int borderWidth READ borderWidth WRITE setBorderWidth )
    Q_PROPERTY( int wheelBorderWidth READ wheelBorderWidth WRITE setWheelBorderWidth )
55

pixhawk's avatar
pixhawk committed
56
public:
Bryant's avatar
Bryant committed
57
    explicit QwtWheel( QWidget *parent = NULL );
pixhawk's avatar
pixhawk committed
58 59
    virtual ~QwtWheel();

Bryant's avatar
Bryant committed
60 61 62 63
    double value() const;

    void setOrientation( Qt::Orientation );
    Qt::Orientation orientation() const;
pixhawk's avatar
pixhawk committed
64 65 66

    double totalAngle() const;
    double viewAngle() const;
Bryant's avatar
Bryant committed
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

    void setTickCount( int );
    int tickCount() const;

    void setWheelWidth( int );
    int wheelWidth() const;

    void setWheelBorderWidth( int );
    int wheelBorderWidth() const;

    void setBorderWidth( int );
    int borderWidth() const;

    void setInverted( bool tf );
    bool isInverted() const;

    void setWrapping( bool tf );
    bool wrapping() const;

    void setSingleStep( double );
    double singleStep() const;

    void setPageStepCount( int );
    int pageStepCount() const;

    void setStepAlignment( bool on );
    bool stepAlignment() const;

    void setRange( double vmin, double vmax );

    void setMinimum( double min );
    double minimum() const;

    void setMaximum( double max );
    double maximum() const;

    void setUpdateInterval( int );
    int updateInterval() const;

    void setTracking( bool enable );
    bool isTracking() const;
pixhawk's avatar
pixhawk committed
108 109 110

    double mass() const;

Bryant's avatar
Bryant committed
111 112 113 114 115
public Q_SLOTS:
    void setValue( double );
    void setTotalAngle ( double );
    void setViewAngle( double );
    void setMass( double );
pixhawk's avatar
pixhawk committed
116

Bryant's avatar
Bryant committed
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
Q_SIGNALS:

    /*!
      \brief Notify a change of value.

      When tracking is enabled this signal will be emitted every
      time the value changes. 

      \param value new value
      \sa setTracking()
    */
    void valueChanged( double value );

    /*!
      This signal is emitted when the user presses the
      the wheel with the mouse
    */
    void wheelPressed();

    /*!
      This signal is emitted when the user releases the mouse
    */
    void wheelReleased();

    /*!
      This signal is emitted when the user moves the
      wheel with the mouse.

      \param value new value
    */
    void wheelMoved( double value );
pixhawk's avatar
pixhawk committed
148 149

protected:
Bryant's avatar
Bryant committed
150 151 152 153 154 155 156
    virtual void paintEvent( QPaintEvent * );
    virtual void mousePressEvent( QMouseEvent * );
    virtual void mouseReleaseEvent( QMouseEvent * );
    virtual void mouseMoveEvent( QMouseEvent * );
    virtual void keyPressEvent( QKeyEvent * );
    virtual void wheelEvent( QWheelEvent * );
    virtual void timerEvent( QTimerEvent * );
pixhawk's avatar
pixhawk committed
157

Bryant's avatar
Bryant committed
158 159 160 161 162 163
    void stopFlying();

    QRect wheelRect() const;

    virtual QSize sizeHint() const;
    virtual QSize minimumSizeHint() const;
pixhawk's avatar
pixhawk committed
164

Bryant's avatar
Bryant committed
165 166
    virtual void drawTicks( QPainter *, const QRectF & );
    virtual void drawWheelBackground( QPainter *, const QRectF & );
pixhawk's avatar
pixhawk committed
167

Bryant's avatar
Bryant committed
168
    virtual double valueAt( const QPoint & ) const;
pixhawk's avatar
pixhawk committed
169 170

private:
Bryant's avatar
Bryant committed
171 172
    double alignedValue( double ) const;
    double boundedValue( double ) const;
pixhawk's avatar
pixhawk committed
173 174 175 176 177 178

    class PrivateData;
    PrivateData *d_data;
};

#endif