source: ntrip/trunk/BNC/qwtpolar/qwt_polar_item.h@ 7047

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