mirror of
https://bitbucket.org/librepilot/librepilot.git
synced 2025-02-05 21:52:10 +01:00
Added Safe-Area options onto the right-click context menu.
git-svn-id: svn://svn.openpilot.org/OpenPilot/trunk@1917 ebee16cc-31ac-478f-84a7-5cbb03baadba
This commit is contained in:
parent
c13816db20
commit
a081fb7ec1
@ -40,6 +40,8 @@
|
|||||||
|
|
||||||
#define max_digital_zoom 3 // maximum allowed digital zoom level
|
#define max_digital_zoom 3 // maximum allowed digital zoom level
|
||||||
|
|
||||||
|
const int safe_area_radius_list[] = {5, 10, 20, 50, 100, 200, 500, 1000, 2000, 5000};
|
||||||
|
|
||||||
// *************************************************************************************
|
// *************************************************************************************
|
||||||
|
|
||||||
// constructor
|
// constructor
|
||||||
@ -127,6 +129,9 @@ OPMapGadgetWidget::OPMapGadgetWidget(QWidget *parent) : QWidget(parent)
|
|||||||
m_map->SetShowHome(true); // display the HOME position on the map
|
m_map->SetShowHome(true); // display the HOME position on the map
|
||||||
m_map->SetShowUAV(true); // display the UAV position on the map
|
m_map->SetShowUAV(true); // display the UAV position on the map
|
||||||
|
|
||||||
|
m_map->Home->SetSafeArea(safe_area_radius_list[3]); // set radius (meters)
|
||||||
|
m_map->Home->SetShowSafeArea(true); // show the safe area
|
||||||
|
|
||||||
m_map->UAV->SetTrailTime(0.5); // seconds
|
m_map->UAV->SetTrailTime(0.5); // seconds
|
||||||
m_map->UAV->SetTrailDistance(0.01); // kilometers
|
m_map->UAV->SetTrailDistance(0.01); // kilometers
|
||||||
|
|
||||||
@ -176,12 +181,14 @@ OPMapGadgetWidget::OPMapGadgetWidget(QWidget *parent) : QWidget(parent)
|
|||||||
case Normal_MapMode:
|
case Normal_MapMode:
|
||||||
m_widget->toolButtonMagicWaypointMapMode->setChecked(false);
|
m_widget->toolButtonMagicWaypointMapMode->setChecked(false);
|
||||||
m_widget->toolButtonNormalMapMode->setChecked(true);
|
m_widget->toolButtonNormalMapMode->setChecked(true);
|
||||||
|
m_widget->toolButtonHomeWaypoint->setEnabled(false);
|
||||||
m_widget->toolButtonCenterWaypoint->setEnabled(false);
|
m_widget->toolButtonCenterWaypoint->setEnabled(false);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case MagicWaypoint_MapMode:
|
case MagicWaypoint_MapMode:
|
||||||
m_widget->toolButtonNormalMapMode->setChecked(false);
|
m_widget->toolButtonNormalMapMode->setChecked(false);
|
||||||
m_widget->toolButtonMagicWaypointMapMode->setChecked(true);
|
m_widget->toolButtonMagicWaypointMapMode->setChecked(true);
|
||||||
|
m_widget->toolButtonHomeWaypoint->setEnabled(true);
|
||||||
m_widget->toolButtonCenterWaypoint->setEnabled(true);
|
m_widget->toolButtonCenterWaypoint->setEnabled(true);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@ -189,6 +196,7 @@ OPMapGadgetWidget::OPMapGadgetWidget(QWidget *parent) : QWidget(parent)
|
|||||||
m_map_mode = Normal_MapMode;
|
m_map_mode = Normal_MapMode;
|
||||||
m_widget->toolButtonMagicWaypointMapMode->setChecked(false);
|
m_widget->toolButtonMagicWaypointMapMode->setChecked(false);
|
||||||
m_widget->toolButtonNormalMapMode->setChecked(true);
|
m_widget->toolButtonNormalMapMode->setChecked(true);
|
||||||
|
m_widget->toolButtonHomeWaypoint->setEnabled(false);
|
||||||
m_widget->toolButtonCenterWaypoint->setEnabled(false);
|
m_widget->toolButtonCenterWaypoint->setEnabled(false);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -500,6 +508,14 @@ void OPMapGadgetWidget::contextMenuEvent(QContextMenuEvent *event)
|
|||||||
|
|
||||||
menu.addSeparator();
|
menu.addSeparator();
|
||||||
|
|
||||||
|
menu.addAction(showSafeAreaAct);
|
||||||
|
QMenu safeAreaSubMenu(tr("Safe Area") + " (" + QString::number(m_map->Home->SafeArea()) + "m)", this);
|
||||||
|
for (int i = 0; i < safeAreaAct.count(); i++)
|
||||||
|
safeAreaSubMenu.addAction(safeAreaAct.at(i));
|
||||||
|
menu.addMenu(&safeAreaSubMenu);
|
||||||
|
|
||||||
|
menu.addSeparator();
|
||||||
|
|
||||||
menu.addAction(showCompassAct);
|
menu.addAction(showCompassAct);
|
||||||
|
|
||||||
menu.addSeparator()->setText(tr("Zoom"));
|
menu.addSeparator()->setText(tr("Zoom"));
|
||||||
@ -1215,6 +1231,7 @@ void OPMapGadgetWidget::setMapMode(opMapModeType mode)
|
|||||||
m_widget->toolButtonMagicWaypointMapMode->setChecked(false);
|
m_widget->toolButtonMagicWaypointMapMode->setChecked(false);
|
||||||
m_widget->toolButtonNormalMapMode->setChecked(true);
|
m_widget->toolButtonNormalMapMode->setChecked(true);
|
||||||
|
|
||||||
|
m_widget->toolButtonHomeWaypoint->setEnabled(false);
|
||||||
m_widget->toolButtonCenterWaypoint->setEnabled(false);
|
m_widget->toolButtonCenterWaypoint->setEnabled(false);
|
||||||
|
|
||||||
// delete the magic waypoint from the map
|
// delete the magic waypoint from the map
|
||||||
@ -1251,6 +1268,7 @@ void OPMapGadgetWidget::setMapMode(opMapModeType mode)
|
|||||||
m_widget->toolButtonNormalMapMode->setChecked(false);
|
m_widget->toolButtonNormalMapMode->setChecked(false);
|
||||||
m_widget->toolButtonMagicWaypointMapMode->setChecked(true);
|
m_widget->toolButtonMagicWaypointMapMode->setChecked(true);
|
||||||
|
|
||||||
|
m_widget->toolButtonHomeWaypoint->setEnabled(true);
|
||||||
m_widget->toolButtonCenterWaypoint->setEnabled(true);
|
m_widget->toolButtonCenterWaypoint->setEnabled(true);
|
||||||
|
|
||||||
// delete the normal waypoints from the map
|
// delete the normal waypoints from the map
|
||||||
@ -1454,6 +1472,30 @@ void OPMapGadgetWidget::createActions()
|
|||||||
zoomAct.append(zoom_act);
|
zoomAct.append(zoom_act);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// *****
|
||||||
|
// safe area
|
||||||
|
|
||||||
|
showSafeAreaAct = new QAction(tr("Show Safe Area"), this);
|
||||||
|
showSafeAreaAct->setStatusTip(tr("Show/Hide the Safe Area around the home location"));
|
||||||
|
showSafeAreaAct->setCheckable(true);
|
||||||
|
showSafeAreaAct->setChecked(m_map->Home->ShowSafeArea());
|
||||||
|
connect(showSafeAreaAct, SIGNAL(toggled(bool)), this, SLOT(onShowSafeAreaAct_toggled(bool)));
|
||||||
|
|
||||||
|
safeAreaActGroup = new QActionGroup(this);
|
||||||
|
connect(safeAreaActGroup, SIGNAL(triggered(QAction *)), this, SLOT(onSafeAreaActGroup_triggered(QAction *)));
|
||||||
|
safeAreaAct.clear();
|
||||||
|
for (int i = 0; i < sizeof(safe_area_radius_list) / sizeof(safe_area_radius_list[0]); i++)
|
||||||
|
{
|
||||||
|
int safeArea = safe_area_radius_list[i];
|
||||||
|
QAction *safeArea_act = new QAction(QString::number(safeArea) + "m", safeAreaActGroup);
|
||||||
|
safeArea_act->setCheckable(true);
|
||||||
|
safeArea_act->setChecked(safeArea == m_map->Home->SafeArea());
|
||||||
|
safeArea_act->setData(safeArea);
|
||||||
|
safeAreaAct.append(safeArea_act);
|
||||||
|
}
|
||||||
|
|
||||||
|
// *****
|
||||||
|
|
||||||
// ***********************
|
// ***********************
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1813,6 +1855,26 @@ void OPMapGadgetWidget::onCenterMagicWaypointAct_triggered()
|
|||||||
centerMagicWaypoint();
|
centerMagicWaypoint();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void OPMapGadgetWidget::onShowSafeAreaAct_toggled(bool show)
|
||||||
|
{
|
||||||
|
if (!m_widget || !m_map)
|
||||||
|
return;
|
||||||
|
|
||||||
|
m_map->Home->SetShowSafeArea(show); // show the safe area
|
||||||
|
m_map->Home->RefreshPos();
|
||||||
|
}
|
||||||
|
|
||||||
|
void OPMapGadgetWidget::onSafeAreaActGroup_triggered(QAction *action)
|
||||||
|
{
|
||||||
|
if (!m_widget || !m_map)
|
||||||
|
return;
|
||||||
|
|
||||||
|
int radius = action->data().toInt();
|
||||||
|
|
||||||
|
m_map->Home->SetSafeArea(radius); // set the radius (meters)
|
||||||
|
m_map->Home->RefreshPos();
|
||||||
|
}
|
||||||
|
|
||||||
// *************************************************************************************
|
// *************************************************************************************
|
||||||
// move the magic waypoint to the home position
|
// move the magic waypoint to the home position
|
||||||
|
|
||||||
|
@ -211,6 +211,8 @@ private slots:
|
|||||||
void onZoomActGroup_triggered(QAction *action);
|
void onZoomActGroup_triggered(QAction *action);
|
||||||
void onHomeMagicWaypointAct_triggered();
|
void onHomeMagicWaypointAct_triggered();
|
||||||
void onCenterMagicWaypointAct_triggered();
|
void onCenterMagicWaypointAct_triggered();
|
||||||
|
void onShowSafeAreaAct_toggled(bool show);
|
||||||
|
void onSafeAreaActGroup_triggered(QAction *action);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
int min_zoom;
|
int min_zoom;
|
||||||
@ -291,6 +293,10 @@ private:
|
|||||||
QAction *homeMagicWaypointAct;
|
QAction *homeMagicWaypointAct;
|
||||||
QAction *centerMagicWaypointAct;
|
QAction *centerMagicWaypointAct;
|
||||||
|
|
||||||
|
QAction *showSafeAreaAct;
|
||||||
|
QActionGroup *safeAreaActGroup;
|
||||||
|
QList<QAction *> safeAreaAct;
|
||||||
|
|
||||||
QActionGroup *mapModeActGroup;
|
QActionGroup *mapModeActGroup;
|
||||||
QList<QAction *> mapModeAct;
|
QList<QAction *> mapModeAct;
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user