1
0
mirror of https://github.com/tumic0/GPXSee.git synced 2024-11-28 05:34:47 +01:00

Graph items are now selecteble like path items (+ tool tips)

This commit is contained in:
Martin Tůma 2017-09-24 19:54:13 +02:00
parent 7bc83603ca
commit d3fbbecb2d
41 changed files with 954 additions and 169 deletions

View File

@ -97,7 +97,13 @@ HEADERS += src/config.h \
src/oddspinbox.h \ src/oddspinbox.h \
src/rectc.h \ src/rectc.h \
src/searchpointer.h \ src/searchpointer.h \
src/percentslider.h src/percentslider.h \
src/elevationgraphitem.h \
src/speedgraphitem.h \
src/heartrategraphitem.h \
src/temperaturegraphitem.h \
src/cadencegraphitem.h \
src/powergraphitem.h
SOURCES += src/main.cpp \ SOURCES += src/main.cpp \
src/gui.cpp \ src/gui.cpp \
src/poi.cpp \ src/poi.cpp \
@ -167,7 +173,13 @@ SOURCES += src/main.cpp \
src/albersequal.cpp \ src/albersequal.cpp \
src/oddspinbox.cpp \ src/oddspinbox.cpp \
src/rectc.cpp \ src/rectc.cpp \
src/percentslider.cpp src/percentslider.cpp \
src/elevationgraphitem.cpp \
src/speedgraphitem.cpp \
src/heartrategraphitem.cpp \
src/temperaturegraphitem.cpp \
src/cadencegraphitem.cpp \
src/powergraphitem.cpp
RESOURCES += gpxsee.qrc RESOURCES += gpxsee.qrc
TRANSLATIONS = lang/gpxsee_cs.ts \ TRANSLATIONS = lang/gpxsee_cs.ts \
lang/gpxsee_sv.ts \ lang/gpxsee_sv.ts \

BIN
lang/gpxsee_cs.qm Normal file

Binary file not shown.

View File

@ -25,6 +25,25 @@
<translation>Maximum</translation> <translation>Maximum</translation>
</message> </message>
</context> </context>
<context>
<name>CadenceGraphItem</name>
<message>
<location filename="../src/cadencegraphitem.cpp" line="20"/>
<source>Maximum</source>
<translation>Maximum</translation>
</message>
<message>
<location filename="../src/cadencegraphitem.cpp" line="21"/>
<location filename="../src/cadencegraphitem.cpp" line="23"/>
<source>1/min</source>
<translation>1/min</translation>
</message>
<message>
<location filename="../src/cadencegraphitem.cpp" line="22"/>
<source>Average</source>
<translation>Průměr</translation>
</message>
</context>
<context> <context>
<name>Data</name> <name>Data</name>
<message> <message>
@ -82,36 +101,69 @@
<translation>Výška</translation> <translation>Výška</translation>
</message> </message>
<message> <message>
<location filename="../src/elevationgraph.cpp" line="141"/> <location filename="../src/elevationgraph.cpp" line="122"/>
<source>m</source> <source>m</source>
<translation>m</translation> <translation>m</translation>
</message> </message>
<message> <message>
<location filename="../src/elevationgraph.cpp" line="58"/> <location filename="../src/elevationgraph.cpp" line="57"/>
<source>Ascent</source> <source>Ascent</source>
<translation>Stoupání</translation> <translation>Stoupání</translation>
</message> </message>
<message> <message>
<location filename="../src/elevationgraph.cpp" line="60"/> <location filename="../src/elevationgraph.cpp" line="59"/>
<source>Descent</source> <source>Descent</source>
<translation>Klesání</translation> <translation>Klesání</translation>
</message> </message>
<message> <message>
<location filename="../src/elevationgraph.cpp" line="64"/> <location filename="../src/elevationgraph.cpp" line="63"/>
<source>Minimum</source> <source>Minimum</source>
<translation>Minimum</translation> <translation>Minimum</translation>
</message> </message>
<message> <message>
<location filename="../src/elevationgraph.cpp" line="144"/> <location filename="../src/elevationgraph.cpp" line="125"/>
<source>ft</source> <source>ft</source>
<translation>ft</translation> <translation>ft</translation>
</message> </message>
<message> <message>
<location filename="../src/elevationgraph.cpp" line="62"/> <location filename="../src/elevationgraph.cpp" line="61"/>
<source>Maximum</source> <source>Maximum</source>
<translation>Maximum</translation> <translation>Maximum</translation>
</message> </message>
</context> </context>
<context>
<name>ElevationGraphItem</name>
<message>
<location filename="../src/elevationgraphitem.cpp" line="26"/>
<source>m</source>
<translation>m</translation>
</message>
<message>
<location filename="../src/elevationgraphitem.cpp" line="26"/>
<source>ft</source>
<translation>ft</translation>
</message>
<message>
<location filename="../src/elevationgraphitem.cpp" line="28"/>
<source>Ascent</source>
<translation>Stoupání</translation>
</message>
<message>
<location filename="../src/elevationgraphitem.cpp" line="30"/>
<source>Descent</source>
<translation>Klesání</translation>
</message>
<message>
<location filename="../src/elevationgraphitem.cpp" line="32"/>
<source>Maximum</source>
<translation>Maximum</translation>
</message>
<message>
<location filename="../src/elevationgraphitem.cpp" line="34"/>
<source>Minimum</source>
<translation>Minimum</translation>
</message>
</context>
<context> <context>
<name>ExportDialog</name> <name>ExportDialog</name>
<message> <message>
@ -725,12 +777,12 @@
</message> </message>
<message> <message>
<location filename="../src/graphview.cpp" line="60"/> <location filename="../src/graphview.cpp" line="60"/>
<location filename="../src/graphview.cpp" line="157"/> <location filename="../src/graphview.cpp" line="161"/>
<source>Distance</source> <source>Distance</source>
<translation>Vzdálenost</translation> <translation>Vzdálenost</translation>
</message> </message>
<message> <message>
<location filename="../src/graphview.cpp" line="159"/> <location filename="../src/graphview.cpp" line="163"/>
<source>Time</source> <source>Time</source>
<translation>Čas</translation> <translation>Čas</translation>
</message> </message>
@ -759,6 +811,25 @@
<translation>Maximum</translation> <translation>Maximum</translation>
</message> </message>
</context> </context>
<context>
<name>HeartRateGraphItem</name>
<message>
<location filename="../src/heartrategraphitem.cpp" line="20"/>
<source>Maximum</source>
<translation>Maximum</translation>
</message>
<message>
<location filename="../src/heartrategraphitem.cpp" line="21"/>
<location filename="../src/heartrategraphitem.cpp" line="23"/>
<source>1/min</source>
<translation>1/min</translation>
</message>
<message>
<location filename="../src/heartrategraphitem.cpp" line="22"/>
<source>Average</source>
<translation>Průměr</translation>
</message>
</context>
<context> <context>
<name>MapList</name> <name>MapList</name>
<message> <message>
@ -1152,6 +1223,25 @@
<translation>Maximum</translation> <translation>Maximum</translation>
</message> </message>
</context> </context>
<context>
<name>PowerGraphItem</name>
<message>
<location filename="../src/powergraphitem.cpp" line="20"/>
<source>Maximum</source>
<translation>Maximum</translation>
</message>
<message>
<location filename="../src/powergraphitem.cpp" line="21"/>
<location filename="../src/powergraphitem.cpp" line="23"/>
<source>1/min</source>
<translation>1/min</translation>
</message>
<message>
<location filename="../src/powergraphitem.cpp" line="22"/>
<source>Average</source>
<translation>Průměr</translation>
</message>
</context>
<context> <context>
<name>RouteItem</name> <name>RouteItem</name>
<message> <message>
@ -1196,32 +1286,60 @@
<context> <context>
<name>SpeedGraph</name> <name>SpeedGraph</name>
<message> <message>
<location filename="../src/speedgraph.cpp" line="13"/> <location filename="../src/speedgraph.cpp" line="14"/>
<location filename="../src/speedgraph.h" line="14"/> <location filename="../src/speedgraph.h" line="14"/>
<source>Speed</source> <source>Speed</source>
<translation>Rychlost</translation> <translation>Rychlost</translation>
</message> </message>
<message> <message>
<location filename="../src/speedgraph.cpp" line="79"/> <location filename="../src/speedgraph.cpp" line="81"/>
<source>km/h</source> <source>km/h</source>
<translation>km/h</translation> <translation>km/h</translation>
</message> </message>
<message> <message>
<location filename="../src/speedgraph.cpp" line="21"/> <location filename="../src/speedgraph.cpp" line="22"/>
<source>Average</source> <source>Average</source>
<translation>Průměr</translation> <translation>Průměr</translation>
</message> </message>
<message> <message>
<location filename="../src/speedgraph.cpp" line="23"/> <location filename="../src/speedgraph.cpp" line="24"/>
<source>Maximum</source> <source>Maximum</source>
<translation>Maximum</translation> <translation>Maximum</translation>
</message> </message>
<message> <message>
<location filename="../src/speedgraph.cpp" line="82"/> <location filename="../src/speedgraph.cpp" line="84"/>
<source>mi/h</source> <source>mi/h</source>
<translation>mi/h</translation> <translation>mi/h</translation>
</message> </message>
</context> </context>
<context>
<name>SpeedGraphItem</name>
<message>
<location filename="../src/speedgraphitem.cpp" line="17"/>
<source>km/h</source>
<translation>km/h</translation>
</message>
<message>
<location filename="../src/speedgraphitem.cpp" line="17"/>
<source>mi/h</source>
<translation>mi/h</translation>
</message>
<message>
<location filename="../src/speedgraphitem.cpp" line="19"/>
<source>Maximum</source>
<translation>Maximum</translation>
</message>
<message>
<location filename="../src/speedgraphitem.cpp" line="21"/>
<source>Average</source>
<translation>Průměr</translation>
</message>
<message>
<location filename="../src/speedgraphitem.cpp" line="23"/>
<source>Moving average</source>
<translation>Čistý průměr</translation>
</message>
</context>
<context> <context>
<name>TemperatureGraph</name> <name>TemperatureGraph</name>
<message> <message>
@ -1246,16 +1364,44 @@
<translation>Maximum</translation> <translation>Maximum</translation>
</message> </message>
<message> <message>
<location filename="../src/temperaturegraph.cpp" line="81"/> <location filename="../src/temperaturegraph.cpp" line="76"/>
<source>C</source> <source>C</source>
<translation>C</translation> <translation>C</translation>
</message> </message>
<message> <message>
<location filename="../src/temperaturegraph.cpp" line="85"/> <location filename="../src/temperaturegraph.cpp" line="80"/>
<source>F</source> <source>F</source>
<translation>F</translation> <translation>F</translation>
</message> </message>
</context> </context>
<context>
<name>TemperatureGraphItem</name>
<message>
<location filename="../src/temperaturegraphitem.cpp" line="22"/>
<source>C</source>
<translation>C</translation>
</message>
<message>
<location filename="../src/temperaturegraphitem.cpp" line="22"/>
<source>F</source>
<translation>F</translation>
</message>
<message>
<location filename="../src/temperaturegraphitem.cpp" line="24"/>
<source>Average</source>
<translation>Průměr</translation>
</message>
<message>
<location filename="../src/temperaturegraphitem.cpp" line="26"/>
<source>Maximum</source>
<translation>Maximum</translation>
</message>
<message>
<location filename="../src/temperaturegraphitem.cpp" line="28"/>
<source>Minimum</source>
<translation>Minimum</translation>
</message>
</context>
<context> <context>
<name>TrackItem</name> <name>TrackItem</name>
<message> <message>

