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

Last change on this file since 4325 was 4325, checked in by mervart, 12 years ago
File size: 3.6 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 const t_polarData* polarData = reinterpret_cast<const t_polarData*>(data());
34 const t_polarPoint& point = polarData->sample(ii);
35 if (point._value == 1) {
36 ss.setBrush(QBrush(Qt::red));
37 ss.setPen(QPen(Qt::red));
38 }
39 else {
40 ss.setBrush(QBrush(Qt::blue));
41 ss.setPen(QPen(Qt::blue));
42 }
43 QwtPolarCurve::drawSymbols(painter, ss, azimuthMap, radialMap, pole, ii,ii);
44 }
45}
46
47// Sample (virtual) - this is for testing only
48////////////////////////////////////////////////////////////////////////////
49t_polarPoint t_polarData::sample(size_t ii) const {
50 const QwtInterval zenithInterval(0.0, 90.0);
51 const QwtInterval azimuthInterval(0.0, 360.0 );
52
53 const double stepA = 4 * azimuthInterval.width() / _size;
54 const double aa = azimuthInterval.minValue() + ii * stepA;
55
56 const double stepR = zenithInterval.width() / _size;
57 const double rr = zenithInterval.minValue() + ii * stepR;
58
59 double value = 0.0;
60 if (ii % 3 == 0) {
61 value = 1.0;
62 }
63
64 return t_polarPoint(aa, rr, value);
65}
66
67//
68////////////////////////////////////////////////////////////////////////////
69t_polarCurve* t_polarPlot::createCurve() const {
70 const int numPoints = 200;
71 t_polarCurve* curve = new t_polarCurve();
72 curve->setStyle(QwtPolarCurve::NoCurve); // draw only symbols
73 curve->setSymbol(new QwtSymbol(QwtSymbol::Ellipse,
74 QBrush(Qt::red), QPen(Qt::red),
75 QSize(3, 3)));
76 QwtSeriesData<t_polarPoint>* data = new t_polarData(numPoints);
77 curve->setData(reinterpret_cast<QwtSeriesData<QwtPointPolar>*>(data));
78 return curve;
79}
80
81// Constructor
82////////////////////////////////////////////////////////////////////////////
83t_polarPlot::t_polarPlot(QWidget* parent) :
84 QwtPolarPlot(QwtText("Polar Plot"), parent) {
85
86 setPlotBackground(Qt::white);
87
88 setAzimuthOrigin(M_PI/2.0);
89
90 // Scales
91 // ------
92 setScale(QwtPolar::Radius, 0.0, 90.0);
93 setScale(QwtPolar::Azimuth, 360.0, 0.0, 30.0);
94
95 // Grids, Axes
96 // -----------
97 QwtPolarGrid* grid = new QwtPolarGrid();
98 grid->setPen(QPen(Qt::black));
99 for ( int scaleId = 0; scaleId < QwtPolar::ScaleCount; scaleId++ ) {
100 grid->showGrid(scaleId);
101 }
102
103 grid->setAxisPen(QwtPolar::AxisAzimuth, QPen(Qt::black));
104
105 grid->showAxis(QwtPolar::AxisAzimuth, true);
106 grid->showAxis(QwtPolar::AxisTop, true);
107 grid->showAxis(QwtPolar::AxisBottom, false);
108 grid->showAxis(QwtPolar::AxisLeft, false);
109 grid->showAxis(QwtPolar::AxisRight, false);
110
111 grid->showGrid(QwtPolar::Azimuth, true);
112 grid->showGrid(QwtPolar::Radius, true);
113
114 grid->attach(this);
115
116 // Curves
117 // ------
118 t_polarCurve* curve = createCurve();
119 curve->attach(this);
120}
121
Note: See TracBrowser for help on using the repository browser.