source: ntrip/trunk/BNC/bncfigureppp.cpp@ 2156

Last change on this file since 2156 was 2156, checked in by mervart, 14 years ago

* empty log message *

File size: 4.4 KB
Line 
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
46using namespace std;
47
48// Constructor
49////////////////////////////////////////////////////////////////////////////
50bncFigurePPP::bncFigurePPP(QWidget *parent) : QWidget(parent) {
51}
52
53// Destructor
54////////////////////////////////////////////////////////////////////////////
55bncFigurePPP::~bncFigurePPP() {
56 for (int ii = 0; ii < _pos.size(); ++ii) {
57 delete _pos[ii];
58 }
59}
60
61//
62////////////////////////////////////////////////////////////////////////////
63void bncFigurePPP::slotNewPosition(bncTime time, double x, double y, double z){
64
65 const static int MAXNUMPOS = 300;
66
67 QMutexLocker locker(&_mutex);
68
69 pppPos* newPos = new pppPos;
70
71 newPos->time = time;
72 newPos->xyz[0] = x;
73 newPos->xyz[1] = y;
74 newPos->xyz[2] = z;
75
76 _pos.push_back(newPos);
77
78 if (_pos.size() > MAXNUMPOS) {
79 delete _pos[0];
80 _pos.pop_front();
81 }
82
83 update();
84}
85
86//
87////////////////////////////////////////////////////////////////////////////
88QPoint bncFigurePPP::pltPoint(double tt, double yy) {
89
90 const static double scale0 = 0.8;
91 double tScale = scale0 * _width / _tRange;
92 double yScale = scale0 * _height / (2.0 * _xyzMax);
93 double tOffset = _tRange / 10.0;
94
95 int tNew = int( (tt-_tMin+tOffset) * tScale);
96 int yNew = int( (yy+_xyzMax) * yScale);
97
98 return QPoint(tNew, yNew);
99}
100
101//
102////////////////////////////////////////////////////////////////////////////
103void bncFigurePPP::paintEvent(QPaintEvent *) {
104
105 QPainter painter(this);
106 _width = painter.viewport().width();
107 _height = painter.viewport().height();
108
109 // Plot X-coordinates as a function of time (in seconds)
110 // -----------------------------------------------------
111 if (_pos.size() > 1) {
112
113 // Find the minimum and maximum values
114 // -----------------------------------
115 _tRange = _pos[_pos.size()-1]->time - _pos[0]->time; // in sec
116 _tMin = _pos[0]->time.gpssec();
117
118 // Reduced Coordinates
119 // -------------------
120 _xyzMax = 0.0;
121 double neu[_pos.size()][3];
122 for (int ii = 0; ii < _pos.size(); ++ii) {
123 for (int ic = 0; ic < 3; ++ic) {
124 neu[ii][ic] = _pos[ii]->xyz[ic] - _pos[0]->xyz[ic];
125 if (fabs(neu[ii][ic]) > _xyzMax) {
126 _xyzMax = fabs(neu[ii][ic]);
127 }
128 }
129 }
130
131 if (_xyzMax > 0.0 && _tRange > 0.0) {
132
133 // x-axis
134 // ------
135 painter.drawLine(pltPoint(_tMin, 0.0), pltPoint(_tMin+_tRange, 0.0));
136
137 // y-axis
138 // ------
139 painter.drawLine(pltPoint(_tMin, -_xyzMax), pltPoint(_tMin, _xyzMax));
140
141 for (int ii = 1; ii < _pos.size(); ++ii) {
142 double t1 = _tMin + (_pos[ii-1]->time - _pos[0]->time);
143 double t2 = _tMin + (_pos[ii]->time - _pos[0]->time);
144 painter.setPen(QColor(Qt::red));
145 painter.drawLine(pltPoint(t1, neu[ii-1][0]), pltPoint(t2, neu[ii][0]));
146 painter.setPen(QColor(Qt::green));
147 painter.drawLine(pltPoint(t1, neu[ii-1][1]), pltPoint(t2, neu[ii][1]));
148 painter.setPen(QColor(Qt::blue));
149 painter.drawLine(pltPoint(t1, neu[ii-1][2]), pltPoint(t2, neu[ii][2]));
150 }
151 }
152 }
153}
154
Note: See TracBrowser for help on using the repository browser.