mirror of
https://github.com/tumic0/GPXSee.git
synced 2024-11-27 21:24:47 +01:00
Added "enable pause detection" setting
This commit is contained in:
parent
36bf66b984
commit
7e690bdbfb
@ -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);
|
||||||
|
@ -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)
|
||||||
|
@ -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;
|
||||||
|
@ -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 );
|
||||||
|
@ -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;
|
||||||
|
@ -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,32 +182,33 @@ Track::Track(const TrackData &data) : _pause(0)
|
|||||||
if (!hasTime)
|
if (!hasTime)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
|
if (_detectPauses) {
|
||||||
|
// get stop-points + pause duration
|
||||||
|
int pauseInterval;
|
||||||
|
qreal pauseSpeed;
|
||||||
|
|
||||||
// get stop-points + pause duration
|
if (_automaticPause) {
|
||||||
int pauseInterval;
|
pauseSpeed = (avg(seg.speed) > 2.8) ? 0.40 : 0.15;
|
||||||
qreal pauseSpeed;
|
pauseInterval = 10;
|
||||||
|
} else {
|
||||||
|
pauseSpeed = _pauseSpeed;
|
||||||
|
pauseInterval = _pauseInterval;
|
||||||
|
}
|
||||||
|
|
||||||
if (_automaticPause) {
|
int ss = 0, la = 0;
|
||||||
pauseSpeed = (avg(seg.speed) > 2.8) ? 0.40 : 0.15;
|
for (int j = 1; j < seg.time.size(); j++) {
|
||||||
pauseInterval = 10;
|
if (seg.speed.at(j) > pauseSpeed)
|
||||||
} else {
|
ss = -1;
|
||||||
pauseSpeed = _pauseSpeed;
|
else if (ss < 0)
|
||||||
pauseInterval = _pauseInterval;
|
ss = j-1;
|
||||||
}
|
|
||||||
|
|
||||||
int ss = 0, la = 0;
|
if (ss >= 0 && seg.time.at(j) > seg.time.at(ss) + pauseInterval) {
|
||||||
for (int j = 1; j < seg.time.size(); j++) {
|
int l = qMax(ss, la);
|
||||||
if (seg.speed.at(j) > pauseSpeed)
|
_pause += seg.time.at(j) - seg.time.at(l);
|
||||||
ss = -1;
|
for (int k = l; k <= j; k++)
|
||||||
else if (ss < 0)
|
seg.stop.insert(k);
|
||||||
ss = j-1;
|
la = j;
|
||||||
|
}
|
||||||
if (ss >= 0 && seg.time.at(j) > seg.time.at(ss) + pauseInterval) {
|
|
||||||
int l = qMax(ss, la);
|
|
||||||
_pause += seg.time.at(j) - seg.time.at(l);
|
|
||||||
for (int k = l; k <= j; k++)
|
|
||||||
seg.stop.insert(k);
|
|
||||||
la = j;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -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;
|
||||||
|
Loading…
Reference in New Issue
Block a user