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

Last change on this file since 2167 was 2167, checked in by weber, 14 years ago

* empty log message *

File size: 7.6 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: bncFigurePPP
30 *
31 * Purpose:
32 *
33 * Author: 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"
45#include "bncutils.h"
46
47using namespace std;
48
49// Constructor
50////////////////////////////////////////////////////////////////////////////
51bncFigurePPP::bncFigurePPP(QWidget *parent) : QWidget(parent) {
52
53 bncSettings settings;
54
55 _xyzRef[0] = settings.value("pppRefCrdX").toDouble();
56 _xyzRef[1] = settings.value("pppRefCrdY").toDouble();
57 _xyzRef[2] = settings.value("pppRefCrdZ").toDouble();
58
59}
60
61// Destructor
62////////////////////////////////////////////////////////////////////////////
63bncFigurePPP::~bncFigurePPP() {
64 for (int ii = 0; ii < _pos.size(); ++ii) {
65 delete _pos[ii];
66 }
67}
68
69//
70////////////////////////////////////////////////////////////////////////////
71void bncFigurePPP::slotNewPosition(bncTime time, double x, double y, double z){
72
73 QMutexLocker locker(&_mutex);
74
75 pppPos* newPos = new pppPos;
76
77 newPos->time = time;
78 newPos->xyz[0] = x;
79 newPos->xyz[1] = y;
80 newPos->xyz[2] = z;
81
82 _pos.push_back(newPos);
83
84 if (_pos.size() > MAXNUMPOS) {
85 delete _pos[0];
86 _pos.pop_front();
87 }
88
89 update();
90}
91
92// Coordinate Transformation
93////////////////////////////////////////////////////////////////////////////
94QPoint bncFigurePPP::pltPoint(double tt, double yy) {
95
96 double tScale = 0.90 * _width / _tRange;
97 double yScale = 0.90 * _height / (2.0 * _neuMax);
98 double tOffset = _tRange / 13.0;
99 double yOffset = _neuMax / 10.0;
100
101 int tNew = int( ( tt - _tMin + tOffset) * tScale );
102 int yNew = int( (-yy + _neuMax + yOffset) * yScale );
103
104 return QPoint(tNew, yNew);
105}
106
107//
108////////////////////////////////////////////////////////////////////////////
109void bncFigurePPP::paintEvent(QPaintEvent *) {
110
111 QPainter painter(this);
112
113 _width = painter.viewport().width();
114 _height = painter.viewport().height();
115
116 QFont font;
117 font.setPointSize(int(font.QFont::pointSize()*0.8));
118 painter.setFont(font);
119
120 // Plot X-coordinates as a function of time (in seconds)
121 // -----------------------------------------------------
122 if (_pos.size() > 1) {
123
124// _tRange = _pos[_pos.size()-1]->time - _pos[0]->time;
125 _tRange = MAXNUMPOS; // GW
126 _tMin = _pos[0]->time.gpssec();
127
128 // Reference Coordinates
129 // ---------------------
130 if (_xyzRef[0] == 0.0 && _xyzRef[1] == 0.0 && _xyzRef[2] == 0.0) {
131 _xyzRef[0] = _pos[0]->xyz[0];
132 _xyzRef[1] = _pos[0]->xyz[1];
133 _xyzRef[2] = _pos[0]->xyz[2];
134 }
135 double ellRef[3];
136 xyz2ell(_xyzRef, ellRef);
137
138 // North, East and Up differences wrt Reference Coordinates
139 // --------------------------------------------------------
140 _neuMax = 0.0;
141 double neu[_pos.size()][3];
142 for (int ii = 0; ii < _pos.size(); ++ii) {
143 double dXYZ[3];
144 for (int ic = 0; ic < 3; ++ic) {
145 dXYZ[ic] = _pos[ii]->xyz[ic] - _xyzRef[ic];
146 }
147 xyz2neu(ellRef, dXYZ, neu[ii]);
148 for (int ic = 0; ic < 3; ++ic) {
149 if (fabs(neu[ii][ic]) > _neuMax) {
150 _neuMax = fabs(neu[ii][ic]);
151 }
152 }
153 }
154
155 if (_neuMax > 0.0 && _tRange > 0.0) {
156
157 if (_neuMax < 0.15) {
158 _neuMax = 0.15;
159 }
160
161 // time-axis
162 // ---------
163 painter.drawLine(pltPoint(_tMin, 0.0), pltPoint(_tMin+_tRange, 0.0));
164
165 // neu-axis
166 // --------
167 painter.drawLine(pltPoint(_tMin, -_neuMax), pltPoint(_tMin, _neuMax));
168
169 // neu-tics
170 // --------
171 double tic = floor(20.0 * (_neuMax - 0.05)) / 20.0;
172 QString strP = QString("%1 m").arg( tic,0,'f',2);
173 QString strM = QString("%1 m").arg(-tic,0,'f',2);
174 QString strZ = QString("%1 m").arg(0.0,0,'f',2);
175
176 QPoint pntP = pltPoint(_tMin, tic);
177 QPoint pntM = pltPoint(_tMin,-tic);
178 QPoint pntZ = pltPoint(_tMin, 0.0);
179
180 int ww = QFontMetrics(this->font()).width('w');
181
182 painter.setPen(QColor(Qt::red));
183 painter.drawText(0,int( ww * 1.0),int(pntP.x() + ww * 3.00),
184 int(pntP.x()),Qt::AlignRight,"N");
185 painter.setPen(QColor(Qt::green));
186 painter.drawText(0,int( ww * 1.0),int(pntP.x() + ww * 4.00),
187 int(pntP.x()),Qt::AlignRight,"E");
188 painter.setPen(QColor(Qt::blue));
189 painter.drawText(0,int( ww * 1.0),int(pntP.x() + ww * 5.00),
190 int(pntP.x()),Qt::AlignRight,"U");
191 painter.setPen(QColor(Qt::black));
192
193 painter.drawText(0,int(pntP.y() - ww * 0.5),int(pntP.x() - ww * 0.25),
194 int(pntP.x()),Qt::AlignRight,strP);
195 painter.drawText(0,int(pntM.y() - ww * 0.5),int(pntM.x() - ww * 0.25),
196 int(pntM.y()),Qt::AlignRight,strM);
197 painter.drawText(0,int(pntZ.y() - ww * 0.5),int(pntZ.x() - ww * 0.25),
198 int(pntZ.y()),Qt::AlignRight,strZ);
199
200 painter.drawLine(pntP.x(), pntP.y(), pntP.x()+ww, pntP.y());
201 painter.drawLine(pntM.x(), pntM.y(), pntM.x()+ww, pntM.y());
202
203 // neu components
204 // --------------
205 for (int ii = 1; ii < _pos.size(); ++ii) {
206 double t1 = _tMin + (_pos[ii-1]->time - _pos[0]->time);
207 double t2 = _tMin + (_pos[ii]->time - _pos[0]->time);
208
209 // time-tics
210 // ---------
211 if (fmod(t1,60.) == 0) {
212 QPoint pntTic = pltPoint(t1, 0.0);
213 int daySec = int(fmod(t1,86400.));
214 int hours = int(daySec / 3600);
215 int minutes = int((daySec - hours * 3600)/ 60.);
216 QString strTic = QString("%1:%2").arg(hours, 2, 10, QChar('0'))
217 .arg(minutes, 2, 10, QChar('0'));
218 painter.setPen(QColor(Qt::black));
219 double xFirstCharTic = pntTic.x() - ww * 1.2;
220 if ( xFirstCharTic > pntZ.x()) {
221 painter.drawText(int(xFirstCharTic),int(pntTic.y() + ww * 1.7),strTic);
222 painter.drawLine(int(pntTic.x()),int(pntTic.y()),
223 int(pntTic.x()),int(pntTic.y() + ww * 0.5));
224 }
225 }
226 painter.setPen(QColor(Qt::red));
227 painter.drawLine(pltPoint(t1, neu[ii-1][0]), pltPoint(t2, neu[ii][0]));
228 painter.setPen(QColor(Qt::green));
229 painter.drawLine(pltPoint(t1, neu[ii-1][1]), pltPoint(t2, neu[ii][1]));
230 painter.setPen(QColor(Qt::blue));
231 painter.drawLine(pltPoint(t1, neu[ii-1][2]), pltPoint(t2, neu[ii][2]));
232 }
233 }
234 }
235}
236
Note: See TracBrowser for help on using the repository browser.