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

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