Commit a13508b3 authored by Lorenz Meier's avatar Lorenz Meier

Allowed offline editing of waypoints

parent 42de6b7c
...@@ -12,7 +12,7 @@ QGCWaypointListMulti::QGCWaypointListMulti(QWidget *parent) : ...@@ -12,7 +12,7 @@ QGCWaypointListMulti::QGCWaypointListMulti(QWidget *parent) :
connect(UASManager::instance(), SIGNAL(UASCreated(UASInterface*)), this, SLOT(systemCreated(UASInterface*))); connect(UASManager::instance(), SIGNAL(UASCreated(UASInterface*)), this, SLOT(systemCreated(UASInterface*)));
connect(UASManager::instance(), SIGNAL(activeUASSet(int)), this, SLOT(systemSetActive(int))); connect(UASManager::instance(), SIGNAL(activeUASSet(int)), this, SLOT(systemSetActive(int)));
WaypointList* list = new WaypointList(ui->stackedWidget, NULL); WaypointList* list = new WaypointList(ui->stackedWidget, UASManager::instance()->getActiveUASWaypointManager());
lists.insert(offline_uas_id, list); lists.insert(offline_uas_id, list);
ui->stackedWidget->addWidget(list); ui->stackedWidget->addWidget(list);
...@@ -40,7 +40,7 @@ void QGCWaypointListMulti::systemDeleted(QObject* uas) ...@@ -40,7 +40,7 @@ void QGCWaypointListMulti::systemDeleted(QObject* uas)
void QGCWaypointListMulti::systemCreated(UASInterface* uas) void QGCWaypointListMulti::systemCreated(UASInterface* uas)
{ {
WaypointList* list = new WaypointList(ui->stackedWidget, uas); WaypointList* list = new WaypointList(ui->stackedWidget, uas->getWaypointManager());
lists.insert(uas->getUASID(), list); lists.insert(uas->getUASID(), list);
ui->stackedWidget->addWidget(list); ui->stackedWidget->addWidget(list);
// Ensure widget is deleted when system is deleted // Ensure widget is deleted when system is deleted
......
...@@ -34,15 +34,17 @@ This file is part of the PIXHAWK project ...@@ -34,15 +34,17 @@ This file is part of the PIXHAWK project
#include "WaypointList.h" #include "WaypointList.h"
#include "ui_WaypointList.h" #include "ui_WaypointList.h"
#include <UASInterface.h> #include <UASInterface.h>
#include <UAS.h>
#include <UASManager.h> #include <UASManager.h>
#include <QDebug> #include <QDebug>
#include <QFileDialog> #include <QFileDialog>
#include <QMessageBox> #include <QMessageBox>
#include <QMouseEvent> #include <QMouseEvent>
WaypointList::WaypointList(QWidget *parent, UASInterface* uas) : WaypointList::WaypointList(QWidget *parent, UASWaypointManager* wpm) :
QWidget(parent), QWidget(parent),
uas(NULL), uas(NULL),
WPM(wpm),
mavX(0.0), mavX(0.0),
mavY(0.0), mavY(0.0),
mavZ(0.0), mavZ(0.0),
...@@ -96,13 +98,9 @@ WaypointList::WaypointList(QWidget *parent, UASInterface* uas) : ...@@ -96,13 +98,9 @@ WaypointList::WaypointList(QWidget *parent, UASInterface* uas) :
connect(m_ui->refreshButton, SIGNAL(clicked()), this, SLOT(refresh())); connect(m_ui->refreshButton, SIGNAL(clicked()), this, SLOT(refresh()));
if (WPM) {
// SET UAS AFTER ALL SIGNALS/SLOTS ARE CONNECTED // SET UAS AFTER ALL SIGNALS/SLOTS ARE CONNECTED
if (uas) if (!WPM->getUAS())
{
WPM = uas->getWaypointManager();
}
else
{ {
// Hide buttons, which don't make sense without valid UAS // Hide buttons, which don't make sense without valid UAS
m_ui->positionAddButton->hide(); m_ui->positionAddButton->hide();
...@@ -113,10 +111,18 @@ WaypointList::WaypointList(QWidget *parent, UASInterface* uas) : ...@@ -113,10 +111,18 @@ WaypointList::WaypointList(QWidget *parent, UASInterface* uas) :
UnconnectedUASInfoWidget* inf = new UnconnectedUASInfoWidget(this); UnconnectedUASInfoWidget* inf = new UnconnectedUASInfoWidget(this);
viewOnlyListLayout->insertWidget(0, inf); //insert a "NO UAV" info into the Onboard Tab viewOnlyListLayout->insertWidget(0, inf); //insert a "NO UAV" info into the Onboard Tab
showOfflineWarning = true; showOfflineWarning = true;
WPM = new UASWaypointManager(NULL); } else {
setUAS(static_cast<UASInterface*>(WPM->getUAS()));
} }
setUAS(uas); /* connect slots */
connect(WPM, SIGNAL(updateStatusString(const QString &)), this, SLOT(updateStatusLabel(const QString &)));
connect(WPM, SIGNAL(waypointEditableListChanged(void)), this, SLOT(waypointEditableListChanged(void)));
connect(WPM, SIGNAL(waypointEditableChanged(int,Waypoint*)), this, SLOT(updateWaypointEditable(int,Waypoint*)));
connect(WPM, SIGNAL(waypointViewOnlyListChanged(void)), this, SLOT(waypointViewOnlyListChanged(void)));
connect(WPM, SIGNAL(waypointViewOnlyChanged(int,Waypoint*)), this, SLOT(updateWaypointViewOnly(int,Waypoint*)));
connect(WPM, SIGNAL(currentWaypointChanged(quint16)), this, SLOT(currentWaypointViewOnlyChanged(quint16)));
}
// STATUS LABEL // STATUS LABEL
updateStatusLabel(""); updateStatusLabel("");
...@@ -154,12 +160,26 @@ void WaypointList::updateAttitude(UASInterface* uas, double roll, double pitch, ...@@ -154,12 +160,26 @@ void WaypointList::updateAttitude(UASInterface* uas, double roll, double pitch,
void WaypointList::setUAS(UASInterface* uas) void WaypointList::setUAS(UASInterface* uas)
{ {
if (this->uas == NULL && uas != NULL) if (!uas)
return;
if (this->uas != NULL)
{ {
WPM = uas->getWaypointManager(); // Clear current list
on_clearWPListButton_clicked();
// Disconnect everything
disconnect(WPM, SIGNAL(updateStatusString(const QString &)), this, SLOT(updateStatusLabel(const QString &)));
disconnect(WPM, SIGNAL(waypointEditableListChanged(void)), this, SLOT(waypointEditableListChanged(void)));
disconnect(WPM, SIGNAL(waypointEditableChanged(int,Waypoint*)), this, SLOT(updateWaypointEditable(int,Waypoint*)));
disconnect(WPM, SIGNAL(waypointViewOnlyListChanged(void)), this, SLOT(waypointViewOnlyListChanged(void)));
disconnect(WPM, SIGNAL(waypointViewOnlyChanged(int,Waypoint*)), this, SLOT(updateWaypointViewOnly(int,Waypoint*)));
disconnect(WPM, SIGNAL(currentWaypointChanged(quint16)), this, SLOT(currentWaypointViewOnlyChanged(quint16)));
disconnect(this->uas, SIGNAL(localPositionChanged(UASInterface*,double,double,double,quint64)), this, SLOT(updatePosition(UASInterface*,double,double,double,quint64)));
disconnect(this->uas, SIGNAL(attitudeChanged(UASInterface*,double,double,double,quint64)), this, SLOT(updateAttitude(UASInterface*,double,double,double,quint64)));
} }
if (this->uas == NULL)
{ WPM = uas->getWaypointManager();
this->uas = uas; this->uas = uas;
connect(WPM, SIGNAL(updateStatusString(const QString &)), this, SLOT(updateStatusLabel(const QString &))); connect(WPM, SIGNAL(updateStatusString(const QString &)), this, SLOT(updateStatusLabel(const QString &)));
connect(WPM, SIGNAL(waypointEditableListChanged(void)), this, SLOT(waypointEditableListChanged(void))); connect(WPM, SIGNAL(waypointEditableListChanged(void)), this, SLOT(waypointEditableListChanged(void)));
...@@ -167,14 +187,10 @@ void WaypointList::setUAS(UASInterface* uas) ...@@ -167,14 +187,10 @@ void WaypointList::setUAS(UASInterface* uas)
connect(WPM, SIGNAL(waypointViewOnlyListChanged(void)), this, SLOT(waypointViewOnlyListChanged(void))); connect(WPM, SIGNAL(waypointViewOnlyListChanged(void)), this, SLOT(waypointViewOnlyListChanged(void)));
connect(WPM, SIGNAL(waypointViewOnlyChanged(int,Waypoint*)), this, SLOT(updateWaypointViewOnly(int,Waypoint*))); connect(WPM, SIGNAL(waypointViewOnlyChanged(int,Waypoint*)), this, SLOT(updateWaypointViewOnly(int,Waypoint*)));
connect(WPM, SIGNAL(currentWaypointChanged(quint16)), this, SLOT(currentWaypointViewOnlyChanged(quint16))); connect(WPM, SIGNAL(currentWaypointChanged(quint16)), this, SLOT(currentWaypointViewOnlyChanged(quint16)));
if (uas != NULL)
{
connect(uas, SIGNAL(localPositionChanged(UASInterface*,double,double,double,quint64)), this, SLOT(updatePosition(UASInterface*,double,double,double,quint64))); connect(uas, SIGNAL(localPositionChanged(UASInterface*,double,double,double,quint64)), this, SLOT(updatePosition(UASInterface*,double,double,double,quint64)));
connect(uas, SIGNAL(attitudeChanged(UASInterface*,double,double,double,quint64)), this, SLOT(updateAttitude(UASInterface*,double,double,double,quint64))); connect(uas, SIGNAL(attitudeChanged(UASInterface*,double,double,double,quint64)), this, SLOT(updateAttitude(UASInterface*,double,double,double,quint64)));
}
//connect(WPM,SIGNAL(loadWPFile()),this,SLOT(setIsLoadFileWP())); //connect(WPM,SIGNAL(loadWPFile()),this,SLOT(setIsLoadFileWP()));
//connect(WPM,SIGNAL(readGlobalWPFromUAS(bool)),this,SLOT(setIsReadGlobalWP(bool))); //connect(WPM,SIGNAL(readGlobalWPFromUAS(bool)),this,SLOT(setIsReadGlobalWP(bool)));
}
// Update list // Update list
read(); read();
...@@ -583,8 +599,6 @@ void WaypointList::changeEvent(QEvent *e) ...@@ -583,8 +599,6 @@ void WaypointList::changeEvent(QEvent *e)
void WaypointList::on_clearWPListButton_clicked() void WaypointList::on_clearWPListButton_clicked()
{ {
if (uas) { if (uas) {
emit clearPathclicked(); emit clearPathclicked();
const QVector<Waypoint *> &waypoints = WPM->getWaypointEditableList(); const QVector<Waypoint *> &waypoints = WPM->getWaypointEditableList();
...@@ -592,11 +606,6 @@ void WaypointList::on_clearWPListButton_clicked() ...@@ -592,11 +606,6 @@ void WaypointList::on_clearWPListButton_clicked()
WaypointEditableView* widget = wpEditableViews.find(waypoints[0]).value(); WaypointEditableView* widget = wpEditableViews.find(waypoints[0]).value();
widget->remove(); widget->remove();
} }
} else {
// if(isGlobalWP)
// {
// emit clearPathclicked();
// }
} }
} }
......
...@@ -56,7 +56,7 @@ class WaypointList : public QWidget ...@@ -56,7 +56,7 @@ class WaypointList : public QWidget
Q_OBJECT Q_OBJECT
Q_DISABLE_COPY(WaypointList) Q_DISABLE_COPY(WaypointList)
public: public:
WaypointList(QWidget* parent = NULL, UASInterface* uas = NULL); WaypointList(QWidget* parent = NULL, UASWaypointManager* wpm = NULL);
virtual ~WaypointList(); virtual ~WaypointList();
public slots: public slots:
......
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