Commit 88671631 authored by pixhawk's avatar pixhawk

cleaned up arguments and members

parent d02cd51b
...@@ -82,3 +82,23 @@ void Waypoint::setCurrent(bool current) ...@@ -82,3 +82,23 @@ void Waypoint::setCurrent(bool current)
{ {
this->current = 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;
}
...@@ -69,6 +69,12 @@ public slots: ...@@ -69,6 +69,12 @@ public slots:
void setYaw(float yaw); void setYaw(float yaw);
void setAutocontinue(bool autoContinue); void setAutocontinue(bool autoContinue);
void setCurrent(bool current); 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 #endif // WAYPOINT_H
...@@ -86,12 +86,12 @@ void UASWaypointManager::clearWaypointList() ...@@ -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() ...@@ -121,7 +121,7 @@ void UASWaypointManager::requestWaypoints()
} }
} }
void UASWaypointManager::sendWaypoints(const QVector<Waypoint *> &list) void UASWaypointManager::sendWaypoints(const QVector<Waypoint*> &list)
{ {
if (current_state == WP_IDLE) if (current_state == WP_IDLE)
{ {
......
...@@ -31,14 +31,14 @@ private: ...@@ -31,14 +31,14 @@ private:
public slots: public slots:
void clearWaypointList(); void clearWaypointList();
void currentWaypointChanged(int); void currentWaypointChanged(quint16);
void removeWaypointId(int); void removeWaypointId(quint16);
void requestWaypoints(); void requestWaypoints();
void sendWaypoints(const QVector<Waypoint *> &list); void sendWaypoints(const QVector<Waypoint *> &list);
void waypointChanged(Waypoint*); void waypointChanged(Waypoint*);
signals: 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 void updateStatusString(const QString &); ///< updates the current status string
private: private:
......
...@@ -97,12 +97,12 @@ void WaypointList::setUAS(UASInterface* uas) ...@@ -97,12 +97,12 @@ void WaypointList::setUAS(UASInterface* uas)
if (this->uas == NULL && uas != NULL) if (this->uas == NULL && uas != NULL)
{ {
this->uas = uas; 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(waypointUpdated(int,quint16,double,double,double,double,bool,bool)), this, SLOT(setWaypoint(int,quint16,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(waypointChanged(Waypoint*)), &uas->getWaypointManager(), SLOT(setWaypoint(Waypoint*))); //connect(this, SIGNAL(currentWaypointChanged(int)), &uas->getWaypointManager(), SLOT(setWaypointActive(quint16)));
connect(this, SIGNAL(currentWaypointChanged(int)), &uas->getWaypointManager(), SLOT(setWaypointActive(int))); connect(this, SIGNAL(sendWaypoints(const QVector<Waypoint*> &)), &uas->getWaypointManager(), SLOT(sendWaypoints(const QVector<Waypoint*> &)));
connect(this, SIGNAL(requestWaypoints()), &uas->getWaypointManager(), SLOT(requestWaypoints())); connect(this, SIGNAL(requestWaypoints()), &uas->getWaypointManager(), SLOT(requestWaypoints()));
connect(this, SIGNAL(clearWaypointList()), &uas->getWaypointManager(), SLOT(clearWaypointList())); connect(this, SIGNAL(clearWaypointList()), &uas->getWaypointManager(), SLOT(clearWaypointList()));
connect(&uas->getWaypointManager(), SIGNAL(updateStatusString(const QString &)), this, SLOT(updateStatusLabel(const QString &))); connect(&uas->getWaypointManager(), SIGNAL(updateStatusString(const QString &)), this, SLOT(updateStatusLabel(const QString &)));
...@@ -113,24 +113,17 @@ void WaypointList::setUAS(UASInterface* uas) ...@@ -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()) if (uasId == this->uas->getUASID())
{ {
transmitDelay->start(1000); 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); Waypoint* wp = new Waypoint(id, x, y, z, yaw, autocontinue, current);
addWaypoint(wp); addWaypoint(wp);
} }
} }
void WaypointList::waypointReached(UASInterface* uas, int waypointId) void WaypointList::waypointReached(UASInterface* uas, quint16 waypointId)
{ {
Q_UNUSED(uas); Q_UNUSED(uas);
qDebug() << "Waypoint reached: " << waypointId; qDebug() << "Waypoint reached: " << waypointId;
...@@ -170,16 +163,17 @@ void WaypointList::transmit() ...@@ -170,16 +163,17 @@ void WaypointList::transmit()
transmitDelay->start(1000); transmitDelay->start(1000);
m_ui->transmitButton->setEnabled(false); m_ui->transmitButton->setEnabled(false);
emit clearWaypointList(); emit clearWaypointList();
waypointNames.clear();
for(int i = 0; i < waypoints.size(); i++) for(int i = 0; i < waypoints.size(); i++)
{ {
//Waypoint* wp = waypoints[i]; //Waypoint* wp = waypoints[i];
/*waypointNames.insert(wp->id, wp->name); //emit waypointChanged(wp);
emit waypointChanged(wp); //if (wp->current)
if (wp->current) // emit currentWaypointChanged(wp->id);
emit currentWaypointChanged(wp->id);*/
} }
emit sendWaypoints(waypoints);
while(waypoints.size()>0) while(waypoints.size()>0)
{ {
removeWaypoint(waypoints[0]); removeWaypoint(waypoints[0]);
...@@ -219,7 +213,7 @@ void WaypointList::addWaypoint(Waypoint* wp) ...@@ -219,7 +213,7 @@ void WaypointList::addWaypoint(Waypoint* wp)
listLayout->addWidget(wpViews.value(wp)); listLayout->addWidget(wpViews.value(wp));
connect(wpview, SIGNAL(moveDownWaypoint(Waypoint*)), this, SLOT(moveDown(Waypoint*))); connect(wpview, SIGNAL(moveDownWaypoint(Waypoint*)), this, SLOT(moveDown(Waypoint*)));
connect(wpview, SIGNAL(moveUpWaypoint(Waypoint*)), this, SLOT(moveUp(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(setCurrentWaypoint(Waypoint*)), this, SLOT(setCurrentWaypoint(Waypoint*)));
connect(wpview, SIGNAL(waypointUpdated(Waypoint*)), this, SIGNAL(waypointChanged(Waypoint*))); connect(wpview, SIGNAL(waypointUpdated(Waypoint*)), this, SIGNAL(waypointChanged(Waypoint*)));
} }
...@@ -293,11 +287,10 @@ void WaypointList::moveDown(Waypoint* wp) ...@@ -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); removeWaypoint(wp);
} }*/
void WaypointList::removeWaypoint(Waypoint* wp) void WaypointList::removeWaypoint(Waypoint* wp)
{ {
...@@ -382,7 +375,7 @@ void WaypointList::loadWaypoints() ...@@ -382,7 +375,7 @@ void WaypointList::loadWaypoints()
while(waypoints.size()>0) while(waypoints.size()>0)
{ {
removeWaypointAndName(waypoints[0]); removeWaypoint(waypoints[0]);
} }
QTextStream in(&file); QTextStream in(&file);
......
...@@ -71,17 +71,15 @@ public slots: ...@@ -71,17 +71,15 @@ public slots:
void updateStatusLabel(const QString &string); void updateStatusLabel(const QString &string);
//To be moved to UASWaypointManager (?) //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 addWaypoint(Waypoint* wp);
void removeWaypointAndName(Waypoint* wp); void removeWaypoint(Waypoint* wp);
void waypointReached(UASInterface* uas, int waypointId); void waypointReached(UASInterface* uas, quint16 waypointId);
protected: protected:
virtual void changeEvent(QEvent *e); virtual void changeEvent(QEvent *e);
void debugOutputWaypoints();
QVector<Waypoint*> waypoints; QVector<Waypoint*> waypoints;
QMap<int, QString> waypointNames;
QMap<Waypoint*, WaypointView*> wpViews; QMap<Waypoint*, WaypointView*> wpViews;
QVBoxLayout* listLayout; QVBoxLayout* listLayout;
QTimer* transmitDelay; QTimer* transmitDelay;
...@@ -89,12 +87,12 @@ protected: ...@@ -89,12 +87,12 @@ protected:
private: private:
Ui::WaypointList *m_ui; Ui::WaypointList *m_ui;
void removeWaypoint(Waypoint* wp);
signals: signals:
void waypointChanged(Waypoint*); //void waypointChanged(Waypoint*);
void currentWaypointChanged(int); //void currentWaypointChanged(int);
void removeWaypointId(int); //void removeWaypointId(int);
void sendWaypoints(const QVector<Waypoint*> &);
void requestWaypoints(); void requestWaypoints();
void clearWaypointList(); void clearWaypointList();
}; };
......
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