diff --git a/src/GUI/gearratiographitem.cpp b/src/GUI/gearratiographitem.cpp index db4e4006..5c128466 100644 --- a/src/GUI/gearratiographitem.cpp +++ b/src/GUI/gearratiographitem.cpp @@ -7,16 +7,11 @@ GearRatioGraphItem::GearRatioGraphItem(const Graph &graph, GraphType type, QGraphicsItem *parent) : GraphItem(graph, type, parent), _top(NAN) { - qreal val = NAN; - - for (QMap::const_iterator it = _map.constBegin(); - it != _map.constEnd(); ++it) { - if (it == _map.constBegin()) { - val = it.value(); - _top = it.key(); - } else if (it.value() > val) { - val = it.value(); - _top = it.key(); + for (int i = 0; i < graph.size(); i++) { + const GraphSegment &segment = graph.at(i); + for (int j = 1; j < segment.size(); j++) { + qreal dx = segment.at(j).s() - segment.at(j-1).s(); + _map.insert(segment.at(j).y(), _map.value(segment.at(j).y()) + dx); } }