1
0
mirror of https://github.com/tumic0/GPXSee.git synced 2024-11-28 05:34:47 +01:00

Allow only odd window sizes for moving average filter

This commit is contained in:
Martin Tůma 2017-05-22 23:41:01 +02:00
parent d54f22d3f0
commit aff7b1c13f
5 changed files with 53 additions and 12 deletions

View File

@ -93,7 +93,8 @@ HEADERS += src/config.h \
src/ozf.h \ src/ozf.h \
src/datum.h \ src/datum.h \
src/maplist.h \ src/maplist.h \
src/albersequal.h src/albersequal.h \
src/oddspinbox.h
SOURCES += src/main.cpp \ SOURCES += src/main.cpp \
src/gui.cpp \ src/gui.cpp \
src/poi.cpp \ src/poi.cpp \
@ -160,7 +161,8 @@ SOURCES += src/main.cpp \
src/ozf.cpp \ src/ozf.cpp \
src/datum.cpp \ src/datum.cpp \
src/maplist.cpp \ src/maplist.cpp \
src/albersequal.cpp src/albersequal.cpp \
src/oddspinbox.cpp
RESOURCES += gpxsee.qrc RESOURCES += gpxsee.qrc
TRANSLATIONS = lang/gpxsee_cs.ts \ TRANSLATIONS = lang/gpxsee_cs.ts \
lang/gpxsee_sv.ts \ lang/gpxsee_sv.ts \

22
src/oddspinbox.cpp Normal file
View File

@ -0,0 +1,22 @@
#include "oddspinbox.h"
#include <QDebug>
OddSpinBox::OddSpinBox(QWidget *parent) : QSpinBox(parent)
{
setSingleStep(2);
setMinimum(1);
}
QValidator::State OddSpinBox::validate(QString &text, int &pos) const
{
Q_UNUSED(pos);
bool ok;
int val;
val = text.toInt(&ok);
if (!ok || val < 0 || val % 2 == 0)
return QValidator::Invalid;
return QValidator::Acceptable;
}

15
src/oddspinbox.h Normal file
View File

@ -0,0 +1,15 @@
#ifndef ODDSPINBOX_H
#define ODDSPINBOX_H
#include <QSpinBox>
class OddSpinBox : public QSpinBox
{
public:
OddSpinBox(QWidget *parent = 0);
protected:
QValidator::State validate(QString &text, int &pos) const;
};
#endif // ODDSPINBOX_H

View File

@ -14,6 +14,7 @@
#include "icons.h" #include "icons.h"
#include "colorbox.h" #include "colorbox.h"
#include "stylecombobox.h" #include "stylecombobox.h"
#include "oddspinbox.h"
#include "optionsdialog.h" #include "optionsdialog.h"
#define MENU_MARGIN 20 #define MENU_MARGIN 20
@ -122,19 +123,19 @@ QWidget *OptionsDialog::createDataPage()
{ {
QString filterToolTip = tr("Moving average window size"); QString filterToolTip = tr("Moving average window size");
_elevationFilter = new QSpinBox(); _elevationFilter = new OddSpinBox();
_elevationFilter->setValue(_options->elevationFilter); _elevationFilter->setValue(_options->elevationFilter);
_elevationFilter->setToolTip(filterToolTip); _elevationFilter->setToolTip(filterToolTip);
_speedFilter = new QSpinBox(); _speedFilter = new OddSpinBox();
_speedFilter->setValue(_options->speedFilter); _speedFilter->setValue(_options->speedFilter);
_speedFilter->setToolTip(filterToolTip); _speedFilter->setToolTip(filterToolTip);
_heartRateFilter = new QSpinBox(); _heartRateFilter = new OddSpinBox();
_heartRateFilter->setValue(_options->heartRateFilter); _heartRateFilter->setValue(_options->heartRateFilter);
_heartRateFilter->setToolTip(filterToolTip); _heartRateFilter->setToolTip(filterToolTip);
_cadenceFilter = new QSpinBox(); _cadenceFilter = new OddSpinBox();
_cadenceFilter->setValue(_options->cadenceFilter); _cadenceFilter->setValue(_options->cadenceFilter);
_cadenceFilter->setToolTip(filterToolTip); _cadenceFilter->setToolTip(filterToolTip);
_powerFilter = new QSpinBox(); _powerFilter = new OddSpinBox();
_powerFilter->setValue(_options->powerFilter); _powerFilter->setValue(_options->powerFilter);
_powerFilter->setToolTip(filterToolTip); _powerFilter->setToolTip(filterToolTip);

View File

@ -7,6 +7,7 @@
class ColorBox; class ColorBox;
class StyleComboBox; class StyleComboBox;
class OddSpinBox;
class QSpinBox; class QSpinBox;
class QDoubleSpinBox; class QDoubleSpinBox;
class QComboBox; class QComboBox;
@ -78,11 +79,11 @@ private:
QSpinBox *_graphWidth; QSpinBox *_graphWidth;
QCheckBox *_graphAA; QCheckBox *_graphAA;
// Data // Data
QSpinBox *_elevationFilter; OddSpinBox *_elevationFilter;
QSpinBox *_speedFilter; OddSpinBox *_speedFilter;
QSpinBox *_heartRateFilter; OddSpinBox *_heartRateFilter;
QSpinBox *_cadenceFilter; OddSpinBox *_cadenceFilter;
QSpinBox *_powerFilter; OddSpinBox *_powerFilter;
QCheckBox *_outlierEliminate; QCheckBox *_outlierEliminate;
QDoubleSpinBox *_pauseSpeed; QDoubleSpinBox *_pauseSpeed;
QSpinBox *_pauseInterval; QSpinBox *_pauseInterval;