qwt_compass.h 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. /* -*- mode: C++ ; c-file-style: "stroustrup" -*- *****************************
  2. * Qwt Widget Library
  3. * Copyright (C) 1997 Josef Wilgen
  4. * Copyright (C) 2002 Uwe Rathmann
  5. *
  6. * This library is free software; you can redistribute it and/or
  7. * modify it under the terms of the Qwt License, Version 1.0
  8. *****************************************************************************/
  9. #ifndef QWT_COMPASS_H
  10. #define QWT_COMPASS_H 1
  11. #include "qwt_global.h"
  12. #include "qwt_dial.h"
  13. #include "qwt_round_scale_draw.h"
  14. #include <qstring.h>
  15. #include <qmap.h>
  16. class QwtCompassRose;
  17. /*!
  18. \brief A special scale draw made for QwtCompass
  19. QwtCompassScaleDraw maps values to strings using
  20. a special map, that can be modified by the application
  21. The default map consists of the labels N, NE, E, SE, S, SW, W, NW.
  22. \sa QwtCompass
  23. */
  24. class QWT_EXPORT QwtCompassScaleDraw: public QwtRoundScaleDraw
  25. {
  26. public:
  27. explicit QwtCompassScaleDraw();
  28. explicit QwtCompassScaleDraw( const QMap<double, QString> &map );
  29. void setLabelMap( const QMap<double, QString> &map );
  30. QMap<double, QString> labelMap() const;
  31. virtual QwtText label( double value ) const;
  32. private:
  33. QMap<double, QString> d_labelMap;
  34. };
  35. /*!
  36. \brief A Compass Widget
  37. QwtCompass is a widget to display and enter directions. It consists
  38. of a scale, an optional needle and rose.
  39. \image html dials1.png
  40. \note The examples/dials example shows how to use QwtCompass.
  41. */
  42. class QWT_EXPORT QwtCompass: public QwtDial
  43. {
  44. Q_OBJECT
  45. public:
  46. explicit QwtCompass( QWidget* parent = NULL );
  47. virtual ~QwtCompass();
  48. void setRose( QwtCompassRose *rose );
  49. const QwtCompassRose *rose() const;
  50. QwtCompassRose *rose();
  51. protected:
  52. virtual void drawRose( QPainter *, const QPointF &center,
  53. double radius, double north, QPalette::ColorGroup ) const;
  54. virtual void drawScaleContents( QPainter *,
  55. const QPointF &center, double radius ) const;
  56. virtual void keyPressEvent( QKeyEvent * );
  57. private:
  58. class PrivateData;
  59. PrivateData *d_data;
  60. };
  61. #endif