diff --git a/src/Waypoint.cc b/src/Waypoint.cc index bf947d4ad28e5246afa37f77bdb5ad3495bb5cc0..d4e2746913170278a17fb2cdbf438f1b342500a4 100644 --- a/src/Waypoint.cc +++ b/src/Waypoint.cc @@ -82,3 +82,23 @@ void Waypoint::setCurrent(bool current) { this->current = current; } + +void Waypoint::setX(double x) +{ + this->x = x; +} + +void Waypoint::setY(double y) +{ + this->y = y; +} + +void Waypoint::setZ(double z) +{ + this->z = z; +} + +void Waypoint::setYaw(double yaw) +{ + this->yaw = yaw; +} diff --git a/src/Waypoint.h b/src/Waypoint.h index 36698b16fc837dd7d7ce239facc7cd55b611c023..d736af3dfd1c8e2ead32f8f97b63ec6eb83cab34 100644 --- a/src/Waypoint.h +++ b/src/Waypoint.h @@ -69,6 +69,12 @@ public slots: void setYaw(float yaw); void setAutocontinue(bool autoContinue); void setCurrent(bool current); + + //for QDoubleSpin + void setX(double x); + void setY(double y); + void setZ(double z); + void setYaw(double yaw); }; #endif // WAYPOINT_H diff --git a/src/uas/UASWaypointManager.cc b/src/uas/UASWaypointManager.cc index b589341b836badfccff968962c99a8a872d9d17d..9ce5e5fd892a7b2e3678fa6a3e320d749de7015f 100644 --- a/src/uas/UASWaypointManager.cc +++ b/src/uas/UASWaypointManager.cc @@ -86,12 +86,12 @@ void UASWaypointManager::clearWaypointList() } -void UASWaypointManager::currentWaypointChanged(int) +void UASWaypointManager::currentWaypointChanged(quint16) { } -void UASWaypointManager::removeWaypointId(int) +void UASWaypointManager::removeWaypointId(quint16) { } @@ -121,7 +121,7 @@ void UASWaypointManager::requestWaypoints() } } -void UASWaypointManager::sendWaypoints(const QVector &list) +void UASWaypointManager::sendWaypoints(const QVector &list) { if (current_state == WP_IDLE) { diff --git a/src/uas/UASWaypointManager.h b/src/uas/UASWaypointManager.h index 26e6be1a34af860560ea49eb15853e35d97d0d3d..46c4c97a87e96fdf647251802ec06f5f848bcd7e 100644 --- a/src/uas/UASWaypointManager.h +++ b/src/uas/UASWaypointManager.h @@ -31,14 +31,14 @@ private: public slots: void clearWaypointList(); - void currentWaypointChanged(int); - void removeWaypointId(int); + void currentWaypointChanged(quint16); + void removeWaypointId(quint16); void requestWaypoints(); void sendWaypoints(const QVector &list); void waypointChanged(Waypoint*); signals: - void waypointUpdated(int,int,double,double,double,double,bool,bool); ///< Adds a waypoint to the waypoint list widget + void waypointUpdated(int,quint16,double,double,double,double,bool,bool); ///< Adds a waypoint to the waypoint list widget void updateStatusString(const QString &); ///< updates the current status string private: diff --git a/src/ui/WaypointList.cc b/src/ui/WaypointList.cc index f790905f5beebce12360ec6291523fb4ff122129..9512b77aa2408b9fdd7e0087263cb88e7a45b728 100644 --- a/src/ui/WaypointList.cc +++ b/src/ui/WaypointList.cc @@ -97,12 +97,12 @@ void WaypointList::setUAS(UASInterface* uas) if (this->uas == NULL && uas != NULL) { this->uas = uas; - connect(&uas->getWaypointManager(), SIGNAL(waypointUpdated(int,int,double,double,double,double,bool,bool)), this, SLOT(setWaypoint(int,int,double,double,double,double,bool,bool))); - connect(&uas->getWaypointManager(), SIGNAL(waypointReached(UASInterface*,int)), this, SLOT(waypointReached(UASInterface*,int))); - connect(this, SIGNAL(waypointChanged(Waypoint*)), &uas->getWaypointManager(), SLOT(setWaypoint(Waypoint*))); - connect(this, SIGNAL(currentWaypointChanged(int)), &uas->getWaypointManager(), SLOT(setWaypointActive(int))); - connect(this, SIGNAL(requestWaypoints()), &uas->getWaypointManager(), SLOT(requestWaypoints())); - connect(this, SIGNAL(clearWaypointList()), &uas->getWaypointManager(), SLOT(clearWaypointList())); + connect(&uas->getWaypointManager(), SIGNAL(waypointUpdated(int,quint16,double,double,double,double,bool,bool)), this, SLOT(setWaypoint(int,quint16,double,double,double,double,bool,bool))); + //connect(this, SIGNAL(waypointChanged(Waypoint*)), &uas->getWaypointManager(), SLOT(setWaypoint(Waypoint*))); + //connect(this, SIGNAL(currentWaypointChanged(int)), &uas->getWaypointManager(), SLOT(setWaypointActive(quint16))); + connect(this, SIGNAL(sendWaypoints(const QVector &)), &uas->getWaypointManager(), SLOT(sendWaypoints(const QVector &))); + connect(this, SIGNAL(requestWaypoints()), &uas->getWaypointManager(), SLOT(requestWaypoints())); + connect(this, SIGNAL(clearWaypointList()), &uas->getWaypointManager(), SLOT(clearWaypointList())); connect(&uas->getWaypointManager(), SIGNAL(updateStatusString(const QString &)), this, SLOT(updateStatusLabel(const QString &))); @@ -113,24 +113,17 @@ void WaypointList::setUAS(UASInterface* uas) } } -void WaypointList::setWaypoint(int uasId, int id, double x, double y, double z, double yaw, bool autocontinue, bool current) +void WaypointList::setWaypoint(int uasId, quint16 id, double x, double y, double z, double yaw, bool autocontinue, bool current) { if (uasId == this->uas->getUASID()) { transmitDelay->start(1000); - QString string = "New waypoint"; - - if (waypointNames.contains(id)) - { - string = waypointNames.value(id); - } - Waypoint* wp = new Waypoint(id, x, y, z, yaw, autocontinue, current); addWaypoint(wp); } } -void WaypointList::waypointReached(UASInterface* uas, int waypointId) +void WaypointList::waypointReached(UASInterface* uas, quint16 waypointId) { Q_UNUSED(uas); qDebug() << "Waypoint reached: " << waypointId; @@ -170,16 +163,17 @@ void WaypointList::transmit() transmitDelay->start(1000); m_ui->transmitButton->setEnabled(false); emit clearWaypointList(); - waypointNames.clear(); + for(int i = 0; i < waypoints.size(); i++) { //Waypoint* wp = waypoints[i]; - /*waypointNames.insert(wp->id, wp->name); - emit waypointChanged(wp); - if (wp->current) - emit currentWaypointChanged(wp->id);*/ + //emit waypointChanged(wp); + //if (wp->current) + // emit currentWaypointChanged(wp->id); } + emit sendWaypoints(waypoints); + while(waypoints.size()>0) { removeWaypoint(waypoints[0]); @@ -219,7 +213,7 @@ void WaypointList::addWaypoint(Waypoint* wp) listLayout->addWidget(wpViews.value(wp)); connect(wpview, SIGNAL(moveDownWaypoint(Waypoint*)), this, SLOT(moveDown(Waypoint*))); connect(wpview, SIGNAL(moveUpWaypoint(Waypoint*)), this, SLOT(moveUp(Waypoint*))); - connect(wpview, SIGNAL(removeWaypoint(Waypoint*)), this, SLOT(removeWaypointAndName(Waypoint*))); + connect(wpview, SIGNAL(removeWaypoint(Waypoint*)), this, SLOT(removeWaypoint(Waypoint*))); connect(wpview, SIGNAL(setCurrentWaypoint(Waypoint*)), this, SLOT(setCurrentWaypoint(Waypoint*))); connect(wpview, SIGNAL(waypointUpdated(Waypoint*)), this, SIGNAL(waypointChanged(Waypoint*))); } @@ -293,11 +287,10 @@ void WaypointList::moveDown(Waypoint* wp) } } -void WaypointList::removeWaypointAndName(Waypoint* wp) +/*void WaypointList::removeWaypointAndName(Waypoint* wp) { - waypointNames.remove(wp->getId()); removeWaypoint(wp); -} +}*/ void WaypointList::removeWaypoint(Waypoint* wp) { @@ -382,7 +375,7 @@ void WaypointList::loadWaypoints() while(waypoints.size()>0) { - removeWaypointAndName(waypoints[0]); + removeWaypoint(waypoints[0]); } QTextStream in(&file); diff --git a/src/ui/WaypointList.h b/src/ui/WaypointList.h index cde1a2891a341bda7a60bb181476496fc85ea94a..403e71e0ce2c7a7913f10020d92bc6dfcea7df0c 100644 --- a/src/ui/WaypointList.h +++ b/src/ui/WaypointList.h @@ -71,17 +71,15 @@ public slots: void updateStatusLabel(const QString &string); //To be moved to UASWaypointManager (?) - void setWaypoint(int uasId, int id, double x, double y, double z, double yaw, bool autocontinue, bool current); + void setWaypoint(int uasId, quint16 id, double x, double y, double z, double yaw, bool autocontinue, bool current); void addWaypoint(Waypoint* wp); - void removeWaypointAndName(Waypoint* wp); - void waypointReached(UASInterface* uas, int waypointId); + void removeWaypoint(Waypoint* wp); + void waypointReached(UASInterface* uas, quint16 waypointId); protected: virtual void changeEvent(QEvent *e); - void debugOutputWaypoints(); QVector waypoints; - QMap waypointNames; QMap wpViews; QVBoxLayout* listLayout; QTimer* transmitDelay; @@ -89,12 +87,12 @@ protected: private: Ui::WaypointList *m_ui; - void removeWaypoint(Waypoint* wp); signals: - void waypointChanged(Waypoint*); - void currentWaypointChanged(int); - void removeWaypointId(int); + //void waypointChanged(Waypoint*); + //void currentWaypointChanged(int); + //void removeWaypointId(int); + void sendWaypoints(const QVector &); void requestWaypoints(); void clearWaypointList(); };