[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 |
|
---|
| 47 | using namespace std;
|
---|
| 48 |
|
---|
| 49 | // Constructor
|
---|
| 50 | ////////////////////////////////////////////////////////////////////////////
|
---|
| 51 | bncFigurePPP::bncFigurePPP(QWidget *parent) : QWidget(parent) {
|
---|
[2163] | 52 |
|
---|
[2164] | 53 | bncSettings settings;
|
---|
[2163] | 54 |
|
---|
[2165] | 55 | _xyzRef[0] = settings.value("pppRefCrdX").toDouble();
|
---|
| 56 | _xyzRef[1] = settings.value("pppRefCrdY").toDouble();
|
---|
| 57 | _xyzRef[2] = settings.value("pppRefCrdZ").toDouble();
|
---|
[2164] | 58 |
|
---|
[2140] | 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 | ////////////////////////////////////////////////////////////////////////////
|
---|
[2145] | 71 | void bncFigurePPP::slotNewPosition(bncTime time, double x, double y, double z){
|
---|
[2140] | 72 |
|
---|
| 73 | QMutexLocker locker(&_mutex);
|
---|
| 74 |
|
---|
[2142] | 75 | pppPos* newPos = new pppPos;
|
---|
[2140] | 76 |
|
---|
[2142] | 77 | newPos->time = time;
|
---|
[2145] | 78 | newPos->xyz[0] = x;
|
---|
| 79 | newPos->xyz[1] = y;
|
---|
| 80 | newPos->xyz[2] = z;
|
---|
[2140] | 81 |
|
---|
| 82 | _pos.push_back(newPos);
|
---|
| 83 |
|
---|
| 84 | if (_pos.size() > MAXNUMPOS) {
|
---|
| 85 | delete _pos[0];
|
---|
| 86 | _pos.pop_front();
|
---|
| 87 | }
|
---|
| 88 |
|
---|
[2148] | 89 | update();
|
---|
[2140] | 90 | }
|
---|
| 91 |
|
---|
[2157] | 92 | // Coordinate Transformation
|
---|
[2140] | 93 | ////////////////////////////////////////////////////////////////////////////
|
---|
[2156] | 94 | QPoint bncFigurePPP::pltPoint(double tt, double yy) {
|
---|
| 95 |
|
---|
[2165] | 96 | double tScale = 0.90 * _width / _tRange;
|
---|
[2163] | 97 | double yScale = 0.90 * _height / (2.0 * _neuMax);
|
---|
[2165] | 98 | double tOffset = _tRange / 13.0;
|
---|
[2158] | 99 | double yOffset = _neuMax / 10.0;
|
---|
[2156] | 100 |
|
---|
[2162] | 101 | int tNew = int( ( tt - _tMin + tOffset) * tScale );
|
---|
| 102 | int yNew = int( (-yy + _neuMax + yOffset) * yScale );
|
---|
[2156] | 103 |
|
---|
| 104 | return QPoint(tNew, yNew);
|
---|
| 105 | }
|
---|
| 106 |
|
---|
| 107 | //
|
---|
| 108 | ////////////////////////////////////////////////////////////////////////////
|
---|
[2140] | 109 | void bncFigurePPP::paintEvent(QPaintEvent *) {
|
---|
| 110 |
|
---|
| 111 | QPainter painter(this);
|
---|
[2165] | 112 |
|
---|
[2156] | 113 | _width = painter.viewport().width();
|
---|
| 114 | _height = painter.viewport().height();
|
---|
[2140] | 115 |
|
---|
[2165] | 116 | QFont font;
|
---|
| 117 | font.setPointSize(int(font.QFont::pointSize()*0.8));
|
---|
| 118 | painter.setFont(font);
|
---|
| 119 |
|
---|
[2148] | 120 | // Plot X-coordinates as a function of time (in seconds)
|
---|
| 121 | // -----------------------------------------------------
|
---|
| 122 | if (_pos.size() > 1) {
|
---|
[2165] | 123 | // _tRange = _pos[_pos.size()-1]->time - _pos[0]->time;
|
---|
[2169] | 124 | _tRange = MAXNUMPOS;
|
---|
[2156] | 125 | _tMin = _pos[0]->time.gpssec();
|
---|
[2140] | 126 |
|
---|
[2159] | 127 | // Reference Coordinates
|
---|
| 128 | // ---------------------
|
---|
[2163] | 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 | }
|
---|
[2158] | 134 | double ellRef[3];
|
---|
[2163] | 135 | xyz2ell(_xyzRef, ellRef);
|
---|
[2158] | 136 |
|
---|
| 137 | // North, East and Up differences wrt Reference Coordinates
|
---|
| 138 | // --------------------------------------------------------
|
---|
[2159] | 139 | _neuMax = 0.0;
|
---|
[2156] | 140 | double neu[_pos.size()][3];
|
---|
[2152] | 141 | for (int ii = 0; ii < _pos.size(); ++ii) {
|
---|
[2158] | 142 | double dXYZ[3];
|
---|
[2156] | 143 | for (int ic = 0; ic < 3; ++ic) {
|
---|
[2163] | 144 | dXYZ[ic] = _pos[ii]->xyz[ic] - _xyzRef[ic];
|
---|
[2158] | 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]);
|
---|
[2156] | 150 | }
|
---|
[2146] | 151 | }
|
---|
| 152 | }
|
---|
| 153 |
|
---|
[2158] | 154 | if (_neuMax > 0.0 && _tRange > 0.0) {
|
---|
[2149] | 155 |
|
---|
[2161] | 156 | if (_neuMax < 0.15) {
|
---|
| 157 | _neuMax = 0.15;
|
---|
| 158 | }
|
---|
[2163] | 159 |
|
---|
| 160 | // time-axis
|
---|
| 161 | // ---------
|
---|
[2156] | 162 | painter.drawLine(pltPoint(_tMin, 0.0), pltPoint(_tMin+_tRange, 0.0));
|
---|
[2148] | 163 |
|
---|
[2163] | 164 | // neu-axis
|
---|
| 165 | // --------
|
---|
[2158] | 166 | painter.drawLine(pltPoint(_tMin, -_neuMax), pltPoint(_tMin, _neuMax));
|
---|
[2148] | 167 |
|
---|
[2163] | 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);
|
---|
[2165] | 173 | QString strZ = QString("%1 m").arg(0.0,0,'f',2);
|
---|
[2159] | 174 |
|
---|
[2163] | 175 | QPoint pntP = pltPoint(_tMin, tic);
|
---|
| 176 | QPoint pntM = pltPoint(_tMin,-tic);
|
---|
[2165] | 177 | QPoint pntZ = pltPoint(_tMin, 0.0);
|
---|
[2163] | 178 |
|
---|
| 179 | int ww = QFontMetrics(this->font()).width('w');
|
---|
| 180 |
|
---|
[2167] | 181 | painter.setPen(QColor(Qt::red));
|
---|
| 182 | painter.drawText(0,int( ww * 1.0),int(pntP.x() + ww * 3.00),
|
---|
[2169] | 183 | int(pntP.x()),Qt::AlignRight,"N");
|
---|
| 184 | painter.setPen(QColor(0,210,0,127));
|
---|
[2167] | 185 | painter.drawText(0,int( ww * 1.0),int(pntP.x() + ww * 4.00),
|
---|
[2169] | 186 | int(pntP.x()),Qt::AlignRight,"E");
|
---|
[2167] | 187 | painter.setPen(QColor(Qt::blue));
|
---|
| 188 | painter.drawText(0,int( ww * 1.0),int(pntP.x() + ww * 5.00),
|
---|
[2169] | 189 | int(pntP.x()),Qt::AlignRight,"U");
|
---|
[2167] | 190 | painter.setPen(QColor(Qt::black));
|
---|
[2163] | 191 |
|
---|
[2167] | 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 |
|
---|
[2163] | 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 | // --------------
|
---|
[2147] | 204 | for (int ii = 1; ii < _pos.size(); ++ii) {
|
---|
[2156] | 205 | double t1 = _tMin + (_pos[ii-1]->time - _pos[0]->time);
|
---|
| 206 | double t2 = _tMin + (_pos[ii]->time - _pos[0]->time);
|
---|
[2169] | 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 | }
|
---|
[2165] | 222 |
|
---|
| 223 | // time-tics
|
---|
| 224 | // ---------
|
---|
| 225 | if (fmod(t1,60.) == 0) {
|
---|
| 226 | QPoint pntTic = pltPoint(t1, 0.0);
|
---|
[2169] | 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'));
|
---|
[2165] | 232 | painter.setPen(QColor(Qt::black));
|
---|
| 233 | double xFirstCharTic = pntTic.x() - ww * 1.2;
|
---|
| 234 | if ( xFirstCharTic > pntZ.x()) {
|
---|
[2169] | 235 | painter.drawText(int(xFirstCharTic),int(pntTic.y() + ww * 1.7),_strTic);
|
---|
[2167] | 236 | painter.drawLine(int(pntTic.x()),int(pntTic.y()),
|
---|
| 237 | int(pntTic.x()),int(pntTic.y() + ww * 0.5));
|
---|
[2165] | 238 | }
|
---|
| 239 | }
|
---|
[2152] | 240 | painter.setPen(QColor(Qt::red));
|
---|
[2156] | 241 | painter.drawLine(pltPoint(t1, neu[ii-1][0]), pltPoint(t2, neu[ii][0]));
|
---|
[2169] | 242 | painter.setPen(QColor(0,210,0,127));
|
---|
[2156] | 243 | painter.drawLine(pltPoint(t1, neu[ii-1][1]), pltPoint(t2, neu[ii][1]));
|
---|
[2152] | 244 | painter.setPen(QColor(Qt::blue));
|
---|
[2156] | 245 | painter.drawLine(pltPoint(t1, neu[ii-1][2]), pltPoint(t2, neu[ii][2]));
|
---|
[2147] | 246 | }
|
---|
[2146] | 247 | }
|
---|
| 248 | }
|
---|
[2140] | 249 | }
|
---|
| 250 |
|
---|