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 | ////////////////////////////////////////////////////////////////////////////
|
---|
63 | void bncFigurePPP::slotNewPosition(bncTime time, double x, double y, double z){
|
---|
64 |
|
---|
65 | const static int MAXNUMPOS = 1000;
|
---|
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 | //// beg test
|
---|
79 | cout << newPos->time.timestr(1) << " "
|
---|
80 | << newPos->xyz[0] << " "
|
---|
81 | << newPos->xyz[1] << " "
|
---|
82 | << newPos->xyz[2] << endl;
|
---|
83 | //// end test
|
---|
84 |
|
---|
85 | if (_pos.size() > MAXNUMPOS) {
|
---|
86 | delete _pos[0];
|
---|
87 | _pos.pop_front();
|
---|
88 | }
|
---|
89 |
|
---|
90 | repaint();
|
---|
91 | }
|
---|
92 |
|
---|
93 | //
|
---|
94 | ////////////////////////////////////////////////////////////////////////////
|
---|
95 | void bncFigurePPP::paintEvent(QPaintEvent *) {
|
---|
96 |
|
---|
97 | cout << "paintEvent" << endl;
|
---|
98 |
|
---|
99 | int tMin = 0;
|
---|
100 | int tMax = 640;
|
---|
101 | int xMin = 0;
|
---|
102 | int xMax = 140;
|
---|
103 | float xLine = .60;
|
---|
104 |
|
---|
105 | QPainter painter(this);
|
---|
106 |
|
---|
107 | QFont font;
|
---|
108 | font.setPointSize(int(font.QFont::pointSize()*0.8));
|
---|
109 | painter.setFont(font);
|
---|
110 |
|
---|
111 | // x-axis
|
---|
112 | // ------
|
---|
113 | painter.drawLine(tMin+60, int((xMax-xMin)*xLine), tMax*3,
|
---|
114 | int((xMax-xMin)*xLine));
|
---|
115 |
|
---|
116 | // y-axis
|
---|
117 | // ------
|
---|
118 | painter.drawLine(tMin+60, int((xMax-xMin)*xLine), tMin+60, xMin+10);
|
---|
119 |
|
---|
120 | // Plot X-coordinates
|
---|
121 | // ------------------
|
---|
122 | if (_pos.size() > 1) {
|
---|
123 | double posXmin = _pos[0]->xyz[0];
|
---|
124 | double posXmax = _pos[0]->xyz[0];
|
---|
125 | for (int ii = 1; ii < _pos.size(); ++ii) {
|
---|
126 | if (_pos[ii]->xyz[0] < posXmin) {
|
---|
127 | posXmin = _pos[ii]->xyz[0];
|
---|
128 | }
|
---|
129 | if (_pos[ii]->xyz[0] > posXmax) {
|
---|
130 | posXmax = _pos[ii]->xyz[0];
|
---|
131 | }
|
---|
132 | }
|
---|
133 | double rangeX = posXmax - posXmin; // in meters
|
---|
134 | double rangeT = _pos[_pos.size()-1]->time - _pos[0]->time; // in seconds
|
---|
135 |
|
---|
136 | if (rangeX > 0.0 && rangeT > 0.0) {
|
---|
137 | double factorX = (xMax - xMin) / rangeX;
|
---|
138 | double factorT = (tMax - tMin) / rangeT;
|
---|
139 |
|
---|
140 | for (int ii = 1; ii < _pos.size(); ++ii) {
|
---|
141 | int t1 = int( (_pos[ii-1]->time - _pos[0]->time) * factorT ) ;
|
---|
142 | int t2 = int( (_pos[ii]->time - _pos[0]->time) * factorT ) ;
|
---|
143 | int x1 = int( (_pos[ii-1]->xyz[0] - posXmin) * factorX ) ;
|
---|
144 | int x2 = int( (_pos[ii]->xyz[0] - posXmin) * factorX ) ;
|
---|
145 |
|
---|
146 | painter.drawLine(t1, x1, t2, x2);
|
---|
147 | }
|
---|
148 | }
|
---|
149 | }
|
---|
150 | }
|
---|
151 |
|
---|