source: ntrip/trunk/BNC/qwt/qwt_plot_item.h@ 10578

Last change on this file since 10578 was 9383, checked in by stoecker, 4 years ago

update to qwt verion 6.1.1 to fix build with newer Qt5

File size: 8.1 KB
RevLine 
[4271]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
10#ifndef QWT_PLOT_ITEM_H
11#define QWT_PLOT_ITEM_H
12
13#include "qwt_global.h"
14#include "qwt_text.h"
[8127]15#include "qwt_legend_data.h"
16#include "qwt_graphic.h"
[4271]17#include <qrect.h>
[8127]18#include <qlist.h>
19#include <qmetatype.h>
[4271]20
21class QPainter;
22class QwtScaleMap;
23class QwtScaleDiv;
[8127]24class QwtPlot;
[4271]25
26/*!
27 \brief Base class for items on the plot canvas
28
29 A plot item is "something", that can be painted on the plot canvas,
30 or only affects the scales of the plot widget. They can be categorized as:
31
32 - Representator\n
33 A "Representator" is an item that represents some sort of data
34 on the plot canvas. The different representator classes are organized
35 according to the characteristics of the data:
36 - QwtPlotMarker
37 Represents a point or a horizontal/vertical coordinate
38 - QwtPlotCurve
39 Represents a series of points
40 - QwtPlotSpectrogram ( QwtPlotRasterItem )
41 Represents raster data
42 - ...
43
44 - Decorators\n
45 A "Decorator" is an item, that displays additional information, that
46 is not related to any data:
47 - QwtPlotGrid
48 - QwtPlotScaleItem
49 - QwtPlotSvgItem
50 - ...
51
52 Depending on the QwtPlotItem::ItemAttribute flags, an item is included
[8127]53 into autoscaling or has an entry on the legend.
[4271]54
55 Before misusing the existing item classes it might be better to
56 implement a new type of plot item
57 ( don't implement a watermark as spectrogram ).
58 Deriving a new type of QwtPlotItem primarily means to implement
59 the YourPlotItem::draw() method.
60
61 \sa The cpuplot example shows the implementation of additional plot items.
62*/
63
[8127]64class QWT_EXPORT QwtPlotItem
[4271]65{
66public:
67 /*!
68 \brief Runtime type information
69
70 RttiValues is used to cast plot items, without
71 having to enable runtime type information of the compiler.
72 */
73 enum RttiValues
74 {
[8127]75 //! Unspecific value, that can be used, when it doesn't matter
[4271]76 Rtti_PlotItem = 0,
77
[8127]78 //! For QwtPlotGrid
[4271]79 Rtti_PlotGrid,
[8127]80
81 //! For QwtPlotScaleItem
[4271]82 Rtti_PlotScale,
[8127]83
84 //! For QwtPlotLegendItem
85 Rtti_PlotLegend,
86
87 //! For QwtPlotMarker
[4271]88 Rtti_PlotMarker,
[8127]89
90 //! For QwtPlotCurve
[4271]91 Rtti_PlotCurve,
[8127]92
93 //! For QwtPlotSpectroCurve
[4271]94 Rtti_PlotSpectroCurve,
[8127]95
96 //! For QwtPlotIntervalCurve
[4271]97 Rtti_PlotIntervalCurve,
[8127]98
99 //! For QwtPlotHistogram
[4271]100 Rtti_PlotHistogram,
[8127]101
102 //! For QwtPlotSpectrogram
[4271]103 Rtti_PlotSpectrogram,
[8127]104
105 //! For QwtPlotSvgItem
[4271]106 Rtti_PlotSVG,
107
[8127]108 //! For QwtPlotTradingCurve
109 Rtti_PlotTradingCurve,
110
111 //! For QwtPlotBarChart
112 Rtti_PlotBarChart,
113
114 //! For QwtPlotMultiBarChart
115 Rtti_PlotMultiBarChart,
116
117 //! For QwtPlotShapeItem
118 Rtti_PlotShape,
119
120 //! For QwtPlotTextLabel
121 Rtti_PlotTextLabel,
122
123 //! For QwtPlotZoneItem
124 Rtti_PlotZone,
125
[9383]126 /*!
[8127]127 Values >= Rtti_PlotUserItem are reserved for plot items
128 not implemented in the Qwt library.
129 */
[4271]130 Rtti_PlotUserItem = 1000
131 };
132
133 /*!
[8127]134 \brief Plot Item Attributes
135
136 Various aspects of a plot widget depend on the attributes of
[9383]137 the attached plot items. If and how a single plot item
[8127]138 participates in these updates depends on its attributes.
[9383]139
[8127]140 \sa setItemAttribute(), testItemAttribute(), ItemInterest
[4271]141 */
142 enum ItemAttribute
143 {
144 //! The item is represented on the legend.
145 Legend = 0x01,
146
147 /*!
[8127]148 The boundingRect() of the item is included in the
149 autoscaling calculation as long as its width or height
150 is >= 0.0.
[4271]151 */
[8127]152 AutoScale = 0x02,
153
154 /*!
155 The item needs extra space to display something outside
[9383]156 its bounding rectangle.
[8127]157 \sa getCanvasMarginHint()
158 */
159 Margins = 0x04
[4271]160 };
161
162 //! Plot Item Attributes
163 typedef QFlags<ItemAttribute> ItemAttributes;
164
[8127]165 /*!
166 \brief Plot Item Interests
167
168 Plot items might depend on the situation of the corresponding
169 plot widget. By enabling an interest the plot item will be
170 notified, when the corresponding attribute of the plot widgets
171 has changed.
172
173 \sa setItemAttribute(), testItemAttribute(), ItemInterest
174 */
175 enum ItemInterest
176 {
[9383]177 /*!
[8127]178 The item is interested in updates of the scales
179 \sa updateScaleDiv()
180 */
181 ScaleInterest = 0x01,
182
[9383]183 /*!
[8127]184 The item is interested in updates of the legend ( of other items )
185 This flag is intended for items, that want to implement a legend
186 for displaying entries of other plot item.
187
188 \note If the plot item wants to be represented on a legend
189 enable QwtPlotItem::Legend instead.
190
191 \sa updateLegend()
192 */
193 LegendInterest = 0x02
194 };
195
196 //! Plot Item Interests
197 typedef QFlags<ItemInterest> ItemInterests;
198
[4271]199 //! Render hints
200 enum RenderHint
201 {
202 //! Enable antialiasing
[8127]203 RenderAntialiased = 0x1
[4271]204 };
205
206 //! Render hints
207 typedef QFlags<RenderHint> RenderHints;
208
209 explicit QwtPlotItem( const QwtText &title = QwtText() );
210 virtual ~QwtPlotItem();
211
212 void attach( QwtPlot *plot );
213 void detach();
214
215 QwtPlot *plot() const;
216
217 void setTitle( const QString &title );
218 void setTitle( const QwtText &title );
219 const QwtText &title() const;
220
221 virtual int rtti() const;
222
223 void setItemAttribute( ItemAttribute, bool on = true );
224 bool testItemAttribute( ItemAttribute ) const;
225
[8127]226 void setItemInterest( ItemInterest, bool on = true );
227 bool testItemInterest( ItemInterest ) const;
228
[4271]229 void setRenderHint( RenderHint, bool on = true );
230 bool testRenderHint( RenderHint ) const;
231
[8127]232 void setRenderThreadCount( uint numThreads );
233 uint renderThreadCount() const;
234
235 void setLegendIconSize( const QSize & );
236 QSize legendIconSize() const;
237
[4271]238 double z() const;
239 void setZ( double z );
240
241 void show();
242 void hide();
243 virtual void setVisible( bool );
244 bool isVisible () const;
245
246 void setAxes( int xAxis, int yAxis );
247
248 void setXAxis( int axis );
249 int xAxis() const;
250
251 void setYAxis( int axis );
252 int yAxis() const;
253
254 virtual void itemChanged();
[8127]255 virtual void legendChanged();
[4271]256
257 /*!
258 \brief Draw the item
259
260 \param painter Painter
261 \param xMap Maps x-values into pixel coordinates.
262 \param yMap Maps y-values into pixel coordinates.
263 \param canvasRect Contents rect of the canvas in painter coordinates
264 */
265 virtual void draw( QPainter *painter,
266 const QwtScaleMap &xMap, const QwtScaleMap &yMap,
267 const QRectF &canvasRect ) const = 0;
268
269 virtual QRectF boundingRect() const;
270
[9383]271 virtual void getCanvasMarginHint(
[8127]272 const QwtScaleMap &xMap, const QwtScaleMap &yMap,
[9383]273 const QRectF &canvasRect,
[8127]274 double &left, double &top, double &right, double &bottom) const;
275
[9383]276 virtual void updateScaleDiv(
[4271]277 const QwtScaleDiv&, const QwtScaleDiv& );
278
[8127]279 virtual void updateLegend( const QwtPlotItem *,
280 const QList<QwtLegendData> & );
[4271]281
282 QRectF scaleRect( const QwtScaleMap &, const QwtScaleMap & ) const;
283 QRectF paintRect( const QwtScaleMap &, const QwtScaleMap & ) const;
284
[8127]285 virtual QList<QwtLegendData> legendData() const;
286
287 virtual QwtGraphic legendIcon( int index, const QSizeF & ) const;
288
289protected:
290 QwtGraphic defaultIcon( const QBrush &, const QSizeF & ) const;
291
[4271]292private:
293 // Disabled copy constructor and operator=
294 QwtPlotItem( const QwtPlotItem & );
295 QwtPlotItem &operator=( const QwtPlotItem & );
296
297 class PrivateData;
298 PrivateData *d_data;
299};
300
301Q_DECLARE_OPERATORS_FOR_FLAGS( QwtPlotItem::ItemAttributes )
[8127]302Q_DECLARE_OPERATORS_FOR_FLAGS( QwtPlotItem::ItemInterests )
[4271]303Q_DECLARE_OPERATORS_FOR_FLAGS( QwtPlotItem::RenderHints )
304
[8127]305Q_DECLARE_METATYPE( QwtPlotItem * )
306
[4271]307#endif
Note: See TracBrowser for help on using the repository browser.