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
RevLine 
[4302]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>
[4328]22#include <qwt_scale_widget.h>
[4302]23
24#include "polarplot.h"
[4329]25#include "graphwin.h"
[4302]26
[4317]27// Draw Symbols (virtual) - change symbol's color
[4316]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 {
[4328]33 t_colorMap colorMap;
[4316]34 for (int ii = from; ii <= to; ii++) {
[4317]35 QwtSymbol ss(symbol);
[4331]36 const QwtPointPolar& point = sample(ii);
[4327]37 const QColor color = colorMap.color(QwtInterval(0.0, 1.0), point._value);
38 ss.setBrush(QBrush(color));
39 ss.setPen(QPen(color));
[4317]40 QwtPolarCurve::drawSymbols(painter, ss, azimuthMap, radialMap, pole, ii,ii);
[4316]41 }
42}
43
[4322]44// Sample (virtual) - this is for testing only
[4302]45////////////////////////////////////////////////////////////////////////////
[4331]46QwtPointPolar t_polarData::sample(size_t ii) const {
[4321]47 const QwtInterval zenithInterval(0.0, 90.0);
48 const QwtInterval azimuthInterval(0.0, 360.0 );
[4302]49
[4321]50 const double stepA = 4 * azimuthInterval.width() / _size;
51 const double aa = azimuthInterval.minValue() + ii * stepA;
[4302]52
[4321]53 const double stepR = zenithInterval.width() / _size;
54 const double rr = zenithInterval.minValue() + ii * stepR;
55
[4327]56 double value = static_cast<double>(ii) / _size;
[4322]57
[4331]58 QwtPointPolar point(aa,rr);
59 point._value = value;
60
61 return point;
[4320]62}
[4302]63
[4321]64//
[4302]65////////////////////////////////////////////////////////////////////////////
[4321]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)));
[4326]73 t_polarData* data = new t_polarData(numPoints);
[4331]74 curve->setData(data);
[4321]75 return curve;
[4320]76}
[4302]77
78// Constructor
79////////////////////////////////////////////////////////////////////////////
[4321]80t_polarPlot::t_polarPlot(QWidget* parent) :
81 QwtPolarPlot(QwtText("Polar Plot"), parent) {
[4302]82
[4313]83 setPlotBackground(Qt::white);
[4302]84
[4319]85 setAzimuthOrigin(M_PI/2.0);
86
[4302]87 // Scales
88 // ------
[4322]89 setScale(QwtPolar::Radius, 0.0, 90.0);
90 setScale(QwtPolar::Azimuth, 360.0, 0.0, 30.0);
[4311]91
[4302]92 // Grids, Axes
93 // -----------
[4314]94 QwtPolarGrid* grid = new QwtPolarGrid();
95 grid->setPen(QPen(Qt::black));
[4302]96 for ( int scaleId = 0; scaleId < QwtPolar::ScaleCount; scaleId++ ) {
[4314]97 grid->showGrid(scaleId);
[4302]98 }
99
[4314]100 grid->setAxisPen(QwtPolar::AxisAzimuth, QPen(Qt::black));
[4302]101
[4314]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);
[4311]107
[4314]108 grid->showGrid(QwtPolar::Azimuth, true);
109 grid->showGrid(QwtPolar::Radius, true);
[4311]110
[4314]111 grid->attach(this);
[4302]112
113 // Curves
114 // ------
[4316]115 t_polarCurve* curve = createCurve();
[4302]116 curve->attach(this);
117}
118
Note: See TracBrowser for help on using the repository browser.