[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 | *
|
---|
| 33 | * Author: Perlt, 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 |
|
---|
| 46 | using namespace std;
|
---|
| 47 |
|
---|
| 48 | // Constructor
|
---|
| 49 | ////////////////////////////////////////////////////////////////////////////
|
---|
| 50 | bncFigurePPP::bncFigurePPP(QWidget *parent) : QWidget(parent) {
|
---|
| 51 | }
|
---|
| 52 |
|
---|
| 53 | // Destructor
|
---|
| 54 | ////////////////////////////////////////////////////////////////////////////
|
---|
| 55 | bncFigurePPP::~bncFigurePPP() {
|
---|
| 56 | for (int ii = 0; ii < _pos.size(); ++ii) {
|
---|
| 57 | delete _pos[ii];
|
---|
| 58 | }
|
---|
| 59 | }
|
---|
| 60 |
|
---|
| 61 | //
|
---|
| 62 | ////////////////////////////////////////////////////////////////////////////
|
---|
[2145] | 63 | void bncFigurePPP::slotNewPosition(bncTime time, double x, double y, double z){
|
---|
[2140] | 64 |
|
---|
[2153] | 65 | const static int MAXNUMPOS = 300;
|
---|
[2140] | 66 |
|
---|
| 67 | QMutexLocker locker(&_mutex);
|
---|
| 68 |
|
---|
[2142] | 69 | pppPos* newPos = new pppPos;
|
---|
[2140] | 70 |
|
---|
[2142] | 71 | newPos->time = time;
|
---|
[2145] | 72 | newPos->xyz[0] = x;
|
---|
| 73 | newPos->xyz[1] = y;
|
---|
| 74 | newPos->xyz[2] = z;
|
---|
[2140] | 75 |
|
---|
| 76 | _pos.push_back(newPos);
|
---|
| 77 |
|
---|
| 78 | if (_pos.size() > MAXNUMPOS) {
|
---|
| 79 | delete _pos[0];
|
---|
| 80 | _pos.pop_front();
|
---|
| 81 | }
|
---|
| 82 |
|
---|
[2148] | 83 | update();
|
---|
[2140] | 84 | }
|
---|
| 85 |
|
---|
| 86 | //
|
---|
| 87 | ////////////////////////////////////////////////////////////////////////////
|
---|
| 88 | void bncFigurePPP::paintEvent(QPaintEvent *) {
|
---|
| 89 |
|
---|
| 90 | QPainter painter(this);
|
---|
| 91 |
|
---|
[2148] | 92 | // Plot X-coordinates as a function of time (in seconds)
|
---|
| 93 | // -----------------------------------------------------
|
---|
| 94 | if (_pos.size() > 1) {
|
---|
[2140] | 95 |
|
---|
[2148] | 96 | // Find the minimum and maximum values
|
---|
| 97 | // -----------------------------------
|
---|
| 98 | double tRange = _pos[_pos.size()-1]->time - _pos[0]->time; // in sec
|
---|
| 99 | double tMin = _pos[0]->time.gpssec();
|
---|
| 100 | double tMax = tMin + tRange;
|
---|
[2140] | 101 |
|
---|
[2152] | 102 | // Reduced Coordinates
|
---|
| 103 | // -------------------
|
---|
| 104 | double xx[_pos.size()];
|
---|
| 105 | double yy[_pos.size()];
|
---|
| 106 | double zz[_pos.size()];
|
---|
| 107 |
|
---|
| 108 | double xyzMax = 0.0;
|
---|
| 109 | for (int ii = 0; ii < _pos.size(); ++ii) {
|
---|
| 110 | xx[ii] = _pos[ii]->xyz[0] - _pos[0]->xyz[0];
|
---|
| 111 | yy[ii] = _pos[ii]->xyz[1] - _pos[0]->xyz[1];
|
---|
| 112 | zz[ii] = _pos[ii]->xyz[2] - _pos[0]->xyz[2];
|
---|
[2153] | 113 | if (fabs(xx[ii]) > xyzMax) {
|
---|
| 114 | xyzMax = fabs(xx[ii]);
|
---|
[2146] | 115 | }
|
---|
[2153] | 116 | if (fabs(yy[ii]) > xyzMax) {
|
---|
| 117 | xyzMax = fabs(yy[ii]);
|
---|
[2146] | 118 | }
|
---|
[2153] | 119 | if (fabs(zz[ii]) > xyzMax) {
|
---|
| 120 | xyzMax = fabs(zz[ii]);
|
---|
[2152] | 121 | }
|
---|
[2146] | 122 | }
|
---|
[2153] | 123 | double xyzRange = 2.0 * xyzMax;
|
---|
[2146] | 124 |
|
---|
[2152] | 125 | if (xyzRange > 0.0 && tRange > 0.0) {
|
---|
[2148] | 126 |
|
---|
[2149] | 127 | const static double scale0 = 0.8;
|
---|
[2151] | 128 | double tOffset = tRange / 10.0;
|
---|
[2153] | 129 | double xyzOffset = tRange / 10.0;
|
---|
[2149] | 130 | double tScale = scale0 * frameSize().width() / tRange;
|
---|
[2152] | 131 | double xScale = scale0 * frameSize().height() / xyzRange;
|
---|
[2149] | 132 |
|
---|
[2148] | 133 | QTransform transform;
|
---|
| 134 | transform.scale(tScale, xScale);
|
---|
[2153] | 135 | transform.translate(-tMin+tOffset, xyzMax/2.0 + xyzOffset);
|
---|
[2148] | 136 | painter.setTransform(transform);
|
---|
| 137 |
|
---|
| 138 | // x-axis
|
---|
| 139 | // ------
|
---|
[2153] | 140 | painter.drawLine(QPointF(tMin, 0.0), QPointF(tMax, 0.0));
|
---|
[2148] | 141 |
|
---|
| 142 | // y-axis
|
---|
| 143 | // ------
|
---|
[2153] | 144 | painter.drawLine(QPointF(tMin, -xyzMax), QPointF(tMin, xyzMax));
|
---|
[2148] | 145 |
|
---|
[2147] | 146 | for (int ii = 1; ii < _pos.size(); ++ii) {
|
---|
[2148] | 147 | double t1 = _pos[ii-1]->time.gpssec();
|
---|
| 148 | double t2 = _pos[ii]->time.gpssec();
|
---|
[2152] | 149 | painter.setPen(QColor(Qt::red));
|
---|
| 150 | painter.drawLine(QPointF(t1, xx[ii-1]), QPointF(t2, xx[ii]));
|
---|
| 151 | painter.setPen(QColor(Qt::green));
|
---|
| 152 | painter.drawLine(QPointF(t1, yy[ii-1]), QPointF(t2, yy[ii]));
|
---|
| 153 | painter.setPen(QColor(Qt::blue));
|
---|
| 154 | painter.drawLine(QPointF(t1, zz[ii-1]), QPointF(t2, zz[ii]));
|
---|
[2147] | 155 | }
|
---|
[2146] | 156 | }
|
---|
| 157 | }
|
---|
[2140] | 158 | }
|
---|
| 159 |
|
---|