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

Last change on this file since 5760 was 4665, checked in by mervart, 12 years ago
File size: 4.1 KB
RevLine 
[4659]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 *
[4662]29 * Class: t_elePlot
[4659]30 *
[4662]31 * Purpose: Plot satellite elevations
[4659]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>
[4665]44#include <qwt_plot_marker.h>
[4659]45
[4662]46#include "eleplot.h"
[4659]47#include "reqcanalyze.h"
48
49//
50//////////////////////////////////////////////////////////////////////////////
51class t_scaleDrawTime : public QwtScaleDraw {
52 public:
53 t_scaleDrawTime() {}
54 virtual QwtText label(double mjdX24) const {
55 bncTime epoTime; epoTime.setmjd(mjdX24/24.0);
56 return QwtText(epoTime.timestr(0,':').c_str());
57 }
58};
59
60// Constructor
61//////////////////////////////////////////////////////////////////////////////
[4662]62t_elePlot::t_elePlot(QWidget* parent, QMap<QString, t_availData>* availDataMap)
[4659]63: QwtPlot(parent) {
64
65 setCanvasBackground(QColor(Qt::white));
66
67 // Axes
68 // ----
69 setAxisScaleDraw(QwtPlot::xBottom, new t_scaleDrawTime());
70 setAxisLabelRotation(QwtPlot::xBottom, -10.0);
71 setAxisLabelAlignment(QwtPlot::xBottom, Qt::AlignLeft | Qt::AlignBottom);
[4661]72 setAxisScale(QwtPlot::yLeft, 0.0, 90.0);
[4659]73
74 // Legend
75 // ------
76 QwtLegend* legend = new QwtLegend;
77 insertLegend(legend, QwtPlot::RightLegend);
78
79 // Curves
80 // ------
[4664]81 int numCurves = availDataMap->size();
82 if (numCurves > 0) {
83 int iC = 0;
84 QMapIterator<QString, t_availData > it(*availDataMap);
85 while (it.hasNext()) {
86 it.next();
87 ++iC;
88 const QString& prn = it.key();
89 const t_availData& availData = it.value();
90
91 // Draw one curve
92 // --------------
93 if (availData._eleTim.size()) {
94 const QVector<double>& xData = availData._eleTim;
95 const QVector<double>& yData = availData._eleDeg;
96 QColor color = QColor::fromHsv((iC-1)*(359.0/numCurves), 255, 255);
97 QwtSymbol symbol(QwtSymbol::Rect, QBrush(color), QPen(color), QSize(1,1));
98 addCurve(prn, symbol, xData, yData);
99 }
[4659]100 }
101 }
102
103 // Important !!!
104 // -------------
105 replot();
106}
107
108// Add Curve
109//////////////////////////////////////////////////////////////////////////////
[4662]110QwtPlotCurve* t_elePlot::addCurve(const QString& name,
[4659]111 const QwtSymbol& symbol,
112 const QVector<double>& xData,
113 const QVector<double>& yData) {
114 QwtPlotCurve* curve = new QwtPlotCurve(name);
115 curve->setSymbol(new QwtSymbol(symbol));
116 curve->setStyle(QwtPlotCurve::NoCurve);
117 curve->setXAxis(QwtPlot::xBottom);
118 curve->setYAxis(QwtPlot::yLeft);
119 curve->setSamples(xData, yData);
120 curve->attach(this);
[4665]121
122 if (xData.size() > 0 && yData.size() > 0) {
123 QwtPlotMarker* marker = new QwtPlotMarker();
124 int ii = xData.size() / 2;
125 marker->setValue(xData[ii], yData[ii]);
126 QwtText text(name);
127 text.setColor(symbol.pen().color());
128 marker->setLabel(text);
129 marker->setLabelAlignment(Qt::AlignTop);
130 marker->attach(this);
131 }
132
[4659]133 return curve;
134}
Note: See TracBrowser for help on using the repository browser.