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

Removed center maguc waypoint to map

git-svn-id: svn://svn.openpilot.org/OpenPilot/trunk@1935 ebee16cc-31ac-478f-84a7-5cbb03baadba
This commit is contained in:
pip 2010-10-10 07:42:41 +00:00 committed by pip
parent 3a2fe4587d
commit d11e9c56e5
3 changed files with 37 additions and 65 deletions

View File

@ -432,32 +432,6 @@ border-radius: 2px;
</property>
</widget>
</item>
<item>
<widget class="QToolButton" name="toolButtonCenterWaypoint">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="toolTip">
<string>Move the magic waypoint to center of map</string>
</property>
<property name="text">
<string>Center WP</string>
</property>
<property name="icon">
<iconset resource="opmap.qrc">
<normaloff>:/opmap/images/center_wp.png</normaloff>:/opmap/images/center_wp.png</iconset>
</property>
<property name="iconSize">
<size>
<width>28</width>
<height>28</height>
</size>
</property>
</widget>
</item>
<item>
<widget class="Line" name="line_8">
<property name="frameShadow">

View File

@ -609,7 +609,6 @@ void OPMapGadgetWidget::contextMenuEvent(QContextMenuEvent *event)
case MagicWaypoint_MapMode:
menu.addSeparator()->setText(tr("Waypoints"));
menu.addAction(homeMagicWaypointAct);
menu.addAction(centerMagicWaypointAct);
break;
}
@ -1111,11 +1110,6 @@ void OPMapGadgetWidget::on_toolButtonHomeWaypoint_clicked()
homeMagicWaypoint();
}
void OPMapGadgetWidget::on_toolButtonCenterWaypoint_clicked()
{
centerMagicWaypoint();
}
void OPMapGadgetWidget::on_toolButtonMoveToWP_clicked()
{
moveToMagicWaypointPosition();
@ -1141,6 +1135,9 @@ void OPMapGadgetWidget::setHome(internals::PointLatLng pos_lat_lon)
m_map->Home->SetCoord(home_position.coord);
m_map->Home->RefreshPos();
// move the magic waypoint to keep it within the safe area boundry
keepMagicWaypointWithInSafeArea();
}
void OPMapGadgetWidget::goHome()
@ -1493,10 +1490,6 @@ void OPMapGadgetWidget::createActions()
homeMagicWaypointAct->setStatusTip(tr("Move the magic waypoint to the home position"));
connect(homeMagicWaypointAct, SIGNAL(triggered()), this, SLOT(onHomeMagicWaypointAct_triggered()));
centerMagicWaypointAct = new QAction(tr("Center magic waypoint"), this);
centerMagicWaypointAct->setStatusTip(tr("Move the magic waypoint to the center of the map"));
connect(centerMagicWaypointAct, SIGNAL(triggered()), this, SLOT(onCenterMagicWaypointAct_triggered()));
mapModeActGroup = new QActionGroup(this);
connect(mapModeActGroup, SIGNAL(triggered(QAction *)), this, SLOT(onMapModeActGroup_triggered(QAction *)));
mapModeAct.clear();
@ -1975,12 +1968,6 @@ void OPMapGadgetWidget::onHomeMagicWaypointAct_triggered()
homeMagicWaypoint();
}
void OPMapGadgetWidget::onCenterMagicWaypointAct_triggered()
{
// center the magic waypoint on the map
centerMagicWaypoint();
}
void OPMapGadgetWidget::onShowSafeAreaAct_toggled(bool show)
{
if (!m_widget || !m_map)
@ -1999,6 +1986,9 @@ void OPMapGadgetWidget::onSafeAreaActGroup_triggered(QAction *action)
m_map->Home->SetSafeArea(radius); // set the radius (meters)
m_map->Home->RefreshPos();
// move the magic waypoint if need be to keep it within the safe area around the home position
keepMagicWaypointWithInSafeArea();
}
// *************************************************************************************
@ -2018,23 +2008,6 @@ void OPMapGadgetWidget::homeMagicWaypoint()
magic_waypoint.map_wp_item->SetCoord(magic_waypoint.coord);
}
// *************************************************************************************
// move the magic waypoint to the center of the map
void OPMapGadgetWidget::centerMagicWaypoint()
{
if (!m_widget || !m_map)
return;
if (m_map_mode != MagicWaypoint_MapMode)
return;
magic_waypoint.coord = m_map->CurrentPosition();
if (magic_waypoint.map_wp_item)
magic_waypoint.map_wp_item->SetCoord(magic_waypoint.coord);
}
// *************************************************************************************
// move the UAV to the magic waypoint position
@ -2108,7 +2081,6 @@ void OPMapGadgetWidget::hideMagicWaypointControls()
{
m_widget->lineWaypoint->setVisible(false);
m_widget->toolButtonHomeWaypoint->setVisible(false);
m_widget->toolButtonCenterWaypoint->setVisible(false);
m_widget->toolButtonMoveToWP->setVisible(false);
}
@ -2116,10 +2088,38 @@ void OPMapGadgetWidget::showMagicWaypointControls()
{
m_widget->lineWaypoint->setVisible(true);
m_widget->toolButtonHomeWaypoint->setVisible(true);
m_widget->toolButtonCenterWaypoint->setVisible(true);
m_widget->toolButtonMoveToWP->setVisible(true);
}
// *************************************************************************************
// move the magic waypoint to keep it within the safe area boundry
void OPMapGadgetWidget::keepMagicWaypointWithInSafeArea()
{
// calcute the bearing and distance from the home position to the magic waypoint
double dist = distance(home_position.coord, magic_waypoint.coord);
double bear = bearing(home_position.coord, magic_waypoint.coord);
// get the maximum safe distance - in kilometers
double boundry_dist = (double)m_map->Home->SafeArea() / 1000;
// if (dist <= boundry_dist)
// return; // the magic waypoint is still within the safe area, don't move it
if (dist > boundry_dist) dist = boundry_dist;
// move the magic waypoint
magic_waypoint.coord = destPoint(home_position.coord, bear, dist);
if (m_map_mode == MagicWaypoint_MapMode)
{ // move the on-screen waypoint
if (magic_waypoint.map_wp_item)
magic_waypoint.map_wp_item->SetCoord(magic_waypoint.coord);
}
}
// *************************************************************************************
// return the distance between two points .. in kilometers

