1
0
mirror of https://github.com/tumic0/GPXSee.git synced 2024-11-24 11:45:53 +01:00

Added heart rate graph

Improved graphs loading performance
Fixed various corner case behaviour bugs
This commit is contained in:
Martin Tůma 2016-03-21 22:37:55 +01:00
parent b212ccf594
commit 93670d3026
16 changed files with 409 additions and 169 deletions

View File

@ -33,7 +33,8 @@ HEADERS += src/config.h \
src/graphview.h \ src/graphview.h \
src/trackpoint.h \ src/trackpoint.h \
src/waypointitem.h \ src/waypointitem.h \
src/palette.h src/palette.h \
src/heartrategraph.h
SOURCES += src/main.cpp \ SOURCES += src/main.cpp \
src/gui.cpp \ src/gui.cpp \
src/gpx.cpp \ src/gpx.cpp \
@ -57,7 +58,8 @@ SOURCES += src/main.cpp \
src/track.cpp \ src/track.cpp \
src/graphview.cpp \ src/graphview.cpp \
src/waypointitem.cpp \ src/waypointitem.cpp \
src/palette.cpp src/palette.cpp \
src/heartrategraph.cpp
RESOURCES += gpxsee.qrc RESOURCES += gpxsee.qrc
TRANSLATIONS = lang/gpxsee_cs.ts TRANSLATIONS = lang/gpxsee_cs.ts
macx:ICON = icons/gpxsee.icns macx:ICON = icons/gpxsee.icns

View File

