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: bncMapWin
|
---|
30 | *
|
---|
31 | * Purpose: Displays the Google Map
|
---|
32 | *
|
---|
33 | * Author: L. Mervart
|
---|
34 | *
|
---|
35 | * Created: 08-Jun-2013
|
---|
36 | *
|
---|
37 | * Changes:
|
---|
38 | *
|
---|
39 | * -----------------------------------------------------------------------*/
|
---|
40 |
|
---|
41 | #include "map/bncmapwin.h"
|
---|
42 | #include "bncutils.h"
|
---|
43 |
|
---|
44 | // Constructor
|
---|
45 | ////////////////////////////////////////////////////////////////////////////
|
---|
46 | bncMapWin::bncMapWin(QWidget* parent) : QDialog(parent) {
|
---|
47 |
|
---|
48 | const int ww = QFontMetrics(font()).width('w');
|
---|
49 |
|
---|
50 | setWindowTitle("BNC: Map View");
|
---|
51 |
|
---|
52 | // BKG Coordinates
|
---|
53 | // ---------------
|
---|
54 | _currLat = 50.090956;
|
---|
55 | _currLon = 8.663283;
|
---|
56 |
|
---|
57 | _webView = new QWebView(this);
|
---|
58 | connect(_webView, SIGNAL(loadFinished(bool)), this, SLOT(slotInitMap(bool)));
|
---|
59 |
|
---|
60 | loadHtmlPage();
|
---|
61 |
|
---|
62 | _webView->show();
|
---|
63 |
|
---|
64 | // Test
|
---|
65 | // ----
|
---|
66 | _mode = mode_ppp;
|
---|
67 | _testButton = new QPushButton(tr("Start Test"));
|
---|
68 | _testButton->setMaximumWidth(10*ww);
|
---|
69 | connect(_testButton, SIGNAL(clicked()), this, SLOT(slotTest()));
|
---|
70 |
|
---|
71 | // Layout
|
---|
72 | // ------
|
---|
73 | QHBoxLayout* buttonLayout = new QHBoxLayout;
|
---|
74 | buttonLayout->addWidget(_testButton);
|
---|
75 |
|
---|
76 | QVBoxLayout* mainLayout = new QVBoxLayout(this);
|
---|
77 | mainLayout->addWidget(_webView);
|
---|
78 | mainLayout->addLayout(buttonLayout);
|
---|
79 |
|
---|
80 | setLayout(mainLayout);
|
---|
81 | resize(60*ww, 60*ww);
|
---|
82 |
|
---|
83 | show();
|
---|
84 | }
|
---|
85 |
|
---|
86 | // Destructor
|
---|
87 | ////////////////////////////////////////////////////////////////////////////
|
---|
88 | bncMapWin::~bncMapWin() {
|
---|
89 | }
|
---|
90 |
|
---|
91 | //
|
---|
92 | ////////////////////////////////////////////////////////////////////////////
|
---|
93 | void bncMapWin::loadHtmlPage() {
|
---|
94 |
|
---|
95 | QFile htmlFile(":/map/map_gm.html");
|
---|
96 | if (!htmlFile.open(QFile::ReadOnly)) {
|
---|
97 | qDebug() << "bncMapWin:: cannot open html file";
|
---|
98 | return;
|
---|
99 | }
|
---|
100 |
|
---|
101 | QTextStream stream(&htmlFile);
|
---|
102 | QString html = stream.readAll();
|
---|
103 |
|
---|
104 | _webView->setHtml(html);
|
---|
105 | }
|
---|
106 |
|
---|
107 | //
|
---|
108 | ////////////////////////////////////////////////////////////////////////////
|
---|
109 | void bncMapWin::slotInitMap(bool isOk) {
|
---|
110 | if (!isOk) {
|
---|
111 | return;
|
---|
112 | }
|
---|
113 | QString location = QString("%1, %2").arg(_currLat,0,'f',8).arg(_currLon,0,'f',8);
|
---|
114 | _webView->page()->mainFrame()->evaluateJavaScript(QString("initialize( %1 )").arg(location));
|
---|
115 | }
|
---|
116 |
|
---|
117 | //
|
---|
118 | ////////////////////////////////////////////////////////////////////////////
|
---|
119 | void bncMapWin::gotoLocation(double lat, double lon) {
|
---|
120 | _currLat = lat;
|
---|
121 | _currLon = lon;
|
---|
122 | QString location = QString("%1, %2").arg(_currLat,0,'f',8).arg(_currLon,0,'f',8);
|
---|
123 | _webView->page()->mainFrame()->evaluateJavaScript(QString("gotoLocation( %1 )").arg(location));
|
---|
124 | }
|
---|
125 |
|
---|
126 | //
|
---|
127 | ////////////////////////////////////////////////////////////////////////////
|
---|
128 | void bncMapWin::slotTest() {
|
---|
129 |
|
---|
130 | if (sender() == _testButton) {
|
---|
131 | if (_mode == mode_ppp) {
|
---|
132 | _mode = mode_test;
|
---|
133 | _testButton->setText(tr("Stop Test"));
|
---|
134 | }
|
---|
135 | else {
|
---|
136 | _mode = mode_ppp;
|
---|
137 | _testButton->setText(tr("Start Test"));
|
---|
138 | return;
|
---|
139 | }
|
---|
140 | }
|
---|
141 |
|
---|
142 | if (_mode == mode_test) {
|
---|
143 | _currLat += 0.00001;
|
---|
144 | _currLon += 0.00001;
|
---|
145 | gotoLocation(_currLat, _currLon);
|
---|
146 | QTimer::singleShot(100, this, SLOT(slotTest()));
|
---|
147 | }
|
---|
148 | }
|
---|
149 |
|
---|
150 | //
|
---|
151 | ////////////////////////////////////////////////////////////////////////////
|
---|
152 | void bncMapWin::slotNewPosition(bncTime /* time */, double xx, double yy, double zz) {
|
---|
153 | double xyz[3];
|
---|
154 | xyz[0] = xx;
|
---|
155 | xyz[1] = yy;
|
---|
156 | xyz[2] = zz;
|
---|
157 | double ell[3];
|
---|
158 | xyz2ell(xyz, ell);
|
---|
159 | gotoLocation(ell[0]*180.0/M_PI, ell[1]*180.0/M_PI);
|
---|
160 | }
|
---|