From bbdef443448a44206a738e21aea7fd0299eb1f1c Mon Sep 17 00:00:00 2001 From: Philippe Renon Date: Wed, 11 Dec 2013 23:13:32 +0100 Subject: [PATCH] OP-112 OP-1120 waypoint editor - added popup notification for success or failure of uploading/downloading a flight path to the board + minor header file reorg --- .../src/plugins/opmap/modeluavoproxy.cpp | 16 +++++++++------- .../src/plugins/opmap/modeluavoproxy.h | 16 +++++++++------- 2 files changed, 18 insertions(+), 14 deletions(-) diff --git a/ground/openpilotgcs/src/plugins/opmap/modeluavoproxy.cpp b/ground/openpilotgcs/src/plugins/opmap/modeluavoproxy.cpp index 6937ee1b0..5af2a707f 100644 --- a/ground/openpilotgcs/src/plugins/opmap/modeluavoproxy.cpp +++ b/ground/openpilotgcs/src/plugins/opmap/modeluavoproxy.cpp @@ -66,10 +66,10 @@ void ModelUavoProxy::flightPlanSent(UAVObject *obj, bool success) if (completionCount == 2) { qDebug() << "ModelUavoProxy::flightPlanSent - success" << (completionSuccessCount == 2); if (completionSuccessCount == 2) { - // TODO : popup? + QMessageBox::information(NULL, tr("Flight Plan Upload Successful"), tr("Flight plan upload was successful.")); } else { - // TODO : popup? + QMessageBox::critical(NULL, tr("Flight Plan Upload Failed !"), tr("Failed to upload the flight plan !")); } } } @@ -102,10 +102,10 @@ void ModelUavoProxy::flightPlanReceived(UAVObject *obj, bool success) qDebug() << "ModelUavoProxy::flightPlanReceived - success" << (completionSuccessCount == 2); if (completionSuccessCount == 2) { objectsToModel(); - // TODO : popup? + QMessageBox::information(NULL, tr("Flight Plan Download Successful"), tr("Flight plan download was successful.")); } else { - // TODO : popup? + QMessageBox::critical(NULL, tr("Flight Plan Download Failed !"), tr("Failed to download the flight plan !")); } } } @@ -254,8 +254,11 @@ PathAction *ModelUavoProxy::findPathAction(const PathAction::DataFields &actionD void ModelUavoProxy::objectsToModel() { + // build model from uav objects + // the list of objects can end with "garbage" instances due to previous flightpath + // they need to be ignored + int instanceCount = objManager->getNumInstances(Waypoint::OBJID); - // TODO retain only reachable waypoints int rowCount = myModel->rowCount(); if (instanceCount < rowCount) { @@ -275,8 +278,7 @@ void ModelUavoProxy::objectsToModel() Waypoint::DataFields waypointData = waypoint->getData(); waypointToModel(i, waypointData); - int actionId = waypointData.Action; - PathAction *action = PathAction::GetInstance(objManager, actionId); + PathAction *action = PathAction::GetInstance(objManager, waypoint->getAction()); Q_ASSERT(action); if (!action) { continue; diff --git a/ground/openpilotgcs/src/plugins/opmap/modeluavoproxy.h b/ground/openpilotgcs/src/plugins/opmap/modeluavoproxy.h index 1b685a739..9e3a2cd2e 100644 --- a/ground/openpilotgcs/src/plugins/opmap/modeluavoproxy.h +++ b/ground/openpilotgcs/src/plugins/opmap/modeluavoproxy.h @@ -38,9 +38,6 @@ class ModelUavoProxy : public QObject { public: explicit ModelUavoProxy(QObject *parent, flightDataModel *model); - void modelToObjects(); - void objectsToModel(); - public slots: void sendFlightPlan(); void receiveFlightPlan(); @@ -51,16 +48,21 @@ private: uint completionCount; uint completionSuccessCount; + void modelToObjects(); + void objectsToModel(); + Waypoint *createWaypoint(int index, Waypoint *newWaypoint); - void modelToWaypoint(int i, Waypoint::DataFields &data); - void waypointToModel(int i, Waypoint::DataFields &data); + PathAction *createPathAction(int index, PathAction *newAction); PathAction *findPathAction(const PathAction::DataFields& actionFields, int actionCount); - PathAction *createPathAction(int index, PathAction *newAction); + + void modelToWaypoint(int i, Waypoint::DataFields &data); void modelToPathAction(int i, PathAction::DataFields &data); + + void waypointToModel(int i, Waypoint::DataFields &data); void pathActionToModel(int i, PathAction::DataFields &data); -public slots: +private slots: void flightPlanSent(UAVObject *, bool success); void flightPlanReceived(UAVObject *, bool success);