source: ntrip/branches/BNC_2.11.0/src/rinex/availplot.cpp@ 6478

Last change on this file since 6478 was 4669, checked in by mervart, 12 years ago
File size: 6.7 KB
Line 
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 *
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
41#include <qwt_scale_draw.h>
42#include <qwt_text.h>
43#include <qwt_legend.h>
44
45#include "availplot.h"
46#include "reqcanalyze.h"
47
48//
49//////////////////////////////////////////////////////////////////////////////
50class t_scaleDrawTime : public QwtScaleDraw {
51 public:
52 t_scaleDrawTime() {}
53 virtual QwtText label(double mjdX24) const {
54 bncTime epoTime; epoTime.setmjd(mjdX24/24.0);
55 return QwtText(epoTime.timestr(0,':').c_str());
56 }
57};
58
59//
60//////////////////////////////////////////////////////////////////////////////
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//////////////////////////////////////////////////////////////////////////////
72t_availPlot::t_availPlot(QWidget* parent,
73 QMap<QString, t_availData>* availDataMap)
74: QwtPlot(parent) {
75
76 setCanvasBackground(QColor(Qt::white));
77
78 // Axes
79 // ----
80 setAxisScaleDraw(QwtPlot::xBottom, new t_scaleDrawTime());
81 setAxisLabelRotation(QwtPlot::xBottom, -10.0);
82 setAxisLabelAlignment(QwtPlot::xBottom, Qt::AlignLeft | Qt::AlignBottom);
83
84 t_scaleDrawPrn* scaleDrawPrn = new t_scaleDrawPrn();
85 setAxisScaleDraw(QwtPlot::yLeft, scaleDrawPrn);
86
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
93 // Symbols
94 // -------
95 QColor red(220,20,60);
96 QColor green(150,200,50);
97 QColor blue(60,100,200);
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));
101
102 // Legend
103 // ------
104 QwtLegend* legend = new QwtLegend;
105 insertLegend(legend, QwtPlot::RightLegend);
106
107 QVector<double> xData0(0);
108 QVector<double> yData0(0);
109 addCurve("OK ", symbGreen, xData0, yData0);
110 addCurve("Gap ", symbBlue, xData0, yData0);
111 addCurve("Slip", symbRed, xData0, yData0);
112
113 // Curves
114 // ------
115 int iC = 0;
116 QMapIterator<QString, t_availData > it(*availDataMap);
117 while (it.hasNext()) {
118 it.next();
119 ++iC;
120 const QString& prn = it.key();
121 const t_availData& availData = it.value();
122
123 scaleDrawPrn->_yLabels[iC] = prn;
124
125 double eps = 0.1;
126
127 // L1 ok Curve
128 // -----------
129 if (availData._L1ok.size()) {
130 const QVector<double>& xData = availData._L1ok;
131 QVector<double> yData(xData.size(), double(iC)+eps);
132 QwtPlotCurve* curve = addCurve(prn, symbGreen, xData, yData);
133 curve->setItemAttribute(QwtPlotItem::Legend, false);
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);
141 QwtPlotCurve* curve = addCurve(prn, symbGreen, xData, yData);
142 curve->setItemAttribute(QwtPlotItem::Legend, false);
143 }
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);
150 QwtPlotCurve* curve = addCurve(prn, symbBlue, xData, yData);
151 curve->setItemAttribute(QwtPlotItem::Legend, false);
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);
159 QwtPlotCurve* curve = addCurve(prn, symbBlue, xData, yData);
160 curve->setItemAttribute(QwtPlotItem::Legend, false);
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);
168 QwtPlotCurve* curve = addCurve(prn, symbRed, xData, yData);
169 curve->setItemAttribute(QwtPlotItem::Legend, false);
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);
177 QwtPlotCurve* curve = addCurve(prn, symbRed, xData, yData);
178 curve->setItemAttribute(QwtPlotItem::Legend, false);
179 }
180 }
181
182 QList<double> ticks[QwtScaleDiv::NTickTypes];
183 QList<double> &majorTicks = ticks[QwtScaleDiv::MajorTick];
184 QMapIterator<int, QString> itT(scaleDrawPrn->_yLabels);
185 while (itT.hasNext()) {
186 itT.next();
187 majorTicks << double(itT.key());
188 }
189 QwtScaleDiv yScaleDiv(majorTicks.first()-0.5, majorTicks.last()+0.5, ticks );
190 setAxisScaleDiv(QwtPlot::yLeft, yScaleDiv);
191
192 // Important !!!
193 // -------------
194 replot();
195}
196
197// Add Curve
198//////////////////////////////////////////////////////////////////////////////
199QwtPlotCurve* t_availPlot::addCurve(const QString& name,
200 const QwtSymbol& symbol,
201 const QVector<double>& xData,
202 const QVector<double>& yData) {
203 QwtPlotCurve* curve = new QwtPlotCurve(name);
204 curve->setSymbol(new QwtSymbol(symbol));
205 curve->setStyle(QwtPlotCurve::NoCurve);
206 curve->setXAxis(QwtPlot::xBottom);
207 curve->setYAxis(QwtPlot::yLeft);
208 curve->setSamples(xData, yData);
209 curve->attach(this);
210 return curve;
211}
Note: See TracBrowser for help on using the repository browser.