BIN
lang/gpxsee_de.qm Normal file

Binary file not shown.

View File

@ -25,6 +25,25 @@
<translation>Maximum</translation> <translation>Maximum</translation>
</message> </message>
</context> </context>
<context>
<name>CadenceGraphItem</name>
<message>
<location filename="../src/cadencegraphitem.cpp" line="20"/>
<source>Maximum</source>
<translation>Maximum</translation>
</message>
<message>
<location filename="../src/cadencegraphitem.cpp" line="21"/>
<location filename="../src/cadencegraphitem.cpp" line="23"/>
<source>1/min</source>
<translation>1/min</translation>
</message>
<message>
<location filename="../src/cadencegraphitem.cpp" line="22"/>
<source>Average</source>
<translation>Durchschnitt</translation>
</message>
</context>
<context> <context>
<name>Data</name> <name>Data</name>
<message> <message>
@ -82,36 +101,69 @@
<translation>Höhe</translation> <translation>Höhe</translation>
</message> </message>
<message> <message>
<location filename="../src/elevationgraph.cpp" line="141"/> <location filename="../src/elevationgraph.cpp" line="122"/>
<source>m</source> <source>m</source>
<translation>m</translation> <translation>m</translation>
</message> </message>
<message> <message>
<location filename="../src/elevationgraph.cpp" line="58"/> <location filename="../src/elevationgraph.cpp" line="57"/>
<source>Ascent</source> <source>Ascent</source>
<translation>Steigung</translation> <translation>Steigung</translation>
</message> </message>
<message> <message>
<location filename="../src/elevationgraph.cpp" line="60"/> <location filename="../src/elevationgraph.cpp" line="59"/>
<source>Descent</source> <source>Descent</source>
<translation>Gefälle</translation> <translation>Gefälle</translation>
</message> </message>
<message> <message>
<location filename="../src/elevationgraph.cpp" line="64"/> <location filename="../src/elevationgraph.cpp" line="63"/>
<source>Minimum</source> <source>Minimum</source>
<translation>Minimum</translation> <translation>Minimum</translation>
</message> </message>
<message> <message>
<location filename="../src/elevationgraph.cpp" line="144"/> <location filename="../src/elevationgraph.cpp" line="125"/>
<source>ft</source> <source>ft</source>
<translation>ft</translation> <translation>ft</translation>
</message> </message>
<message> <message>
<location filename="../src/elevationgraph.cpp" line="62"/> <location filename="../src/elevationgraph.cpp" line="61"/>
<source>Maximum</source> <source>Maximum</source>
<translation>Maximum</translation> <translation>Maximum</translation>
</message> </message>
</context> </context>
<context>
<name>ElevationGraphItem</name>
<message>
<location filename="../src/elevationgraphitem.cpp" line="26"/>
<source>m</source>
<translation>m</translation>
</message>
<message>
<location filename="../src/elevationgraphitem.cpp" line="26"/>
<source>ft</source>
<translation>ft</translation>
</message>
<message>
<location filename="../src/elevationgraphitem.cpp" line="28"/>
<source>Ascent</source>
<translation>Steigung</translation>
</message>
<message>
<location filename="../src/elevationgraphitem.cpp" line="30"/>
<source>Descent</source>
<translation>Gefälle</translation>
</message>
<message>
<location filename="../src/elevationgraphitem.cpp" line="32"/>
<source>Maximum</source>
<translation>Maximum</translation>
</message>
<message>
<location filename="../src/elevationgraphitem.cpp" line="34"/>
<source>Minimum</source>
<translation>Minimum</translation>
</message>
</context>
<context> <context>
<name>ExportDialog</name> <name>ExportDialog</name>
<message> <message>
@ -724,12 +776,12 @@
</message> </message>
<message> <message>
<location filename="../src/graphview.cpp" line="60"/> <location filename="../src/graphview.cpp" line="60"/>
<location filename="../src/graphview.cpp" line="157"/> <location filename="../src/graphview.cpp" line="161"/>
<source>Distance</source> <source>Distance</source>
<translation>Distanz</translation> <translation>Distanz</translation>
</message> </message>
<message> <message>
<location filename="../src/graphview.cpp" line="159"/> <location filename="../src/graphview.cpp" line="163"/>
<source>Time</source> <source>Time</source>
<translation>Zeit</translation> <translation>Zeit</translation>
</message> </message>
@ -758,6 +810,25 @@
<translation>Maximum</translation> <translation>Maximum</translation>
</message> </message>
</context> </context>
<context>
<name>HeartRateGraphItem</name>
<message>
<location filename="../src/heartrategraphitem.cpp" line="20"/>
<source>Maximum</source>
<translation>Maximum</translation>
</message>
<message>
<location filename="../src/heartrategraphitem.cpp" line="21"/>
<location filename="../src/heartrategraphitem.cpp" line="23"/>
<source>1/min</source>
<translation>1/min</translation>
</message>
<message>
<location filename="../src/heartrategraphitem.cpp" line="22"/>
<source>Average</source>
<translation>Durchschnitt</translation>
</message>
</context>
<context> <context>
<name>MapList</name> <name>MapList</name>
<message> <message>
@ -1151,6 +1222,25 @@
<translation>Maximum</translation> <translation>Maximum</translation>
</message> </message>
</context> </context>
<context>
<name>PowerGraphItem</name>
<message>
<location filename="../src/powergraphitem.cpp" line="20"/>
<source>Maximum</source>
<translation>Maximum</translation>
</message>
<message>
<location filename="../src/powergraphitem.cpp" line="21"/>
<location filename="../src/powergraphitem.cpp" line="23"/>
<source>1/min</source>
<translation>1/min</translation>
</message>
<message>
<location filename="../src/powergraphitem.cpp" line="22"/>
<source>Average</source>
<translation>Durchschnitt</translation>
</message>
</context>
<context> <context>
<name>RouteItem</name> <name>RouteItem</name>
<message> <message>
@ -1195,32 +1285,60 @@
<context> <context>
<name>SpeedGraph</name> <name>SpeedGraph</name>
<message> <message>
<location filename="../src/speedgraph.cpp" line="13"/> <location filename="../src/speedgraph.cpp" line="14"/>
<location filename="../src/speedgraph.h" line="14"/> <location filename="../src/speedgraph.h" line="14"/>
<source>Speed</source> <source>Speed</source>
<translation>Geschwindigkeit</translation> <translation>Geschwindigkeit</translation>
</message> </message>
<message> <message>
<location filename="../src/speedgraph.cpp" line="79"/> <location filename="../src/speedgraph.cpp" line="81"/>
<source>km/h</source> <source>km/h</source>
<translation>km/h</translation> <translation>km/h</translation>
</message> </message>
<message> <message>
<location filename="../src/speedgraph.cpp" line="21"/> <location filename="../src/speedgraph.cpp" line="22"/>
<source>Average</source> <source>Average</source>
<translation>Durchschnitt</translation> <translation>Durchschnitt</translation>
</message> </message>
<message> <message>
<location filename="../src/speedgraph.cpp" line="23"/> <location filename="../src/speedgraph.cpp" line="24"/>
<source>Maximum</source> <source>Maximum</source>
<translation>Maximum</translation> <translation>Maximum</translation>
</message> </message>
<message> <message>
<location filename="../src/speedgraph.cpp" line="82"/> <location filename="../src/speedgraph.cpp" line="84"/>
<source>mi/h</source> <source>mi/h</source>
<translation>mi/h</translation> <translation>mi/h</translation>
</message> </message>
</context> </context>
<context>
<name>SpeedGraphItem</name>
<message>
<location filename="../src/speedgraphitem.cpp" line="17"/>
<source>km/h</source>
<translation>km/h</translation>
</message>
<message>
<location filename="../src/speedgraphitem.cpp" line="17"/>
<source>mi/h</source>
<translation>mi/h</translation>
</message>
<message>
<location filename="../src/speedgraphitem.cpp" line="19"/>
<source>Maximum</source>
<translation>Maximum</translation>
</message>
<message>
<location filename="../src/speedgraphitem.cpp" line="21"/>
<source>Average</source>
<translation>Durchschnitt</translation>
</message>
<message>
<location filename="../src/speedgraphitem.cpp" line="23"/>
<source>Moving average</source>
<translation>Bewegungsdurchschnitt</translation>
</message>
</context>
<context> <context>
<name>TemperatureGraph</name> <name>TemperatureGraph</name>
<message> <message>
@ -1245,16 +1363,44 @@
<translation>Maximum</translation> <translation>Maximum</translation>
</message> </message>
<message> <message>
<location filename="../src/temperaturegraph.cpp" line="81"/> <location filename="../src/temperaturegraph.cpp" line="76"/>
<source>C</source> <source>C</source>
<translation>C</translation> <translation>C</translation>
</message> </message>
<message> <message>
<location filename="../src/temperaturegraph.cpp" line="85"/> <location filename="../src/temperaturegraph.cpp" line="80"/>
<source>F</source> <source>F</source>
<translation>F</translation> <translation>F</translation>
</message> </message>
</context> </context>
<context>
<name>TemperatureGraphItem</name>
<message>
<location filename="../src/temperaturegraphitem.cpp" line="22"/>
<source>C</source>
<translation>C</translation>
</message>
<message>
<location filename="../src/temperaturegraphitem.cpp" line="22"/>
<source>F</source>
<translation>F</translation>
</message>
<message>
<location filename="../src/temperaturegraphitem.cpp" line="24"/>
<source>Average</source>
<translation>Durchschnitt</translation>
</message>
<message>
<location filename="../src/temperaturegraphitem.cpp" line="26"/>
<source>Maximum</source>
<translation>Maximum</translation>
</message>
<message>
<location filename="../src/temperaturegraphitem.cpp" line="28"/>
<source>Minimum</source>
<translation>Minimum</translation>
</message>
</context>
<context> <context>
<name>TrackItem</name> <name>TrackItem</name>
<message> <message>

