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

Last change on this file since 10590 was 8127, checked in by stoecker, 8 years ago

update qwt and qwtpolar, many QT5 fixes (unfinished)

File size: 4.7 KB
Line 
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_data.h>
15#include <qwt_graphic.h>
16#include <qwt_interval.h>
17
18class QString;
19class QRect;
20class QPointF;
21class QPainter;
22class QwtPolarPlot;
23class QwtScaleMap;
24class 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*/
37class QWT_POLAR_EXPORT QwtPolarItem
38{
39public:
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 //! Item attributes
87 typedef QFlags<ItemAttribute> ItemAttributes;
88
89 /*!
90 \brief Render hints
91 \sa setRenderHint(), testRenderHint()
92 */
93 enum RenderHint
94 {
95 //! Enable antialiasing
96 RenderAntialiased = 0x01
97 };
98
99 //! Item attributes
100 typedef QFlags<RenderHint> RenderHints;
101
102 explicit QwtPolarItem( const QwtText &title = QwtText() );
103 virtual ~QwtPolarItem();
104
105 void attach( QwtPolarPlot *plot );
106 void detach();
107
108 QwtPolarPlot *plot() const;
109
110 void setTitle( const QString &title );
111 void setTitle( const QwtText &title );
112 const QwtText &title() const;
113
114 virtual int rtti() const;
115
116 void setItemAttribute( ItemAttribute, bool on = true );
117 bool testItemAttribute( ItemAttribute ) const;
118
119 void setRenderHint( RenderHint, bool on = true );
120 bool testRenderHint( RenderHint ) const;
121
122 void setRenderThreadCount( uint numThreads );
123 uint renderThreadCount() const;
124
125 double z() const;
126 void setZ( double z );
127
128 void show();
129 void hide();
130 virtual void setVisible( bool );
131 bool isVisible () const;
132
133 virtual void itemChanged();
134 virtual void legendChanged();
135
136 /*!
137 \brief Draw the item
138
139 \param painter Painter
140 \param azimuthMap Maps azimuth values to values related to 0.0, M_2PI
141 \param radialMap Maps radius values into painter coordinates.
142 \param pole Position of the pole in painter coordinates
143 \param radius Radius of the complete plot area in painter coordinates
144 \param canvasRect Contents rect of the canvas in painter coordinates
145 */
146 virtual void draw( QPainter *painter,
147 const QwtScaleMap &azimuthMap, const QwtScaleMap &radialMap,
148 const QPointF &pole, double radius,
149 const QRectF &canvasRect ) const = 0;
150
151 virtual QwtInterval boundingInterval( int scaleId ) const;
152
153 virtual void updateScaleDiv( const QwtScaleDiv &,
154 const QwtScaleDiv &, const QwtInterval & );
155
156 virtual int marginHint() const;
157
158 void setLegendIconSize( const QSize & );
159 QSize legendIconSize() const;
160
161 virtual QList<QwtLegendData> legendData() const;
162 virtual QwtGraphic legendIcon( int index, const QSizeF & ) 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
176Q_DECLARE_METATYPE( QwtPolarItem * )
177
178#endif
Note: See TracBrowser for help on using the repository browser.