Browse Source

Changed braces

QGC4.4
lm 14 years ago
parent
commit
5ec5d936c8
  1. 5
      src/uas/UASWaypointManager.cc
  2. 15
      src/ui/WaypointList.cc
  3. 27
      src/ui/map/QGCMapWidget.cc

5
src/uas/UASWaypointManager.cc

@ -305,7 +305,8 @@ int UASWaypointManager::setCurrentWaypoint(quint16 seq)
*/ */
void UASWaypointManager::addWaypoint(Waypoint *wp, bool enforceFirstActive) void UASWaypointManager::addWaypoint(Waypoint *wp, bool enforceFirstActive)
{ {
if (wp) { if (wp)
{
wp->setId(waypoints.size()); wp->setId(waypoints.size());
if (enforceFirstActive && waypoints.size() == 0) if (enforceFirstActive && waypoints.size() == 0)
{ {
@ -315,8 +316,8 @@ void UASWaypointManager::addWaypoint(Waypoint *wp, bool enforceFirstActive)
waypoints.insert(waypoints.size(), wp); waypoints.insert(waypoints.size(), wp);
connect(wp, SIGNAL(changed(Waypoint*)), this, SLOT(notifyOfChange(Waypoint*))); connect(wp, SIGNAL(changed(Waypoint*)), this, SLOT(notifyOfChange(Waypoint*)));
emit waypointListChanged();
emit waypointListChanged(uas.getUASID()); emit waypointListChanged(uas.getUASID());
emit waypointListChanged();
} }
} }

15
src/ui/WaypointList.cc

@ -118,7 +118,8 @@ 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 (this->uas == NULL && uas != NULL)
{
this->uas = uas; this->uas = uas;
connect(uas, SIGNAL(localPositionChanged(UASInterface*,double,double,double,quint64)), this, SLOT(updatePosition(UASInterface*,double,double,double,quint64))); connect(uas, SIGNAL(localPositionChanged(UASInterface*,double,double,double,quint64)), this, SLOT(updatePosition(UASInterface*,double,double,double,quint64)));
@ -136,7 +137,8 @@ void WaypointList::setUAS(UASInterface* uas)
void WaypointList::saveWaypoints() void WaypointList::saveWaypoints()
{ {
if (uas) { if (uas)
{
QString fileName = QFileDialog::getSaveFileName(this, tr("Save File"), "./waypoints.txt", tr("Waypoint File (*.txt)")); QString fileName = QFileDialog::getSaveFileName(this, tr("Save File"), "./waypoints.txt", tr("Waypoint File (*.txt)"));
uas->getWaypointManager()->saveWaypoints(fileName); uas->getWaypointManager()->saveWaypoints(fileName);
} }
@ -144,7 +146,8 @@ void WaypointList::saveWaypoints()
void WaypointList::loadWaypoints() void WaypointList::loadWaypoints()
{ {
if (uas) { if (uas)
{
QString fileName = QFileDialog::getOpenFileName(this, tr("Load File"), ".", tr("Waypoint File (*.txt)")); QString fileName = QFileDialog::getOpenFileName(this, tr("Load File"), ".", tr("Waypoint File (*.txt)"));
uas->getWaypointManager()->loadWaypoints(fileName); uas->getWaypointManager()->loadWaypoints(fileName);
} }
@ -152,14 +155,16 @@ void WaypointList::loadWaypoints()
void WaypointList::transmit() void WaypointList::transmit()
{ {
if (uas) { if (uas)
{
uas->getWaypointManager()->writeWaypoints(); uas->getWaypointManager()->writeWaypoints();
} }
} }
void WaypointList::read() void WaypointList::read()
{ {
if (uas) { if (uas)
{
uas->getWaypointManager()->readWaypoints(); uas->getWaypointManager()->readWaypoints();
} }
} }

27
src/ui/map/QGCMapWidget.cc

@ -427,9 +427,11 @@ void QGCMapWidget::updateWaypoint(int uas, Waypoint* wp)
// Currently only accept waypoint updates from the UAS in focus // Currently only accept waypoint updates from the UAS in focus
// this has to be changed to accept read-only updates from other systems as well. // this has to be changed to accept read-only updates from other systems as well.
UASInterface* uasInstance = UASManager::instance()->getUASForId(uas); UASInterface* uasInstance = UASManager::instance()->getUASForId(uas);
if (uasInstance->getWaypointManager() == currWPManager || uas == -1) { if (uasInstance->getWaypointManager() == currWPManager || uas == -1)
{
// Only accept waypoints in global coordinate frame // Only accept waypoints in global coordinate frame
if (((wp->getFrame() == MAV_FRAME_GLOBAL) || (wp->getFrame() == MAV_FRAME_GLOBAL_RELATIVE_ALT)) && wp->isNavigationType()) { if (((wp->getFrame() == MAV_FRAME_GLOBAL) || (wp->getFrame() == MAV_FRAME_GLOBAL_RELATIVE_ALT)) && wp->isNavigationType())
{
// We're good, this is a global waypoint // We're good, this is a global waypoint
// Get the index of this waypoint // Get the index of this waypoint
@ -442,7 +444,8 @@ void QGCMapWidget::updateWaypoint(int uas, Waypoint* wp)
firingWaypointChange = wp; firingWaypointChange = wp;
// Check if wp exists yet in map // Check if wp exists yet in map
if (!waypointsToIcons.contains(wp)) { if (!waypointsToIcons.contains(wp))
{
// Create icon for new WP // Create icon for new WP
QColor wpColor(Qt::red); QColor wpColor(Qt::red);
if (uasInstance) wpColor = uasInstance->getColor(); if (uasInstance) wpColor = uasInstance->getColor();
@ -473,7 +476,9 @@ void QGCMapWidget::updateWaypoint(int uas, Waypoint* wp)
} }
} }
} }
} else { }
else
{
// Waypoint exists, block it's signals and update it // Waypoint exists, block it's signals and update it
mapcontrol::WayPointItem* icon = waypointsToIcons.value(wp); mapcontrol::WayPointItem* icon = waypointsToIcons.value(wp);
// Make sure we don't die on a null pointer // Make sure we don't die on a null pointer
@ -504,12 +509,15 @@ void QGCMapWidget::updateWaypoint(int uas, Waypoint* wp)
firingWaypointChange = NULL; firingWaypointChange = NULL;
} else { }
else
{
// Check if the index of this waypoint is larger than the global // Check if the index of this waypoint is larger than the global
// waypoint list. This implies that the coordinate frame of this // waypoint list. This implies that the coordinate frame of this
// waypoint was changed and the list containing only global // waypoint was changed and the list containing only global
// waypoints was shortened. Thus update the whole list // waypoints was shortened. Thus update the whole list
if (waypointsToIcons.size() > currWPManager->getGlobalFrameAndNavTypeCount()) { if (waypointsToIcons.size() > currWPManager->getGlobalFrameAndNavTypeCount())
{
updateWaypointList(uas); updateWaypointList(uas);
} }
} }
@ -526,7 +534,8 @@ void QGCMapWidget::updateWaypointList(int uas)
// Currently only accept waypoint updates from the UAS in focus // Currently only accept waypoint updates from the UAS in focus
// this has to be changed to accept read-only updates from other systems as well. // this has to be changed to accept read-only updates from other systems as well.
UASInterface* uasInstance = UASManager::instance()->getUASForId(uas); UASInterface* uasInstance = UASManager::instance()->getUASForId(uas);
if ((uasInstance && (uasInstance->getWaypointManager() == currWPManager)) || uas == -1) { if ((uasInstance && (uasInstance->getWaypointManager() == currWPManager)) || uas == -1)
{
// ORDER MATTERS HERE! // ORDER MATTERS HERE!
// TWO LOOPS ARE NEEDED - INFINITY LOOP ELSE // TWO LOOPS ARE NEEDED - INFINITY LOOP ELSE
@ -535,10 +544,10 @@ void QGCMapWidget::updateWaypointList(int uas)
QVector<Waypoint* > wps = currWPManager->getGlobalFrameAndNavTypeWaypointList(); QVector<Waypoint* > wps = currWPManager->getGlobalFrameAndNavTypeWaypointList();
foreach (Waypoint* wp, waypointsToIcons.keys()) foreach (Waypoint* wp, waypointsToIcons.keys())
{ {
// Get icon to work on
mapcontrol::WayPointItem* icon = waypointsToIcons.value(wp);
if (!wps.contains(wp)) if (!wps.contains(wp))
{ {
// Get icon to work on
mapcontrol::WayPointItem* icon = waypointsToIcons.value(wp);
waypointsToIcons.remove(wp); waypointsToIcons.remove(wp);
iconsToWaypoints.remove(icon); iconsToWaypoints.remove(icon);
WPDelete(icon); WPDelete(icon);

Loading…
Cancel
Save