1
0
mirror of https://bitbucket.org/librepilot/librepilot.git synced 2025-02-20 10:54:14 +01:00

LP-572 Make safe area user-configurable

This commit is contained in:
Laurent Lalanne 2018-01-05 13:41:14 +01:00
parent debddb5c0b
commit 16cca00f21
7 changed files with 224 additions and 115 deletions

View File

@ -67,6 +67,8 @@ void OPMapGadget::loadConfiguration(IUAVGadgetConfiguration *config)
m_widget->SetUavPic(m_config->uavSymbol());
m_widget->setZoom(m_config->zoom());
m_widget->setPosition(QPointF(m_config->longitude(), m_config->latitude()));
m_widget->setSafeAreaRadius(m_config->safeAreaRadius());
m_widget->setShowSafeArea(m_config->showSafeArea());
m_widget->setOverlayOpacity(m_config->opacity());
m_widget->setDefaultWaypointAltitude(m_config->defaultWaypointAltitude());
m_widget->setDefaultWaypointVelocity(m_config->defaultWaypointVelocity());

View File

@ -43,6 +43,8 @@ OPMapGadgetConfiguration::OPMapGadgetConfiguration(QString classId, QSettings &s
m_useOpenGL = settings.value("useOpenGL").toBool();
m_showTileGridLines = settings.value("showTileGridLines").toBool();
m_uavSymbol = settings.value("uavSymbol", QString::fromUtf8(":/uavs/images/mapquad.png")).toString();
m_safeAreaRadius = settings.value("safeAreaRadius", 5).toInt();
m_showSafeArea = settings.value("showSafeArea").toBool();
m_maxUpdateRate = settings.value("maxUpdateRate", 2000).toInt();
if (m_maxUpdateRate < 100 || m_maxUpdateRate > 5000) {
@ -69,6 +71,8 @@ OPMapGadgetConfiguration::OPMapGadgetConfiguration(const OPMapGadgetConfiguratio
m_cacheLocation = obj.m_cacheLocation;
m_uavSymbol = obj.m_uavSymbol;
m_maxUpdateRate = obj.m_maxUpdateRate;
m_safeAreaRadius = obj.m_safeAreaRadius;
m_showSafeArea = obj.m_showSafeArea;
m_opacity = obj.m_opacity;
m_defaultWaypointAltitude = obj.m_defaultWaypointAltitude;
m_defaultWaypointVelocity = obj.m_defaultWaypointVelocity;
@ -99,6 +103,8 @@ void OPMapGadgetConfiguration::saveConfig(QSettings &settings) const
settings.setValue("uavSymbol", m_uavSymbol);
settings.setValue("cacheLocation", Utils::RemoveStoragePath(m_cacheLocation));
settings.setValue("maxUpdateRate", m_maxUpdateRate);
settings.setValue("safeAreaRadius", m_safeAreaRadius);
settings.setValue("showSafeArea", m_showSafeArea);
settings.setValue("overlayOpacity", m_opacity);
settings.setValue("defaultWaypointAltitude", m_defaultWaypointAltitude);

View File

@ -46,6 +46,8 @@ class OPMapGadgetConfiguration : public IUAVGadgetConfiguration {
Q_PROPERTY(QString cacheLocation READ cacheLocation WRITE setCacheLocation)
Q_PROPERTY(QString uavSymbol READ uavSymbol WRITE setUavSymbol)
Q_PROPERTY(int maxUpdateRate READ maxUpdateRate WRITE setMaxUpdateRate)
Q_PROPERTY(int safeAreaRadius READ safeAreaRadius WRITE setSafeAreaRadius)
Q_PROPERTY(bool showSafeArea READ showSafeArea WRITE setShowSafeArea)
Q_PROPERTY(qreal overlayOpacity READ opacity WRITE setOpacity)
Q_PROPERTY(qreal defaultWaypointAltitude READ defaultWaypointAltitude WRITE setDefaultWaypointAltitude)
Q_PROPERTY(qreal defaultWaypointVelocity READ defaultWaypointVelocity WRITE setDefaultWaypointVelocity)
@ -103,6 +105,14 @@ public:
{
return m_maxUpdateRate;
}
int safeAreaRadius() const
{
return m_safeAreaRadius;
}
bool showSafeArea() const
{
return m_showSafeArea;
}
qreal opacity() const
{
return m_opacity;
@ -164,6 +174,14 @@ public slots:
{
m_maxUpdateRate = update_rate;
}
void setSafeAreaRadius(int safe_area_radius)
{
m_safeAreaRadius = safe_area_radius;
}
void setShowSafeArea(bool showSafeArea)
{
m_showSafeArea = showSafeArea;
}
void setDefaultWaypointAltitude(qreal default_altitude)
{
@ -187,6 +205,8 @@ private:
QString m_cacheLocation;
QString m_uavSymbol;
int m_maxUpdateRate;
int m_safeAreaRadius;
bool m_showSafeArea;
qreal m_opacity;
qreal m_defaultWaypointAltitude;
qreal m_defaultWaypointVelocity;

View File

@ -79,6 +79,25 @@ QWidget *OPMapGadgetOptionsPage::createPage(QWidget *parent)
index = (index >= 0) ? index : 4;
m_page->maxUpdateRateComboBox->setCurrentIndex(index);
// populate the safety area radius combobox
m_page->safeAreaRadiusComboBox->clear();
m_page->safeAreaRadiusComboBox->addItem("5m", 5);
m_page->safeAreaRadiusComboBox->addItem("10m", 10);
m_page->safeAreaRadiusComboBox->addItem("20m", 20);
m_page->safeAreaRadiusComboBox->addItem("50m", 50);
m_page->safeAreaRadiusComboBox->addItem("100m", 100);
m_page->safeAreaRadiusComboBox->addItem("200m", 200);
m_page->safeAreaRadiusComboBox->addItem("500m", 500);
m_page->safeAreaRadiusComboBox->addItem("1000m", 1000);
m_page->safeAreaRadiusComboBox->addItem("2000m", 2000);
m_page->safeAreaRadiusComboBox->addItem("5000m", 5000);
index = m_page->safeAreaRadiusComboBox->findData(m_config->safeAreaRadius());
index = (index >= 0) ? index : 0;
m_page->safeAreaRadiusComboBox->setCurrentIndex(index);
m_page->checkBoxShowSafeArea->setChecked(m_config->showSafeArea());
m_page->zoomSpinBox->setValue(m_config->zoom());
m_page->latitudeSpinBox->setValue(m_config->latitude());
m_page->longitudeSpinBox->setValue(m_config->longitude());
@ -140,6 +159,8 @@ void OPMapGadgetOptionsPage::apply()
m_config->setCacheLocation(m_page->lineEditCacheLocation->path());
m_config->setUavSymbol(m_page->uavSymbolComboBox->itemData(m_page->uavSymbolComboBox->currentIndex()).toString());
m_config->setMaxUpdateRate(m_page->maxUpdateRateComboBox->itemData(m_page->maxUpdateRateComboBox->currentIndex()).toInt());
m_config->setSafeAreaRadius(m_page->safeAreaRadiusComboBox->itemData(m_page->safeAreaRadiusComboBox->currentIndex()).toInt());
m_config->setShowSafeArea(m_page->checkBoxShowSafeArea->isChecked());
m_config->setDefaultWaypointAltitude(m_page->defaultWaypointAltitude->value());
m_config->setDefaultWaypointVelocity(m_page->defaultWaypointVelocity->value());
}

View File

@ -54,8 +54,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>549</width>
<height>401</height>
<width>550</width>
<height>422</height>
</rect>
</property>
<property name="sizePolicy">
@ -88,7 +88,17 @@
</widget>
</item>
<item row="0" column="0" colspan="2">
<layout class="QGridLayout" name="gridLayout_3" rowstretch="0,0,0,0,0,0" rowminimumheight="22,22,22,0,22,0">
<layout class="QGridLayout" name="gridLayout_3" rowstretch="0,0,0,0,0,0,0" rowminimumheight="22,22,22,0,22,0,0">
<item row="1" column="2">
<widget class="QLabel" name="label_3">
<property name="text">
<string>Default latitude </string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget>
</item>
<item row="2" column="0">
<spacer name="horizontalSpacer_4">
<property name="orientation">
@ -102,16 +112,72 @@
</property>
</spacer>
</item>
<item row="0" column="0">
<widget class="QLabel" name="label">
<item row="4" column="2">
<widget class="QCheckBox" name="checkBoxUseOpenGL">
<property name="enabled">
<bool>true</bool>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>0</width>
<height>0</height>
</size>
</property>
<property name="layoutDirection">
<enum>Qt::RightToLeft</enum>
</property>
<property name="text">
<string>Map type </string>
<string>Use OpenGL</string>
</property>
</widget>
</item>
<item row="4" column="3">
<widget class="QCheckBox" name="checkBoxShowTileGridLines">
<property name="enabled">
<bool>true</bool>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>161</width>
<height>0</height>
</size>
</property>
<property name="mouseTracking">
<bool>true</bool>
</property>
<property name="layoutDirection">
<enum>Qt::RightToLeft</enum>
</property>
<property name="text">
<string>Show Tile Grid Lines</string>
</property>
</widget>
</item>
<item row="0" column="3">
<widget class="QLabel" name="label_2">
<property name="text">
<string>Default zoom </string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget>
</item>
<item row="5" column="3">
<widget class="QComboBox" name="maxUpdateRateComboBox"/>
</item>
<item row="0" column="2">
<widget class="QComboBox" name="providerComboBox">
<property name="sizePolicy">
@ -137,85 +203,6 @@
</property>
</widget>
</item>
<item row="0" column="3">
<widget class="QLabel" name="label_2">
<property name="text">
<string>Default zoom </string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget>
</item>
<item row="0" column="4">
<widget class="QSpinBox" name="zoomSpinBox">
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>0</width>
<height>0</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>50</width>
<height>16777215</height>
</size>
</property>
<property name="frame">
<bool>true</bool>
</property>
<property name="minimum">
<number>2</number>
</property>
<property name="maximum">
<number>18</number>
</property>
</widget>
</item>
<item row="1" column="2">
<widget class="QLabel" name="label_3">
<property name="text">
<string>Default latitude </string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget>
</item>
<item row="1" column="3">
<widget class="QDoubleSpinBox" name="latitudeSpinBox">
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>120</width>
<height>0</height>
</size>
</property>
<property name="frame">
<bool>true</bool>
</property>
<property name="decimals">
<number>8</number>
</property>
<property name="minimum">
<double>-90.000000000000000</double>
</property>
<property name="maximum">
<double>90.000000000000000</double>
</property>
</widget>
</item>
<item row="2" column="2">
<widget class="QLabel" name="label_4">
<property name="text">
@ -254,11 +241,8 @@
</property>
</widget>
</item>
<item row="4" column="3">
<widget class="QCheckBox" name="checkBoxShowTileGridLines">
<property name="enabled">
<bool>true</bool>
</property>
<item row="0" column="4">
<widget class="QSpinBox" name="zoomSpinBox">
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Preferred">
<horstretch>0</horstretch>
@ -267,23 +251,90 @@
</property>
<property name="minimumSize">
<size>
<width>161</width>
<width>0</width>
<height>0</height>
</size>
</property>
<property name="mouseTracking">
<property name="maximumSize">
<size>
<width>50</width>
<height>16777215</height>
</size>
</property>
<property name="frame">
<bool>true</bool>
</property>
<property name="layoutDirection">
<enum>Qt::RightToLeft</enum>
<property name="minimum">
<number>2</number>
</property>
<property name="text">
<string>Show Tile Grid Lines</string>
<property name="maximum">
<number>18</number>
</property>
</widget>
</item>
<item row="4" column="2">
<widget class="QCheckBox" name="checkBoxUseOpenGL">
<item row="0" column="0">
<widget class="QLabel" name="label">
<property name="text">
<string>Map type </string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget>
</item>
<item row="1" column="3">
<widget class="QDoubleSpinBox" name="latitudeSpinBox">
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>120</width>
<height>0</height>
</size>
</property>
<property name="frame">
<bool>true</bool>
</property>
<property name="decimals">
<number>8</number>
</property>
<property name="minimum">
<double>-90.000000000000000</double>
</property>
<property name="maximum">
<double>90.000000000000000</double>
</property>
</widget>
</item>
<item row="5" column="2">
<widget class="QLabel" name="label_9">
<property name="text">
<string>Default Max Update Rate </string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget>
</item>
<item row="6" column="3">
<widget class="QComboBox" name="safeAreaRadiusComboBox"/>
</item>
<item row="6" column="2">
<widget class="QLabel" name="label_13">
<property name="text">
<string>Default Safe Area Radius </string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget>
</item>
<item row="6" column="0">
<widget class="QCheckBox" name="checkBoxShowSafeArea">
<property name="enabled">
<bool>true</bool>
</property>
@ -303,20 +354,7 @@
<enum>Qt::RightToLeft</enum>
</property>
<property name="text">
<string>Use OpenGL</string>
</property>
</widget>
</item>
<item row="5" column="3">
<widget class="QComboBox" name="maxUpdateRateComboBox"/>
</item>
<item row="5" column="2">
<widget class="QLabel" name="label_9">
<property name="text">
<string>Default Max Update Rate </string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
<string>Show Safe Area</string>
</property>
</widget>
</item>

View File

@ -164,14 +164,14 @@ OPMapGadgetWidget::OPMapGadgetWidget(QWidget *parent) : QWidget(parent)
m_max_zoom = m_widget->horizontalSliderZoom->maximum(); // maximum zoom we can accept
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->SetFollowMouse(true); // we want a continuous mouse position reading
m_map->SetShowHome(true); // display the HOME position on the map
m_map->SetShowUAV(true); // display the UAV position on the map
m_map->SetShowNav(false); // initially don't display the NAV position on the map
m_map->Home->SetSafeArea(safe_area_radius_list[0]); // set radius (meters) //SHOULDN'T THE DEFAULT BE USER DEFINED?
m_map->Home->SetShowSafeArea(true); // show the safe area //SHOULDN'T THE DEFAULT BE USER DEFINED?
m_map->Home->SetSafeArea(safe_area_radius_list[0]); // set radius (meters)
m_map->Home->SetShowSafeArea(true); // show the safe area
m_map->Home->SetToggleRefresh(true);
if (m_map->Home) {
@ -1104,6 +1104,26 @@ void OPMapGadgetWidget::setMaxUpdateRate(int update_rate)
// m_statusUpdateTimer->setInterval(m_maxUpdateRate);
}
void OPMapGadgetWidget::setSafeAreaRadius(int safe_area_radius)
{
if (!m_widget || !m_map) {
return;
}
m_map->Home->SetSafeArea(safe_area_radius);
m_map->Home->SetToggleRefresh(true);
}
void OPMapGadgetWidget::setShowSafeArea(bool showSafeArea)
{
if (!m_widget || !m_map) {
return;
}
m_map->Home->SetShowSafeArea(showSafeArea);
m_map->Home->SetToggleRefresh(true);
}
void OPMapGadgetWidget::setZoom(int zoom)
{
if (!m_widget || !m_map) {

View File

@ -113,6 +113,8 @@ public:
void SetUavPic(QString UAVPic);
void SetHomePic(QString HomePic);
void setMaxUpdateRate(int update_rate);
void setSafeAreaRadius(int safe_area_radius);
void setShowSafeArea(bool showSafeArea);
void setHomePosition(QPointF pos);
void setOverlayOpacity(qreal value);
void setDefaultWaypointAltitude(qreal default_altitude);