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 | QString refCrdStr = "";
|
---|
54 |
|
---|
55 | QStringList refCrdStrList = refCrdStr.split(' ', QString::SkipEmptyParts);
|
---|
56 | if (refCrdStrList.size() == 3) {
|
---|
57 | _xyzRef[0] = refCrdStrList[0].toDouble();
|
---|
58 | _xyzRef[1] = refCrdStrList[1].toDouble();
|
---|
59 | _xyzRef[2] = refCrdStrList[2].toDouble();
|
---|
60 | }
|
---|
61 | else {
|
---|
62 | _xyzRef[0] = 0.0;
|
---|
63 | _xyzRef[1] = 0.0;
|
---|
64 | _xyzRef[2] = 0.0;
|
---|
65 | }
|
---|
66 | }
|
---|
67 |
|
---|
68 | // Destructor
|
---|
69 | ////////////////////////////////////////////////////////////////////////////
|
---|
70 | bncFigurePPP::~bncFigurePPP() {
|
---|
71 | for (int ii = 0; ii < _pos.size(); ++ii) {
|
---|
72 | delete _pos[ii];
|
---|
73 | }
|
---|
74 | }
|
---|
75 |
|
---|
76 | //
|
---|
77 | ////////////////////////////////////////////////////////////////////////////
|
---|
78 | void bncFigurePPP::slotNewPosition(bncTime time, double x, double y, double z){
|
---|
79 |
|
---|
80 | const static int MAXNUMPOS = 300;
|
---|
81 |
|
---|
82 | QMutexLocker locker(&_mutex);
|
---|
83 |
|
---|
84 | pppPos* newPos = new pppPos;
|
---|
85 |
|
---|
86 | newPos->time = time;
|
---|
87 | newPos->xyz[0] = x;
|
---|
88 | newPos->xyz[1] = y;
|
---|
89 | newPos->xyz[2] = z;
|
---|
90 |
|
---|
91 | _pos.push_back(newPos);
|
---|
92 |
|
---|
93 | if (_pos.size() > MAXNUMPOS) {
|
---|
94 | delete _pos[0];
|
---|
95 | _pos.pop_front();
|
---|
96 | }
|
---|
97 |
|
---|
98 | update();
|
---|
99 | }
|
---|
100 |
|
---|
101 | // Coordinate Transformation
|
---|
102 | ////////////////////////////////////////////////////////////////////////////
|
---|
103 | QPoint bncFigurePPP::pltPoint(double tt, double yy) {
|
---|
104 |
|
---|
105 | double tScale = 0.85 * _width / _tRange;
|
---|
106 | double yScale = 0.90 * _height / (2.0 * _neuMax);
|
---|
107 | double tOffset = _tRange / 10.0;
|
---|
108 | double yOffset = _neuMax / 10.0;
|
---|
109 |
|
---|
110 | int tNew = int( ( tt - _tMin + tOffset) * tScale );
|
---|
111 | int yNew = int( (-yy + _neuMax + yOffset) * yScale );
|
---|
112 |
|
---|
113 | return QPoint(tNew, yNew);
|
---|
114 | }
|
---|
115 |
|
---|
116 | //
|
---|
117 | ////////////////////////////////////////////////////////////////////////////
|
---|
118 | void bncFigurePPP::paintEvent(QPaintEvent *) {
|
---|
119 |
|
---|
120 | QPainter painter(this);
|
---|
121 | _width = painter.viewport().width();
|
---|
122 | _height = painter.viewport().height();
|
---|
123 |
|
---|
124 | // Plot X-coordinates as a function of time (in seconds)
|
---|
125 | // -----------------------------------------------------
|
---|
126 | if (_pos.size() > 1) {
|
---|
127 |
|
---|
128 | _tRange = _pos[_pos.size()-1]->time - _pos[0]->time; // in sec
|
---|
129 | _tMin = _pos[0]->time.gpssec();
|
---|
130 |
|
---|
131 | // Reference Coordinates
|
---|
132 | // ---------------------
|
---|
133 | if (_xyzRef[0] == 0.0 && _xyzRef[1] == 0.0 && _xyzRef[2] == 0.0) {
|
---|
134 | _xyzRef[0] = _pos[0]->xyz[0];
|
---|
135 | _xyzRef[1] = _pos[0]->xyz[1];
|
---|
136 | _xyzRef[2] = _pos[0]->xyz[2];
|
---|
137 | }
|
---|
138 | double ellRef[3];
|
---|
139 | xyz2ell(_xyzRef, ellRef);
|
---|
140 |
|
---|
141 | // North, East and Up differences wrt Reference Coordinates
|
---|
142 | // --------------------------------------------------------
|
---|
143 | _neuMax = 0.0;
|
---|
144 | double neu[_pos.size()][3];
|
---|
145 | for (int ii = 0; ii < _pos.size(); ++ii) {
|
---|
146 | double dXYZ[3];
|
---|
147 | for (int ic = 0; ic < 3; ++ic) {
|
---|
148 | dXYZ[ic] = _pos[ii]->xyz[ic] - _xyzRef[ic];
|
---|
149 | }
|
---|
150 | xyz2neu(ellRef, dXYZ, neu[ii]);
|
---|
151 | for (int ic = 0; ic < 3; ++ic) {
|
---|
152 | if (fabs(neu[ii][ic]) > _neuMax) {
|
---|
153 | _neuMax = fabs(neu[ii][ic]);
|
---|
154 | }
|
---|
155 | }
|
---|
156 | }
|
---|
157 |
|
---|
158 | if (_neuMax > 0.0 && _tRange > 0.0) {
|
---|
159 |
|
---|
160 | if (_neuMax < 0.15) {
|
---|
161 | _neuMax = 0.15;
|
---|
162 | }
|
---|
163 |
|
---|
164 | // time-axis
|
---|
165 | // ---------
|
---|
166 | painter.drawLine(pltPoint(_tMin, 0.0), pltPoint(_tMin+_tRange, 0.0));
|
---|
167 |
|
---|
168 | // neu-axis
|
---|
169 | // --------
|
---|
170 | painter.drawLine(pltPoint(_tMin, -_neuMax), pltPoint(_tMin, _neuMax));
|
---|
171 |
|
---|
172 | // neu-tics
|
---|
173 | // --------
|
---|
174 | double tic = floor(20.0 * (_neuMax - 0.05)) / 20.0;
|
---|
175 | QString strP = QString("%1 m").arg( tic,0,'f',2);
|
---|
176 | QString strM = QString("%1 m").arg(-tic,0,'f',2);
|
---|
177 |
|
---|
178 | QPoint pntP = pltPoint(_tMin, tic);
|
---|
179 | QPoint pntM = pltPoint(_tMin,-tic);
|
---|
180 |
|
---|
181 | int ww = QFontMetrics(this->font()).width('w');
|
---|
182 |
|
---|
183 | painter.drawText(pntP.x() - ww * strP.length(), pntP.y()+ww, strP);
|
---|
184 | painter.drawText(pntM.x() - ww * strM.length(), pntM.y(), strM);
|
---|
185 |
|
---|
186 | painter.drawLine(pntP.x(), pntP.y(), pntP.x()+ww, pntP.y());
|
---|
187 | painter.drawLine(pntM.x(), pntM.y(), pntM.x()+ww, pntM.y());
|
---|
188 |
|
---|
189 | // time-tic
|
---|
190 | // --------
|
---|
191 | painter.drawText(pltPoint(_tMin+_tRange,0.0),
|
---|
192 | QString(" %1 s").arg(_tRange));
|
---|
193 |
|
---|
194 | // neu components
|
---|
195 | // --------------
|
---|
196 | for (int ii = 1; ii < _pos.size(); ++ii) {
|
---|
197 | double t1 = _tMin + (_pos[ii-1]->time - _pos[0]->time);
|
---|
198 | double t2 = _tMin + (_pos[ii]->time - _pos[0]->time);
|
---|
199 | painter.setPen(QColor(Qt::red));
|
---|
200 | painter.drawLine(pltPoint(t1, neu[ii-1][0]), pltPoint(t2, neu[ii][0]));
|
---|
201 | painter.setPen(QColor(Qt::green));
|
---|
202 | painter.drawLine(pltPoint(t1, neu[ii-1][1]), pltPoint(t2, neu[ii][1]));
|
---|
203 | painter.setPen(QColor(Qt::blue));
|
---|
204 | painter.drawLine(pltPoint(t1, neu[ii-1][2]), pltPoint(t2, neu[ii][2]));
|
---|
205 | }
|
---|
206 | }
|
---|
207 | }
|
---|
208 | }
|
---|
209 |
|
---|