BIN
lang/gpxsee_sv.qm Normal file

Binary file not shown.

View File

@ -25,6 +25,25 @@
<translation>Maximal</translation> <translation>Maximal</translation>
</message> </message>
</context> </context>
<context>
<name>CadenceGraphItem</name>
<message>
<location filename="../src/cadencegraphitem.cpp" line="20"/>
<source>Maximum</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../src/cadencegraphitem.cpp" line="21"/>
<location filename="../src/cadencegraphitem.cpp" line="23"/>
<source>1/min</source>
<translation>1/min</translation>
</message>
<message>
<location filename="../src/cadencegraphitem.cpp" line="22"/>
<source>Average</source>
<translation type="unfinished"></translation>
</message>
</context>
<context> <context>
<name>Data</name> <name>Data</name>
<message> <message>
@ -82,36 +101,69 @@
<translation>Höjd</translation> <translation>Höjd</translation>
</message> </message>
<message> <message>
<location filename="../src/elevationgraph.cpp" line="141"/> <location filename="../src/elevationgraph.cpp" line="122"/>
<source>m</source> <source>m</source>
<translation>m</translation> <translation>m</translation>
</message> </message>
<message> <message>
<location filename="../src/elevationgraph.cpp" line="58"/> <location filename="../src/elevationgraph.cpp" line="57"/>
<source>Ascent</source> <source>Ascent</source>
<translation>Stigning</translation> <translation>Stigning</translation>
</message> </message>
<message> <message>
<location filename="../src/elevationgraph.cpp" line="60"/> <location filename="../src/elevationgraph.cpp" line="59"/>
<source>Descent</source> <source>Descent</source>
<translation>Nedstigning</translation> <translation>Nedstigning</translation>
</message> </message>
<message> <message>
<location filename="../src/elevationgraph.cpp" line="64"/> <location filename="../src/elevationgraph.cpp" line="63"/>
<source>Minimum</source> <source>Minimum</source>
<translation>Minimum</translation> <translation>Minimum</translation>
</message> </message>
<message> <message>
<location filename="../src/elevationgraph.cpp" line="144"/> <location filename="../src/elevationgraph.cpp" line="125"/>
<source>ft</source> <source>ft</source>
<translation>ft</translation> <translation>ft</translation>
</message> </message>
<message> <message>
<location filename="../src/elevationgraph.cpp" line="62"/> <location filename="../src/elevationgraph.cpp" line="61"/>
<source>Maximum</source> <source>Maximum</source>
<translation>Maximum</translation> <translation>Maximum</translation>
</message> </message>
</context> </context>
<context>
<name>ElevationGraphItem</name>
<message>
<location filename="../src/elevationgraphitem.cpp" line="26"/>
<source>m</source>
<translation>m</translation>
</message>
<message>
<location filename="../src/elevationgraphitem.cpp" line="26"/>
<source>ft</source>
<translation>ft</translation>
</message>
<message>
<location filename="../src/elevationgraphitem.cpp" line="28"/>
<source>Ascent</source>
<translation>Stigning</translation>
</message>
<message>
<location filename="../src/elevationgraphitem.cpp" line="30"/>
<source>Descent</source>
<translation>Nedstigning</translation>
</message>
<message>
<location filename="../src/elevationgraphitem.cpp" line="32"/>
<source>Maximum</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../src/elevationgraphitem.cpp" line="34"/>
<source>Minimum</source>
<translation type="unfinished"></translation>
</message>
</context>
<context> <context>
<name>ExportDialog</name> <name>ExportDialog</name>
<message> <message>
@ -724,12 +776,12 @@
</message> </message>
<message> <message>
<location filename="../src/graphview.cpp" line="60"/> <location filename="../src/graphview.cpp" line="60"/>
<location filename="../src/graphview.cpp" line="157"/> <location filename="../src/graphview.cpp" line="161"/>
<source>Distance</source> <source>Distance</source>
<translation>Avstånd</translation> <translation>Avstånd</translation>
</message> </message>
<message> <message>
<location filename="../src/graphview.cpp" line="159"/> <location filename="../src/graphview.cpp" line="163"/>
<source>Time</source> <source>Time</source>
<translation>Tid</translation> <translation>Tid</translation>
</message> </message>
@ -758,6 +810,25 @@
<translation>Max</translation> <translation>Max</translation>
</message> </message>
</context> </context>
<context>
<name>HeartRateGraphItem</name>
<message>
<location filename="../src/heartrategraphitem.cpp" line="20"/>
<source>Maximum</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../src/heartrategraphitem.cpp" line="21"/>
<location filename="../src/heartrategraphitem.cpp" line="23"/>
<source>1/min</source>
<translation>1/min</translation>
</message>
<message>
<location filename="../src/heartrategraphitem.cpp" line="22"/>
<source>Average</source>
<translation type="unfinished"></translation>
</message>
</context>
<context> <context>
<name>MapList</name> <name>MapList</name>
<message> <message>
@ -1151,6 +1222,25 @@
<translation>Max</translation> <translation>Max</translation>
</message> </message>
</context> </context>
<context>
<name>PowerGraphItem</name>
<message>
<location filename="../src/powergraphitem.cpp" line="20"/>
<source>Maximum</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../src/powergraphitem.cpp" line="21"/>
<location filename="../src/powergraphitem.cpp" line="23"/>
<source>1/min</source>
<translation>1/min</translation>
</message>
<message>
<location filename="../src/powergraphitem.cpp" line="22"/>
<source>Average</source>
<translation type="unfinished"></translation>
</message>
</context>
<context> <context>
<name>RouteItem</name> <name>RouteItem</name>
<message> <message>
@ -1195,32 +1285,60 @@
<context> <context>
<name>SpeedGraph</name> <name>SpeedGraph</name>
<message> <message>
<location filename="../src/speedgraph.cpp" line="13"/> <location filename="../src/speedgraph.cpp" line="14"/>
<location filename="../src/speedgraph.h" line="14"/> <location filename="../src/speedgraph.h" line="14"/>
<source>Speed</source> <source>Speed</source>
<translation>Hastighet</translation> <translation>Hastighet</translation>
</message> </message>
<message> <message>
<location filename="../src/speedgraph.cpp" line="79"/> <location filename="../src/speedgraph.cpp" line="81"/>
<source>km/h</source> <source>km/h</source>
<translation>km/h</translation> <translation>km/h</translation>
</message> </message>
<message> <message>
<location filename="../src/speedgraph.cpp" line="21"/> <location filename="../src/speedgraph.cpp" line="22"/>
<source>Average</source> <source>Average</source>
<translation>Medel</translation> <translation>Medel</translation>
</message> </message>
<message> <message>
<location filename="../src/speedgraph.cpp" line="23"/> <location filename="../src/speedgraph.cpp" line="24"/>
<source>Maximum</source> <source>Maximum</source>
<translation>Max</translation> <translation>Max</translation>
</message> </message>
<message> <message>
<location filename="../src/speedgraph.cpp" line="82"/> <location filename="../src/speedgraph.cpp" line="84"/>
<source>mi/h</source> <source>mi/h</source>
<translation>mi/h</translation> <translation>mi/h</translation>
</message> </message>
</context> </context>
<context>
<name>SpeedGraphItem</name>
<message>
<location filename="../src/speedgraphitem.cpp" line="17"/>
<source>km/h</source>
<translation>km/h</translation>
</message>
<message>
<location filename="../src/speedgraphitem.cpp" line="17"/>
<source>mi/h</source>
<translation>mi/h</translation>
</message>
<message>
<location filename="../src/speedgraphitem.cpp" line="19"/>
<source>Maximum</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../src/speedgraphitem.cpp" line="21"/>
<source>Average</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../src/speedgraphitem.cpp" line="23"/>
<source>Moving average</source>
<translation type="unfinished"></translation>
</message>
</context>
<context> <context>
<name>TemperatureGraph</name> <name>TemperatureGraph</name>
<message> <message>
@ -1245,16 +1363,44 @@
<translation>Max</translation> <translation>Max</translation>
</message> </message>
<message> <message>
<location filename="../src/temperaturegraph.cpp" line="81"/> <location filename="../src/temperaturegraph.cpp" line="76"/>
<source>C</source> <source>C</source>
<translation>C</translation> <translation>C</translation>
</message> </message>
<message> <message>
<location filename="../src/temperaturegraph.cpp" line="85"/> <location filename="../src/temperaturegraph.cpp" line="80"/>
<source>F</source> <source>F</source>
<translation>F</translation> <translation>F</translation>
</message> </message>
</context> </context>
<context>
<name>TemperatureGraphItem</name>
<message>
<location filename="../src/temperaturegraphitem.cpp" line="22"/>
<source>C</source>
<translation>C</translation>
</message>
<message>
<location filename="../src/temperaturegraphitem.cpp" line="22"/>
<source>F</source>
<translation>F</translation>
</message>
<message>
<location filename="../src/temperaturegraphitem.cpp" line="24"/>
<source>Average</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../src/temperaturegraphitem.cpp" line="26"/>
<source>Maximum</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../src/temperaturegraphitem.cpp" line="28"/>
<source>Minimum</source>
<translation type="unfinished"></translation>
</message>
</context>
<context> <context>
<name>TrackItem</name> <name>TrackItem</name>
<message> <message>

