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

LP-572 Add buttons to the right: Save, clear trail, PathPlan editor, Home set

This commit is contained in:
Laurent Lalanne 2018-01-21 21:01:50 +01:00
parent 40f669b232
commit 1fd91caa29
5 changed files with 315 additions and 8 deletions

View File

@ -6,8 +6,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>514</width>
<height>412</height>
<width>671</width>
<height>488</height>
</rect>
</property>
<property name="sizePolicy">
@ -29,7 +29,16 @@
<property name="spacing">
<number>0</number>
</property>
<property name="margin">
<property name="leftMargin">
<number>0</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
<item>
@ -242,7 +251,16 @@ border-radius: 2px;
<property name="spacing">
<number>0</number>
</property>
<property name="margin">
<property name="leftMargin">
<number>0</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
<item>
@ -531,7 +549,7 @@ border-radius: 2px;
</property>
<property name="icon">
<iconset resource="opmap.qrc">
<normaloff>:/opmap/images/uav.png</normaloff>:/opmap/images/button_uav.png</iconset>
<normaloff>:/opmap/images/button_uav.png</normaloff>:/opmap/images/button_uav.png</iconset>
</property>
<property name="iconSize">
<size>
@ -569,7 +587,7 @@ border-radius: 2px;
</property>
<property name="icon">
<iconset resource="opmap.qrc">
<normaloff>:/opmap/images/uav_heading.png</normaloff>:/opmap/images/button_uav_heading.png</iconset>
<normaloff>:/opmap/images/button_uav_heading.png</normaloff>:/opmap/images/button_uav_heading.png</iconset>
</property>
<property name="iconSize">
<size>
@ -775,7 +793,16 @@ border-radius: 3px;
<property name="spacing">
<number>0</number>
</property>
<property name="margin">
<property name="leftMargin">
<number>0</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
<item>
@ -876,7 +903,16 @@ border-radius: 3px;
<property name="spacing">
<number>5</number>
</property>
<property name="margin">
<property name="leftMargin">
<number>1</number>
</property>
<property name="topMargin">
<number>1</number>
</property>
<property name="rightMargin">
<number>1</number>
</property>
<property name="bottomMargin">
<number>1</number>
</property>
<item>
@ -1020,6 +1056,152 @@ border-radius: 3px;
</property>
</widget>
</item>
<item>
<widget class="Line" name="line_7">
<property name="frameShadow">
<enum>QFrame::Plain</enum>
</property>
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
</widget>
</item>
<item>
<widget class="QToolButton" name="toolButtonHomeSet">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="toolTip">
<string>Set HomeLocation to be used by the
autopilot or just pick the first GPS fix.</string>
</property>
<property name="text">
<string>Home Set</string>
</property>
<property name="icon">
<iconset resource="opmap.qrc">
<normaloff>:/opmap/images/button_home_not_set.png</normaloff>
<normalon>:/opmap/images/button_home_set.png</normalon>:/opmap/images/button_home_not_set.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>
<item>
<widget class="QToolButton" name="toolButtonClearUAVTrail">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="toolTip">
<string>Clear UAV trail</string>
</property>
<property name="text">
<string>Clear UAV trail</string>
</property>
<property name="icon">
<iconset resource="opmap.qrc">
<normaloff>:/opmap/images/button_clear_uavtrail.png</normaloff>:/opmap/images/button_clear_uavtrail.png</iconset>
</property>
<property name="iconSize">
<size>
<width>28</width>
<height>28</height>
</size>
</property>
<property name="checkable">
<bool>false</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>
<item>
<widget class="Line" name="line_9">
<property name="frameShadow">
<enum>QFrame::Plain</enum>
</property>
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
</widget>
</item>
<item>
<widget class="QToolButton" name="toolButtonPlanEditor">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="toolTip">
<string>Edit PathPlan</string>
</property>
<property name="text">
<string>Edit plan</string>
</property>
<property name="icon">
<iconset resource="opmap.qrc">
<normaloff>:/opmap/images/button_edit_plan.png</normaloff>:/opmap/images/button_edit_plan.png</iconset>
</property>
<property name="iconSize">
<size>
<width>28</width>
<height>28</height>
</size>
</property>
<property name="checkable">
<bool>false</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>
<item>
<widget class="Line" name="line_10">
<property name="frameShadow">
<enum>QFrame::Plain</enum>
</property>
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
</widget>
</item>
<item>
<spacer name="verticalSpacer_2">
<property name="orientation">
@ -1036,6 +1218,54 @@ border-radius: 3px;
</property>
</spacer>
</item>
<item>
<widget class="Line" name="line_11">
<property name="frameShadow">
<enum>QFrame::Plain</enum>
</property>
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
</widget>
</item>
<item>
<widget class="QToolButton" name="toolButtonSaveSettings">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="toolTip">
<string>Save current map settings</string>
</property>
<property name="text">
<string>Save settings</string>
</property>
<property name="icon">
<iconset resource="opmap.qrc">
<normaloff>:/opmap/images/button_save.png</normaloff>:/opmap/images/button_save.png</iconset>
</property>
<property name="iconSize">
<size>
<width>28</width>
<height>28</height>
</size>
</property>
<property name="checkable">
<bool>false</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>
</widget>
</item>

View File

