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

Last change on this file since 4334 was 4334, checked in by mervart, 12 years ago
File size: 2.8 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_series_data.h>
20#include <qwt_symbol.h>
21#include <qwt_polar_grid.h>
22#include <qwt_scale_widget.h>
23
24#include "polarplot.h"
25#include "graphwin.h"
26
27// Draw Symbols (virtual) - change symbol's color
28////////////////////////////////////////////////////////////////////////////
29void t_polarCurve::drawSymbols(QPainter* painter, const QwtSymbol& symbol,
30 const QwtScaleMap& azimuthMap,
31 const QwtScaleMap& radialMap,
32 const QPointF& pole, int from, int to) const {
33 t_colorMap colorMap;
34 for (int ii = from; ii <= to; ii++) {
35 QwtSymbol ss(symbol);
36 const QwtPointPolar& point = sample(ii);
37 const QColor color = colorMap.color(QwtInterval(0.0, 1.0), 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(QWidget* parent) :
47 QwtPolarPlot(QwtText("Polar Plot"), parent) {
48
49 setPlotBackground(Qt::white);
50
51 setAzimuthOrigin(M_PI/2.0);
52
53 // Scales
54 // ------
55 setScale(QwtPolar::Radius, 0.0, 90.0);
56 setScale(QwtPolar::Azimuth, 360.0, 0.0, 30.0);
57
58 // Grids, Axes
59 // -----------
60 QwtPolarGrid* grid = new QwtPolarGrid();
61 grid->setPen(QPen(Qt::black));
62 for ( int scaleId = 0; scaleId < QwtPolar::ScaleCount; scaleId++ ) {
63 grid->showGrid(scaleId);
64 }
65
66 grid->setAxisPen(QwtPolar::AxisAzimuth, QPen(Qt::black));
67
68 grid->showAxis(QwtPolar::AxisAzimuth, true);
69 grid->showAxis(QwtPolar::AxisTop, true);
70 grid->showAxis(QwtPolar::AxisBottom, false);
71 grid->showAxis(QwtPolar::AxisLeft, false);
72 grid->showAxis(QwtPolar::AxisRight, false);
73
74 grid->showGrid(QwtPolar::Azimuth, true);
75 grid->showGrid(QwtPolar::Radius, true);
76
77 grid->attach(this);
78}
79
80//
81////////////////////////////////////////////////////////////////////////////
82void t_polarPlot::addCurve(QVector<t_polarPoint*>* data) {
83 t_polarCurve* curve = new t_polarCurve();
84 curve->setStyle(QwtPolarCurve::NoCurve); // draw only symbols
85 curve->setSymbol(new QwtSymbol(QwtSymbol::Ellipse,
86 QBrush(Qt::red), QPen(Qt::red),
87 QSize(3, 3)));
88 t_polarData* polarData = new t_polarData(data);
89 curve->setData(polarData);
90 curve->attach(this);
91}
Note: See TracBrowser for help on using the repository browser.