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

View File

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