source: ntrip/trunk/BNC/src/map/bncmapwin.cpp@ 5229

Last change on this file since 5229 was 5229, checked in by mervart, 9 years ago
File size: 3.8 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: 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////////////////////////////////////////////////////////////////////////////
46bncMapWin::bncMapWin(QWidget* parent) : QDialog(parent) {
47
48 const int ww = QFontMetrics(font()).width('w');
49
50 setWindowTitle("BNC: Map View");
51
52 // Current Coordinates
53 // -------------------
54 _currLat = 50.09057949; // BKG latitude
55 _currLon = 8.66496871; // BKG longitude
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 _statusLabel = new QLabel;
65
66 // Layout
67 // ------
68 QHBoxLayout* statusLayout = new QHBoxLayout;
69 statusLayout->addWidget(_statusLabel);
70
71 QVBoxLayout* mainLayout = new QVBoxLayout(this);
72 mainLayout->addWidget(_webView);
73 mainLayout->addLayout(statusLayout);
74
75 setLayout(mainLayout);
76 resize(60*ww, 60*ww);
77
78 show();
79}
80
81// Destructor
82////////////////////////////////////////////////////////////////////////////
83bncMapWin::~bncMapWin() {
84}
85
86//
87////////////////////////////////////////////////////////////////////////////
88void bncMapWin::loadHtmlPage() {
89
90 QFile htmlFile(":/map/map_gm.html");
91 if (!htmlFile.open(QFile::ReadOnly)) {
92 qDebug() << "bncMapWin:: cannot open html file";
93 return;
94 }
95
96 QTextStream stream(&htmlFile);
97 QString html = stream.readAll();
98
99 _webView->setHtml(html);
100}
101
102//
103////////////////////////////////////////////////////////////////////////////
104void bncMapWin::slotInitMap(bool isOk) {
105 if (!isOk) {
106 return;
107 }
108 QString location = QString("%1, %2").arg(_currLat,0,'f',8).arg(_currLon,0,'f',8);
109 _webView->page()->mainFrame()->evaluateJavaScript(QString("initialize( %1 )").arg(location));
110}
111
112//
113////////////////////////////////////////////////////////////////////////////
114void bncMapWin::gotoLocation(double lat, double lon) {
115 _currLat = lat;
116 _currLon = lon;
117 QString location = QString("%1, %2").arg(_currLat,0,'f',8).arg(_currLon,0,'f',8);
118 _statusLabel->setText(location);
119 _webView->page()->mainFrame()->evaluateJavaScript(QString("gotoLocation( %1 )").arg(location));
120}
121
122//
123////////////////////////////////////////////////////////////////////////////
124void 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);
132}
Note: See TracBrowser for help on using the repository browser.