From 9494749115c2177730960af96fc555c23518d955 Mon Sep 17 00:00:00 2001 From: pixhawk Date: Sat, 22 Jan 2011 18:36:40 +0100 Subject: [PATCH] Fixed last wp issue --- qgroundcontrol.pro | 1 - src/Waypoint.cc | 108 ++++++++++++++++++++-------------------- src/Waypoint.h | 48 +++++++++--------- src/ui/MapWidget.cc | 4 ++ src/ui/WaypointView.cc | 100 +++++++++++++++++++++---------------- src/ui/WaypointView.ui | 45 +++++++++++++++++ src/ui/map/MAV2DIcon.cc | 1 + 7 files changed, 184 insertions(+), 123 deletions(-) diff --git a/qgroundcontrol.pro b/qgroundcontrol.pro index 13ff2dc06..44001d4ed 100644 --- a/qgroundcontrol.pro +++ b/qgroundcontrol.pro @@ -140,7 +140,6 @@ FORMS += src/ui/MainWindow.ui \ src/ui/QGCPxImuFirmwareUpdate.ui \ src/ui/QGCDataPlot2D.ui \ src/ui/QGCRemoteControlView.ui \ - src/ui/WaypointGlobalView.ui \ src/ui/QMap3D.ui \ src/ui/QGCWebView.ui \ src/ui/map3D/QGCGoogleEarthView.ui \ diff --git a/src/Waypoint.cc b/src/Waypoint.cc index d885cbb7f..b629f3355 100644 --- a/src/Waypoint.cc +++ b/src/Waypoint.cc @@ -9,15 +9,15 @@ This file is part of the QGROUNDCONTROL project it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. - + QGROUNDCONTROL is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - + You should have received a copy of the GNU General Public License along with QGROUNDCONTROL. If not, see . - + ======================================================================*/ /** @@ -32,7 +32,7 @@ This file is part of the QGROUNDCONTROL project #include "Waypoint.h" #include -Waypoint::Waypoint(quint16 _id, float _x, float _y, float _z, float _yaw, bool _autocontinue, bool _current, float _orbit, int _holdTime, MAV_FRAME _frame, MAV_ACTION _action) +Waypoint::Waypoint(quint16 _id, double _x, double _y, double _z, double _yaw, bool _autocontinue, bool _current, double _orbit, int _holdTime, MAV_FRAME _frame, MAV_ACTION _action) : id(_id), x(_x), y(_y), @@ -50,7 +50,7 @@ Waypoint::Waypoint(quint16 _id, float _x, float _y, float _z, float _yaw, bool _ Waypoint::~Waypoint() { - + } void Waypoint::save(QTextStream &saveStream) @@ -94,7 +94,7 @@ void Waypoint::setId(quint16 id) emit changed(this); } -void Waypoint::setX(float x) +void Waypoint::setX(double x) { if (this->x != x) { @@ -103,7 +103,7 @@ void Waypoint::setX(float x) } } -void Waypoint::setY(float y) +void Waypoint::setY(double y) { if (this->y != y) { @@ -112,7 +112,7 @@ void Waypoint::setY(float y) } } -void Waypoint::setZ(float z) +void Waypoint::setZ(double z) { if (this->z != z) { @@ -121,7 +121,7 @@ void Waypoint::setZ(float z) } } -void Waypoint::setYaw(float yaw) +void Waypoint::setYaw(double yaw) { if (this->yaw != yaw) { @@ -166,7 +166,7 @@ void Waypoint::setCurrent(bool current) } } -void Waypoint::setOrbit(float orbit) +void Waypoint::setOrbit(double orbit) { if (this->orbit != orbit) { @@ -184,47 +184,47 @@ void Waypoint::setHoldTime(int holdTime) } } -void Waypoint::setX(double x) -{ - if (this->x != static_cast(x)) - { - this->x = x; - emit changed(this); - } -} - -void Waypoint::setY(double y) -{ - if (this->y != static_cast(y)) - { - this->y = y; - emit changed(this); - } -} - -void Waypoint::setZ(double z) -{ - if (this->z != static_cast(z)) - { - this->z = z; - emit changed(this); - } -} - -void Waypoint::setYaw(double yaw) -{ - if (this->yaw != static_cast(yaw)) - { - this->yaw = yaw; - emit changed(this); - } -} - -void Waypoint::setOrbit(double orbit) -{ - if (this->orbit != static_cast(orbit)) - { - this->orbit = orbit; - emit changed(this); - } -} +//void Waypoint::setX(double x) +//{ +// if (this->x != static_cast(x)) +// { +// this->x = x; +// emit changed(this); +// } +//} + +//void Waypoint::setY(double y) +//{ +// if (this->y != static_cast(y)) +// { +// this->y = y; +// emit changed(this); +// } +//} + +//void Waypoint::setZ(double z) +//{ +// if (this->z != static_cast(z)) +// { +// this->z = z; +// emit changed(this); +// } +//} + +//void Waypoint::setYaw(double yaw) +//{ +// if (this->yaw != static_cast(yaw)) +// { +// this->yaw = yaw; +// emit changed(this); +// } +//} + +//void Waypoint::setOrbit(double orbit) +//{ +// if (this->orbit != static_cast(orbit)) +// { +// this->orbit = orbit; +// emit changed(this); +// } +//} diff --git a/src/Waypoint.h b/src/Waypoint.h index be350cfcc..afe529668 100644 --- a/src/Waypoint.h +++ b/src/Waypoint.h @@ -43,20 +43,20 @@ class Waypoint : public QObject Q_OBJECT public: - Waypoint(quint16 id = 0, float x = 0.0f, float y = 0.0f, float z = 0.0f, float yaw = 0.0f, bool autocontinue = false, - bool current = false, float orbit = 0.15f, int holdTime = 0, + Waypoint(quint16 id = 0, double x = 0.0f, double y = 0.0f, double z = 0.0f, double yaw = 0.0f, bool autocontinue = false, + bool current = false, double orbit = 0.15f, int holdTime = 0, MAV_FRAME frame=MAV_FRAME_GLOBAL, MAV_ACTION action=MAV_ACTION_NAVIGATE); ~Waypoint(); quint16 getId() const { return id; } - float getX() const { return x; } - float getY() const { return y; } - float getZ() const { return z; } - float getYaw() const { return yaw; } + double getX() const { return x; } + double getY() const { return y; } + double getZ() const { return z; } + double getYaw() const { return yaw; } bool getAutoContinue() const { return autocontinue; } bool getCurrent() const { return current; } - float getOrbit() const { return orbit; } - float getHoldTime() const { return holdTime; } + double getOrbit() const { return orbit; } + double getHoldTime() const { return holdTime; } MAV_FRAME getFrame() const { return frame; } MAV_ACTION getAction() const { return action; } const QString& getName() const { return name; } @@ -67,38 +67,38 @@ public: protected: quint16 id; - float x; - float y; - float z; - float yaw; + double x; + double y; + double z; + double yaw; MAV_FRAME frame; MAV_ACTION action; bool autocontinue; bool current; - float orbit; + double orbit; int holdTime; QString name; public slots: void setId(quint16 id); - void setX(float x); - void setY(float y); - void setZ(float z); - void setYaw(float yaw); + void setX(double x); + void setY(double y); + void setZ(double z); + void setYaw(double yaw); void setAction(MAV_ACTION action); void setFrame(MAV_FRAME frame); void setAutocontinue(bool autoContinue); void setCurrent(bool current); - void setOrbit(float orbit); + void setOrbit(double orbit); void setHoldTime(int holdTime); - //for QDoubleSpin - void setX(double x); - void setY(double y); - void setZ(double z); - void setYaw(double yaw); - void setOrbit(double orbit); +// //for QDoubleSpin +// void setX(double x); +// void setY(double y); +// void setZ(double z); +// void setYaw(double yaw); +// void setOrbit(double orbit); signals: /** @brief Announces a change to the waypoint data */ diff --git a/src/ui/MapWidget.cc b/src/ui/MapWidget.cc index 1a8bd7b7b..39522871d 100644 --- a/src/ui/MapWidget.cc +++ b/src/ui/MapWidget.cc @@ -930,6 +930,7 @@ void MapWidget::changeEvent(QEvent *e) void MapWidget::clearWaypoints(int uas) { + Q_UNUSED(uas); // Clear the previous WP track //mc->layer("Waypoints")->clearGeometries(); @@ -962,6 +963,7 @@ void MapWidget::clearWaypoints(int uas) void MapWidget::clearPath(int uas) { + Q_UNUSED(uas); mc->layer("Tracking")->clearGeometries(); foreach (qmapcontrol::LineString* ls, uasTrails) { @@ -976,6 +978,8 @@ void MapWidget::clearPath(int uas) void MapWidget::updateCameraPosition(double radio, double bearing, QString dir) { + Q_UNUSED(dir); + Q_UNUSED(bearing); // FIXME Mariano //camPoints.clear(); QPointF currentPos = mc->currentCoordinate(); diff --git a/src/ui/WaypointView.cc b/src/ui/WaypointView.cc index 5723efe74..d8ee43a48 100644 --- a/src/ui/WaypointView.cc +++ b/src/ui/WaypointView.cc @@ -1,24 +1,4 @@ -/*===================================================================== - -PIXHAWK Micro Air Vehicle Flying Robotics Toolkit - -(c) 2009, 2010 PIXHAWK PROJECT - -This file is part of the PIXHAWK project - - PIXHAWK is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - PIXHAWK is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with PIXHAWK. If not, see . - +/*=================================================================== ======================================================================*/ /** @@ -43,8 +23,8 @@ This file is part of the PIXHAWK project #include "ui_WaypointView.h" WaypointView::WaypointView(Waypoint* wp, QWidget* parent) : - QWidget(parent), - m_ui(new Ui::WaypointView) + QWidget(parent), + m_ui(new Ui::WaypointView) { m_ui->setupUi(this); @@ -146,7 +126,7 @@ void WaypointView::changedAction(int index) break; case MAV_ACTION_NAVIGATE: m_ui->autoContinue->show(); - m_ui->orbitSpinBox->show(); + m_ui->orbitSpinBox->show(); break; case MAV_ACTION_LOITER: m_ui->orbitSpinBox->show(); @@ -159,14 +139,6 @@ void WaypointView::changedAction(int index) void WaypointView::changedFrame(int index) { - // hide everything to start - m_ui->lonSpinBox->hide(); - m_ui->latSpinBox->hide(); - m_ui->altSpinBox->hide(); - m_ui->posNSpinBox->hide(); - m_ui->posESpinBox->hide(); - m_ui->posDSpinBox->hide(); - // set waypoint action MAV_FRAME frame = (MAV_FRAME)m_ui->comboBox_frame->itemData(index).toUInt(); wp->setFrame(frame); @@ -174,11 +146,17 @@ void WaypointView::changedFrame(int index) switch(frame) { case MAV_FRAME_GLOBAL: + m_ui->posNSpinBox->hide(); + m_ui->posESpinBox->hide(); + m_ui->posDSpinBox->hide(); m_ui->lonSpinBox->show(); m_ui->latSpinBox->show(); m_ui->altSpinBox->show(); break; case MAV_FRAME_LOCAL: + m_ui->lonSpinBox->hide(); + m_ui->latSpinBox->hide(); + m_ui->altSpinBox->hide(); m_ui->posNSpinBox->show(); m_ui->posESpinBox->show(); m_ui->posDSpinBox->show(); @@ -217,14 +195,36 @@ void WaypointView::updateValues() switch(frame) { case(MAV_FRAME_LOCAL): - m_ui->posNSpinBox->setValue(wp->getX()); - m_ui->posESpinBox->setValue(wp->getY()); - m_ui->posDSpinBox->setValue(wp->getZ()); + { + if (m_ui->posNSpinBox->value() != wp->getX()) + { + m_ui->posNSpinBox->setValue(wp->getX()); + } + if (m_ui->posESpinBox->value() != wp->getY()) + { + m_ui->posESpinBox->setValue(wp->getY()); + } + if (m_ui->posDSpinBox->value() != wp->getZ()) + { + m_ui->posDSpinBox->setValue(wp->getZ()); + } + } break; case(MAV_FRAME_GLOBAL): - m_ui->lonSpinBox->setValue(wp->getX()); - m_ui->latSpinBox->setValue(wp->getY()); - m_ui->altSpinBox->setValue(wp->getZ()); + { + if (m_ui->lonSpinBox->value() != wp->getX()) + { + m_ui->lonSpinBox->setValue(wp->getX()); + } + if (m_ui->latSpinBox->value() != wp->getY()) + { + m_ui->latSpinBox->setValue(wp->getY()); + } + if (m_ui->altSpinBox->value() != wp->getZ()) + { + m_ui->altSpinBox->setValue(wp->getZ()); + } + } break; } changedFrame(frame_index); @@ -232,7 +232,10 @@ void WaypointView::updateValues() // update action MAV_ACTION action = wp->getAction(); int action_index = m_ui->comboBox_action->findData(action); - m_ui->comboBox_action->setCurrentIndex(action_index); + if (m_ui->comboBox_action->currentIndex() != action_index) + { + m_ui->comboBox_action->setCurrentIndex(action_index); + } switch(action) { case MAV_ACTION_TAKEOFF: @@ -248,12 +251,21 @@ void WaypointView::updateValues() } changedAction(action_index); - m_ui->yawSpinBox->setValue(wp->getYaw()/M_PI*180.); + if (m_ui->yawSpinBox->value() != wp->getYaw()/M_PI*180.) + { + m_ui->yawSpinBox->setValue(wp->getYaw()/M_PI*180.); + } m_ui->selectedBox->setChecked(wp->getCurrent()); m_ui->autoContinue->setChecked(wp->getAutoContinue()); - m_ui->idLabel->setText(QString("%1").arg(wp->getId()));\ - m_ui->orbitSpinBox->setValue(wp->getOrbit()); - m_ui->holdTimeSpinBox->setValue(wp->getHoldTime()); + m_ui->idLabel->setText(QString("%1").arg(wp->getId())); + if (m_ui->orbitSpinBox->value() != wp->getOrbit()) + { + m_ui->orbitSpinBox->setValue(wp->getOrbit()); + } + if (m_ui->holdTimeSpinBox->value() != wp->getHoldTime()) + { + m_ui->holdTimeSpinBox->setValue(wp->getHoldTime()); + } wp->blockSignals(false); } @@ -265,7 +277,7 @@ void WaypointView::setCurrent(bool state) } else { - m_ui->selectedBox->setCheckState(Qt::Unchecked); + m_ui->selectedBox->setCheckState(Qt::Unchecked); } } diff --git a/src/ui/WaypointView.ui b/src/ui/WaypointView.ui index afba9592b..5f0188b07 100644 --- a/src/ui/WaypointView.ui +++ b/src/ui/WaypointView.ui @@ -170,6 +170,9 @@ QProgressBar::chunk#thrustBar { + + Qt::TabFocus + Currently selected waypoint @@ -231,12 +234,21 @@ QProgressBar::chunk#thrustBar { 0 + + Qt::ClickFocus + Position X coordinate false + + true + + + true + N @@ -262,6 +274,9 @@ QProgressBar::chunk#thrustBar { 0 + + Qt::StrongFocus + Position Y coordinate @@ -293,6 +308,9 @@ QProgressBar::chunk#thrustBar { 0 + + Qt::StrongFocus + Position Z coordinate (negative) @@ -321,6 +339,9 @@ QProgressBar::chunk#thrustBar { 0 + + Qt::StrongFocus + lat @@ -349,6 +370,9 @@ QProgressBar::chunk#thrustBar { 0 + + Qt::StrongFocus + lon @@ -402,6 +426,9 @@ QProgressBar::chunk#thrustBar { 0 + + Qt::StrongFocus + Yaw angle @@ -430,6 +457,9 @@ QProgressBar::chunk#thrustBar { 0 + + Qt::StrongFocus + Orbit radius @@ -458,6 +488,9 @@ QProgressBar::chunk#thrustBar { 0 + + Qt::StrongFocus + Time in milliseconds that the MAV has to stay inside the orbit before advancing @@ -486,6 +519,9 @@ QProgressBar::chunk#thrustBar { 0 + + Qt::StrongFocus + Take off angle @@ -515,6 +551,9 @@ QProgressBar::chunk#thrustBar { 22 + + Qt::NoFocus + Move Up @@ -535,6 +574,9 @@ QProgressBar::chunk#thrustBar { 22 + + Qt::NoFocus + Move Down @@ -555,6 +597,9 @@ QProgressBar::chunk#thrustBar { 22 + + Qt::NoFocus + Delete diff --git a/src/ui/map/MAV2DIcon.cc b/src/ui/map/MAV2DIcon.cc index 607276c4f..0075ebcbe 100644 --- a/src/ui/map/MAV2DIcon.cc +++ b/src/ui/map/MAV2DIcon.cc @@ -57,6 +57,7 @@ void MAV2DIcon::setYaw(float yaw) void MAV2DIcon::drawIcon(QPen* pen) { + Q_UNUSED(pen); switch (type) { case MAV_ICON_GENERIC: -- 2.22.0