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

Last change on this file since 10126 was 9847, checked in by stuerze, 2 years ago

minor changes

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 *
[9847]37 * Changes:
[4636]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//////////////////////////////////////////////////////////////////////////////
[9847]73t_availPlot::t_availPlot(QWidget* parent, const QMap<t_prn, t_plotData>& plotDataMap) :
[6272]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);
[9847]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 }
[9847]141
[8555]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 }
[9847]150
[8555]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
[9847]160 updateLegend();
161
[8561]162 eps += 0.2;
[4598]163 }
[4578]164 }
[9847]165
[4588]166 QList<double> ticks[QwtScaleDiv::NTickTypes];
167 QList<double> &majorTicks = ticks[QwtScaleDiv::MajorTick];
[4589]168 QMapIterator<int, QString> itT(scaleDrawPrn->_yLabels);
169 while (itT.hasNext()) {
170 itT.next();
171 majorTicks << double(itT.key());
[4588]172 }
173 QwtScaleDiv yScaleDiv(majorTicks.first()-0.5, majorTicks.last()+0.5, ticks );
174 setAxisScaleDiv(QwtPlot::yLeft, yScaleDiv);
[4581]175
[4582]176 // Important !!!
177 // -------------
[4581]178 replot();
[4578]179}
180
[4595]181// Add Curve
182//////////////////////////////////////////////////////////////////////////////
[9847]183QwtPlotCurve* t_availPlot::addCurve(const QString& name,
[4613]184 const QwtSymbol& symbol,
[4610]185 const QVector<double>& xData,
186 const QVector<double>& yData) {
[4595]187 QwtPlotCurve* curve = new QwtPlotCurve(name);
[8127]188 QwtSymbol *s = new QwtSymbol(symbol.style());
189 s->setSize(symbol.size());
190 s->setBrush(symbol.brush());
191 s->setPen(symbol.pen());
192 curve->setSymbol(s);
[4595]193 curve->setStyle(QwtPlotCurve::NoCurve);
194 curve->setXAxis(QwtPlot::xBottom);
195 curve->setYAxis(QwtPlot::yLeft);
196 curve->setSamples(xData, yData);
197 curve->attach(this);
[4610]198 return curve;
[4595]199}
Note: See TracBrowser for help on using the repository browser.