mirror of
https://bitbucket.org/librepilot/librepilot.git
synced 2025-01-29 14:52:12 +01:00
Start adding the ability to delete a waypoint
This commit is contained in:
parent
64ba15cf07
commit
e686ac0b1d
@ -1957,52 +1957,22 @@ void OPMapGadgetWidget::onLockWayPointAct_triggered()
|
|||||||
|
|
||||||
void OPMapGadgetWidget::onDeleteWayPointAct_triggered()
|
void OPMapGadgetWidget::onDeleteWayPointAct_triggered()
|
||||||
{
|
{
|
||||||
|
Q_ASSERT(m_widget);
|
||||||
|
Q_ASSERT(m_map);
|
||||||
|
|
||||||
if (!m_widget || !m_map)
|
if (!m_widget || !m_map)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (m_map_mode != Normal_MapMode)
|
if (m_map_mode != Normal_MapMode)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (!m_mouse_waypoint)
|
Q_ASSERT(m_mouse_waypoint);
|
||||||
return;
|
if(m_mouse_waypoint) {
|
||||||
|
int waypointIdx = m_mouse_waypoint->Description().toInt();
|
||||||
|
|
||||||
bool locked = (m_mouse_waypoint->flags() & QGraphicsItem::ItemIsMovable) == 0;
|
Q_ASSERT(pathCompiler);
|
||||||
|
if(pathCompiler)
|
||||||
if (locked) return; // waypoint is locked
|
pathCompiler->doDelWaypoint(waypointIdx);
|
||||||
|
|
||||||
QMutexLocker locker(&m_waypoint_list_mutex);
|
|
||||||
|
|
||||||
for (int i = 0; i < m_waypoint_list.count(); i++)
|
|
||||||
{
|
|
||||||
t_waypoint *wp = m_waypoint_list.at(i);
|
|
||||||
if (!wp) continue;
|
|
||||||
if (!wp->map_wp_item || wp->map_wp_item != m_mouse_waypoint) continue;
|
|
||||||
|
|
||||||
// delete the waypoint from the map
|
|
||||||
m_map->WPDelete(wp->map_wp_item);
|
|
||||||
|
|
||||||
// delete the waypoint from our local waypoint list
|
|
||||||
m_waypoint_list.removeAt(i);
|
|
||||||
|
|
||||||
delete wp;
|
|
||||||
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
foreach (t_waypoint *wp, m_waypoint_list)
|
|
||||||
{
|
|
||||||
if (!wp) continue;
|
|
||||||
if (!wp->map_wp_item || wp->map_wp_item != m_mouse_waypoint) continue;
|
|
||||||
|
|
||||||
// delete the waypoint from the map
|
|
||||||
m_map->WPDelete(wp->map_wp_item);
|
|
||||||
|
|
||||||
// delete the waypoint from our local waypoint list
|
|
||||||
m_waypoint_list.removeOne(wp);
|
|
||||||
|
|
||||||
delete wp;
|
|
||||||
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
m_mouse_waypoint = NULL;
|
m_mouse_waypoint = NULL;
|
||||||
@ -2013,26 +1983,18 @@ void OPMapGadgetWidget::onDeleteWayPointAct_triggered()
|
|||||||
*/
|
*/
|
||||||
void OPMapGadgetWidget::onClearWayPointsAct_triggered()
|
void OPMapGadgetWidget::onClearWayPointsAct_triggered()
|
||||||
{
|
{
|
||||||
|
Q_ASSERT(m_widget);
|
||||||
|
Q_ASSERT(m_map);
|
||||||
|
|
||||||
if (!m_widget || !m_map)
|
if (!m_widget || !m_map)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (m_map_mode != Normal_MapMode)
|
if (m_map_mode != Normal_MapMode)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
QMutexLocker locker(&m_waypoint_list_mutex);
|
Q_ASSERT(pathCompiler);
|
||||||
|
if(pathCompiler)
|
||||||
m_map->WPDeleteAll();
|
pathCompiler->doDelAllWaypoints();
|
||||||
|
|
||||||
foreach (t_waypoint *wp, m_waypoint_list)
|
|
||||||
{
|
|
||||||
if (wp)
|
|
||||||
{
|
|
||||||
delete wp;
|
|
||||||
wp = NULL;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
m_waypoint_list.clear();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void OPMapGadgetWidget::onHomeMagicWaypointAct_triggered()
|
void OPMapGadgetWidget::onHomeMagicWaypointAct_triggered()
|
||||||
|
@ -121,7 +121,7 @@ void PathCompiler::doAddWaypoint(struct PathCompiler::waypoint waypoint, int /*p
|
|||||||
* Delete a waypoint
|
* Delete a waypoint
|
||||||
* @param index which waypoint to delete
|
* @param index which waypoint to delete
|
||||||
*/
|
*/
|
||||||
void PathCompiler::doDelWaypoint(int /*index*/)
|
void PathCompiler::doDelWaypoint(int index)
|
||||||
{
|
{
|
||||||
// This method is awkward because there is no support
|
// This method is awkward because there is no support
|
||||||
// on the FC for actually deleting a waypoint. We need
|
// on the FC for actually deleting a waypoint. We need
|
||||||
@ -132,6 +132,14 @@ void PathCompiler::doDelWaypoint(int /*index*/)
|
|||||||
Q_ASSERT(false);
|
Q_ASSERT(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Delete all the waypoints
|
||||||
|
*/
|
||||||
|
void PathCompiler::doDelAllWaypoints()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* When the UAV waypoints change trigger the pathcompiler to
|
* When the UAV waypoints change trigger the pathcompiler to
|
||||||
* get the latest version and then update the visualization
|
* get the latest version and then update the visualization
|
||||||
|
@ -109,6 +109,11 @@ public slots:
|
|||||||
*/
|
*/
|
||||||
void doDelWaypoint(int index);
|
void doDelWaypoint(int index);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Delete all the waypoints
|
||||||
|
*/
|
||||||
|
void doDelAllWaypoints();
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
/**
|
/**
|
||||||
* These are slots that the UAV can call to update the path.
|
* These are slots that the UAV can call to update the path.
|
||||||
|
Loading…
x
Reference in New Issue
Block a user