| 1 | /******************************************************************************
|
|---|
| 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 |
|
|---|
| 9 | #ifndef QWT_POLAR_ITEM_H
|
|---|
| 10 | #define QWT_POLAR_ITEM_H
|
|---|
| 11 |
|
|---|
| 12 | #include "qwt_global.h"
|
|---|
| 13 | #include "qwt_text.h"
|
|---|
| 14 | #include "qwt_legend_data.h"
|
|---|
| 15 | #include "qwt_graphic.h"
|
|---|
| 16 | #include "qwt_interval.h"
|
|---|
| 17 |
|
|---|
| 18 | class QString;
|
|---|
| 19 | class QRect;
|
|---|
| 20 | class QPointF;
|
|---|
| 21 | class QPainter;
|
|---|
| 22 | class QwtPolarPlot;
|
|---|
| 23 | class QwtScaleMap;
|
|---|
| 24 | class QwtScaleDiv;
|
|---|
| 25 |
|
|---|
| 26 | /*!
|
|---|
| 27 | \brief Base class for items on a polar plot
|
|---|
| 28 |
|
|---|
| 29 | A QwtPolarItem is "something that can be painted on the canvas".
|
|---|
| 30 | It is connected to the QwtPolar framework by a couple of virtual
|
|---|
| 31 | methods, that are individually implemented in derived item classes.
|
|---|
| 32 |
|
|---|
| 33 | QwtPolar offers an implementation of the most common types of items,
|
|---|
| 34 | but deriving from QwtPolarItem makes it easy to implement additional
|
|---|
| 35 | types of items.
|
|---|
| 36 | */
|
|---|
| 37 | class QWT_EXPORT QwtPolarItem
|
|---|
| 38 | {
|
|---|
| 39 | public:
|
|---|
| 40 | /*!
|
|---|
| 41 | \brief Runtime type information
|
|---|
| 42 |
|
|---|
| 43 | RttiValues is used to cast plot items, without
|
|---|
| 44 | having to enable runtime type information of the compiler.
|
|---|
| 45 | */
|
|---|
| 46 | enum RttiValues
|
|---|
| 47 | {
|
|---|
| 48 | //! Unspecific value, that can be used, when it doesn't matter
|
|---|
| 49 | Rtti_PolarItem = 0,
|
|---|
| 50 |
|
|---|
| 51 | //! For QwtPolarGrid
|
|---|
| 52 | Rtti_PolarGrid,
|
|---|
| 53 |
|
|---|
| 54 | //! For QwtPolarMarker
|
|---|
| 55 | Rtti_PolarMarker,
|
|---|
| 56 |
|
|---|
| 57 | //! For QwtPolarCurve
|
|---|
| 58 | Rtti_PolarCurve,
|
|---|
| 59 |
|
|---|
| 60 | //! For QwtPolarSpectrogram
|
|---|
| 61 | Rtti_PolarSpectrogram,
|
|---|
| 62 |
|
|---|
| 63 | /*!
|
|---|
| 64 | Values >= Rtti_PolarUserItem are reserved for plot items
|
|---|
| 65 | not implemented in the QwtPolar library.
|
|---|
| 66 | */
|
|---|
| 67 | Rtti_PolarUserItem = 1000
|
|---|
| 68 | };
|
|---|
| 69 |
|
|---|
| 70 | /*!
|
|---|
| 71 | \brief Plot Item Attributes
|
|---|
| 72 | \sa setItemAttribute(), testItemAttribute()
|
|---|
| 73 | */
|
|---|
| 74 | enum ItemAttribute
|
|---|
| 75 | {
|
|---|
| 76 | //! The item is represented on the legend.
|
|---|
| 77 | Legend = 0x01,
|
|---|
| 78 |
|
|---|
| 79 | /*!
|
|---|
| 80 | The boundingRect() of the item is included in the
|
|---|
| 81 | autoscaling calculation.
|
|---|
| 82 | */
|
|---|
| 83 | AutoScale = 0x02
|
|---|
| 84 | };
|
|---|
| 85 |
|
|---|
| 86 | Q_DECLARE_FLAGS( ItemAttributes, ItemAttribute )
|
|---|
| 87 |
|
|---|
| 88 | /*!
|
|---|
| 89 | \brief Render hints
|
|---|
| 90 | \sa setRenderHint(), testRenderHint()
|
|---|
| 91 | */
|
|---|
| 92 | enum RenderHint
|
|---|
| 93 | {
|
|---|
| 94 | //! Enable antialiasing
|
|---|
| 95 | RenderAntialiased = 0x01
|
|---|
| 96 | };
|
|---|
| 97 |
|
|---|
| 98 | Q_DECLARE_FLAGS( RenderHints, RenderHint )
|
|---|
| 99 |
|
|---|
| 100 | explicit QwtPolarItem( const QwtText& title = QwtText() );
|
|---|
| 101 | virtual ~QwtPolarItem();
|
|---|
| 102 |
|
|---|
| 103 | void attach( QwtPolarPlot* plot );
|
|---|
| 104 | void detach();
|
|---|
| 105 |
|
|---|
| 106 | QwtPolarPlot* plot() const;
|
|---|
| 107 |
|
|---|
| 108 | void setTitle( const QString& title );
|
|---|
| 109 | void setTitle( const QwtText& title );
|
|---|
| 110 | const QwtText& title() const;
|
|---|
| 111 |
|
|---|
| 112 | virtual int rtti() const;
|
|---|
| 113 |
|
|---|
| 114 | void setItemAttribute( ItemAttribute, bool on = true );
|
|---|
| 115 | bool testItemAttribute( ItemAttribute ) const;
|
|---|
| 116 |
|
|---|
| 117 | void setRenderHint( RenderHint, bool on = true );
|
|---|
| 118 | bool testRenderHint( RenderHint ) const;
|
|---|
| 119 |
|
|---|
| 120 | void setRenderThreadCount( uint numThreads );
|
|---|
| 121 | uint renderThreadCount() const;
|
|---|
| 122 |
|
|---|
| 123 | double z() const;
|
|---|
| 124 | void setZ( double z );
|
|---|
| 125 |
|
|---|
| 126 | void show();
|
|---|
| 127 | void hide();
|
|---|
| 128 | virtual void setVisible( bool );
|
|---|
| 129 | bool isVisible () const;
|
|---|
| 130 |
|
|---|
| 131 | virtual void itemChanged();
|
|---|
| 132 | virtual void legendChanged();
|
|---|
| 133 |
|
|---|
| 134 | /*!
|
|---|
| 135 | \brief Draw the item
|
|---|
| 136 |
|
|---|
| 137 | \param painter Painter
|
|---|
| 138 | \param azimuthMap Maps azimuth values to values related to 0.0, M_2PI
|
|---|
| 139 | \param radialMap Maps radius values into painter coordinates.
|
|---|
| 140 | \param pole Position of the pole in painter coordinates
|
|---|
| 141 | \param radius Radius of the complete plot area in painter coordinates
|
|---|
| 142 | \param canvasRect Contents rect of the canvas in painter coordinates
|
|---|
| 143 | */
|
|---|
| 144 | virtual void draw( QPainter* painter,
|
|---|
| 145 | const QwtScaleMap& azimuthMap, const QwtScaleMap& radialMap,
|
|---|
| 146 | const QPointF& pole, double radius,
|
|---|
| 147 | const QRectF& canvasRect ) const = 0;
|
|---|
| 148 |
|
|---|
| 149 | virtual QwtInterval boundingInterval( int scaleId ) const;
|
|---|
| 150 |
|
|---|
| 151 | virtual void updateScaleDiv( const QwtScaleDiv&,
|
|---|
| 152 | const QwtScaleDiv&, const QwtInterval& );
|
|---|
| 153 |
|
|---|
| 154 | virtual int marginHint() const;
|
|---|
| 155 |
|
|---|
| 156 | void setLegendIconSize( const QSize& );
|
|---|
| 157 | QSize legendIconSize() const;
|
|---|
| 158 |
|
|---|
| 159 | virtual QList< QwtLegendData > legendData() const;
|
|---|
| 160 | virtual QwtGraphic legendIcon( int index, const QSizeF& ) const;
|
|---|
| 161 |
|
|---|
| 162 | private:
|
|---|
| 163 | Q_DISABLE_COPY( QwtPolarItem )
|
|---|
| 164 |
|
|---|
| 165 | class PrivateData;
|
|---|
| 166 | PrivateData* m_data;
|
|---|
| 167 | };
|
|---|
| 168 |
|
|---|
| 169 | Q_DECLARE_OPERATORS_FOR_FLAGS( QwtPolarItem::ItemAttributes )
|
|---|
| 170 | Q_DECLARE_OPERATORS_FOR_FLAGS( QwtPolarItem::RenderHints )
|
|---|
| 171 |
|
|---|
| 172 | Q_DECLARE_METATYPE( QwtPolarItem* )
|
|---|
| 173 |
|
|---|
| 174 | #endif
|
|---|