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