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

Last change on this file since 6462 was 6272, checked in by mervart, 10 years ago
File size: 6.8 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() {}
65 virtual QwtText label(double iPrn) const {
66 return _yLabels[iPrn];
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));
[6261]77 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
[4593]126 double eps = 0.1;
127
[4592]128 // L1 ok Curve
129 // -----------
[6272]130 if (plotData._L1ok.size()) {
131 const QVector<double>& xData = plotData._L1ok;
[4596]132 QVector<double> yData(xData.size(), double(iC)+eps);
[4613]133 QwtPlotCurve* curve = addCurve(prn, symbGreen, xData, yData);
[4610]134 curve->setItemAttribute(QwtPlotItem::Legend, false);
[4596]135 }
136
137 // L2 ok Curve
138 // -----------
[6272]139 if (plotData._L2ok.size()) {
140 const QVector<double>& xData = plotData._L2ok;
[4596]141 QVector<double> yData(xData.size(), double(iC)-eps);
[4613]142 QwtPlotCurve* curve = addCurve(prn, symbGreen, xData, yData);
[4610]143 curve->setItemAttribute(QwtPlotItem::Legend, false);
[4596]144 }
[4598]145
146 // L1 gaps Curve
147 // -------------
[6272]148 if (plotData._L1gap.size()) {
149 const QVector<double>& xData = plotData._L1gap;
[4598]150 QVector<double> yData(xData.size(), double(iC)+eps);
[4613]151 QwtPlotCurve* curve = addCurve(prn, symbBlue, xData, yData);
[4610]152 curve->setItemAttribute(QwtPlotItem::Legend, false);
[4598]153 }
154
155 // L2 gaps Curve
156 // -------------
[6272]157 if (plotData._L2gap.size()) {
158 const QVector<double>& xData = plotData._L2gap;
[4598]159 QVector<double> yData(xData.size(), double(iC)-eps);
[4613]160 QwtPlotCurve* curve = addCurve(prn, symbBlue, xData, yData);
[4610]161 curve->setItemAttribute(QwtPlotItem::Legend, false);
[4598]162 }
163
164 // L1 slips Curve
165 // --------------
[6272]166 if (plotData._L1slip.size()) {
167 const QVector<double>& xData = plotData._L1slip;
[4598]168 QVector<double> yData(xData.size(), double(iC)+eps);
[4613]169 QwtPlotCurve* curve = addCurve(prn, symbRed, xData, yData);
[4610]170 curve->setItemAttribute(QwtPlotItem::Legend, false);
[4598]171 }
172
173 // L2 slips Curve
174 // --------------
[6272]175 if (plotData._L2slip.size()) {
176 const QVector<double>& xData = plotData._L2slip;
[4598]177 QVector<double> yData(xData.size(), double(iC)-eps);
[4613]178 QwtPlotCurve* curve = addCurve(prn, symbRed, xData, yData);
[4610]179 curve->setItemAttribute(QwtPlotItem::Legend, false);
[4598]180 }
[4578]181 }
[4588]182
183 QList<double> ticks[QwtScaleDiv::NTickTypes];
184 QList<double> &majorTicks = ticks[QwtScaleDiv::MajorTick];
[4589]185 QMapIterator<int, QString> itT(scaleDrawPrn->_yLabels);
186 while (itT.hasNext()) {
187 itT.next();
188 majorTicks << double(itT.key());
[4588]189 }
190 QwtScaleDiv yScaleDiv(majorTicks.first()-0.5, majorTicks.last()+0.5, ticks );
191 setAxisScaleDiv(QwtPlot::yLeft, yScaleDiv);
[4581]192
[4582]193 // Important !!!
194 // -------------
[4581]195 replot();
[4578]196}
197
[4595]198// Add Curve
199//////////////////////////////////////////////////////////////////////////////
[4610]200QwtPlotCurve* t_availPlot::addCurve(const QString& name,
[4613]201 const QwtSymbol& symbol,
[4610]202 const QVector<double>& xData,
203 const QVector<double>& yData) {
[4595]204 QwtPlotCurve* curve = new QwtPlotCurve(name);
[4613]205 curve->setSymbol(new QwtSymbol(symbol));
[4595]206 curve->setStyle(QwtPlotCurve::NoCurve);
207 curve->setXAxis(QwtPlot::xBottom);
208 curve->setYAxis(QwtPlot::yLeft);
209 curve->setSamples(xData, yData);
210 curve->attach(this);
[4610]211 return curve;
[4595]212}
Note: See TracBrowser for help on using the repository browser.