Commit 94228d60 authored by Mariano Lizarraga's avatar Mariano Lizarraga

Continue the scaffoldinf for the WP click creation. Now the waypoints are...

Continue the scaffoldinf for the WP click creation. Now the waypoints are graphically shown in the MapControl. Ready to start interacting with the Waypoint widget
parent 1b1e7a36
......@@ -60,9 +60,12 @@ MapWidget::MapWidget(QWidget *parent) :
// create a layer with the mapadapter and type MapLayer
osmLayer = new Layer("Custom Layer", osmAdapter, Layer::MapLayer);
// create a layer with the mapadapter and type GeometryLayer (for waypoints)
geomLayer = new Layer("Geom Layer", osmAdapter, Layer::GeometryLayer);
// add Layer to the MapControl
// add Layers to the MapControl and set zoom level
mc->addLayer(osmLayer);
mc->addLayer(geomLayer);
mc->setZoom(3);
// display the MapControl in the application
......@@ -71,7 +74,6 @@ MapWidget::MapWidget(QWidget *parent) :
layout->addWidget(mc);
setLayout(layout);
// 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);
......@@ -83,15 +85,12 @@ MapWidget::MapWidget(QWidget *parent) :
createPath->setMaximumWidth(50);
followgps->setMaximumWidth(50);
// 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);
......@@ -102,6 +101,12 @@ MapWidget::MapWidget(QWidget *parent) :
// Connect the required signals-slots
connect(zoomin, SIGNAL(clicked(bool)),
mc, SLOT(zoomIn()));
connect(zoomout, SIGNAL(clicked(bool)),
mc, SLOT(zoomOut()));
connect(UASManager::instance(), SIGNAL(UASCreated(UASInterface*)),
this, SLOT(addUAS(UASInterface*)));
......@@ -111,6 +116,16 @@ MapWidget::MapWidget(QWidget *parent) :
connect(createPath, SIGNAL(clicked(bool)),
this, SLOT(createPathButtonClicked()));
connect(geomLayer, SIGNAL(geometryClicked(Geometry*,QPoint)),
this, SLOT(captureGeometryClick(Geometry*, QPoint)));
// Configure the WP Path's pen
pointPen = new QPen(QColor(0, 255,0));
pointPen->setWidth(3);
path = new LineString (wps, "UAV Path", pointPen);
mc->layer("Geom Layer")->addGeometry(path);
this->setVisible(false);
......@@ -136,18 +151,52 @@ MapWidget::MapWidget(QWidget *parent) :
}
void MapWidget::createPathButtonClicked(){
this->setCursor(createPath->isChecked()? Qt::PointingHandCursor : Qt::ArrowCursor);
if (createPath->isChecked()){
// change the cursor shape
this->setCursor(Qt::PointingHandCursor);
// Clear the previous WP track
// TODO: Move this to an actual clear track button and add a warning dialog
mc->layer("Geom Layer")->clearGeometries();
wps.clear();
path->setPoints(wps);
mc->layer("Geom Layer")->addGeometry(path);
} else {
this->setCursor(Qt::ArrowCursor);
}
}
void MapWidget::captureMapClick(const QMouseEvent* event, const QPointF coordinate){
if (QEvent::MouseButtonRelease == event->type() && createPath->isChecked()){
qDebug()<< "Click Event";
// Create waypoint name
QString str;
str = QString("WP%1").arg(path->numberOfPoints()+1);
qDebug()<< "Waypoint " << str;
qDebug()<< "Lat: " << coordinate.y();
qDebug()<< "Lon: " << coordinate.x();
// create the WP and set everything in the LineString to display the path
mc->layer("Geom Layer")->addGeometry(new CirclePoint(coordinate.x(), coordinate.y(), 10, str));
wps.append(new Point(coordinate.x(), coordinate.y(),str));
path->addPoint(new Point(coordinate.x(), coordinate.y(),str));
mc->updateRequestNew();
}
}
void MapWidget::captureGeometryClick(Geometry* geom, QPoint point){
Q_UNUSED(point);
qDebug ()<< geom->name();
qDebug() << geom->GeometryType;
}
MapWidget::~MapWidget()
{
delete m_ui;
......
......@@ -73,6 +73,8 @@ protected:
TileMapAdapter* osmAdapter;
GoogleSatMapAdapter* gSatAdapter;
Layer* osmLayer;
Layer* geomLayer;
//Layer* gSatLayer;
QMap<int, CirclePoint*> uasIcons;
......@@ -83,9 +85,12 @@ protected:
protected slots:
void captureMapClick (const QMouseEvent* event, const QPointF coordinate);
void createPathButtonClicked();
void captureGeometryClick(Geometry*, QPoint);
private:
Ui::MapWidget *m_ui;
QList<Point*> wps;
LineString* path;
QPen* pointPen;
};
#endif // MAPWIDGET_H
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment