Commit 3920c256 authored by pixhawk's avatar pixhawk

One step closer to fulle rewritten WP interface

parent 69aed4a6
...@@ -321,6 +321,8 @@ void UASWaypointManager::addWaypoint(Waypoint *wp) ...@@ -321,6 +321,8 @@ void UASWaypointManager::addWaypoint(Waypoint *wp)
emit waypointListChanged(); emit waypointListChanged();
emit waypointListChanged(uas.getUASID()); emit waypointListChanged(uas.getUASID());
qDebug() << "ADDED WAYPOINT WITH ID:" << wp->getId();
} }
} }
......
...@@ -436,7 +436,7 @@ void MapWidget::captureMapClick(const QMouseEvent* event, const QPointF coordina ...@@ -436,7 +436,7 @@ void MapWidget::captureMapClick(const QMouseEvent* event, const QPointF coordina
// waypointPath->setPen(pathPen); // waypointPath->setPen(pathPen);
// } // }
wpIndex.insert(str,tempPoint); //wpIndex.insert(str,tempPoint);
// Refresh the screen // Refresh the screen
mc->updateRequest(tempPoint->boundingBox().toRect()); mc->updateRequest(tempPoint->boundingBox().toRect());
...@@ -449,17 +449,19 @@ void MapWidget::captureMapClick(const QMouseEvent* event, const QPointF coordina ...@@ -449,17 +449,19 @@ void MapWidget::captureMapClick(const QMouseEvent* event, const QPointF coordina
void MapWidget::updateWaypoint(int uas, Waypoint* wp) void MapWidget::updateWaypoint(int uas, Waypoint* wp)
{ {
qDebug() << "UPDATING WP" << wp->getId() << __FILE__ << __LINE__;
if (uas == this->mav->getUASID()) if (uas == this->mav->getUASID())
{ {
// Create waypoint name // Create waypoint name
QString str = QString("%1").arg(wp->getId()); QString str = QString("%1").arg(wp->getId());
// Check if wp exists yet // Check if wp exists yet
if (!wpIndex.contains(str)) if (!(wps.count() > wp->getId()))
{ {
QPointF coordinate; QPointF coordinate;
coordinate.setX(wp->getX()); coordinate.setX(wp->getX());
coordinate.setY(wp->getY()); coordinate.setY(wp->getY());
createWaypointGraphAtMap(coordinate); createWaypointGraphAtMap(wp->getId(), coordinate);
qDebug() << "Waypoint Index did not contain" << str; qDebug() << "Waypoint Index did not contain" << str;
} }
else else
...@@ -474,7 +476,7 @@ void MapWidget::updateWaypoint(int uas, Waypoint* wp) ...@@ -474,7 +476,7 @@ void MapWidget::updateWaypoint(int uas, Waypoint* wp)
coordinate.setY(wp->getY()); coordinate.setY(wp->getY());
Point* waypoint; Point* waypoint;
waypoint = wpIndex[str]; waypoint = wps.at(wp->getId());//wpIndex[str];
if (waypoint) if (waypoint)
{ {
// First set waypoint coordinate // First set waypoint coordinate
...@@ -496,16 +498,13 @@ void MapWidget::updateWaypoint(int uas, Waypoint* wp) ...@@ -496,16 +498,13 @@ void MapWidget::updateWaypoint(int uas, Waypoint* wp)
} }
} }
void MapWidget::createWaypointGraphAtMap(const QPointF coordinate) void MapWidget::createWaypointGraphAtMap(int id, const QPointF coordinate)
{ {
if (!wpExists(coordinate)) if (!wpExists(coordinate))
{ {
// Create waypoint name // Create waypoint name
QString str; QString str;
// create the WP and set everything in the LineString to display the path // create the WP and set everything in the LineString to display the path
//CirclePoint* tempCirclePoint = new CirclePoint(coordinate.x(), coordinate.y(), 10, str); //CirclePoint* tempCirclePoint = new CirclePoint(coordinate.x(), coordinate.y(), 10, str);
Waypoint2DIcon* tempCirclePoint; Waypoint2DIcon* tempCirclePoint;
...@@ -513,13 +512,13 @@ void MapWidget::createWaypointGraphAtMap(const QPointF coordinate) ...@@ -513,13 +512,13 @@ void MapWidget::createWaypointGraphAtMap(const QPointF coordinate)
if (mav) if (mav)
{ {
int uas = mav->getUASID(); int uas = mav->getUASID();
str = QString("%1").arg(mav->getWaypointManager()->getWaypointList().count()); str = QString("%1").arg(id);
qDebug() << "Waypoint list count:" << str; qDebug() << "Waypoint list count:" << str;
tempCirclePoint = new Waypoint2DIcon(coordinate.x(), coordinate.y(), 20, str, qmapcontrol::Point::Middle, mavPens.value(uas)); tempCirclePoint = new Waypoint2DIcon(coordinate.x(), coordinate.y(), 20, str, qmapcontrol::Point::Middle, mavPens.value(uas));
} }
else else
{ {
str = QString("%1").arg(waypointPath->numberOfPoints()); str = QString("%1").arg(id);
tempCirclePoint = new Waypoint2DIcon(coordinate.x(), coordinate.y(), 20, str, qmapcontrol::Point::Middle); tempCirclePoint = new Waypoint2DIcon(coordinate.x(), coordinate.y(), 20, str, qmapcontrol::Point::Middle);
} }
...@@ -530,7 +529,7 @@ void MapWidget::createWaypointGraphAtMap(const QPointF coordinate) ...@@ -530,7 +529,7 @@ void MapWidget::createWaypointGraphAtMap(const QPointF coordinate)
wps.append(tempPoint); wps.append(tempPoint);
waypointPath->addPoint(tempPoint); waypointPath->addPoint(tempPoint);
wpIndex.insert(str,tempPoint); //wpIndex.insert(str,tempPoint);
qDebug()<<"Funcion createWaypointGraphAtMap WP= "<<str<<" -> x= "<<tempPoint->latitude()<<" y= "<<tempPoint->longitude(); qDebug()<<"Funcion createWaypointGraphAtMap WP= "<<str<<" -> x= "<<tempPoint->latitude()<<" y= "<<tempPoint->longitude();
// Refresh the screen // Refresh the screen
...@@ -576,7 +575,7 @@ void MapWidget::captureGeometryDrag(Geometry* geom, QPointF coordinate) ...@@ -576,7 +575,7 @@ void MapWidget::captureGeometryDrag(Geometry* geom, QPointF coordinate)
int index = geom->name().toInt(&wpIndexOk); int index = geom->name().toInt(&wpIndexOk);
qmapcontrol::Point* point2Find; qmapcontrol::Point* point2Find;
point2Find = wpIndex[geom->name()]; point2Find = wps.at(geom->name().toInt());
if (point2Find) if (point2Find)
{ {
...@@ -662,11 +661,10 @@ void MapWidget::updateWaypointList(int uas) ...@@ -662,11 +661,10 @@ void MapWidget::updateWaypointList(int uas)
} }
// Delete now unused wps // Delete now unused wps
if (wpIndex.count() > wpList.count()) if (wps.count() > wpList.count())
{ {
for (int i = wpList.count(); i < wpIndex.count(); ++i) for (int i = wpList.count(); i < wps.count(); ++i)
{ {
wpIndex.remove(QString("%i").arg(i));
QRect updateRect = wps.at(i)->boundingBox().toRect(); QRect updateRect = wps.at(i)->boundingBox().toRect();
wps.removeAt(i); wps.removeAt(i);
waypointPath->points().removeAt(i); waypointPath->points().removeAt(i);
...@@ -906,8 +904,10 @@ void MapWidget::clearWaypoints(int uas) ...@@ -906,8 +904,10 @@ void MapWidget::clearWaypoints(int uas)
mc->layer("Waypoints")->clearGeometries(); mc->layer("Waypoints")->clearGeometries();
wps.clear(); wps.clear();
waypointPath->points().clear(); waypointPath->points().clear();
//delete waypointPath;
//waypointPath = new
mc->layer("Waypoints")->addGeometry(waypointPath); mc->layer("Waypoints")->addGeometry(waypointPath);
wpIndex.clear(); //wpIndex.clear();
mc->updateRequestNew();//(waypointPath->boundingBox().toRect()); mc->updateRequestNew();//(waypointPath->boundingBox().toRect());
if(createPath->isChecked()) if(createPath->isChecked())
......
...@@ -147,7 +147,8 @@ protected: ...@@ -147,7 +147,8 @@ protected:
void createPathButtonClicked(bool checked); void createPathButtonClicked(bool checked);
void createWaypointGraphAtMap(const QPointF coordinate); /** @brief Create the graphic representation of the waypoint */
void createWaypointGraphAtMap(int id, const QPointF coordinate);
void mapproviderSelected(QAction* action); void mapproviderSelected(QAction* action);
signals: signals:
...@@ -162,7 +163,7 @@ private: ...@@ -162,7 +163,7 @@ private:
Ui::MapWidget *m_ui; Ui::MapWidget *m_ui;
QList<qmapcontrol::Point*> wps; QList<qmapcontrol::Point*> wps;
qmapcontrol::LineString* waypointPath; qmapcontrol::LineString* waypointPath;
QHash <QString, qmapcontrol::Point*> wpIndex; //QHash <QString, qmapcontrol::Point*> wpIndex;
QPen* pointPen; QPen* pointPen;
int wpExists(const QPointF coordinate); int wpExists(const QPointF coordinate);
bool waypointIsDrag; bool waypointIsDrag;
......
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