@ -15,43 +15,43 @@
</message> </message>
<message> <message>
<location filename="../src/elevationgraph.cpp" line="16"/> <location filename="../src/elevationgraph.cpp" line="16"/>
<location filename="../src/elevationgraph.cpp" line="83"/> <location filename="../src/elevationgraph.cpp" line="84"/>
<source>km</source> <source>km</source>
<translation>km</translation> <translation>km</translation>
</message> </message>
<message> <message>
<location filename="../src/elevationgraph.cpp" line="17"/> <location filename="../src/elevationgraph.cpp" line="17"/>
<location filename="../src/elevationgraph.cpp" line="84"/> <location filename="../src/elevationgraph.cpp" line="85"/>
<source>m</source> <source>m</source>
<translation>m</translation> <translation>m</translation>
</message> </message>
<message> <message>
<location filename="../src/elevationgraph.cpp" line="23"/> <location filename="../src/elevationgraph.cpp" line="24"/>
<source>Ascent</source> <source>Ascent</source>
<translation>Stoupání</translation> <translation>Stoupání</translation>
</message> </message>
<message> <message>
<location filename="../src/elevationgraph.cpp" line="25"/> <location filename="../src/elevationgraph.cpp" line="26"/>
<source>Descent</source> <source>Descent</source>
<translation>Klesání</translation> <translation>Klesání</translation>
</message> </message>
<message> <message>
<location filename="../src/elevationgraph.cpp" line="29"/> <location filename="../src/elevationgraph.cpp" line="30"/>
<source>Minimum</source> <source>Minimum</source>
<translation>Minimum</translation> <translation>Minimum</translation>
</message> </message>
<message> <message>
<location filename="../src/elevationgraph.cpp" line="88"/> <location filename="../src/elevationgraph.cpp" line="89"/>
<source>mi</source> <source>mi</source>
<translation>mi</translation> <translation>mi</translation>
</message> </message>
<message> <message>
<location filename="../src/elevationgraph.cpp" line="89"/> <location filename="../src/elevationgraph.cpp" line="90"/>
<source>ft</source> <source>ft</source>
<translation>ft</translation> <translation>ft</translation>
</message> </message>
<message> <message>
<location filename="../src/elevationgraph.cpp" line="27"/> <location filename="../src/elevationgraph.cpp" line="28"/>
<source>Maximum</source> <source>Maximum</source>
<translation>Maximum</translation> <translation>Maximum</translation>
</message> </message>
@ -59,352 +59,396 @@
<context> <context>
<name>GUI</name> <name>GUI</name>
<message> <message>
<location filename="../src/gui.cpp" line="161"/> <location filename="../src/gui.cpp" line="172"/>
<source>About Qt</source> <source>About Qt</source>
<translation>O Qt</translation> <translation>O Qt</translation>
</message> </message>
<message> <message>
<location filename="../src/gui.cpp" line="380"/> <location filename="../src/gui.cpp" line="393"/>
<source>GPXSee is distributed under the terms of the GNU General Public License version 3. For more info about GPXSee visit the project homepage at </source> <source>GPXSee is distributed under the terms of the GNU General Public License version 3. For more info about GPXSee visit the project homepage at </source>
<translation>Program GPXSee je distribuován pod podmínkami licence GNU General Public License verze 3. Pro více informací navštivte stránky programu na adrese </translation> <translation>Program GPXSee je distribuován pod podmínkami licence GNU General Public License verze 3. Pro více informací navštivte stránky programu na adrese </translation>
</message> </message>
<message> <message>
<location filename="../src/gui.cpp" line="441"/> <location filename="../src/gui.cpp" line="454"/>
<source>Open file</source> <source>Open file</source>
<translation>Otevřít soubor</translation> <translation>Otevřít soubor</translation>
</message> </message>
<message> <message>
<location filename="../src/gui.cpp" line="175"/> <location filename="../src/gui.cpp" line="186"/>
<source>Save as</source> <source>Save as</source>
<translation>Uložit jako</translation> <translation>Uložit jako</translation>
</message> </message>
<message> <message>
<location filename="../src/gui.cpp" line="501"/> <location filename="../src/gui.cpp" line="515"/>
<source>Open POI file</source> <source>Open POI file</source>
<translation>Otevřít POI soubor</translation> <translation>Otevřít POI soubor</translation>
</message> </message>
<message> <message>
<location filename="../src/gui.cpp" line="166"/> <location filename="../src/gui.cpp" line="177"/>
<source>Open</source> <source>Open</source>
<translation>Otevřít</translation> <translation>Otevřít</translation>
</message> </message>
<message> <message>
<location filename="../src/gui.cpp" line="149"/> <location filename="../src/gui.cpp" line="160"/>
<source>Quit</source> <source>Quit</source>
<translation>Ukončit</translation> <translation>Ukončit</translation>
</message> </message>
<message> <message>
<location filename="../src/gui.cpp" line="156"/> <location filename="../src/gui.cpp" line="167"/>
<location filename="../src/gui.cpp" line="396"/> <location filename="../src/gui.cpp" line="409"/>
<location filename="../src/gui.cpp" line="397"/> <location filename="../src/gui.cpp" line="410"/>
<source>Keyboard controls</source> <source>Keyboard controls</source>
<translation>Ovládací klávesy</translation> <translation>Ovládací klávesy</translation>
</message> </message>
<message> <message>
<location filename="../src/gui.cpp" line="170"/> <location filename="../src/gui.cpp" line="181"/>
<source>Save</source> <source>Save</source>
<translation>Uložit</translation> <translation>Uložit</translation>
</message> </message>
<message> <message>
<location filename="../src/gui.cpp" line="180"/> <location filename="../src/gui.cpp" line="191"/>
<source>Close</source> <source>Close</source>
<translation>Zavřít</translation> <translation>Zavřít</translation>
</message> </message>
<message> <message>
<location filename="../src/gui.cpp" line="185"/> <location filename="../src/gui.cpp" line="196"/>
<source>Reload</source> <source>Reload</source>
<translation>Znovu načíst</translation> <translation>Znovu načíst</translation>
</message> </message>
<message> <message>
<location filename="../src/gui.cpp" line="317"/> <location filename="../src/gui.cpp" line="328"/>
<source>Show</source> <source>Show</source>
<translation>Zobrazit</translation> <translation>Zobrazit</translation>
</message> </message>
<message> <message>
<location filename="../src/gui.cpp" line="262"/> <location filename="../src/gui.cpp" line="273"/>
<location filename="../src/gui.cpp" line="308"/> <location filename="../src/gui.cpp" line="319"/>
<source>File</source> <source>File</source>
<translation>Soubor</translation> <translation>Soubor</translation>
</message> </message>
<message> <message>
<location filename="../src/gui.cpp" line="154"/> <location filename="../src/gui.cpp" line="165"/>
<location filename="../src/gui.cpp" line="414"/> <location filename="../src/gui.cpp" line="427"/>
<location filename="../src/gui.cpp" line="415"/> <location filename="../src/gui.cpp" line="428"/>
<source>Data sources</source> <source>Data sources</source>
<translation>Zdroje dat</translation> <translation>Zdroje dat</translation>
</message> </message>
<message> <message>
<location filename="../src/gui.cpp" line="192"/> <location filename="../src/gui.cpp" line="203"/>
<source>Load POI file</source> <source>Load POI file</source>
<translation>Nahrát POI soubor</translation> <translation>Nahrát POI soubor</translation>
</message> </message>
<message> <message>
<location filename="../src/gui.cpp" line="195"/> <location filename="../src/gui.cpp" line="206"/>
<source>Close POI files</source> <source>Close POI files</source>
<translation>Zavřit soubory POI</translation> <translation>Zavřit soubory POI</translation>
</message> </message>
<message> <message>
<location filename="../src/gui.cpp" line="198"/> <location filename="../src/gui.cpp" line="209"/>
<source>Show POIs</source> <source>Show POIs</source>
<translation>Zobrazit POI</translation> <translation>Zobrazit POI</translation>
</message> </message>
<message> <message>
<location filename="../src/gui.cpp" line="205"/> <location filename="../src/gui.cpp" line="216"/>
<source>Show map</source> <source>Show map</source>
<translation>Zobrazit mapu</translation> <translation>Zobrazit mapu</translation>
</message> </message>
<message> <message>
<location filename="../src/gui.cpp" line="218"/> <location filename="../src/gui.cpp" line="229"/>
<source>Show graphs</source> <source>Show graphs</source>
<translation>Zobrazovat grafy</translation> <translation>Zobrazovat grafy</translation>
</message> </message>
<message> <message>
<location filename="../src/gui.cpp" line="224"/> <location filename="../src/gui.cpp" line="235"/>
<source>Show toolbars</source> <source>Show toolbars</source>
<translation>Zobrazovat nástrojové lišty</translation> <translation>Zobrazovat nástrojové lišty</translation>
</message> </message>
<message> <message>
<location filename="../src/gui.cpp" line="231"/> <location filename="../src/gui.cpp" line="242"/>
<source>Metric</source> <source>Metric</source>
<translation>Metrické</translation> <translation>Metrické</translation>
</message> </message>
<message> <message>
<location filename="../src/gui.cpp" line="237"/> <location filename="../src/gui.cpp" line="248"/>
<source>Imperial</source> <source>Imperial</source>
<translation>Imperiální</translation> <translation>Imperiální</translation>
</message> </message>
<message> <message>
<location filename="../src/gui.cpp" line="244"/> <location filename="../src/gui.cpp" line="255"/>
<source>Next</source> <source>Next</source>
<translation>Následující</translation> <translation>Následující</translation>
</message> </message>
<message> <message>
<location filename="../src/gui.cpp" line="247"/> <location filename="../src/gui.cpp" line="258"/>
<source>Previous</source> <source>Previous</source>
<translation>Předchozí</translation> <translation>Předchozí</translation>
</message> </message>
<message> <message>
<location filename="../src/gui.cpp" line="251"/> <location filename="../src/gui.cpp" line="262"/>
<source>Last</source> <source>Last</source>
<translation>Poslední</translation> <translation>Poslední</translation>
</message> </message>
<message> <message>
<location filename="../src/gui.cpp" line="254"/> <location filename="../src/gui.cpp" line="265"/>
<source>First</source> <source>First</source>
<translation>První</translation> <translation>První</translation>
</message> </message>
<message> <message>
<location filename="../src/gui.cpp" line="276"/> <location filename="../src/gui.cpp" line="287"/>
<source>Map</source> <source>Map</source>
<translation>Mapa</translation> <translation>Mapa</translation>
</message> </message>
<message> <message>
<location filename="../src/gui.cpp" line="281"/> <location filename="../src/gui.cpp" line="292"/>
<source>POI</source> <source>POI</source>
<translation>POI</translation> <translation>POI</translation>
</message> </message>
<message> <message>
<location filename="../src/gui.cpp" line="282"/> <location filename="../src/gui.cpp" line="293"/>
<source>POI files</source> <source>POI files</source>
<translation>POI soubory</translation> <translation>POI soubory</translation>
</message> </message>
<message> <message>
<location filename="../src/gui.cpp" line="290"/> <location filename="../src/gui.cpp" line="301"/>
<source>Settings</source> <source>Settings</source>
<translation>Nastavení</translation> <translation>Nastavení</translation>
</message> </message>
<message> <message>
<location filename="../src/gui.cpp" line="291"/> <location filename="../src/gui.cpp" line="302"/>
<source>Units</source> <source>Units</source>
<translation>Jednotky</translation> <translation>Jednotky</translation>
</message> </message>
<message> <message>
<location filename="../src/gui.cpp" line="298"/> <location filename="../src/gui.cpp" line="309"/>
<source>Help</source> <source>Help</source>
<translation>Nápověda</translation> <translation>Nápověda</translation>
</message> </message>
<message> <message>
<location filename="../src/gui.cpp" line="348"/> <location filename="../src/gui.cpp" line="360"/>
<source>Elevation</source> <source>Elevation</source>
<translation>Výška</translation> <translation>Výška</translation>
</message> </message>
<message> <message>
<location filename="../src/gui.cpp" line="349"/> <location filename="../src/gui.cpp" line="361"/>
<source>Speed</source> <source>Speed</source>
<translation>Rychlost</translation> <translation>Rychlost</translation>
</message> </message>
<message> <message>
<location filename="../src/gui.cpp" line="399"/> <location filename="../src/gui.cpp" line="362"/>
<source>Heart rate</source>
<translation>Tep</translation>
</message>
<message>
<location filename="../src/gui.cpp" line="412"/>
<source>Next file</source> <source>Next file</source>
<translation>Následující soubor</translation> <translation>Následující soubor</translation>
</message> </message>
<message> <message>
<location filename="../src/gui.cpp" line="400"/> <location filename="../src/gui.cpp" line="413"/>
<source>Previous file</source> <source>Previous file</source>
<translation>Předchozí soubor</translation> <translation>Předchozí soubor</translation>
</message> </message>
<message> <message>
<location filename="../src/gui.cpp" line="402"/> <location filename="../src/gui.cpp" line="415"/>
<source>First file</source> <source>First file</source>
<translation>První soubor</translation> <translation>První soubor</translation>
</message> </message>
<message> <message>
<location filename="../src/gui.cpp" line="403"/> <location filename="../src/gui.cpp" line="416"/>
<source>Last file</source> <source>Last file</source>
<translation>Poslední soubor</translation> <translation>Poslední soubor</translation>
</message> </message>
<message> <message>
<location filename="../src/gui.cpp" line="404"/> <location filename="../src/gui.cpp" line="417"/>
<source>Append modifier</source> <source>Append modifier</source>
<translation>Modifikátor nahradit/přidat</translation> <translation>Modifikátor nahradit/přidat</translation>
</message> </message>
<message> <message>
<location filename="../src/gui.cpp" line="418"/> <location filename="../src/gui.cpp" line="431"/>
<source>Map (tiles) source URLs are read on program startup from the following file:</source> <source>Map (tiles) source URLs are read on program startup from the following file:</source>
<translation>URL mapových zdrojů (dlaždic) jsou načteny při startu programu z následujícího souboru:</translation> <translation>URL mapových zdrojů (dlaždic) jsou načteny při startu programu z následujícího souboru:</translation>
</message> </message>
<message> <message>
<location filename="../src/gui.cpp" line="422"/> <location filename="../src/gui.cpp" line="435"/>
<source>The file format is one map entry per line, consisting of the map name and tiles URL delimited by a TAB character. The tile X and Y coordinates are replaced with $x and $y in the URL and the zoom level is replaced with $z. An example map file could look like:</source> <source>The file format is one map entry per line, consisting of the map name and tiles URL delimited by a TAB character. The tile X and Y coordinates are replaced with $x and $y in the URL and the zoom level is replaced with $z. An example map file could look like:</source>
<translation>Formát souboru je jeden mapový záznam na řádku, kde mapový záznam sestává ze jména mapy a URL dlaždic navzájem oddělených tabulátorem. Souřadnice dlaždice jsou v URL nahrazeny řetězci $x a $y, úroven přiblížení (zoom) pak řetězcem $z. Příklad:</translation> <translation>Formát souboru je jeden mapový záznam na řádku, kde mapový záznam sestává ze jména mapy a URL dlaždic navzájem oddělených tabulátorem. Souřadnice dlaždice jsou v URL nahrazeny řetězci $x a $y, úroven přiblížení (zoom) pak řetězcem $z. Příklad:</translation>
</message> </message>
<message> <message>
<location filename="../src/gui.cpp" line="430"/> <location filename="../src/gui.cpp" line="443"/>
<source>To make GPXSee load a POI file automatically on startup, add the file to the following directory:</source> <source>To make GPXSee load a POI file automatically on startup, add the file to the following directory:</source>
<translation>POI soubory, které se mají automaticky nahrát při startu programu jsou načítány z následujícího adresáře:</translation> <translation>POI soubory, které se mají automaticky nahrát při startu programu jsou načítány z následujícího adresáře:</translation>
</message> </message>
<message> <message>
<location filename="../src/gui.cpp" line="442"/> <location filename="../src/gui.cpp" line="455"/>
<source>GPX files (*.gpx);;All files (*)</source> <source>GPX files (*.gpx);;All files (*)</source>
<translation>soubory GPX (*.gpx);;všechny soubory (*)</translation> <translation>soubory GPX (*.gpx);;všechny soubory (*)</translation>
</message> </message>
<message> <message>
<location filename="../src/gui.cpp" line="492"/> <location filename="../src/gui.cpp" line="506"/>
<location filename="../src/gui.cpp" line="509"/> <location filename="../src/gui.cpp" line="523"/>
<source>Line: %1</source> <source>Line: %1</source>
<translation>Řádka: %1</translation> <translation>Řádka: %1</translation>
</message> </message>
<message> <message>
<location filename="../src/gui.cpp" line="502"/> <location filename="../src/gui.cpp" line="516"/>
<source>GPX files (*.gpx);;CSV files (*.csv);;All files (*)</source> <source>GPX files (*.gpx);;CSV files (*.csv);;All files (*)</source>
<translation>soubory GPX (*.gpx);;soubory CSV (*.csv);;všechny soubory (*)</translation> <translation>soubory GPX (*.gpx);;soubory CSV (*.csv);;všechny soubory (*)</translation>
</message> </message>
<message> <message>
<location filename="../src/gui.cpp" line="577"/> <location filename="../src/gui.cpp" line="585"/>
<location filename="../src/gui.cpp" line="697"/> <location filename="../src/gui.cpp" line="707"/>
<source>mi</source> <source>mi</source>
<translation>mi</translation> <translation>mi</translation>
</message> </message>
<message> <message>
<location filename="../src/gui.cpp" line="580"/> <location filename="../src/gui.cpp" line="588"/>
<location filename="../src/gui.cpp" line="582"/> <location filename="../src/gui.cpp" line="590"/>
<location filename="../src/gui.cpp" line="584"/> <location filename="../src/gui.cpp" line="592"/>
<location filename="../src/gui.cpp" line="586"/> <location filename="../src/gui.cpp" line="594"/>
<source>ft</source> <source>ft</source>
<translation>ft</translation> <translation>ft</translation>
</message> </message>
<message> <message>
<location filename="../src/gui.cpp" line="583"/> <location filename="../src/gui.cpp" line="591"/>
<location filename="../src/gui.cpp" line="595"/> <location filename="../src/gui.cpp" line="603"/>
<source>Maximum</source> <source>Maximum</source>
<translation>Maximum</translation> <translation>Maximum</translation>
</message> </message>
<message> <message>
<location filename="../src/gui.cpp" line="585"/> <location filename="../src/gui.cpp" line="593"/>
<location filename="../src/gui.cpp" line="597"/> <location filename="../src/gui.cpp" line="605"/>
<source>Minimum</source> <source>Minimum</source>
<translation>Minimum</translation> <translation>Minimum</translation>
</message> </message>
<message> <message>
<location filename="../src/gui.cpp" line="159"/> <location filename="../src/gui.cpp" line="170"/>
<location filename="../src/gui.cpp" line="376"/> <location filename="../src/gui.cpp" line="389"/>
<source>About GPXSee</source> <source>About GPXSee</source>
<translation>O aplikaci GPXSee</translation> <translation>O aplikaci GPXSee</translation>
</message> </message>
<message> <message>
<location filename="../src/gui.cpp" line="324"/> <location filename="../src/gui.cpp" line="335"/>
<source>Navigation</source> <source>Navigation</source>
<translation>Navigace</translation> <translation>Navigace</translation>
</message> </message>
<message> <message>
<location filename="../src/gui.cpp" line="378"/> <location filename="../src/gui.cpp" line="391"/>
<source>GPX viewer and analyzer</source> <source>GPX viewer and analyzer</source>
<translation>Prohlížeč a analyzátor GPX</translation> <translation>Prohlížeč a analyzátor GPX</translation>
</message> </message>
<message> <message>
<location filename="../src/gui.cpp" line="417"/> <location filename="../src/gui.cpp" line="430"/>
<source>Map sources</source> <source>Map sources</source>
<translation>Mapové zdroje</translation> <translation>Mapové zdroje</translation>
</message> </message>
<message> <message>
<location filename="../src/gui.cpp" line="429"/> <location filename="../src/gui.cpp" line="442"/>
<source>POIs</source> <source>POIs</source>
<translation>POI body</translation> <translation>POI body</translation>
</message> </message>
<message> <message>
<location filename="../src/gui.cpp" line="576"/> <location filename="../src/gui.cpp" line="584"/>
<location filename="../src/gui.cpp" line="588"/> <location filename="../src/gui.cpp" line="596"/>
<source>Distance</source> <source>Distance</source>
<translation>Vzdálenost</translation> <translation>Vzdálenost</translation>
</message> </message>
<message> <message>
<location filename="../src/gui.cpp" line="578"/> <location filename="../src/gui.cpp" line="586"/>
<location filename="../src/gui.cpp" line="590"/> <location filename="../src/gui.cpp" line="598"/>
<source>Time</source> <source>Time</source>
<translation>Čas</translation> <translation>Čas</translation>
</message> </message>
<message> <message>
<location filename="../src/gui.cpp" line="579"/> <location filename="../src/gui.cpp" line="587"/>
<location filename="../src/gui.cpp" line="591"/> <location filename="../src/gui.cpp" line="599"/>
<source>Ascent</source> <source>Ascent</source>
<translation>Stoupání</translation> <translation>Stoupání</translation>
</message> </message>
<message> <message>
<location filename="../src/gui.cpp" line="592"/> <location filename="../src/gui.cpp" line="600"/>
<location filename="../src/gui.cpp" line="594"/> <location filename="../src/gui.cpp" line="602"/>
<location filename="../src/gui.cpp" line="596"/> <location filename="../src/gui.cpp" line="604"/>
<location filename="../src/gui.cpp" line="598"/> <location filename="../src/gui.cpp" line="606"/>
<source>m</source> <source>m</source>
<translation>m</translation> <translation>m</translation>
</message> </message>
<message> <message>
<location filename="../src/gui.cpp" line="581"/> <location filename="../src/gui.cpp" line="589"/>
<location filename="../src/gui.cpp" line="593"/> <location filename="../src/gui.cpp" line="601"/>
<source>Descent</source> <source>Descent</source>
<translation>Klesání</translation> <translation>Klesání</translation>
</message> </message>
<message> <message>
<location filename="../src/gui.cpp" line="693"/> <location filename="../src/gui.cpp" line="703"/>
<source>%1 tracks</source> <source>%1 tracks</source>
<translation>Počet tras: %1</translation> <translation>Počet tras: %1</translation>
</message> </message>
<message> <message>
<location filename="../src/gui.cpp" line="589"/> <location filename="../src/gui.cpp" line="597"/>
<location filename="../src/gui.cpp" line="700"/> <location filename="../src/gui.cpp" line="710"/>
<source>km</source> <source>km</source>
<translation>km</translation> <translation>km</translation>
</message> </message>
<message> <message>
<location filename="../src/gui.cpp" line="494"/> <location filename="../src/gui.cpp" line="508"/>
<location filename="../src/gui.cpp" line="510"/> <location filename="../src/gui.cpp" line="524"/>
<source>Error</source> <source>Error</source>
<translation>Chyba</translation> <translation>Chyba</translation>
</message> </message>
<message> <message>
<location filename="../src/gui.cpp" line="489"/> <location filename="../src/gui.cpp" line="503"/>
<source>Error loading GPX file: <source>Error loading GPX file:
%1</source> %1</source>
<translation>Soubor GPX nelze otevřít: <translation>Soubor GPX nelze otevřít:
%1</translation> %1</translation>
</message> </message>
<message> <message>
<location filename="../src/gui.cpp" line="506"/> <location filename="../src/gui.cpp" line="520"/>
<source>Error loading POI file: <source>Error loading POI file:
%1</source> %1</source>
<translation>Soubor POI nelze otevřít: <translation>Soubor POI nelze otevřít:
%1</translation> %1</translation>
</message> </message>
</context> </context>
<context>
<name>HeartRateGraph</name>
<message>
<location filename="../src/heartrategraph.cpp" line="9"/>
<source>Distance</source>
<translation>Vzdálenost</translation>
</message>
<message>
<location filename="../src/heartrategraph.cpp" line="10"/>
<source>Heart rate</source>
<translation>Tep</translation>
</message>
<message>
<location filename="../src/heartrategraph.cpp" line="11"/>
<location filename="../src/heartrategraph.cpp" line="74"/>
<source>km</source>
<translation>km</translation>
</message>
<message>
<location filename="../src/heartrategraph.cpp" line="12"/>
<source>1/min</source>
<translation>1/min</translation>
</message>
<message>
<location filename="../src/heartrategraph.cpp" line="19"/>
<source>Average</source>
<translation>Průměr</translation>
</message>
<message>
<location filename="../src/heartrategraph.cpp" line="21"/>
<source>Maximum</source>
<translation>Maximum</translation>
</message>
<message>
<location filename="../src/heartrategraph.cpp" line="77"/>
<source>mi</source>
<translation>mi</translation>
</message>
</context>
<context> <context>
<name>QObject</name> <name>QObject</name>
<message> <message>

