qwt_polar_item.h 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178
  1. /* -*- mode: C++ ; c-file-style: "stroustrup" -*- *****************************
  2. * QwtPolar Widget Library
  3. * Copyright (C) 2008 Uwe Rathmann
  4. *
  5. * This library is free software; you can redistribute it and/or
  6. * modify it under the terms of the Qwt License, Version 1.0
  7. *****************************************************************************/
  8. #ifndef QWT_POLAR_ITEM_H
  9. #define QWT_POLAR_ITEM_H
  10. #include "qwt_polar_global.h"
  11. #include <qwt_text.h>
  12. #include <qwt_legend_data.h>
  13. #include <qwt_graphic.h>
  14. #include <qwt_interval.h>
  15. class QString;
  16. class QRect;
  17. class QPointF;
  18. class QPainter;
  19. class QwtPolarPlot;
  20. class QwtScaleMap;
  21. class QwtScaleDiv;
  22. /*!
  23. \brief Base class for items on a polar plot
  24. A QwtPolarItem is "something that can be painted on the canvas".
  25. It is connected to the QwtPolar framework by a couple of virtual
  26. methods, that are individually implemented in derived item classes.
  27. QwtPolar offers an implementation of the most common types of items,
  28. but deriving from QwtPolarItem makes it easy to implement additional
  29. types of items.
  30. */
  31. class QWT_POLAR_EXPORT QwtPolarItem
  32. {
  33. public:
  34. /*!
  35. \brief Runtime type information
  36. RttiValues is used to cast plot items, without
  37. having to enable runtime type information of the compiler.
  38. */
  39. enum RttiValues
  40. {
  41. //! Unspecific value, that can be used, when it doesn't matter
  42. Rtti_PolarItem = 0,
  43. //! For QwtPolarGrid
  44. Rtti_PolarGrid,
  45. //! For QwtPolarMarker
  46. Rtti_PolarMarker,
  47. //! For QwtPolarCurve
  48. Rtti_PolarCurve,
  49. //! For QwtPolarSpectrogram
  50. Rtti_PolarSpectrogram,
  51. /*!
  52. Values >= Rtti_PolarUserItem are reserved for plot items
  53. not implemented in the QwtPolar library.
  54. */
  55. Rtti_PolarUserItem = 1000
  56. };
  57. /*!
  58. \brief Plot Item Attributes
  59. \sa setItemAttribute(), testItemAttribute()
  60. */
  61. enum ItemAttribute
  62. {
  63. //! The item is represented on the legend.
  64. Legend = 0x01,
  65. /*!
  66. The boundingRect() of the item is included in the
  67. autoscaling calculation.
  68. */
  69. AutoScale = 0x02
  70. };
  71. //! Item attributes
  72. typedef QFlags<ItemAttribute> ItemAttributes;
  73. /*!
  74. \brief Render hints
  75. \sa setRenderHint(), testRenderHint()
  76. */
  77. enum RenderHint
  78. {
  79. //! Enable antialiasing
  80. RenderAntialiased = 0x01
  81. };
  82. //! Item attributes
  83. typedef QFlags<RenderHint> RenderHints;
  84. explicit QwtPolarItem( const QwtText &title = QwtText() );
  85. virtual ~QwtPolarItem();
  86. void attach( QwtPolarPlot *plot );
  87. void detach();
  88. QwtPolarPlot *plot() const;
  89. void setTitle( const QString &title );
  90. void setTitle( const QwtText &title );
  91. const QwtText &title() const;
  92. virtual int rtti() const;
  93. void setItemAttribute( ItemAttribute, bool on = true );
  94. bool testItemAttribute( ItemAttribute ) const;
  95. void setRenderHint( RenderHint, bool on = true );
  96. bool testRenderHint( RenderHint ) const;
  97. void setRenderThreadCount( uint numThreads );
  98. uint renderThreadCount() const;
  99. double z() const;
  100. void setZ( double z );
  101. void show();
  102. void hide();
  103. virtual void setVisible( bool );
  104. bool isVisible () const;
  105. virtual void itemChanged();
  106. virtual void legendChanged();
  107. /*!
  108. \brief Draw the item
  109. \param painter Painter
  110. \param azimuthMap Maps azimuth values to values related to 0.0, M_2PI
  111. \param radialMap Maps radius values into painter coordinates.
  112. \param pole Position of the pole in painter coordinates
  113. \param radius Radius of the complete plot area in painter coordinates
  114. \param canvasRect Contents rect of the canvas in painter coordinates
  115. */
  116. virtual void draw( QPainter *painter,
  117. const QwtScaleMap &azimuthMap, const QwtScaleMap &radialMap,
  118. const QPointF &pole, double radius,
  119. const QRectF &canvasRect ) const = 0;
  120. virtual QwtInterval boundingInterval( int scaleId ) const;
  121. virtual void updateScaleDiv( const QwtScaleDiv &,
  122. const QwtScaleDiv &, const QwtInterval & );
  123. virtual int marginHint() const;
  124. void setLegendIconSize( const QSize & );
  125. QSize legendIconSize() const;
  126. virtual QList<QwtLegendData> legendData() const;
  127. virtual QwtGraphic legendIcon( int index, const QSizeF & ) const;
  128. private:
  129. // Disabled copy constructor and operator=
  130. QwtPolarItem( const QwtPolarItem & );
  131. QwtPolarItem &operator=( const QwtPolarItem & );
  132. class PrivateData;
  133. PrivateData *d_data;
  134. };
  135. Q_DECLARE_OPERATORS_FOR_FLAGS( QwtPolarItem::ItemAttributes )
  136. Q_DECLARE_OPERATORS_FOR_FLAGS( QwtPolarItem::RenderHints )
  137. Q_DECLARE_METATYPE( QwtPolarItem * )
  138. #endif