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

Last change on this file since 6398 was 6262, checked in by mervart, 10 years ago
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++) {
[4317]34 QwtSymbol ss(symbol);
[4334]35 const QwtPointPolar& point = sample(ii);
[4356]36 const QColor color = colorMap.color(_scaleInterval, point._value);
[4327]37 ss.setBrush(QBrush(color));
38 ss.setPen(QPen(color));
[4317]39 QwtPolarCurve::drawSymbols(painter, ss, azimuthMap, radialMap, pole, ii,ii);
[4316]40 }
41}
42
[4302]43// Constructor
44////////////////////////////////////////////////////////////////////////////
[4356]45t_polarPlot::t_polarPlot(const QwtText& title, const QwtInterval& scaleInterval,
46 QWidget* parent) : QwtPolarPlot(title, parent) {
[4302]47
[4356]48 _scaleInterval = scaleInterval;
[4345]49
[6262]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 }
[4302]59
[4319]60 setAzimuthOrigin(M_PI/2.0);
61
[4302]62 // Scales
63 // ------
[4322]64 setScale(QwtPolar::Radius, 0.0, 90.0);
65 setScale(QwtPolar::Azimuth, 360.0, 0.0, 30.0);
[4311]66
[4302]67 // Grids, Axes
68 // -----------
[4314]69 QwtPolarGrid* grid = new QwtPolarGrid();
70 grid->setPen(QPen(Qt::black));
[4302]71 for ( int scaleId = 0; scaleId < QwtPolar::ScaleCount; scaleId++ ) {
[4314]72 grid->showGrid(scaleId);
[4302]73 }
74
[4314]75 grid->setAxisPen(QwtPolar::AxisAzimuth, QPen(Qt::black));
[4302]76
[4314]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);
[4311]82
[4314]83 grid->showGrid(QwtPolar::Azimuth, true);
84 grid->showGrid(QwtPolar::Radius, true);
[4311]85
[4314]86 grid->attach(this);
[4334]87}
[4302]88
[4334]89//
90////////////////////////////////////////////////////////////////////////////
91void t_polarPlot::addCurve(QVector<t_polarPoint*>* data) {
92 t_polarCurve* curve = new t_polarCurve();
[4356]93 curve->setScaleInterval(_scaleInterval);
[4334]94 curve->setStyle(QwtPolarCurve::NoCurve); // draw only symbols
[4359]95 curve->setSymbol(new QwtSymbol(QwtSymbol::Ellipse, QBrush(Qt::red),
96 QPen(Qt::red), QSize(2, 2)));
[4334]97 t_polarData* polarData = new t_polarData(data);
98 curve->setData(polarData);
[4302]99 curve->attach(this);
100}
Note: See TracBrowser for help on using the repository browser.