diff --git a/src/GUI/speedgraph.cpp b/src/GUI/speedgraph.cpp index 8d26073c..d9f457f7 100644 --- a/src/GUI/speedgraph.cpp +++ b/src/GUI/speedgraph.cpp @@ -64,6 +64,7 @@ GraphItem *SpeedGraph::loadGraph(const Graph &graph, const Track &track, if (primary) { _avg.append(QPointF(track.distance(), gi->avg())); _mavg.append(QPointF(track.distance(), gi->mavg())); + _max.append(QPointF(track.distance(), gi->max())); } return gi; @@ -117,6 +118,16 @@ qreal SpeedGraph::avg() const return (sum / w); } +qreal SpeedGraph::max() const +{ + qreal mv = 0; + + for (int i = 0; i < _max.size(); i++) + mv = qMax(mv, _max.at(i).y()); + + return mv; +} + void SpeedGraph::clear() { qDeleteAll(_tracks); @@ -124,6 +135,7 @@ void SpeedGraph::clear() _avg.clear(); _mavg.clear(); + _max.clear(); GraphTab::clear(); } diff --git a/src/GUI/speedgraph.h b/src/GUI/speedgraph.h index f44b7b4a..febf16be 100644 --- a/src/GUI/speedgraph.h +++ b/src/GUI/speedgraph.h @@ -26,12 +26,13 @@ private: GraphItem *loadGraph(const Graph &graph, const Track &track, const QColor &color, bool primary); qreal avg() const; - qreal max() const {return bounds().bottom();} + qreal max() const; void setYUnits(); void setInfo(); QVector _avg; QVector _mavg; + QVector _max; Units _units; TimeType _timeType;