source: ntrip/trunk/BNC/src/rinex/polarplot.cpp@ 4321

Last change on this file since 4321 was 4321, checked in by mervart, 12 years ago
File size: 3.4 KB
Line 
1
2/* -------------------------------------------------------------------------
3 * BKG NTRIP Client
4 * -------------------------------------------------------------------------
5 *
6 * Class: t_polarPlot
7 *
8 * Purpose: Polar Plot
9 *
10 * Author: L. Mervart
11 *
12 * Created: 23-Jun-2012
13 *
14 * Changes:
15 *
16 * -----------------------------------------------------------------------*/
17
18#include <qpen.h>
19#include <qwt_series_data.h>
20#include <qwt_symbol.h>
21#include <qwt_polar_grid.h>
22
23#include "polarplot.h"
24
25// Draw Symbols (virtual) - change symbol's color
26////////////////////////////////////////////////////////////////////////////
27void t_polarCurve::drawSymbols(QPainter* painter, const QwtSymbol& symbol,
28 const QwtScaleMap& azimuthMap,
29 const QwtScaleMap& radialMap,
30 const QPointF& pole, int from, int to) const {
31 for (int ii = from; ii <= to; ii++) {
32 QwtSymbol ss(symbol);
33 if (ii % 2 == 0) {
34 ss.setBrush(QBrush(Qt::red));
35 ss.setPen(QPen(Qt::red));
36 }
37 else {
38 ss.setBrush(QBrush(Qt::blue));
39 ss.setPen(QPen(Qt::blue));
40 }
41 QwtPolarCurve::drawSymbols(painter, ss, azimuthMap, radialMap, pole, ii,ii);
42 }
43}
44
45// Sample (virtual)
46////////////////////////////////////////////////////////////////////////////
47t_polarPoint t_polarData::sample(size_t ii) const {
48 const QwtInterval zenithInterval(0.0, 90.0);
49 const QwtInterval azimuthInterval(0.0, 360.0 );
50
51 const double stepA = 4 * azimuthInterval.width() / _size;
52 const double aa = azimuthInterval.minValue() + ii * stepA;
53
54 const double stepR = zenithInterval.width() / _size;
55 const double rr = zenithInterval.minValue() + ii * stepR;
56
57 return t_polarPoint(aa, rr);
58}
59
60//
61////////////////////////////////////////////////////////////////////////////
62t_polarCurve* t_polarPlot::createCurve() const {
63 const int numPoints = 200;
64 t_polarCurve* curve = new t_polarCurve();
65 curve->setStyle(QwtPolarCurve::NoCurve); // draw only symbols
66 curve->setSymbol(new QwtSymbol(QwtSymbol::Ellipse,
67 QBrush(Qt::red), QPen(Qt::red),
68 QSize(3, 3)));
69 QwtSeriesData<t_polarPoint>* data = new t_polarData(numPoints);
70 curve->setData((QwtSeriesData<QwtPointPolar>*) data);
71 return curve;
72}
73
74// Constructor
75////////////////////////////////////////////////////////////////////////////
76t_polarPlot::t_polarPlot(QWidget* parent) :
77 QwtPolarPlot(QwtText("Polar Plot"), parent) {
78
79 setPlotBackground(Qt::white);
80
81 setAzimuthOrigin(M_PI/2.0);
82
83 // Scales
84 // ------
85 setScale(QwtPolar::Radius, 0.0, 90.0);
86 setScale(QwtPolar::Azimuth, 360.0, 0, 30.0);
87
88 // Grids, Axes
89 // -----------
90 QwtPolarGrid* grid = new QwtPolarGrid();
91 grid->setPen(QPen(Qt::black));
92 for ( int scaleId = 0; scaleId < QwtPolar::ScaleCount; scaleId++ ) {
93 grid->showGrid(scaleId);
94 }
95
96 grid->setAxisPen(QwtPolar::AxisAzimuth, QPen(Qt::black));
97
98 grid->showAxis(QwtPolar::AxisAzimuth, true);
99 grid->showAxis(QwtPolar::AxisTop, true);
100 grid->showAxis(QwtPolar::AxisBottom, false);
101 grid->showAxis(QwtPolar::AxisLeft, false);
102 grid->showAxis(QwtPolar::AxisRight, false);
103
104 grid->showGrid(QwtPolar::Azimuth, true);
105 grid->showGrid(QwtPolar::Radius, true);
106
107 grid->attach(this);
108
109 // Curves
110 // ------
111 t_polarCurve* curve = createCurve();
112 curve->attach(this);
113}
114
Note: See TracBrowser for help on using the repository browser.