View File

@ -11,12 +11,12 @@ ElevationGraph::ElevationGraph(QWidget *parent) : GraphView(parent)
_max = -FLT_MAX; _max = -FLT_MAX;
_min = FLT_MAX; _min = FLT_MAX;
GraphView::setXLabel(tr("Distance")); setXLabel(tr("Distance"));
GraphView::setYLabel(tr("Elevation")); setYLabel(tr("Elevation"));
GraphView::setXUnits(tr("km")); setXUnits(tr("km"));
GraphView::setYUnits(tr("m")); setYUnits(tr("m"));
GraphView::setXScale(M2KM); setXScale(M2KM);
GraphView::setMinRange(50.0); setMinRange(50.0);
} }
void ElevationGraph::addInfo() void ElevationGraph::addInfo()
@ -38,14 +38,16 @@ void ElevationGraph::loadGPX(const GPX &gpx)
qreal min, max, ascent = 0, descent = 0; qreal min, max, ascent = 0, descent = 0;
gpx.track(i).elevationGraph(data); gpx.track(i).elevationGraph(data);
if (data.isEmpty()) if (data.count() < 2) {
skipColor();
continue; continue;
}
min = max = data.at(0).y(); min = max = data.at(0).y();
for (int i = 1; i < data.size(); i++) { for (int j = 1; j < data.size(); j++) {
qreal cur = data.at(i).y(); qreal cur = data.at(j).y();
qreal prev = data.at(i-1).y(); qreal prev = data.at(j-1).y();
if (cur > prev) if (cur > prev)
ascent += cur - prev; ascent += cur - prev;
@ -81,15 +83,15 @@ void ElevationGraph::clear()
void ElevationGraph::setUnits(enum Units units) void ElevationGraph::setUnits(enum Units units)
{ {
if (units == Metric) { if (units == Metric) {
GraphView::setXUnits(tr("km")); setXUnits(tr("km"));
GraphView::setYUnits(tr("m")); setYUnits(tr("m"));
GraphView::setXScale(M2KM); setXScale(M2KM);
GraphView::setYScale(1); setYScale(1);
} else { } else {
GraphView::setXUnits(tr("mi")); setXUnits(tr("mi"));
GraphView::setYUnits(tr("ft")); setYUnits(tr("ft"));
GraphView::setXScale(M2MI); setXScale(M2MI);
GraphView::setYScale(M2FT); setYScale(M2FT);
} }
clearInfo(); clearInfo();

View File

@ -294,7 +294,7 @@ void GraphView::emitSliderPositionChanged(const QPointF &pos)
return; return;
qreal val = pos.x() / _slider->area().width(); qreal val = pos.x() / _slider->area().width();
emit sliderPositionChanged(val); emit sliderPositionChanged(val * (_xMax - _xMin));
const QPainterPath &path = _graphs.at(0)->path(); const QPainterPath &path = _graphs.at(0)->path();
QRectF br = path.boundingRect(); QRectF br = path.boundingRect();
@ -309,18 +309,27 @@ void GraphView::emitSliderPositionChanged(const QPointF &pos)
qreal GraphView::sliderPosition() const qreal GraphView::sliderPosition() const
{ {
return _slider->pos().x() / _slider->area().width(); if (!_slider->isVisible())
return -1;
else
return (_slider->pos().x() / _slider->area().width()) * (_xMax - _xMin);
} }
void GraphView::setSliderPosition(qreal pos) void GraphView::setSliderPosition(qreal pos)
{ {
_slider->setPos(pos * _slider->area().width(), 0); if (pos > (_xMax - _xMin))
_slider->setVisible(false);
else {
_slider->setPos((pos / (_xMax - _xMin)) * _slider->area().width(), 0);
_slider->setVisible(true);
}
} }
void GraphView::newSliderPosition(const QPointF &pos) void GraphView::newSliderPosition(const QPointF &pos)
{ {
if (_slider->area().contains(pos)) { if (_slider->area().contains(pos)) {
_slider->setPos(pos); _slider->setPos(pos);
_slider->setVisible(true);
emitSliderPositionChanged(pos); emitSliderPositionChanged(pos);
} }
} }

View File

@ -55,6 +55,8 @@ public:
void addInfo(const QString &key, const QString &value); void addInfo(const QString &key, const QString &value);
void clearInfo(); void clearInfo();
void skipColor() {_palette.color();}
signals: signals:
void sliderPositionChanged(qreal); void sliderPositionChanged(qreal);

View File

@ -22,6 +22,7 @@
#include "maplist.h" #include "maplist.h"
#include "elevationgraph.h" #include "elevationgraph.h"
#include "speedgraph.h" #include "speedgraph.h"
#include "heartrategraph.h"
#include "trackview.h" #include "trackview.h"
#include "infoitem.h" #include "infoitem.h"
#include "filebrowser.h" #include "filebrowser.h"
@ -56,6 +57,8 @@ GUI::GUI(QWidget *parent) : QMainWindow(parent)
SLOT(movePositionMarker(qreal))); SLOT(movePositionMarker(qreal)));
connect(_speedGraph, SIGNAL(sliderPositionChanged(qreal)), _track, connect(_speedGraph, SIGNAL(sliderPositionChanged(qreal)), _track,
SLOT(movePositionMarker(qreal))); SLOT(movePositionMarker(qreal)));
connect(_heartRateGraph, SIGNAL(sliderPositionChanged(qreal)), _track,
SLOT(movePositionMarker(qreal)));
_browser = new FileBrowser(this); _browser = new FileBrowser(this);
_browser->setFilter(QStringList("*.gpx")); _browser->setFilter(QStringList("*.gpx"));
@ -75,6 +78,9 @@ GUI::GUI(QWidget *parent) : QMainWindow(parent)
_time = 0; _time = 0;
_trackCount = 0; _trackCount = 0;
_lastGraph = static_cast<GraphView*>(_trackGraphs->currentWidget());
_lastSliderPos = _lastGraph->sliderPosition();
resize(600, 800); resize(600, 800);
} }
@ -349,10 +355,12 @@ void GUI::createTrackGraphs()
{ {
_elevationGraph = new ElevationGraph; _elevationGraph = new ElevationGraph;
_speedGraph = new SpeedGraph; _speedGraph = new SpeedGraph;
_heartRateGraph = new HeartRateGraph;
_trackGraphs = new QTabWidget; _trackGraphs = new QTabWidget;
_trackGraphs->addTab(_elevationGraph, tr("Elevation")); _trackGraphs->addTab(_elevationGraph, tr("Elevation"));
_trackGraphs->addTab(_speedGraph, tr("Speed")); _trackGraphs->addTab(_speedGraph, tr("Speed"));
_trackGraphs->addTab(_heartRateGraph, tr("Heart rate"));
connect(_trackGraphs, SIGNAL(currentChanged(int)), this, connect(_trackGraphs, SIGNAL(currentChanged(int)), this,
SLOT(graphChanged(int))); SLOT(graphChanged(int)));
@ -478,6 +486,7 @@ bool GUI::loadFile(const QString &fileName)
if (gpx.loadFile(fileName)) { if (gpx.loadFile(fileName)) {
_elevationGraph->loadGPX(gpx); _elevationGraph->loadGPX(gpx);
_speedGraph->loadGPX(gpx); _speedGraph->loadGPX(gpx);
_heartRateGraph->loadGPX(gpx);
_track->loadGPX(gpx); _track->loadGPX(gpx);
if (_showPOIAction->isChecked()) if (_showPOIAction->isChecked())
_track->loadPOI(_poi); _track->loadPOI(_poi);
@ -611,6 +620,7 @@ void GUI::reloadFile()
_elevationGraph->clear(); _elevationGraph->clear();
_speedGraph->clear(); _speedGraph->clear();
_heartRateGraph->clear();
_track->clear(); _track->clear();
for (int i = 0; i < _files.size(); i++) { for (int i = 0; i < _files.size(); i++) {
@ -635,6 +645,7 @@ void GUI::closeFile()
_elevationGraph->clear(); _elevationGraph->clear();
_speedGraph->clear(); _speedGraph->clear();
_heartRateGraph->clear();
_track->clear(); _track->clear();
_files.clear(); _files.clear();
@ -721,10 +732,11 @@ void GUI::poiFileChecked(int index)
void GUI::graphChanged(int index) void GUI::graphChanged(int index)
{ {
if (_trackGraphs->widget(index) == _elevationGraph) GraphView *tv = static_cast<GraphView*>(_trackGraphs->widget(index));
_elevationGraph->setSliderPosition(_speedGraph->sliderPosition()); if (_lastGraph->sliderPosition() >= 0)
else if (_trackGraphs->widget(index) == _speedGraph) _lastSliderPos = _lastGraph->sliderPosition();
_speedGraph->setSliderPosition(_elevationGraph->sliderPosition()); tv->setSliderPosition(_lastSliderPos);
_lastGraph = tv;
} }
void GUI::updateNavigationActions() void GUI::updateNavigationActions()
@ -751,6 +763,7 @@ void GUI::setMetricUnits()
_track->setUnits(Metric); _track->setUnits(Metric);
_elevationGraph->setUnits(Metric); _elevationGraph->setUnits(Metric);
_speedGraph->setUnits(Metric); _speedGraph->setUnits(Metric);
_heartRateGraph->setUnits(Metric);
updateStatusBarInfo(); updateStatusBarInfo();
} }
@ -759,6 +772,7 @@ void GUI::setImperialUnits()
_track->setUnits(Imperial); _track->setUnits(Imperial);
_elevationGraph->setUnits(Imperial); _elevationGraph->setUnits(Imperial);
_speedGraph->setUnits(Imperial); _speedGraph->setUnits(Imperial);
_heartRateGraph->setUnits(Imperial);
updateStatusBarInfo(); updateStatusBarInfo();
} }

View File

@ -14,8 +14,10 @@ class QAction;
class QLabel; class QLabel;
class QSignalMapper; class QSignalMapper;
class FileBrowser; class FileBrowser;
class GraphView;
class ElevationGraph; class ElevationGraph;
class SpeedGraph; class SpeedGraph;
class HeartRateGraph;
class TrackView; class TrackView;
class Map; class Map;
@ -124,6 +126,7 @@ private:
ElevationGraph *_elevationGraph; ElevationGraph *_elevationGraph;
SpeedGraph *_speedGraph; SpeedGraph *_speedGraph;
HeartRateGraph *_heartRateGraph;
TrackView *_track; TrackView *_track;
POI _poi; POI _poi;
@ -137,6 +140,9 @@ private:
qreal _distance; qreal _distance;
qreal _time; qreal _time;
int _trackCount; int _trackCount;
GraphView *_lastGraph;
qreal _lastSliderPos;
}; };
#endif // GUI_H #endif // GUI_H

