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