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

Last change on this file since 4668 was 4668, checked in by mervart, 12 years ago
File size: 7.1 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>
[4578]44
45#include "availplot.h"
[4584]46#include "reqcanalyze.h"
[4578]47
[4586]48//
49//////////////////////////////////////////////////////////////////////////////
[4587]50class t_scaleDrawTime : public QwtScaleDraw {
[4586]51 public:
[4587]52 t_scaleDrawTime() {}
[4617]53 virtual QwtText label(double mjdX24) const {
54 bncTime epoTime; epoTime.setmjd(mjdX24/24.0);
[4586]55 return QwtText(epoTime.timestr(0,':').c_str());
56 }
57};
58
59//
60//////////////////////////////////////////////////////////////////////////////
[4587]61class t_scaleDrawPrn : public QwtScaleDraw {
62 public:
63 t_scaleDrawPrn() {}
64 virtual QwtText label(double iPrn) const {
65 return _yLabels[iPrn];
66 }
67 QMap<int, QString> _yLabels;
68};
69
70// Constructor
71//////////////////////////////////////////////////////////////////////////////
[4578]72t_availPlot::t_availPlot(QWidget* parent,
[4584]73 QMap<QString, t_availData>* availDataMap)
[4578]74: QwtPlot(parent) {
75
[4579]76 setCanvasBackground(QColor(Qt::white));
77
[4578]78 // Axes
79 // ----
[4587]80 setAxisScaleDraw(QwtPlot::xBottom, new t_scaleDrawTime());
[4589]81 setAxisLabelRotation(QwtPlot::xBottom, -10.0);
[4586]82 setAxisLabelAlignment(QwtPlot::xBottom, Qt::AlignLeft | Qt::AlignBottom);
83
[4587]84 t_scaleDrawPrn* scaleDrawPrn = new t_scaleDrawPrn();
85 setAxisScaleDraw(QwtPlot::yLeft, scaleDrawPrn);
[4578]86
[4618]87 // Smaller Font for y-Axis
88 // -----------------------
89 QFont yFont = axisFont(QwtPlot::yLeft);
90 yFont.setPointSize(yFont.pointSize()/2);
91 setAxisFont(QwtPlot::yLeft, yFont);
92
[4593]93 // Symbols
94 // -------
[4604]95 QColor red(220,20,60);
96 QColor green(150,200,50);
97 QColor blue(60,100,200);
[4614]98 QwtSymbol symbRed(QwtSymbol::Rect, QBrush(red), QPen(red), QSize(2,1));
99 QwtSymbol symbGreen(QwtSymbol::Rect, QBrush(green), QPen(green), QSize(2,1));
100 QwtSymbol symbBlue (QwtSymbol::Rect, QBrush(blue), QPen(blue), QSize(2,1));
[4610]101
102 // Legend
103 // ------
104 QwtLegend* legend = new QwtLegend;
105 insertLegend(legend, QwtPlot::RightLegend);
[4611]106
107 QVector<double> xData0(0);
108 QVector<double> yData0(0);
[4613]109 addCurve("OK ", symbGreen, xData0, yData0);
110 addCurve("Gap ", symbBlue, xData0, yData0);
111 addCurve("Slip", symbRed, xData0, yData0);
[4593]112
[4578]113 // Curves
114 // ------
115 int iC = 0;
[4584]116 QMapIterator<QString, t_availData > it(*availDataMap);
[4578]117 while (it.hasNext()) {
118 it.next();
119 ++iC;
[4584]120 const QString& prn = it.key();
121 const t_availData& availData = it.value();
[4578]122
[4587]123 scaleDrawPrn->_yLabels[iC] = prn;
124
[4593]125 double eps = 0.1;
126
[4592]127 // L1 ok Curve
128 // -----------
[4596]129 if (availData._L1ok.size()) {
130 const QVector<double>& xData = availData._L1ok;
131 QVector<double> yData(xData.size(), double(iC)+eps);
[4613]132 QwtPlotCurve* curve = addCurve(prn, symbGreen, xData, yData);
[4610]133 curve->setItemAttribute(QwtPlotItem::Legend, false);
[4596]134 }
135
136 // L2 ok Curve
137 // -----------
138 if (availData._L2ok.size()) {
139 const QVector<double>& xData = availData._L2ok;
140 QVector<double> yData(xData.size(), double(iC)-eps);
[4613]141 QwtPlotCurve* curve = addCurve(prn, symbGreen, xData, yData);
[4610]142 curve->setItemAttribute(QwtPlotItem::Legend, false);
[4596]143 }
[4598]144
145 // L1 gaps Curve
146 // -------------
147 if (availData._L1gap.size()) {
148 const QVector<double>& xData = availData._L1gap;
149 QVector<double> yData(xData.size(), double(iC)+eps);
[4613]150 QwtPlotCurve* curve = addCurve(prn, symbBlue, xData, yData);
[4610]151 curve->setItemAttribute(QwtPlotItem::Legend, false);
[4598]152 }
153
154 // L2 gaps Curve
155 // -------------
156 if (availData._L2gap.size()) {
157 const QVector<double>& xData = availData._L2gap;
158 QVector<double> yData(xData.size(), double(iC)-eps);
[4613]159 QwtPlotCurve* curve = addCurve(prn, symbBlue, xData, yData);
[4610]160 curve->setItemAttribute(QwtPlotItem::Legend, false);
[4598]161 }
162
163 // L1 slips Curve
164 // --------------
165 if (availData._L1slip.size()) {
166 const QVector<double>& xData = availData._L1slip;
167 QVector<double> yData(xData.size(), double(iC)+eps);
[4613]168 QwtPlotCurve* curve = addCurve(prn, symbRed, xData, yData);
[4610]169 curve->setItemAttribute(QwtPlotItem::Legend, false);
[4598]170 }
171
172 // L2 slips Curve
173 // --------------
174 if (availData._L2slip.size()) {
175 const QVector<double>& xData = availData._L2slip;
176 QVector<double> yData(xData.size(), double(iC)-eps);
[4613]177 QwtPlotCurve* curve = addCurve(prn, symbRed, xData, yData);
[4610]178 curve->setItemAttribute(QwtPlotItem::Legend, false);
[4598]179 }
[4578]180 }
[4588]181
182 QList<double> ticks[QwtScaleDiv::NTickTypes];
183 QList<double> &majorTicks = ticks[QwtScaleDiv::MajorTick];
[4589]184 QMapIterator<int, QString> itT(scaleDrawPrn->_yLabels);
185 while (itT.hasNext()) {
186 itT.next();
187 majorTicks << double(itT.key());
[4588]188 }
189 QwtScaleDiv yScaleDiv(majorTicks.first()-0.5, majorTicks.last()+0.5, ticks );
190 setAxisScaleDiv(QwtPlot::yLeft, yScaleDiv);
[4581]191
[4582]192 // Important !!!
193 // -------------
[4581]194 replot();
[4578]195}
196
[4595]197// Add Curve
198//////////////////////////////////////////////////////////////////////////////
[4610]199QwtPlotCurve* t_availPlot::addCurve(const QString& name,
[4613]200 const QwtSymbol& symbol,
[4610]201 const QVector<double>& xData,
202 const QVector<double>& yData) {
[4595]203 QwtPlotCurve* curve = new QwtPlotCurve(name);
[4613]204 curve->setSymbol(new QwtSymbol(symbol));
[4595]205 curve->setStyle(QwtPlotCurve::NoCurve);
206 curve->setXAxis(QwtPlot::xBottom);
207 curve->setYAxis(QwtPlot::yLeft);
208 curve->setSamples(xData, yData);
209 curve->attach(this);
[4610]210 return curve;
[4595]211}
[4667]212
213//
214//////////////////////////////////////////////////////////////////////////////
215void t_availPlot::setNumSat(const QVector<double>& _numSatTim,
216 const QVector<double>& _numSat) {
[4668]217 QwtPlotCurve* curve = new QwtPlotCurve("# sat");
218 curve->setXAxis(QwtPlot::xBottom);
219 curve->setYAxis(QwtPlot::yRight);
220 curve->setSamples(_numSatTim, _numSat);
221 curve->attach(this);
[4667]222}
Note: See TracBrowser for help on using the repository browser.