87
src/heartrategraph.cpp Normal file
View File

@ -0,0 +1,87 @@
#include "gpx.h"
#include "heartrategraph.h"
HeartRateGraph::HeartRateGraph(QWidget *parent) : GraphView(parent)
{
_max = 0;
setXLabel(tr("Distance"));
setYLabel(tr("Heart rate"));
setXUnits(tr("km"));
setYUnits(tr("1/min"));
setXScale(M2KM);
setPrecision(0);
}
void HeartRateGraph::addInfo()
{
GraphView::addInfo(tr("Average"), QString::number(avg() * _yScale, 'f', 0)
+ UNIT_SPACE + _yUnits);
GraphView::addInfo(tr("Maximum"), QString::number(_max * _yScale, 'f', 0)
+ UNIT_SPACE + _yUnits);
}
void HeartRateGraph::loadGPX(const GPX &gpx)
{
for (int i = 0; i < gpx.trackCount(); i++) {
QVector<QPointF> data;
qreal max = 0, sum = 0, w = 0;
gpx.track(i).heartRateGraph(data);
if (data.count() < 2) {
skipColor();
continue;
}
for (int j = 1; j < data.size(); j++) {
sum += data.at(j).y() * (data.at(j).x() - data.at(j-1).x());
w += data.at(j).x() - data.at(j-1).x();
}
_avg.append(QPointF(gpx.track(i).distance(), sum/w));
for (int j = 0; j < data.size(); j++)
max = qMax(max, data.at(j).y());
_max = qMax(_max, max);
addInfo();
loadData(data);
}
}
qreal HeartRateGraph::avg() const
{
qreal sum = 0, w = 0;
QList<QPointF>::const_iterator it;
for (it = _avg.begin(); it != _avg.end(); it++) {
sum += it->y() * it->x();
w += it->x();
}
return (sum / w);
}
void HeartRateGraph::clear()
{
_max = 0;
_avg.clear();
GraphView::clear();
}
void HeartRateGraph::setUnits(enum Units units)
{
if (units == Metric) {
setXUnits(tr("km"));
setXScale(M2KM);
} else {
setXUnits(tr("mi"));
setXScale(M2MI);
}
clearInfo();
addInfo();
redraw();
}

