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

Last change on this file since 10573 was 8127, checked in by stoecker, 8 years ago

update qwt and qwtpolar, many QT5 fixes (unfinished)

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