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

Last change on this file since 5228 was 5228, checked in by mervart, 11 years ago
File size: 3.7 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 // 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 _statusLabel = new QLabel;
65
66 // Layout
67 // ------
68
69 QHBoxLayout* statusLayout = new QHBoxLayout;
70 statusLayout->addWidget(_statusLabel);
71
72 QVBoxLayout* mainLayout = new QVBoxLayout(this);
73 mainLayout->addWidget(_webView);
74 mainLayout->addLayout(statusLayout);
75
76 setLayout(mainLayout);
77 resize(60*ww, 60*ww);
78
79 show();
80}
81
82// Destructor
83////////////////////////////////////////////////////////////////////////////
84bncMapWin::~bncMapWin() {
85}
86
87//
88////////////////////////////////////////////////////////////////////////////
89void bncMapWin::loadHtmlPage() {
90
91 QFile htmlFile(":/map/map_gm.html");
92 if (!htmlFile.open(QFile::ReadOnly)) {
93 qDebug() << "bncMapWin:: cannot open html file";
94 return;
95 }
96
97 QTextStream stream(&htmlFile);
98 QString html = stream.readAll();
99
100 _webView->setHtml(html);
101}
102
103//
104////////////////////////////////////////////////////////////////////////////
105void bncMapWin::slotInitMap(bool isOk) {
106 if (!isOk) {
107 return;
108 }
109 QString location = QString("%1, %2").arg(_currLat,0,'f',8).arg(_currLon,0,'f',8);
110 _webView->page()->mainFrame()->evaluateJavaScript(QString("initialize( %1 )").arg(location));
111}
112
113//
114////////////////////////////////////////////////////////////////////////////
115void bncMapWin::gotoLocation(double lat, double lon) {
116 _currLat = lat;
117 _currLon = lon;
118 QString location = QString("%1, %2").arg(_currLat,0,'f',8).arg(_currLon,0,'f',8);
119 _statusLabel->setText(location);
120 _webView->page()->mainFrame()->evaluateJavaScript(QString("gotoLocation( %1 )").arg(location));
121}
122
123//
124////////////////////////////////////////////////////////////////////////////
125void bncMapWin::slotNewPosition(bncTime /* time */, double xx, double yy, double zz) {
126 double xyz[3];
127 xyz[0] = xx;
128 xyz[1] = yy;
129 xyz[2] = zz;
130 double ell[3];
131 xyz2ell(xyz, ell);
132 gotoLocation(ell[0]*180.0/M_PI, ell[1]*180.0/M_PI);
133}
Note: See TracBrowser for help on using the repository browser.