source: ntrip/trunk/BNC/qwt/qwt_polar_grid.h

Last change on this file was 11158, checked in by stuerze, 4 weeks ago

deprecated functions exchanged libs updated

File size: 5.5 KB
Line 
1/******************************************************************************
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_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_EXPORT QwtPolarGrid : public QwtPolarItem
42{
43 public:
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 code.
84 */
85 ClipGridLines = 16
86 };
87
88 Q_DECLARE_FLAGS( DisplayFlags, DisplayFlag )
89
90 /*!
91 \brief Grid attributes
92 \sa setGridAttributes(), testGridAttributes()
93 */
94 enum GridAttribute
95 {
96 /*!
97 When AutoScaling is enabled, the radial axes will be adjusted
98 to the interval, that is currently visible on the canvas plot.
99 */
100 AutoScaling = 0x01
101 };
102
103 Q_DECLARE_FLAGS( GridAttributes, GridAttribute )
104
105 explicit QwtPolarGrid();
106 virtual ~QwtPolarGrid();
107
108 virtual int rtti() const QWT_OVERRIDE;
109
110 void setDisplayFlag( DisplayFlag, bool on = true );
111 bool testDisplayFlag( DisplayFlag ) const;
112
113 void setGridAttribute( GridAttribute, bool on = true );
114 bool testGridAttribute( GridAttribute ) const;
115
116 void showGrid( int scaleId, bool show = true );
117 bool isGridVisible( int scaleId ) const;
118
119 void showMinorGrid( int scaleId, bool show = true );
120 bool isMinorGridVisible( int scaleId ) const;
121
122 void showAxis( int axisId, bool show = true );
123 bool isAxisVisible( int axisId ) const;
124
125 void setPen( const QPen& p );
126 void setFont( const QFont& );
127
128 void setMajorGridPen( const QPen& p );
129 void setMajorGridPen( int scaleId, const QPen& p );
130 QPen majorGridPen( int scaleId ) const;
131
132 void setMinorGridPen( const QPen& p );
133 void setMinorGridPen( int scaleId, const QPen& p );
134 QPen minorGridPen( int scaleId ) const;
135
136 void setAxisPen( int axisId, const QPen& p );
137 QPen axisPen( int axisId ) const;
138
139 void setAxisFont( int axisId, const QFont& p );
140 QFont axisFont( int axisId ) const;
141
142 void setScaleDraw( int axisId, QwtScaleDraw* );
143 const QwtScaleDraw* scaleDraw( int axisId ) const;
144 QwtScaleDraw* scaleDraw( int axisId );
145
146 void setAzimuthScaleDraw( QwtRoundScaleDraw* );
147 const QwtRoundScaleDraw* azimuthScaleDraw() const;
148 QwtRoundScaleDraw* azimuthScaleDraw();
149
150 virtual void draw( QPainter* p,
151 const QwtScaleMap& azimuthMap, const QwtScaleMap& radialMap,
152 const QPointF& pole, double radius,
153 const QRectF& rect ) const QWT_OVERRIDE;
154
155 virtual void updateScaleDiv( const QwtScaleDiv& azimuthMap,
156 const QwtScaleDiv& radialMap, const QwtInterval& ) QWT_OVERRIDE;
157
158 virtual int marginHint() const QWT_OVERRIDE;
159
160 protected:
161 void drawRays( QPainter*, const QRectF&,
162 const QPointF& pole, double radius,
163 const QwtScaleMap& azimuthMap, const QList< double >& ) const;
164 void drawCircles( QPainter*, const QRectF&,
165 const QPointF& pole, const QwtScaleMap& radialMap,
166 const QList< double >& ) const;
167
168 void drawAxis( QPainter*, int axisId ) const;
169
170 private:
171 void updateScaleDraws(
172 const QwtScaleMap& azimuthMap, const QwtScaleMap& radialMap,
173 const QPointF& pole, const double radius ) const;
174
175 private:
176 class PrivateData;
177 PrivateData* m_data;
178};
179
180Q_DECLARE_OPERATORS_FOR_FLAGS( QwtPolarGrid::DisplayFlags )
181Q_DECLARE_OPERATORS_FOR_FLAGS( QwtPolarGrid::GridAttributes )
182
183#endif
Note: See TracBrowser for help on using the repository browser.