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