3 #include "gearratiographitem.h"
4 #include "gearratiograph.h"
7 GearRatioGraph::GearRatioGraph(QWidget
*parent
) : GraphTab(parent
)
11 GraphView::setYUnits("");
12 setYLabel(tr("Gear ratio"));
14 setSliderPrecision(2);
17 GearRatioGraph::~GearRatioGraph()
22 void GearRatioGraph::setInfo()
25 QLocale
l(QLocale::system());
28 GraphView::addInfo(tr("Top"), l
.toString(top() * yScale(), 'f', 2)
29 + UNIT_SPACE
+ yUnits());
30 GraphView::addInfo(tr("Min"), l
.toString(min() * yScale(), 'f', 2)
31 + UNIT_SPACE
+ yUnits());
32 GraphView::addInfo(tr("Max"), l
.toString(max() * yScale(), 'f', 2)
33 + UNIT_SPACE
+ yUnits());
35 GraphView::addInfo(tr("Most used"), l
.toString(top() * yScale(),
36 'f', 2) + UNIT_SPACE
+ yUnits());
37 GraphView::addInfo(tr("Minimum"), l
.toString(min() * yScale(), 'f',
38 2) + UNIT_SPACE
+ yUnits());
39 GraphView::addInfo(tr("Maximum"), l
.toString(max() * yScale(), 'f',
40 2) + UNIT_SPACE
+ yUnits());
41 #endif // Q_OS_ANDROID
46 QList
<GraphItem
*> GearRatioGraph::loadData(const Data
&data
, Map
*map
)
49 QList
<GraphItem
*> graphs
;
51 for (int i
= 0; i
< data
.tracks().count(); i
++) {
52 const Graph
&graph
= data
.tracks().at(i
).ratio();
54 if (graph
.isEmpty()) {
58 GearRatioGraphItem
*gi
= new GearRatioGraphItem(graph
, _graphType
,
59 _width
, _palette
.nextColor());
65 for (QMap
<qreal
, qreal
>::const_iterator it
= gi
->map().constBegin();
66 it
!= gi
->map().constEnd(); ++it
)
67 _map
.insert(it
.key(), _map
.value(it
.key()) + it
.value());
72 for (int i
= 0; i
< data
.routes().count(); i
++) {
77 for (int i
= 0; i
< data
.areas().count(); i
++)
86 qreal
GearRatioGraph::top() const
88 qreal key
= NAN
, val
= NAN
;
90 for (QMap
<qreal
, qreal
>::const_iterator it
= _map
.constBegin();
91 it
!= _map
.constEnd(); ++it
) {
92 if (std::isnan(val
) || it
.value() > val
) {
101 void GearRatioGraph::clear()
111 void GearRatioGraph::showTracks(bool show
)
115 for (int i
= 0; i
< _tracks
.size(); i
++) {
117 addGraph(_tracks
.at(i
));
119 removeGraph(_tracks
.at(i
));