source: ntrip/trunk/BNC/src/bncfigureppp.cpp@ 4974

Last change on this file since 4974 was 4974, checked in by neumaier, 11 years ago

pppCorrMount String added to PPP time series plot

File size: 10.5 KB
RevLine 
[2140]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: bncFigurePPP
30 *
31 * Purpose:
32 *
[2163]33 * Author: Mervart
[2140]34 *
35 * Created: 11-Nov-2009
36 *
37 * Changes:
38 *
39 * -----------------------------------------------------------------------*/
40
41#include <iostream>
42
43#include "bncfigureppp.h"
44#include "bncsettings.h"
[2158]45#include "bncutils.h"
[2140]46
47using namespace std;
48
49// Constructor
50////////////////////////////////////////////////////////////////////////////
51bncFigurePPP::bncFigurePPP(QWidget *parent) : QWidget(parent) {
[2177]52 reset();
53}
[2163]54
[2177]55
56// Destructor
57////////////////////////////////////////////////////////////////////////////
58bncFigurePPP::~bncFigurePPP() {
59 for (int ii = 0; ii < _pos.size(); ++ii) {
60 delete _pos[ii];
61 }
62}
63
64//
65////////////////////////////////////////////////////////////////////////////
66void bncFigurePPP::reset() {
67 QMutexLocker locker(&_mutex);
68
[2164]69 bncSettings settings;
[2163]70
[2730]71 if (settings.value("pppRefCrdX").toString() != "" &&
72 settings.value("pppRefCrdY").toString() != "" &&
73 settings.value("pppRefCrdZ").toString() != "") {
[2305]74 _xyzRef[0] = settings.value("pppRefCrdX").toDouble();
75 _xyzRef[1] = settings.value("pppRefCrdY").toDouble();
76 _xyzRef[2] = settings.value("pppRefCrdZ").toDouble();
77 }
[2721]78 else {
[2305]79 _xyzRef[0] = 0.0;
80 _xyzRef[1] = 0.0;
81 _xyzRef[2] = 0.0;
82 }
83
[4550]84 if (settings.value("pppRefCrdX").toString() != "" &&
85 settings.value("pppRefCrdY").toString() != "" &&
86 settings.value("pppRefCrdZ").toString() != "" &&
87 settings.value("pppQuickStart").toString() != "" &&
88 settings.value("pppAudioResponse").toString() != "" ) {
89 _pppAudioResponse = settings.value("pppAudioResponse").toDouble();
90 }
91 else {
[4551]92 _pppAudioResponse = 0.0;
[4550]93 }
94
95 _pppMount = settings.value("pppMount").toString();
[4974]96 _pppCorrMount = settings.value("pppCorrMount").toString();
97 _pppSPP = settings.value("pppSPP").toString();
[4550]98
[2140]99 for (int ii = 0; ii < _pos.size(); ++ii) {
100 delete _pos[ii];
101 }
[2177]102 _pos.clear();
103
104 update();
[2140]105}
106
107//
108////////////////////////////////////////////////////////////////////////////
[2145]109void bncFigurePPP::slotNewPosition(bncTime time, double x, double y, double z){
[2140]110
111 QMutexLocker locker(&_mutex);
112
[2142]113 pppPos* newPos = new pppPos;
[2140]114
[2142]115 newPos->time = time;
[2145]116 newPos->xyz[0] = x;
117 newPos->xyz[1] = y;
118 newPos->xyz[2] = z;
[2140]119
120 _pos.push_back(newPos);
121
[2177]122 if (_pos.size() == 1) {
123 _startTime = time;
124 }
125
[2204]126 QMutableVectorIterator<pppPos*> it(_pos);
127 while (it.hasNext()) {
128 pppPos* pp = it.next();
129 if ( (time - pp->time) > _tRange ) {
130 delete pp;
131 it.remove();
132 }
[2140]133 }
134
[2148]135 update();
[2140]136}
137
[2157]138// Coordinate Transformation
[2140]139////////////////////////////////////////////////////////////////////////////
[2156]140QPoint bncFigurePPP::pltPoint(double tt, double yy) {
141
[2165]142 double tScale = 0.90 * _width / _tRange;
[2163]143 double yScale = 0.90 * _height / (2.0 * _neuMax);
[2165]144 double tOffset = _tRange / 13.0;
[2158]145 double yOffset = _neuMax / 10.0;
[2156]146
[2162]147 int tNew = int( ( tt - _tMin + tOffset) * tScale );
148 int yNew = int( (-yy + _neuMax + yOffset) * yScale );
[2156]149
150 return QPoint(tNew, yNew);
151}
152
153//
154////////////////////////////////////////////////////////////////////////////
[2140]155void bncFigurePPP::paintEvent(QPaintEvent *) {
156
157 QPainter painter(this);
[2165]158
[2156]159 _width = painter.viewport().width();
160 _height = painter.viewport().height();
[2140]161
[2177]162 QFont font = this->font();
163 font.setPointSize(int(this->font().pointSize()*0.9));
[2165]164 painter.setFont(font);
165
[2148]166 // Plot X-coordinates as a function of time (in seconds)
167 // -----------------------------------------------------
168 if (_pos.size() > 1) {
[2156]169 _tMin = _pos[0]->time.gpssec();
[2140]170
[2159]171 // Reference Coordinates
172 // ---------------------
[2163]173 if (_xyzRef[0] == 0.0 && _xyzRef[1] == 0.0 && _xyzRef[2] == 0.0) {
174 _xyzRef[0] = _pos[0]->xyz[0];
175 _xyzRef[1] = _pos[0]->xyz[1];
176 _xyzRef[2] = _pos[0]->xyz[2];
177 }
[2158]178 double ellRef[3];
[2163]179 xyz2ell(_xyzRef, ellRef);
[2158]180
181 // North, East and Up differences wrt Reference Coordinates
182 // --------------------------------------------------------
[2159]183 _neuMax = 0.0;
[2156]184 double neu[_pos.size()][3];
[2152]185 for (int ii = 0; ii < _pos.size(); ++ii) {
[2158]186 double dXYZ[3];
[2156]187 for (int ic = 0; ic < 3; ++ic) {
[2163]188 dXYZ[ic] = _pos[ii]->xyz[ic] - _xyzRef[ic];
[2158]189 }
190 xyz2neu(ellRef, dXYZ, neu[ii]);
191 for (int ic = 0; ic < 3; ++ic) {
192 if (fabs(neu[ii][ic]) > _neuMax) {
193 _neuMax = fabs(neu[ii][ic]);
[2156]194 }
[2146]195 }
196 }
197
[2204]198 if (_neuMax > 0.0) {
[2149]199
[2220]200 if (_neuMax < 0.151) {
201 _neuMax = 0.151;
[2161]202 }
[2163]203
[2201]204 unsigned hour, minute;
205 double second;
206 int ww = QFontMetrics(this->font()).width('w');
207
208 // neu components
209 // --------------
210 for (int ii = 1; ii < _pos.size(); ++ii) {
211 double t1 = _tMin + (_pos[ii-1]->time - _pos[0]->time);
212 double t2 = _tMin + (_pos[ii]->time - _pos[0]->time);
213
[4550]214 // Audio response
215 // --------------
[4551]216 if ( ii == _pos.size()-1) {
217 if ( _pppAudioResponse > 0.0 &&
218 (fabs(neu[ii-1][0]) > _pppAudioResponse ||
219 fabs(neu[ii-1][1]) > _pppAudioResponse) ) {
220 QApplication::beep();
[4550]221 }
222 }
[2201]223
224 // dots
225 // ----
[2205]226 painter.setPen(QColor(Qt::gray));
227 painter.drawLine(pltPoint(t1, neu[ii-1][0]), pltPoint(t2, neu[ii][0]));
[2201]228 painter.setPen(QColor(Qt::red));
229 painter.setBrush(QColor(Qt::red));
[2209]230 painter.drawEllipse(pltPoint(t1,neu[ii-1][0]), ww/6, ww/6);
[2201]231
[2205]232 painter.setPen(QColor(Qt::gray));
233 painter.drawLine(pltPoint(t1, neu[ii-1][1]), pltPoint(t2, neu[ii][1]));
[2201]234 painter.setPen(QColor(Qt::green));
235 painter.setBrush(QColor(Qt::green));
[2209]236 painter.drawEllipse(pltPoint(t1,neu[ii-1][1]), ww/6, ww/6);
[2201]237
[2205]238 painter.setPen(QColor(Qt::gray));
239 painter.drawLine(pltPoint(t1, neu[ii-1][2]), pltPoint(t2, neu[ii][2]));
[2201]240 painter.setPen(QColor(Qt::blue));
241 painter.setBrush(QColor(Qt::blue));
[2209]242 painter.drawEllipse(pltPoint(t1,neu[ii-1][2]), ww/6, ww/6);
[2201]243
244 // time-tics
245 // ---------
246 if ( fmod(_pos[ii-1]->time.daysec(), 60.0) == 0 ) {
247 _pos[ii-1]->time.civil_time(hour, minute, second);
248 QPoint pntTic = pltPoint(t1, 0.0);
249 QString strTic = QString("%1:%2").arg(hour, 2, 10, QChar('0'))
250 .arg(minute, 2, 10, QChar('0'));
251 double xFirstCharTic = pntTic.x() - ww * 1.2;
252 if ( xFirstCharTic > pltPoint(_tMin, 0.0).x()) {
253 painter.setPen(QColor(Qt::black));
254 painter.drawText(int(xFirstCharTic), int(pntTic.y() + ww * 1.7),
255 strTic);
256 painter.drawLine(pntTic.x(), pntTic.y(),
257 pntTic.x(), pntTic.y()+ww/2);
258 }
259 }
260 }
261
[2163]262 // time-axis
263 // ---------
[2201]264 painter.setPen(QColor(Qt::black));
[2156]265 painter.drawLine(pltPoint(_tMin, 0.0), pltPoint(_tMin+_tRange, 0.0));
[2148]266
[2163]267 // neu-axis
268 // --------
[2158]269 painter.drawLine(pltPoint(_tMin, -_neuMax), pltPoint(_tMin, _neuMax));
[2148]270
[2163]271 // neu-tics
272 // --------
[2201]273 double tic = floor(20.0 * (_neuMax - 0.05)) / 20.0;
[2163]274 QString strP = QString("%1 m").arg( tic,0,'f',2);
275 QString strM = QString("%1 m").arg(-tic,0,'f',2);
[2165]276 QString strZ = QString("%1 m").arg(0.0,0,'f',2);
[2159]277
[2163]278 QPoint pntP = pltPoint(_tMin, tic);
279 QPoint pntM = pltPoint(_tMin,-tic);
[2165]280 QPoint pntZ = pltPoint(_tMin, 0.0);
[2163]281
[2167]282 painter.setPen(QColor(Qt::red));
[2177]283 painter.drawText(0, ww, pntP.x() + 3*ww, pntP.x(), Qt::AlignRight, "N");
284 painter.setPen(QColor(Qt::green));
285 painter.drawText(0, ww, pntP.x() + 4*ww, pntP.x(), Qt::AlignRight, "E");
[2167]286 painter.setPen(QColor(Qt::blue));
[2177]287 painter.drawText(0, ww, pntP.x() + 5*ww, pntP.x(), Qt::AlignRight, "U");
288
[2167]289 painter.setPen(QColor(Qt::black));
[2177]290 painter.drawText(0, pntP.y()-ww/2, pntP.x()- ww/4, pntP.x(),
291 Qt::AlignRight, strP);
292 painter.drawText(0, pntM.y()-ww/2, pntM.x()- ww/4, pntM.x(),
293 Qt::AlignRight, strM);
294 painter.drawText(0, pntZ.y()-ww/2, pntZ.x()- ww/4, pntZ.x(),
295 Qt::AlignRight, strZ);
[2163]296
297 painter.drawLine(pntP.x(), pntP.y(), pntP.x()+ww, pntP.y());
298 painter.drawLine(pntM.x(), pntM.y(), pntM.x()+ww, pntM.y());
299
[2177]300 // Start Time
301 // ----------
[4974]302
[2177]303 _startTime.civil_time(hour, minute, second);
[4974]304
305 if (_pppSPP == "Realtime-PPP") {
306
307 QString startStr = QString("%1 %2 Start %3:%4:%5")
308 .arg(_pppMount)
309 .arg(_pppCorrMount)
[2177]310 .arg(hour, 2, 10, QChar('0'))
311 .arg(minute, 2, 10, QChar('0'))
[4974]312 .arg(int(second), 2, 10, QChar('0'));
[2177]313 painter.setPen(QColor(Qt::black));
[4553]314 painter.drawText(0, ww, pntP.x() + 21*ww, pntP.x(),
[4974]315 Qt::AlignRight, startStr);
316 }
317
318 if (_pppSPP == "Realtime-SPP") {
319
320 QString startStr = QString("%1 Start %2:%3:%4")
321 .arg(_pppMount)
322 .arg(hour, 2, 10, QChar('0'))
323 .arg(minute, 2, 10, QChar('0'))
324 .arg(int(second), 2, 10, QChar('0'));
325 painter.setPen(QColor(Qt::black));
326 painter.drawText(0, ww, pntP.x() + 21*ww, pntP.x(),
327 Qt::AlignRight, startStr);
328 }
329
330
331
[2146]332 }
333 }
[2140]334}
335
Note: See TracBrowser for help on using the repository browser.