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

Improved handlig of small-distance tracks

This commit is contained in:
Martin Tůma 2016-03-27 15:04:58 +02:00
parent c9b5e0f2cb
commit 06248457a0
8 changed files with 127 additions and 41 deletions

View File

@ -8,11 +8,12 @@ ElevationGraph::ElevationGraph(QWidget *parent) : GraphView(parent)
_ascent = 0; _ascent = 0;
_descent = 0; _descent = 0;
_units = Metric;
setYUnits();
setXLabel(tr("Distance")); setXLabel(tr("Distance"));
setYLabel(tr("Elevation")); setYLabel(tr("Elevation"));
setXUnits(tr("km"));
setYUnits(tr("m"));
setXScale(M2KM);
setMinYRange(50.0); setMinYRange(50.0);
} }
@ -58,6 +59,7 @@ void ElevationGraph::loadGPX(const GPX &gpx)
loadData(data); loadData(data);
} }
setXUnits();
addInfo(); addInfo();
} }
@ -69,19 +71,43 @@ void ElevationGraph::clear()
GraphView::clear(); GraphView::clear();
} }
void ElevationGraph::setUnits(enum Units units) void ElevationGraph::setXUnits()
{ {
if (units == Metric) { if (_units == Metric) {
setXUnits(tr("km")); if (bounds().width() < KMINM) {
setYUnits(tr("m")); GraphView::setXUnits(tr("m"));
setXScale(1);
} else {
GraphView::setXUnits(tr("km"));
setXScale(M2KM); setXScale(M2KM);
}
} else {
if (bounds().width() < MIINM) {
GraphView::setXUnits(tr("ft"));
setXScale(M2FT);
} else {
GraphView::setXUnits(tr("mi"));
setXScale(M2MI);
}
}
}
void ElevationGraph::setYUnits()
{
if (_units == Metric) {
GraphView::setYUnits(tr("m"));
setYScale(1); setYScale(1);
} else { } else {
setXUnits(tr("mi")); GraphView::setYUnits(tr("ft"));
setYUnits(tr("ft"));
setXScale(M2MI);
setYScale(M2FT); setYScale(M2FT);
} }
}
void ElevationGraph::setUnits(enum Units units)
{
_units = units;
setXUnits();
setYUnits();
clearInfo(); clearInfo();
addInfo(); addInfo();

View File

@ -23,9 +23,12 @@ public:
qreal min() const {return bounds().top();} qreal min() const {return bounds().top();}
private: private:
void setXUnits();
void setYUnits();
void addInfo(); void addInfo();
qreal _ascent, _descent; qreal _ascent, _descent;
enum Units _units;
}; };
#endif // ELEVATIONGRAPH_H #endif // ELEVATIONGRAPH_H

View File

@ -746,12 +746,21 @@ void GUI::updateStatusBarInfo()
else else
_fileNameLabel->setText(tr("%1 tracks").arg(_trackCount)); _fileNameLabel->setText(tr("%1 tracks").arg(_trackCount));
if (_imperialUnitsAction->isChecked()) if (_imperialUnitsAction->isChecked()) {
if (_distance < MIINM)
_distanceLabel->setText(QString::number(_distance * M2FT, 'f', 0)
+ UNIT_SPACE + tr("ft"));
else
_distanceLabel->setText(QString::number(_distance * M2MI, 'f', 1) _distanceLabel->setText(QString::number(_distance * M2MI, 'f', 1)
+ UNIT_SPACE + tr("mi")); + UNIT_SPACE + tr("mi"));
} else {
if (_distance < KMINM)
_distanceLabel->setText(QString::number(_distance, 'f', 0)
+ UNIT_SPACE + tr("m"));
else else
_distanceLabel->setText(QString::number(_distance * M2KM, 'f', 1) _distanceLabel->setText(QString::number(_distance * M2KM, 'f', 1)
+ UNIT_SPACE + tr("km")); + UNIT_SPACE + tr("km"));
}
_timeLabel->setText(timeSpan(_time)); _timeLabel->setText(timeSpan(_time));
} }

View File