View File

@ -1,10 +1,10 @@
#include "data.h" #include "data.h"
#include "cadencegraphitem.h"
#include "cadencegraph.h" #include "cadencegraph.h"
CadenceGraph::CadenceGraph(QWidget *parent) : GraphTab(parent) CadenceGraph::CadenceGraph(QWidget *parent) : GraphTab(parent)
{ {
_units = Metric;
_showTracks = true; _showTracks = true;
GraphView::setYUnits(tr("1/min")); GraphView::setYUnits(tr("1/min"));
@ -28,21 +28,16 @@ void CadenceGraph::loadData(const Data &data, const QList<PathItem *> &paths)
{ {
for (int i = 0; i < data.tracks().count(); i++) { for (int i = 0; i < data.tracks().count(); i++) {
const Graph &graph = data.tracks().at(i)->cadence(); const Graph &graph = data.tracks().at(i)->cadence();
qreal sum = 0, w = 0;
if (graph.size() < 2) { if (graph.size() < 2) {
skipColor(); skipColor();
continue; continue;
} }
for (int j = 1; j < graph.size(); j++) { CadenceGraphItem *gi = new CadenceGraphItem(graph);
qreal ds = graph.at(j).s() - graph.at(j-1).s(); GraphView::addGraph(gi, paths.at(i));
sum += graph.at(j).y() * ds;
w += ds;
}
_avg.append(QPointF(data.tracks().at(i)->distance(), sum/w));
GraphView::loadGraph(graph, paths.at(i)); _avg.append(QPointF(data.tracks().at(i)->distance(), gi->avg()));
} }
for (int i = 0; i < data.routes().count(); i++) for (int i = 0; i < data.routes().count(); i++)

View File

@ -23,7 +23,6 @@ private:
QList<QPointF> _avg; QList<QPointF> _avg;
enum Units _units;
bool _showTracks; bool _showTracks;
}; };

26
src/cadencegraphitem.cpp Normal file
View File

@ -0,0 +1,26 @@
#include "tooltip.h"
#include "cadencegraphitem.h"
CadenceGraphItem::CadenceGraphItem(const Graph &graph, QGraphicsItem *parent)
: GraphItem(graph, parent)
{
qreal sum = 0;
for (int j = 1; j < graph.size(); j++)
sum += graph.at(j).y() * (graph.at(j).s() - graph.at(j-1).s());
_avg = sum/graph.last().s();
setToolTip(toolTip());
}
QString CadenceGraphItem::toolTip() const
{
ToolTip tt;
tt.insert(tr("Maximum"), QString::number(max(), 'f', 1)
+ UNIT_SPACE + tr("1/min"));
tt.insert(tr("Average"), QString::number(avg(), 'f', 1)
+ UNIT_SPACE + tr("1/min"));
return tt.toString();
}

20
src/cadencegraphitem.h Normal file
View File

@ -0,0 +1,20 @@
#ifndef CADENCEGRAPHITEM_H
#define CADENCEGRAPHITEM_H
#include "graphitem.h"
class CadenceGraphItem : public GraphItem
{
public:
CadenceGraphItem(const Graph &graph, QGraphicsItem *parent = 0);
qreal max() const {return -bounds().top();}
qreal avg() const {return _avg;}
private:
QString toolTip() const;
qreal _avg;
};
#endif // CADENCEGRAPHITEM_H

View File

@ -1,6 +1,8 @@
#include <cmath> #include <cmath>
#include "config.h" #include "config.h"
#include "data.h" #include "data.h"
#include "tooltip.h"
#include "elevationgraphitem.h"
#include "elevationgraph.h" #include "elevationgraph.h"
@ -42,11 +44,8 @@ ElevationGraph::ElevationGraph(QWidget *parent) : GraphTab(parent)
_showRoutes = true; _showRoutes = true;
_showTracks = true; _showTracks = true;
_units = Metric;
setYUnits(); setYUnits();
setYLabel(tr("Elevation")); setYLabel(tr("Elevation"));
setMinYRange(50.0); setMinYRange(50.0);
} }
@ -68,43 +67,25 @@ void ElevationGraph::setInfo()
void ElevationGraph::loadGraph(const Graph &graph, Type type, PathItem *path) void ElevationGraph::loadGraph(const Graph &graph, Type type, PathItem *path)
{ {
qreal ascent = 0, descent = 0;
qreal min, max;
if (graph.size() < 2) { if (graph.size() < 2) {
skipColor(); skipColor();
return; return;
} }
max = min = graph.at(0).y(); ElevationGraphItem *gi = new ElevationGraphItem(graph);
for (int j = 1; j < graph.size(); j++) { GraphView::addGraph(gi, path, type);
qreal cur = graph.at(j).y();
qreal prev = graph.at(j-1).y();
if (cur > prev)
ascent += cur - prev;
if (cur < prev)
descent += prev - cur;
if (cur < min)
min = cur;
if (cur > max)
max = cur;
}
if (type == Track) { if (type == Track) {
_trackAscent += ascent; _trackAscent += gi->ascent();
_trackDescent += descent; _trackDescent += gi->descent();
_trackMax = nMax(_trackMax, max); _trackMax = nMax(_trackMax, gi->max());
_trackMin = nMin(_trackMin, min); _trackMin = nMin(_trackMin, gi->min());
} else { } else {
_routeAscent += ascent; _routeAscent += gi->ascent();
_routeDescent += descent; _routeDescent += gi->descent();
_routeMax = nMax(_routeMax, max); _routeMax = nMax(_routeMax, gi->max());
_routeMin = nMin(_routeMin, min); _routeMin = nMin(_routeMin, gi->min());
} }
GraphView::loadGraph(graph, path, type);
} }
void ElevationGraph::loadData(const Data &data, const QList<PathItem *> &paths) void ElevationGraph::loadData(const Data &data, const QList<PathItem *> &paths)
@ -148,11 +129,10 @@ void ElevationGraph::setYUnits()
void ElevationGraph::setUnits(enum Units units) void ElevationGraph::setUnits(enum Units units)
{ {
_units = units; GraphView::setUnits(units);
setYUnits(); setYUnits();
setInfo(); setInfo();
GraphView::setUnits(units);
redraw(); redraw();
} }