View File

@ -156,7 +156,6 @@ private slots:
void on_toolButtonMagicWaypointMapMode_clicked();
void on_toolButtonNormalMapMode_clicked();
void on_toolButtonHomeWaypoint_clicked();
void on_toolButtonCenterWaypoint_clicked();
void on_toolButtonMoveToWP_clicked();
/**
@ -208,7 +207,6 @@ private slots:
void onMapModeActGroup_triggered(QAction *action);
void onZoomActGroup_triggered(QAction *action);
void onHomeMagicWaypointAct_triggered();
void onCenterMagicWaypointAct_triggered();
void onShowSafeAreaAct_toggled(bool show);
void onSafeAreaActGroup_triggered(QAction *action);
void onUAVTrailTypeActGroup_triggered(QAction *action);
@ -293,7 +291,6 @@ private:
QAction *deleteWayPointAct;
QAction *clearWayPointsAct;
QAction *homeMagicWaypointAct;
QAction *centerMagicWaypointAct;
QAction *showSafeAreaAct;
QActionGroup *safeAreaActGroup;
@ -314,7 +311,6 @@ private:
QList<QAction *> zoomAct;
void homeMagicWaypoint();
void centerMagicWaypoint();
void moveToMagicWaypointPosition();
@ -324,6 +320,8 @@ private:
void hideMagicWaypointControls();
void showMagicWaypointControls();
void keepMagicWaypointWithInSafeArea();
double distance(internals::PointLatLng from, internals::PointLatLng to);
double bearing(internals::PointLatLng from, internals::PointLatLng to);
internals::PointLatLng destPoint(internals::PointLatLng source, double bear, double dist);