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 |
|
---|
47 | using namespace std;
|
---|
48 |
|
---|
49 | // Constructor
|
---|
50 | ////////////////////////////////////////////////////////////////////////////
|
---|
51 | bncFigurePPP::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 | ////////////////////////////////////////////////////////////////////////////
|
---|
63 | bncFigurePPP::~bncFigurePPP() {
|
---|
64 | for (int ii = 0; ii < _pos.size(); ++ii) {
|
---|
65 | delete _pos[ii];
|
---|
66 | }
|
---|
67 | }
|
---|
68 |
|
---|
69 | //
|
---|
70 | ////////////////////////////////////////////////////////////////////////////
|
---|
71 | void 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 | ////////////////////////////////////////////////////////////////////////////
|
---|
94 | QPoint 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 | ////////////////////////////////////////////////////////////////////////////
|
---|
109 | void 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 | // _tRange = _pos[_pos.size()-1]->time - _pos[0]->time;
|
---|
124 | _tRange = MAXNUMPOS;
|
---|
125 | _tMin = _pos[0]->time.gpssec();
|
---|
126 |
|
---|
127 | // Reference Coordinates
|
---|
128 | // ---------------------
|
---|
129 | if (_xyzRef[0] == 0.0 && _xyzRef[1] == 0.0 && _xyzRef[2] == 0.0) {
|
---|
130 | _xyzRef[0] = _pos[0]->xyz[0];
|
---|
131 | _xyzRef[1] = _pos[0]->xyz[1];
|
---|
132 | _xyzRef[2] = _pos[0]->xyz[2];
|
---|
133 | }
|
---|
134 | double ellRef[3];
|
---|
135 | xyz2ell(_xyzRef, ellRef);
|
---|
136 |
|
---|
137 | // North, East and Up differences wrt Reference Coordinates
|
---|
138 | // --------------------------------------------------------
|
---|
139 | _neuMax = 0.0;
|
---|
140 | double neu[_pos.size()][3];
|
---|
141 | for (int ii = 0; ii < _pos.size(); ++ii) {
|
---|
142 | double dXYZ[3];
|
---|
143 | for (int ic = 0; ic < 3; ++ic) {
|
---|
144 | dXYZ[ic] = _pos[ii]->xyz[ic] - _xyzRef[ic];
|
---|
145 | }
|
---|
146 | xyz2neu(ellRef, dXYZ, neu[ii]);
|
---|
147 | for (int ic = 0; ic < 3; ++ic) {
|
---|
148 | if (fabs(neu[ii][ic]) > _neuMax) {
|
---|
149 | _neuMax = fabs(neu[ii][ic]);
|
---|
150 | }
|
---|
151 | }
|
---|
152 | }
|
---|
153 |
|
---|
154 | if (_neuMax > 0.0 && _tRange > 0.0) {
|
---|
155 |
|
---|
156 | if (_neuMax < 0.15) {
|
---|
157 | _neuMax = 0.15;
|
---|
158 | }
|
---|
159 |
|
---|
160 | // time-axis
|
---|
161 | // ---------
|
---|
162 | painter.drawLine(pltPoint(_tMin, 0.0), pltPoint(_tMin+_tRange, 0.0));
|
---|
163 |
|
---|
164 | // neu-axis
|
---|
165 | // --------
|
---|
166 | painter.drawLine(pltPoint(_tMin, -_neuMax), pltPoint(_tMin, _neuMax));
|
---|
167 |
|
---|
168 | // neu-tics
|
---|
169 | // --------
|
---|
170 | double tic = floor(20.0 * (_neuMax - 0.05)) / 20.0;
|
---|
171 | QString strP = QString("%1 m").arg( tic,0,'f',2);
|
---|
172 | QString strM = QString("%1 m").arg(-tic,0,'f',2);
|
---|
173 | QString strZ = QString("%1 m").arg(0.0,0,'f',2);
|
---|
174 |
|
---|
175 | QPoint pntP = pltPoint(_tMin, tic);
|
---|
176 | QPoint pntM = pltPoint(_tMin,-tic);
|
---|
177 | QPoint pntZ = pltPoint(_tMin, 0.0);
|
---|
178 |
|
---|
179 | int ww = QFontMetrics(this->font()).width('w');
|
---|
180 |
|
---|
181 | painter.setPen(QColor(Qt::red));
|
---|
182 | painter.drawText(0,int( ww * 1.0),int(pntP.x() + ww * 3.00),
|
---|
183 | int(pntP.x()),Qt::AlignRight,"N");
|
---|
184 | painter.setPen(QColor(0,210,0,127));
|
---|
185 | painter.drawText(0,int( ww * 1.0),int(pntP.x() + ww * 4.00),
|
---|
186 | int(pntP.x()),Qt::AlignRight,"E");
|
---|
187 | painter.setPen(QColor(Qt::blue));
|
---|
188 | painter.drawText(0,int( ww * 1.0),int(pntP.x() + ww * 5.00),
|
---|
189 | int(pntP.x()),Qt::AlignRight,"U");
|
---|
190 | painter.setPen(QColor(Qt::black));
|
---|
191 |
|
---|
192 | painter.drawText(0,int(pntP.y() - ww * 0.5),int(pntP.x() - ww * 0.25),
|
---|
193 | int(pntP.x()),Qt::AlignRight,strP);
|
---|
194 | painter.drawText(0,int(pntM.y() - ww * 0.5),int(pntM.x() - ww * 0.25),
|
---|
195 | int(pntM.y()),Qt::AlignRight,strM);
|
---|
196 | painter.drawText(0,int(pntZ.y() - ww * 0.5),int(pntZ.x() - ww * 0.25),
|
---|
197 | int(pntZ.y()),Qt::AlignRight,strZ);
|
---|
198 |
|
---|
199 | painter.drawLine(pntP.x(), pntP.y(), pntP.x()+ww, pntP.y());
|
---|
200 | painter.drawLine(pntM.x(), pntM.y(), pntM.x()+ww, pntM.y());
|
---|
201 |
|
---|
202 | // neu components
|
---|
203 | // --------------
|
---|
204 | for (int ii = 1; ii < _pos.size(); ++ii) {
|
---|
205 | double t1 = _tMin + (_pos[ii-1]->time - _pos[0]->time);
|
---|
206 | double t2 = _tMin + (_pos[ii]->time - _pos[0]->time);
|
---|
207 |
|
---|
208 | // start time
|
---|
209 | // ----------
|
---|
210 | if (ii == 1) {
|
---|
211 | _daySec = int(fmod(t1,86400.));
|
---|
212 | _hours = int(_daySec / 3600);
|
---|
213 | _minutes = int((_daySec - _hours * 3600)/ 60.);
|
---|
214 | _seconds = int(fmod(t1,60.));
|
---|
215 | _strTic = QString("Start %1:%2:%3").arg(_hours, 2, 10, QChar('0'))
|
---|
216 | .arg(_minutes, 2, 10, QChar('0'))
|
---|
217 | .arg(_seconds, 2, 10, QChar('0'));
|
---|
218 | painter.setPen(QColor(Qt::black));
|
---|
219 | painter.drawText(0,int( ww * 1.0),int(pntP.x() + ww * 13.50),
|
---|
220 | int(pntP.x()),Qt::AlignRight,_strTic);
|
---|
221 | }
|
---|
222 |
|
---|
223 | // time-tics
|
---|
224 | // ---------
|
---|
225 | if (fmod(t1,60.) == 0) {
|
---|
226 | QPoint pntTic = pltPoint(t1, 0.0);
|
---|
227 | _daySec = int(fmod(t1,86400.));
|
---|
228 | _hours = int(_daySec / 3600);
|
---|
229 | _minutes = int((_daySec - _hours * 3600)/ 60.);
|
---|
230 | _strTic = QString("%1:%2").arg(_hours, 2, 10, QChar('0'))
|
---|
231 | .arg(_minutes, 2, 10, QChar('0'));
|
---|
232 | painter.setPen(QColor(Qt::black));
|
---|
233 | double xFirstCharTic = pntTic.x() - ww * 1.2;
|
---|
234 | if ( xFirstCharTic > pntZ.x()) {
|
---|
235 | painter.drawText(int(xFirstCharTic),int(pntTic.y() + ww * 1.7),_strTic);
|
---|
236 | painter.drawLine(int(pntTic.x()),int(pntTic.y()),
|
---|
237 | int(pntTic.x()),int(pntTic.y() + ww * 0.5));
|
---|
238 | }
|
---|
239 | }
|
---|
240 | painter.setPen(QColor(Qt::red));
|
---|
241 | painter.drawLine(pltPoint(t1, neu[ii-1][0]), pltPoint(t2, neu[ii][0]));
|
---|
242 | painter.setPen(QColor(0,210,0,127));
|
---|
243 | painter.drawLine(pltPoint(t1, neu[ii-1][1]), pltPoint(t2, neu[ii][1]));
|
---|
244 | painter.setPen(QColor(Qt::blue));
|
---|
245 | painter.drawLine(pltPoint(t1, neu[ii-1][2]), pltPoint(t2, neu[ii][2]));
|
---|
246 | }
|
---|
247 | }
|
---|
248 | }
|
---|
249 | }
|
---|
250 |
|
---|