0,0 → 1,198 |
/*************************************************************************** |
* Copyright (C) 2009 by Manuel Schrape * |
* manuel.schrape@gmx.de * |
* * |
* This program is free software; you can redistribute it and/or modify * |
* it under the terms of the GNU General Public License as published by * |
* the Free Software Foundation; either version 2 of the License. * |
* * |
* This program is distributed in the hope that it will be useful, * |
* but WITHOUT ANY WARRANTY; without even the implied warranty of * |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * |
* GNU General Public License for more details. * |
* * |
* You should have received a copy of the GNU General Public License * |
* along with this program; if not, write to the * |
* Free Software Foundation, Inc., * |
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * |
***************************************************************************/ |
#include "dlg_Map.h" |
|
dlg_Map::dlg_Map(QWidget *parent) : QDialog(parent) |
{ |
setupUi(this); |
|
connect(sl_Zoom, SIGNAL(valueChanged(int)), this, SLOT(slot_Zoom(int))); |
connect(pb_Add, SIGNAL(clicked()), this, SLOT(slot_AddWP())); |
connect(pb_Delete, SIGNAL(clicked()), this, SLOT(slot_DeleteWP())); |
connect(cb_Maps, SIGNAL(currentIndexChanged(int)), this, SLOT(slot_ChangeMap(int))); |
|
// o_Map = new MapControl(QSize(500,300)); |
o_Map = new MapControl(w_Map->size()); |
|
o_Adapter = new OSMMapAdapter(); |
// o_Adapter = new GoogleMapAdapter(); |
|
o_Layer = new MapLayer("MapLayer", o_Adapter); |
o_Click = new GeometryLayer("Click", o_Adapter); |
o_Route = new GeometryLayer("Poute", o_Adapter); |
|
o_Map->addLayer(o_Layer); |
o_Map->addLayer(o_Click); |
o_Map->addLayer(o_Route); |
|
o_Map->setZoom(17); |
// o_Map->setView(QPointF(13.85615670,52.50787020)); |
o_Map->setView(QPointF(13.5,52.5)); |
|
connect(o_Map, SIGNAL(mouseEventCoordinate(const QMouseEvent*, const QPointF)), this, SLOT(slot_Click(const QMouseEvent*, const QPointF))); |
|
l_Map->addWidget(o_Map); |
|
sl_Zoom->setValue(17); |
|
QDir path = QDir::homePath() + "/.QMK-Cache"; |
o_Map->enablePersistentCache(path); |
|
Pen[0] = new QPen(QColor(0,0,255,255)); |
Pen[0]->setWidth(2); |
Pen[1] = new QPen(QColor(255,0,0,255)); |
Pen[1]->setWidth(2); |
|
} |
|
void dlg_Map::add_Position(double x, double y) |
{ |
o_Route->removeGeometry(l_RouteFL); |
p_RouteFL.append(new Point(x,y)); |
|
o_Click->removeGeometry(LastPos); |
|
Point* P = new CirclePoint(x, y, "P1", Point::Middle, Pen[0]); |
LastPos = P; |
P->setBaselevel(17); |
o_Click->addGeometry(P); |
|
if (cb_CenterPos->isChecked()) |
{ |
o_Map->setView(QPointF(x, y)); |
} |
|
if (cb_ShowRoute->isChecked()) |
{ |
l_RouteFL = new LineString(p_RouteFL, "", Pen[1]); |
|
o_Route->addGeometry(l_RouteFL); |
} |
o_Map->updateRequestNew(); |
} |
|
void dlg_Map::slot_Zoom(int i_Zoom) |
{ |
o_Map->setZoom(i_Zoom); |
} |
|
void dlg_Map::slot_AddWP() |
{ |
o_Route->removeGeometry(l_RouteWP); |
|
p_RouteWP.append(LastClick); |
l_RouteWP = new LineString(p_RouteWP, "", Pen[0]); |
|
o_Route->addGeometry(l_RouteWP); |
o_Map->updateRequestNew(); |
} |
|
void dlg_Map::slot_DeleteWP() |
{ |
o_Route->removeGeometry(l_RouteWP); |
p_RouteWP.clear(); |
o_Map->updateRequestNew(); |
} |
|
void dlg_Map::slot_Click(const QMouseEvent* Event, const QPointF Coord) |
{ |
if ((Event->type() == QEvent::MouseButtonPress) && ((Event->button() == Qt::RightButton) || (Event->button() == Qt::MidButton))) |
{ |
sl_Zoom->setValue(o_Adapter->adaptedZoom()); |
} |
|
if ((Event->type() == QEvent::MouseButtonPress) && (Event->button() == Qt::LeftButton)) |
{ |
o_Click->removeGeometry(LastPoint); |
|
Point* P = new CirclePoint(Coord.x(), Coord.y(), 3, "P1", Point::Middle, Pen[1]); |
LastPoint = P; |
|
LastClick = new Point(Coord.x(), Coord.y()); |
|
P->setBaselevel(o_Adapter->adaptedZoom()); |
o_Click->addGeometry(P); |
} |
o_Map->updateRequestNew(); |
} |
|
void dlg_Map::resizeEvent ( QResizeEvent * event ) |
{ |
// o_Map->resize(event->size()); |
o_Map->resize(w_Map->size() - QSize(20,20)); |
} |
|
void dlg_Map::slot_ChangeMap(int Set) |
{ |
switch(Set) |
{ |
case 0 : |
{ |
int zoom = o_Adapter->adaptedZoom(); |
o_Map->setZoom(0); |
|
o_Adapter = new OSMMapAdapter(); |
o_Layer->setMapAdapter(o_Adapter); |
|
o_Map->updateRequestNew(); |
o_Map->setZoom(zoom); |
} |
break; |
case 1 : |
{ |
int zoom = o_Adapter->adaptedZoom(); |
o_Map->setZoom(0); |
|
o_Adapter = new YahooMapAdapter(); |
o_Layer->setMapAdapter(o_Adapter); |
|
o_Map->updateRequestNew(); |
o_Map->setZoom(zoom); |
} |
break; |
case 2 : |
{ |
int zoom = o_Adapter->adaptedZoom(); |
QPointF a = o_Map->currentCoordinate(); |
|
o_Map->setZoom(0); |
|
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"); |
o_Layer->setMapAdapter(o_Adapter); |
|
o_Map->updateRequestNew(); |
o_Map->setZoom(zoom); |
} |
break; |
case 3 : |
{ |
int zoom = o_Adapter->adaptedZoom(); |
QPointF a = o_Map->currentCoordinate(); |
|
o_Map->setZoom(0); |
|
o_Adapter = new GoogleMapAdapter(); |
o_Layer->setMapAdapter(o_Adapter); |
|
o_Map->updateRequestNew(); |
o_Map->setZoom(zoom); |
} |
break; |
} |
} |