source: ntrip/trunk/BNC/src/rinex/availplot.cpp@ 9158

Last change on this file since 9158 was 8561, checked in by mervart, 6 years ago

Analyze more than two signals

File size: 6.2 KB
RevLine 
[4636]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.
[4578]24
[4636]25/* -------------------------------------------------------------------------
26 * BKG NTRIP Client
27 * -------------------------------------------------------------------------
28 *
29 * Class: t_availPlot
30 *
31 * Purpose: Plot with satellite availability
32 *
33 * Author: L. Mervart
34 *
35 * Created: 30-Aug-2012
36 *
37 * Changes:
38 *
39 * -----------------------------------------------------------------------*/
40
[4586]41#include <qwt_scale_draw.h>
42#include <qwt_text.h>
[4610]43#include <qwt_legend.h>
[6261]44#include <qwt_plot_canvas.h>
[4578]45
46#include "availplot.h"
[4584]47#include "reqcanalyze.h"
[4578]48
[4586]49//
50//////////////////////////////////////////////////////////////////////////////
[4587]51class t_scaleDrawTime : public QwtScaleDraw {
[4586]52 public:
[4587]53 t_scaleDrawTime() {}
[4617]54 virtual QwtText label(double mjdX24) const {
55 bncTime epoTime; epoTime.setmjd(mjdX24/24.0);
[4586]56 return QwtText(epoTime.timestr(0,':').c_str());
57 }
58};
59
60//
61//////////////////////////////////////////////////////////////////////////////
[4587]62class t_scaleDrawPrn : public QwtScaleDraw {
63 public:
64 t_scaleDrawPrn() {}
[6539]65 virtual QwtText label(double iPrn) const {
[6542]66 return _yLabels[int(iPrn)];
[4587]67 }
68 QMap<int, QString> _yLabels;
69};
70
71// Constructor
72//////////////////////////////////////////////////////////////////////////////
[6272]73t_availPlot::t_availPlot(QWidget* parent, const QMap<t_prn, t_plotData>& plotDataMap) :
74QwtPlot(parent) {
[4578]75
[4579]76 setCanvasBackground(QColor(Qt::white));
[8127]77 ((QwtPlotCanvas *)canvas())->setFrameStyle(QFrame::NoFrame | QFrame::Plain);
[4579]78
[4578]79 // Axes
80 // ----
[4587]81 setAxisScaleDraw(QwtPlot::xBottom, new t_scaleDrawTime());
[4589]82 setAxisLabelRotation(QwtPlot::xBottom, -10.0);
[4586]83 setAxisLabelAlignment(QwtPlot::xBottom, Qt::AlignLeft | Qt::AlignBottom);
84
[4587]85 t_scaleDrawPrn* scaleDrawPrn = new t_scaleDrawPrn();
86 setAxisScaleDraw(QwtPlot::yLeft, scaleDrawPrn);
[4578]87
[4618]88 // Smaller Font for y-Axis
89 // -----------------------
90 QFont yFont = axisFont(QwtPlot::yLeft);
91 yFont.setPointSize(yFont.pointSize()/2);
92 setAxisFont(QwtPlot::yLeft, yFont);
93
[4593]94 // Symbols
95 // -------
[4604]96 QColor red(220,20,60);
97 QColor green(150,200,50);
98 QColor blue(60,100,200);
[4614]99 QwtSymbol symbRed(QwtSymbol::Rect, QBrush(red), QPen(red), QSize(2,1));
100 QwtSymbol symbGreen(QwtSymbol::Rect, QBrush(green), QPen(green), QSize(2,1));
101 QwtSymbol symbBlue (QwtSymbol::Rect, QBrush(blue), QPen(blue), QSize(2,1));
[4610]102
103 // Legend
104 // ------
105 QwtLegend* legend = new QwtLegend;
106 insertLegend(legend, QwtPlot::RightLegend);
[4611]107
108 QVector<double> xData0(0);
109 QVector<double> yData0(0);
[4613]110 addCurve("OK ", symbGreen, xData0, yData0);
111 addCurve("Gap ", symbBlue, xData0, yData0);
112 addCurve("Slip", symbRed, xData0, yData0);
[4593]113
[4578]114 // Curves
115 // ------
116 int iC = 0;
[6272]117 QMapIterator<t_prn, t_plotData > it(plotDataMap);
[4578]118 while (it.hasNext()) {
119 it.next();
120 ++iC;
[6272]121 QString prn = QString(it.key().toString().c_str());
122 const t_plotData& plotData = it.value();
[4578]123
[4587]124 scaleDrawPrn->_yLabels[iC] = prn;
125
[8561]126 double eps = -0.1;
[4593]127
[8555]128 for (QMap<char, t_plotData::t_hlpStatus >::const_iterator it = plotData._status.begin();
129 it != plotData._status.end(); it++) {
[4596]130
[8555]131 const t_plotData::t_hlpStatus& status = it.value();
[4598]132
[8555]133 // OK Curve
134 // --------
135 if (status._ok.size()) {
136 const QVector<double>& xData = status._ok;
137 QVector<double> yData(xData.size(), double(iC)+eps);
138 QwtPlotCurve* curve = addCurve(prn, symbGreen, xData, yData);
139 curve->setItemAttribute(QwtPlotItem::Legend, false);
140 }
141
142 // Gaps Curve
143 // ----------
144 if (status._gap.size()) {
145 const QVector<double>& xData = status._gap;
146 QVector<double> yData(xData.size(), double(iC)+eps);
147 QwtPlotCurve* curve = addCurve(prn, symbBlue, xData, yData);
148 curve->setItemAttribute(QwtPlotItem::Legend, false);
149 }
150
151 // Slips Curve
152 // -----------
153 if (status._slip.size()) {
154 const QVector<double>& xData = status._slip;
155 QVector<double> yData(xData.size(), double(iC)+eps);
156 QwtPlotCurve* curve = addCurve(prn, symbRed, xData, yData);
157 curve->setItemAttribute(QwtPlotItem::Legend, false);
158 }
[4598]159
[8561]160 eps += 0.2;
[4598]161 }
[4578]162 }
[4588]163
164 QList<double> ticks[QwtScaleDiv::NTickTypes];
165 QList<double> &majorTicks = ticks[QwtScaleDiv::MajorTick];
[4589]166 QMapIterator<int, QString> itT(scaleDrawPrn->_yLabels);
167 while (itT.hasNext()) {
168 itT.next();
169 majorTicks << double(itT.key());
[4588]170 }
171 QwtScaleDiv yScaleDiv(majorTicks.first()-0.5, majorTicks.last()+0.5, ticks );
172 setAxisScaleDiv(QwtPlot::yLeft, yScaleDiv);
[4581]173
[4582]174 // Important !!!
175 // -------------
[4581]176 replot();
[4578]177}
178
[4595]179// Add Curve
180//////////////////////////////////////////////////////////////////////////////
[4610]181QwtPlotCurve* t_availPlot::addCurve(const QString& name,
[4613]182 const QwtSymbol& symbol,
[4610]183 const QVector<double>& xData,
184 const QVector<double>& yData) {
[4595]185 QwtPlotCurve* curve = new QwtPlotCurve(name);
[8127]186 QwtSymbol *s = new QwtSymbol(symbol.style());
187 s->setSize(symbol.size());
188 s->setBrush(symbol.brush());
189 s->setPen(symbol.pen());
190 curve->setSymbol(s);
[4595]191 curve->setStyle(QwtPlotCurve::NoCurve);
192 curve->setXAxis(QwtPlot::xBottom);
193 curve->setYAxis(QwtPlot::yLeft);
194 curve->setSamples(xData, yData);
195 curve->attach(this);
[4610]196 return curve;
[4595]197}
Note: See TracBrowser for help on using the repository browser.