View File

@ -35,7 +35,6 @@ private:
qreal _trackMax, _routeMax; qreal _trackMax, _routeMax;
qreal _trackMin, _routeMin; qreal _trackMin, _routeMin;
enum Units _units;
bool _showTracks, _showRoutes; bool _showTracks, _showRoutes;
}; };

View File

@ -0,0 +1,43 @@
#include "tooltip.h"
#include "elevationgraphitem.h"
ElevationGraphItem::ElevationGraphItem(const Graph &graph, QGraphicsItem *parent)
: GraphItem(graph, parent)
{
_ascent = _descent = 0;
for (int j = 1; j < graph.size(); j++) {
qreal cur = graph.at(j).y();
qreal prev = graph.at(j-1).y();
if (cur > prev)
_ascent += cur - prev;
if (cur < prev)
_descent += prev - cur;
}
setToolTip(toolTip(Metric));
}
QString ElevationGraphItem::toolTip(Units units) const
{
ToolTip tt;
qreal scale = (units == Metric) ? 1.0 : M2FT;
QString su = (units == Metric) ? tr("m") : tr("ft");
tt.insert(tr("Ascent"), QString::number(ascent() * scale, 'f', 0)
+ UNIT_SPACE + su);
tt.insert(tr("Descent"), QString::number(descent() * scale, 'f', 0)
+ UNIT_SPACE + su);
tt.insert(tr("Maximum"), QString::number(max() * scale, 'f', 0)
+ UNIT_SPACE + su);
tt.insert(tr("Minimum"), QString::number(min() * scale, 'f', 0)
+ UNIT_SPACE + su);
return tt.toString();
}
void ElevationGraphItem::setUnits(Units units)
{
setToolTip(toolTip(units));
}

24
src/elevationgraphitem.h Normal file
View File

@ -0,0 +1,24 @@
#ifndef ELEVATIONGRAPHITEM_H
#define ELEVATIONGRAPHITEM_H
#include "graphitem.h"
class ElevationGraphItem : public GraphItem
{
public:
ElevationGraphItem(const Graph &graph, QGraphicsItem *parent = 0);
qreal ascent() const {return _ascent;}
qreal descent() const {return _descent;}
qreal min() const {return -bounds().bottom();}
qreal max() const {return -bounds().top();}
void setUnits(Units units);
private:
QString toolTip(Units units) const;
qreal _ascent, _descent;
};
#endif // ELEVATIONGRAPHITEM_H

View File

@ -25,7 +25,17 @@ GraphItem::GraphItem(const Graph &graph, QGraphicsItem *parent)
setZValue(1.0); setZValue(1.0);
updatePath(); updatePath();
updateShape();
updateBounds(); updateBounds();
setAcceptHoverEvents(true);
}
void GraphItem::updateShape()
{
QPainterPathStroker s;
s.setWidth(_width + 1);
_shape = s.createStroke(_path);
} }
void GraphItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, void GraphItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *option,
@ -50,6 +60,7 @@ void GraphItem::setGraphType(GraphType type)
_type = type; _type = type;
updatePath(); updatePath();
updateShape();
updateBounds(); updateBounds();
} }
@ -65,6 +76,8 @@ void GraphItem::setWidth(int width)
_width = width; _width = width;
_pen.setWidth(width); _pen.setWidth(width);
updateShape();
} }
qreal GraphItem::yAtX(qreal x) qreal GraphItem::yAtX(qreal x)
@ -143,9 +156,9 @@ void GraphItem::emitSliderPositionChanged(qreal pos)
emit sliderPositionChanged(pos); emit sliderPositionChanged(pos);
} }
void GraphItem::selected(bool selected) void GraphItem::hover(bool hover)
{ {
if (selected) { if (hover) {
_pen.setWidth(_width + 1); _pen.setWidth(_width + 1);
setZValue(zValue() + 1.0); setZValue(zValue() + 1.0);
} else { } else {
@ -165,6 +178,7 @@ void GraphItem::setScale(qreal sx, qreal sy)
_sx = sx; _sy = sy; _sx = sx; _sy = sy;
updatePath(); updatePath();
updateShape();
} }
void GraphItem::updatePath() void GraphItem::updatePath()
@ -199,3 +213,25 @@ void GraphItem::updateBounds()
_bounds = QRectF(QPointF(left, top), QPointF(right, bottom)); _bounds = QRectF(QPointF(left, top), QPointF(right, bottom));
} }
void GraphItem::hoverEnterEvent(QGraphicsSceneHoverEvent *event)
{
Q_UNUSED(event);
_pen.setWidthF(_width + 1);
setZValue(zValue() + 1.0);
update();
emit selected(true);
}
void GraphItem::hoverLeaveEvent(QGraphicsSceneHoverEvent *event)
{
Q_UNUSED(event);
_pen.setWidthF(_width);
setZValue(zValue() - 1.0);
update();
emit selected(false);
}

