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

Last change on this file since 4336 was 4336, checked in by mervart, 12 years ago
File size: 2.7 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_symbol.h>
20#include <qwt_polar_grid.h>
21
22#include "polarplot.h"
23#include "graphwin.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 t_colorMap colorMap;
32 for (int ii = from; ii <= to; ii++) {
33 QwtSymbol ss(symbol);
34 const QwtPointPolar& point = sample(ii);
35 const QColor color = colorMap.color(QwtInterval(0.0, 1.0), point._value);
36 ss.setBrush(QBrush(color));
37 ss.setPen(QPen(color));
38 QwtPolarCurve::drawSymbols(painter, ss, azimuthMap, radialMap, pole, ii,ii);
39 }
40}
41
42// Constructor
43////////////////////////////////////////////////////////////////////////////
44t_polarPlot::t_polarPlot(QWidget* parent) :
45 QwtPolarPlot(QwtText("Polar Plot"), parent) {
46
47 setPlotBackground(Qt::white);
48
49 setAzimuthOrigin(M_PI/2.0);
50
51 // Scales
52 // ------
53 setScale(QwtPolar::Radius, 0.0, 90.0);
54 setScale(QwtPolar::Azimuth, 360.0, 0.0, 30.0);
55
56 // Grids, Axes
57 // -----------
58 QwtPolarGrid* grid = new QwtPolarGrid();
59 grid->setPen(QPen(Qt::black));
60 for ( int scaleId = 0; scaleId < QwtPolar::ScaleCount; scaleId++ ) {
61 grid->showGrid(scaleId);
62 }
63
64 grid->setAxisPen(QwtPolar::AxisAzimuth, QPen(Qt::black));
65
66 grid->showAxis(QwtPolar::AxisAzimuth, true);
67 grid->showAxis(QwtPolar::AxisTop, true);
68 grid->showAxis(QwtPolar::AxisBottom, false);
69 grid->showAxis(QwtPolar::AxisLeft, false);
70 grid->showAxis(QwtPolar::AxisRight, false);
71
72 grid->showGrid(QwtPolar::Azimuth, true);
73 grid->showGrid(QwtPolar::Radius, true);
74
75 grid->attach(this);
76}
77
78//
79////////////////////////////////////////////////////////////////////////////
80void t_polarPlot::addCurve(QVector<t_polarPoint*>* data) {
81 t_polarCurve* curve = new t_polarCurve();
82 curve->setStyle(QwtPolarCurve::NoCurve); // draw only symbols
83 curve->setSymbol(new QwtSymbol(QwtSymbol::Ellipse,
84 QBrush(Qt::red), QPen(Qt::red),
85 QSize(3, 3)));
86 t_polarData* polarData = new t_polarData(data);
87 curve->setData(polarData);
88 curve->attach(this);
89}
Note: See TracBrowser for help on using the repository browser.