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