source: ntrip/trunk/BNC/qwtpolar/qwt_polar_grid.h@ 6036

Last change on this file since 6036 was 4272, checked in by mervart, 12 years ago
File size: 5.5 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_GRID_H
10#define QWT_POLAR_GRID_H
11
12#include "qwt_polar_global.h"
13#include "qwt_polar.h"
14#include "qwt_polar_item.h"
15#include "qwt_polar_plot.h"
16
17class QPainter;
18class QPen;
19class QwtScaleMap;
20class QwtScaleDiv;
21class QwtRoundScaleDraw;
22class QwtScaleDraw;
23
24/*!
25 \brief An item which draws scales and grid lines on a polar plot.
26
27 The QwtPolarGrid class can be used to draw a coordinate grid.
28 A coordinate grid consists of major and minor gridlines.
29 The locations of the gridlines are determined by the azimuth and radial
30 scale divisions.
31
32 QwtPolarGrid is also responsible for drawing the axis representing the
33 scales. It is possible to display 4 radial and one azimuth axis.
34
35 Whenever the scale divisions of the plot widget changes the grid
36 is synchronized by updateScaleDiv().
37
38 \sa QwtPolarPlot, QwtPolar::Axis
39*/
40
41class QWT_POLAR_EXPORT QwtPolarGrid: public QwtPolarItem
42{
43public:
44 /*!
45 Mysterious flags trying to avoid conflicts, when painting the
46 scales and grid lines.
47
48 The default setting enables all flags.
49
50 \sa setDisplayFlag(), testDisplayFlag()
51 */
52 enum DisplayFlag
53 {
54 /*!
55 Try to avoid situations, where the label of the origin is
56 painted over another axis.
57 */
58 SmartOriginLabel = 1,
59
60 /*!
61 Often the outermost tick of the radial scale is close to the
62 canvas border. With HideMaxRadiusLabel enabled it is not painted.
63 */
64 HideMaxRadiusLabel = 2,
65
66 /*!
67 The tick labels of the radial scales might be hard to read, when
68 they are painted on top of the radial grid lines ( or on top
69 of a curve/spectrogram ). When ClipAxisBackground the bounding rect
70 of each label is added to the clip region.
71 */
72 ClipAxisBackground = 4,
73
74 /*!
75 Don't paint the backbone of the radial axes, when they are very close
76 to a line of the azimuth grid.
77 */
78 SmartScaleDraw = 8,
79
80 /*!
81 All grid lines are clipped against the plot area before being painted.
82 When the plot is zoomed in this will have an significant impact
83 on the performance of the painting cde.
84 */
85 ClipGridLines = 16
86 };
87
88 //! Display flags
89 typedef QFlags<DisplayFlag> DisplayFlags;
90
91 /*!
92 \brief Grid attributes
93 \sa setGridAttributes(), testGridAttributes()
94 */
95 enum GridAttribute
96 {
97 /*!
98 When AutoScaling is enabled, the radial axes will be adjusted
99 to the interval, that is currently visible on the canvas plot.
100 */
101 AutoScaling = 0x01
102 };
103
104 //! Grid attributes
105 typedef QFlags<GridAttribute> GridAttributes;
106
107 explicit QwtPolarGrid();
108 virtual ~QwtPolarGrid();
109
110 virtual int rtti() const;
111
112 void setDisplayFlag( DisplayFlag, bool on = true );
113 bool testDisplayFlag( DisplayFlag ) const;
114
115 void setGridAttribute( GridAttribute, bool on = true );
116 bool testGridAttribute( GridAttribute ) const;
117
118 void showGrid( int scaleId, bool show = true );
119 bool isGridVisible( int scaleId ) const;
120
121 void showMinorGrid( int scaleId, bool show = true );
122 bool isMinorGridVisible( int scaleId ) const;
123
124 void showAxis( int axisId, bool show = true );
125 bool isAxisVisible( int axisId ) const;
126
127 void setPen( const QPen &p );
128 void setFont( const QFont & );
129
130 void setMajorGridPen( const QPen &p );
131 void setMajorGridPen( int scaleId, const QPen &p );
132 QPen majorGridPen( int scaleId ) const;
133
134 void setMinorGridPen( const QPen &p );
135 void setMinorGridPen( int scaleId, const QPen &p );
136 QPen minorGridPen( int scaleId ) const;
137
138 void setAxisPen( int axisId, const QPen &p );
139 QPen axisPen( int axisId ) const;
140
141 void setAxisFont( int axisId, const QFont &p );
142 QFont axisFont( int axisId ) const;
143
144 void setScaleDraw( int axisId, QwtScaleDraw * );
145 const QwtScaleDraw *scaleDraw( int axisId ) const;
146 QwtScaleDraw *scaleDraw( int axisId );
147
148 void setAzimuthScaleDraw( QwtRoundScaleDraw * );
149 const QwtRoundScaleDraw *azimuthScaleDraw() const;
150 QwtRoundScaleDraw *azimuthScaleDraw();
151
152 virtual void draw( QPainter *p,
153 const QwtScaleMap &azimuthMap, const QwtScaleMap &radialMap,
154 const QPointF &pole, double radius,
155 const QRectF &rect ) const;
156
157 virtual void updateScaleDiv( const QwtScaleDiv &azimuthMap,
158 const QwtScaleDiv &radialMap, const QwtInterval & );
159
160 virtual int marginHint() const;
161
162protected:
163 void drawRays( QPainter *, const QRectF &,
164 const QPointF &pole, double radius,
165 const QwtScaleMap &azimuthMap, const QList<double> & ) const;
166 void drawCircles( QPainter *, const QRectF &,
167 const QPointF &pole, const QwtScaleMap &radialMap,
168 const QList<double> & ) const;
169
170 void drawAxis( QPainter *, int axisId ) const;
171
172private:
173 void updateScaleDraws(
174 const QwtScaleMap &azimuthMap, const QwtScaleMap &radialMap,
175 const QPointF &pole, const double radius ) const;
176
177private:
178 class GridData;
179 class AxisData;
180 class PrivateData;
181 PrivateData *d_data;
182};
183
184Q_DECLARE_OPERATORS_FOR_FLAGS( QwtPolarGrid::DisplayFlags )
185Q_DECLARE_OPERATORS_FOR_FLAGS( QwtPolarGrid::GridAttributes )
186
187#endif
Note: See TracBrowser for help on using the repository browser.