-
Notifications
You must be signed in to change notification settings - Fork 0
/
mapviewer.cpp
97 lines (79 loc) · 2.71 KB
/
mapviewer.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
#include "mapviewer.h"
MapViewer::MapViewer (QWidget *parent) : DataViewer(parent)
{
map = new QWebEngineView();
viewerLayout->addWidget(map);
map->setUrl(QUrl("qrc:/html/google_maps.html"));
map->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Minimum);
map->setMinimumSize(300, 200);
map->show();
cleanMap = new QPushButton("Clean");
cleanMap->setFixedSize(100, 25);
connect(cleanMap, SIGNAL(pressed()), this, SLOT(onCleanMapPressed()));
buttonLayout->addWidget(cleanMap);
}
void MapViewer::startPreparationToDraw()
{
//add start marker?
}
void MapViewer::updateViewer(bool isForward)
{
if ( isForward )
{
if (actionData[currentRecord]){
addMarker(currentRecord);
}
currentRecord != 0 ? addLine(currentRecord) : removeAllLines();
}
else
{
if (actionData[currentRecord]){
removeMarker(currentRecord);
}
currentRecord != recordCounter - 1 ? removeLine(currentRecord) : addAllLines();
}
}
void MapViewer::addMarker(qint64 id){
QString jsParam = QString::number(viewerData[0][id]) + "," +
QString::number(viewerData[1][id]) ;
QString str = "addMarker(" + jsParam + ");"; // run func from google_maps.html
map->page()->runJavaScript(str);
}
void MapViewer::removeMarker(qint64 id){
QString jsParam = QString::number(id-1);
QString str = "removeMarker(" + jsParam + ");"; // run func from google_maps.html
map->page()->runJavaScript(str);
}
void MapViewer::removeAllMarkers(){
map->page()->runJavaScript("removeAllMarkers()");
}
void MapViewer::addLine(qint64 id){
QString jsParam = QString::number(viewerData[0][id-1]) + "," + // current lat
QString::number(viewerData[1][id-1]) + "," + // current lng
QString::number(viewerData[0][id]) + "," + // next lat
QString::number(viewerData[1][id]) ; // next lng
QString str = "addLine(" + jsParam + ");"; // run func from google_maps.html
map->page()->runJavaScript(str);
}
void MapViewer::addAllLines(){
for (qint64 i = 1; i < recordCounter; ++i)
addLine(i); // add line from ( i - 1 ) to ( i )
}
void MapViewer::removeLine(qint64 id){
QString jsParam = QString::number(id-1);
QString str = "removeLine(" + jsParam + ");"; // run func from google_maps.html
map->page()->runJavaScript(str);
}
void MapViewer::removeAllLines(){
map->page()->runJavaScript("removeAllLines()");
}
void MapViewer::onCleanMapPressed()
{
removeAllLines();
}
void MapViewer::onHidePressed()
{
map->setVisible(map->isVisible() ? false : true);
filenameLabel->setVisible(map->isVisible());
}
void MapViewer::onClosePressed() {}