@ -44,30 +44,26 @@ MapWidget::MapWidget(QWidget *parent) :
@@ -44,30 +44,26 @@ MapWidget::MapWidget(QWidget *parent) :
m_ui ( new Ui : : MapWidget )
{
m_ui - > setupUi ( this ) ;
// Accept focus by clicking or keyboard
this - > setFocusPolicy ( Qt : : StrongFocus ) ;
// create MapControl
mc = new MapControl ( QSize ( 320 , 240 ) ) ;
mc - > showScale ( true ) ;
mc - > showCoord ( true ) ;
mc - > enablePersistentCache ( ) ;
//uasIcons = QMap<int, CirclePoint*>();
//QSize(480,640)
// ImageManager::instance()->setProxy("www-cache", 8080);
mc - > setMouseTracking ( true ) ; // required to update the mouse position for diplay and capture
// create MapAdapter to get maps from
TileMapAdapter * osmAdapter = new TileMapAdapter ( " tile.openstreetmap.org " , " /%1/%2/%3.png " , 256 , 0 , 17 ) ;
//GoogleSatMapAdapter* gSatAdapter = new GoogleSatMapAdapter();
// create a layer with the mapadapter and type MapLayer
osmLayer = new Layer ( " Custom Layer " , osmAdapter , Layer : : MapLayer ) ;
//Layer* gSatLayer = new Layer("Custom Layer", gSatAdapter, Layer::MapLayer);
// add Layer to the MapControl
mc - > addLayer ( osmLayer ) ;
//mc->addLayer(gSatLayer);
mc - > setZoom ( 3 ) ;
// display the MapControl in the application
QHBoxLayout * layout = new QHBoxLayout ;
@ -75,40 +71,81 @@ MapWidget::MapWidget(QWidget *parent) :
@@ -75,40 +71,81 @@ MapWidget::MapWidget(QWidget *parent) :
layout - > addWidget ( mc ) ;
setLayout ( layout ) ;
// create buttons as controls for zoom
// create buttons to control the map (zoom, GPS tracking and WP capture)
QPushButton * zoomin = new QPushButton ( QIcon ( " :/images/actions/list-add.svg " ) , " " , this ) ;
QPushButton * zoomout = new QPushButton ( QIcon ( " :/images/actions/list-remove.svg " ) , " " , this ) ;
createPath = new QPushButton ( QIcon ( " :/images/actions/go-bottom.svg " ) , " " , this ) ;
followgps = new QPushButton ( QIcon ( " :/images/actions/system-lock-screen.svg " ) , " " , this ) ;
followgps - > setCheckable ( true ) ;
// gpsposition = new QLabel();
zoomin - > setMaximumWidth ( 50 ) ;
zoomout - > setMaximumWidth ( 50 ) ;
createPath - > setMaximumWidth ( 50 ) ;
followgps - > setMaximumWidth ( 50 ) ;
//gpsposition->setFont(QFont("Arial", 10));
connect ( zoomin , SIGNAL ( clicked ( bool ) ) ,
mc , SLOT ( zoomIn ( ) ) ) ;
connect ( zoomout , SIGNAL ( clicked ( bool ) ) ,
mc , SLOT ( zoomOut ( ) ) ) ;
// add zoom buttons to the layout of the MapControl
// Set checkable buttons
// TODO: Currently checked buttons are are very difficult to distinguish when checked.
// create a style and the slots to change the background so it is easier to distinguish
followgps - > setCheckable ( true ) ;
createPath - > setCheckable ( true ) ;
// add buttons to control the map (zoom, GPS tracking and WP capture)
QVBoxLayout * innerlayout = new QVBoxLayout ;
innerlayout - > addWidget ( zoomin ) ;
innerlayout - > addWidget ( zoomout ) ;
innerlayout - > addWidget ( followgps ) ;
//innerlayout->addWidget(gpsposition);
innerlayout - > addWidget ( createPath ) ;
mc - > setLayout ( innerlayout ) ;
// Connect the required signals-slots
connect ( UASManager : : instance ( ) , SIGNAL ( UASCreated ( UASInterface * ) ) ,
this , SLOT ( addUAS ( UASInterface * ) ) ) ;
connect ( mc , SIGNAL ( mouseEventCoordinate ( const QMouseEvent * , const QPointF ) ) ,
this , SLOT ( captureMapClick ( const QMouseEvent * , const QPointF ) ) ) ;
connect ( createPath , SIGNAL ( clicked ( bool ) ) ,
this , SLOT ( createPathButtonClicked ( ) ) ) ;
this - > setVisible ( false ) ;
// Attic (Code that was commented)
// ==============================
//uasIcons = QMap<int, CirclePoint*>();
//QSize(480,640)
// ImageManager::instance()->setProxy("www-cache", 8080);
//GoogleSatMapAdapter* gSatAdapter = new GoogleSatMapAdapter();
//Layer* gSatLayer = new Layer("Custom Layer", gSatAdapter, Layer::MapLayer);
//mc->addLayer(gSatLayer);
// gpsposition = new QLabel();
//gpsposition->setFont(QFont("Arial", 10));
//GPS_Neo* gm = new GPS_Neo();
//connect(gm, SIGNAL(new_position(float, QPointF)),
// this, SLOT(updatePosition(float, QPointF)));
//gm->start();
mc - > setZoom ( 3 ) ;
}
connect ( UASManager : : instance ( ) , SIGNAL ( UASCreated ( UASInterface * ) ) , this , SLOT ( addUAS ( UASInterface * ) ) ) ;
void MapWidget : : createPathButtonClicked ( ) {
this - > setCursor ( createPath - > isChecked ( ) ? Qt : : PointingHandCursor : Qt : : ArrowCursor ) ;
}
this - > setVisible ( false ) ;
void MapWidget : : captureMapClick ( const QMouseEvent * event , const QPointF coordinate ) {
if ( QEvent : : MouseButtonRelease = = event - > type ( ) & & createPath - > isChecked ( ) ) {
qDebug ( ) < < " Click Event " ;
qDebug ( ) < < " Lat: " < < coordinate . y ( ) ;
qDebug ( ) < < " Lon: " < < coordinate . x ( ) ;
}
}
MapWidget : : ~ MapWidget ( )
@ -180,7 +217,7 @@ void MapWidget::updateGlobalPosition(UASInterface* uas, double lat, double lon,
@@ -180,7 +217,7 @@ void MapWidget::updateGlobalPosition(UASInterface* uas, double lat, double lon,
// points.append(new Point(8.260378, 50.030345, "Wiesbaden-Mainz-Amoneburg, Dyckerhoffstraße"));
// Connect click events of the layer to this object
//connect(osmLayer, SIGNAL(geometryClicked(Geometry*, QPoint)),
// connect(osmLayer, SIGNAL(geometryClicked(Geometry*, QPoint)),
// this, SLOT(geometryClicked(Geometry*, QPoint)));
// Sets the view to the interesting area