1
0
mirror of https://github.com/tumic0/GPXSee.git synced 2024-11-30 22:51:16 +01: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 "config.h"
#include "tooltip.h"
#include "format.h"
#include "speedgraphitem.h"
#include "speedgraph.h"
SpeedGraph::SpeedGraph(QWidget *parent) : GraphTab(parent)
{
_units = Metric;
_timeType = Total;
_showTracks = true;
setYUnits(Metric);
setYUnits();
setYLabel(tr("Speed"));
setSliderPrecision(1);
@ -19,10 +21,15 @@ SpeedGraph::SpeedGraph(QWidget *parent) : GraphTab(parent)
void SpeedGraph::setInfo()
{
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',
1) + UNIT_SPACE + yUnits());
GraphView::addInfo(tr("Maximum"), QString::number(max() * yScale(), 'f',
1) + UNIT_SPACE + yUnits());
GraphView::addInfo(tr("Pace"), pace + UNIT_SPACE + pu);
} else
clearInfo();
}
@ -77,12 +84,12 @@ void SpeedGraph::clear()
GraphView::clear();
}
void SpeedGraph::setYUnits(Units units)
void SpeedGraph::setYUnits()
{
if (units == Nautical) {
if (_units == Nautical) {
GraphView::setYUnits(tr("kn"));
setYScale(MS2KN);
} else if (units == Imperial) {
} else if (_units == Imperial) {
GraphView::setYUnits(tr("mi/h"));
setYScale(MS2MIH);
} else {
@ -93,7 +100,9 @@ void SpeedGraph::setYUnits(Units units)
void SpeedGraph::setUnits(Units units)
{
setYUnits(units);
_units = units;
setYUnits();
setInfo();
GraphView::setUnits(units);

View File

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

View File

@ -1,4 +1,5 @@
#include "tooltip.h"
#include "format.h"
#include "speedgraphitem.h"
SpeedGraphItem::SpeedGraphItem(const Graph &graph, GraphType type,
@ -20,11 +21,16 @@ QString SpeedGraphItem::toolTip() const
? MS2KN : MS2KMH;
QString su = (_units == Imperial) ? tr("mi/h") : (_units == Nautical)
? 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)
+ UNIT_SPACE + su);
tt.insert(tr("Average"), QString::number((_timeType == Total)
? avg() * scale : mavg() * scale, 'f', 1) + UNIT_SPACE + su);
tt.insert(tr("Pace"), pace + UNIT_SPACE + pu);
return tt.toString();
}