Added Israleli grid projection
[GPXSee.git] / src / GUI / gearratiographitem.cpp
blobdc7decb52569daee9fb2f05d32a76340785d6002
1 #include <QMap>
2 #include <QLocale>
3 #include "tooltip.h"
4 #include "gearratiographitem.h"
7 GearRatioGraphItem::GearRatioGraphItem(const Graph &graph, GraphType type,
8 int width, const QColor &color, QGraphicsItem *parent)
9 : GraphItem(graph, type, width, color, Qt::SolidLine, parent)
11 for (int i = 0; i < graph.size(); i++) {
12 const GraphSegment &segment = graph.at(i);
13 for (int j = 1; j < segment.size(); j++) {
14 qreal dx = segment.at(j).s() - segment.at(j-1).s();
15 _map.insert(segment.at(j).y(), _map.value(segment.at(j).y()) + dx);
19 qreal key = NAN, val = NAN;
20 for (QMap<qreal, qreal>::const_iterator it = _map.constBegin();
21 it != _map.constEnd(); ++it) {
22 if (std::isnan(val) || it.value() > val) {
23 val = it.value();
24 key = it.key();
27 _top = key;
30 ToolTip GearRatioGraphItem::info(bool extended) const
32 Q_UNUSED(extended);
34 ToolTip tt;
35 QLocale l(QLocale::system());
37 tt.insert(tr("Minimum"), l.toString(min(), 'f', 2));
38 tt.insert(tr("Maximum"), l.toString(max(), 'f', 2));
39 tt.insert(tr("Most used"), l.toString(top(), 'f', 2));
41 return tt;