1
0
mirror of https://bitbucket.org/librepilot/librepilot.git synced 2024-11-30 08:24:11 +01:00

Added UAV trail settings onto the right-click context menu on the map.

git-svn-id: svn://svn.openpilot.org/OpenPilot/trunk@1927 ebee16cc-31ac-478f-84a7-5cbb03baadba
This commit is contained in:
pip 2010-10-09 12:29:30 +00:00 committed by pip
parent 34dffe73de
commit 676166f045
3 changed files with 120 additions and 79 deletions

View File

@ -553,44 +553,6 @@ border-radius: 2px;
</property> </property>
</widget> </widget>
</item> </item>
<item>
<widget class="QToolButton" name="toolButtonShowUAVtrail">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="toolTip">
<string>Show/Hide the UAV trail</string>
</property>
<property name="text">
<string>Trail</string>
</property>
<property name="icon">
<iconset resource="opmap.qrc">
<normaloff>:/opmap/images/uav_trail.png</normaloff>:/opmap/images/uav_trail.png</iconset>
</property>
<property name="iconSize">
<size>
<width>28</width>
<height>28</height>
</size>
</property>
<property name="checkable">
<bool>true</bool>
</property>
<property name="autoRepeat">
<bool>false</bool>
</property>
<property name="toolButtonStyle">
<enum>Qt::ToolButtonIconOnly</enum>
</property>
<property name="autoRaise">
<bool>false</bool>
</property>
</widget>
</item>
</layout> </layout>
</item> </item>
</layout> </layout>

View File

