1
0
mirror of https://bitbucket.org/librepilot/librepilot.git synced 2025-01-17 02:52:12 +01:00

UAV overlay control added to the OPMap plug-in

git-svn-id: svn://svn.openpilot.org/OpenPilot/trunk@1085 ebee16cc-31ac-478f-84a7-5cbb03baadba
This commit is contained in:
pip 2010-07-13 15:45:40 +00:00 committed by pip
parent fbc627aeed
commit f56866c45b
7 changed files with 203 additions and 38 deletions

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.4 KiB

After

Width:  |  Height:  |  Size: 3.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.9 KiB

View File

@ -19,5 +19,7 @@
<file>images/waypoint_marker2.png</file>
<file>images/waypoint_marker1.png</file>
<file>images/uav_heading.png</file>
<file>images/uav_trail.png</file>
<file>images/uav_trail_clear.png</file>
</qresource>
</RCC>

View File

@ -6,8 +6,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>713</width>
<height>363</height>
<width>548</width>
<height>416</height>
</rect>
</property>
<property name="sizePolicy">
@ -874,6 +874,15 @@ border-radius: 3px;
<height>20</height>
</size>
</property>
<property name="autoRepeat">
<bool>true</bool>
</property>
<property name="autoRepeatDelay">
<number>500</number>
</property>
<property name="autoRepeatInterval">
<number>500</number>
</property>
<property name="autoRaise">
<bool>false</bool>
</property>
@ -955,6 +964,15 @@ border-radius: 3px;
<height>20</height>
</size>
</property>
<property name="autoRepeat">
<bool>true</bool>
</property>
<property name="autoRepeatDelay">
<number>500</number>
</property>
<property name="autoRepeatInterval">
<number>500</number>
</property>
<property name="autoRaise">
<bool>false</bool>
</property>
@ -998,7 +1016,7 @@ border-radius: 3px;
</size>
</property>
<property name="autoRepeat">
<bool>true</bool>
<bool>false</bool>
</property>
<property name="autoRaise">
<bool>false</bool>
@ -1030,7 +1048,7 @@ border-radius: 3px;
<bool>true</bool>
</property>
<property name="autoRepeat">
<bool>true</bool>
<bool>false</bool>
</property>
<property name="autoRaise">
<bool>false</bool>
@ -1062,8 +1080,72 @@ border-radius: 3px;
<bool>true</bool>
</property>
<property name="autoRepeat">
<bool>false</bool>
</property>
<property name="autoRaise">
<bool>false</bool>
</property>
</widget>
</item>
<item>
<widget class="QToolButton" name="toolButtonShowUAVtrail">
<property name="toolTip">
<string>Show/Hide the UAV trail</string>
</property>
<property name="styleSheet">
<string notr="true"/>
</property>
<property name="text">
<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>20</width>
<height>20</height>
</size>
</property>
<property name="checkable">
<bool>true</bool>
</property>
<property name="autoRepeat">
<bool>false</bool>
</property>
<property name="autoRaise">
<bool>false</bool>
</property>
</widget>
</item>
<item>
<widget class="QToolButton" name="toolButtonClearUAVtrail">
<property name="toolTip">
<string>Clear the UAV trail</string>
</property>
<property name="styleSheet">
<string notr="true"/>
</property>
<property name="text">
<string/>
</property>
<property name="icon">
<iconset resource="opmap.qrc">
<normaloff>:/opmap/images/uav_trail_clear.png</normaloff>:/opmap/images/uav_trail_clear.png</iconset>
</property>
<property name="iconSize">
<size>
<width>20</width>
<height>20</height>
</size>
</property>
<property name="checkable">
<bool>false</bool>
</property>
<property name="autoRepeat">
<bool>false</bool>
</property>
<property name="autoRaise">
<bool>false</bool>
</property>

View File

