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,28 +98,32 @@ WaypointList::WaypointList(QWidget *parent, UASInterface* uas) : ...@@ -96,28 +98,32 @@ 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
if (!WPM->getUAS())
{
// Hide buttons, which don't make sense without valid UAS
m_ui->positionAddButton->hide();
m_ui->transmitButton->hide();
m_ui->readButton->hide();
m_ui->refreshButton->hide();
//FIXME: The whole "Onboard Waypoints"-tab should be hidden, instead of "refresh" button
UnconnectedUASInfoWidget* inf = new UnconnectedUASInfoWidget(this);
viewOnlyListLayout->insertWidget(0, inf); //insert a "NO UAV" info into the Onboard Tab
showOfflineWarning = true;
} else {
setUAS(static_cast<UASInterface*>(WPM->getUAS()));
}
// SET UAS AFTER ALL SIGNALS/SLOTS ARE CONNECTED /* connect slots */
if (uas) connect(WPM, SIGNAL(updateStatusString(const QString &)), this, SLOT(updateStatusLabel(const QString &)));
{ connect(WPM, SIGNAL(waypointEditableListChanged(void)), this, SLOT(waypointEditableListChanged(void)));
WPM = uas->getWaypointManager(); connect(WPM, SIGNAL(waypointEditableChanged(int,Waypoint*)), this, SLOT(updateWaypointEditable(int,Waypoint*)));
} connect(WPM, SIGNAL(waypointViewOnlyListChanged(void)), this, SLOT(waypointViewOnlyListChanged(void)));
else connect(WPM, SIGNAL(waypointViewOnlyChanged(int,Waypoint*)), this, SLOT(updateWaypointViewOnly(int,Waypoint*)));
{ connect(WPM, SIGNAL(currentWaypointChanged(quint16)), this, SLOT(currentWaypointViewOnlyChanged(quint16)));
// Hide buttons, which don't make sense without valid UAS
m_ui->positionAddButton->hide();
m_ui->transmitButton->hide();
m_ui->readButton->hide();
m_ui->refreshButton->hide();
//FIXME: The whole "Onboard Waypoints"-tab should be hidden, instead of "refresh" button
UnconnectedUASInfoWidget* inf = new UnconnectedUASInfoWidget(this);
viewOnlyListLayout->insertWidget(0, inf); //insert a "NO UAV" info into the Onboard Tab
showOfflineWarning = true;
WPM = new UASWaypointManager(NULL);
} }
setUAS(uas);
// STATUS LABEL // STATUS LABEL
updateStatusLabel(""); updateStatusLabel("");
...@@ -154,28 +160,38 @@ void WaypointList::updateAttitude(UASInterface* uas, double roll, double pitch, ...@@ -154,28 +160,38 @@ 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;
WPM = uas->getWaypointManager();
} if (this->uas != NULL)
if (this->uas == NULL)
{ {
this->uas = uas; // Clear current list
connect(WPM, SIGNAL(updateStatusString(const QString &)), this, SLOT(updateStatusLabel(const QString &))); on_clearWPListButton_clicked();
connect(WPM, SIGNAL(waypointEditableListChanged(void)), this, SLOT(waypointEditableListChanged(void))); // Disconnect everything
connect(WPM, SIGNAL(waypointEditableChanged(int,Waypoint*)), this, SLOT(updateWaypointEditable(int,Waypoint*))); disconnect(WPM, SIGNAL(updateStatusString(const QString &)), this, SLOT(updateStatusLabel(const QString &)));
connect(WPM, SIGNAL(waypointViewOnlyListChanged(void)), this, SLOT(waypointViewOnlyListChanged(void))); disconnect(WPM, SIGNAL(waypointEditableListChanged(void)), this, SLOT(waypointEditableListChanged(void)));
connect(WPM, SIGNAL(waypointViewOnlyChanged(int,Waypoint*)), this, SLOT(updateWaypointViewOnly(int,Waypoint*))); disconnect(WPM, SIGNAL(waypointEditableChanged(int,Waypoint*)), this, SLOT(updateWaypointEditable(int,Waypoint*)));
connect(WPM, SIGNAL(currentWaypointChanged(quint16)), this, SLOT(currentWaypointViewOnlyChanged(quint16))); disconnect(WPM, SIGNAL(waypointViewOnlyListChanged(void)), this, SLOT(waypointViewOnlyListChanged(void)));
if (uas != NULL) disconnect(WPM, SIGNAL(waypointViewOnlyChanged(int,Waypoint*)), this, SLOT(updateWaypointViewOnly(int,Waypoint*)));
{ disconnect(WPM, SIGNAL(currentWaypointChanged(quint16)), this, SLOT(currentWaypointViewOnlyChanged(quint16)));
connect(uas, SIGNAL(localPositionChanged(UASInterface*,double,double,double,quint64)), this, SLOT(updatePosition(UASInterface*,double,double,double,quint64))); disconnect(this->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))); disconnect(this->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(readGlobalWPFromUAS(bool)),this,SLOT(setIsReadGlobalWP(bool)));
} }
WPM = uas->getWaypointManager();
this->uas = uas;
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)));
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(WPM,SIGNAL(loadWPFile()),this,SLOT(setIsLoadFileWP()));
//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