From 8de6bbe4fb9c1af90705bedd4e2d03dec4cb9e79 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20T=C5=AFma?= Date: Sun, 16 Mar 2025 17:14:14 +0100 Subject: [PATCH] Fixed maximal speed info Display the maximum of all primary graphs, not the maximum of all graphs. --- src/GUI/speedgraph.cpp | 12 ++++++++++++ src/GUI/speedgraph.h | 3 ++- 2 files changed, 14 insertions(+), 1 deletion(-) 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;