[4659] | 1 | // Part of BNC, a utility for retrieving decoding and
|
---|
| 2 | // converting GNSS data streams from NTRIP broadcasters.
|
---|
| 3 | //
|
---|
| 4 | // Copyright (C) 2007
|
---|
| 5 | // German Federal Agency for Cartography and Geodesy (BKG)
|
---|
| 6 | // http://www.bkg.bund.de
|
---|
| 7 | // Czech Technical University Prague, Department of Geodesy
|
---|
| 8 | // http://www.fsv.cvut.cz
|
---|
| 9 | //
|
---|
| 10 | // Email: euref-ip@bkg.bund.de
|
---|
| 11 | //
|
---|
| 12 | // This program is free software; you can redistribute it and/or
|
---|
| 13 | // modify it under the terms of the GNU General Public License
|
---|
| 14 | // as published by the Free Software Foundation, version 2.
|
---|
| 15 | //
|
---|
| 16 | // This program is distributed in the hope that it will be useful,
|
---|
| 17 | // but WITHOUT ANY WARRANTY; without even the implied warranty of
|
---|
| 18 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
---|
| 19 | // GNU General Public License for more details.
|
---|
| 20 | //
|
---|
| 21 | // You should have received a copy of the GNU General Public License
|
---|
| 22 | // along with this program; if not, write to the Free Software
|
---|
| 23 | // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
---|
| 24 |
|
---|
| 25 | /* -------------------------------------------------------------------------
|
---|
| 26 | * BKG NTRIP Client
|
---|
| 27 | * -------------------------------------------------------------------------
|
---|
| 28 | *
|
---|
[4662] | 29 | * Class: t_elePlot
|
---|
[4659] | 30 | *
|
---|
[4662] | 31 | * Purpose: Plot satellite elevations
|
---|
[4659] | 32 | *
|
---|
| 33 | * Author: L. Mervart
|
---|
| 34 | *
|
---|
| 35 | * Created: 08-Sep-2012
|
---|
| 36 | *
|
---|
| 37 | * Changes:
|
---|
| 38 | *
|
---|
| 39 | * -----------------------------------------------------------------------*/
|
---|
| 40 |
|
---|
| 41 | #include <qwt_scale_draw.h>
|
---|
| 42 | #include <qwt_text.h>
|
---|
| 43 | #include <qwt_legend.h>
|
---|
[4665] | 44 | #include <qwt_plot_marker.h>
|
---|
[6261] | 45 | #include <qwt_plot_canvas.h>
|
---|
[4659] | 46 |
|
---|
[4662] | 47 | #include "eleplot.h"
|
---|
[4659] | 48 | #include "reqcanalyze.h"
|
---|
| 49 |
|
---|
| 50 | //
|
---|
| 51 | //////////////////////////////////////////////////////////////////////////////
|
---|
| 52 | class t_scaleDrawTime : public QwtScaleDraw {
|
---|
| 53 | public:
|
---|
| 54 | t_scaleDrawTime() {}
|
---|
| 55 | virtual QwtText label(double mjdX24) const {
|
---|
| 56 | bncTime epoTime; epoTime.setmjd(mjdX24/24.0);
|
---|
| 57 | return QwtText(epoTime.timestr(0,':').c_str());
|
---|
| 58 | }
|
---|
| 59 | };
|
---|
| 60 |
|
---|
| 61 | // Constructor
|
---|
| 62 | //////////////////////////////////////////////////////////////////////////////
|
---|
[6272] | 63 | t_elePlot::t_elePlot(QWidget* parent, const QMap<t_prn, t_plotData>& plotDataMap)
|
---|
[4659] | 64 | : QwtPlot(parent) {
|
---|
| 65 |
|
---|
| 66 | setCanvasBackground(QColor(Qt::white));
|
---|
[8127] | 67 | ((QwtPlotCanvas *)canvas())->setFrameStyle(QFrame::NoFrame | QFrame::Plain);
|
---|
[4659] | 68 |
|
---|
| 69 | // Axes
|
---|
| 70 | // ----
|
---|
| 71 | setAxisScaleDraw(QwtPlot::xBottom, new t_scaleDrawTime());
|
---|
| 72 | setAxisLabelRotation(QwtPlot::xBottom, -10.0);
|
---|
| 73 | setAxisLabelAlignment(QwtPlot::xBottom, Qt::AlignLeft | Qt::AlignBottom);
|
---|
[4661] | 74 | setAxisScale(QwtPlot::yLeft, 0.0, 90.0);
|
---|
[4659] | 75 |
|
---|
| 76 | // Legend
|
---|
| 77 | // ------
|
---|
| 78 | QwtLegend* legend = new QwtLegend;
|
---|
| 79 | insertLegend(legend, QwtPlot::RightLegend);
|
---|
| 80 |
|
---|
| 81 | // Curves
|
---|
| 82 | // ------
|
---|
[6272] | 83 | int numCurves = plotDataMap.size();
|
---|
[4664] | 84 | if (numCurves > 0) {
|
---|
| 85 | int iC = 0;
|
---|
[6272] | 86 | QMapIterator<t_prn, t_plotData> it(plotDataMap);
|
---|
[4664] | 87 | while (it.hasNext()) {
|
---|
| 88 | it.next();
|
---|
| 89 | ++iC;
|
---|
[6272] | 90 | QString prn = QString(it.key().toString().c_str());
|
---|
| 91 | const t_plotData& plotData = it.value();
|
---|
[4664] | 92 |
|
---|
| 93 | // Draw one curve
|
---|
| 94 | // --------------
|
---|
[6272] | 95 | if (plotData._mjdX24.size()) {
|
---|
| 96 | const QVector<double>& xData = plotData._mjdX24;
|
---|
| 97 | const QVector<double>& yData = plotData._eleDeg;
|
---|
[6537] | 98 | QColor color = QColor::fromHsv(int((iC-1)*(359.0/numCurves)), 255, 255);
|
---|
[4664] | 99 | QwtSymbol symbol(QwtSymbol::Rect, QBrush(color), QPen(color), QSize(1,1));
|
---|
| 100 | addCurve(prn, symbol, xData, yData);
|
---|
| 101 | }
|
---|
[4659] | 102 | }
|
---|
| 103 | }
|
---|
| 104 |
|
---|
| 105 | // Important !!!
|
---|
| 106 | // -------------
|
---|
| 107 | replot();
|
---|
| 108 | }
|
---|
| 109 |
|
---|
| 110 | // Add Curve
|
---|
| 111 | //////////////////////////////////////////////////////////////////////////////
|
---|
[4662] | 112 | QwtPlotCurve* t_elePlot::addCurve(const QString& name,
|
---|
[4659] | 113 | const QwtSymbol& symbol,
|
---|
| 114 | const QVector<double>& xData,
|
---|
| 115 | const QVector<double>& yData) {
|
---|
| 116 | QwtPlotCurve* curve = new QwtPlotCurve(name);
|
---|
[8127] | 117 | QwtSymbol *s = new QwtSymbol(symbol.style());
|
---|
| 118 | s->setSize(symbol.size());
|
---|
| 119 | s->setBrush(symbol.brush());
|
---|
| 120 | s->setPen(symbol.pen());
|
---|
| 121 | curve->setSymbol(s);
|
---|
[4659] | 122 | curve->setStyle(QwtPlotCurve::NoCurve);
|
---|
| 123 | curve->setXAxis(QwtPlot::xBottom);
|
---|
| 124 | curve->setYAxis(QwtPlot::yLeft);
|
---|
| 125 | curve->setSamples(xData, yData);
|
---|
| 126 | curve->attach(this);
|
---|
[4665] | 127 |
|
---|
| 128 | if (xData.size() > 0 && yData.size() > 0) {
|
---|
| 129 | QwtPlotMarker* marker = new QwtPlotMarker();
|
---|
| 130 | int ii = xData.size() / 2;
|
---|
| 131 | marker->setValue(xData[ii], yData[ii]);
|
---|
| 132 | QwtText text(name);
|
---|
| 133 | text.setColor(symbol.pen().color());
|
---|
| 134 | marker->setLabel(text);
|
---|
| 135 | marker->setLabelAlignment(Qt::AlignTop);
|
---|
| 136 | marker->attach(this);
|
---|
| 137 | }
|
---|
| 138 |
|
---|
[4659] | 139 | return curve;
|
---|
| 140 | }
|
---|