mirror of
https://github.com/tumic0/GPXSee.git
synced 2024-11-24 03:35:53 +01:00
Unified average speed handling
This commit is contained in:
parent
64f685cf60
commit
00ef815738
@ -1292,7 +1292,7 @@
|
||||
<translation>Rychlost</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/speedgraph.cpp" line="81"/>
|
||||
<location filename="../src/speedgraph.cpp" line="82"/>
|
||||
<source>km/h</source>
|
||||
<translation>km/h</translation>
|
||||
</message>
|
||||
@ -1307,7 +1307,7 @@
|
||||
<translation>Maximum</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/speedgraph.cpp" line="84"/>
|
||||
<location filename="../src/speedgraph.cpp" line="85"/>
|
||||
<source>mi/h</source>
|
||||
<translation>mi/h</translation>
|
||||
</message>
|
||||
@ -1315,30 +1315,25 @@
|
||||
<context>
|
||||
<name>SpeedGraphItem</name>
|
||||
<message>
|
||||
<location filename="../src/speedgraphitem.cpp" line="17"/>
|
||||
<location filename="../src/speedgraphitem.cpp" line="20"/>
|
||||
<source>km/h</source>
|
||||
<translation>km/h</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/speedgraphitem.cpp" line="17"/>
|
||||
<location filename="../src/speedgraphitem.cpp" line="20"/>
|
||||
<source>mi/h</source>
|
||||
<translation>mi/h</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/speedgraphitem.cpp" line="19"/>
|
||||
<location filename="../src/speedgraphitem.cpp" line="22"/>
|
||||
<source>Maximum</source>
|
||||
<translation>Maximum</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/speedgraphitem.cpp" line="21"/>
|
||||
<location filename="../src/speedgraphitem.cpp" line="24"/>
|
||||
<source>Average</source>
|
||||
<translation>Průměr</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/speedgraphitem.cpp" line="23"/>
|
||||
<source>Moving average</source>
|
||||
<translation>Čistý průměr</translation>
|
||||
</message>
|
||||
</context>
|
||||
<context>
|
||||
<name>TemperatureGraph</name>
|
||||
|
@ -1291,7 +1291,7 @@
|
||||
<translation>Geschwindigkeit</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/speedgraph.cpp" line="81"/>
|
||||
<location filename="../src/speedgraph.cpp" line="82"/>
|
||||
<source>km/h</source>
|
||||
<translation>km/h</translation>
|
||||
</message>
|
||||
@ -1306,7 +1306,7 @@
|
||||
<translation>Maximum</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/speedgraph.cpp" line="84"/>
|
||||
<location filename="../src/speedgraph.cpp" line="85"/>
|
||||
<source>mi/h</source>
|
||||
<translation>mi/h</translation>
|
||||
</message>
|
||||
@ -1314,30 +1314,25 @@
|
||||
<context>
|
||||
<name>SpeedGraphItem</name>
|
||||
<message>
|
||||
<location filename="../src/speedgraphitem.cpp" line="17"/>
|
||||
<location filename="../src/speedgraphitem.cpp" line="20"/>
|
||||
<source>km/h</source>
|
||||
<translation>km/h</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/speedgraphitem.cpp" line="17"/>
|
||||
<location filename="../src/speedgraphitem.cpp" line="20"/>
|
||||
<source>mi/h</source>
|
||||
<translation>mi/h</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/speedgraphitem.cpp" line="19"/>
|
||||
<location filename="../src/speedgraphitem.cpp" line="22"/>
|
||||
<source>Maximum</source>
|
||||
<translation>Maximum</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/speedgraphitem.cpp" line="21"/>
|
||||
<location filename="../src/speedgraphitem.cpp" line="24"/>
|
||||
<source>Average</source>
|
||||
<translation>Durchschnitt</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/speedgraphitem.cpp" line="23"/>
|
||||
<source>Moving average</source>
|
||||
<translation>Bewegungsdurchschnitt</translation>
|
||||
</message>
|
||||
</context>
|
||||
<context>
|
||||
<name>TemperatureGraph</name>
|
||||
|
@ -1291,7 +1291,7 @@
|
||||
<translation>Hastighet</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/speedgraph.cpp" line="81"/>
|
||||
<location filename="../src/speedgraph.cpp" line="82"/>
|
||||
<source>km/h</source>
|
||||
<translation>km/h</translation>
|
||||
</message>
|
||||
@ -1306,7 +1306,7 @@
|
||||
<translation>Max</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/speedgraph.cpp" line="84"/>
|
||||
<location filename="../src/speedgraph.cpp" line="85"/>
|
||||
<source>mi/h</source>
|
||||
<translation>mi/h</translation>
|
||||
</message>
|
||||
@ -1314,30 +1314,25 @@
|
||||
<context>
|
||||
<name>SpeedGraphItem</name>
|
||||
<message>
|
||||
<location filename="../src/speedgraphitem.cpp" line="17"/>
|
||||
<location filename="../src/speedgraphitem.cpp" line="20"/>
|
||||
<source>km/h</source>
|
||||
<translation>km/h</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/speedgraphitem.cpp" line="17"/>
|
||||
<location filename="../src/speedgraphitem.cpp" line="20"/>
|
||||
<source>mi/h</source>
|
||||
<translation>mi/h</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/speedgraphitem.cpp" line="19"/>
|
||||
<location filename="../src/speedgraphitem.cpp" line="22"/>
|
||||
<source>Maximum</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/speedgraphitem.cpp" line="21"/>
|
||||
<location filename="../src/speedgraphitem.cpp" line="24"/>
|
||||
<source>Average</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/speedgraphitem.cpp" line="23"/>
|
||||
<source>Moving average</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
</context>
|
||||
<context>
|
||||
<name>TemperatureGraph</name>
|
||||
|
@ -68,6 +68,7 @@ protected:
|
||||
void clearInfo();
|
||||
void skipColor() {_palette.nextColor();}
|
||||
|
||||
QList<GraphItem*> _graphs;
|
||||
Units _units;
|
||||
GraphType _graphType;
|
||||
|
||||
@ -103,7 +104,6 @@ private:
|
||||
InfoItem *_info;
|
||||
GridItem *_grid;
|
||||
|
||||
QList<GraphItem*> _graphs;
|
||||
QList<GraphItem*> _visible;
|
||||
QSet<int> _hide;
|
||||
QRectF _bounds;
|
||||
|
@ -39,6 +39,7 @@ void SpeedGraph::loadData(const Data &data, const QList<PathItem *> &paths)
|
||||
}
|
||||
|
||||
SpeedGraphItem *gi = new SpeedGraphItem(graph, track->movingTime());
|
||||
gi->setTimeType(_timeType);
|
||||
GraphView::addGraph(gi, paths.at(i));
|
||||
|
||||
_avg.append(QPointF(track->distance(), gi->avg()));
|
||||
@ -100,6 +101,9 @@ void SpeedGraph::setTimeType(enum TimeType type)
|
||||
{
|
||||
_timeType = type;
|
||||
|
||||
for (int i = 0; i < _graphs.size(); i++)
|
||||
static_cast<SpeedGraphItem*>(_graphs.at(i))->setTimeType(type);
|
||||
|
||||
setInfo();
|
||||
redraw();
|
||||
}
|
||||
|
@ -4,29 +4,37 @@
|
||||
SpeedGraphItem::SpeedGraphItem(const Graph &graph, qreal movingTime,
|
||||
QGraphicsItem *parent) : GraphItem(graph, parent)
|
||||
{
|
||||
_units = Metric;
|
||||
_timeType = Total;
|
||||
|
||||
_avg = graph.last().s() / graph.last().t();
|
||||
_mavg = graph.last().s() / movingTime;
|
||||
|
||||
setToolTip(toolTip(Metric));
|
||||
setToolTip(toolTip());
|
||||
}
|
||||
|
||||
QString SpeedGraphItem::toolTip(Units units) const
|
||||
QString SpeedGraphItem::toolTip() const
|
||||
{
|
||||
ToolTip tt;
|
||||
qreal scale = (units == Metric) ? MS2KMH : MS2MIH;
|
||||
QString su = (units == Metric) ? tr("km/h") : tr("mi/h");
|
||||
qreal scale = (_units == Metric) ? MS2KMH : MS2MIH;
|
||||
QString su = (_units == Metric) ? tr("km/h") : tr("mi/h");
|
||||
|
||||
tt.insert(tr("Maximum"), QString::number(max() * scale, 'f', 1)
|
||||
+ UNIT_SPACE + su);
|
||||
tt.insert(tr("Average"), QString::number(avg() * scale, 'f', 1)
|
||||
+ UNIT_SPACE + su);
|
||||
tt.insert(tr("Moving average"), QString::number(mavg() * scale, 'f', 1)
|
||||
+ UNIT_SPACE + su);
|
||||
tt.insert(tr("Average"), QString::number((_timeType == Total)
|
||||
? avg() * scale : mavg() * scale, 'f', 1) + UNIT_SPACE + su);
|
||||
|
||||
return tt.toString();
|
||||
}
|
||||
|
||||
void SpeedGraphItem::setUnits(Units units)
|
||||
{
|
||||
setToolTip(toolTip(units));
|
||||
_units = units;
|
||||
setToolTip(toolTip());
|
||||
}
|
||||
|
||||
void SpeedGraphItem::setTimeType(TimeType type)
|
||||
{
|
||||
_timeType = type;
|
||||
setToolTip(toolTip());
|
||||
}
|
||||
|
@ -1,6 +1,7 @@
|
||||
#ifndef SPEEDGRAPHITEM_H
|
||||
#define SPEEDGRAPHITEM_H
|
||||
|
||||
#include "timetype.h"
|
||||
#include "graphitem.h"
|
||||
|
||||
class SpeedGraphItem : public GraphItem
|
||||
@ -16,11 +17,15 @@ public:
|
||||
qreal mavg() const {return _mavg;}
|
||||
|
||||
void setUnits(Units units);
|
||||
void setTimeType(TimeType type);
|
||||
|
||||
private:
|
||||
QString toolTip(Units units) const;
|
||||
QString toolTip() const;
|
||||
|
||||
qreal _avg, _mavg;
|
||||
|
||||
Units _units;
|
||||
TimeType _timeType;
|
||||
};
|
||||
|
||||
#endif // SPEEDGRAPHITEM_H
|
||||
|
Loading…
Reference in New Issue
Block a user