Changeset 4311 in ntrip
- Timestamp:
- Jun 23, 2012, 2:26:04 PM (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/BNC/src/rinex/polarplot.cpp
r4309 r4311 27 27 #include "polarplot.h" 28 28 29 const QwtInterval radialInterval( 0.0, 10.0);30 const QwtInterval azimuthInterval( 0.0, 360.0);29 const QwtInterval zenithInterval(0.0, 90.0); 30 const QwtInterval azimuthInterval(0.0, 360.0); 31 31 32 // 32 // Data Class 33 33 //////////////////////////////////////////////////////////////////////////// 34 34 class Data: public QwtSeriesData<QwtPointPolar> { 35 35 public: 36 Data( const QwtInterval &radialInterval, 37 const QwtInterval &azimuthInterval, size_t size ): 38 _radialInterval( radialInterval ), 39 _azimuthInterval( azimuthInterval ), 40 _size( size ) {} 36 Data(const QwtInterval &zenithInterval, 37 const QwtInterval &azimuthInterval, size_t size) : 38 _zenithInterval(zenithInterval), _azimuthInterval(azimuthInterval), 39 _size(size) {} 41 40 42 41 virtual size_t size() const {return _size;} 43 42 44 43 protected: 45 QwtInterval _ radialInterval;44 QwtInterval _zenithInterval; 46 45 QwtInterval _azimuthInterval; 47 46 size_t _size; 48 47 }; 49 48 50 // 49 // Spiral Data Class 51 50 //////////////////////////////////////////////////////////////////////////// 52 51 class SpiralData: public Data { 53 52 public: 54 SpiralData( const QwtInterval &radialInterval,55 const QwtInterval &azimuthInterval, size_t size ):56 Data( radialInterval, azimuthInterval, size) {}53 SpiralData(const QwtInterval &zenithInterval, 54 const QwtInterval &azimuthInterval, size_t size) : 55 Data(zenithInterval, azimuthInterval, size) {} 57 56 58 virtual QwtPointPolar sample(size_t i ) const {57 virtual QwtPointPolar sample(size_t ii) const { 59 58 const double stepA = 4 * _azimuthInterval.width() / _size; 60 const double a = _azimuthInterval.minValue() +i * stepA;59 const double aa = _azimuthInterval.minValue() + ii * stepA; 61 60 62 const double stepR = _ radialInterval.width() / _size;63 const double r = _radialInterval.minValue() +i * stepR;61 const double stepR = _zenithInterval.width() / _size; 62 const double rr = _zenithInterval.minValue() + ii * stepR; 64 63 65 return QwtPointPolar( a, r);64 return QwtPointPolar(aa, rr); 66 65 } 67 66 68 67 virtual QRectF boundingRect() const { 69 if ( d_boundingRect.width() < 0.0) {70 d_boundingRect = qwtBoundingRect( *this);68 if (d_boundingRect.width() < 0.0) { 69 d_boundingRect = qwtBoundingRect(*this); 71 70 } 72 71 return d_boundingRect; … … 77 76 //////////////////////////////////////////////////////////////////////////// 78 77 t_polarPlot::t_polarPlot( QWidget *parent ) : 79 QwtPolarPlot(QwtText("Polar Plot"), parent 78 QwtPolarPlot(QwtText("Polar Plot"), parent) { 80 79 81 /// setAutoReplot(false);82 80 setPlotBackground(Qt::darkBlue); 83 81 84 82 // Scales 85 83 // ------ 84 setScale(QwtPolar::Radius, 85 zenithInterval.minValue(), zenithInterval.maxValue()); 86 86 87 setScale(QwtPolar::Azimuth, 87 88 azimuthInterval.minValue(), azimuthInterval.maxValue(), 88 89 azimuthInterval.width() / 12); 89 90 90 setScaleMaxMinor( QwtPolar::Azimuth, 2 ); 91 setScale( QwtPolar::Radius, 92 radialInterval.minValue(), radialInterval.maxValue() ); 91 setScaleMaxMinor(QwtPolar::Azimuth, 2); 93 92 94 93 // Grids, Axes 95 94 // ----------- 96 95 _grid = new QwtPolarGrid(); 97 _grid->setPen( QPen( Qt::white ));96 _grid->setPen(QPen(Qt::white)); 98 97 for ( int scaleId = 0; scaleId < QwtPolar::ScaleCount; scaleId++ ) { 99 98 _grid->showGrid( scaleId ); 100 99 _grid->showMinorGrid( scaleId ); 101 102 100 QPen minorPen( Qt::gray ); 103 _grid->setMinorGridPen( scaleId, minorPen);101 _grid->setMinorGridPen(scaleId, minorPen); 104 102 } 105 103 106 _grid->setAxisPen( QwtPolar::AxisAzimuth, QPen( Qt::black ));104 _grid->setAxisPen(QwtPolar::AxisAzimuth, QPen(Qt::black)); 107 105 108 _grid->showAxis( QwtPolar::AxisAzimuth, true ); 109 _grid->showAxis( QwtPolar::AxisLeft, false ); 110 _grid->showAxis( QwtPolar::AxisRight, true ); 111 _grid->showAxis( QwtPolar::AxisTop, true ); 112 _grid->showAxis( QwtPolar::AxisBottom, false ); 113 _grid->showGrid( QwtPolar::Azimuth, true ); 114 _grid->showGrid( QwtPolar::Radius, true ); 106 _grid->showAxis(QwtPolar::AxisAzimuth, true ); 107 _grid->showAxis(QwtPolar::AxisLeft, false); 108 _grid->showAxis(QwtPolar::AxisRight, true); 109 _grid->showAxis(QwtPolar::AxisTop, true); 110 _grid->showAxis(QwtPolar::AxisBottom, false); 111 112 _grid->showGrid(QwtPolar::Azimuth, true); 113 _grid->showGrid(QwtPolar::Radius, true); 114 115 115 _grid->attach( this ); 116 116 … … 124 124 // ------ 125 125 QwtLegend *legend = new QwtLegend; 126 insertLegend( legend, QwtPolarPlot::BottomLegend);126 insertLegend(legend, QwtPolarPlot::BottomLegend); 127 127 } 128 128 … … 136 136 QwtPolarCurve* t_polarPlot::createCurve() const { 137 137 const int numPoints = 200; 138 139 138 QwtPolarCurve* curve = new QwtPolarCurve(); 140 curve->setStyle( QwtPolarCurve::Lines);141 curve->setTitle( "Spiral");142 curve->setPen( QPen( Qt::yellow, 2 ));139 curve->setStyle(QwtPolarCurve::Lines); 140 curve->setTitle("Example Curve"); 141 curve->setPen(QPen( Qt::yellow, 2)); 143 142 curve->setSymbol(new QwtSymbol(QwtSymbol::Rect, 144 QBrush(Qt::cyan), QPen(Qt::white), QSize(3, 3)));145 curve->setData(146 new SpiralData( radialInterval, azimuthInterval, numPoints ));143 QBrush(Qt::cyan), QPen(Qt::white), 144 QSize(3, 3))); 145 curve->setData(new SpiralData(zenithInterval, azimuthInterval, numPoints)); 147 146 return curve; 148 147 }
Note:
See TracChangeset
for help on using the changeset viewer.