source: ntrip/trunk/BNC/src/rinex/eleplot.cpp@ 4663

Last change on this file since 4663 was 4663, checked in by mervart, 12 years ago
File size: 3.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_elePlot
30 *
31 * Purpose: Plot satellite elevations
32 *
33 * Author: L. Mervart
34 *
35 * Created: 08-Sep-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 "eleplot.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// Constructor
60//////////////////////////////////////////////////////////////////////////////
61t_elePlot::t_elePlot(QWidget* parent, QMap<QString, t_availData>* availDataMap)
62: QwtPlot(parent) {
63
64 setCanvasBackground(QColor(Qt::white));
65
66 // Axes
67 // ----
68 setAxisScaleDraw(QwtPlot::xBottom, new t_scaleDrawTime());
69 setAxisLabelRotation(QwtPlot::xBottom, -10.0);
70 setAxisLabelAlignment(QwtPlot::xBottom, Qt::AlignLeft | Qt::AlignBottom);
71 setAxisScale(QwtPlot::yLeft, 0.0, 90.0);
72
73 // Legend
74 // ------
75 QwtLegend* legend = new QwtLegend;
76 insertLegend(legend, QwtPlot::RightLegend);
77
78 // Curves
79 // ------
80 int iC = 0;
81 QMapIterator<QString, t_availData > it(*availDataMap);
82 while (it.hasNext()) {
83 it.next();
84 ++iC;
85 const QString& prn = it.key();
86 const t_availData& availData = it.value();
87
88 // Draw one curve
89 // --------------
90 if (availData._eleTim.size()) {
91 const QVector<double>& xData = availData._eleTim;
92 const QVector<double>& yData = availData._eleDeg;
93 QColor color(qrand() % 255, qrand() % 255, qrand() % 255);
94 QwtSymbol symbol(QwtSymbol::Rect, QBrush(color), QPen(color), QSize(1,1));
95 addCurve(prn, symbol, xData, yData);
96 }
97 }
98
99 // Important !!!
100 // -------------
101 replot();
102}
103
104// Add Curve
105//////////////////////////////////////////////////////////////////////////////
106QwtPlotCurve* t_elePlot::addCurve(const QString& name,
107 const QwtSymbol& symbol,
108 const QVector<double>& xData,
109 const QVector<double>& yData) {
110 QwtPlotCurve* curve = new QwtPlotCurve(name);
111 curve->setSymbol(new QwtSymbol(symbol));
112 curve->setStyle(QwtPlotCurve::NoCurve);
113 curve->setXAxis(QwtPlot::xBottom);
114 curve->setYAxis(QwtPlot::yLeft);
115 curve->setSamples(xData, yData);
116 curve->attach(this);
117 return curve;
118}
Note: See TracBrowser for help on using the repository browser.