1
0
mirror of https://github.com/tumic0/GPXSee.git synced 2024-11-24 03:35:53 +01:00

Added "enable pause detection" setting

This commit is contained in:
Martin Tůma 2024-09-01 16:28:25 +02:00
parent 36bf66b984
commit 7e690bdbfb
7 changed files with 54 additions and 27 deletions

View File

@ -2594,6 +2594,7 @@ void GUI::writeSettings()
WRITE(cadenceFilter, _options.cadenceFilter); WRITE(cadenceFilter, _options.cadenceFilter);
WRITE(powerFilter, _options.powerFilter); WRITE(powerFilter, _options.powerFilter);
WRITE(outlierEliminate, _options.outlierEliminate); WRITE(outlierEliminate, _options.outlierEliminate);
WRITE(detectPauses, _options.detectPauses);
WRITE(automaticPause, _options.automaticPause); WRITE(automaticPause, _options.automaticPause);
WRITE(pauseSpeed, _options.pauseSpeed); WRITE(pauseSpeed, _options.pauseSpeed);
WRITE(pauseInterval, _options.pauseInterval); WRITE(pauseInterval, _options.pauseInterval);
@ -2901,6 +2902,7 @@ void GUI::readSettings(QString &activeMap, QStringList &disabledPOIs,
_options.powerFilter = READ(powerFilter).toInt(); _options.powerFilter = READ(powerFilter).toInt();
_options.outlierEliminate = READ(outlierEliminate).toBool(); _options.outlierEliminate = READ(outlierEliminate).toBool();
_options.pauseSpeed = READ(pauseSpeed).toFloat(); _options.pauseSpeed = READ(pauseSpeed).toFloat();
_options.detectPauses = READ(detectPauses).toBool();
_options.automaticPause = READ(automaticPause).toBool(); _options.automaticPause = READ(automaticPause).toBool();
_options.pauseInterval = READ(pauseInterval).toInt(); _options.pauseInterval = READ(pauseInterval).toInt();
_options.useReportedSpeed = READ(useReportedSpeed).toBool(); _options.useReportedSpeed = READ(useReportedSpeed).toBool();
@ -2993,6 +2995,7 @@ void GUI::loadOptions()
Track::setCadenceFilter(_options.cadenceFilter); Track::setCadenceFilter(_options.cadenceFilter);
Track::setPowerFilter(_options.powerFilter); Track::setPowerFilter(_options.powerFilter);
Track::setOutlierElimination(_options.outlierEliminate); Track::setOutlierElimination(_options.outlierEliminate);
Track::detectPauses(_options.detectPauses);
Track::setAutomaticPause(_options.automaticPause); Track::setAutomaticPause(_options.automaticPause);
Track::setPauseSpeed(_options.pauseSpeed); Track::setPauseSpeed(_options.pauseSpeed);
Track::setPauseInterval(_options.pauseInterval); Track::setPauseInterval(_options.pauseInterval);
@ -3121,6 +3124,7 @@ void GUI::updateOptions(const Options &options)
SET_TRACK_OPTION(cadenceFilter, setCadenceFilter); SET_TRACK_OPTION(cadenceFilter, setCadenceFilter);
SET_TRACK_OPTION(powerFilter, setPowerFilter); SET_TRACK_OPTION(powerFilter, setPowerFilter);
SET_TRACK_OPTION(outlierEliminate, setOutlierElimination); SET_TRACK_OPTION(outlierEliminate, setOutlierElimination);
SET_TRACK_OPTION(detectPauses, detectPauses);
SET_TRACK_OPTION(automaticPause, setAutomaticPause); SET_TRACK_OPTION(automaticPause, setAutomaticPause);
SET_TRACK_OPTION(pauseSpeed, setPauseSpeed); SET_TRACK_OPTION(pauseSpeed, setPauseSpeed);
SET_TRACK_OPTION(pauseInterval, setPauseInterval); SET_TRACK_OPTION(pauseInterval, setPauseInterval);

View File

@ -53,6 +53,14 @@ void OptionsDialog::automaticPauseDetectionSet(bool set)
_pauseSpeed->setEnabled(!set); _pauseSpeed->setEnabled(!set);
} }
void OptionsDialog::pauseDetectionSet(bool set)
{
_automaticPause->setEnabled(set);
_manualPause->setEnabled(set);
_pauseInterval->setEnabled(set && _manualPause->isChecked());
_pauseSpeed->setEnabled(set && _manualPause->isChecked());
}
QWidget *OptionsDialog::createMapPage() QWidget *OptionsDialog::createMapPage()
{ {
ProjectionList outputProjections(GCS::WGS84List() + Conversion::list()); ProjectionList outputProjections(GCS::WGS84List() + Conversion::list());
@ -377,6 +385,9 @@ QWidget *OptionsDialog::createDataPage()
filterTab->setLayout(filterTabLayout); filterTab->setLayout(filterTabLayout);
#endif // Q_OS_MAC #endif // Q_OS_MAC
_detectPauses = new QCheckBox(tr("Detect pauses"));
_detectPauses->setChecked(_options.detectPauses);
_automaticPause = new QRadioButton(tr("Automatic")); _automaticPause = new QRadioButton(tr("Automatic"));
_manualPause = new QRadioButton(tr("Custom")); _manualPause = new QRadioButton(tr("Custom"));
if (_options.automaticPause) if (_options.automaticPause)
@ -405,6 +416,10 @@ QWidget *OptionsDialog::createDataPage()
_pauseInterval->setValue(_options.pauseInterval); _pauseInterval->setValue(_options.pauseInterval);
_pauseInterval->setEnabled(_manualPause->isChecked()); _pauseInterval->setEnabled(_manualPause->isChecked());
pauseDetectionSet(_options.detectPauses);
connect(_detectPauses, &QCheckBox::toggled, this,
&OptionsDialog::pauseDetectionSet);
connect(_automaticPause, &QRadioButton::toggled, this, connect(_automaticPause, &QRadioButton::toggled, this,
&OptionsDialog::automaticPauseDetectionSet); &OptionsDialog::automaticPauseDetectionSet);
@ -516,19 +531,17 @@ QWidget *OptionsDialog::createDataPage()
QHBoxLayout *pauseTypeLayout = new QHBoxLayout(); QHBoxLayout *pauseTypeLayout = new QHBoxLayout();
#ifdef Q_OS_MAC
pauseTypeLayout->addStretch();
#endif
pauseTypeLayout->addWidget(_automaticPause); pauseTypeLayout->addWidget(_automaticPause);
pauseTypeLayout->addWidget(_manualPause); pauseTypeLayout->addWidget(_manualPause);
pauseTypeLayout->addStretch(); pauseTypeLayout->addStretch();
QFormLayout *pauseValuesLayout = new QFormLayout(); QFormLayout *pauseValuesLayout = new QFormLayout();
pauseValuesLayout->addRow(tr("Detection:"), pauseTypeLayout);
pauseValuesLayout->addRow(tr("Minimal speed:"), _pauseSpeed); pauseValuesLayout->addRow(tr("Minimal speed:"), _pauseSpeed);
pauseValuesLayout->addRow(tr("Minimal duration:"), _pauseInterval); pauseValuesLayout->addRow(tr("Minimal duration:"), _pauseInterval);
QVBoxLayout *pauseLayout = new QVBoxLayout(); QVBoxLayout *pauseLayout = new QVBoxLayout();
pauseLayout->addLayout(pauseTypeLayout); pauseLayout->addWidget(_detectPauses);
pauseLayout->addLayout(pauseValuesLayout); pauseLayout->addLayout(pauseValuesLayout);
QWidget *pauseTab = new QWidget(); QWidget *pauseTab = new QWidget();
@ -960,6 +973,7 @@ void OptionsDialog::accept()
_options.cadenceFilter = _cadenceFilter->value(); _options.cadenceFilter = _cadenceFilter->value();
_options.powerFilter = _powerFilter->value(); _options.powerFilter = _powerFilter->value();
_options.outlierEliminate = _outlierEliminate->isChecked(); _options.outlierEliminate = _outlierEliminate->isChecked();
_options.detectPauses = _detectPauses->isChecked();
_options.automaticPause = _automaticPause->isChecked(); _options.automaticPause = _automaticPause->isChecked();
qreal pauseSpeed = (_units == Imperial) qreal pauseSpeed = (_units == Imperial)
? _pauseSpeed->value() / MS2MIH : (_units == Nautical) ? _pauseSpeed->value() / MS2MIH : (_units == Nautical)

View File

@ -56,6 +56,7 @@ struct Options {
int cadenceFilter; int cadenceFilter;
int powerFilter; int powerFilter;
bool outlierEliminate; bool outlierEliminate;
bool detectPauses;
bool automaticPause; bool automaticPause;
qreal pauseSpeed; qreal pauseSpeed;
int pauseInterval; int pauseInterval;
@ -113,6 +114,7 @@ public:
private slots: private slots:
void automaticPauseDetectionSet(bool set); void automaticPauseDetectionSet(bool set);
void pauseDetectionSet(bool set);
private: private:
QWidget *createMapPage(); QWidget *createMapPage();
@ -164,6 +166,7 @@ private:
QCheckBox *_outlierEliminate; QCheckBox *_outlierEliminate;
QRadioButton *_automaticPause; QRadioButton *_automaticPause;
QRadioButton *_manualPause; QRadioButton *_manualPause;
QCheckBox *_detectPauses;
QDoubleSpinBox *_pauseSpeed; QDoubleSpinBox *_pauseSpeed;
QSpinBox *_pauseInterval; QSpinBox *_pauseInterval;
QRadioButton *_computedSpeed; QRadioButton *_computedSpeed;

View File

@ -230,6 +230,7 @@ SETTING(heartRateFilter, "heartrateFilter", 3 );
SETTING(cadenceFilter, "cadenceFilter", 3 ); SETTING(cadenceFilter, "cadenceFilter", 3 );
SETTING(powerFilter, "powerFilter", 3 ); SETTING(powerFilter, "powerFilter", 3 );
SETTING(outlierEliminate, "outlierEliminate", true ); SETTING(outlierEliminate, "outlierEliminate", true );
SETTING(detectPauses, "detectPauses", true );
SETTING(automaticPause, "automaticPause", true ); SETTING(automaticPause, "automaticPause", true );
SETTING(pauseSpeed, "pauseSpeed", 0.5 ); SETTING(pauseSpeed, "pauseSpeed", 0.5 );
SETTING(pauseInterval, "pauseInterval", 10 ); SETTING(pauseInterval, "pauseInterval", 10 );

View File

@ -182,6 +182,7 @@ public:
static const Setting cadenceFilter; static const Setting cadenceFilter;
static const Setting powerFilter; static const Setting powerFilter;
static const Setting outlierEliminate; static const Setting outlierEliminate;
static const Setting detectPauses;
static const Setting automaticPause; static const Setting automaticPause;
static const Setting pauseSpeed; static const Setting pauseSpeed;
static const Setting pauseInterval; static const Setting pauseInterval;

View File

@ -8,6 +8,7 @@ int Track::_heartRateWindow = 3;
int Track::_cadenceWindow = 3; int Track::_cadenceWindow = 3;
int Track::_powerWindow = 3; int Track::_powerWindow = 3;
bool Track::_detectPauses = true;
bool Track::_automaticPause = true; bool Track::_automaticPause = true;
qreal Track::_pauseSpeed = 0.5; qreal Track::_pauseSpeed = 0.5;
int Track::_pauseInterval = 10; int Track::_pauseInterval = 10;
@ -181,7 +182,7 @@ Track::Track(const TrackData &data) : _pause(0)
if (!hasTime) if (!hasTime)
continue; continue;
if (_detectPauses) {
// get stop-points + pause duration // get stop-points + pause duration
int pauseInterval; int pauseInterval;
qreal pauseSpeed; qreal pauseSpeed;
@ -209,6 +210,7 @@ Track::Track(const TrackData &data) : _pause(0)
la = j; la = j;
} }
} }
}
if (!_outlierEliminate) if (!_outlierEliminate)
continue; continue;

