1
0
mirror of https://github.com/tumic0/GPXSee.git synced 2024-10-06 14:53:21 +02:00

Added pace info

This commit is contained in:
Martin Tůma 2018-03-10 20:25:13 +01:00
parent fd15799114
commit bcd14726f3
3 changed files with 23 additions and 7 deletions

View File

@ -1,16 +1,18 @@
#include "data/data.h" #include "data/data.h"
#include "config.h" #include "config.h"
#include "tooltip.h" #include "tooltip.h"
#include "format.h"
#include "speedgraphitem.h" #include "speedgraphitem.h"
#include "speedgraph.h" #include "speedgraph.h"
SpeedGraph::SpeedGraph(QWidget *parent) : GraphTab(parent) SpeedGraph::SpeedGraph(QWidget *parent) : GraphTab(parent)
{ {
_units = Metric;
_timeType = Total; _timeType = Total;
_showTracks = true; _showTracks = true;
setYUnits(Metric); setYUnits();
setYLabel(tr("Speed")); setYLabel(tr("Speed"));
setSliderPrecision(1); setSliderPrecision(1);
@ -19,10 +21,15 @@ SpeedGraph::SpeedGraph(QWidget *parent) : GraphTab(parent)
void SpeedGraph::setInfo() void SpeedGraph::setInfo()
{ {
if (_showTracks) { if (_showTracks) {
QString pace = Format::timeSpan((3600.0 / (avg() * yScale())), false);
QString pu = (_units == Metric) ? tr("min/km") : (_units == Imperial) ?
tr("min/mi") : tr("min/nmi");
GraphView::addInfo(tr("Average"), QString::number(avg() * yScale(), 'f', GraphView::addInfo(tr("Average"), QString::number(avg() * yScale(), 'f',
1) + UNIT_SPACE + yUnits()); 1) + UNIT_SPACE + yUnits());
GraphView::addInfo(tr("Maximum"), QString::number(max() * yScale(), 'f', GraphView::addInfo(tr("Maximum"), QString::number(max() * yScale(), 'f',
1) + UNIT_SPACE + yUnits()); 1) + UNIT_SPACE + yUnits());
GraphView::addInfo(tr("Pace"), pace + UNIT_SPACE + pu);
} else } else
clearInfo(); clearInfo();
} }
@ -77,12 +84,12 @@ void SpeedGraph::clear()
GraphView::clear(); GraphView::clear();
} }
void SpeedGraph::setYUnits(Units units) void SpeedGraph::setYUnits()
{ {
if (units == Nautical) { if (_units == Nautical) {
GraphView::setYUnits(tr("kn")); GraphView::setYUnits(tr("kn"));
setYScale(MS2KN); setYScale(MS2KN);
} else if (units == Imperial) { } else if (_units == Imperial) {
GraphView::setYUnits(tr("mi/h")); GraphView::setYUnits(tr("mi/h"));
setYScale(MS2MIH); setYScale(MS2MIH);
} else { } else {
@ -93,7 +100,9 @@ void SpeedGraph::setYUnits(Units units)
void SpeedGraph::setUnits(Units units) void SpeedGraph::setUnits(Units units)
{ {
setYUnits(units); _units = units;
setYUnits();
setInfo(); setInfo();
GraphView::setUnits(units); GraphView::setUnits(units);

View File

@ -21,13 +21,14 @@ public:
private: private:
qreal avg() const; qreal avg() const;
qreal max() const {return bounds().bottom();} qreal max() const {return bounds().bottom();}
void setYUnits(Units units); void setYUnits();
void setInfo(); void setInfo();
QList<QPointF> _avg; QList<QPointF> _avg;
QList<QPointF> _mavg; QList<QPointF> _mavg;
enum TimeType _timeType; Units _units;
TimeType _timeType;
bool _showTracks; bool _showTracks;
}; };

View File

@ -1,4 +1,5 @@
#include "tooltip.h" #include "tooltip.h"
#include "format.h"
#include "speedgraphitem.h" #include "speedgraphitem.h"
SpeedGraphItem::SpeedGraphItem(const Graph &graph, GraphType type, SpeedGraphItem::SpeedGraphItem(const Graph &graph, GraphType type,
@ -20,11 +21,16 @@ QString SpeedGraphItem::toolTip() const
? MS2KN : MS2KMH; ? MS2KN : MS2KMH;
QString su = (_units == Imperial) ? tr("mi/h") : (_units == Nautical) QString su = (_units == Imperial) ? tr("mi/h") : (_units == Nautical)
? tr("kn") : tr("km/h"); ? tr("kn") : tr("km/h");
QString pace = Format::timeSpan((3600.0 / ((_timeType == Total)
? avg() * scale : mavg() * scale)), false);
QString pu = (_units == Metric) ? tr("min/km") : (_units == Imperial) ?
tr("min/mi") : tr("min/nmi");
tt.insert(tr("Maximum"), QString::number(max() * scale, 'f', 1) tt.insert(tr("Maximum"), QString::number(max() * scale, 'f', 1)
+ UNIT_SPACE + su); + UNIT_SPACE + su);
tt.insert(tr("Average"), QString::number((_timeType == Total) tt.insert(tr("Average"), QString::number((_timeType == Total)
? avg() * scale : mavg() * scale, 'f', 1) + UNIT_SPACE + su); ? avg() * scale : mavg() * scale, 'f', 1) + UNIT_SPACE + su);
tt.insert(tr("Pace"), pace + UNIT_SPACE + pu);
return tt.toString(); return tt.toString();
} }