@ -32,6 +32,7 @@ OPMapGadget::OPMapGadget(QString classId, OPMapGadgetWidget *widget, QWidget *pa
m_widget(widget), m_config(NULL)
{
connect(m_widget, SIGNAL(defaultLocationAndZoomChanged(double, double, double)), this, SLOT(saveDefaultLocation(double, double, double)));
connect(m_widget, SIGNAL(defaultSafeAreaChanged(int, bool)), this, SLOT(saveDefaultSafeArea(int, bool)));
connect(m_widget, SIGNAL(overlayOpacityChanged(qreal)), this, SLOT(saveOpacity(qreal)));
}
@ -48,6 +49,14 @@ void OPMapGadget::saveDefaultLocation(double lng, double lat, double zoom)
m_config->save();
}
}
void OPMapGadget::saveDefaultSafeArea(int safe_area_radius, bool showSafeArea)
{
if (m_config) {
m_config->setSafeAreaRadius(safe_area_radius);
m_config->setShowSafeArea(showSafeArea);
m_config->save();
}
}
void OPMapGadget::saveOpacity(qreal value)
{

View File

@ -56,6 +56,7 @@ private:
private slots:
void saveOpacity(qreal value);
void saveDefaultLocation(double lng, double lat, double zoom);
void saveDefaultSafeArea(int safe_area_radius, bool showSafeArea);
};

View File

@ -216,6 +216,7 @@ OPMapGadgetWidget::OPMapGadgetWidget(QWidget *parent) : QWidget(parent)
connect(m_map, SIGNAL(OnWayPointDoubleClicked(WayPointItem *)), this, SLOT(wpDoubleClickEvent(WayPointItem *)));
m_map->SetCurrentPosition(m_home_position.coord); // set the map position
m_map->Home->SetCoord(m_home_position.coord); // set the HOME position
m_map->Home->RefreshPos();
m_map->Nav->SetCoord(m_home_position.coord); // set the NAV position
m_map->UAV->SetUAVPos(m_home_position.coord, 0.0); // set the UAV position
m_map->UAV->update();
@ -885,6 +886,65 @@ void OPMapGadgetWidget::on_horizontalSliderZoom_sliderMoved(int position)
setZoom(position);
}
void OPMapGadgetWidget::on_toolButtonHomeSet_clicked()
{
if (!m_widget || !m_map) {
return;
}
double LLA[3];
bool checked = m_widget->toolButtonHomeSet->isChecked();
if (!m_telemetry_connected) {
m_widget->toolButtonHomeSet->setChecked(false);
checked = false;
// Default map center from default settings
LLA[0] = m_home_position.coord.Lat();
LLA[1] = m_home_position.coord.Lng();
LLA[2] = m_home_position.altitude;
} else {
bool set;
if (obum->getHomeLocation(set, LLA) < 0) {
return; // error
}
}
obum->setHomeLocation(LLA, checked);
}
void OPMapGadgetWidget::on_toolButtonClearUAVTrail_clicked()
{
if (!m_widget || !m_map) {
return;
}
m_map->UAV->DeleteTrail();
if (m_map->GPS) {
m_map->GPS->DeleteTrail();
}
}
void OPMapGadgetWidget::on_toolButtonPlanEditor_clicked()
{
if (!m_widget || !m_map) {
return;
}
// open dialog
table->show();
// bring dialog to the front in case it was already open and hidden away
table->raise();
}
void OPMapGadgetWidget::on_toolButtonSaveSettings_clicked()
{
if (!m_widget || !m_map) {
return;
}
emit defaultLocationAndZoomChanged(m_map->CurrentPosition().Lng(), m_map->CurrentPosition().Lat(), m_map->ZoomTotal());
emit defaultSafeAreaChanged(m_map->Home->SafeArea(), m_map->Home->ShowSafeArea());
}
void OPMapGadgetWidget::on_toolButtonNormalMapMode_clicked()
{
@ -944,6 +1004,7 @@ void OPMapGadgetWidget::homePositionUpdated(UAVObject *hp)
} else {
HomePic = "home2_not_set.svg";
}
m_widget->toolButtonHomeSet->setChecked(set);
SetHomePic(HomePic);
setHome(internals::PointLatLng(LLA[0], LLA[1]), LLA[2]);
@ -1021,6 +1082,7 @@ void OPMapGadgetWidget::setHome(internals::PointLatLng pos_lat_lon, double altit
m_map->Home->SetCoord(m_home_position.coord);
m_map->Home->SetAltitude(altitude);
m_map->Home->SetToggleRefresh(true);
m_map->Home->RefreshPos();
// move the magic waypoint to keep it within the safe area boundry

View File

@ -123,6 +123,7 @@ public:
bool applyHomeLocationOnMap();
signals:
void defaultLocationAndZoomChanged(double lng, double lat, double zoom);
void defaultSafeAreaChanged(int safe_area_radius, bool showSafeArea);
void overlayOpacityChanged(qreal);
public slots:
@ -159,6 +160,10 @@ private slots:
void on_toolButtonNormalMapMode_clicked();
void on_toolButtonHomeWaypoint_clicked();
void on_toolButtonMoveToWP_clicked();
void on_toolButtonHomeSet_clicked();
void on_toolButtonClearUAVTrail_clicked();
void on_toolButtonPlanEditor_clicked();
void on_toolButtonSaveSettings_clicked();
/**
* @brief signals received from the map object