Commit 60e7913f authored by pixhawk's avatar pixhawk

Additional minor fixes to WP interface

parent 0f85d37d
...@@ -476,6 +476,11 @@ void UASWaypointManager::clearWaypointList() ...@@ -476,6 +476,11 @@ void UASWaypointManager::clearWaypointList()
} }
} }
int UASWaypointManager::getIndexOf(Waypoint* wp)
{
return waypoints.indexOf(wp);
}
void UASWaypointManager::readWaypoints() void UASWaypointManager::readWaypoints()
{ {
emit readGlobalWPFromUAS(true); emit readGlobalWPFromUAS(true);
......
...@@ -96,7 +96,7 @@ public: ...@@ -96,7 +96,7 @@ public:
void localMoveWaypoint(quint16 cur_seq, quint16 new_seq); ///< locally move a waypoint from its current position cur_seq to a new position new_seq void localMoveWaypoint(quint16 cur_seq, quint16 new_seq); ///< locally move a waypoint from its current position cur_seq to a new position new_seq
void localSaveWaypoints(const QString &saveFile); ///< saves the local waypoint list to saveFile void localSaveWaypoints(const QString &saveFile); ///< saves the local waypoint list to saveFile
void localLoadWaypoints(const QString &loadFile); ///< loads a waypoint list from loadFile void localLoadWaypoints(const QString &loadFile); ///< loads a waypoint list from loadFile
int getIndexOf(Waypoint* wp); ///< Get the index of a waypoint in the list
/*@}*/ /*@}*/
UAS& getUAS() { return this->uas; } ///< Returns the owning UAS UAS& getUAS() { return this->uas; } ///< Returns the owning UAS
......
...@@ -401,7 +401,6 @@ void MapWidget::createPathButtonClicked(bool checked) ...@@ -401,7 +401,6 @@ void MapWidget::createPathButtonClicked(bool checked)
void MapWidget::captureMapClick(const QMouseEvent* event, const QPointF coordinate) void MapWidget::captureMapClick(const QMouseEvent* event, const QPointF coordinate)
{ {
//qDebug() << mc->mouseMode();
if (QEvent::MouseButtonRelease == event->type() && createPath->isChecked()) if (QEvent::MouseButtonRelease == event->type() && createPath->isChecked())
{ {
// Create waypoint name // Create waypoint name
...@@ -413,11 +412,6 @@ void MapWidget::captureMapClick(const QMouseEvent* event, const QPointF coordina ...@@ -413,11 +412,6 @@ void MapWidget::captureMapClick(const QMouseEvent* event, const QPointF coordina
if (mav) if (mav)
{ {
mav->getWaypointManager()->addWaypoint(new Waypoint(mav->getWaypointManager()->getWaypointList().count(), coordinate.x(), coordinate.y())); mav->getWaypointManager()->addWaypoint(new Waypoint(mav->getWaypointManager()->getWaypointList().count(), coordinate.x(), coordinate.y()));
// QVector<Waypoint*> mavWps = mav->getWaypointManager()->getWaypointList();
// str = QString("%1").arg(mavWps.count());
// tempCirclePoint = new Waypoint2DIcon(coordinate.x(), coordinate.y(), 20, str, qmapcontrol::Point::Middle, new QPen(mav->getColor()));
// //mav->getWaypointManager()->addWaypoint(new Waypoint(mavWps.count(), coordinate.x(), coordinate.y()));
} }
else else
{ {
...@@ -429,14 +423,6 @@ void MapWidget::captureMapClick(const QMouseEvent* event, const QPointF coordina ...@@ -429,14 +423,6 @@ void MapWidget::captureMapClick(const QMouseEvent* event, const QPointF coordina
qmapcontrol::Point* tempPoint = new qmapcontrol::Point(coordinate.x(), coordinate.y(),str); qmapcontrol::Point* tempPoint = new qmapcontrol::Point(coordinate.x(), coordinate.y(),str);
wps.append(tempPoint); wps.append(tempPoint);
waypointPath->addPoint(tempPoint); waypointPath->addPoint(tempPoint);
// if (mav)
// {
// QPen* pathPen = new QPen(mav->getColor());
// pathPen->setWidth(2);
// waypointPath->setPen(pathPen);
// }
//wpIndex.insert(str,tempPoint);
// Refresh the screen // Refresh the screen
mc->updateRequest(tempPoint->boundingBox().toRect()); mc->updateRequest(tempPoint->boundingBox().toRect());
...@@ -449,18 +435,19 @@ void MapWidget::captureMapClick(const QMouseEvent* event, const QPointF coordina ...@@ -449,18 +435,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__; //qDebug() << "UPDATING WP" << wp->getId() << __FILE__ << __LINE__;
if (uas == this->mav->getUASID()) if (uas == this->mav->getUASID())
{ {
int wpindex = UASManager::instance()->getUASForId(uas)->getWaypointManager()->getIndexOf(wp);
// Create waypoint name // Create waypoint name
QString str = QString("%1").arg(wp->getId()); QString str = QString("%1").arg(wpindex);
// Check if wp exists yet // Check if wp exists yet
if (!(wps.count() > wp->getId())) if (!(wps.count() > wpindex))
{ {
QPointF coordinate; QPointF coordinate;
coordinate.setX(wp->getX()); coordinate.setX(wp->getX());
coordinate.setY(wp->getY()); coordinate.setY(wp->getY());
createWaypointGraphAtMap(wp->getId(), coordinate); createWaypointGraphAtMap(wpindex, coordinate);
qDebug() << "Waypoint Index did not contain" << str; qDebug() << "Waypoint Index did not contain" << str;
} }
...@@ -469,29 +456,27 @@ void MapWidget::updateWaypoint(int uas, Waypoint* wp) ...@@ -469,29 +456,27 @@ void MapWidget::updateWaypoint(int uas, Waypoint* wp)
// Waypoint exists, update it // Waypoint exists, update it
if(!waypointIsDrag) if(!waypointIsDrag)
{ {
qDebug() <<"indice WP= "<< wp->getId() <<"\n"; qDebug() <<"indice WP= "<< wpindex <<"\n";
QPointF coordinate; QPointF coordinate;
coordinate.setX(wp->getX()); coordinate.setX(wp->getX());
coordinate.setY(wp->getY()); coordinate.setY(wp->getY());
Point* waypoint; Point* waypoint;
waypoint = wps.at(wp->getId());//wpIndex[str]; waypoint = wps.at(wpindex);//wpIndex[str];
if (waypoint) if (waypoint)
{ {
// First set waypoint coordinate // First set waypoint coordinate
waypoint->setCoordinate(coordinate); waypoint->setCoordinate(coordinate);
// Now update icon position // Now update icon position
//mc->layer("Waypoints")->removeGeometry(wpIcons.at(wp->getId())); //mc->layer("Waypoints")->removeGeometry(wpIcons.at(wpindex));
wpIcons.at(wp->getId())->setCoordinate(coordinate); wpIcons.at(wpindex)->setCoordinate(coordinate);
//mc->layer("Waypoints")->addGeometry(wpIcons.at(wp->getId())); //mc->layer("Waypoints")->addGeometry(wpIcons.at(wpindex));
// Then waypoint line coordinate // Then waypoint line coordinate
int linesegmentId = mav->getWaypointManager()->getWaypointList().indexOf(wp);
qDebug() << "SEGMENT" << linesegmentId;
Point* linesegment = NULL; Point* linesegment = NULL;
if (waypointPath->points().size() > linesegmentId) if (waypointPath->points().size() > wpindex)
{ {
linesegment = waypointPath->points().at(linesegmentId); linesegment = waypointPath->points().at(wpindex);
} }
if (linesegment) if (linesegment)
...@@ -499,7 +484,7 @@ void MapWidget::updateWaypoint(int uas, Waypoint* wp) ...@@ -499,7 +484,7 @@ void MapWidget::updateWaypoint(int uas, Waypoint* wp)
linesegment->setCoordinate(coordinate); linesegment->setCoordinate(coordinate);
} }
//point2Find = dynamic_cast <Point*> (mc->layer("Waypoints")->get_Geometry(wp->getId())); //point2Find = dynamic_cast <Point*> (mc->layer("Waypoints")->get_Geometry(wpindex));
//point2Find->setCoordinate(coordinate); //point2Find->setCoordinate(coordinate);
mc->updateRequest(waypoint->boundingBox().toRect()); mc->updateRequest(waypoint->boundingBox().toRect());
} }
...@@ -925,7 +910,7 @@ void MapWidget::clearWaypoints(int uas) ...@@ -925,7 +910,7 @@ void MapWidget::clearWaypoints(int uas)
{ {
// Clear the previous WP track // Clear the previous WP track
mc->layer("Waypoints")->clearGeometries(); //mc->layer("Waypoints")->clearGeometries();
wps.clear(); wps.clear();
waypointPath->points().clear(); waypointPath->points().clear();
//delete waypointPath; //delete waypointPath;
......
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