View File

@ -44,6 +44,7 @@ public:
static void setHeartRateFilter(int window) {_heartRateWindow = window;} static void setHeartRateFilter(int window) {_heartRateWindow = window;}
static void setCadenceFilter(int window) {_cadenceWindow = window;} static void setCadenceFilter(int window) {_cadenceWindow = window;}
static void setPowerFilter(int window) {_powerWindow = window;} static void setPowerFilter(int window) {_powerWindow = window;}
static void detectPauses(bool detect) {_detectPauses = detect;}
static void setAutomaticPause(bool set) {_automaticPause = set;} static void setAutomaticPause(bool set) {_automaticPause = set;}
static void setPauseSpeed(qreal speed) {_pauseSpeed = speed;} static void setPauseSpeed(qreal speed) {_pauseSpeed = speed;}
static void setPauseInterval(int interval) {_pauseInterval = interval;} static void setPauseInterval(int interval) {_pauseInterval = interval;}
@ -84,6 +85,7 @@ private:
static int _heartRateWindow; static int _heartRateWindow;
static int _cadenceWindow; static int _cadenceWindow;
static int _powerWindow; static int _powerWindow;
static bool _detectPauses;
static bool _automaticPause; static bool _automaticPause;
static qreal _pauseSpeed; static qreal _pauseSpeed;
static int _pauseInterval; static int _pauseInterval;