[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 |
|
---|
[5229] | 52 | // Current Coordinates
|
---|
| 53 | // -------------------
|
---|
| 54 | _currLat = 50.09057949; // BKG latitude
|
---|
| 55 | _currLon = 8.66496871; // BKG longitude
|
---|
[5180] | 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 |
|
---|
[5228] | 64 | _statusLabel = new QLabel;
|
---|
[5161] | 65 |
|
---|
[5180] | 66 | // Layout
|
---|
| 67 | // ------
|
---|
[5228] | 68 | QHBoxLayout* statusLayout = new QHBoxLayout;
|
---|
| 69 | statusLayout->addWidget(_statusLabel);
|
---|
| 70 |
|
---|
[5180] | 71 | QVBoxLayout* mainLayout = new QVBoxLayout(this);
|
---|
| 72 | mainLayout->addWidget(_webView);
|
---|
[5228] | 73 | mainLayout->addLayout(statusLayout);
|
---|
[5180] | 74 |
|
---|
| 75 | setLayout(mainLayout);
|
---|
[5161] | 76 | resize(60*ww, 60*ww);
|
---|
[5180] | 77 |
|
---|
[5161] | 78 | show();
|
---|
| 79 | }
|
---|
| 80 |
|
---|
| 81 | // Destructor
|
---|
| 82 | ////////////////////////////////////////////////////////////////////////////
|
---|
| 83 | bncMapWin::~bncMapWin() {
|
---|
| 84 | }
|
---|
| 85 |
|
---|
[5166] | 86 | //
|
---|
| 87 | ////////////////////////////////////////////////////////////////////////////
|
---|
| 88 | void bncMapWin::loadHtmlPage() {
|
---|
| 89 |
|
---|
[5213] | 90 | QFile htmlFile(":/map/map_gm.html");
|
---|
[5166] | 91 | if (!htmlFile.open(QFile::ReadOnly)) {
|
---|
[5213] | 92 | qDebug() << "bncMapWin:: cannot open html file";
|
---|
[5166] | 93 | return;
|
---|
| 94 | }
|
---|
| 95 |
|
---|
| 96 | QTextStream stream(&htmlFile);
|
---|
| 97 | QString html = stream.readAll();
|
---|
| 98 |
|
---|
| 99 | _webView->setHtml(html);
|
---|
| 100 | }
|
---|
| 101 |
|
---|
[5167] | 102 | //
|
---|
| 103 | ////////////////////////////////////////////////////////////////////////////
|
---|
| 104 | void bncMapWin::slotInitMap(bool isOk) {
|
---|
| 105 | if (!isOk) {
|
---|
| 106 | return;
|
---|
| 107 | }
|
---|
[5177] | 108 | QString location = QString("%1, %2").arg(_currLat,0,'f',8).arg(_currLon,0,'f',8);
|
---|
[5167] | 109 | _webView->page()->mainFrame()->evaluateJavaScript(QString("initialize( %1 )").arg(location));
|
---|
[5177] | 110 | }
|
---|
[5175] | 111 |
|
---|
[5177] | 112 | //
|
---|
| 113 | ////////////////////////////////////////////////////////////////////////////
|
---|
[5187] | 114 | void bncMapWin::gotoLocation(double lat, double lon) {
|
---|
[5180] | 115 | _currLat = lat;
|
---|
| 116 | _currLon = lon;
|
---|
[5177] | 117 | QString location = QString("%1, %2").arg(_currLat,0,'f',8).arg(_currLon,0,'f',8);
|
---|
[5228] | 118 | _statusLabel->setText(location);
|
---|
[5177] | 119 | _webView->page()->mainFrame()->evaluateJavaScript(QString("gotoLocation( %1 )").arg(location));
|
---|
[5180] | 120 | }
|
---|
| 121 |
|
---|
| 122 | //
|
---|
| 123 | ////////////////////////////////////////////////////////////////////////////
|
---|
[5188] | 124 | void bncMapWin::slotNewPosition(bncTime /* time */, double xx, double yy, double zz) {
|
---|
| 125 | double xyz[3];
|
---|
| 126 | xyz[0] = xx;
|
---|
| 127 | xyz[1] = yy;
|
---|
| 128 | xyz[2] = zz;
|
---|
| 129 | double ell[3];
|
---|
| 130 | xyz2ell(xyz, ell);
|
---|
| 131 | gotoLocation(ell[0]*180.0/M_PI, ell[1]*180.0/M_PI);
|
---|
[5187] | 132 | }
|
---|