source: ntrip/trunk/BNC/bncfigureppp.cpp@ 2159

Last change on this file since 2159 was 2159, checked in by mervart, 14 years ago

* empty log message *

File size: 5.4 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 *
33 * Author: Perlt, Mervart
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) {
52}
53
54// Destructor
55////////////////////////////////////////////////////////////////////////////
56bncFigurePPP::~bncFigurePPP() {
57 for (int ii = 0; ii < _pos.size(); ++ii) {
58 delete _pos[ii];
59 }
60}
61
62//
63////////////////////////////////////////////////////////////////////////////
[2145]64void bncFigurePPP::slotNewPosition(bncTime time, double x, double y, double z){
[2140]65
[2153]66 const static int MAXNUMPOS = 300;
[2140]67
68 QMutexLocker locker(&_mutex);
69
[2142]70 pppPos* newPos = new pppPos;
[2140]71
[2142]72 newPos->time = time;
[2145]73 newPos->xyz[0] = x;
74 newPos->xyz[1] = y;
75 newPos->xyz[2] = z;
[2140]76
77 _pos.push_back(newPos);
78
79 if (_pos.size() > MAXNUMPOS) {
80 delete _pos[0];
81 _pos.pop_front();
82 }
83
[2148]84 update();
[2140]85}
86
[2157]87// Coordinate Transformation
[2140]88////////////////////////////////////////////////////////////////////////////
[2156]89QPoint bncFigurePPP::pltPoint(double tt, double yy) {
90
[2157]91 const static double scale0 = 0.9;
[2156]92 double tScale = scale0 * _width / _tRange;
[2158]93 double yScale = scale0 * _height / (2.0 * _neuMax);
[2156]94 double tOffset = _tRange / 10.0;
[2158]95 double yOffset = _neuMax / 10.0;
[2156]96
[2157]97 int tNew = int( (tt - _tMin + tOffset) * tScale );
[2158]98 int yNew = int( (yy + _neuMax + yOffset) * yScale );
[2156]99
100 return QPoint(tNew, yNew);
101}
102
103//
104////////////////////////////////////////////////////////////////////////////
[2140]105void bncFigurePPP::paintEvent(QPaintEvent *) {
106
107 QPainter painter(this);
[2156]108 _width = painter.viewport().width();
109 _height = painter.viewport().height();
[2140]110
[2148]111 // Plot X-coordinates as a function of time (in seconds)
112 // -----------------------------------------------------
113 if (_pos.size() > 1) {
[2140]114
[2156]115 _tRange = _pos[_pos.size()-1]->time - _pos[0]->time; // in sec
116 _tMin = _pos[0]->time.gpssec();
[2140]117
[2159]118 // Reference Coordinates
119 // ---------------------
[2158]120 double xyzRef[3];
121 xyzRef[0] = _pos[0]->xyz[0];
122 xyzRef[1] = _pos[0]->xyz[1];
123 xyzRef[2] = _pos[0]->xyz[2];
124 double ellRef[3];
125 xyz2ell(xyzRef, ellRef);
126
127 // North, East and Up differences wrt Reference Coordinates
128 // --------------------------------------------------------
[2159]129 _neuMax = 0.0;
[2156]130 double neu[_pos.size()][3];
[2152]131 for (int ii = 0; ii < _pos.size(); ++ii) {
[2158]132 double dXYZ[3];
[2156]133 for (int ic = 0; ic < 3; ++ic) {
[2158]134 dXYZ[ic] = _pos[ii]->xyz[ic] - xyzRef[ic];
135 }
136 xyz2neu(ellRef, dXYZ, neu[ii]);
137 for (int ic = 0; ic < 3; ++ic) {
138 if (fabs(neu[ii][ic]) > _neuMax) {
139 _neuMax = fabs(neu[ii][ic]);
[2156]140 }
[2146]141 }
142 }
143
[2158]144 if (_neuMax > 0.0 && _tRange > 0.0) {
[2149]145
[2148]146 // x-axis
147 // ------
[2156]148 painter.drawLine(pltPoint(_tMin, 0.0), pltPoint(_tMin+_tRange, 0.0));
[2148]149
150 // y-axis
151 // ------
[2158]152 painter.drawLine(pltPoint(_tMin, -_neuMax), pltPoint(_tMin, _neuMax));
[2148]153
[2159]154 if (_neuMax < 1.0) {
155 painter.drawText(pltPoint(0, 0.5), " 0.5 m");
156 painter.drawText(pltPoint(0, -0.5), "-0.5 m");
157 }
158 else if (_neuMax < 2.0) {
159 painter.drawText(pltPoint(0, 1.0), " 1.0 m");
160 painter.drawText(pltPoint(0, -1.0), "-1.0 m");
161 }
162 else if (_neuMax < 10.0) {
163 painter.drawText(pltPoint(0, 5.0), " 5.0 m");
164 painter.drawText(pltPoint(0, -5.0), "-5.0 m");
165 }
166 else {
167 painter.drawText(pltPoint(0, 10.0), " 10.0 m");
168 painter.drawText(pltPoint(0,-10.0), "-10.0 m");
169 }
170
[2147]171 for (int ii = 1; ii < _pos.size(); ++ii) {
[2156]172 double t1 = _tMin + (_pos[ii-1]->time - _pos[0]->time);
173 double t2 = _tMin + (_pos[ii]->time - _pos[0]->time);
[2152]174 painter.setPen(QColor(Qt::red));
[2156]175 painter.drawLine(pltPoint(t1, neu[ii-1][0]), pltPoint(t2, neu[ii][0]));
[2152]176 painter.setPen(QColor(Qt::green));
[2156]177 painter.drawLine(pltPoint(t1, neu[ii-1][1]), pltPoint(t2, neu[ii][1]));
[2152]178 painter.setPen(QColor(Qt::blue));
[2156]179 painter.drawLine(pltPoint(t1, neu[ii-1][2]), pltPoint(t2, neu[ii][2]));
[2147]180 }
[2146]181 }
182 }
[2140]183}
184
Note: See TracBrowser for help on using the repository browser.