@ -92,6 +92,13 @@ OPMapGadgetWidget::OPMapGadgetWidget(QWidget *parent) : QWidget(parent)
m_map->SetMaxZoom(19);
m_map->SetMouseWheelZoomType(internals::MouseWheelZoomType::MousePositionWithoutCenter); // set how the mouse wheel zoom functions
m_map->SetFollowMouse(true); // we want a contiuous mouse position reading
m_map->SetShowUAV(true); // display the UAV position on the map
// m_map->UAV->SetTrailTime(1); // seconds
// m_map->UAV->SetTrailDistance(0.1); // kilometers
m_map->UAV->SetTrailType(UAVTrailType::ByTimeElapsed);
// m_map->UAV->SetTrailType(UAVTrailType::ByDistance);
// **************
@ -145,6 +152,8 @@ OPMapGadgetWidget::OPMapGadgetWidget(QWidget *parent) : QWidget(parent)
m_widget->progressBarMap->setMaximum(1);
m_widget->toolButtonShowUAVtrail->setChecked(true);
/*
#if defined(Q_OS_MAC)
#elif defined(Q_OS_WIN)
@ -419,8 +428,10 @@ void OPMapGadgetWidget::contextMenuEvent(QContextMenuEvent *event)
menu.addAction(goHomeAct);
menu.addAction(goUAVAct);
menu.addSeparator()->setText(tr("Follow"));
menu.addSeparator()->setText(tr("UAV"));
menu.addAction(showUAVAct);
menu.addAction(showUAVtrailAct);
menu.addAction(followUAVpositionAct);
menu.addAction(followUAVheadingAct);
@ -501,36 +512,26 @@ void OPMapGadgetWidget::keyPressEvent(QKeyEvent* event)
void OPMapGadgetWidget::updatePosition()
{
PositionActual::DataFields data = m_positionActual->getData(); // get current UAV data
internals::PointLatLng uav_pos = internals::PointLatLng(data.Latitude, data.Longitude); // current UAV position
double uav_heading = data.Heading; // current UAV heading
double uav_height_meters = data.Altitude; // current UAV height
double uav_ground_speed_meters_per_second = data.Groundspeed; // current UAV ground speed
float uav_heading = data.Heading; // current UAV heading
float uav_altitude_meters = data.Altitude; // current UAV height
float uav_ground_speed_meters_per_second = data.Groundspeed; // current UAV ground speed
// display the UAV lat/lon position
QString str = " lat: " + QString::number(uav_pos.Lat(), 'f', 7) +
" lon: " + QString::number(uav_pos.Lng(), 'f', 7) +
" " + QString::number(uav_heading, 'f', 1) + "deg" +
" " + QString::number(uav_height_meters, 'f', 1) + "m" +
" " + QString::number(uav_altitude_meters, 'f', 1) + "m" +
" " + QString::number(uav_ground_speed_meters_per_second, 'f', 1) + "m/s";
if (m_widget) m_widget->labelUAVPos->setText(str);
if (m_map && followUAVpositionAct && followUAVheadingAct)
if (m_map)
{
if (followUAVpositionAct->isChecked())
// if (m_map->ShowUAV())
{
internals::PointLatLng map_pos = m_map->CurrentPosition(); // current MAP position
double map_heading = m_map->Rotate();
if (map_pos != uav_pos || map_heading != uav_heading)
{
m_map->SetCurrentPosition(uav_pos); // keep the map centered on the UAV
if (followUAVheadingAct->isChecked())
m_map->SetRotate(-uav_heading); // rotate the map to match the uav heading
else
if (m_map->Rotate() != 0)
m_map->SetRotate(0); // reset the rotation to '0'
}
m_map->UAV->SetUAVPos(uav_pos, uav_altitude_meters); // set the maps UAV position
m_map->UAV->SetUAVHeading(uav_heading); // set the maps UAV heading
}
}
}
@ -713,6 +714,16 @@ void OPMapGadgetWidget::on_toolButtonMapUAVheading_clicked()
followUAVheadingAct->toggle();
}
void OPMapGadgetWidget::on_toolButtonShowUAVtrail_clicked()
{
showUAVtrailAct->toggle();
}
void OPMapGadgetWidget::on_toolButtonClearUAVtrail_clicked()
{
clearUAVtrailAct->trigger();
}
void OPMapGadgetWidget::on_horizontalSliderZoom_sliderMoved(int position)
{
setZoom(position);
@ -894,12 +905,18 @@ void OPMapGadgetWidget::createActions()
connect(findPlaceAct, SIGNAL(triggered()), this, SLOT(onFindPlaceAct_triggered()));
showCompassAct = new QAction(tr("Show compass"), this);
// showCompassAct->setShortcut(tr("Ctrl+M"));
showCompassAct->setStatusTip(tr("Show/Hide the map compass"));
showCompassAct->setStatusTip(tr("Show/Hide the compass"));
showCompassAct->setCheckable(true);
showCompassAct->setChecked(true);
connect(showCompassAct, SIGNAL(toggled(bool)), this, SLOT(onShowCompassAct_toggled(bool)));
showUAVAct = new QAction(tr("Show UAV"), this);
showUAVAct->setStatusTip(tr("Show/Hide the UAV"));
showUAVAct->setCheckable(true);
showUAVAct->setChecked(m_map->ShowUAV());
showUAVAct->setEnabled(false); // temporary
connect(showUAVAct, SIGNAL(toggled(bool)), this, SLOT(onShowUAVAct_toggled(bool)));
zoomInAct = new QAction(tr("Zoom &In"), this);
zoomInAct->setShortcut(Qt::Key_PageUp);
zoomInAct->setStatusTip(tr("Zoom the map in"));
@ -938,6 +955,16 @@ void OPMapGadgetWidget::createActions()
followUAVheadingAct->setChecked(false);
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->setShortcut(tr("Ctrl+W"));
wayPointEditorAct->setStatusTip(tr("Open the waypoint editor"));
@ -1035,10 +1062,16 @@ void OPMapGadgetWidget::onFindPlaceAct_triggered()
*/
}
void OPMapGadgetWidget::onShowCompassAct_toggled(bool show_compass)
void OPMapGadgetWidget::onShowCompassAct_toggled(bool show)
{
if (m_map)
m_map->SetShowCompass(show_compass);
m_map->SetShowCompass(show);
}
void OPMapGadgetWidget::onShowUAVAct_toggled(bool show)
{
if (m_map)
m_map->SetShowUAV(show); // this can cause a rather big crash
}
void OPMapGadgetWidget::onGoZoomInAct_triggered()
@ -1093,11 +1126,7 @@ void OPMapGadgetWidget::onFollowUAVpositionAct_toggled(bool checked)
if (m_widget->toolButtonMapUAV->isChecked() != checked)
m_widget->toolButtonMapUAV->setChecked(checked);
if (m_map)
{
// m_map->SetCanDragMap(!checked); // allow/disallow manual map dragging
if (!checked) m_map->SetRotate(0); // reset map rotation to 0deg
}
setMapFollowingmode();
}
}
@ -1108,13 +1137,28 @@ void OPMapGadgetWidget::onFollowUAVheadingAct_toggled(bool checked)
if (m_widget->toolButtonMapUAVheading->isChecked() != checked)
m_widget->toolButtonMapUAVheading->setChecked(checked);
if (m_map)
{
if (!checked) m_map->SetRotate(0); // reset map rotation to 0deg
}
setMapFollowingmode();
}
}
void OPMapGadgetWidget::onShowUAVtrailAct_toggled(bool checked)
{
if (m_widget)
{
if (m_widget->toolButtonShowUAVtrail->isChecked() != checked)
m_widget->toolButtonShowUAVtrail->setChecked(checked);
if (m_map)
m_map->UAV->SetShowTrail(checked);
}
}
void OPMapGadgetWidget::onClearUAVtrailAct_triggered()
{
if (m_map)
m_map->UAV->DeleteTrail();
}
void OPMapGadgetWidget::onOpenWayPointEditorAct_triggered()
{
waypoint_editor_dialog.show();
@ -1242,3 +1286,30 @@ void OPMapGadgetWidget::saveComboBoxLines(QComboBox *comboBox, QString filename)
}
// *************************************************************************************
void OPMapGadgetWidget::setMapFollowingmode()
{
if (!m_map) return;
if (!followUAVpositionAct->isChecked())
{
m_map->UAV->SetMapFollowType(UAVMapFollowType::None);
m_map->SetRotate(0); // reset map rotation to 0deg
}
else
if (!followUAVheadingAct->isChecked())
{
m_map->UAV->SetMapFollowType(UAVMapFollowType::CenterMap);
m_map->SetRotate(0); // reset map rotation to 0deg
}
else
{
m_map->UAV->SetMapFollowType(UAVMapFollowType::CenterMap); // the map library won't let you reset the uav rotation if it's already in rotate mode
// if (m_map->ShowUAV())
m_map->UAV->SetUAVHeading(0); // reset the UAV heading to 0deg
m_map->UAV->SetMapFollowType(UAVMapFollowType::CenterAndRotateMap);
}
}
// *************************************************************************************

