From ff7f724283205e115423742e4941681a332604dd Mon Sep 17 00:00:00 2001 From: James Goppert Date: Mon, 15 Nov 2010 09:06:51 -0500 Subject: [PATCH] Added waypoint types. --- src/Waypoint.cc | 5 +++++ src/Waypoint.h | 11 +++++++++++ src/ui/WaypointGlobalView.cc | 5 +++++ src/ui/WaypointView.cc | 24 ++++++++++++++++++++++++ src/ui/WaypointView.h | 1 + src/ui/WaypointView.ui | 16 +++++++++++++--- 6 files changed, 59 insertions(+), 3 deletions(-) diff --git a/src/Waypoint.cc b/src/Waypoint.cc index 7901330b9..07a4f6f2b 100644 --- a/src/Waypoint.cc +++ b/src/Waypoint.cc @@ -100,6 +100,11 @@ void Waypoint::setYaw(float yaw) this->yaw = yaw; } +void Waypoint::setType(type_enum type) +{ + this->type = type; +} + void Waypoint::setAutocontinue(bool autoContinue) { this->autocontinue = autoContinue; diff --git a/src/Waypoint.h b/src/Waypoint.h index 8e8f40025..777e78488 100644 --- a/src/Waypoint.h +++ b/src/Waypoint.h @@ -36,6 +36,7 @@ This file is part of the PIXHAWK project #include #include #include +#include class Waypoint : public QObject { @@ -58,6 +59,14 @@ public: void save(QTextStream &saveStream); bool load(QTextStream &loadStream); + enum type_enum + { + GLOBAL = 0, + LOCAL = 1, + GLOBAL_ORBIT = 2, + LOCAL_ORBIT = 3 + }; + protected: quint16 id; @@ -65,6 +74,7 @@ protected: float y; float z; float yaw; + type_enum type; bool autocontinue; bool current; float orbit; @@ -76,6 +86,7 @@ public slots: void setY(float y); void setZ(float z); void setYaw(float yaw); + void setType(type_enum type); void setAutocontinue(bool autoContinue); void setCurrent(bool current); void setOrbit(float orbit); diff --git a/src/ui/WaypointGlobalView.cc b/src/ui/WaypointGlobalView.cc index 44a9202f0..e5e468ff3 100644 --- a/src/ui/WaypointGlobalView.cc +++ b/src/ui/WaypointGlobalView.cc @@ -12,6 +12,9 @@ WaypointGlobalView::WaypointGlobalView(Waypoint* wp,QWidget *parent) : ui->m_orbitalSpinBox->hide(); + // set type + wp->setType(Waypoint::GLOBAL); + // Read values and set user interface updateValues(); @@ -197,11 +200,13 @@ void WaypointGlobalView::changeOrbitalState(int state) { ui->m_orbitalSpinBox->setEnabled(true); ui->m_orbitalSpinBox->show(); + wp->setType(Waypoint::GLOBAL_ORBIT); } else { ui->m_orbitalSpinBox->setEnabled(false); ui->m_orbitalSpinBox->hide(); + wp->setType(Waypoint::GLOBAL); } } diff --git a/src/ui/WaypointView.cc b/src/ui/WaypointView.cc index 13c772e23..4e9ee95db 100644 --- a/src/ui/WaypointView.cc +++ b/src/ui/WaypointView.cc @@ -46,6 +46,9 @@ WaypointView::WaypointView(Waypoint* wp, QWidget* parent) : m_ui->setupUi(this); this->wp = wp; + wp->setType(Waypoint::LOCAL); + m_ui->orbitSpinBox->setEnabled(false); + m_ui->orbitSpinBox->hide(); // Read values and set user interface updateValues(); @@ -64,6 +67,9 @@ WaypointView::WaypointView(Waypoint* wp, QWidget* parent) : connect(m_ui->autoContinue, SIGNAL(stateChanged(int)), this, SLOT(changedAutoContinue(int))); connect(m_ui->selectedBox, SIGNAL(stateChanged(int)), this, SLOT(changedCurrent(int))); + connect(m_ui->orbitCheckBox, SIGNAL(stateChanged(int)), this, SLOT(changeOrbitalState(int))); + + connect(m_ui->orbitSpinBox, SIGNAL(valueChanged(double)), wp, SLOT(setOrbit(double))); connect(m_ui->holdTimeSpinBox, SIGNAL(valueChanged(int)), wp, SLOT(setHoldTime(int))); @@ -153,3 +159,21 @@ void WaypointView::changeEvent(QEvent *e) break; } } + +void WaypointView::changeOrbitalState(int state) +{ + Q_UNUSED(state); + + if(m_ui->orbitCheckBox->isChecked()) + { + m_ui->orbitSpinBox->setEnabled(true); + m_ui->orbitSpinBox->show(); + wp->setType(Waypoint::LOCAL_ORBIT); + } + else + { + m_ui->orbitSpinBox->setEnabled(false); + m_ui->orbitSpinBox->hide(); + wp->setType(Waypoint::LOCAL); + } +} diff --git a/src/ui/WaypointView.h b/src/ui/WaypointView.h index e293064d2..367102135 100644 --- a/src/ui/WaypointView.h +++ b/src/ui/WaypointView.h @@ -56,6 +56,7 @@ public slots: void moveDown(); void remove(); void changedAutoContinue(int); + void changeOrbitalState(int state); void changedCurrent(int); void updateValues(void); diff --git a/src/ui/WaypointView.ui b/src/ui/WaypointView.ui index ad3680fc7..4396337c0 100644 --- a/src/ui/WaypointView.ui +++ b/src/ui/WaypointView.ui @@ -6,8 +6,8 @@ 0 0 - 763 - 40 + 853 + 30 @@ -155,7 +155,7 @@ QProgressBar::chunk#thrustBar { - + 2 @@ -343,6 +343,16 @@ QProgressBar::chunk#thrustBar { + + + + enable orbital mode (loiter at waypoint) + + + + + + -- 2.22.0