@ -4,11 +4,11 @@
HeartRateGraph::HeartRateGraph(QWidget *parent) : GraphView(parent) HeartRateGraph::HeartRateGraph(QWidget *parent) : GraphView(parent)
{ {
_units = Metric;
setXLabel(tr("Distance")); setXLabel(tr("Distance"));
setYLabel(tr("Heart rate")); setYLabel(tr("Heart rate"));
setXUnits(tr("km"));
setYUnits(tr("1/min"));
setXScale(M2KM);
setSliderPrecision(0); setSliderPrecision(0);
} }
@ -43,6 +43,7 @@ void HeartRateGraph::loadGPX(const GPX &gpx)
loadData(data); loadData(data);
} }
setXUnits();
addInfo(); addInfo();
} }
@ -66,15 +67,31 @@ void HeartRateGraph::clear()
GraphView::clear(); GraphView::clear();
} }
void HeartRateGraph::setUnits(enum Units units) void HeartRateGraph::setXUnits()
{ {
if (units == Metric) { if (_units == Metric) {
setXUnits(tr("km")); if (bounds().width() < KMINM) {
setXScale(M2KM); GraphView::setXUnits(tr("m"));
setXScale(1);
} else { } else {
setXUnits(tr("mi")); GraphView::setXUnits(tr("km"));
setXScale(M2KM);
}
} else {
if (bounds().width() < MIINM) {
GraphView::setXUnits(tr("ft"));
setXScale(M2FT);
} else {
GraphView::setXUnits(tr("mi"));
setXScale(M2MI); setXScale(M2MI);
} }
}
}
void HeartRateGraph::setUnits(enum Units units)
{
_units = units;
setXUnits();
clearInfo(); clearInfo();
addInfo(); addInfo();

View File

@ -21,9 +21,11 @@ public:
qreal max() const {return bounds().bottom();} qreal max() const {return bounds().bottom();}
private: private:
void setXUnits();
void addInfo(); void addInfo();
QList<QPointF> _avg; QList<QPointF> _avg;
enum Units _units;
}; };
#endif // HEARTRATEGRAPH_H #endif // HEARTRATEGRAPH_H

View File

@ -5,12 +5,12 @@
SpeedGraph::SpeedGraph(QWidget *parent) : GraphView(parent) SpeedGraph::SpeedGraph(QWidget *parent) : GraphView(parent)
{ {
_units = Metric;
setYUnits();
setXLabel(tr("Distance")); setXLabel(tr("Distance"));
setYLabel(tr("Speed")); setYLabel(tr("Speed"));
setXUnits(tr("km"));
setYUnits(tr("km/h"));
setXScale(M2KM);
setYScale(MS2KMH);
setSliderPrecision(1); setSliderPrecision(1);
} }
@ -41,6 +41,7 @@ void SpeedGraph::loadGPX(const GPX &gpx)
loadData(data); loadData(data);
} }
setXUnits();
addInfo(); addInfo();
} }
@ -64,19 +65,43 @@ void SpeedGraph::clear()
GraphView::clear(); GraphView::clear();
} }
void SpeedGraph::setUnits(enum Units units) void SpeedGraph::setXUnits()
{ {
if (units == Metric) { if (_units == Metric) {
setXUnits(tr("km")); if (bounds().width() < KMINM) {
setYUnits(tr("km/h")); GraphView::setXUnits(tr("m"));
setXScale(1);
} else {
GraphView::setXUnits(tr("km"));
setXScale(M2KM); setXScale(M2KM);
}
} else {
if (bounds().width() < MIINM) {
GraphView::setXUnits(tr("ft"));
setXScale(M2FT);
} else {
GraphView::setXUnits(tr("mi"));
setXScale(M2MI);
}
}
}
void SpeedGraph::setYUnits()
{
if (_units == Metric) {
GraphView::setYUnits(tr("km/h"));
setYScale(MS2KMH); setYScale(MS2KMH);
} else { } else {
setXUnits(tr("mi")); GraphView::setYUnits(tr("mi/h"));
setYUnits(tr("mi/h"));
setXScale(M2MI);
setYScale(MS2MIH); setYScale(MS2MIH);
} }
}
void SpeedGraph::setUnits(enum Units units)
{
_units = units;
setXUnits();
setYUnits();
clearInfo(); clearInfo();
addInfo(); addInfo();

View File

@ -22,9 +22,12 @@ public:
qreal max() const {return bounds().bottom();} qreal max() const {return bounds().bottom();}
private: private:
void setXUnits();
void setYUnits();
void addInfo(); void addInfo();
QList<QPointF> _avg; QList<QPointF> _avg;
enum Units _units;
}; };
#endif // SPEEDGRAPH_H #endif // SPEEDGRAPH_H

View File

@ -13,8 +13,9 @@ enum Units {
#define MS2MIH 2.236936290000 // m/s -> mi/h #define MS2MIH 2.236936290000 // m/s -> mi/h
#define FT2MI 0.000189393939 // ft -> mi #define FT2MI 0.000189393939 // ft -> mi
#define MIINFT 5280 // 1 mi in ft
#define KMINM 1000 // 1 km in m #define KMINM 1000 // 1 km in m
#define MIINFT 5280 // 1 mi in ft
#define MIINM 1609.344 // 1mi in m
#ifdef Q_OS_WIN32 #ifdef Q_OS_WIN32
#define UNIT_SPACE " " #define UNIT_SPACE " "