Rev 358 | Go to most recent revision | Only display areas with differences | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 358 | Rev 361 | ||
---|---|---|---|
1 | /*************************************************************************** |
1 | /*************************************************************************** |
2 | * Copyright (C) 2009 by Manuel Schrape * |
2 | * Copyright (C) 2009 by Manuel Schrape * |
3 | * manuel.schrape@gmx.de * |
3 | * manuel.schrape@gmx.de * |
4 | * * |
4 | * * |
5 | * This program is free software; you can redistribute it and/or modify * |
5 | * This program is free software; you can redistribute it and/or modify * |
6 | * it under the terms of the GNU General Public License as published by * |
6 | * it under the terms of the GNU General Public License as published by * |
7 | * the Free Software Foundation; either version 2 of the License. * |
7 | * the Free Software Foundation; either version 2 of the License. * |
8 | * * |
8 | * * |
9 | * This program is distributed in the hope that it will be useful, * |
9 | * This program is distributed in the hope that it will be useful, * |
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of * |
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of * |
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * |
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * |
12 | * GNU General Public License for more details. * |
12 | * GNU General Public License for more details. * |
13 | * * |
13 | * * |
14 | * You should have received a copy of the GNU General Public License * |
14 | * You should have received a copy of the GNU General Public License * |
15 | * along with this program; if not, write to the * |
15 | * along with this program; if not, write to the * |
16 | * Free Software Foundation, Inc., * |
16 | * Free Software Foundation, Inc., * |
17 | * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * |
17 | * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * |
18 | ***************************************************************************/ |
18 | ***************************************************************************/ |
19 | #include "dlg_Map.h" |
19 | #include "dlg_Map.h" |
- | 20 | #include <QDomDocument> |
|
- | 21 | #include <QFile> |
|
20 | 22 | ||
21 | dlg_Map::dlg_Map(QWidget *parent) : QDialog(parent) |
23 | dlg_Map::dlg_Map(QWidget *parent) : QDialog(parent) |
22 | { |
24 | { |
23 | setupUi(this); |
25 | setupUi(this); |
24 | 26 | ||
25 | cb_Maps->removeItem(5); |
27 | cb_Maps->removeItem(5); |
26 | cb_Maps->removeItem(4); |
28 | cb_Maps->removeItem(4); |
27 | cb_Maps->removeItem(3); |
29 | cb_Maps->removeItem(3); |
28 | cb_Maps->removeItem(2); |
30 | cb_Maps->removeItem(2); |
29 | 31 | ||
30 | pb_Add->setEnabled(false); |
32 | pb_Add->setEnabled(false); |
31 | pb_Goto->setEnabled(false); |
33 | pb_Goto->setEnabled(false); |
32 | } |
34 | } |
33 | 35 | ||
34 | // Karte erstellen und anzeigen |
36 | // Karte erstellen und anzeigen |
35 | void dlg_Map::create_Map(cSettings *t_Settings) |
37 | void dlg_Map::create_Map(cSettings *t_Settings) |
36 | { |
38 | { |
37 | o_Settings = t_Settings; |
39 | o_Settings = t_Settings; |
38 | 40 | ||
39 | cb_CenterPos->setChecked(o_Settings->Map.GotoPosition); |
41 | cb_CenterPos->setChecked(o_Settings->Map.GotoPosition); |
40 | cb_ShowRoute->setChecked(o_Settings->Map.ShowTrack); |
42 | cb_ShowRoute->setChecked(o_Settings->Map.ShowTrack); |
41 | 43 | ||
42 | connect(sl_Zoom, SIGNAL(valueChanged(int)), this, SLOT(slot_Zoom(int))); |
44 | connect(sl_Zoom, SIGNAL(valueChanged(int)), this, SLOT(slot_Zoom(int))); |
43 | connect(pb_Add, SIGNAL(clicked()), this, SLOT(slot_AddWayPoint())); |
45 | connect(pb_Add, SIGNAL(clicked()), this, SLOT(slot_AddWayPoint())); |
44 | connect(pb_Delete, SIGNAL(clicked()), this, SLOT(slot_DeleteWayPoints())); |
46 | connect(pb_Delete, SIGNAL(clicked()), this, SLOT(slot_DeleteWayPoints())); |
45 | connect(pb_Goto, SIGNAL(clicked()), this, SLOT(slot_GotoTarget())); |
47 | connect(pb_Goto, SIGNAL(clicked()), this, SLOT(slot_GotoTarget())); |
46 | connect(pb_SendWaypoints, SIGNAL(clicked()), this, SLOT(slot_SendWayPoints())); |
48 | connect(pb_SendWaypoints, SIGNAL(clicked()), this, SLOT(slot_SendWayPoints())); |
- | 49 | ||
- | 50 | connect(pb_Load, SIGNAL(clicked()), this, SLOT(slot_LoadWayPoints())); |
|
- | 51 | connect(pb_Save, SIGNAL(clicked()), this, SLOT(slot_SaveWayPoints())); |
|
- | 52 | ||
47 | connect(cb_Maps, SIGNAL(currentIndexChanged(int)), this, SLOT(slot_ChangeMap(int))); |
53 | connect(cb_Maps, SIGNAL(currentIndexChanged(int)), this, SLOT(slot_ChangeMap(int))); |
- | 54 | connect(cb_ShowWPs, SIGNAL(toggled(bool)), this, SLOT(slot_ShowWayPoints(bool))); |
|
- | 55 | ||
48 | connect(this, SIGNAL(rejected()), this, SLOT(slot_Close())); |
56 | connect(this, SIGNAL(rejected()), this, SLOT(slot_Close())); |
49 | 57 | ||
50 | o_Map = new MapControl(w_Map->size()); |
58 | o_Map = new MapControl(w_Map->size()); |
51 | o_Map->enablePersistentCache(o_Settings->DIR.Cache); |
59 | o_Map->enablePersistentCache(o_Settings->DIR.Cache); |
52 | o_Map->showScale(true); |
60 | o_Map->showScale(true); |
53 | 61 | ||
54 | o_Adapter = new OSMMapAdapter(); |
62 | o_Adapter = new OSMMapAdapter(); |
55 | 63 | ||
56 | o_Layer = new MapLayer("MapLayer", o_Adapter); |
64 | o_Layer = new MapLayer("MapLayer", o_Adapter); |
57 | o_Click = new GeometryLayer("Click", o_Adapter); |
65 | o_Click = new GeometryLayer("Click", o_Adapter); |
58 | o_Route = new GeometryLayer("Poute", o_Adapter); |
66 | o_Route = new GeometryLayer("Poute", o_Adapter); |
59 | 67 | ||
60 | o_Map->addLayer(o_Layer); |
68 | o_Map->addLayer(o_Layer); |
61 | o_Map->addLayer(o_Click); |
69 | o_Map->addLayer(o_Click); |
62 | o_Map->addLayer(o_Route); |
70 | o_Map->addLayer(o_Route); |
63 | 71 | ||
64 | o_Map->setZoom(17); |
72 | o_Map->setZoom(17); |
65 | o_Map->setView(QPointF(13.5,52.5)); |
73 | o_Map->setView(QPointF(13.5,52.5)); |
66 | 74 | ||
67 | connect(o_Map, SIGNAL(mouseEventCoordinate(const QMouseEvent*, const QPointF)), this, SLOT(slot_Click(const QMouseEvent*, const QPointF))); |
75 | connect(o_Map, SIGNAL(mouseEventCoordinate(const QMouseEvent*, const QPointF)), this, SLOT(slot_Click(const QMouseEvent*, const QPointF))); |
68 | 76 | ||
69 | l_Map->addWidget(o_Map); |
77 | l_Map->addWidget(o_Map); |
70 | 78 | ||
71 | sl_Zoom->setValue(17); |
79 | sl_Zoom->setValue(17); |
72 | 80 | ||
73 | Pen[0] = new QPen(QColor(0,0,255,255)); |
81 | Pen[0] = new QPen(QColor(0,0,255,255)); |
74 | Pen[0]->setWidth(2); |
82 | Pen[0]->setWidth(2); |
75 | Pen[1] = new QPen(QColor(255,0,0,255)); |
83 | Pen[1] = new QPen(QColor(255,0,0,255)); |
76 | Pen[1]->setWidth(2); |
84 | Pen[1]->setWidth(2); |
77 | } |
85 | } |
- | 86 | ||
- | 87 | QList<sWayPoint> dlg_Map::parse_WayPointKML(QString s_File) |
|
- | 88 | { |
|
- | 89 | QList<sWayPoint> tmp_WayPoints; |
|
- | 90 | sWayPoint tmp_WayPoint; |
|
- | 91 | ||
- | 92 | QFile f_KML(s_File); |
|
- | 93 | f_KML.open(QIODevice::ReadOnly | QIODevice::Text); |
|
- | 94 | ||
- | 95 | QByteArray s_KML; |
|
- | 96 | ||
- | 97 | while (!f_KML.atEnd()) |
|
- | 98 | { |
|
- | 99 | s_KML.append(f_KML.readLine()); |
|
- | 100 | } |
|
- | 101 | ||
- | 102 | f_KML.close(); |
|
- | 103 | ||
- | 104 | QDomDocument *UserXML; |
|
- | 105 | UserXML = new QDomDocument; |
|
- | 106 | ||
- | 107 | UserXML->setContent(s_KML); |
|
- | 108 | ||
- | 109 | QDomElement Root = UserXML->firstChildElement("kml"); |
|
- | 110 | QDomElement Document = Root.firstChildElement("Document"); |
|
- | 111 | QDomElement Placemark = Document.firstChildElement("Placemark"); |
|
- | 112 | QDomElement Linestring = Placemark.firstChildElement("LineString"); |
|
- | 113 | ||
- | 114 | QString Name = Placemark.firstChildElement("name").toElement().text(); |
|
- | 115 | ||
- | 116 | QString Route = Linestring.firstChildElement("coordinates").toElement().text(); |
|
- | 117 | ||
- | 118 | QStringList s_Points = Route.split(" "); |
|
- | 119 | ||
- | 120 | QStringList Position; |
|
- | 121 | ||
- | 122 | for (int z = 0; z < s_Points.count() - 1; z++) |
|
- | 123 | { |
|
- | 124 | if (z != 20) |
|
- | 125 | { |
|
- | 126 | Position = s_Points[z].split(","); |
|
- | 127 | tmp_WayPoint.Longitude = Position[0].toDouble(); |
|
- | 128 | tmp_WayPoint.Latitude = Position[1].toDouble(); |
|
- | 129 | tmp_WayPoint.Altitude = Position[2].toDouble(); |
|
- | 130 | tmp_WayPoint.Time = sb_Time->value(); |
|
- | 131 | ||
- | 132 | tmp_WayPoints.append(tmp_WayPoint); |
|
- | 133 | } |
|
- | 134 | else |
|
- | 135 | { |
|
- | 136 | QMessageBox::warning(this, QA_NAME,trUtf8("Die Wegpunkt-Liste umfasst mehr als 20 Einträge. Es werden nur die ersten 20 Einträge übernommen."), QMessageBox::Ok); |
|
- | 137 | ||
- | 138 | pb_Add->setEnabled(false); |
|
- | 139 | ||
- | 140 | z = s_Points.count(); |
|
- | 141 | } |
|
- | 142 | } |
|
- | 143 | return tmp_WayPoints; |
|
- | 144 | } |
|
- | 145 | ||
- | 146 | QList<sWayPoint> dlg_Map::parse_WayPointMKW(QString s_File) |
|
- | 147 | { |
|
- | 148 | QList<sWayPoint> tmp_WayPoints; |
|
- | 149 | sWayPoint tmp_WayPoint; |
|
- | 150 | ||
- | 151 | QFile f_MKW(s_File); |
|
- | 152 | f_MKW.open(QIODevice::ReadOnly | QIODevice::Text); |
|
- | 153 | ||
- | 154 | QString s_MKW; |
|
- | 155 | ||
- | 156 | while (!f_MKW.atEnd()) |
|
- | 157 | { |
|
- | 158 | s_MKW.append(f_MKW.readLine()); |
|
- | 159 | } |
|
- | 160 | ||
- | 161 | f_MKW.close(); |
|
- | 162 | ||
- | 163 | QStringList s_Points = s_MKW.split(" "); |
|
- | 164 | ||
- | 165 | QStringList Position; |
|
- | 166 | ||
- | 167 | for (int z = 0; z < s_Points.count() - 1; z++) |
|
- | 168 | { |
|
- | 169 | if (z != 20) |
|
- | 170 | { |
|
- | 171 | Position = s_Points[z].split(","); |
|
- | 172 | tmp_WayPoint.Longitude = Position[0].toDouble(); |
|
- | 173 | tmp_WayPoint.Latitude = Position[1].toDouble(); |
|
- | 174 | tmp_WayPoint.Altitude = Position[2].toDouble(); |
|
- | 175 | tmp_WayPoint.Time = Position[3].toInt(); |
|
- | 176 | ||
- | 177 | tmp_WayPoints.append(tmp_WayPoint); |
|
- | 178 | } |
|
- | 179 | else |
|
- | 180 | { |
|
- | 181 | QMessageBox::warning(this, QA_NAME,trUtf8("Die Wegpunkt-Liste umfasst mehr als 20 Einträge. Es werden nur die ersten 20 Einträge übernommen."), QMessageBox::Ok); |
|
- | 182 | ||
- | 183 | pb_Add->setEnabled(false); |
|
- | 184 | ||
- | 185 | z = s_Points.count(); |
|
- | 186 | } |
|
- | 187 | } |
|
- | 188 | return tmp_WayPoints; |
|
- | 189 | } |
|
- | 190 | ||
- | 191 | void dlg_Map::show_WayPoints(QList<sWayPoint> WayPoints) |
|
- | 192 | { |
|
- | 193 | Point* p_Point; |
|
- | 194 | ||
- | 195 | o_Route->removeGeometry(l_RouteWP); |
|
- | 196 | p_RouteWP.clear(); |
|
- | 197 | l_WayPoints.clear(); |
|
- | 198 | ||
- | 199 | l_WayPoints = WayPoints; |
|
- | 200 | ||
- | 201 | for (int z = 0; z < WayPoints.count(); z++) |
|
- | 202 | { |
|
- | 203 | p_Point = new Point(WayPoints[z].Longitude, WayPoints[z].Latitude); |
|
- | 204 | ||
- | 205 | p_RouteWP.append(p_Point); |
|
- | 206 | } |
|
- | 207 | ||
- | 208 | l_RouteWP = new LineString(p_RouteWP, "", Pen[0]); |
|
- | 209 | o_Route->addGeometry(l_RouteWP); |
|
- | 210 | ||
- | 211 | o_Map->setView(p_Point); |
|
- | 212 | ||
- | 213 | o_Map->updateRequestNew(); |
|
- | 214 | } |
|
- | 215 | ||
- | 216 | void dlg_Map::save_WayPointsMKW(QString s_File) |
|
- | 217 | { |
|
- | 218 | QFile *f_MKW = new QFile(s_File); |
|
- | 219 | ||
- | 220 | f_MKW->open(QIODevice::ReadWrite | QIODevice::Text); |
|
- | 221 | ||
- | 222 | QTextStream out(f_MKW); |
|
- | 223 | ||
- | 224 | out.setRealNumberPrecision(9); |
|
- | 225 | ||
- | 226 | for (int z = 0; z < l_WayPoints.count(); z++) |
|
- | 227 | { |
|
- | 228 | out << l_WayPoints[z].Longitude << "," << l_WayPoints[z].Latitude << "," << l_WayPoints[z].Altitude << "," << l_WayPoints[z].Time << " \n"; |
|
- | 229 | } |
|
- | 230 | ||
- | 231 | f_MKW->close(); |
|
- | 232 | } |
|
- | 233 | ||
- | 234 | void dlg_Map::slot_LoadWayPoints() |
|
- | 235 | { |
|
- | 236 | QString Filename = QFileDialog::getOpenFileName(this, "WayPoint-Route laden", o_Settings->DIR.Logging, "Mikrokopter WayPoints(*.mkw);;KML-Datei(*.kml);;Alle Dateien (*)"); |
|
- | 237 | ||
- | 238 | if (!Filename.isEmpty()) |
|
- | 239 | { |
|
- | 240 | if (Filename.endsWith(".kml", Qt::CaseInsensitive)) |
|
- | 241 | { |
|
- | 242 | cb_ShowWPs->setChecked(true); |
|
- | 243 | pb_SendWaypoints->setEnabled(true); |
|
- | 244 | ||
- | 245 | show_WayPoints(parse_WayPointKML(Filename)); |
|
- | 246 | } |
|
- | 247 | if (Filename.endsWith(".mkw", Qt::CaseInsensitive)) |
|
- | 248 | { |
|
- | 249 | cb_ShowWPs->setChecked(true); |
|
- | 250 | pb_SendWaypoints->setEnabled(true); |
|
- | 251 | ||
- | 252 | show_WayPoints(parse_WayPointMKW(Filename)); |
|
- | 253 | } |
|
- | 254 | } |
|
- | 255 | } |
|
- | 256 | ||
- | 257 | void dlg_Map::slot_SaveWayPoints() |
|
- | 258 | { |
|
- | 259 | QString Filename = QFileDialog::getSaveFileName(this, "WayPoint-Route speichern", o_Settings->DIR.Logging, "Mikrokopter WayPoints(*.mkw);;Alle Dateien (*)"); |
|
- | 260 | ||
- | 261 | if (!Filename.isEmpty()) |
|
- | 262 | { |
|
- | 263 | if (!(Filename.endsWith(".mkw", Qt::CaseInsensitive))) |
|
- | 264 | { |
|
- | 265 | Filename = Filename + QString(".mkw"); |
|
- | 266 | } |
|
- | 267 | ||
- | 268 | save_WayPointsMKW(Filename); |
|
- | 269 | } |
|
- | 270 | } |
|
- | 271 | ||
- | 272 | void dlg_Map::slot_ShowWayPoints(bool Show) |
|
- | 273 | { |
|
- | 274 | if (Show == true) |
|
- | 275 | { |
|
- | 276 | qDebug("An"); |
|
- | 277 | o_Route->addGeometry(l_RouteWP); |
|
- | 278 | o_Map->updateRequestNew(); |
|
- | 279 | } |
|
- | 280 | else |
|
- | 281 | { |
|
- | 282 | qDebug("Aus"); |
|
- | 283 | o_Route->removeGeometry(l_RouteWP); |
|
- | 284 | o_Map->updateRequestNew(); |
|
- | 285 | } |
|
- | 286 | } |
|
78 | 287 | ||
79 | // Position zum Flug-Track hinzufügen |
288 | // Position zum Flug-Track hinzufügen |
80 | void dlg_Map::add_Position(double x, double y) |
289 | void dlg_Map::add_Position(double x, double y) |
81 | { |
290 | { |
82 | sWayPoint WayPoint; |
291 | sWayPoint WayPoint; |
83 | 292 | ||
84 | WayPoint.Longitude = x; |
293 | WayPoint.Longitude = x; |
85 | WayPoint.Latitude = y; |
294 | WayPoint.Latitude = y; |
86 | // WayPoint.Time = sb_Time->value(); |
295 | // WayPoint.Time = sb_Time->value(); |
87 | 296 | ||
88 | l_Track.append(WayPoint); |
297 | l_Track.append(WayPoint); |
89 | 298 | ||
90 | o_Route->removeGeometry(l_RouteFL); |
299 | o_Route->removeGeometry(l_RouteFL); |
91 | p_RouteFL.append(new Point(x,y)); |
300 | p_RouteFL.append(new Point(x,y)); |
92 | 301 | ||
93 | o_Click->removeGeometry(LastPos); |
302 | o_Click->removeGeometry(LastPos); |
94 | 303 | ||
95 | Point* P = new CirclePoint(x, y, "P1", Point::Middle, Pen[0]); |
304 | Point* P = new CirclePoint(x, y, "P1", Point::Middle, Pen[0]); |
96 | LastPos = P; |
305 | LastPos = P; |
97 | P->setBaselevel(17); |
306 | P->setBaselevel(17); |
98 | o_Click->addGeometry(P); |
307 | o_Click->addGeometry(P); |
99 | 308 | ||
100 | if (cb_CenterPos->isChecked()) |
309 | if (cb_CenterPos->isChecked()) |
101 | { |
310 | { |
102 | o_Map->setView(QPointF(x, y)); |
311 | o_Map->setView(QPointF(x, y)); |
103 | } |
312 | } |
104 | 313 | ||
105 | if (cb_ShowRoute->isChecked()) |
314 | if (cb_ShowRoute->isChecked()) |
106 | { |
315 | { |
107 | l_RouteFL = new LineString(p_RouteFL, "", Pen[1]); |
316 | l_RouteFL = new LineString(p_RouteFL, "", Pen[1]); |
108 | 317 | ||
109 | o_Route->addGeometry(l_RouteFL); |
318 | o_Route->addGeometry(l_RouteFL); |
110 | } |
319 | } |
111 | o_Map->updateRequestNew(); |
320 | o_Map->updateRequestNew(); |
112 | } |
321 | } |
113 | 322 | ||
114 | // Zoom der Karte ändern |
323 | // Zoom der Karte ändern |
115 | void dlg_Map::slot_Zoom(int t_Zoom) |
324 | void dlg_Map::slot_Zoom(int t_Zoom) |
116 | { |
325 | { |
117 | o_Map->setZoom(t_Zoom); |
326 | o_Map->setZoom(t_Zoom); |
118 | } |
327 | } |
119 | 328 | ||
120 | // Waypoint zur Liste hinzufügen |
329 | // Waypoint zur Liste hinzufügen |
121 | void dlg_Map::slot_AddWayPoint() |
330 | void dlg_Map::slot_AddWayPoint() |
122 | { |
331 | { |
- | 332 | cb_ShowWPs->setChecked(true); |
|
- | 333 | ||
123 | sWayPoint WayPoint; |
334 | sWayPoint WayPoint; |
124 | 335 | ||
125 | WayPoint.Longitude = LastClick->longitude(); |
336 | WayPoint.Longitude = LastClick->longitude(); |
126 | WayPoint.Latitude = LastClick->latitude(); |
337 | WayPoint.Latitude = LastClick->latitude(); |
127 | WayPoint.Time = sb_Time->value(); |
338 | WayPoint.Time = sb_Time->value(); |
128 | 339 | ||
129 | l_WayPoints.append(WayPoint); |
340 | l_WayPoints.append(WayPoint); |
130 | 341 | ||
131 | o_Route->removeGeometry(l_RouteWP); |
342 | o_Route->removeGeometry(l_RouteWP); |
132 | 343 | ||
133 | p_RouteWP.append(LastClick); |
344 | p_RouteWP.append(LastClick); |
134 | l_RouteWP = new LineString(p_RouteWP, "", Pen[0]); |
345 | l_RouteWP = new LineString(p_RouteWP, "", Pen[0]); |
135 | 346 | ||
136 | o_Route->addGeometry(l_RouteWP); |
347 | o_Route->addGeometry(l_RouteWP); |
137 | o_Map->updateRequestNew(); |
348 | o_Map->updateRequestNew(); |
138 | 349 | ||
139 | pb_SendWaypoints->setEnabled(true); |
350 | pb_SendWaypoints->setEnabled(true); |
- | 351 | ||
- | 352 | if (l_WayPoints.count() == 20) |
|
- | 353 | { |
|
- | 354 | QMessageBox::warning(this, QA_NAME,trUtf8("Wegpunkt-Liste ist voll. Es können maximal 20 Wegpunkte benutzt werden."), QMessageBox::Ok); |
|
- | 355 | pb_Add->setEnabled(false); |
|
- | 356 | } |
|
- | 357 | ||
140 | } |
358 | } |
141 | 359 | ||
142 | // Waypoint-Liste löschen |
360 | // Waypoint-Liste löschen |
143 | void dlg_Map::slot_DeleteWayPoints() |
361 | void dlg_Map::slot_DeleteWayPoints() |
144 | { |
362 | { |
145 | o_Route->removeGeometry(l_RouteWP); |
363 | o_Route->removeGeometry(l_RouteWP); |
146 | p_RouteWP.clear(); |
364 | p_RouteWP.clear(); |
147 | l_WayPoints.clear(); |
365 | l_WayPoints.clear(); |
148 | o_Map->updateRequestNew(); |
366 | o_Map->updateRequestNew(); |
- | 367 | ||
- | 368 | pb_Add->setEnabled(pb_Goto->isEnabled()); |
|
149 | } |
369 | } |
150 | 370 | ||
151 | void dlg_Map::slot_SendWayPoints() |
371 | void dlg_Map::slot_SendWayPoints() |
152 | { |
372 | { |
153 | emit(set_WayPoints(l_WayPoints)); |
373 | emit(set_WayPoints(l_WayPoints)); |
154 | } |
374 | } |
155 | 375 | ||
156 | // Zum Zielpunkt fliegen |
376 | // Zum Zielpunkt fliegen |
157 | void dlg_Map::slot_GotoTarget() |
377 | void dlg_Map::slot_GotoTarget() |
158 | { |
378 | { |
159 | sWayPoint Target; |
379 | sWayPoint Target; |
160 | 380 | ||
161 | Target.Longitude = LastClick->longitude(); |
381 | Target.Longitude = LastClick->longitude(); |
162 | Target.Latitude = LastClick->latitude(); |
382 | Target.Latitude = LastClick->latitude(); |
163 | Target.Time = sb_Time->value(); |
383 | Target.Time = sb_Time->value(); |
164 | 384 | ||
165 | emit(set_Target(Target)); |
385 | emit(set_Target(Target)); |
166 | } |
386 | } |
167 | 387 | ||
168 | // Click in der Karte |
388 | // Click in der Karte |
169 | void dlg_Map::slot_Click(const QMouseEvent* Event, const QPointF Coord) |
389 | void dlg_Map::slot_Click(const QMouseEvent* Event, const QPointF Coord) |
170 | { |
390 | { |
171 | if ((Event->type() == QEvent::MouseButtonPress) && ((Event->button() == Qt::RightButton) || (Event->button() == Qt::MidButton))) |
391 | if ((Event->type() == QEvent::MouseButtonPress) && ((Event->button() == Qt::RightButton) || (Event->button() == Qt::MidButton))) |
172 | { |
392 | { |
173 | sl_Zoom->setValue(o_Adapter->adaptedZoom()); |
393 | sl_Zoom->setValue(o_Adapter->adaptedZoom()); |
174 | } |
394 | } |
175 | 395 | ||
176 | // Überwachen ob Karte verschoben wird |
396 | // Überwachen ob Karte verschoben wird |
177 | if ((Event->type() == QEvent::MouseButtonPress) && (Event->button() == Qt::LeftButton)) |
397 | if ((Event->type() == QEvent::MouseButtonPress) && (Event->button() == Qt::LeftButton)) |
178 | { |
398 | { |
179 | MapCenter = o_Map->currentCoordinate(); |
399 | MapCenter = o_Map->currentCoordinate(); |
180 | } |
400 | } |
181 | 401 | ||
182 | // Nur wenn nicht Verschoben dann einen Punkt setzen |
402 | // Nur wenn nicht Verschoben dann einen Punkt setzen |
183 | if ((Event->type() == QEvent::MouseButtonRelease) && (Event->button() == Qt::LeftButton)) |
403 | if ((Event->type() == QEvent::MouseButtonRelease) && (Event->button() == Qt::LeftButton)) |
184 | { |
404 | { |
185 | if (o_Map->currentCoordinate() == MapCenter) |
405 | if (o_Map->currentCoordinate() == MapCenter) |
186 | { |
406 | { |
- | 407 | if (l_WayPoints.count() < 20) |
|
- | 408 | { |
|
187 | pb_Add->setEnabled(true); |
409 | pb_Add->setEnabled(true); |
- | 410 | } |
|
188 | pb_Goto->setEnabled(true); |
411 | pb_Goto->setEnabled(true); |
189 | 412 | ||
190 | o_Click->removeGeometry(ClickPoint); |
413 | o_Click->removeGeometry(ClickPoint); |
191 | 414 | ||
192 | ClickPoint = new CirclePoint(Coord.x(), Coord.y(), 6, "P1", Point::Middle, Pen[1]); |
415 | ClickPoint = new CirclePoint(Coord.x(), Coord.y(), 6, "P1", Point::Middle, Pen[1]); |
193 | // LastPoint = P; |
- | |
194 | 416 | ||
195 | LastClick = new Point(Coord.x(), Coord.y()); |
417 | LastClick = new Point(Coord.x(), Coord.y()); |
196 | 418 | ||
197 | ClickPoint->setBaselevel(o_Adapter->adaptedZoom()); |
419 | ClickPoint->setBaselevel(o_Adapter->adaptedZoom()); |
198 | o_Click->addGeometry(ClickPoint); |
420 | o_Click->addGeometry(ClickPoint); |
199 | } |
421 | } |
200 | } |
422 | } |
201 | 423 | ||
202 | o_Map->updateRequestNew(); |
424 | o_Map->updateRequestNew(); |
203 | // qDebug(QString("%1").arg(Coord.x()).toLatin1().data()); |
425 | // qDebug(QString("%1").arg(Coord.x()).toLatin1().data()); |
204 | // qDebug(QString("%1").arg(Coord.y()).toLatin1().data()); |
426 | // qDebug(QString("%1").arg(Coord.y()).toLatin1().data()); |
205 | } |
427 | } |
206 | 428 | ||
207 | // auf Veränderung der Fenstergröße reagieren |
429 | // auf Veränderung der Fenstergröße reagieren |
208 | void dlg_Map::resizeEvent ( QResizeEvent * event ) |
430 | void dlg_Map::resizeEvent ( QResizeEvent * event ) |
209 | { |
431 | { |
210 | event = event; |
432 | event = event; |
211 | o_Map->resize(w_Map->size() - QSize(20,20)); |
433 | o_Map->resize(w_Map->size() - QSize(20,20)); |
212 | } |
434 | } |
213 | 435 | ||
214 | // Karte wechseln |
436 | // Karte wechseln |
215 | void dlg_Map::slot_ChangeMap(int t_Set) |
437 | void dlg_Map::slot_ChangeMap(int t_Set) |
216 | { |
438 | { |
217 | int zoom = o_Adapter->adaptedZoom(); |
439 | int zoom = o_Adapter->adaptedZoom(); |
218 | QPointF a = o_Map->currentCoordinate(); |
440 | QPointF a = o_Map->currentCoordinate(); |
219 | 441 | ||
220 | o_Map->setZoom(0); |
442 | o_Map->setZoom(0); |
221 | 443 | ||
222 | switch(t_Set) |
444 | switch(t_Set) |
223 | { |
445 | { |
224 | case 0 : // OpenStreetMap |
446 | case 0 : // OpenStreetMap |
225 | { |
447 | { |
226 | o_Adapter = new OSMMapAdapter(); |
448 | o_Adapter = new OSMMapAdapter(); |
227 | } |
449 | } |
228 | break; |
450 | break; |
229 | case 1 : // Yahoo Sat |
451 | case 1 : // Yahoo Sat |
230 | { |
452 | { |
231 | o_Adapter = new TileMapAdapter("tile.openaerialmap.org", "/tiles/1.0.0/openaerialmap-900913/%1/%2/%3.png", 256, 0, 17); |
453 | o_Adapter = new TileMapAdapter("tile.openaerialmap.org", "/tiles/1.0.0/openaerialmap-900913/%1/%2/%3.png", 256, 0, 17); |
232 | } |
454 | } |
233 | break; |
455 | break; |
234 | case 2 : // Google Maps |
456 | case 2 : // Google Maps |
235 | { |
457 | { |
236 | o_Adapter = new GoogleMapAdapter(); |
458 | o_Adapter = new GoogleMapAdapter(); |
237 | } |
459 | } |
238 | break; |
460 | break; |
239 | case 3 : // Google Sat |
461 | case 3 : // Google Sat |
240 | { |
462 | { |
241 | o_Adapter = new GoogleSatMapAdapter(); |
463 | o_Adapter = new GoogleSatMapAdapter(); |
242 | } |
464 | } |
243 | break; |
465 | break; |
244 | case 4 : // Yahoo Maps |
466 | case 4 : // Yahoo Maps |
245 | { |
467 | { |
246 | o_Adapter = new YahooMapAdapter(); |
468 | o_Adapter = new YahooMapAdapter(); |
247 | } |
469 | } |
248 | break; |
470 | break; |
249 | case 5 : // Yahoo Sat |
471 | case 5 : // Yahoo Sat |
250 | { |
472 | { |
251 | o_Adapter = new YahooMapAdapter("us.maps3.yimg.com", "/aerial.maps.yimg.com/png?v=1.7&t=a&s=256&x=%2&y=%3&z=%1"); |
473 | o_Adapter = new YahooMapAdapter("us.maps3.yimg.com", "/aerial.maps.yimg.com/png?v=1.7&t=a&s=256&x=%2&y=%3&z=%1"); |
252 | } |
474 | } |
253 | break; |
475 | break; |
254 | } |
476 | } |
255 | 477 | ||
256 | o_Layer->setMapAdapter(o_Adapter); |
478 | o_Layer->setMapAdapter(o_Adapter); |
257 | o_Click->setMapAdapter(o_Adapter); |
479 | o_Click->setMapAdapter(o_Adapter); |
258 | o_Route->setMapAdapter(o_Adapter); |
480 | o_Route->setMapAdapter(o_Adapter); |
259 | 481 | ||
260 | o_Map->updateRequestNew(); |
482 | o_Map->updateRequestNew(); |
261 | o_Map->setZoom(zoom); |
483 | o_Map->setZoom(zoom); |
262 | } |
484 | } |
263 | 485 | ||
264 | // Fenster wird geschlossen. |
486 | // Fenster wird geschlossen. |
265 | void dlg_Map::slot_Close() |
487 | void dlg_Map::slot_Close() |
266 | { |
488 | { |
267 | o_Settings->Map.GotoPosition = cb_CenterPos->isChecked(); |
489 | o_Settings->Map.GotoPosition = cb_CenterPos->isChecked(); |
268 | o_Settings->Map.ShowTrack = cb_ShowRoute->isChecked(); |
490 | o_Settings->Map.ShowTrack = cb_ShowRoute->isChecked(); |
269 | emit set_Settings(o_Settings); |
491 | emit set_Settings(o_Settings); |
270 | } |
492 | } |
271 | 493 | ||
272 | 494 |