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

Last change on this file since 11158 was 11158, checked in by stuerze, 3 days ago

deprecated functions exchanged libs updated

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