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

Last change on this file since 6715 was 6262, checked in by mervart, 10 years ago
File size: 3.1 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#include <qwt_polar_canvas.h>
22
23#include "polarplot.h"
24#include "graphwin.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 QwtPointPolar& point = sample(ii);
36 const QColor color = colorMap.color(_scaleInterval, point._value);
37 ss.setBrush(QBrush(color));
38 ss.setPen(QPen(color));
39 QwtPolarCurve::drawSymbols(painter, ss, azimuthMap, radialMap, pole, ii,ii);
40 }
41}
42
43// Constructor
44////////////////////////////////////////////////////////////////////////////
45t_polarPlot::t_polarPlot(const QwtText& title, const QwtInterval& scaleInterval,
46 QWidget* parent) : QwtPolarPlot(title, parent) {
47
48 _scaleInterval = scaleInterval;
49
50 if (false) {
51 setPlotBackground(Qt::white); // sets the background of the circle only
52 }
53 else {
54 canvas()->setAutoFillBackground(true);
55 QPalette palette = canvas()->palette();
56 palette.setColor(QPalette::Window, Qt::white);
57 canvas()->setPalette(palette);
58 }
59
60 setAzimuthOrigin(M_PI/2.0);
61
62 // Scales
63 // ------
64 setScale(QwtPolar::Radius, 0.0, 90.0);
65 setScale(QwtPolar::Azimuth, 360.0, 0.0, 30.0);
66
67 // Grids, Axes
68 // -----------
69 QwtPolarGrid* grid = new QwtPolarGrid();
70 grid->setPen(QPen(Qt::black));
71 for ( int scaleId = 0; scaleId < QwtPolar::ScaleCount; scaleId++ ) {
72 grid->showGrid(scaleId);
73 }
74
75 grid->setAxisPen(QwtPolar::AxisAzimuth, QPen(Qt::black));
76
77 grid->showAxis(QwtPolar::AxisAzimuth, true);
78 grid->showAxis(QwtPolar::AxisTop, true);
79 grid->showAxis(QwtPolar::AxisBottom, false);
80 grid->showAxis(QwtPolar::AxisLeft, false);
81 grid->showAxis(QwtPolar::AxisRight, false);
82
83 grid->showGrid(QwtPolar::Azimuth, true);
84 grid->showGrid(QwtPolar::Radius, true);
85
86 grid->attach(this);
87}
88
89//
90////////////////////////////////////////////////////////////////////////////
91void t_polarPlot::addCurve(QVector<t_polarPoint*>* data) {
92 t_polarCurve* curve = new t_polarCurve();
93 curve->setScaleInterval(_scaleInterval);
94 curve->setStyle(QwtPolarCurve::NoCurve); // draw only symbols
95 curve->setSymbol(new QwtSymbol(QwtSymbol::Ellipse, QBrush(Qt::red),
96 QPen(Qt::red), QSize(2, 2)));
97 t_polarData* polarData = new t_polarData(data);
98 curve->setData(polarData);
99 curve->attach(this);
100}
Note: See TracBrowser for help on using the repository browser.