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

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

update qwt and qwtpolar, many QT5 fixes (unfinished)

File size: 3.1 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_symbol.h>
20#include <qwt_polar_grid.h>
[6262]21#include <qwt_polar_canvas.h>
[4302]22
23#include "polarplot.h"
[4329]24#include "graphwin.h"
[4302]25
[4317]26// Draw Symbols (virtual) - change symbol's color
[4316]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 {
[4328]32 t_colorMap colorMap;
[4316]33 for (int ii = from; ii <= to; ii++) {
[8127]34 QwtSymbol ss(symbol.style());
35 ss.setSize(symbol.size());
[4334]36 const QwtPointPolar& point = sample(ii);
[4356]37 const QColor color = colorMap.color(_scaleInterval, point._value);
[4327]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
[4302]44// Constructor
45////////////////////////////////////////////////////////////////////////////
[4356]46t_polarPlot::t_polarPlot(const QwtText& title, const QwtInterval& scaleInterval,
47 QWidget* parent) : QwtPolarPlot(title, parent) {
[4302]48
[4356]49 _scaleInterval = scaleInterval;
[4345]50
[6262]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 }
[4302]60
[4319]61 setAzimuthOrigin(M_PI/2.0);
62
[4302]63 // Scales
64 // ------
[4322]65 setScale(QwtPolar::Radius, 0.0, 90.0);
66 setScale(QwtPolar::Azimuth, 360.0, 0.0, 30.0);
[4311]67
[4302]68 // Grids, Axes
69 // -----------
[4314]70 QwtPolarGrid* grid = new QwtPolarGrid();
71 grid->setPen(QPen(Qt::black));
[4302]72 for ( int scaleId = 0; scaleId < QwtPolar::ScaleCount; scaleId++ ) {
[4314]73 grid->showGrid(scaleId);
[4302]74 }
75
[4314]76 grid->setAxisPen(QwtPolar::AxisAzimuth, QPen(Qt::black));
[4302]77
[4314]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);
[4311]83
[4314]84 grid->showGrid(QwtPolar::Azimuth, true);
85 grid->showGrid(QwtPolar::Radius, true);
[4311]86
[4314]87 grid->attach(this);
[4334]88}
[4302]89
[4334]90//
91////////////////////////////////////////////////////////////////////////////
92void t_polarPlot::addCurve(QVector<t_polarPoint*>* data) {
93 t_polarCurve* curve = new t_polarCurve();
[4356]94 curve->setScaleInterval(_scaleInterval);
[4334]95 curve->setStyle(QwtPolarCurve::NoCurve); // draw only symbols
[4359]96 curve->setSymbol(new QwtSymbol(QwtSymbol::Ellipse, QBrush(Qt::red),
97 QPen(Qt::red), QSize(2, 2)));
[4334]98 t_polarData* polarData = new t_polarData(data);
99 curve->setData(polarData);
[4302]100 curve->attach(this);
101}
Note: See TracBrowser for help on using the repository browser.