View File

@ -116,6 +116,8 @@ private slots:
void on_toolButtonMapHome_clicked();
void on_toolButtonMapUAV_clicked();
void on_toolButtonMapUAVheading_clicked();
void on_toolButtonShowUAVtrail_clicked();
void on_toolButtonClearUAVtrail_clicked();
void on_horizontalSliderZoom_sliderMoved(int position);
void on_toolButtonAddWaypoint_clicked();
void on_treeViewWaypoints_clicked(QModelIndex index);
@ -154,7 +156,8 @@ private slots:
void onCopyMouseLatToClipAct_triggered();
void onCopyMouseLonToClipAct_triggered();
void onFindPlaceAct_triggered();
void onShowCompassAct_toggled(bool show_compass);
void onShowCompassAct_toggled(bool show);
void onShowUAVAct_toggled(bool show);
void onGoZoomInAct_triggered();
void onGoZoomOutAct_triggered();
void onGoMouseClickAct_triggered();
@ -162,6 +165,8 @@ private slots:
void onGoUAVAct_triggered();
void onFollowUAVpositionAct_toggled(bool checked);
void onFollowUAVheadingAct_toggled(bool checked);
void onShowUAVtrailAct_toggled(bool checked);
void onClearUAVtrailAct_triggered();
void onOpenWayPointEditorAct_triggered();
void onAddWayPointAct_triggered();
void onEditWayPointAct_triggered();
@ -218,6 +223,7 @@ private:
QAction *copyMouseLonToClipAct;
QAction *findPlaceAct;
QAction *showCompassAct;
QAction *showUAVAct;
QAction *zoomInAct;
QAction *zoomOutAct;
QAction *goMouseClickAct;
@ -225,6 +231,8 @@ private:
QAction *goUAVAct;
QAction *followUAVpositionAct;
QAction *followUAVheadingAct;
QAction *showUAVtrailAct;
QAction *clearUAVtrailAct;
QAction *wayPointEditorAct;
QAction *addWayPointAct;
QAction *editWayPointAct;
@ -237,6 +245,8 @@ private:
void loadComboBoxLines(QComboBox *comboBox, QString filename);
void saveComboBoxLines(QComboBox *comboBox, QString filename);
void setMapFollowingmode();
};
#endif /* OPMAP_GADGETWIDGET_H_ */