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

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