@ -40,7 +40,11 @@
#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}; const int safe_area_radius_list[] = {5, 10, 20, 50, 100, 200, 500, 1000, 2000, 5000}; // meters
const int uav_trail_time_list[] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10}; // seconds
const int uav_trail_distance_list[] = {1, 2, 5, 10, 20, 50, 100, 200, 500}; // meters
// ************************************************************************************* // *************************************************************************************
@ -131,14 +135,14 @@ 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->SetSafeArea(safe_area_radius_list[3]); // set radius (meters)
m_map->Home->SetShowSafeArea(true); // show the safe area m_map->Home->SetShowSafeArea(true); // show the safe area
m_map->UAV->SetTrailTime(0.5); // seconds m_map->UAV->SetTrailTime(uav_trail_time_list[0]); // seconds
m_map->UAV->SetTrailDistance(0.01); // kilometers m_map->UAV->SetTrailDistance(uav_trail_distance_list[1]); // meters
// m_map->UAV->SetTrailType(UAVTrailType::ByTimeElapsed); m_map->UAV->SetTrailType(UAVTrailType::ByTimeElapsed);
m_map->UAV->SetTrailType(UAVTrailType::ByDistance); // m_map->UAV->SetTrailType(UAVTrailType::ByDistance);
// ************** // **************
@ -218,8 +222,6 @@ OPMapGadgetWidget::OPMapGadgetWidget(QWidget *parent) : QWidget(parent)
m_widget->progressBarMap->setMaximum(1); m_widget->progressBarMap->setMaximum(1);
m_widget->toolButtonShowUAVtrail->setChecked(true);
/* /*
#if defined(Q_OS_MAC) #if defined(Q_OS_MAC)
#elif defined(Q_OS_WIN) #elif defined(Q_OS_WIN)
@ -540,16 +542,37 @@ void OPMapGadgetWidget::contextMenuEvent(QContextMenuEvent *event)
menu.addAction(showHomeAct); menu.addAction(showHomeAct);
menu.addAction(goHomeAct); menu.addAction(goHomeAct);
// ****
// uav trails
menu.addSeparator()->setText(tr("UAV Trail"));
QMenu uavTrailTypeSubMenu(tr("UAV trail type") + " (" + mapcontrol::Helper::StrFromUAVTrailType(m_map->UAV->GetTrailType()) + ")", this);
for (int i = 0; i < uavTrailTypeAct.count(); i++)
uavTrailTypeSubMenu.addAction(uavTrailTypeAct.at(i));
menu.addMenu(&uavTrailTypeSubMenu);
QMenu uavTrailTimeSubMenu(tr("UAV trail time") + " (" + QString::number(m_map->UAV->TrailTime()) + " sec)", this);
for (int i = 0; i < uavTrailTimeAct.count(); i++)
uavTrailTimeSubMenu.addAction(uavTrailTimeAct.at(i));
menu.addMenu(&uavTrailTimeSubMenu);
QMenu uavTrailDistanceSubMenu(tr("UAV trail distance") + " (" + QString::number(m_map->UAV->TrailDistance()) + " meters)", this);
for (int i = 0; i < uavTrailDistanceAct.count(); i++)
uavTrailDistanceSubMenu.addAction(uavTrailDistanceAct.at(i));
menu.addMenu(&uavTrailDistanceSubMenu);
menu.addAction(clearUAVtrailAct);
// ****
menu.addSeparator()->setText(tr("UAV")); menu.addSeparator()->setText(tr("UAV"));
menu.addAction(showUAVAct); menu.addAction(showUAVAct);
menu.addAction(showUAVtrailAct);
menu.addAction(followUAVpositionAct); menu.addAction(followUAVpositionAct);
menu.addAction(followUAVheadingAct); menu.addAction(followUAVheadingAct);
menu.addAction(goUAVAct); menu.addAction(goUAVAct);
menu.addAction(clearUAVtrailAct);
// ********* // *********
switch (m_map_mode) switch (m_map_mode)
@ -913,16 +936,6 @@ void OPMapGadgetWidget::on_toolButtonMapUAVheading_clicked()
followUAVheadingAct->toggle(); followUAVheadingAct->toggle();
} }
void OPMapGadgetWidget::on_toolButtonShowUAVtrail_clicked()
{
if (!m_widget || !m_map)
return;
// QMutexLocker locker(&m_map_mutex);
showUAVtrailAct->toggle();
}
void OPMapGadgetWidget::on_horizontalSliderZoom_sliderMoved(int position) void OPMapGadgetWidget::on_horizontalSliderZoom_sliderMoved(int position)
{ {
if (!m_widget || !m_map) if (!m_widget || !m_map)
@ -1390,16 +1403,6 @@ 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)));
showUAVtrailAct = new QAction(tr("Show UAV trail"), this);
showUAVtrailAct->setStatusTip(tr("Show/Hide the UAV trail"));
showUAVtrailAct->setCheckable(true);
showUAVtrailAct->setChecked(true);
connect(showUAVtrailAct, SIGNAL(toggled(bool)), this, SLOT(onShowUAVtrailAct_toggled(bool)));
clearUAVtrailAct = new QAction(tr("Clear UAV trail"), this);
clearUAVtrailAct->setStatusTip(tr("Clear the UAV trail"));
connect(clearUAVtrailAct, SIGNAL(triggered()), this, SLOT(onClearUAVtrailAct_triggered()));
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"));
@ -1492,6 +1495,53 @@ void OPMapGadgetWidget::createActions()
safeAreaAct.append(safeArea_act); safeAreaAct.append(safeArea_act);
} }
// *****
// UAV trail
uavTrailTypeActGroup = new QActionGroup(this);
connect(uavTrailTypeActGroup, SIGNAL(triggered(QAction *)), this, SLOT(onUAVTrailTypeActGroup_triggered(QAction *)));
uavTrailTypeAct.clear();
QStringList uav_trail_type_list = mapcontrol::Helper::UAVTrailTypes();
for (int i = 0; i < uav_trail_type_list.count(); i++)
{
mapcontrol::UAVTrailType::Types uav_trail_type = mapcontrol::Helper::UAVTrailTypeFromString(uav_trail_type_list[i]);
QAction *uavTrailType_act = new QAction(mapcontrol::Helper::StrFromUAVTrailType(uav_trail_type), uavTrailTypeActGroup);
uavTrailType_act->setCheckable(true);
uavTrailType_act->setChecked(uav_trail_type == m_map->UAV->GetTrailType());
uavTrailType_act->setData(i);
uavTrailTypeAct.append(uavTrailType_act);
}
clearUAVtrailAct = new QAction(tr("Clear UAV trail"), this);
clearUAVtrailAct->setStatusTip(tr("Clear the UAV trail"));
connect(clearUAVtrailAct, SIGNAL(triggered()), this, SLOT(onClearUAVtrailAct_triggered()));
uavTrailTimeActGroup = new QActionGroup(this);
connect(uavTrailTimeActGroup, SIGNAL(triggered(QAction *)), this, SLOT(onUAVTrailTimeActGroup_triggered(QAction *)));
uavTrailTimeAct.clear();
for (int i = 0; i < sizeof(uav_trail_time_list) / sizeof(uav_trail_time_list[0]); i++)
{
int uav_trail_time = uav_trail_time_list[i];
QAction *uavTrailTime_act = new QAction(QString::number(uav_trail_time) + " sec", uavTrailTimeActGroup);
uavTrailTime_act->setCheckable(true);
uavTrailTime_act->setChecked(uav_trail_time == m_map->UAV->TrailTime());
uavTrailTime_act->setData(uav_trail_time);
uavTrailTimeAct.append(uavTrailTime_act);
}
uavTrailDistanceActGroup = new QActionGroup(this);
connect(uavTrailDistanceActGroup, SIGNAL(triggered(QAction *)), this, SLOT(onUAVTrailDistanceActGroup_triggered(QAction *)));
uavTrailDistanceAct.clear();
for (int i = 0; i < sizeof(uav_trail_distance_list) / sizeof(uav_trail_distance_list[0]); i++)
{
int uav_trail_distance = uav_trail_distance_list[i];
QAction *uavTrailDistance_act = new QAction(QString::number(uav_trail_distance) + " meters", uavTrailDistanceActGroup);
uavTrailDistance_act->setCheckable(true);
uavTrailDistance_act->setChecked(uav_trail_distance == m_map->UAV->TrailDistance());
uavTrailDistance_act->setData(uav_trail_distance);
uavTrailDistanceAct.append(uavTrailDistance_act);
}
// ***** // *****
// *********************** // ***********************
@ -1663,15 +1713,17 @@ void OPMapGadgetWidget::onFollowUAVheadingAct_toggled(bool checked)
setMapFollowingMode(); setMapFollowingMode();
} }
void OPMapGadgetWidget::onShowUAVtrailAct_toggled(bool checked) void OPMapGadgetWidget::onUAVTrailTypeActGroup_triggered(QAction *action)
{ {
if (!m_widget || !m_map) if (!m_widget || !m_map)
return; return;
if (m_widget->toolButtonShowUAVtrail->isChecked() != checked) int trail_type_idx = action->data().toInt();
m_widget->toolButtonShowUAVtrail->setChecked(checked);
m_map->UAV->SetShowTrail(checked); QStringList uav_trail_type_list = mapcontrol::Helper::UAVTrailTypes();
mapcontrol::UAVTrailType::Types uav_trail_type = mapcontrol::Helper::UAVTrailTypeFromString(uav_trail_type_list[trail_type_idx]);
m_map->UAV->SetTrailType(uav_trail_type);
} }
void OPMapGadgetWidget::onClearUAVtrailAct_triggered() void OPMapGadgetWidget::onClearUAVtrailAct_triggered()
@ -1682,6 +1734,26 @@ void OPMapGadgetWidget::onClearUAVtrailAct_triggered()
m_map->UAV->DeleteTrail(); m_map->UAV->DeleteTrail();
} }
void OPMapGadgetWidget::onUAVTrailTimeActGroup_triggered(QAction *action)
{
if (!m_widget || !m_map)
return;
int trail_time = (double)action->data().toInt();
m_map->UAV->SetTrailTime(trail_time);
}
void OPMapGadgetWidget::onUAVTrailDistanceActGroup_triggered(QAction *action)
{
if (!m_widget || !m_map)
return;
int trail_distance = action->data().toInt();
m_map->UAV->SetTrailDistance(trail_distance);
}
void OPMapGadgetWidget::onOpenWayPointEditorAct_triggered() void OPMapGadgetWidget::onOpenWayPointEditorAct_triggered()
{ {
if (!m_widget || !m_map) if (!m_widget || !m_map)

View File

@ -145,7 +145,6 @@ private slots:
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_toolButtonShowUAVtrail_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);
@ -199,8 +198,6 @@ 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 onShowUAVtrailAct_toggled(bool checked);
void onClearUAVtrailAct_triggered();
void onOpenWayPointEditorAct_triggered(); void onOpenWayPointEditorAct_triggered();
void onAddWayPointAct_triggered(); void onAddWayPointAct_triggered();
void onEditWayPointAct_triggered(); void onEditWayPointAct_triggered();
@ -213,6 +210,10 @@ private slots:
void onCenterMagicWaypointAct_triggered(); void onCenterMagicWaypointAct_triggered();
void onShowSafeAreaAct_toggled(bool show); void onShowSafeAreaAct_toggled(bool show);
void onSafeAreaActGroup_triggered(QAction *action); void onSafeAreaActGroup_triggered(QAction *action);
void onUAVTrailTypeActGroup_triggered(QAction *action);
void onClearUAVtrailAct_triggered();
void onUAVTrailTimeActGroup_triggered(QAction *action);
void onUAVTrailDistanceActGroup_triggered(QAction *action);
private: private:
int min_zoom; int min_zoom;
@ -283,8 +284,6 @@ private:
QAction *goUAVAct; QAction *goUAVAct;
QAction *followUAVpositionAct; QAction *followUAVpositionAct;
QAction *followUAVheadingAct; QAction *followUAVheadingAct;
QAction *showUAVtrailAct;
QAction *clearUAVtrailAct;
QAction *wayPointEditorAct; QAction *wayPointEditorAct;
QAction *addWayPointAct; QAction *addWayPointAct;
QAction *editWayPointAct; QAction *editWayPointAct;
@ -298,6 +297,14 @@ private:
QActionGroup *safeAreaActGroup; QActionGroup *safeAreaActGroup;
QList<QAction *> safeAreaAct; QList<QAction *> safeAreaAct;
QActionGroup *uavTrailTypeActGroup;
QList<QAction *> uavTrailTypeAct;
QAction *clearUAVtrailAct;
QActionGroup *uavTrailTimeActGroup;
QList<QAction *> uavTrailTimeAct;
QActionGroup *uavTrailDistanceActGroup;
QList<QAction *> uavTrailDistanceAct;
QActionGroup *mapModeActGroup; QActionGroup *mapModeActGroup;
QList<QAction *> mapModeAct; QList<QAction *> mapModeAct;