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

Last change on this file since 4664 was 4664, checked in by mervart, 12 years ago
File size: 3.8 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 numCurves = availDataMap->size();
81 if (numCurves > 0) {
82 int iC = 0;
83 QMapIterator<QString, t_availData > it(*availDataMap);
84 while (it.hasNext()) {
85 it.next();
86 ++iC;
87 const QString& prn = it.key();
88 const t_availData& availData = it.value();
89
90 // Draw one curve
91 // --------------
92 if (availData._eleTim.size()) {
93 const QVector<double>& xData = availData._eleTim;
94 const QVector<double>& yData = availData._eleDeg;
95 QColor color = QColor::fromHsv((iC-1)*(359.0/numCurves), 255, 255);
96 QwtSymbol symbol(QwtSymbol::Rect, QBrush(color), QPen(color), QSize(1,1));
97 addCurve(prn, symbol, xData, yData);
98 }
99 }
100 }
101
102 // Important !!!
103 // -------------
104 replot();
105}
106
107// Add Curve
108//////////////////////////////////////////////////////////////////////////////
109QwtPlotCurve* t_elePlot::addCurve(const QString& name,
110 const QwtSymbol& symbol,
111 const QVector<double>& xData,
112 const QVector<double>& yData) {
113 QwtPlotCurve* curve = new QwtPlotCurve(name);
114 curve->setSymbol(new QwtSymbol(symbol));
115 curve->setStyle(QwtPlotCurve::NoCurve);
116 curve->setXAxis(QwtPlot::xBottom);
117 curve->setYAxis(QwtPlot::yLeft);
118 curve->setSamples(xData, yData);
119 curve->attach(this);
120 return curve;
121}
Note: See TracBrowser for help on using the repository browser.