View File

@ -3,6 +3,7 @@
#include <QGraphicsObject> #include <QGraphicsObject>
#include <QPen> #include <QPen>
#include "units.h"
#include "graph.h" #include "graph.h"
class GraphItem : public QGraphicsObject class GraphItem : public QGraphicsObject
@ -12,8 +13,8 @@ class GraphItem : public QGraphicsObject
public: public:
GraphItem(const Graph &graph, QGraphicsItem *parent = 0); GraphItem(const Graph &graph, QGraphicsItem *parent = 0);
QRectF boundingRect() const QPainterPath shape() const {return _shape;}
{return _path.boundingRect();} QRectF boundingRect() const {return _shape.boundingRect();}
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, void paint(QPainter *painter, const QStyleOptionGraphicsItem *option,
QWidget *widget); QWidget *widget);
@ -29,15 +30,22 @@ public:
qreal yAtX(qreal x); qreal yAtX(qreal x);
qreal distanceAtTime(qreal time); qreal distanceAtTime(qreal time);
virtual void setUnits(Units units) {Q_UNUSED(units);}
signals: signals:
void sliderPositionChanged(qreal); void sliderPositionChanged(qreal);
void selected(bool);
public slots: public slots:
void emitSliderPositionChanged(qreal); void emitSliderPositionChanged(qreal);
void selected(bool selected); void hover(bool hover);
private: private:
void hoverEnterEvent(QGraphicsSceneHoverEvent *event);
void hoverLeaveEvent(QGraphicsSceneHoverEvent *event);
void updatePath(); void updatePath();
void updateShape();
void updateBounds(); void updateBounds();
int _id; int _id;
@ -48,6 +56,7 @@ private:
GraphType _type; GraphType _type;
QPainterPath _path; QPainterPath _path;
QPainterPath _shape;
QRectF _bounds; QRectF _bounds;
qreal _sx, _sy; qreal _sx, _sy;

View File

@ -139,6 +139,10 @@ void GraphView::setXUnits()
void GraphView::setUnits(Units units) void GraphView::setUnits(Units units)
{ {
_units = units; _units = units;
for (int i = 0; i < _graphs.count(); i++)
_graphs.at(i)->setUnits(units);
setXUnits(); setXUnits();
} }
@ -167,29 +171,27 @@ void GraphView::showGrid(bool show)
_grid->setVisible(show); _grid->setVisible(show);
} }
void GraphView::loadGraph(const Graph &graph, PathItem *path, int id) void GraphView::addGraph(GraphItem *graph, PathItem *path, int id)
{ {
if (graph.size() < 2) graph->setUnits(_units);
return; graph->setGraphType(_graphType);
graph->setId(id);
graph->setColor(_palette.nextColor());
graph->setWidth(_width);
GraphItem *gi = new GraphItem(graph); connect(this, SIGNAL(sliderPositionChanged(qreal)), graph,
gi->setGraphType(_graphType);
gi->setId(id);
gi->setColor(_palette.nextColor());
gi->setWidth(_width);
connect(this, SIGNAL(sliderPositionChanged(qreal)), gi,
SLOT(emitSliderPositionChanged(qreal))); SLOT(emitSliderPositionChanged(qreal)));
connect(gi, SIGNAL(sliderPositionChanged(qreal)), path, connect(graph, SIGNAL(sliderPositionChanged(qreal)), path,
SLOT(moveMarker(qreal))); SLOT(moveMarker(qreal)));
connect(path, SIGNAL(selected(bool)), gi, SLOT(selected(bool))); connect(path, SIGNAL(selected(bool)), graph, SLOT(hover(bool)));
connect(graph, SIGNAL(selected(bool)), path, SLOT(hover(bool)));
_graphs.append(gi); _graphs.append(graph);
if (!_hide.contains(id)) { if (!_hide.contains(id)) {
_visible.append(gi); _visible.append(graph);
_scene->addItem(gi); _scene->addItem(graph);
_bounds |= gi->bounds(); _bounds |= graph->bounds();
setXUnits(); setXUnits();
} }
} }

View File

@ -4,9 +4,9 @@
#include <QGraphicsView> #include <QGraphicsView>
#include <QList> #include <QList>
#include <QSet> #include <QSet>
#include "graph.h"
#include "palette.h" #include "palette.h"
#include "units.h" #include "units.h"
#include "graph.h"
class AxisItem; class AxisItem;
@ -25,7 +25,7 @@ public:
GraphView(QWidget *parent = 0); GraphView(QWidget *parent = 0);
~GraphView(); ~GraphView();
void loadGraph(const Graph &graph, PathItem *path, int id = 0); void addGraph(GraphItem *graph, PathItem *path, int id = 0);
int count() const {return _graphs.count();} int count() const {return _graphs.count();}
void redraw(); void redraw();
void clear(); void clear();
@ -68,6 +68,9 @@ protected:
void clearInfo(); void clearInfo();
void skipColor() {_palette.nextColor();} void skipColor() {_palette.nextColor();}
Units _units;
GraphType _graphType;
private slots: private slots:
void emitSliderPositionChanged(const QPointF &pos); void emitSliderPositionChanged(const QPointF &pos);
void newSliderPosition(const QPointF &pos); void newSliderPosition(const QPointF &pos);
@ -106,9 +109,6 @@ private:
QRectF _bounds; QRectF _bounds;
Palette _palette; Palette _palette;
int _width; int _width;
Units _units;
GraphType _graphType;
}; };
#endif // GRAPHVIEW_H #endif // GRAPHVIEW_H

View File

