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

Added configurable segments usage

This commit is contained in:
Martin Tůma 2020-09-20 22:18:35 +02:00
parent d738ad7b5a
commit 50f483663c
6 changed files with 33 additions and 6 deletions

View File

@ -970,6 +970,7 @@ void GUI::openOptions()
SET_TRACK_OPTION(dataUseDEM, useDEM); SET_TRACK_OPTION(dataUseDEM, useDEM);
SET_TRACK_OPTION(showSecondaryElevation, showSecondaryElevation); SET_TRACK_OPTION(showSecondaryElevation, showSecondaryElevation);
SET_TRACK_OPTION(showSecondarySpeed, showSecondarySpeed); SET_TRACK_OPTION(showSecondarySpeed, showSecondarySpeed);
SET_TRACK_OPTION(useSegments, useSegments);
SET_ROUTE_OPTION(dataUseDEM, useDEM); SET_ROUTE_OPTION(dataUseDEM, useDEM);
SET_ROUTE_OPTION(showSecondaryElevation, showSecondaryElevation); SET_ROUTE_OPTION(showSecondaryElevation, showSecondaryElevation);
@ -1884,6 +1885,8 @@ void GUI::writeSettings()
settings.setValue(TIME_ZONE_SETTING, QVariant::fromValue( settings.setValue(TIME_ZONE_SETTING, QVariant::fromValue(
_options.timeZone)); _options.timeZone));
#endif // ENABLE_TIMEZONES #endif // ENABLE_TIMEZONES
if (_options.useSegments != USE_SEGMENTS_DEFAULT)
settings.setValue(USE_SEGMENTS_SETTING, _options.useSegments);
if (_options.poiRadius != POI_RADIUS_DEFAULT) if (_options.poiRadius != POI_RADIUS_DEFAULT)
settings.setValue(POI_RADIUS_SETTING, _options.poiRadius); settings.setValue(POI_RADIUS_SETTING, _options.poiRadius);
if (_options.useOpenGL != USE_OPENGL_DEFAULT) if (_options.useOpenGL != USE_OPENGL_DEFAULT)
@ -2159,6 +2162,8 @@ void GUI::readSettings()
#ifdef ENABLE_TIMEZONES #ifdef ENABLE_TIMEZONES
_options.timeZone = settings.value(TIME_ZONE_SETTING).value<TimeZoneInfo>(); _options.timeZone = settings.value(TIME_ZONE_SETTING).value<TimeZoneInfo>();
#endif // ENABLE_TIMEZONES #endif // ENABLE_TIMEZONES
_options.useSegments = settings.value(USE_SEGMENTS_SETTING,
USE_SEGMENTS_DEFAULT).toBool();
_options.automaticPause = settings.value(AUTOMATIC_PAUSE_SETTING, _options.automaticPause = settings.value(AUTOMATIC_PAUSE_SETTING,
AUTOMATIC_PAUSE_DEFAULT).toBool(); AUTOMATIC_PAUSE_DEFAULT).toBool();
_options.pauseInterval = settings.value(PAUSE_INTERVAL_SETTING, _options.pauseInterval = settings.value(PAUSE_INTERVAL_SETTING,
@ -2250,6 +2255,7 @@ void GUI::readSettings()
Track::useDEM(_options.dataUseDEM); Track::useDEM(_options.dataUseDEM);
Track::showSecondaryElevation(_options.showSecondaryElevation); Track::showSecondaryElevation(_options.showSecondaryElevation);
Track::showSecondarySpeed(_options.showSecondarySpeed); Track::showSecondarySpeed(_options.showSecondarySpeed);
Track::useSegments(_options.useSegments);
Route::useDEM(_options.dataUseDEM); Route::useDEM(_options.dataUseDEM);
Route::showSecondaryElevation(_options.showSecondaryElevation); Route::showSecondaryElevation(_options.showSecondaryElevation);
Waypoint::useDEM(_options.dataUseDEM); Waypoint::useDEM(_options.dataUseDEM);

View File

@ -439,6 +439,9 @@ QWidget *OptionsDialog::createDataPage()
customZoneLayout->addWidget(_timeZone); customZoneLayout->addWidget(_timeZone);
#endif // ENABLE_TIMEZONES #endif // ENABLE_TIMEZONES
_useSegments = new QCheckBox(tr("Use segments"));
_useSegments->setChecked(_options->useSegments);
QWidget *sourceTab = new QWidget(); QWidget *sourceTab = new QWidget();
QVBoxLayout *sourceTabLayout = new QVBoxLayout(); QVBoxLayout *sourceTabLayout = new QVBoxLayout();
@ -477,6 +480,7 @@ QWidget *OptionsDialog::createDataPage()
#ifdef ENABLE_TIMEZONES #ifdef ENABLE_TIMEZONES
formLayout->addRow(tr("Time zone:"), zoneOptions); formLayout->addRow(tr("Time zone:"), zoneOptions);
#endif // ENABLE_TIMEZONES #endif // ENABLE_TIMEZONES
formLayout->addRow(_useSegments);
sourceTabLayout->addLayout(formLayout); sourceTabLayout->addLayout(formLayout);
#else // Q_OS_MAC #else // Q_OS_MAC
@ -485,6 +489,7 @@ QWidget *OptionsDialog::createDataPage()
#ifdef ENABLE_TIMEZONES #ifdef ENABLE_TIMEZONES
QFormLayout *timeZoneLayout = new QFormLayout(); QFormLayout *timeZoneLayout = new QFormLayout();
#endif // ENABLE_TIMEZONES #endif // ENABLE_TIMEZONES
QFormLayout *segmentsLayout = new QFormLayout();
speedLayout->addWidget(_computedSpeed); speedLayout->addWidget(_computedSpeed);
speedLayout->addWidget(_reportedSpeed); speedLayout->addWidget(_reportedSpeed);
@ -510,11 +515,14 @@ QWidget *OptionsDialog::createDataPage()
timeZoneBox->setLayout(timeZoneLayout); timeZoneBox->setLayout(timeZoneLayout);
#endif // ENABLE_TIMEZONES #endif // ENABLE_TIMEZONES
segmentsLayout->addWidget(_useSegments);
sourceTabLayout->addWidget(speedBox); sourceTabLayout->addWidget(speedBox);
sourceTabLayout->addWidget(elevationBox); sourceTabLayout->addWidget(elevationBox);
#ifdef ENABLE_TIMEZONES #ifdef ENABLE_TIMEZONES
sourceTabLayout->addWidget(timeZoneBox); sourceTabLayout->addWidget(timeZoneBox);
#endif // ENABLE_TIMEZONES #endif // ENABLE_TIMEZONES
sourceTabLayout->addLayout(segmentsLayout);
#endif // Q_OS_MAC #endif // Q_OS_MAC
sourceTabLayout->addStretch(); sourceTabLayout->addStretch();
sourceTab->setLayout(sourceTabLayout); sourceTab->setLayout(sourceTabLayout);
@ -780,6 +788,7 @@ void OptionsDialog::accept()
_options->timeZone.setCustomZone(QTimeZone(_timeZone->currentText() _options->timeZone.setCustomZone(QTimeZone(_timeZone->currentText()
.toLatin1())); .toLatin1()));
#endif // ENABLE_TIMEZONES #endif // ENABLE_TIMEZONES
_options->useSegments = _useSegments->isChecked();
qreal poiRadius = (_options->units == Imperial) qreal poiRadius = (_options->units == Imperial)
? _poiRadius->value() * MIINM : (_options->units == Nautical) ? _poiRadius->value() * MIINM : (_options->units == Nautical)

View File

@ -63,6 +63,7 @@ struct Options {
#ifdef ENABLE_TIMEZONES #ifdef ENABLE_TIMEZONES
TimeZoneInfo timeZone; TimeZoneInfo timeZone;
#endif // ENABLE_TIMEZONES #endif // ENABLE_TIMEZONES
bool useSegments;
// POI // POI
int poiRadius; int poiRadius;
// System // System
@ -157,6 +158,7 @@ private:
QRadioButton *_customZone; QRadioButton *_customZone;
QComboBox *_timeZone; QComboBox *_timeZone;
#endif // ENABLE_TIMEZONES #endif // ENABLE_TIMEZONES
QCheckBox *_useSegments;
// POI // POI
QDoubleSpinBox *_poiRadius; QDoubleSpinBox *_poiRadius;
// System // System

View File

@ -150,6 +150,8 @@
#define SHOW_SECONDARY_SPEED_SETTING "showSecondarySpeed" #define SHOW_SECONDARY_SPEED_SETTING "showSecondarySpeed"
#define SHOW_SECONDARY_SPEED_DEFAULT false #define SHOW_SECONDARY_SPEED_DEFAULT false
#define TIME_ZONE_SETTING "timeZone" #define TIME_ZONE_SETTING "timeZone"
#define USE_SEGMENTS_SETTING "useSegments"
#define USE_SEGMENTS_DEFAULT true
#define POI_RADIUS_SETTING "poiRadius" #define POI_RADIUS_SETTING "poiRadius"
#define POI_RADIUS_DEFAULT (int)(IMPERIAL_UNITS() ? MIINM : KMINM) #define POI_RADIUS_DEFAULT (int)(IMPERIAL_UNITS() ? MIINM : KMINM)
#define USE_OPENGL_SETTING "useOpenGL" #define USE_OPENGL_SETTING "useOpenGL"

View File

@ -17,7 +17,7 @@ bool Track::_useReportedSpeed = false;
bool Track::_useDEM = false; bool Track::_useDEM = false;
bool Track::_show2ndElevation = false; bool Track::_show2ndElevation = false;
bool Track::_show2ndSpeed = false; bool Track::_show2ndSpeed = false;
bool Track::_useSegments = true;
static qreal avg(const QVector<qreal> &v) static qreal avg(const QVector<qreal> &v)
{ {
@ -88,10 +88,18 @@ static GraphSegment filter(const GraphSegment &g, int window)
} }
Track::Track(const TrackData &data) : _data(data), _pause(0) Track::Track(const TrackData &data) : _pause(0)
{ {
qreal ds, dt; qreal ds, dt;
if (_useSegments)
_data = data;
else {
_data.append(SegmentData());
for (int i = 0; i < data.size(); i++)
_data[0].append(data.at(i));
}
for (int i = 0; i < _data.size(); i++) { for (int i = 0; i < _data.size(); i++) {
const SegmentData &sd = _data.at(i); const SegmentData &sd = _data.at(i);
_segments.append(Segment()); _segments.append(Segment());

View File

@ -49,10 +49,9 @@ public:
{_outlierEliminate = eliminate;} {_outlierEliminate = eliminate;}
static void useReportedSpeed(bool use) {_useReportedSpeed = use;} static void useReportedSpeed(bool use) {_useReportedSpeed = use;}
static void useDEM(bool use) {_useDEM = use;} static void useDEM(bool use) {_useDEM = use;}
static void showSecondaryElevation(bool show) static void showSecondaryElevation(bool show) {_show2ndElevation = show;}
{_show2ndElevation = show;} static void showSecondarySpeed(bool show) {_show2ndSpeed = show;}
static void showSecondarySpeed(bool show) static void useSegments(bool use) {_useSegments = use;}
{_show2ndSpeed = show;}
private: private:
struct Segment { struct Segment {
@ -87,6 +86,7 @@ private:
static bool _useDEM; static bool _useDEM;
static bool _show2ndElevation; static bool _show2ndElevation;
static bool _show2ndSpeed; static bool _show2ndSpeed;
static bool _useSegments;
}; };
#endif // TRACK_H #endif // TRACK_H