30
src/heartrategraph.h Normal file
View File

@ -0,0 +1,30 @@
#ifndef HEARTRATEGRAPH_H
#define HEARTRATEGRAPH_H
#include "graphview.h"
#include "units.h"
class GPX;
class HeartRateGraph : public GraphView
{
Q_OBJECT
public:
HeartRateGraph(QWidget *parent = 0);
void loadGPX(const GPX &gpx);
void clear();
void setUnits(enum Units units);
qreal avg() const;
qreal max() const {return _max;}
private:
void addInfo();
qreal _max;
QList<QPointF> _avg;
};
#endif // HEARTRATEGRAPH_H

View File

@ -5,16 +5,18 @@ void Parser::handleExtensionData(QStringRef element, const QString &value)
{ {
if (element == "speed") if (element == "speed")
_track->last().speed = value.toDouble(); _track->last().speed = value.toDouble();
else if (element == "hr" || element == "heartrate")
_track->last().heartRate = value.toDouble();
} }
void Parser::handleTrekPointData(QStringRef element, const QString &value) void Parser::handleTrekPointData(QStringRef element, const QString &value)
{ {
if (element == "ele") if (element == "ele")
_track->last().elevation = value.toLatin1().toDouble(); _track->last().elevation = value.toLatin1().toDouble();
if (element == "time") else if (element == "time")
_track->last().timestamp = QDateTime::fromString(value.toLatin1(), _track->last().timestamp = QDateTime::fromString(value.toLatin1(),
Qt::ISODate); Qt::ISODate);
if (element == "geoidheight") else if (element == "geoidheight")
_track->last().geoidheight = value.toLatin1().toDouble(); _track->last().geoidheight = value.toLatin1().toDouble();
} }
@ -40,7 +42,8 @@ void Parser::handleWayPointAttributes(const QXmlStreamAttributes &attr)
void Parser::extensions() void Parser::extensions()
{ {
while (_reader.readNextStartElement()) { while (_reader.readNextStartElement()) {
if (_reader.name() == "speed") if (_reader.name() == "speed" || _reader.name() == "hr"
|| _reader.name() == "heartrate")
handleExtensionData(_reader.name(), _reader.readElementText()); handleExtensionData(_reader.name(), _reader.readElementText());
else else
_reader.skipCurrentElement(); _reader.skipCurrentElement();

View File

@ -7,13 +7,13 @@ SpeedGraph::SpeedGraph(QWidget *parent) : GraphView(parent)
{ {
_max = 0; _max = 0;
GraphView::setXLabel(tr("Distance")); setXLabel(tr("Distance"));
GraphView::setYLabel(tr("Speed")); setYLabel(tr("Speed"));
GraphView::setXUnits(tr("km")); setXUnits(tr("km"));
GraphView::setYUnits(tr("km/h")); setYUnits(tr("km/h"));
GraphView::setXScale(M2KM); setXScale(M2KM);
GraphView::setYScale(MS2KMH); setYScale(MS2KMH);
GraphView::setPrecision(1); setPrecision(1);
} }
void SpeedGraph::addInfo() void SpeedGraph::addInfo()
@ -31,14 +31,16 @@ void SpeedGraph::loadGPX(const GPX &gpx)
qreal max = 0; qreal max = 0;
gpx.track(i).speedGraph(data); gpx.track(i).speedGraph(data);
if (data.isEmpty()) if (data.count() < 2) {
skipColor();
continue; continue;
}
_avg.append(QPointF(gpx.track(i).distance(), gpx.track(i).distance() _avg.append(QPointF(gpx.track(i).distance(), gpx.track(i).distance()
/ gpx.track(i).time())); / gpx.track(i).time()));
for (int i = 0; i < data.size(); i++) for (int j = 0; j < data.size(); j++)
max = qMax(max, data.at(i).y()); max = qMax(max, data.at(j).y());
_max = qMax(_max, max); _max = qMax(_max, max);
addInfo(); addInfo();
@ -70,15 +72,15 @@ void SpeedGraph::clear()
void SpeedGraph::setUnits(enum Units units) void SpeedGraph::setUnits(enum Units units)
{ {
if (units == Metric) { if (units == Metric) {
GraphView::setXUnits(tr("km")); setXUnits(tr("km"));
GraphView::setYUnits(tr("km/h")); setYUnits(tr("km/h"));
GraphView::setXScale(M2KM); setXScale(M2KM);
GraphView::setYScale(MS2KMH); setYScale(MS2KMH);
} else { } else {
GraphView::setXUnits(tr("mi")); setXUnits(tr("mi"));
GraphView::setYUnits(tr("mi/h")); setYUnits(tr("mi/h"));
GraphView::setXScale(M2MI); setXScale(M2MI);
GraphView::setYScale(MS2MIH); setYScale(MS2MIH);
} }
clearInfo(); clearInfo();

View File

@ -6,6 +6,8 @@
#define WINDOW_EF 3 #define WINDOW_EF 3
#define WINDOW_SE 11 #define WINDOW_SE 11
#define WINDOW_SF 11 #define WINDOW_SF 11
#define WINDOW_HE 7
#define WINDOW_HF 5
static bool lt(const QPointF &p1, const QPointF &p2) static bool lt(const QPointF &p1, const QPointF &p2)
{ {
@ -78,6 +80,18 @@ static QVector<QPointF> filter(const QVector<QPointF> &v, int window)
return ret; return ret;
} }
Track::Track(const QVector<Trackpoint> &data) : _data(data)
{
_distance = 0;
for (int i = 1; i < _data.count(); i++)
_dd.append(llDistance(_data.at(i).coordinates,
_data.at(i-1).coordinates));
for (int i = 0; i < _dd.size(); i++)
_distance += _dd.at(i);
}
void Track::elevationGraph(QVector<QPointF> &graph) const void Track::elevationGraph(QVector<QPointF> &graph) const
{ {
qreal dist = 0; qreal dist = 0;
@ -86,12 +100,12 @@ void Track::elevationGraph(QVector<QPointF> &graph) const
if (!_data.size()) if (!_data.size())
return; return;
if (isnan(_data.at(0).elevation)) if (std::isnan(_data.at(0).elevation))
return; return;
raw.append(QPointF(0, _data.at(0).elevation)); raw.append(QPointF(0, _data.at(0).elevation));
for (int i = 1; i < _data.size(); i++) { for (int i = 1; i < _data.size(); i++) {
dist += llDistance(_data.at(i).coordinates, _data.at(i-1).coordinates); dist += _dd.at(i-1);
if (isnan(_data.at(i).elevation)) if (std::isnan(_data.at(i).elevation))
return; return;
raw.append(QPointF(dist, _data.at(i).elevation raw.append(QPointF(dist, _data.at(i).elevation
- _data.at(i).geoidheight)); - _data.at(i).geoidheight));
@ -110,11 +124,11 @@ void Track::speedGraph(QVector<QPointF> &graph) const
raw.append(QPointF(0, 0)); raw.append(QPointF(0, 0));
for (int i = 1; i < _data.size(); i++) { for (int i = 1; i < _data.size(); i++) {
ds = llDistance(_data.at(i).coordinates, _data.at(i-1).coordinates); ds = _dd.at(i-1);
dt = _data.at(i-1).timestamp.msecsTo(_data.at(i).timestamp) / 1000.0; dt = _data.at(i-1).timestamp.msecsTo(_data.at(i).timestamp) / 1000.0;
dist += ds; dist += ds;
if (isnan(_data.at(i).speed)) { if (std::isnan(_data.at(i).speed)) {
if (dt == 0) if (dt == 0)
continue; continue;
v = ds / dt; v = ds / dt;
@ -127,22 +141,30 @@ void Track::speedGraph(QVector<QPointF> &graph) const
graph = filter(eliminate(raw, WINDOW_SE), WINDOW_SF); graph = filter(eliminate(raw, WINDOW_SE), WINDOW_SF);
} }
void Track::heartRateGraph(QVector<QPointF> &graph) const
{
qreal dist = 0;
QVector<QPointF> raw;
if (std::isnan(_data.at(0).heartRate))
return;
raw.append(QPointF(0, _data.at(0).heartRate));
for (int i = 1; i < _data.count(); i++) {
if (std::isnan(_data.at(i).heartRate))
return;
dist += _dd.at(i-1);
raw.append(QPointF(dist, _data.at(i).heartRate));
}
graph = filter(eliminate(raw, WINDOW_HE), WINDOW_HF);
}
void Track::track(QVector<QPointF> &track) const void Track::track(QVector<QPointF> &track) const
{ {
for (int i = 0; i < _data.size(); i++) for (int i = 0; i < _data.size(); i++)
track.append(_data.at(i).coordinates); track.append(_data.at(i).coordinates);
} }
qreal Track::distance() const
{
qreal dist = 0;
for (int i = 1; i < _data.size(); i++)
dist += llDistance(_data.at(i).coordinates, _data.at(i-1).coordinates);
return dist;
}
qreal Track::time() const qreal Track::time() const
{ {
if (_data.size() < 2) if (_data.size() < 2)

View File

@ -8,17 +8,20 @@
class Track class Track
{ {
public: public:
Track(const QVector<Trackpoint> &data) : _data(data) {} Track(const QVector<Trackpoint> &data);
void elevationGraph(QVector<QPointF> &graph) const; void elevationGraph(QVector<QPointF> &graph) const;
void speedGraph(QVector<QPointF> &graph) const; void speedGraph(QVector<QPointF> &graph) const;
void heartRateGraph(QVector<QPointF> &graph) const;
void track(QVector<QPointF> &track) const; void track(QVector<QPointF> &track) const;
qreal distance() const; qreal distance() const {return _distance;}
qreal time() const; qreal time() const;
QDateTime date() const; QDateTime date() const;
private: private:
const QVector<Trackpoint> &_data; const QVector<Trackpoint> &_data;
QVector<qreal> _dd;
qreal _distance;
}; };
#endif // TRACK_H #endif // TRACK_H

View File

@ -12,8 +12,14 @@ struct Trackpoint
qreal elevation; qreal elevation;
qreal geoidheight; qreal geoidheight;
qreal speed; qreal speed;
qreal heartRate;
Trackpoint() {elevation = NAN; geoidheight = 0; speed = NAN;} Trackpoint() {
elevation = NAN;
geoidheight = 0;
speed = NAN;
heartRate = NAN;
}
}; };
#endif // TRACKPOINT_H #endif // TRACKPOINT_H

View File

@ -34,7 +34,8 @@ TrackView::TrackView(QWidget *parent)
_zoom = ZOOM_MAX; _zoom = ZOOM_MAX;
_scale = mapScale(_zoom); _scale = mapScale(_zoom);
_map = 0; _map = 0;
_maxLen = 0; _maxPath = 0;
_maxDistance = 0;
} }
TrackView::~TrackView() TrackView::~TrackView()
@ -61,8 +62,7 @@ void TrackView::addTrack(const QVector<QPointF> &track)
path.lineTo(ll2mercator(QPointF(p.x(), -p.y()))); path.lineTo(ll2mercator(QPointF(p.x(), -p.y())));
} }
_maxLen = qMax(path.length(), _maxLen); _maxPath = qMax(path.length(), _maxPath);
pi = new QGraphicsPathItem(path); pi = new QGraphicsPathItem(path);
_paths.append(pi); _paths.append(pi);
@ -108,6 +108,7 @@ void TrackView::loadGPX(const GPX &gpx)
QVector<QPointF> track; QVector<QPointF> track;
gpx.track(i).track(track); gpx.track(i).track(track);
addTrack(track); addTrack(track);
_maxDistance = qMax(gpx.track(i).distance(), _maxDistance);
} }
addWaypoints(gpx.waypoints()); addWaypoints(gpx.waypoints());
@ -403,7 +404,8 @@ void TrackView::clear()
_tracks.clear(); _tracks.clear();
_waypoints.clear(); _waypoints.clear();
_maxLen = 0; _maxPath = 0;
_maxDistance = 0;
_zoom = ZOOM_MAX; _zoom = ZOOM_MAX;
_scale = mapScale(_zoom); _scale = mapScale(_zoom);
@ -412,11 +414,17 @@ void TrackView::clear()
void TrackView::movePositionMarker(qreal val) void TrackView::movePositionMarker(qreal val)
{ {
qreal mp = val / _maxDistance;
for (int i = 0; i < _paths.size(); i++) { for (int i = 0; i < _paths.size(); i++) {
qreal f = _maxLen / _paths.at(i)->path().length(); qreal f = _maxPath / _paths.at(i)->path().length();
QPointF pos = _paths.at(i)->path().pointAtPercent(qMin(val * f, if (mp * f > 1.0)
1.0)); _markers.at(i)->setVisible(false);
else {
QPointF pos = _paths.at(i)->path().pointAtPercent(mp * f);
_markers.at(i)->setPos(pos); _markers.at(i)->setPos(pos);
_markers.at(i)->setVisible(true);
}
} }
} }

View File

@ -75,7 +75,7 @@ private:
ScaleItem *_mapScale; ScaleItem *_mapScale;
Palette _palette; Palette _palette;
qreal _maxLen; qreal _maxPath, _maxDistance;
qreal _scale; qreal _scale;
int _zoom; int _zoom;