source: ntrip/branches/BNC_2.12/qwt/qwt_plot_item.h@ 8286

Last change on this file since 8286 was 4271, checked in by mervart, 12 years ago
File size: 5.0 KB
Line 
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_legend_itemmanager.h"
15#include "qwt_text.h"
16#include <qrect.h>
17
18class QString;
19class QPainter;
20class QWidget;
21class QwtPlot;
22class QwtLegend;
23class QwtScaleMap;
24class QwtScaleDiv;
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
53 into autoscaling or has an entry on the legnd.
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
64class QWT_EXPORT QwtPlotItem: public QwtLegendItemManager
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 {
75 Rtti_PlotItem = 0,
76
77 Rtti_PlotGrid,
78 Rtti_PlotScale,
79 Rtti_PlotMarker,
80 Rtti_PlotCurve,
81 Rtti_PlotSpectroCurve,
82 Rtti_PlotIntervalCurve,
83 Rtti_PlotHistogram,
84 Rtti_PlotSpectrogram,
85 Rtti_PlotSVG,
86
87 Rtti_PlotUserItem = 1000
88 };
89
90 /*!
91 Plot Item Attributes
92 \sa setItemAttribute(), testItemAttribute()
93 */
94 enum ItemAttribute
95 {
96 //! The item is represented on the legend.
97 Legend = 0x01,
98
99 /*!
100 The boundingRect() of the item is included in the
101 autoscaling calculation.
102 */
103 AutoScale = 0x02
104 };
105
106 //! Plot Item Attributes
107 typedef QFlags<ItemAttribute> ItemAttributes;
108
109 //! Render hints
110 enum RenderHint
111 {
112 //! Enable antialiasing
113 RenderAntialiased = 1
114 };
115
116 //! Render hints
117 typedef QFlags<RenderHint> RenderHints;
118
119 explicit QwtPlotItem( const QwtText &title = QwtText() );
120 virtual ~QwtPlotItem();
121
122 void attach( QwtPlot *plot );
123 void detach();
124
125 QwtPlot *plot() const;
126
127 void setTitle( const QString &title );
128 void setTitle( const QwtText &title );
129 const QwtText &title() const;
130
131 virtual int rtti() const;
132
133 void setItemAttribute( ItemAttribute, bool on = true );
134 bool testItemAttribute( ItemAttribute ) const;
135
136 void setRenderHint( RenderHint, bool on = true );
137 bool testRenderHint( RenderHint ) const;
138
139 double z() const;
140 void setZ( double z );
141
142 void show();
143 void hide();
144 virtual void setVisible( bool );
145 bool isVisible () const;
146
147 void setAxes( int xAxis, int yAxis );
148
149 void setXAxis( int axis );
150 int xAxis() const;
151
152 void setYAxis( int axis );
153 int yAxis() const;
154
155 virtual void itemChanged();
156
157 /*!
158 \brief Draw the item
159
160 \param painter Painter
161 \param xMap Maps x-values into pixel coordinates.
162 \param yMap Maps y-values into pixel coordinates.
163 \param canvasRect Contents rect of the canvas in painter coordinates
164 */
165 virtual void draw( QPainter *painter,
166 const QwtScaleMap &xMap, const QwtScaleMap &yMap,
167 const QRectF &canvasRect ) const = 0;
168
169 virtual QRectF boundingRect() const;
170
171 virtual void updateLegend( QwtLegend * ) const;
172 virtual void updateScaleDiv(
173 const QwtScaleDiv&, const QwtScaleDiv& );
174
175 virtual QWidget *legendItem() const;
176
177 QRectF scaleRect( const QwtScaleMap &, const QwtScaleMap & ) const;
178 QRectF paintRect( const QwtScaleMap &, const QwtScaleMap & ) const;
179
180private:
181 // Disabled copy constructor and operator=
182 QwtPlotItem( const QwtPlotItem & );
183 QwtPlotItem &operator=( const QwtPlotItem & );
184
185 class PrivateData;
186 PrivateData *d_data;
187};
188
189Q_DECLARE_OPERATORS_FOR_FLAGS( QwtPlotItem::ItemAttributes )
190Q_DECLARE_OPERATORS_FOR_FLAGS( QwtPlotItem::RenderHints )
191
192#endif
Note: See TracBrowser for help on using the repository browser.