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

Last change on this file since 4328 was 4328, checked in by mervart, 12 years ago
File size: 3.8 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
26// Draw Symbols (virtual) - change symbol's color
27////////////////////////////////////////////////////////////////////////////
28void t_polarCurve::drawSymbols(QPainter* painter, const QwtSymbol& symbol,
29 const QwtScaleMap& azimuthMap,
30 const QwtScaleMap& radialMap,
31 const QPointF& pole, int from, int to) const {
32 t_colorMap colorMap;
33 for (int ii = from; ii <= to; ii++) {
34 QwtSymbol ss(symbol);
35 const t_polarData* polarData = reinterpret_cast<const t_polarData*>(data());
36 const t_polarPoint& point = polarData->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////////////////////////////////////////////////////////////////////////////
46t_polarPoint 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 return t_polarPoint(aa, rr, value);
59}
60
61//
62////////////////////////////////////////////////////////////////////////////
63t_polarCurve* t_polarPlot::createCurve() const {
64 const int numPoints = 200;
65 t_polarCurve* curve = new t_polarCurve();
66 curve->setStyle(QwtPolarCurve::NoCurve); // draw only symbols
67 curve->setSymbol(new QwtSymbol(QwtSymbol::Ellipse,
68 QBrush(Qt::red), QPen(Qt::red),
69 QSize(3, 3)));
70 t_polarData* data = new t_polarData(numPoints);
71 curve->setData(reinterpret_cast<QwtSeriesData<QwtPointPolar>*>(data));
72 return curve;
73}
74
75// Constructor
76////////////////////////////////////////////////////////////////////////////
77t_polarPlot::t_polarPlot(QWidget* parent) :
78 QwtPolarPlot(QwtText("Polar Plot"), parent) {
79
80 setPlotBackground(Qt::white);
81
82 setAzimuthOrigin(M_PI/2.0);
83
84 // Scales
85 // ------
86 setScale(QwtPolar::Radius, 0.0, 90.0);
87 setScale(QwtPolar::Azimuth, 360.0, 0.0, 30.0);
88
89 // Grids, Axes
90 // -----------
91 QwtPolarGrid* grid = new QwtPolarGrid();
92 grid->setPen(QPen(Qt::black));
93 for ( int scaleId = 0; scaleId < QwtPolar::ScaleCount; scaleId++ ) {
94 grid->showGrid(scaleId);
95 }
96
97 grid->setAxisPen(QwtPolar::AxisAzimuth, QPen(Qt::black));
98
99 grid->showAxis(QwtPolar::AxisAzimuth, true);
100 grid->showAxis(QwtPolar::AxisTop, true);
101 grid->showAxis(QwtPolar::AxisBottom, false);
102 grid->showAxis(QwtPolar::AxisLeft, false);
103 grid->showAxis(QwtPolar::AxisRight, false);
104
105 grid->showGrid(QwtPolar::Azimuth, true);
106 grid->showGrid(QwtPolar::Radius, true);
107
108 grid->attach(this);
109
110 _colorMap = new t_colorMap();
111 QwtScaleWidget* colorScale = new QwtScaleWidget(this);
112 colorScale->setAlignment(QwtScaleDraw::RightScale);
113 colorScale->setColorBarEnabled(true);
114 colorScale->setColorMap(QwtInterval(0.0,1.0), _colorMap);
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.