[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>
|
---|
| 21 |
|
---|
| 22 | #include "polarplot.h"
|
---|
[4329] | 23 | #include "graphwin.h"
|
---|
[4302] | 24 |
|
---|
[4317] | 25 | // Draw Symbols (virtual) - change symbol's color
|
---|
[4316] | 26 | ////////////////////////////////////////////////////////////////////////////
|
---|
| 27 | void t_polarCurve::drawSymbols(QPainter* painter, const QwtSymbol& symbol,
|
---|
| 28 | const QwtScaleMap& azimuthMap,
|
---|
| 29 | const QwtScaleMap& radialMap,
|
---|
| 30 | const QPointF& pole, int from, int to) const {
|
---|
[4328] | 31 | t_colorMap colorMap;
|
---|
[4316] | 32 | for (int ii = from; ii <= to; ii++) {
|
---|
[4317] | 33 | QwtSymbol ss(symbol);
|
---|
[4334] | 34 | const QwtPointPolar& point = sample(ii);
|
---|
[4327] | 35 | const QColor color = colorMap.color(QwtInterval(0.0, 1.0), point._value);
|
---|
| 36 | ss.setBrush(QBrush(color));
|
---|
| 37 | ss.setPen(QPen(color));
|
---|
[4317] | 38 | QwtPolarCurve::drawSymbols(painter, ss, azimuthMap, radialMap, pole, ii,ii);
|
---|
[4316] | 39 | }
|
---|
| 40 | }
|
---|
| 41 |
|
---|
[4302] | 42 | // Constructor
|
---|
| 43 | ////////////////////////////////////////////////////////////////////////////
|
---|
[4345] | 44 | t_polarPlot::t_polarPlot(const QwtText& title, QWidget* parent) :
|
---|
[4302] | 45 |
|
---|
[4345] | 46 | QwtPolarPlot(title, parent) {
|
---|
| 47 |
|
---|
[4313] | 48 | setPlotBackground(Qt::white);
|
---|
[4302] | 49 |
|
---|
[4319] | 50 | setAzimuthOrigin(M_PI/2.0);
|
---|
| 51 |
|
---|
[4302] | 52 | // Scales
|
---|
| 53 | // ------
|
---|
[4322] | 54 | setScale(QwtPolar::Radius, 0.0, 90.0);
|
---|
| 55 | setScale(QwtPolar::Azimuth, 360.0, 0.0, 30.0);
|
---|
[4311] | 56 |
|
---|
[4302] | 57 | // Grids, Axes
|
---|
| 58 | // -----------
|
---|
[4314] | 59 | QwtPolarGrid* grid = new QwtPolarGrid();
|
---|
| 60 | grid->setPen(QPen(Qt::black));
|
---|
[4302] | 61 | for ( int scaleId = 0; scaleId < QwtPolar::ScaleCount; scaleId++ ) {
|
---|
[4314] | 62 | grid->showGrid(scaleId);
|
---|
[4302] | 63 | }
|
---|
| 64 |
|
---|
[4314] | 65 | grid->setAxisPen(QwtPolar::AxisAzimuth, QPen(Qt::black));
|
---|
[4302] | 66 |
|
---|
[4314] | 67 | grid->showAxis(QwtPolar::AxisAzimuth, true);
|
---|
| 68 | grid->showAxis(QwtPolar::AxisTop, true);
|
---|
| 69 | grid->showAxis(QwtPolar::AxisBottom, false);
|
---|
| 70 | grid->showAxis(QwtPolar::AxisLeft, false);
|
---|
| 71 | grid->showAxis(QwtPolar::AxisRight, false);
|
---|
[4311] | 72 |
|
---|
[4314] | 73 | grid->showGrid(QwtPolar::Azimuth, true);
|
---|
| 74 | grid->showGrid(QwtPolar::Radius, true);
|
---|
[4311] | 75 |
|
---|
[4314] | 76 | grid->attach(this);
|
---|
[4334] | 77 | }
|
---|
[4302] | 78 |
|
---|
[4334] | 79 | //
|
---|
| 80 | ////////////////////////////////////////////////////////////////////////////
|
---|
| 81 | void t_polarPlot::addCurve(QVector<t_polarPoint*>* data) {
|
---|
| 82 | t_polarCurve* curve = new t_polarCurve();
|
---|
| 83 | curve->setStyle(QwtPolarCurve::NoCurve); // draw only symbols
|
---|
| 84 | curve->setSymbol(new QwtSymbol(QwtSymbol::Ellipse,
|
---|
| 85 | QBrush(Qt::red), QPen(Qt::red),
|
---|
| 86 | QSize(3, 3)));
|
---|
| 87 | t_polarData* polarData = new t_polarData(data);
|
---|
| 88 | curve->setData(polarData);
|
---|
[4302] | 89 | curve->attach(this);
|
---|
| 90 | }
|
---|