1
0
mirror of https://bitbucket.org/librepilot/librepilot.git synced 2025-01-18 03:52:11 +01:00

Enable waypoints on the map again

This commit is contained in:
James Cotton 2012-05-11 20:29:53 -05:00
parent 252f61bb8e
commit f3e3a2f16b
2 changed files with 103 additions and 111 deletions

View File

@ -325,6 +325,21 @@ OPMapGadgetWidget::~OPMapGadgetWidget()
m_map->SetShowUAV(false); // " "
}
m_waypoint_list_mutex.lock();
foreach (t_waypoint *wp, m_waypoint_list)
{
if (!wp) continue;
// todo:
delete wp->map_wp_item;
}
m_waypoint_list_mutex.unlock();
m_waypoint_list.clear();
if (m_map)
{
delete m_map;
@ -442,6 +457,11 @@ void OPMapGadgetWidget::contextMenuEvent(QContextMenuEvent *event)
menu.addSeparator();
/*
menu.addAction(findPlaceAct);
menu.addSeparator();
*/
QMenu safeArea("Safety Area definitions");
// menu.addAction(showSafeAreaAct);
QMenu safeAreaSubMenu(tr("Safe Area Radius") + " (" + QString::number(m_map->Home->SafeArea()) + "m)", this);
@ -514,32 +534,32 @@ void OPMapGadgetWidget::contextMenuEvent(QContextMenuEvent *event)
// *********
qDebug() << "Testing mode";
switch (m_map_mode)
{
case Normal_MapMode:
qDebug() << "Normal mode";
// only show the waypoint stuff if not in 'magic waypoint' mode
/*
menu.addSeparator()->setText(tr("Waypoints"));
menu.addSeparator()->setText(tr("Waypoints"));
menu.addAction(wayPointEditorAct);
menu.addAction(addWayPointAct);
menu.addAction(wayPointEditorAct);
menu.addAction(addWayPointAct);
if (m_mouse_waypoint)
{ // we have a waypoint under the mouse
menu.addAction(editWayPointAct);
if (m_mouse_waypoint)
{ // we have a waypoint under the mouse
menu.addAction(editWayPointAct);
lockWayPointAct->setChecked(waypoint_locked);
menu.addAction(lockWayPointAct);
lockWayPointAct->setChecked(waypoint_locked);
menu.addAction(lockWayPointAct);
if (!waypoint_locked)
menu.addAction(deleteWayPointAct);
}
if (!waypoint_locked)
menu.addAction(deleteWayPointAct);
}
m_waypoint_list_mutex.lock();
if (m_waypoint_list.count() > 0)
menu.addAction(clearWayPointsAct); // we have waypoints
m_waypoint_list_mutex.unlock();
*/
m_waypoint_list_mutex.lock();
if (m_waypoint_list.count() > 0)
menu.addAction(clearWayPointsAct); // we have waypoints
m_waypoint_list_mutex.unlock();
break;
@ -1476,16 +1496,12 @@ void OPMapGadgetWidget::createActions()
followUAVheadingAct->setChecked(false);
connect(followUAVheadingAct, SIGNAL(toggled(bool)), this, SLOT(onFollowUAVheadingAct_toggled(bool)));
/*
TODO: Waypoint support is disabled for v1.0
*/
/*
/* Waypoint stuff */
wayPointEditorAct = new QAction(tr("&Waypoint editor"), this);
wayPointEditorAct->setShortcut(tr("Ctrl+W"));
wayPointEditorAct->setStatusTip(tr("Open the waypoint editor"));
wayPointEditorAct->setEnabled(false); // temporary
connect(wayPointEditorAct, SIGNAL(triggered()), this, SLOT(onOpenWayPointEditorAct_triggered()));
//connect(wayPointEditorAct, SIGNAL(triggered()), this, SLOT(onOpenWayPointEditorAct_triggered()));
addWayPointAct = new QAction(tr("&Add waypoint"), this);
addWayPointAct->setShortcut(tr("Ctrl+A"));
@ -1512,7 +1528,6 @@ void OPMapGadgetWidget::createActions()
clearWayPointsAct->setShortcut(tr("Ctrl+C"));
clearWayPointsAct->setStatusTip(tr("Clear waypoints"));
connect(clearWayPointsAct, SIGNAL(triggered()), this, SLOT(onClearWayPointsAct_triggered()));
*/
homeMagicWaypointAct = new QAction(tr("Home magic waypoint"), this);
homeMagicWaypointAct->setStatusTip(tr("Move the magic waypoint to the home position"));
@ -1877,24 +1892,20 @@ void OPMapGadgetWidget::onUAVTrailDistanceActGroup_triggered(QAction *action)
m_map->UAV->SetTrailDistance(trail_distance);
}
/**
* TODO: unused for v1.0
**/
/*
void OPMapGadgetWidget::onAddWayPointAct_triggered()
{
if (!m_widget || !m_map)
return;
if (!m_widget || !m_map)
return;
if (m_map_mode != Normal_MapMode)
return;
m_waypoint_list_mutex.lock();
// create a waypoint on the map at the last known mouse position
// create a waypoint on the map at the last known mouse position
t_waypoint *wp = new t_waypoint;
wp->map_wp_item = NULL;
wp->coord = context_menu_lat_lon;
wp->coord = m_context_menu_lat_lon;
wp->altitude = 0;
wp->description = "";
wp->locked = false;
@ -1920,7 +1931,6 @@ void OPMapGadgetWidget::onAddWayPointAct_triggered()
m_waypoint_list_mutex.unlock();
}
*/
/**
* Called when the user asks to edit a waypoint from the map
@ -1928,11 +1938,10 @@ void OPMapGadgetWidget::onAddWayPointAct_triggered()
* TODO: should open an interface to edit waypoint properties, or
* propagate the signal to a specific WP plugin (tbd).
**/
/*
void OPMapGadgetWidget::onEditWayPointAct_triggered()
{
if (!m_widget || !m_map)
return;
if (!m_widget || !m_map)
return;
if (m_map_mode != Normal_MapMode)
return;
@ -1944,12 +1953,7 @@ void OPMapGadgetWidget::onEditWayPointAct_triggered()
m_mouse_waypoint = NULL;
}
*/
/**
* TODO: unused for v1.0
*/
/*
void OPMapGadgetWidget::onLockWayPointAct_triggered()
{
if (!m_widget || !m_map || !m_mouse_waypoint)
@ -1969,12 +1973,7 @@ void OPMapGadgetWidget::onLockWayPointAct_triggered()
m_mouse_waypoint = NULL;
}
*/
/**
* TODO: unused for v1.0
*/
/*
void OPMapGadgetWidget::onDeleteWayPointAct_triggered()
{
if (!m_widget || !m_map)
@ -2008,31 +2007,29 @@ void OPMapGadgetWidget::onDeleteWayPointAct_triggered()
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;
// }
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;
}
*/
/**
* TODO: No Waypoint support in v1.0
*/
/*
void OPMapGadgetWidget::onClearWayPointsAct_triggered()
{
if (!m_widget || !m_map)
@ -2043,7 +2040,7 @@ void OPMapGadgetWidget::onClearWayPointsAct_triggered()
QMutexLocker locker(&m_waypoint_list_mutex);
m_map->WPDeleteAll();
m_map->WPDeleteAll();
foreach (t_waypoint *wp, m_waypoint_list)
{
@ -2056,7 +2053,6 @@ void OPMapGadgetWidget::onClearWayPointsAct_triggered()
m_waypoint_list.clear();
}
*/
void OPMapGadgetWidget::onHomeMagicWaypointAct_triggered()
{

View File

@ -7,7 +7,7 @@
* @{
* @addtogroup OPMapPlugin OpenPilot Map Plugin
* @{
* @brief The OpenPilot Map plugin
* @brief The OpenPilot Map plugin
*****************************************************************************/
/*
* This program is free software; you can redistribute it and/or modify
@ -57,7 +57,7 @@
namespace Ui
{
class OPMap_Widget;
class OPMap_Widget;
}
using namespace mapcontrol;
@ -96,7 +96,7 @@ class OPMapGadgetWidget : public QWidget
public:
OPMapGadgetWidget(QWidget *parent = 0);
~OPMapGadgetWidget();
~OPMapGadgetWidget();
/**
* @brief public functions
@ -115,8 +115,8 @@ public:
void setUseMemoryCache(bool useMemoryCache);
void setCacheLocation(QString cacheLocation);
void setMapMode(opMapModeType mode);
void SetUavPic(QString UAVPic);
void setMaxUpdateRate(int update_rate);
void SetUavPic(QString UAVPic);
void setMaxUpdateRate(int update_rate);
public slots:
void homePositionUpdated(UAVObject *);
@ -142,21 +142,21 @@ private slots:
*
* Some are currently disabled for the v1.0 plugin version.
*/
// void comboBoxFindPlace_returnPressed();
// void on_toolButtonFindPlace_clicked();
// void comboBoxFindPlace_returnPressed();
// void on_toolButtonFindPlace_clicked();
void on_toolButtonZoomM_clicked();
void on_toolButtonZoomP_clicked();
void on_toolButtonMapHome_clicked();
void on_toolButtonMapUAV_clicked();
void on_toolButtonMapUAVheading_clicked();
void on_horizontalSliderZoom_sliderMoved(int position);
// void on_toolButtonAddWaypoint_clicked();
// void on_treeViewWaypoints_clicked(QModelIndex index);
// void on_toolButtonHome_clicked();
// void on_toolButtonNextWaypoint_clicked();
// void on_toolButtonPrevWaypoint_clicked();
// void on_toolButtonHoldPosition_clicked();
// void on_toolButtonGo_clicked();
// void on_toolButtonAddWaypoint_clicked();
// void on_treeViewWaypoints_clicked(QModelIndex index);
// void on_toolButtonHome_clicked();
// void on_toolButtonNextWaypoint_clicked();
// void on_toolButtonPrevWaypoint_clicked();
// void on_toolButtonHoldPosition_clicked();
// void on_toolButtonGo_clicked();
void on_toolButtonMagicWaypointMapMode_clicked();
void on_toolButtonNormalMapMode_clicked();
void on_toolButtonHomeWaypoint_clicked();
@ -191,7 +191,7 @@ private slots:
void onCopyMouseLatLonToClipAct_triggered();
void onCopyMouseLatToClipAct_triggered();
void onCopyMouseLonToClipAct_triggered();
// void onFindPlaceAct_triggered();
// void onFindPlaceAct_triggered();
void onShowCompassAct_toggled(bool show);
void onShowDiagnostics_toggled(bool show);
void onShowUAVAct_toggled(bool show);
@ -206,14 +206,12 @@ private slots:
void onGoUAVAct_triggered();
void onFollowUAVpositionAct_toggled(bool checked);
void onFollowUAVheadingAct_toggled(bool checked);
/*
void onOpenWayPointEditorAct_triggered();
//void onOpenWayPointEditorAct_triggered();
void onAddWayPointAct_triggered();
void onEditWayPointAct_triggered();
void onLockWayPointAct_triggered();
void onDeleteWayPointAct_triggered();
void onClearWayPointsAct_triggered();
*/
void onMapModeActGroup_triggered(QAction *action);
void onZoomActGroup_triggered(QAction *action);
void onHomeMagicWaypointAct_triggered();
@ -223,31 +221,31 @@ private slots:
void onClearUAVtrailAct_triggered();
void onUAVTrailTimeActGroup_triggered(QAction *action);
void onUAVTrailDistanceActGroup_triggered(QAction *action);
void onMaxUpdateRateActGroup_triggered(QAction *action);
void onMaxUpdateRateActGroup_triggered(QAction *action);
private:
// *****
// *****
int m_min_zoom;
int m_max_zoom;
int m_min_zoom;
int m_max_zoom;
double m_heading; // uav heading
internals::PointLatLng m_mouse_lat_lon;
internals::PointLatLng m_context_menu_lat_lon;
internals::PointLatLng m_mouse_lat_lon;
internals::PointLatLng m_context_menu_lat_lon;
int m_prev_tile_number;
int m_prev_tile_number;
opMapModeType m_map_mode;
int m_maxUpdateRate;
int m_maxUpdateRate;
t_home m_home_position;
t_home m_home_position;
t_waypoint m_magic_waypoint;
t_waypoint m_magic_waypoint;
QStringList findPlaceWordList;
QStringList findPlaceWordList;
QCompleter *findPlaceCompleter;
QTimer *m_updateTimer;
@ -257,11 +255,11 @@ private:
mapcontrol::OPMapWidget *m_map;
ExtensionSystem::PluginManager *pm;
UAVObjectManager *obm;
UAVObjectUtilManager *obum;
ExtensionSystem::PluginManager *pm;
UAVObjectManager *obm;
UAVObjectUtilManager *obum;
//opmap_waypointeditor_dialog waypoint_editor_dialog;
//opmap_waypointeditor_dialog waypoint_editor_dialog;
//opmap_edit_waypoint_dialog waypoint_edit_dialog;
@ -274,9 +272,9 @@ private:
QMutex m_map_mutex;
bool m_telemetry_connected;
bool m_telemetry_connected;
// *****
// *****
void createActions();
@ -284,7 +282,7 @@ private:
QAction *closeAct2;
QAction *reloadAct;
QAction *ripAct;
QAction *copyMouseLatLonToClipAct;
QAction *copyMouseLatLonToClipAct;
QAction *copyMouseLatToClipAct;
QAction *copyMouseLonToClipAct;
QAction *findPlaceAct;
@ -300,14 +298,12 @@ private:
QAction *goUAVAct;
QAction *followUAVpositionAct;
QAction *followUAVheadingAct;
/*
QAction *wayPointEditorAct;
QAction *addWayPointAct;
QAction *editWayPointAct;
QAction *lockWayPointAct;
QAction *deleteWayPointAct;
QAction *clearWayPointsAct;
*/
QAction *homeMagicWaypointAct;
QAction *showSafeAreaAct;
@ -330,12 +326,12 @@ private:
QActionGroup *zoomActGroup;
QList<QAction *> zoomAct;
QActionGroup *maxUpdateRateActGroup;
QList<QAction *> maxUpdateRateAct;
QActionGroup *maxUpdateRateActGroup;
QList<QAction *> maxUpdateRateAct;
// *****
// *****
void homeMagicWaypoint();
void homeMagicWaypoint();
void moveToMagicWaypointPosition();
@ -351,13 +347,13 @@ private:
double bearing(internals::PointLatLng from, internals::PointLatLng to);
internals::PointLatLng destPoint(internals::PointLatLng source, double bear, double dist);
bool getUAVPosition(double &latitude, double &longitude, double &altitude);
bool getGPSPosition(double &latitude, double &longitude, double &altitude);
bool getUAVPosition(double &latitude, double &longitude, double &altitude);
bool getGPSPosition(double &latitude, double &longitude, double &altitude);
double getUAV_Yaw();
void setMapFollowingMode();
bool setHomeLocationObject();
bool setHomeLocationObject();
};
#endif /* OPMAP_GADGETWIDGET_H_ */