@ -1,10 +1,10 @@
#include "data.h" #include "data.h"
#include "heartrategraphitem.h"
#include "heartrategraph.h" #include "heartrategraph.h"
HeartRateGraph::HeartRateGraph(QWidget *parent) : GraphTab(parent) HeartRateGraph::HeartRateGraph(QWidget *parent) : GraphTab(parent)
{ {
_units = Metric;
_showTracks = true; _showTracks = true;
GraphView::setYUnits(tr("1/min")); GraphView::setYUnits(tr("1/min"));
@ -28,21 +28,16 @@ void HeartRateGraph::loadData(const Data &data, const QList<PathItem *> &paths)
{ {
for (int i = 0; i < data.tracks().count(); i++) { for (int i = 0; i < data.tracks().count(); i++) {
const Graph &graph = data.tracks().at(i)->heartRate(); const Graph &graph = data.tracks().at(i)->heartRate();
qreal sum = 0, w = 0;
if (graph.size() < 2) { if (graph.size() < 2) {
skipColor(); skipColor();
continue; continue;
} }
for (int j = 1; j < graph.size(); j++) { HeartRateGraphItem *gi = new HeartRateGraphItem(graph);
qreal ds = graph.at(j).s() - graph.at(j-1).s(); GraphView::addGraph(gi, paths.at(i));
sum += graph.at(j).y() * ds;
w += ds;
}
_avg.append(QPointF(data.tracks().at(i)->distance(), sum/w));
GraphView::loadGraph(graph, paths.at(i)); _avg.append(QPointF(data.tracks().at(i)->distance(), gi->avg()));
} }
for (int i = 0; i < data.routes().count(); i++) for (int i = 0; i < data.routes().count(); i++)

View File

@ -22,7 +22,6 @@ private:
QList<QPointF> _avg; QList<QPointF> _avg;
enum Units _units;
bool _showTracks; bool _showTracks;
}; };

View File

@ -0,0 +1,26 @@
#include "tooltip.h"
#include "heartrategraphitem.h"
HeartRateGraphItem::HeartRateGraphItem(const Graph &graph, QGraphicsItem *parent)
: GraphItem(graph, parent)
{
qreal sum = 0;
for (int j = 1; j < graph.size(); j++)
sum += graph.at(j).y() * (graph.at(j).s() - graph.at(j-1).s());
_avg = sum/graph.last().s();
setToolTip(toolTip());
}
QString HeartRateGraphItem::toolTip() const
{
ToolTip tt;
tt.insert(tr("Maximum"), QString::number(max(), 'f', 0)
+ UNIT_SPACE + tr("1/min"));
tt.insert(tr("Average"), QString::number(avg(), 'f', 0)
+ UNIT_SPACE + tr("1/min"));
return tt.toString();
}

20
src/heartrategraphitem.h Normal file
View File

@ -0,0 +1,20 @@
#ifndef HEARTRATEGRAPHITEM_H
#define HEARTRATEGRAPHITEM_H
#include "graphitem.h"
class HeartRateGraphItem : public GraphItem
{
public:
HeartRateGraphItem(const Graph &graph, QGraphicsItem *parent = 0);
qreal max() const {return -bounds().top();}
qreal avg() const {return _avg;}
private:
QString toolTip() const;
qreal _avg;
};
#endif // HEARTRATEGRAPHITEM_H

View File

@ -154,6 +154,19 @@ void PathItem::moveMarker(qreal distance)
_marker->setVisible(false); _marker->setVisible(false);
} }
void PathItem::hover(bool hover)
{
if (hover) {
_pen.setWidth(_width + 1);
setZValue(zValue() + 1.0);
} else {
_pen.setWidth(_width);
setZValue(zValue() - 1.0);
}
update();
}
void PathItem::hoverEnterEvent(QGraphicsSceneHoverEvent *event) void PathItem::hoverEnterEvent(QGraphicsSceneHoverEvent *event)
{ {
Q_UNUSED(event); Q_UNUSED(event);

View File

@ -32,6 +32,7 @@ public:
public slots: public slots:
void moveMarker(qreal distance); void moveMarker(qreal distance);
void hover(bool hover);
signals: signals:
void selected(bool); void selected(bool);

View File

@ -1,10 +1,10 @@
#include "data.h" #include "data.h"
#include "powergraphitem.h"
#include "powergraph.h" #include "powergraph.h"
PowerGraph::PowerGraph(QWidget *parent) : GraphTab(parent) PowerGraph::PowerGraph(QWidget *parent) : GraphTab(parent)
{ {
_units = Metric;
_showTracks = true; _showTracks = true;
GraphView::setYUnits(tr("W")); GraphView::setYUnits(tr("W"));
@ -28,21 +28,16 @@ void PowerGraph::loadData(const Data &data, const QList<PathItem *> &paths)
{ {
for (int i = 0; i < data.tracks().count(); i++) { for (int i = 0; i < data.tracks().count(); i++) {
const Graph &graph = data.tracks().at(i)->power(); const Graph &graph = data.tracks().at(i)->power();
qreal sum = 0, w = 0;
if (graph.size() < 2) { if (graph.size() < 2) {
skipColor(); skipColor();
continue; continue;
} }
for (int j = 1; j < graph.size(); j++) { PowerGraphItem *gi = new PowerGraphItem(graph);
qreal ds = graph.at(j).s() - graph.at(j-1).s(); GraphView::addGraph(gi, paths.at(i));
sum += graph.at(j).y() * ds;
w += ds;
}
_avg.append(QPointF(data.tracks().at(i)->distance(), sum/w));
GraphView::loadGraph(graph, paths.at(i)); _avg.append(QPointF(data.tracks().at(i)->distance(), gi->avg()));
} }
for (int i = 0; i < data.routes().count(); i++) for (int i = 0; i < data.routes().count(); i++)

View File

@ -22,7 +22,6 @@ private:
QList<QPointF> _avg; QList<QPointF> _avg;
enum Units _units;
bool _showTracks; bool _showTracks;
}; };

26
src/powergraphitem.cpp Normal file
View File

@ -0,0 +1,26 @@
#include "tooltip.h"
#include "powergraphitem.h"
PowerGraphItem::PowerGraphItem(const Graph &graph, QGraphicsItem *parent)
: GraphItem(graph, parent)
{
qreal sum = 0;
for (int j = 1; j < graph.size(); j++)
sum += graph.at(j).y() * (graph.at(j).s() - graph.at(j-1).s());
_avg = sum/graph.last().s();
setToolTip(toolTip());
}
QString PowerGraphItem::toolTip() const
{
ToolTip tt;
tt.insert(tr("Maximum"), QString::number(max(), 'f', 1)
+ UNIT_SPACE + tr("1/min"));
tt.insert(tr("Average"), QString::number(avg(), 'f', 1)
+ UNIT_SPACE + tr("1/min"));
return tt.toString();
}

20
src/powergraphitem.h Normal file
View File

@ -0,0 +1,20 @@
#ifndef POWERGRAPHITEM_H
#define POWERGRAPHITEM_H
#include "graphitem.h"
class PowerGraphItem : public GraphItem
{
public:
PowerGraphItem(const Graph &graph, QGraphicsItem *parent = 0);
qreal max() const {return -bounds().top();}
qreal avg() const {return _avg;}
private:
QString toolTip() const;
qreal _avg;
};
#endif // POWERGRAPHITEM_H

View File

@ -7,7 +7,7 @@
#include "routeitem.h" #include "routeitem.h"
QString RouteItem::toolTip(Units units) QString RouteItem::toolTip(Units units) const
{ {
ToolTip tt; ToolTip tt;

View File

@ -14,7 +14,6 @@ class RouteItem : public PathItem
public: public:
RouteItem(const Route &route, Map *map, QGraphicsItem *parent = 0); RouteItem(const Route &route, Map *map, QGraphicsItem *parent = 0);
//void setScale(qreal scale);
void setMap(Map *map); void setMap(Map *map);
void setUnits(Units units); void setUnits(Units units);
@ -22,7 +21,7 @@ public:
void showWaypointLabels(bool show); void showWaypointLabels(bool show);
private: private:
QString toolTip(Units units); QString toolTip(Units units) const;
QString _name; QString _name;
QString _desc; QString _desc;

View File

@ -1,11 +1,12 @@
#include "config.h" #include "config.h"
#include "data.h" #include "data.h"
#include "tooltip.h"
#include "speedgraphitem.h"
#include "speedgraph.h" #include "speedgraph.h"
SpeedGraph::SpeedGraph(QWidget *parent) : GraphTab(parent) SpeedGraph::SpeedGraph(QWidget *parent) : GraphTab(parent)
{ {
_units = Metric;
_timeType = Total; _timeType = Total;
_showTracks = true; _showTracks = true;
@ -29,18 +30,19 @@ void SpeedGraph::setInfo()
void SpeedGraph::loadData(const Data &data, const QList<PathItem *> &paths) void SpeedGraph::loadData(const Data &data, const QList<PathItem *> &paths)
{ {
for (int i = 0; i < data.tracks().count(); i++) { for (int i = 0; i < data.tracks().count(); i++) {
const Graph &graph = data.tracks().at(i)->speed(); const Track *track = data.tracks().at(i);
const Graph &graph = track->speed();
if (graph.size() < 2) { if (graph.size() < 2) {
skipColor(); skipColor();
continue; continue;
} }
_avg.append(QPointF(data.tracks().at(i)->distance(), SpeedGraphItem *gi = new SpeedGraphItem(graph, track->movingTime());
data.tracks().at(i)->distance() / data.tracks().at(i)->time())); GraphView::addGraph(gi, paths.at(i));
_avgM.append(QPointF(data.tracks().at(i)->distance(),
data.tracks().at(i)->distance() / data.tracks().at(i)->movingTime()));
GraphView::loadGraph(graph, paths.at(i)); _avg.append(QPointF(track->distance(), gi->avg()));
_mavg.append(QPointF(track->distance(), gi->mavg()));
} }
for (int i = 0; i < data.routes().count(); i++) for (int i = 0; i < data.routes().count(); i++)
@ -55,7 +57,7 @@ qreal SpeedGraph::avg() const
{ {
qreal sum = 0, w = 0; qreal sum = 0, w = 0;
QList<QPointF>::const_iterator it; QList<QPointF>::const_iterator it;
const QList<QPointF> &list = (_timeType == Moving) ? _avgM : _avg; const QList<QPointF> &list = (_timeType == Moving) ? _mavg : _avg;
for (it = list.begin(); it != list.end(); it++) { for (it = list.begin(); it != list.end(); it++) {
sum += it->y() * it->x(); sum += it->y() * it->x();
@ -68,7 +70,7 @@ qreal SpeedGraph::avg() const
void SpeedGraph::clear() void SpeedGraph::clear()
{ {
_avg.clear(); _avg.clear();
_avgM.clear(); _mavg.clear();
GraphView::clear(); GraphView::clear();
} }
@ -86,11 +88,10 @@ void SpeedGraph::setYUnits()
void SpeedGraph::setUnits(enum Units units) void SpeedGraph::setUnits(enum Units units)
{ {
_units = units; GraphView::setUnits(units);
setYUnits(); setYUnits();
setInfo(); setInfo();
GraphView::setUnits(units);
redraw(); redraw();
} }

View File

@ -14,8 +14,8 @@ public:
QString label() const {return tr("Speed");} QString label() const {return tr("Speed");}
void loadData(const Data &data, const QList<PathItem *> &paths); void loadData(const Data &data, const QList<PathItem *> &paths);
void clear(); void clear();
void setUnits(enum Units units); void setUnits(Units units);
void setTimeType(enum TimeType type); void setTimeType(TimeType type);
void showTracks(bool show); void showTracks(bool show);
private: private:
@ -25,9 +25,8 @@ private:
void setInfo(); void setInfo();
QList<QPointF> _avg; QList<QPointF> _avg;
QList<QPointF> _avgM; QList<QPointF> _mavg;
enum Units _units;
enum TimeType _timeType; enum TimeType _timeType;
bool _showTracks; bool _showTracks;
}; };

32
src/speedgraphitem.cpp Normal file
View File

@ -0,0 +1,32 @@
#include "tooltip.h"
#include "speedgraphitem.h"
SpeedGraphItem::SpeedGraphItem(const Graph &graph, qreal movingTime,
QGraphicsItem *parent) : GraphItem(graph, parent)
{
_avg = graph.last().s() / graph.last().t();
_mavg = graph.last().s() / movingTime;
setToolTip(toolTip(Metric));
}
QString SpeedGraphItem::toolTip(Units units) const
{
ToolTip tt;
qreal scale = (units == Metric) ? MS2KMH : MS2MIH;
QString su = (units == Metric) ? tr("km/h") : tr("mi/h");
tt.insert(tr("Maximum"), QString::number(max() * scale, 'f', 1)
+ UNIT_SPACE + su);
tt.insert(tr("Average"), QString::number(avg() * scale, 'f', 1)
+ UNIT_SPACE + su);
tt.insert(tr("Moving average"), QString::number(mavg() * scale, 'f', 1)
+ UNIT_SPACE + su);
return tt.toString();
}
void SpeedGraphItem::setUnits(Units units)
{
setToolTip(toolTip(units));
}

24
src/speedgraphitem.h Normal file
View File

@ -0,0 +1,24 @@
#ifndef SPEEDGRAPHITEM_H
#define SPEEDGRAPHITEM_H
#include "graphitem.h"
class SpeedGraphItem : public GraphItem
{
public:
SpeedGraphItem(const Graph &graph, qreal movingTime,
QGraphicsItem *parent = 0);
qreal max() const {return -bounds().top();}
qreal avg() const {return _avg;}
qreal mavg() const {return _mavg;}
void setUnits(Units units);
private:
QString toolTip(Units units) const;
qreal _avg, _mavg;
};
#endif // SPEEDGRAPHITEM_H

View File

@ -1,10 +1,10 @@
#include "data.h" #include "data.h"
#include "temperaturegraphitem.h"
#include "temperaturegraph.h" #include "temperaturegraph.h"
TemperatureGraph::TemperatureGraph(QWidget *parent) : GraphTab(parent) TemperatureGraph::TemperatureGraph(QWidget *parent) : GraphTab(parent)
{ {
_units = Metric;
_showTracks = true; _showTracks = true;
setYUnits(); setYUnits();
@ -30,21 +30,16 @@ void TemperatureGraph::loadData(const Data &data, const QList<PathItem *> &paths
{ {
for (int i = 0; i < data.tracks().count(); i++) { for (int i = 0; i < data.tracks().count(); i++) {
const Graph &graph = data.tracks().at(i)->temperature(); const Graph &graph = data.tracks().at(i)->temperature();
qreal sum = 0, w = 0;
if (graph.size() < 2) { if (graph.size() < 2) {
skipColor(); skipColor();
continue; continue;
} }
for (int j = 1; j < graph.size(); j++) { TemperatureGraphItem *gi = new TemperatureGraphItem(graph);
qreal ds = graph.at(j).s() - graph.at(j-1).s(); GraphView::addGraph(gi, paths.at(i));
sum += graph.at(j).y() * ds;
w += ds;
}
_avg.append(QPointF(data.tracks().at(i)->distance(), sum/w));
GraphView::loadGraph(graph, paths.at(i)); _avg.append(QPointF(data.tracks().at(i)->distance(), gi->avg()));
} }
for (int i = 0; i < data.routes().count(); i++) for (int i = 0; i < data.routes().count(); i++)
@ -90,11 +85,10 @@ void TemperatureGraph::setYUnits()
void TemperatureGraph::setUnits(enum Units units) void TemperatureGraph::setUnits(enum Units units)
{ {
_units = units; GraphView::setUnits(units);
setYUnits(); setYUnits();
setInfo(); setInfo();
GraphView::setUnits(units);
redraw(); redraw();
} }

View File

@ -25,7 +25,6 @@ private:
QList<QPointF> _avg; QList<QPointF> _avg;
enum Units _units;
bool _showTracks; bool _showTracks;
}; };

View File

@ -0,0 +1,37 @@
#include "tooltip.h"
#include "temperaturegraphitem.h"
TemperatureGraphItem::TemperatureGraphItem(const Graph &graph,
QGraphicsItem *parent) : GraphItem(graph, parent)
{
qreal sum = 0;
for (int j = 1; j < graph.size(); j++)
sum += graph.at(j).y() * (graph.at(j).s() - graph.at(j-1).s());
_avg = sum/graph.last().s();
setToolTip(toolTip(Metric));
}
QString TemperatureGraphItem::toolTip(Units units) const
{
ToolTip tt;
qreal scale = (units == Metric) ? 1.0 : C2FS;
qreal offset = (units == Metric) ? 0 : C2FO;
QString su = (units == Metric) ?
QChar(0x00B0) + tr("C") : QChar(0x00B0) + tr("F");
tt.insert(tr("Average"), QString::number(avg() * scale + offset, 'f', 1)
+ UNIT_SPACE + su);
tt.insert(tr("Maximum"), QString::number(max() * scale + offset, 'f', 1)
+ UNIT_SPACE + su);
tt.insert(tr("Minimum"), QString::number(min() * scale + offset, 'f', 1)
+ UNIT_SPACE + su);
return tt.toString();
}
void TemperatureGraphItem::setUnits(Units units)
{
setToolTip(toolTip(units));
}

View File

@ -0,0 +1,23 @@
#ifndef TEMPERATUREGRAPHITEM_H
#define TEMPERATUREGRAPHITEM_H
#include "graphitem.h"
class TemperatureGraphItem : public GraphItem
{
public:
TemperatureGraphItem(const Graph &graph, QGraphicsItem *parent = 0);
qreal max() const {return -bounds().top();}
qreal min() const {return -bounds().bottom();}
qreal avg() const {return _avg;}
void setUnits(Units units);
private:
QString toolTip(Units units) const;
qreal _avg;
};
#endif // TEMPERATUREGRAPHITEM_H

View File

@ -5,7 +5,7 @@
#include "trackitem.h" #include "trackitem.h"
QString TrackItem::toolTip(Units units) QString TrackItem::toolTip(Units units) const
{ {
ToolTip tt; ToolTip tt;

View File

@ -19,7 +19,7 @@ public:
void setUnits(Units units); void setUnits(Units units);
private: private:
QString toolTip(Units units); QString toolTip(Units units) const;
QString _name; QString _name;
QString _desc; QString _desc;