source: ntrip/trunk/BNC/src/rinex/zenplot.cpp@ 4659

Last change on this file since 4659 was 4659, checked in by mervart, 12 years ago
File size: 4.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_zenPlot
30 *
31 * Purpose: Plot with satellite zenith distances
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 "zenplot.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_zenPlot::t_zenPlot(QWidget* parent, QMap<QString, t_availData>* availDataMap)
73: QwtPlot(parent) {
74
75 setCanvasBackground(QColor(Qt::white));
76
77 // Axes
78 // ----
79 setAxisScaleDraw(QwtPlot::xBottom, new t_scaleDrawTime());
80 setAxisLabelRotation(QwtPlot::xBottom, -10.0);
81 setAxisLabelAlignment(QwtPlot::xBottom, Qt::AlignLeft | Qt::AlignBottom);
82
83 t_scaleDrawPrn* scaleDrawPrn = new t_scaleDrawPrn();
84 setAxisScaleDraw(QwtPlot::yLeft, scaleDrawPrn);
85
86 // Smaller Font for y-Axis
87 // -----------------------
88 QFont yFont = axisFont(QwtPlot::yLeft);
89 yFont.setPointSize(yFont.pointSize()/2);
90 setAxisFont(QwtPlot::yLeft, yFont);
91
92 // Symbols
93 // -------
94 QColor red(220,20,60);
95 QColor green(150,200,50);
96 QColor blue(60,100,200);
97 QwtSymbol symbRed(QwtSymbol::Rect, QBrush(red), QPen(red), QSize(2,1));
98 QwtSymbol symbGreen(QwtSymbol::Rect, QBrush(green), QPen(green), QSize(2,1));
99 QwtSymbol symbBlue (QwtSymbol::Rect, QBrush(blue), QPen(blue), QSize(2,1));
100
101 // Legend
102 // ------
103 QwtLegend* legend = new QwtLegend;
104 insertLegend(legend, QwtPlot::RightLegend);
105
106 // Curves
107 // ------
108 int iC = 0;
109 QMapIterator<QString, t_availData > it(*availDataMap);
110 while (it.hasNext()) {
111 it.next();
112 ++iC;
113 const QString& prn = it.key();
114 const t_availData& availData = it.value();
115
116 scaleDrawPrn->_yLabels[iC] = prn;
117
118 // Draw one curve
119 // --------------
120 if (availData._L1ok.size()) {
121 const QVector<double>& xData = availData._zenTim;
122 const QVector<double>& yData = availData._zenDeg;
123 addCurve(prn, symbGreen, xData, yData);
124 }
125 }
126
127 QList<double> ticks[QwtScaleDiv::NTickTypes];
128 QList<double> &majorTicks = ticks[QwtScaleDiv::MajorTick];
129 QMapIterator<int, QString> itT(scaleDrawPrn->_yLabels);
130 while (itT.hasNext()) {
131 itT.next();
132 majorTicks << double(itT.key());
133 }
134 QwtScaleDiv yScaleDiv(majorTicks.first()-0.5, majorTicks.last()+0.5, ticks );
135 setAxisScaleDiv(QwtPlot::yLeft, yScaleDiv);
136
137 // Important !!!
138 // -------------
139 replot();
140}
141
142// Add Curve
143//////////////////////////////////////////////////////////////////////////////
144QwtPlotCurve* t_zenPlot::addCurve(const QString& name,
145 const QwtSymbol& symbol,
146 const QVector<double>& xData,
147 const QVector<double>& yData) {
148 QwtPlotCurve* curve = new QwtPlotCurve(name);
149 curve->setSymbol(new QwtSymbol(symbol));
150 curve->setStyle(QwtPlotCurve::NoCurve);
151 curve->setXAxis(QwtPlot::xBottom);
152 curve->setYAxis(QwtPlot::yLeft);
153 curve->setSamples(xData, yData);
154 curve->attach(this);
155 return curve;
156}
Note: See TracBrowser for help on using the repository browser.