[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) {
|
---|
[2177] | 52 | reset();
|
---|
| 53 | }
|
---|
[2163] | 54 |
|
---|
[2177] | 55 |
|
---|
| 56 | // Destructor
|
---|
| 57 | ////////////////////////////////////////////////////////////////////////////
|
---|
| 58 | bncFigurePPP::~bncFigurePPP() {
|
---|
| 59 | for (int ii = 0; ii < _pos.size(); ++ii) {
|
---|
| 60 | delete _pos[ii];
|
---|
| 61 | }
|
---|
| 62 | }
|
---|
| 63 |
|
---|
| 64 | //
|
---|
| 65 | ////////////////////////////////////////////////////////////////////////////
|
---|
| 66 | void bncFigurePPP::reset() {
|
---|
| 67 | QMutexLocker locker(&_mutex);
|
---|
| 68 |
|
---|
[2164] | 69 | bncSettings settings;
|
---|
[2163] | 70 |
|
---|
[2730] | 71 | if (settings.value("pppRefCrdX").toString() != "" &&
|
---|
| 72 | settings.value("pppRefCrdY").toString() != "" &&
|
---|
| 73 | settings.value("pppRefCrdZ").toString() != "") {
|
---|
[2305] | 74 | _xyzRef[0] = settings.value("pppRefCrdX").toDouble();
|
---|
| 75 | _xyzRef[1] = settings.value("pppRefCrdY").toDouble();
|
---|
| 76 | _xyzRef[2] = settings.value("pppRefCrdZ").toDouble();
|
---|
| 77 | }
|
---|
[2721] | 78 | else {
|
---|
[2305] | 79 | _xyzRef[0] = 0.0;
|
---|
| 80 | _xyzRef[1] = 0.0;
|
---|
| 81 | _xyzRef[2] = 0.0;
|
---|
| 82 | }
|
---|
| 83 |
|
---|
[2140] | 84 | for (int ii = 0; ii < _pos.size(); ++ii) {
|
---|
| 85 | delete _pos[ii];
|
---|
| 86 | }
|
---|
[2177] | 87 | _pos.clear();
|
---|
| 88 |
|
---|
| 89 | update();
|
---|
[2140] | 90 | }
|
---|
| 91 |
|
---|
| 92 | //
|
---|
| 93 | ////////////////////////////////////////////////////////////////////////////
|
---|
[2145] | 94 | void bncFigurePPP::slotNewPosition(bncTime time, double x, double y, double z){
|
---|
[2140] | 95 |
|
---|
| 96 | QMutexLocker locker(&_mutex);
|
---|
| 97 |
|
---|
[2142] | 98 | pppPos* newPos = new pppPos;
|
---|
[2140] | 99 |
|
---|
[2142] | 100 | newPos->time = time;
|
---|
[2145] | 101 | newPos->xyz[0] = x;
|
---|
| 102 | newPos->xyz[1] = y;
|
---|
| 103 | newPos->xyz[2] = z;
|
---|
[2140] | 104 |
|
---|
| 105 | _pos.push_back(newPos);
|
---|
| 106 |
|
---|
[2177] | 107 | if (_pos.size() == 1) {
|
---|
| 108 | _startTime = time;
|
---|
| 109 | }
|
---|
| 110 |
|
---|
[2204] | 111 | QMutableVectorIterator<pppPos*> it(_pos);
|
---|
| 112 | while (it.hasNext()) {
|
---|
| 113 | pppPos* pp = it.next();
|
---|
| 114 | if ( (time - pp->time) > _tRange ) {
|
---|
| 115 | delete pp;
|
---|
| 116 | it.remove();
|
---|
| 117 | }
|
---|
[2140] | 118 | }
|
---|
| 119 |
|
---|
[2148] | 120 | update();
|
---|
[2140] | 121 | }
|
---|
| 122 |
|
---|
[2157] | 123 | // Coordinate Transformation
|
---|
[2140] | 124 | ////////////////////////////////////////////////////////////////////////////
|
---|
[2156] | 125 | QPoint bncFigurePPP::pltPoint(double tt, double yy) {
|
---|
| 126 |
|
---|
[2165] | 127 | double tScale = 0.90 * _width / _tRange;
|
---|
[2163] | 128 | double yScale = 0.90 * _height / (2.0 * _neuMax);
|
---|
[2165] | 129 | double tOffset = _tRange / 13.0;
|
---|
[2158] | 130 | double yOffset = _neuMax / 10.0;
|
---|
[2156] | 131 |
|
---|
[2162] | 132 | int tNew = int( ( tt - _tMin + tOffset) * tScale );
|
---|
| 133 | int yNew = int( (-yy + _neuMax + yOffset) * yScale );
|
---|
[2156] | 134 |
|
---|
| 135 | return QPoint(tNew, yNew);
|
---|
| 136 | }
|
---|
| 137 |
|
---|
| 138 | //
|
---|
| 139 | ////////////////////////////////////////////////////////////////////////////
|
---|
[2140] | 140 | void bncFigurePPP::paintEvent(QPaintEvent *) {
|
---|
| 141 |
|
---|
| 142 | QPainter painter(this);
|
---|
[2165] | 143 |
|
---|
[2156] | 144 | _width = painter.viewport().width();
|
---|
| 145 | _height = painter.viewport().height();
|
---|
[2140] | 146 |
|
---|
[2177] | 147 | QFont font = this->font();
|
---|
| 148 | font.setPointSize(int(this->font().pointSize()*0.9));
|
---|
[2165] | 149 | painter.setFont(font);
|
---|
| 150 |
|
---|
[2148] | 151 | // Plot X-coordinates as a function of time (in seconds)
|
---|
| 152 | // -----------------------------------------------------
|
---|
| 153 | if (_pos.size() > 1) {
|
---|
[2156] | 154 | _tMin = _pos[0]->time.gpssec();
|
---|
[2140] | 155 |
|
---|
[2159] | 156 | // Reference Coordinates
|
---|
| 157 | // ---------------------
|
---|
[2163] | 158 | if (_xyzRef[0] == 0.0 && _xyzRef[1] == 0.0 && _xyzRef[2] == 0.0) {
|
---|
| 159 | _xyzRef[0] = _pos[0]->xyz[0];
|
---|
| 160 | _xyzRef[1] = _pos[0]->xyz[1];
|
---|
| 161 | _xyzRef[2] = _pos[0]->xyz[2];
|
---|
| 162 | }
|
---|
[2158] | 163 | double ellRef[3];
|
---|
[2163] | 164 | xyz2ell(_xyzRef, ellRef);
|
---|
[2158] | 165 |
|
---|
| 166 | // North, East and Up differences wrt Reference Coordinates
|
---|
| 167 | // --------------------------------------------------------
|
---|
[2159] | 168 | _neuMax = 0.0;
|
---|
[2156] | 169 | double neu[_pos.size()][3];
|
---|
[2152] | 170 | for (int ii = 0; ii < _pos.size(); ++ii) {
|
---|
[2158] | 171 | double dXYZ[3];
|
---|
[2156] | 172 | for (int ic = 0; ic < 3; ++ic) {
|
---|
[2163] | 173 | dXYZ[ic] = _pos[ii]->xyz[ic] - _xyzRef[ic];
|
---|
[2158] | 174 | }
|
---|
| 175 | xyz2neu(ellRef, dXYZ, neu[ii]);
|
---|
| 176 | for (int ic = 0; ic < 3; ++ic) {
|
---|
| 177 | if (fabs(neu[ii][ic]) > _neuMax) {
|
---|
| 178 | _neuMax = fabs(neu[ii][ic]);
|
---|
[2156] | 179 | }
|
---|
[2146] | 180 | }
|
---|
| 181 | }
|
---|
| 182 |
|
---|
[2204] | 183 | if (_neuMax > 0.0) {
|
---|
[2149] | 184 |
|
---|
[2220] | 185 | if (_neuMax < 0.151) {
|
---|
| 186 | _neuMax = 0.151;
|
---|
[2161] | 187 | }
|
---|
[2163] | 188 |
|
---|
[2201] | 189 | unsigned hour, minute;
|
---|
| 190 | double second;
|
---|
| 191 | int ww = QFontMetrics(this->font()).width('w');
|
---|
| 192 |
|
---|
| 193 | // neu components
|
---|
| 194 | // --------------
|
---|
| 195 | for (int ii = 1; ii < _pos.size(); ++ii) {
|
---|
| 196 | double t1 = _tMin + (_pos[ii-1]->time - _pos[0]->time);
|
---|
| 197 | double t2 = _tMin + (_pos[ii]->time - _pos[0]->time);
|
---|
| 198 |
|
---|
[4539] | 199 | // Audio alarm
|
---|
| 200 | // -----------
|
---|
| 201 | // if ( ii == _pos.size() -1) {
|
---|
| 202 | // if (fabs(neu[ii-1][0]) > 0.10 || fabs(neu[ii-1][1]) > 0.10) {
|
---|
| 203 | // QApplication::beep();
|
---|
| 204 | // }
|
---|
| 205 | // }
|
---|
[2201] | 206 |
|
---|
| 207 | // dots
|
---|
| 208 | // ----
|
---|
[2205] | 209 | painter.setPen(QColor(Qt::gray));
|
---|
| 210 | painter.drawLine(pltPoint(t1, neu[ii-1][0]), pltPoint(t2, neu[ii][0]));
|
---|
[2201] | 211 | painter.setPen(QColor(Qt::red));
|
---|
| 212 | painter.setBrush(QColor(Qt::red));
|
---|
[2209] | 213 | painter.drawEllipse(pltPoint(t1,neu[ii-1][0]), ww/6, ww/6);
|
---|
[2201] | 214 |
|
---|
[2205] | 215 | painter.setPen(QColor(Qt::gray));
|
---|
| 216 | painter.drawLine(pltPoint(t1, neu[ii-1][1]), pltPoint(t2, neu[ii][1]));
|
---|
[2201] | 217 | painter.setPen(QColor(Qt::green));
|
---|
| 218 | painter.setBrush(QColor(Qt::green));
|
---|
[2209] | 219 | painter.drawEllipse(pltPoint(t1,neu[ii-1][1]), ww/6, ww/6);
|
---|
[2201] | 220 |
|
---|
[2205] | 221 | painter.setPen(QColor(Qt::gray));
|
---|
| 222 | painter.drawLine(pltPoint(t1, neu[ii-1][2]), pltPoint(t2, neu[ii][2]));
|
---|
[2201] | 223 | painter.setPen(QColor(Qt::blue));
|
---|
| 224 | painter.setBrush(QColor(Qt::blue));
|
---|
[2209] | 225 | painter.drawEllipse(pltPoint(t1,neu[ii-1][2]), ww/6, ww/6);
|
---|
[2201] | 226 |
|
---|
| 227 | // time-tics
|
---|
| 228 | // ---------
|
---|
| 229 | if ( fmod(_pos[ii-1]->time.daysec(), 60.0) == 0 ) {
|
---|
| 230 | _pos[ii-1]->time.civil_time(hour, minute, second);
|
---|
| 231 | QPoint pntTic = pltPoint(t1, 0.0);
|
---|
| 232 | QString strTic = QString("%1:%2").arg(hour, 2, 10, QChar('0'))
|
---|
| 233 | .arg(minute, 2, 10, QChar('0'));
|
---|
| 234 | double xFirstCharTic = pntTic.x() - ww * 1.2;
|
---|
| 235 | if ( xFirstCharTic > pltPoint(_tMin, 0.0).x()) {
|
---|
| 236 | painter.setPen(QColor(Qt::black));
|
---|
| 237 | painter.drawText(int(xFirstCharTic), int(pntTic.y() + ww * 1.7),
|
---|
| 238 | strTic);
|
---|
| 239 | painter.drawLine(pntTic.x(), pntTic.y(),
|
---|
| 240 | pntTic.x(), pntTic.y()+ww/2);
|
---|
| 241 | }
|
---|
| 242 | }
|
---|
| 243 | }
|
---|
| 244 |
|
---|
[2163] | 245 | // time-axis
|
---|
| 246 | // ---------
|
---|
[2201] | 247 | painter.setPen(QColor(Qt::black));
|
---|
[2156] | 248 | painter.drawLine(pltPoint(_tMin, 0.0), pltPoint(_tMin+_tRange, 0.0));
|
---|
[2148] | 249 |
|
---|
[2163] | 250 | // neu-axis
|
---|
| 251 | // --------
|
---|
[2158] | 252 | painter.drawLine(pltPoint(_tMin, -_neuMax), pltPoint(_tMin, _neuMax));
|
---|
[2148] | 253 |
|
---|
[2163] | 254 | // neu-tics
|
---|
| 255 | // --------
|
---|
[2201] | 256 | double tic = floor(20.0 * (_neuMax - 0.05)) / 20.0;
|
---|
[2163] | 257 | QString strP = QString("%1 m").arg( tic,0,'f',2);
|
---|
| 258 | QString strM = QString("%1 m").arg(-tic,0,'f',2);
|
---|
[2165] | 259 | QString strZ = QString("%1 m").arg(0.0,0,'f',2);
|
---|
[2159] | 260 |
|
---|
[2163] | 261 | QPoint pntP = pltPoint(_tMin, tic);
|
---|
| 262 | QPoint pntM = pltPoint(_tMin,-tic);
|
---|
[2165] | 263 | QPoint pntZ = pltPoint(_tMin, 0.0);
|
---|
[2163] | 264 |
|
---|
[2167] | 265 | painter.setPen(QColor(Qt::red));
|
---|
[2177] | 266 | painter.drawText(0, ww, pntP.x() + 3*ww, pntP.x(), Qt::AlignRight, "N");
|
---|
| 267 | painter.setPen(QColor(Qt::green));
|
---|
| 268 | painter.drawText(0, ww, pntP.x() + 4*ww, pntP.x(), Qt::AlignRight, "E");
|
---|
[2167] | 269 | painter.setPen(QColor(Qt::blue));
|
---|
[2177] | 270 | painter.drawText(0, ww, pntP.x() + 5*ww, pntP.x(), Qt::AlignRight, "U");
|
---|
| 271 |
|
---|
[2167] | 272 | painter.setPen(QColor(Qt::black));
|
---|
[2177] | 273 | painter.drawText(0, pntP.y()-ww/2, pntP.x()- ww/4, pntP.x(),
|
---|
| 274 | Qt::AlignRight, strP);
|
---|
| 275 | painter.drawText(0, pntM.y()-ww/2, pntM.x()- ww/4, pntM.x(),
|
---|
| 276 | Qt::AlignRight, strM);
|
---|
| 277 | painter.drawText(0, pntZ.y()-ww/2, pntZ.x()- ww/4, pntZ.x(),
|
---|
| 278 | Qt::AlignRight, strZ);
|
---|
[2163] | 279 |
|
---|
| 280 | painter.drawLine(pntP.x(), pntP.y(), pntP.x()+ww, pntP.y());
|
---|
| 281 | painter.drawLine(pntM.x(), pntM.y(), pntM.x()+ww, pntM.y());
|
---|
| 282 |
|
---|
[2177] | 283 | // Start Time
|
---|
| 284 | // ----------
|
---|
| 285 | _startTime.civil_time(hour, minute, second);
|
---|
| 286 | QString startStr = QString("Start %1:%2:%3")
|
---|
| 287 | .arg(hour, 2, 10, QChar('0'))
|
---|
| 288 | .arg(minute, 2, 10, QChar('0'))
|
---|
| 289 | .arg(int(second), 2, 10, QChar('0'));
|
---|
| 290 | painter.setPen(QColor(Qt::black));
|
---|
[2197] | 291 | painter.drawText(0, ww, pntP.x() + 16*ww, pntP.x(),
|
---|
[2177] | 292 | Qt::AlignRight, startStr);
|
---|
[2146] | 293 | }
|
---|
| 294 | }
|
---|
[2140] | 295 | }
|
---|
| 296 |
|
---|