Skip to content
Permalink
Browse files

[needs-docs][gps] Add explicit setting to allow control over the freq…

…uency

of map rotation to match GPS bearing

Otherwise frequent GPS updates can cause a too many map redraws to occur quickly
  • Loading branch information
nyalldawson committed Jan 6, 2020
1 parent e2bb325 commit 3f9b53ea73e6e3c596fcf5dbd5ac856291232f70
@@ -130,6 +130,8 @@ QgsGpsInformationWidget::QgsGpsInformationWidget( QgsMapCanvas *mapCanvas, QWidg
mpHistogramLayout->addWidget( mPlot );
mpHistogramWidget->setLayout( mpHistogramLayout );

mSpinMapRotateInterval->setClearValue( 0 );

//
// Set up the polar graph for satellite pos
//
@@ -276,7 +278,11 @@ QgsGpsInformationWidget::QgsGpsInformationWidget( QgsMapCanvas *mapCanvas, QWidg
{
radRecenterWhenNeeded->setChecked( true );
}

connect( mRotateMapCheckBox, &QCheckBox::toggled, mSpinMapRotateInterval, &QSpinBox::setEnabled );

mRotateMapCheckBox->setChecked( mySettings.value( QStringLiteral( "gps/rotateMap" ), false ).toBool() );
mSpinMapRotateInterval->setValue( mySettings.value( QStringLiteral( "gps/rotateMapInterval" ), 0 ).toInt() );
mShowBearingLineCheck->setChecked( mySettings.value( QStringLiteral( "gps/showBearingLine" ), false ).toBool() );

mWgs84CRS = QgsCoordinateReferenceSystem::fromOgcWmsCrs( QStringLiteral( "EPSG:4326" ) );
@@ -445,6 +451,7 @@ QgsGpsInformationWidget::~QgsGpsInformationWidget()
mySettings.setValue( QStringLiteral( "gps/panMode" ), "none" );
}
mySettings.setValue( QStringLiteral( "gps/rotateMap" ), mRotateMapCheckBox->isChecked() );
mySettings.setValue( QStringLiteral( "gps/rotateMapInterval" ), mSpinMapRotateInterval->value() );
mySettings.setValue( QStringLiteral( "gps/showBearingLine" ), mShowBearingLineCheck->isChecked() );

QDomDocument doc;
@@ -914,9 +921,10 @@ void QgsGpsInformationWidget::displayGPSInformation( const QgsGpsInformation &in

}

if ( mRotateMapCheckBox->isChecked() )
if ( mRotateMapCheckBox->isChecked() && ( !mLastRotateTimer.isValid() || mLastRotateTimer.hasExpired( mSpinMapRotateInterval->value() * 1000 ) ) )
{
mMapCanvas->setRotation( trueNorth - info.direction );
mLastRotateTimer.restart();
}

if ( mShowBearingLineCheck )
@@ -137,6 +137,9 @@ class APP_EXPORT QgsGpsInformationWidget: public QgsPanelWidget, private Ui::Qgs
QMap<QString, QString> mPreferredTimestampFields;
//! Flag when updating fields
bool mPopulatingFields = false;

QElapsedTimer mLastRotateTimer;

friend class TestQgsGpsInformationWidget;
};

@@ -1028,7 +1028,7 @@ gray = no data
<item row="5" column="0">
<widget class="QgsCollapsibleGroupBoxBasic" name="groupBox">
<property name="title">
<string>Map Centering</string>
<string>Map Centering and Rotation</string>
</property>
<layout class="QGridLayout" name="gridLayout_8">
<property name="topMargin">
@@ -1040,23 +1040,6 @@ gray = no data
<property name="verticalSpacing">
<number>2</number>
</property>
<item row="1" column="0">
<widget class="QRadioButton" name="radRecenterWhenNeeded">
<property name="text">
<string>When leaving</string>
</property>
</widget>
</item>
<item row="0" column="0">
<widget class="QRadioButton" name="radRecenterMap">
<property name="text">
<string>Always</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
</widget>
</item>
<item row="2" column="0">
<layout class="QHBoxLayout" name="horizontalLayout">
<property name="leftMargin">
@@ -1092,6 +1075,23 @@ gray = no data
</item>
</layout>
</item>
<item row="0" column="0">
<widget class="QRadioButton" name="radRecenterMap">
<property name="text">
<string>Always</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QRadioButton" name="radRecenterWhenNeeded">
<property name="text">
<string>When leaving</string>
</property>
</widget>
</item>
<item row="3" column="0">
<widget class="QRadioButton" name="radNeverRecenter">
<property name="text">
@@ -1106,6 +1106,51 @@ gray = no data
</property>
</widget>
</item>
<item row="5" column="0">
<layout class="QHBoxLayout" name="horizontalLayout_5" stretch="0,1">
<property name="leftMargin">
<number>20</number>
</property>
<item>
<widget class="QLabel" name="label_12">
<property name="text">
<string>Frequency</string>
</property>
</widget>
</item>
<item>
<widget class="QgsSpinBox" name="mSpinMapRotateInterval">
<property name="enabled">
<bool>false</bool>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="specialValueText">
<string>On GPS signal</string>
</property>
<property name="suffix">
<string> s</string>
</property>
<property name="minimum">
<number>0</number>
</property>
<property name="maximum">
<number>1000</number>
</property>
<property name="singleStep">
<number>1</number>
</property>
<property name="value">
<number>0</number>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</widget>
</item>

0 comments on commit 3f9b53e

Please sign in to comment.
You can’t perform that action at this time.