source: ntrip/trunk/BNC/qwtpolar/qwt_polar_plot.h@ 7987

Last change on this file since 7987 was 4272, checked in by mervart, 12 years ago
File size: 6.1 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_PLOT_H
10#define QWT_POLAR_PLOT_H 1
11
12#include "qwt_polar_global.h"
13#include "qwt_polar.h"
14#include "qwt_polar_itemdict.h"
15#include <qwt_interval.h>
16#include <qwt_scale_map.h>
17#include <qwt_point_polar.h>
18#include <qframe.h>
19
20class QwtRoundScaleDraw;
21class QwtScaleEngine;
22class QwtScaleDiv;
23class QwtTextLabel;
24class QwtPolarCanvas;
25class QwtPolarLayout;
26
27/*!
28 \brief A plotting widget, displaying a polar coordinate system
29
30 An unlimited number of plot items can be displayed on
31 its canvas. Plot items might be curves (QwtPolarCurve), markers
32 (QwtPolarMarker), the grid (QwtPolarGrid), or anything else derived
33 from QwtPolarItem.
34
35 The coordinate system is defined by a radial and a azimuth scale.
36 The scales at the axes can be explicitely set (QwtScaleDiv), or
37 are calculated from the plot items, using algorithms (QwtScaleEngine) which
38 can be configured separately for each axis. Autoscaling is supported
39 for the radial scale.
40
41 In opposite to QwtPlot the scales might be different from the
42 view, that is displayed on the canvas. The view can be changed by
43 zooming - f.e. by using QwtPolarPanner or QwtPolarMaginfier.
44*/
45class QWT_POLAR_EXPORT QwtPolarPlot: public QFrame, public QwtPolarItemDict
46{
47 Q_OBJECT
48
49 Q_PROPERTY( QBrush plotBackground READ plotBackground WRITE setPlotBackground )
50 Q_PROPERTY( double azimuthOrigin READ azimuthOrigin WRITE setAzimuthOrigin )
51
52
53public:
54 /*!
55 Position of the legend, relative to the canvas.
56 \sa insertLegend()
57 */
58 enum LegendPosition
59 {
60 //! The legend will be left from the canvas.
61 LeftLegend,
62
63 //! The legend will be right from the canvas.
64 RightLegend,
65
66 //! The legend will be below the canvas.
67 BottomLegend,
68
69 //! The legend will be between canvas and title.
70 TopLegend,
71
72 /*!
73 External means that only the content of the legend
74 will be handled by QwtPlot, but not its geometry.
75 This might be interesting if an application wants to
76 have a legend in an external window ( or on the canvas ).
77
78 \note The legend is not painted by QwtPolarRenderer
79 */
80 ExternalLegend
81 };
82
83 explicit QwtPolarPlot( QWidget *parent = NULL );
84 QwtPolarPlot( const QwtText &title, QWidget *parent = NULL );
85
86 virtual ~QwtPolarPlot();
87
88 void setTitle( const QString & );
89 void setTitle( const QwtText & );
90
91 QwtText title() const;
92
93 QwtTextLabel *titleLabel();
94 const QwtTextLabel *titleLabel() const;
95
96 void setAutoReplot( bool tf = true );
97 bool autoReplot() const;
98
99 void setAutoScale( int scaleId );
100 bool hasAutoScale( int scaleId ) const;
101
102 void setScaleMaxMinor( int scaleId, int maxMinor );
103 int scaleMaxMinor( int scaleId ) const;
104
105 int scaleMaxMajor( int scaleId ) const;
106 void setScaleMaxMajor( int scaleId, int maxMajor );
107
108 QwtScaleEngine *scaleEngine( int scaleId );
109 const QwtScaleEngine *scaleEngine( int scaleId ) const;
110 void setScaleEngine( int scaleId, QwtScaleEngine * );
111
112 void setScale( int scaleId, double min, double max, double step = 0 );
113
114 void setScaleDiv( int scaleId, const QwtScaleDiv & );
115 const QwtScaleDiv *scaleDiv( int scaleId ) const;
116 QwtScaleDiv *scaleDiv( int scaleId );
117
118 QwtScaleMap scaleMap( int scaleId, double radius ) const;
119 QwtScaleMap scaleMap( int scaleId ) const;
120
121 void updateScale( int scaleId );
122
123 double azimuthOrigin() const;
124
125 void zoom( const QwtPointPolar&, double factor );
126 void unzoom();
127
128 QwtPointPolar zoomPos() const;
129 double zoomFactor() const;
130
131 // Canvas
132
133 QwtPolarCanvas *canvas();
134 const QwtPolarCanvas *canvas() const;
135
136 void setPlotBackground ( const QBrush &c );
137 const QBrush& plotBackground() const;
138
139 virtual void drawCanvas( QPainter *, const QRectF & ) const;
140
141 // Legend
142
143 void insertLegend( QwtLegend *,
144 LegendPosition = RightLegend, double ratio = -1.0 );
145
146 QwtLegend *legend();
147 const QwtLegend *legend() const;
148
149 // Layout
150 QwtPolarLayout *plotLayout();
151 const QwtPolarLayout *plotLayout() const;
152
153 QwtInterval visibleInterval() const;
154 QRectF plotRect() const;
155 QRectF plotRect( const QRectF & ) const;
156
157 int plotMarginHint() const;
158
159Q_SIGNALS:
160 /*!
161 A signal which is emitted when the user has clicked on
162 a legend item, which is in QwtLegend::ClickableItem mode.
163
164 \param plotItem Corresponding plot item of the
165 selected legend item
166
167 \note clicks are disabled as default
168 \sa QwtLegend::setItemMode, QwtLegend::itemMode
169 */
170 void legendClicked( QwtPolarItem *plotItem );
171
172 /*!
173 A signal which is emitted when the user has clicked on
174 a legend item, which is in QwtLegend::CheckableItem mode
175
176 \param plotItem Corresponding plot item of the
177 selected legend item
178 \param on True when the legen item is checked
179
180 \note clicks are disabled as default
181 \sa QwtLegend::setItemMode, QwtLegend::itemMode
182 */
183 void legendChecked( QwtPolarItem *plotItem, bool on );
184
185 /*!
186 A signal that is emitted, whenever the layout of the plot
187 has been recalculated.
188 */
189 void layoutChanged();
190
191public Q_SLOTS:
192 virtual void replot();
193 void autoRefresh();
194 void setAzimuthOrigin( double );
195
196protected Q_SLOTS:
197 virtual void legendItemClicked();
198 virtual void legendItemChecked( bool );
199
200protected:
201 virtual bool event( QEvent * );
202 virtual void resizeEvent( QResizeEvent * );
203
204 virtual void updateLayout();
205
206 virtual void drawItems( QPainter *painter,
207 const QwtScaleMap &radialMap, const QwtScaleMap &azimuthMap,
208 const QPointF &pole, double radius,
209 const QRectF &canvasRect ) const;
210
211private:
212 void initPlot( const QwtText & );
213
214 class ScaleData;
215 class PrivateData;
216 PrivateData *d_data;
217};
218
219#endif
Note: See TracBrowser for help on using the repository browser.