1
0
mirror of https://github.com/tumic0/GPXSee.git synced 2024-11-30 22:51:16 +01:00

Added support for time graphs

This commit is contained in:
Martin Tůma 2016-09-19 00:56:10 +02:00
parent aa461a04b1
commit 3e421c6aba
35 changed files with 715 additions and 564 deletions

View File

@ -50,7 +50,9 @@ HEADERS += src/config.h \
src/tooltip.h \ src/tooltip.h \
src/route.h \ src/route.h \
src/routeitem.h \ src/routeitem.h \
src/graphitem.h src/graphitem.h \
src/graph.h \
src/pathitem.h
SOURCES += src/main.cpp \ SOURCES += src/main.cpp \
src/gui.cpp \ src/gui.cpp \
src/gpx.cpp \ src/gpx.cpp \

View File

@ -14,6 +14,7 @@
<file>icons/arrow-left-double.png</file> <file>icons/arrow-left-double.png</file>
<file>icons/arrow-right-double.png</file> <file>icons/arrow-right-double.png</file>
<file>icons/view-fullscreen.png</file> <file>icons/view-fullscreen.png</file>
<file>icons/office-chart-line-stacked.png</file>
<file>lang/gpxsee_cs.qm</file> <file>lang/gpxsee_cs.qm</file>
</qresource> </qresource>
</RCC> </RCC>

View File

@ -5,54 +5,37 @@
<name>ElevationGraph</name> <name>ElevationGraph</name>
<message> <message>
<location filename="../src/elevationgraph.cpp" line="48"/> <location filename="../src/elevationgraph.cpp" line="48"/>
<source>Distance</source> <location filename="../src/elevationgraph.h" line="16"/>
<translation>Vzdálenost</translation>
</message>
<message>
<location filename="../src/elevationgraph.cpp" line="49"/>
<location filename="../src/elevationgraph.h" line="15"/>
<source>Elevation</source> <source>Elevation</source>
<translation>Výška</translation> <translation>Výška</translation>
</message> </message>
<message> <message>
<location filename="../src/elevationgraph.cpp" line="145"/> <location filename="../src/elevationgraph.cpp" line="139"/>
<source>km</source>
<translation>km</translation>
</message>
<message>
<location filename="../src/elevationgraph.cpp" line="142"/>
<location filename="../src/elevationgraph.cpp" line="162"/>
<source>m</source> <source>m</source>
<translation>m</translation> <translation>m</translation>
</message> </message>
<message> <message>
<location filename="../src/elevationgraph.cpp" line="59"/> <location filename="../src/elevationgraph.cpp" line="58"/>
<source>Ascent</source> <source>Ascent</source>
<translation>Stoupání</translation> <translation>Stoupání</translation>
</message> </message>
<message> <message>
<location filename="../src/elevationgraph.cpp" line="61"/> <location filename="../src/elevationgraph.cpp" line="60"/>
<source>Descent</source> <source>Descent</source>
<translation>Klesání</translation> <translation>Klesání</translation>
</message> </message>
<message> <message>
<location filename="../src/elevationgraph.cpp" line="65"/> <location filename="../src/elevationgraph.cpp" line="64"/>
<source>Minimum</source> <source>Minimum</source>
<translation>Minimum</translation> <translation>Minimum</translation>
</message> </message>
<message> <message>
<location filename="../src/elevationgraph.cpp" line="153"/> <location filename="../src/elevationgraph.cpp" line="142"/>
<source>mi</source>
<translation>mi</translation>
</message>
<message>
<location filename="../src/elevationgraph.cpp" line="150"/>
<location filename="../src/elevationgraph.cpp" line="165"/>
<source>ft</source> <source>ft</source>
<translation>ft</translation> <translation>ft</translation>
</message> </message>
<message> <message>
<location filename="../src/elevationgraph.cpp" line="63"/> <location filename="../src/elevationgraph.cpp" line="62"/>
<source>Maximum</source> <source>Maximum</source>
<translation>Maximum</translation> <translation>Maximum</translation>
</message> </message>
@ -163,370 +146,377 @@
<context> <context>
<name>GUI</name> <name>GUI</name>
<message> <message>
<location filename="../src/gui.cpp" line="484"/> <location filename="../src/gui.cpp" line="513"/>
<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="548"/> <location filename="../src/gui.cpp" line="577"/>
<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="628"/> <location filename="../src/gui.cpp" line="657"/>
<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="198"/> <location filename="../src/gui.cpp" line="204"/>
<source>Open</source> <source>Open</source>
<translation>Otevřít</translation> <translation>Otevřít</translation>
</message> </message>
<message> <message>
<location filename="../src/gui.cpp" line="182"/> <location filename="../src/gui.cpp" line="188"/>
<source>Quit</source> <source>Quit</source>
<translation>Ukončit</translation> <translation>Ukončit</translation>
</message> </message>
<message> <message>
<location filename="../src/gui.cpp" line="190"/> <location filename="../src/gui.cpp" line="196"/>
<location filename="../src/gui.cpp" line="500"/> <location filename="../src/gui.cpp" line="529"/>
<location filename="../src/gui.cpp" line="501"/> <location filename="../src/gui.cpp" line="530"/>
<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="214"/> <location filename="../src/gui.cpp" line="220"/>
<source>Close</source> <source>Close</source>
<translation>Zavřít</translation> <translation>Zavřít</translation>
</message> </message>
<message> <message>
<location filename="../src/gui.cpp" line="220"/> <location filename="../src/gui.cpp" line="226"/>
<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="418"/> <location filename="../src/gui.cpp" line="446"/>
<source>Show</source> <source>Show</source>
<translation>Zobrazit</translation> <translation>Zobrazit</translation>
</message> </message>
<message> <message>
<location filename="../src/gui.cpp" line="347"/> <location filename="../src/gui.cpp" line="370"/>
<location filename="../src/gui.cpp" line="412"/> <location filename="../src/gui.cpp" line="440"/>
<source>File</source> <source>File</source>
<translation>Soubor</translation> <translation>Soubor</translation>
</message> </message>
<message> <message>
<location filename="../src/gui.cpp" line="188"/> <location filename="../src/gui.cpp" line="194"/>
<location filename="../src/gui.cpp" line="523"/> <location filename="../src/gui.cpp" line="552"/>
<location filename="../src/gui.cpp" line="524"/> <location filename="../src/gui.cpp" line="553"/>
<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="228"/> <location filename="../src/gui.cpp" line="234"/>
<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="231"/> <location filename="../src/gui.cpp" line="237"/>
<source>Close POI files</source> <source>Close POI files</source>
<translation>Zavřit POI soubory</translation> <translation>Zavřit POI soubory</translation>
</message> </message>
<message> <message>
<location filename="../src/gui.cpp" line="233"/> <location filename="../src/gui.cpp" line="239"/>
<source>Overlap POIs</source> <source>Overlap POIs</source>
<translation>Překrývat POI</translation> <translation>Překrývat POI</translation>
</message> </message>
<message> <message>
<location filename="../src/gui.cpp" line="237"/> <location filename="../src/gui.cpp" line="243"/>
<source>Show POI labels</source> <source>Show POI labels</source>
<translation>Zobrazovat názvy POI</translation> <translation>Zobrazovat názvy POI</translation>
</message> </message>
<message> <message>
<location filename="../src/gui.cpp" line="242"/> <location filename="../src/gui.cpp" line="248"/>
<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="250"/> <location filename="../src/gui.cpp" line="256"/>
<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="256"/> <location filename="../src/gui.cpp" line="262"/>
<source>Clear tile cache</source> <source>Clear tile cache</source>
<translation>Vymazat mezipaměť dlaždic</translation> <translation>Vymazat mezipaměť dlaždic</translation>
</message> </message>
<message> <message>
<location filename="../src/gui.cpp" line="265"/> <location filename="../src/gui.cpp" line="271"/>
<location filename="../src/gui.cpp" line="269"/> <location filename="../src/gui.cpp" line="275"/>
<location filename="../src/gui.cpp" line="510"/> <location filename="../src/gui.cpp" line="539"/>
<source>Next map</source> <source>Next map</source>
<translation>Následující mapa</translation> <translation>Následující mapa</translation>
</message> </message>
<message> <message>
<location filename="../src/gui.cpp" line="276"/> <location filename="../src/gui.cpp" line="282"/>
<source>Show tracks</source> <source>Show tracks</source>
<translation>Zobrazit cesty</translation> <translation>Zobrazit cesty</translation>
</message> </message>
<message> <message>
<location filename="../src/gui.cpp" line="280"/> <location filename="../src/gui.cpp" line="286"/>
<source>Show routes</source> <source>Show routes</source>
<translation>Zobrazit trasy</translation> <translation>Zobrazit trasy</translation>
</message> </message>
<message> <message>
<location filename="../src/gui.cpp" line="284"/> <location filename="../src/gui.cpp" line="290"/>
<source>Show waypoints</source> <source>Show waypoints</source>
<translation>Zobrazit navigační body</translation> <translation>Zobrazit navigační body</translation>
</message> </message>
<message> <message>
<location filename="../src/gui.cpp" line="288"/> <location filename="../src/gui.cpp" line="294"/>
<source>Waypoint labels</source> <source>Waypoint labels</source>
<translation>Názvy navigačních bodů</translation> <translation>Názvy navigačních bodů</translation>
</message> </message>
<message> <message>
<location filename="../src/gui.cpp" line="298"/> <location filename="../src/gui.cpp" line="305"/>
<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="304"/> <location filename="../src/gui.cpp" line="327"/>
<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="310"/> <location filename="../src/gui.cpp" line="333"/>
<source>Metric</source> <source>Metric</source>
<translation>Metrické</translation> <translation>Metrické</translation>
</message> </message>
<message> <message>
<location filename="../src/gui.cpp" line="315"/> <location filename="../src/gui.cpp" line="338"/>
<source>Imperial</source> <source>Imperial</source>
<translation>Imperiální</translation> <translation>Imperiální</translation>
</message> </message>
<message> <message>
<location filename="../src/gui.cpp" line="321"/> <location filename="../src/gui.cpp" line="344"/>
<source>Fullscreen mode</source> <source>Fullscreen mode</source>
<translation>Celoobrazovkový režim</translation> <translation>Celoobrazovkový režim</translation>
</message> </message>
<message> <message>
<location filename="../src/gui.cpp" line="329"/> <location filename="../src/gui.cpp" line="352"/>
<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="332"/> <location filename="../src/gui.cpp" line="355"/>
<source>Previous</source> <source>Previous</source>
<translation>Předchozí</translation> <translation>Předchozí</translation>
</message> </message>
<message> <message>
<location filename="../src/gui.cpp" line="336"/> <location filename="../src/gui.cpp" line="359"/>
<source>Last</source> <source>Last</source>
<translation>Poslední</translation> <translation>Poslední</translation>
</message> </message>
<message> <message>
<location filename="../src/gui.cpp" line="339"/> <location filename="../src/gui.cpp" line="362"/>
<source>First</source> <source>First</source>
<translation>První</translation> <translation>První</translation>
</message> </message>
<message> <message>
<location filename="../src/gui.cpp" line="361"/> <location filename="../src/gui.cpp" line="384"/>
<source>Map</source> <source>Map</source>
<translation>Mapa</translation> <translation>Mapa</translation>
</message> </message>
<message> <message>
<location filename="../src/gui.cpp" line="368"/> <location filename="../src/gui.cpp" line="391"/>
<source>Graph</source>
<translation>Graf</translation>
</message>
<message>
<location filename="../src/gui.cpp" line="397"/>
<source>POI</source> <source>POI</source>
<translation>POI</translation> <translation>POI</translation>
</message> </message>
<message> <message>
<location filename="../src/gui.cpp" line="369"/> <location filename="../src/gui.cpp" line="398"/>
<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="380"/> <location filename="../src/gui.cpp" line="409"/>
<source>Data</source> <source>Data</source>
<translation>Data</translation> <translation>Data</translation>
</message> </message>
<message> <message>
<location filename="../src/gui.cpp" line="381"/> <location filename="../src/gui.cpp" line="410"/>
<source>Display</source> <source>Display</source>
<translation>Zobrazit</translation> <translation>Zobrazit</translation>
</message> </message>
<message> <message>
<location filename="../src/gui.cpp" line="389"/> <location filename="../src/gui.cpp" line="418"/>
<source>Settings</source> <source>Settings</source>
<translation>Nastavení</translation> <translation>Nastavení</translation>
</message> </message>
<message> <message>
<location filename="../src/gui.cpp" line="390"/> <location filename="../src/gui.cpp" line="419"/>
<source>Units</source> <source>Units</source>
<translation>Jednotky</translation> <translation>Jednotky</translation>
</message> </message>
<message> <message>
<location filename="../src/gui.cpp" line="399"/> <location filename="../src/gui.cpp" line="427"/>
<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="512"/> <location filename="../src/gui.cpp" line="541"/>
<source>Previous map</source> <source>Previous map</source>
<translation>Předchozí mapa</translation> <translation>Předchozí mapa</translation>
</message> </message>
<message> <message>
<location filename="../src/gui.cpp" line="716"/> <location filename="../src/gui.cpp" line="745"/>
<location filename="../src/gui.cpp" line="719"/> <location filename="../src/gui.cpp" line="748"/>
<source>Date</source> <source>Date</source>
<translation>Datum</translation> <translation>Datum</translation>
</message> </message>
<message> <message>
<location filename="../src/gui.cpp" line="728"/> <location filename="../src/gui.cpp" line="757"/>
<source>Routes</source> <source>Routes</source>
<translation>Trasy</translation> <translation>Trasy</translation>
</message> </message>
<message> <message>
<location filename="../src/gui.cpp" line="918"/> <location filename="../src/gui.cpp" line="947"/>
<source>No GPX files loaded</source> <source>No GPX files loaded</source>
<translation>Nejsou načteny žádné GPX soubory</translation> <translation>Nejsou načteny žádné GPX soubory</translation>
</message> </message>
<message> <message>
<location filename="../src/gui.cpp" line="922"/> <location filename="../src/gui.cpp" line="951"/>
<source>%1 files</source> <source>%1 files</source>
<translation>%1 souborů</translation> <translation>%1 souborů</translation>
</message> </message>
<message> <message>
<location filename="../src/gui.cpp" line="503"/> <location filename="../src/gui.cpp" line="532"/>
<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="480"/> <location filename="../src/gui.cpp" line="509"/>
<source>Version </source> <source>Version </source>
<translation>Verze </translation> <translation>Verze </translation>
</message> </message>
<message> <message>
<location filename="../src/gui.cpp" line="203"/> <location filename="../src/gui.cpp" line="209"/>
<source>Print...</source> <source>Print...</source>
<translation>Tisknout...</translation> <translation>Tisknout...</translation>
</message> </message>
<message> <message>
<location filename="../src/gui.cpp" line="208"/> <location filename="../src/gui.cpp" line="214"/>
<source>Export to PDF...</source> <source>Export to PDF...</source>
<translation>Exportovat do PDF...</translation> <translation>Exportovat do PDF...</translation>
</message> </message>
<message> <message>
<location filename="../src/gui.cpp" line="730"/> <location filename="../src/gui.cpp" line="759"/>
<source>Waypoints</source> <source>Waypoints</source>
<translation>Navigační body</translation> <translation>Navigační body</translation>
</message> </message>
<message> <message>
<location filename="../src/gui.cpp" line="504"/> <location filename="../src/gui.cpp" line="533"/>
<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="292"/> <location filename="../src/gui.cpp" line="298"/>
<source>Route waypoints</source> <source>Route waypoints</source>
<translation>Body tras</translation> <translation>Body tras</translation>
</message> </message>
<message> <message>
<location filename="../src/gui.cpp" line="506"/> <location filename="../src/gui.cpp" line="535"/>
<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="507"/> <location filename="../src/gui.cpp" line="536"/>
<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="508"/> <location filename="../src/gui.cpp" line="537"/>
<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="527"/> <location filename="../src/gui.cpp" line="556"/>
<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="530"/> <location filename="../src/gui.cpp" line="559"/>
<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="538"/> <location filename="../src/gui.cpp" line="567"/>
<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="549"/> <location filename="../src/gui.cpp" line="578"/>
<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="619"/> <location filename="../src/gui.cpp" line="648"/>
<location filename="../src/gui.cpp" line="645"/> <location filename="../src/gui.cpp" line="674"/>
<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="629"/> <location filename="../src/gui.cpp" line="658"/>
<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="726"/> <location filename="../src/gui.cpp" line="755"/>
<source>Tracks</source> <source>Tracks</source>
<translation>Cesty</translation> <translation>Cesty</translation>
</message> </message>
<message> <message>
<location filename="../src/gui.cpp" line="193"/> <location filename="../src/gui.cpp" line="199"/>
<location filename="../src/gui.cpp" line="478"/> <location filename="../src/gui.cpp" line="507"/>
<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="422"/> <location filename="../src/gui.cpp" line="451"/>
<source>Navigation</source> <source>Navigation</source>
<translation>Navigace</translation> <translation>Navigace</translation>
</message> </message>
<message> <message>
<location filename="../src/gui.cpp" line="526"/> <location filename="../src/gui.cpp" line="555"/>
<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="537"/> <location filename="../src/gui.cpp" line="566"/>
<source>POIs</source> <source>POIs</source>
<translation>POI body</translation> <translation>POI body</translation>
</message> </message>
<message> <message>
<location filename="../src/gui.cpp" line="733"/> <location filename="../src/gui.cpp" line="313"/>
<location filename="../src/gui.cpp" line="762"/>
<source>Distance</source> <source>Distance</source>
<translation>Vzdálenost</translation> <translation>Vzdálenost</translation>
</message> </message>
<message> <message>
<location filename="../src/gui.cpp" line="735"/> <location filename="../src/gui.cpp" line="319"/>
<location filename="../src/gui.cpp" line="764"/>
<source>Time</source> <source>Time</source>
<translation>Čas</translation> <translation>Čas</translation>
</message> </message>
<message> <message>
<location filename="../src/gui.cpp" line="621"/> <location filename="../src/gui.cpp" line="650"/>
<location filename="../src/gui.cpp" line="646"/> <location filename="../src/gui.cpp" line="675"/>
<source>Error</source> <source>Error</source>
<translation>Chyba</translation> <translation>Chyba</translation>
</message> </message>
<message> <message>
<location filename="../src/gui.cpp" line="616"/> <location filename="../src/gui.cpp" line="645"/>
<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="642"/> <location filename="../src/gui.cpp" line="671"/>
<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:
@ -534,53 +524,76 @@
</message> </message>
</context> </context>
<context> <context>
<name>HeartRateGraph</name> <name>GraphView</name>
<message> <message>
<location filename="../src/heartrategraph.cpp" line="11"/> <location filename="../src/graphview.cpp" line="110"/>
<source>m</source>
<translation>m</translation>
</message>
<message>
<location filename="../src/graphview.cpp" line="113"/>
<source>km</source>
<translation>km</translation>
</message>
<message>
<location filename="../src/graphview.cpp" line="118"/>
<source>ft</source>
<translation>ft</translation>
</message>
<message>
<location filename="../src/graphview.cpp" line="121"/>
<source>mi</source>
<translation>mi</translation>
</message>
<message>
<location filename="../src/graphview.cpp" line="127"/>
<source>s</source>
<translation>s</translation>
</message>
<message>
<location filename="../src/graphview.cpp" line="130"/>
<source>min</source>
<translation>min</translation>
</message>
<message>
<location filename="../src/graphview.cpp" line="133"/>
<source>h</source>
<translation>h</translation>
</message>
<message>
<location filename="../src/graphview.cpp" line="158"/>
<source>Distance</source> <source>Distance</source>
<translation>Vzdálenost</translation> <translation>Vzdálenost</translation>
</message> </message>
<message> <message>
<location filename="../src/heartrategraph.cpp" line="12"/> <location filename="../src/graphview.cpp" line="160"/>
<source>Time</source>
<translation>Čas</translation>
</message>
</context>
<context>
<name>HeartRateGraph</name>
<message>
<location filename="../src/heartrategraph.cpp" line="11"/>
<location filename="../src/heartrategraph.h" line="15"/> <location filename="../src/heartrategraph.h" line="15"/>
<source>Heart rate</source> <source>Heart rate</source>
<translation>Tep</translation> <translation>Tep</translation>
</message> </message>
<message>
<location filename="../src/heartrategraph.cpp" line="84"/>
<source>km</source>
<translation>km</translation>
</message>
<message> <message>
<location filename="../src/heartrategraph.cpp" line="10"/> <location filename="../src/heartrategraph.cpp" line="10"/>
<source>1/min</source> <source>1/min</source>
<translation>1/min</translation> <translation>1/min</translation>
</message> </message>
<message> <message>
<location filename="../src/heartrategraph.cpp" line="20"/> <location filename="../src/heartrategraph.cpp" line="19"/>
<source>Average</source> <source>Average</source>
<translation>Průměr</translation> <translation>Průměr</translation>
</message> </message>
<message> <message>
<location filename="../src/heartrategraph.cpp" line="22"/> <location filename="../src/heartrategraph.cpp" line="21"/>
<source>Maximum</source> <source>Maximum</source>
<translation>Maximum</translation> <translation>Maximum</translation>
</message> </message>
<message>
<location filename="../src/heartrategraph.cpp" line="81"/>
<source>m</source>
<translation>m</translation>
</message>
<message>
<location filename="../src/heartrategraph.cpp" line="89"/>
<source>ft</source>
<translation>ft</translation>
</message>
<message>
<location filename="../src/heartrategraph.cpp" line="92"/>
<source>mi</source>
<translation>mi</translation>
</message>
</context> </context>
<context> <context>
<name>Misc</name> <name>Misc</name>
@ -610,7 +623,7 @@
<context> <context>
<name>RouteItem</name> <name>RouteItem</name>
<message> <message>
<location filename="../src/routeitem.cpp" line="17"/> <location filename="../src/routeitem.cpp" line="18"/>
<source>Distance</source> <source>Distance</source>
<translation>Vzdálenost</translation> <translation>Vzdálenost</translation>
</message> </message>
@ -618,22 +631,22 @@
<context> <context>
<name>ScaleItem</name> <name>ScaleItem</name>
<message> <message>
<location filename="../src/scaleitem.cpp" line="81"/> <location filename="../src/scaleitem.cpp" line="87"/>
<source>mi</source> <source>mi</source>
<translation>mi</translation> <translation>mi</translation>
</message> </message>
<message> <message>
<location filename="../src/scaleitem.cpp" line="82"/> <location filename="../src/scaleitem.cpp" line="88"/>
<source>ft</source> <source>ft</source>
<translation>ft</translation> <translation>ft</translation>
</message> </message>
<message> <message>
<location filename="../src/scaleitem.cpp" line="84"/> <location filename="../src/scaleitem.cpp" line="90"/>
<source>km</source> <source>km</source>
<translation>km</translation> <translation>km</translation>
</message> </message>
<message> <message>
<location filename="../src/scaleitem.cpp" line="85"/> <location filename="../src/scaleitem.cpp" line="91"/>
<source>m</source> <source>m</source>
<translation>m</translation> <translation>m</translation>
</message> </message>
@ -642,52 +655,27 @@
<name>SpeedGraph</name> <name>SpeedGraph</name>
<message> <message>
<location filename="../src/speedgraph.cpp" line="12"/> <location filename="../src/speedgraph.cpp" line="12"/>
<source>Distance</source>
<translation>Vzdálenost</translation>
</message>
<message>
<location filename="../src/speedgraph.cpp" line="13"/>
<location filename="../src/speedgraph.h" line="16"/> <location filename="../src/speedgraph.h" line="16"/>
<source>Speed</source> <source>Speed</source>
<translation>Rychlost</translation> <translation>Rychlost</translation>
</message> </message>
<message> <message>
<location filename="../src/speedgraph.cpp" line="77"/> <location filename="../src/speedgraph.cpp" line="74"/>
<source>m</source>
<translation>m</translation>
</message>
<message>
<location filename="../src/speedgraph.cpp" line="80"/>
<source>km</source>
<translation></translation>
</message>
<message>
<location filename="../src/speedgraph.cpp" line="85"/>
<source>ft</source>
<translation>ft</translation>
</message>
<message>
<location filename="../src/speedgraph.cpp" line="97"/>
<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="20"/>
<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="22"/>
<source>Maximum</source> <source>Maximum</source>
<translation>Maximum</translation> <translation>Maximum</translation>
</message> </message>
<message> <message>
<location filename="../src/speedgraph.cpp" line="88"/> <location filename="../src/speedgraph.cpp" line="77"/>
<source>mi</source>
<translation>mi</translation>
</message>
<message>
<location filename="../src/speedgraph.cpp" line="100"/>
<source>mi/h</source> <source>mi/h</source>
<translation>mi/h</translation> <translation>mi/h</translation>
</message> </message>
@ -696,57 +684,32 @@
<name>TemperatureGraph</name> <name>TemperatureGraph</name>
<message> <message>
<location filename="../src/temperaturegraph.cpp" line="11"/> <location filename="../src/temperaturegraph.cpp" line="11"/>
<source>Distance</source>
<translation>Vzdálenost</translation>
</message>
<message>
<location filename="../src/temperaturegraph.cpp" line="12"/>
<location filename="../src/temperaturegraph.h" line="15"/> <location filename="../src/temperaturegraph.h" line="15"/>
<source>Temperature</source> <source>Temperature</source>
<translation>Teplota</translation> <translation>Teplota</translation>
</message> </message>
<message> <message>
<location filename="../src/temperaturegraph.cpp" line="20"/> <location filename="../src/temperaturegraph.cpp" line="19"/>
<source>Average</source> <source>Average</source>
<translation>Průměr</translation> <translation>Průměr</translation>
</message> </message>
<message> <message>
<location filename="../src/temperaturegraph.cpp" line="22"/> <location filename="../src/temperaturegraph.cpp" line="21"/>
<source>Minimum</source> <source>Minimum</source>
<translation>Minimum</translation> <translation>Minimum</translation>
</message> </message>
<message> <message>
<location filename="../src/temperaturegraph.cpp" line="24"/> <location filename="../src/temperaturegraph.cpp" line="23"/>
<source>Maximum</source> <source>Maximum</source>
<translation>Maximum</translation> <translation>Maximum</translation>
</message> </message>
<message> <message>
<location filename="../src/temperaturegraph.cpp" line="83"/> <location filename="../src/temperaturegraph.cpp" line="81"/>
<source>m</source>
<translation>m</translation>
</message>
<message>
<location filename="../src/temperaturegraph.cpp" line="86"/>
<source>km</source>
<translation>km</translation>
</message>
<message>
<location filename="../src/temperaturegraph.cpp" line="91"/>
<source>ft</source>
<translation>ft</translation>
</message>
<message>
<location filename="../src/temperaturegraph.cpp" line="94"/>
<source>mi</source>
<translation>mi</translation>
</message>
<message>
<location filename="../src/temperaturegraph.cpp" line="103"/>
<source>C</source> <source>C</source>
<translation>C</translation> <translation>C</translation>
</message> </message>
<message> <message>
<location filename="../src/temperaturegraph.cpp" line="107"/> <location filename="../src/temperaturegraph.cpp" line="85"/>
<source>F</source> <source>F</source>
<translation>F</translation> <translation>F</translation>
</message> </message>
@ -754,17 +717,17 @@
<context> <context>
<name>TrackItem</name> <name>TrackItem</name>
<message> <message>
<location filename="../src/trackitem.cpp" line="16"/> <location filename="../src/trackitem.cpp" line="17"/>
<source>Distance</source> <source>Distance</source>
<translation>Vzdálenost</translation> <translation>Vzdálenost</translation>
</message> </message>
<message> <message>
<location filename="../src/trackitem.cpp" line="19"/> <location filename="../src/trackitem.cpp" line="20"/>
<source>Time</source> <source>Time</source>
<translation>Čas</translation> <translation>Čas</translation>
</message> </message>
<message> <message>
<location filename="../src/trackitem.cpp" line="21"/> <location filename="../src/trackitem.cpp" line="22"/>
<source>Date</source> <source>Date</source>
<translation>Datum</translation> <translation>Datum</translation>
</message> </message>
@ -772,27 +735,27 @@
<context> <context>
<name>WaypointItem</name> <name>WaypointItem</name>
<message> <message>
<location filename="../src/waypointitem.cpp" line="17"/> <location filename="../src/waypointitem.cpp" line="18"/>
<source>Name</source> <source>Name</source>
<translation>Název</translation> <translation>Název</translation>
</message> </message>
<message> <message>
<location filename="../src/waypointitem.cpp" line="18"/> <location filename="../src/waypointitem.cpp" line="19"/>
<source>Coordinates</source> <source>Coordinates</source>
<translation>Souřadnice</translation> <translation>Souřadnice</translation>
</message> </message>
<message> <message>
<location filename="../src/waypointitem.cpp" line="21"/> <location filename="../src/waypointitem.cpp" line="22"/>
<source>Elevation</source> <source>Elevation</source>
<translation>Výška</translation> <translation>Výška</translation>
</message> </message>
<message> <message>
<location filename="../src/waypointitem.cpp" line="24"/> <location filename="../src/waypointitem.cpp" line="25"/>
<source>Date</source> <source>Date</source>
<translation>Datum</translation> <translation>Datum</translation>
</message> </message>
<message> <message>
<location filename="../src/waypointitem.cpp" line="27"/> <location filename="../src/waypointitem.cpp" line="28"/>
<source>Description</source> <source>Description</source>
<translation>Popis</translation> <translation>Popis</translation>
</message> </message>

View File

@ -45,7 +45,6 @@ ElevationGraph::ElevationGraph(QWidget *parent) : GraphTab(parent)
_units = Metric; _units = Metric;
setYUnits(); setYUnits();
setXLabel(tr("Distance"));
setYLabel(tr("Elevation")); setYLabel(tr("Elevation"));
setMinYRange(50.0); setMinYRange(50.0);
@ -67,20 +66,20 @@ void ElevationGraph::setInfo()
} }
} }
void ElevationGraph::loadPath(const QVector<QPointF> &data, Type type) void ElevationGraph::loadGraph(const Graph &graph, Type type, PathItem *path)
{ {
qreal ascent = 0, descent = 0; qreal ascent = 0, descent = 0;
qreal min, max; qreal min, max;
if (data.count() < 2) { if (graph.y.count() < 2) {
skipColor(); skipColor();
return; return;
} }
max = min = data.at(0).y(); max = min = graph.y.at(0);
for (int j = 1; j < data.size(); j++) { for (int j = 1; j < graph.y.size(); j++) {
qreal cur = data.at(j).y(); qreal cur = graph.y.at(j);
qreal prev = data.at(j-1).y(); qreal prev = graph.y.at(j-1);
if (cur > prev) if (cur > prev)
ascent += cur - prev; ascent += cur - prev;
@ -105,17 +104,18 @@ void ElevationGraph::loadPath(const QVector<QPointF> &data, Type type)
_routeMin = nMin(_routeMin, min); _routeMin = nMin(_routeMin, min);
} }
loadData(data, type); GraphView::loadGraph(graph, path, type);
} }
void ElevationGraph::loadGPX(const GPX &gpx) void ElevationGraph::loadGPX(const GPX &gpx, const QList<PathItem *> &paths)
{ {
for (int i = 0; i < gpx.tracks().count(); i++) int p = 0;
loadPath(gpx.tracks().at(i)->elevation(), Track);
for (int i = 0; i < gpx.routes().count(); i++) for (int i = 0; i < gpx.tracks().count(); i++)
loadPath(gpx.routes().at(i)->elevation(), Route); loadGraph(gpx.tracks().at(i)->elevation(), Track, paths.at(p++));
for (int i = 0; i < gpx.routes().count(); i++)
loadGraph(gpx.routes().at(i)->elevation(), Route, paths.at(p++));
setXUnits();
setInfo(); setInfo();
redraw(); redraw();
@ -135,27 +135,6 @@ void ElevationGraph::clear()
GraphView::clear(); GraphView::clear();
} }
void ElevationGraph::setXUnits()
{
if (_units == Metric) {
if (bounds().width() < KMINM) {
GraphView::setXUnits(tr("m"));
setXScale(1);
} else {
GraphView::setXUnits(tr("km"));
setXScale(M2KM);
}
} else {
if (bounds().width() < MIINM) {
GraphView::setXUnits(tr("ft"));
setXScale(M2FT);
} else {
GraphView::setXUnits(tr("mi"));
setXScale(M2MI);
}
}
}
void ElevationGraph::setYUnits() void ElevationGraph::setYUnits()
{ {
if (_units == Metric) { if (_units == Metric) {
@ -171,9 +150,9 @@ void ElevationGraph::setUnits(enum Units units)
{ {
_units = units; _units = units;
setXUnits();
setYUnits(); setYUnits();
setInfo(); setInfo();
GraphView::setUnits(units);
redraw(); redraw();
} }
@ -184,7 +163,6 @@ void ElevationGraph::showTracks(bool show)
setInfo(); setInfo();
showGraph(show, Track); showGraph(show, Track);
setXUnits();
redraw(); redraw();
} }
@ -194,7 +172,6 @@ void ElevationGraph::showRoutes(bool show)
_showRoutes = show; _showRoutes = show;
showGraph(show, Route); showGraph(show, Route);
setXUnits();
setInfo(); setInfo();
redraw(); redraw();

View File

@ -4,6 +4,8 @@
#include "graphtab.h" #include "graphtab.h"
class GPX; class GPX;
class Graph;
class PathItem;
class ElevationGraph : public GraphTab class ElevationGraph : public GraphTab
{ {
@ -13,7 +15,7 @@ public:
ElevationGraph(QWidget *parent = 0); ElevationGraph(QWidget *parent = 0);
QString label() const {return tr("Elevation");} QString label() const {return tr("Elevation");}
void loadGPX(const GPX &gpx); void loadGPX(const GPX &gpx, const QList<PathItem *> &paths);
void clear(); void clear();
void setUnits(enum Units units); void setUnits(enum Units units);
void showTracks(bool show); void showTracks(bool show);
@ -27,11 +29,10 @@ private:
qreal ascent() const; qreal ascent() const;
qreal descent() const; qreal descent() const;
void setXUnits();
void setYUnits(); void setYUnits();
void setInfo(); void setInfo();
void loadPath(const QVector<QPointF> &data, Type type); void loadGraph(const Graph &graph, Type type, PathItem *path);
qreal _trackAscent, _trackDescent; qreal _trackAscent, _trackDescent;
qreal _routeAscent, _routeDescent; qreal _routeAscent, _routeDescent;

View File

@ -1,10 +1,118 @@
#include <QBrush> #include <QPainter>
#include <QPen>
#include "graphitem.h" #include "graphitem.h"
static qreal yAtX(const QPainterPath &path, qreal x)
{
int low = 0;
int high = path.elementCount() - 1;
int mid = 0;
Q_ASSERT(high > low);
Q_ASSERT(x >= path.elementAt(low).x && x <= path.elementAt(high).x);
while (low <= high) {
mid = low + ((high - low) / 2);
const QPainterPath::Element &e = path.elementAt(mid);
if (e.x > x)
high = mid - 1;
else if (e.x < x)
low = mid + 1;
else
return e.y;
}
QLineF l;
if (path.elementAt(mid).x < x)
l = QLineF(path.elementAt(mid).x, path.elementAt(mid).y,
path.elementAt(mid+1).x, path.elementAt(mid+1).y);
else
l = QLineF(path.elementAt(mid-1).x, path.elementAt(mid-1).y,
path.elementAt(mid).x, path.elementAt(mid).y);
return l.pointAt((x - l.p1().x()) / (l.p2().x() - l.p1().x())).y();
}
GraphItem::GraphItem(const Graph &graph, QGraphicsItem *parent)
: QGraphicsObject(parent)
{
_id = 0;
_pen = QPen(QBrush(Qt::SolidPattern), 0);
_type = Graph::Distance;
_distancePath.moveTo(graph.distance.first(), -graph.y.first());
for (int i = 1; i < graph.y.size(); i++)
_distancePath.lineTo(graph.distance.at(i), -graph.y.at(i));
if (!graph.time.isEmpty()) {
_timePath.moveTo(graph.time.first(), -graph.y.first());
for (int i = 1; i < graph.y.size(); i++)
_timePath.lineTo(graph.time.at(i), -graph.y.at(i));
}
}
void GraphItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *option,
QWidget *widget)
{
Q_UNUSED(option);
Q_UNUSED(widget);
painter->setPen(_pen);
painter->drawPath((_type == Graph::Distance) ? _distancePath : _timePath);
}
void GraphItem::setColor(const QColor &color) void GraphItem::setColor(const QColor &color)
{ {
QBrush brush(color, Qt::SolidPattern); QBrush brush(color, Qt::SolidPattern);
QPen pen(brush, 0); _pen.setBrush(brush);
setPen(pen); }
qreal GraphItem::yAtX(qreal x)
{
return ::yAtX((_type == Graph::Distance) ? _distancePath : _timePath, x);
}
qreal GraphItem::distanceAtTime(qreal time)
{
int low = 0;
int high = _timePath.elementCount() - 1;
int mid = 0;
Q_ASSERT(high > low);
Q_ASSERT(time >= _timePath.elementAt(low).x
&& time <= _timePath.elementAt(high).x);
while (low <= high) {
mid = low + ((high - low) / 2);
const QPainterPath::Element &e = _timePath.elementAt(mid);
if (e.x > time)
high = mid - 1;
else if (e.x < time)
low = mid + 1;
else
return _distancePath.elementAt(mid).x;
}
if (_timePath.elementAt(mid).x < time)
return ((_distancePath.elementAt(mid+1).x
+ _distancePath.elementAt(mid).x) / 2.0);
else
return ((_distancePath.elementAt(mid).x
+ _distancePath.elementAt(mid-1).x) / 2.0);
}
void GraphItem::emitSliderPositionChanged(qreal pos)
{
if (_type == Graph::Time) {
if (!_timePath.isEmpty()) {
if (pos <= _timePath.elementAt(_timePath.elementCount() - 1).x)
emit sliderPositionChanged(distanceAtTime(pos));
else
emit sliderPositionChanged(_distancePath.elementAt(
_distancePath.elementCount() - 1).x + 1);
} else
emit sliderPositionChanged(_distancePath.elementAt(
_distancePath.elementCount() - 1).x + 1);
} else
emit sliderPositionChanged(pos);
} }

View File

@ -1,20 +1,42 @@
#ifndef GRAPHITEM_H #ifndef GRAPHITEM_H
#define GRAPHITEM_H #define GRAPHITEM_H
#include <QGraphicsPathItem> #include <QGraphicsObject>
#include <QPen>
#include "graph.h"
class GraphItem : public QGraphicsPathItem class GraphItem : public QGraphicsObject
{ {
public: Q_OBJECT
GraphItem(const QPainterPath &path, QGraphicsItem * parent = 0)
: QGraphicsPathItem(path, parent) {_id = 0;}
public:
GraphItem(const Graph &graph, QGraphicsItem *parent = 0);
QRectF boundingRect() const
{return (_type == Graph::Distance) ? _distancePath.boundingRect()
: _timePath.boundingRect();}
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option,
QWidget *widget);
void setGraphType(Graph::Type type) {_type = type;}
int id() const {return _id;} int id() const {return _id;}
void setId(int id) {_id = id;} void setId(int id) {_id = id;}
void setColor(const QColor &color); void setColor(const QColor &color);
qreal yAtX(qreal x);
qreal distanceAtTime(qreal time);
signals:
void sliderPositionChanged(qreal);
public slots:
void emitSliderPositionChanged(qreal);
private: private:
int _id; int _id;
QPen _pen;
QPainterPath _distancePath, _timePath;
Graph::Type _type;
}; };
#endif // GRAPHITEM_H #endif // GRAPHITEM_H

View File

@ -1,10 +1,12 @@
#ifndef GRAPHTAB_H #ifndef GRAPHTAB_H
#define GRAPHTAB_H #define GRAPHTAB_H
#include <QList>
#include "graphview.h" #include "graphview.h"
#include "units.h" #include "units.h"
class GPX; class GPX;
class PathItem;
class GraphTab : public GraphView class GraphTab : public GraphView
{ {
@ -15,7 +17,7 @@ public:
{setFrameShape(QFrame::NoFrame);} {setFrameShape(QFrame::NoFrame);}
virtual QString label() const = 0; virtual QString label() const = 0;
virtual void loadGPX(const GPX &gpx) = 0; virtual void loadGPX(const GPX &gpx, const QList<PathItem *> &paths) = 0;
virtual void clear() = 0; virtual void clear() = 0;
virtual void setUnits(enum Units units) = 0; virtual void setUnits(enum Units units) = 0;
virtual void showTracks(bool show) = 0; virtual void showTracks(bool show) = 0;

View File

@ -7,7 +7,9 @@
#include "slideritem.h" #include "slideritem.h"
#include "sliderinfoitem.h" #include "sliderinfoitem.h"
#include "infoitem.h" #include "infoitem.h"
#include "graph.h"
#include "graphitem.h" #include "graphitem.h"
#include "pathitem.h"
#include "graphview.h" #include "graphview.h"
@ -55,6 +57,12 @@ GraphView::GraphView(QWidget *parent)
_minYRange = 0.01; _minYRange = 0.01;
_sliderPos = 0; _sliderPos = 0;
_units = Metric;
_graphType = Graph::Distance;
setGraphType(_graphType);
setUnits(_units);
} }
GraphView::~GraphView() GraphView::~GraphView()
@ -83,55 +91,101 @@ void GraphView::createYLabel()
_yAxis->setLabel(QString("%1 [%2]").arg(_yLabel).arg(_yUnits)); _yAxis->setLabel(QString("%1 [%2]").arg(_yLabel).arg(_yUnits));
} }
void GraphView::setXLabel(const QString &label)
{
_xLabel = label;
createXLabel();
}
void GraphView::setYLabel(const QString &label) void GraphView::setYLabel(const QString &label)
{ {
_yLabel = label; _yLabel = label;
createYLabel(); createYLabel();
} }
void GraphView::setXUnits(const QString &units)
{
_xUnits = units;
createXLabel();
}
void GraphView::setYUnits(const QString &units) void GraphView::setYUnits(const QString &units)
{ {
_yUnits = units; _yUnits = units;
createYLabel(); createYLabel();
} }
void GraphView::loadData(const QVector<QPointF> &data, int id) void GraphView::setXUnits()
{ {
QPainterPath path; if (_graphType == Graph::Distance) {
GraphItem *pi; if (_units == Metric) {
if (bounds().width() < KMINM) {
_xUnits = tr("m");
if (data.size() < 2) _xScale = 1;
return; } else {
_xUnits = tr("km");
path.moveTo(data.at(0).x(), -data.at(0).y()); _xScale = M2KM;
for (int i = 1; i < data.size(); i++) { }
const QPointF &p = data.at(i); } else {
path.lineTo(p.x(), -p.y()); if (bounds().width() < MIINM) {
_xUnits = tr("ft");
_xScale = M2FT;
} else {
_xUnits = tr("mi");
_xScale = M2MI;
}
}
} else {
if (bounds().width() < MININS) {
_xUnits = tr("s");
_xScale = 1;
} else if (bounds().width() < HINS) {
_xUnits = tr("min");
_xScale = MIN2S;
} else {
_xUnits = tr("h");
_xScale = H2S;
}
} }
pi = new GraphItem(path); createXLabel();
pi->setId(id); }
pi->setColor(_palette.color());
_graphs.append(pi); void GraphView::setUnits(Units units)
{
_units = units;
setXUnits();
}
void GraphView::setGraphType(Graph::Type type)
{
_graphType = type;
_bounds = QRectF();
for (int i = 0; i < _graphs.count(); i++) {
_graphs.at(i)->setGraphType(type);
updateBounds(_graphs.at(i)->boundingRect());
}
if (type == Graph::Distance)
_xLabel = tr("Distance");
else
_xLabel = tr("Time");
setXUnits();
redraw();
}
void GraphView::loadGraph(const Graph &graph, PathItem *path, int id)
{
if (graph.y.size() < 2)
return;
GraphItem *gi = new GraphItem(graph);
gi->setGraphType(_graphType);
gi->setId(id);
gi->setColor(_palette.color());
connect(this, SIGNAL(sliderPositionChanged(qreal)), gi,
SLOT(emitSliderPositionChanged(qreal)));
connect(gi, SIGNAL(sliderPositionChanged(qreal)), path,
SLOT(moveMarker(qreal)));
_graphs.append(gi);
if (!_hide.contains(id)) { if (!_hide.contains(id)) {
_visible.append(pi); _visible.append(gi);
_scene->addItem(pi); _scene->addItem(gi);
updateBounds(path); updateBounds(gi->boundingRect());
setXUnits();
} }
} }
@ -163,7 +217,7 @@ void GraphView::showGraph(bool show, int id)
else { else {
addItem(gi); addItem(gi);
_visible.append(gi); _visible.append(gi);
updateBounds(gi->path()); updateBounds(gi->boundingRect());
} }
} }
} }
@ -173,9 +227,9 @@ void GraphView::redraw()
redraw(viewport()->size() - QSizeF(MARGIN, MARGIN)); redraw(viewport()->size() - QSizeF(MARGIN, MARGIN));
} }
void GraphView::updateBounds(const QPainterPath &path) void GraphView::updateBounds(const QRectF &boundingRect)
{ {
QRectF br = path.boundingRect(); QRectF br(boundingRect);
br.moveTopLeft(QPointF(br.left(), -br.top() - br.height())); br.moveTopLeft(QPointF(br.left(), -br.top() - br.height()));
_bounds |= br; _bounds |= br;
} }
@ -213,8 +267,8 @@ void GraphView::redraw(const QSizeF &size)
addItem(_slider); addItem(_slider);
addItem(_info); addItem(_info);
rx = RangeF(_bounds.left() * _xScale, _bounds.right() * _xScale); rx = RangeF(bounds().left() * _xScale, bounds().right() * _xScale);
ry = RangeF(_bounds.top() * _yScale + _yOffset, _bounds.bottom() * _yScale ry = RangeF(bounds().top() * _yScale + _yOffset, bounds().bottom() * _yScale
+ _yOffset); + _yOffset);
if (ry.size() < _minYRange) if (ry.size() < _minYRange)
ry.resize(_minYRange); ry.resize(_minYRange);
@ -299,45 +353,14 @@ void GraphView::clear()
_scene->setSceneRect(0, 0, 0, 0); _scene->setSceneRect(0, 0, 0, 0);
} }
static qreal yAtX(const QPainterPath &path, qreal x)
{
int low = 0;
int high = path.elementCount() - 1;
int mid = 0;
Q_ASSERT(high > low);
Q_ASSERT(x >= path.elementAt(low).x && x <= path.elementAt(high).x);
while (low <= high) {
mid = low + ((high - low) / 2);
const QPainterPath::Element &e = path.elementAt(mid);
if (e.x > x)
high = mid - 1;
else if (e.x < x)
low = mid + 1;
else
return e.y;
}
QLineF l;
if (path.elementAt(mid).x < x)
l = QLineF(path.elementAt(mid).x, path.elementAt(mid).y,
path.elementAt(mid+1).x, path.elementAt(mid+1).y);
else
l = QLineF(path.elementAt(mid-1).x, path.elementAt(mid-1).y,
path.elementAt(mid).x, path.elementAt(mid).y);
return l.pointAt((x - l.p1().x()) / (l.p2().x() - l.p1().x())).y();
}
void GraphView::updateSliderPosition() void GraphView::updateSliderPosition()
{ {
if (_bounds.width() <= 0) if (bounds().width() <= 0)
return; return;
if (_sliderPos <= _bounds.right() && _sliderPos >= _bounds.left()) { if (_sliderPos <= bounds().right() && _sliderPos >= bounds().left()) {
_slider->setPos((_sliderPos / _bounds.width()) * _slider->area().width(), _slider->setPos((_sliderPos / bounds().width())
_slider->area().bottom()); * _slider->area().width(), _slider->area().bottom());
_slider->setVisible(!_visible.isEmpty()); _slider->setVisible(!_visible.isEmpty());
} else { } else {
_slider->setPos(_slider->area().left(), _slider->area().bottom()); _slider->setPos(_slider->area().left(), _slider->area().bottom());
@ -353,16 +376,15 @@ void GraphView::updateSliderInfo()
if (!_sliderInfo->isVisible()) if (!_sliderInfo->isVisible())
return; return;
const QPainterPath &path = _visible.first()->path(); QRectF br(_visible.first()->boundingRect());
QRectF br = path.boundingRect();
if (br.height() < _minYRange) if (br.height() < _minYRange)
br.adjust(0, -(_minYRange/2 - br.height()/2), 0, br.adjust(0, -(_minYRange/2 - br.height()/2), 0,
_minYRange/2 - br.height()/2); _minYRange/2 - br.height()/2);
qreal y = yAtX(path, _sliderPos); qreal y = _visible.first()->yAtX(_sliderPos);
qreal r = (y - br.bottom()) / br.height(); qreal r = (y - br.bottom()) / br.height();
qreal pos = (_sliderPos / _bounds.width()) * _slider->area().width(); qreal pos = (_sliderPos / bounds().width()) * _slider->area().width();
SliderInfoItem::Side s = (pos + _sliderInfo->boundingRect().width() SliderInfoItem::Side s = (pos + _sliderInfo->boundingRect().width()
> _slider->area().right()) ? SliderInfoItem::Left : SliderInfoItem::Right; > _slider->area().right()) ? SliderInfoItem::Left : SliderInfoItem::Right;
@ -377,7 +399,7 @@ void GraphView::emitSliderPositionChanged(const QPointF &pos)
if (_slider->area().width() <= 0) if (_slider->area().width() <= 0)
return; return;
_sliderPos = (pos.x() / _slider->area().width()) * _bounds.width(); _sliderPos = (pos.x() / _slider->area().width()) * bounds().width();
updateSliderPosition(); updateSliderPosition();
emit sliderPositionChanged(_sliderPos); emit sliderPositionChanged(_sliderPos);

View File

@ -8,12 +8,16 @@
#include <QSet> #include <QSet>
#include <QPointF> #include <QPointF>
#include "palette.h" #include "palette.h"
#include "units.h"
#include "graph.h"
class AxisItem; class AxisItem;
class SliderItem; class SliderItem;
class SliderInfoItem; class SliderInfoItem;
class InfoItem; class InfoItem;
class GraphItem; class GraphItem;
class PathItem;
class Scene : public QGraphicsScene class Scene : public QGraphicsScene
{ {
@ -35,26 +39,21 @@ public:
GraphView(QWidget *parent = 0); GraphView(QWidget *parent = 0);
~GraphView(); ~GraphView();
void loadData(const QVector<QPointF> &data, int id = 0); void loadGraph(const Graph &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();
void showGraph(bool show, int id = 0); void showGraph(bool show, int id = 0);
void setGraphType(Graph::Type type);
void setUnits(Units units);
const QString &xLabel() const {return _xLabel;}
const QString &yLabel() const {return _yLabel;} const QString &yLabel() const {return _yLabel;}
const QString &xUnits() const {return _xUnits;}
const QString &yUnits() const {return _yUnits;} const QString &yUnits() const {return _yUnits;}
qreal xScale() const {return _xScale;}
qreal yScale() const {return _yScale;} qreal yScale() const {return _yScale;}
qreal yOffset() const {return _yOffset;} qreal yOffset() const {return _yOffset;}
void setXLabel(const QString &label);
void setYLabel(const QString &label); void setYLabel(const QString &label);
void setXUnits(const QString &units);
void setYUnits(const QString &units); void setYUnits(const QString &units);
void setXScale(qreal scale) {_xScale = scale;}
void setYScale(qreal scale) {_yScale = scale;} void setYScale(qreal scale) {_yScale = scale;}
void setYOffset(qreal offset) {_yOffset = offset;} void setYOffset(qreal offset) {_yOffset = offset;}
@ -82,11 +81,12 @@ private slots:
void newSliderPosition(const QPointF &pos); void newSliderPosition(const QPointF &pos);
private: private:
void setXUnits();
void createXLabel(); void createXLabel();
void createYLabel(); void createYLabel();
void updateSliderPosition(); void updateSliderPosition();
void updateSliderInfo(); void updateSliderInfo();
void updateBounds(const QPainterPath &path); void updateBounds(const QRectF &boundingRect);
QRectF graphsBoundingRect() const; QRectF graphsBoundingRect() const;
void removeItem(QGraphicsItem *item); void removeItem(QGraphicsItem *item);
void addItem(QGraphicsItem *item); void addItem(QGraphicsItem *item);
@ -111,6 +111,9 @@ private:
QSet<int> _hide; QSet<int> _hide;
QRectF _bounds; QRectF _bounds;
Palette _palette; Palette _palette;
Units _units;
Graph::Type _graphType;
}; };
#endif // GRAPHVIEW_H #endif // GRAPHVIEW_H

View File

@ -173,6 +173,9 @@ QAction *GUI::createPOIFileAction(int index)
void GUI::createActions() void GUI::createActions()
{ {
QActionGroup *ag;
// Action Groups // Action Groups
_fileActionGroup = new QActionGroup(this); _fileActionGroup = new QActionGroup(this);
_fileActionGroup->setExclusive(false); _fileActionGroup->setExclusive(false);
@ -297,18 +300,35 @@ void GUI::createActions()
connect(_showRouteWaypointsAction, SIGNAL(triggered(bool)), _track, connect(_showRouteWaypointsAction, SIGNAL(triggered(bool)), _track,
SLOT(showRouteWaypoints(bool))); SLOT(showRouteWaypoints(bool)));
// Settings actions // Graph actions
_showGraphsAction = new QAction(tr("Show graphs"), this); _showGraphsAction = new QAction(QIcon(QPixmap(SHOW_GRAPHS_ICON)),
tr("Show graphs"), this);
_showGraphsAction->setCheckable(true); _showGraphsAction->setCheckable(true);
_showGraphsAction->setShortcut(SHOW_GRAPHS_SHORTCUT); _showGraphsAction->setShortcut(SHOW_GRAPHS_SHORTCUT);
connect(_showGraphsAction, SIGNAL(triggered(bool)), this, connect(_showGraphsAction, SIGNAL(triggered(bool)), this,
SLOT(showGraphs(bool))); SLOT(showGraphs(bool)));
addAction(_showGraphsAction); addAction(_showGraphsAction);
ag = new QActionGroup(this);
ag->setExclusive(true);
_distanceGraphAction = new QAction(tr("Distance"), this);
_distanceGraphAction->setCheckable(true);
_distanceGraphAction->setActionGroup(ag);
_distanceGraphAction->setShortcut(DISTANCE_GRAPH_SHORTCUT);
connect(_distanceGraphAction, SIGNAL(triggered()), this,
SLOT(setDistanceGraph()));
_timeGraphAction = new QAction(tr("Time"), this);
_timeGraphAction->setCheckable(true);
_timeGraphAction->setActionGroup(ag);
_timeGraphAction->setShortcut(TIME_GRAPH_SHORTCUT);
connect(_timeGraphAction, SIGNAL(triggered()), this,
SLOT(setTimeGraph()));
// Settings actions
_showToolbarsAction = new QAction(tr("Show toolbars"), this); _showToolbarsAction = new QAction(tr("Show toolbars"), this);
_showToolbarsAction->setCheckable(true); _showToolbarsAction->setCheckable(true);
connect(_showToolbarsAction, SIGNAL(triggered(bool)), this, connect(_showToolbarsAction, SIGNAL(triggered(bool)), this,
SLOT(showToolbars(bool))); SLOT(showToolbars(bool)));
QActionGroup *ag = new QActionGroup(this); ag = new QActionGroup(this);
ag->setExclusive(true); ag->setExclusive(true);
_metricUnitsAction = new QAction(tr("Metric"), this); _metricUnitsAction = new QAction(tr("Metric"), this);
_metricUnitsAction->setCheckable(true); _metricUnitsAction->setCheckable(true);
@ -368,6 +388,12 @@ void GUI::createMenus()
mapMenu->addSeparator(); mapMenu->addSeparator();
mapMenu->addAction(_showMapAction); mapMenu->addAction(_showMapAction);
QMenu *graphMenu = menuBar()->addMenu(tr("Graph"));
graphMenu->addAction(_distanceGraphAction);
graphMenu->addAction(_timeGraphAction);
graphMenu->addSeparator();
graphMenu->addAction(_showGraphsAction);
QMenu *poiMenu = menuBar()->addMenu(tr("POI")); QMenu *poiMenu = menuBar()->addMenu(tr("POI"));
_poiFilesMenu = poiMenu->addMenu(tr("POI files")); _poiFilesMenu = poiMenu->addMenu(tr("POI files"));
_poiFilesMenu->addActions(_poiFilesActions); _poiFilesMenu->addActions(_poiFilesActions);
@ -395,7 +421,6 @@ void GUI::createMenus()
unitsMenu->addAction(_imperialUnitsAction); unitsMenu->addAction(_imperialUnitsAction);
settingsMenu->addSeparator(); settingsMenu->addSeparator();
settingsMenu->addAction(_showToolbarsAction); settingsMenu->addAction(_showToolbarsAction);
settingsMenu->addAction(_showGraphsAction);
settingsMenu->addSeparator(); settingsMenu->addSeparator();
settingsMenu->addAction(_fullscreenAction); settingsMenu->addAction(_fullscreenAction);
@ -421,6 +446,7 @@ void GUI::createToolBars()
_showToolBar = addToolBar(tr("Show")); _showToolBar = addToolBar(tr("Show"));
_showToolBar->addAction(_showPOIAction); _showToolBar->addAction(_showPOIAction);
_showToolBar->addAction(_showMapAction); _showToolBar->addAction(_showMapAction);
_showToolBar->addAction(_showGraphsAction);
_navigationToolBar = addToolBar(tr("Navigation")); _navigationToolBar = addToolBar(tr("Navigation"));
_navigationToolBar->addAction(_firstAction); _navigationToolBar->addAction(_firstAction);
@ -586,13 +612,14 @@ bool GUI::openFile(const QString &fileName)
bool GUI::loadFile(const QString &fileName) bool GUI::loadFile(const QString &fileName)
{ {
GPX gpx; GPX gpx;
QList<PathItem*> paths;
if (gpx.loadFile(fileName)) { if (gpx.loadFile(fileName)) {
paths = _track->loadGPX(gpx);
for (int i = 0; i < _tabs.count(); i++) for (int i = 0; i < _tabs.count(); i++)
_tabs.at(i)->loadGPX(gpx); _tabs.at(i)->loadGPX(gpx, paths);
updateGraphTabs(); updateGraphTabs();
_track->setHidden(false); _track->setHidden(false);
_track->loadGPX(gpx);
if (_showPOIAction->isChecked()) if (_showPOIAction->isChecked())
_track->loadPOI(_poi); _track->loadPOI(_poi);
@ -986,7 +1013,7 @@ void GUI::poiFileChecked(int index)
void GUI::sliderPositionChanged(qreal pos) void GUI::sliderPositionChanged(qreal pos)
{ {
_sliderPos = pos; _sliderPos = pos;
_track->movePositionMarker(_sliderPos); //_track->movePositionMarker(_sliderPos);
} }
void GUI::graphChanged(int index) void GUI::graphChanged(int index)
@ -1066,6 +1093,18 @@ void GUI::setImperialUnits()
updateStatusBarInfo(); updateStatusBarInfo();
} }
void GUI::setDistanceGraph()
{
for (int i = 0; i <_tabs.count(); i++)
_tabs.at(i)->setGraphType(Graph::Distance);
}
void GUI::setTimeGraph()
{
for (int i = 0; i <_tabs.count(); i++)
_tabs.at(i)->setGraphType(Graph::Time);
}
void GUI::next() void GUI::next()
{ {
QString file = _browser->next(); QString file = _browser->next();
@ -1158,7 +1197,6 @@ void GUI::writeSettings()
settings.setValue(UNITS_SETTING, _imperialUnitsAction->isChecked() settings.setValue(UNITS_SETTING, _imperialUnitsAction->isChecked()
? Imperial : Metric); ? Imperial : Metric);
settings.setValue(SHOW_TOOLBARS_SETTING, _showToolbarsAction->isChecked()); settings.setValue(SHOW_TOOLBARS_SETTING, _showToolbarsAction->isChecked());
settings.setValue(SHOW_GRAPHS_SETTING, _showGraphsAction->isChecked());
settings.endGroup(); settings.endGroup();
settings.beginGroup(MAP_SETTINGS_GROUP); settings.beginGroup(MAP_SETTINGS_GROUP);
@ -1167,6 +1205,12 @@ void GUI::writeSettings()
settings.setValue(SHOW_MAP_SETTING, _showMapAction->isChecked()); settings.setValue(SHOW_MAP_SETTING, _showMapAction->isChecked());
settings.endGroup(); settings.endGroup();
settings.beginGroup(GRAPH_SETTINGS_GROUP);
settings.setValue(SHOW_GRAPHS_SETTING, _showGraphsAction->isChecked());
settings.setValue(GRAPH_TYPE_SETTING, _timeGraphAction->isChecked()
? Graph::Time : Graph::Distance);
settings.endGroup();
settings.beginGroup(POI_SETTINGS_GROUP); settings.beginGroup(POI_SETTINGS_GROUP);
settings.setValue(SHOW_POI_SETTING, _showPOIAction->isChecked()); settings.setValue(SHOW_POI_SETTING, _showPOIAction->isChecked());
settings.setValue(OVERLAP_POI_SETTING, _overlapPOIAction->isChecked()); settings.setValue(OVERLAP_POI_SETTING, _overlapPOIAction->isChecked());
@ -1216,10 +1260,6 @@ void GUI::readSettings()
showToolbars(false); showToolbars(false);
else else
_showToolbarsAction->setChecked(true); _showToolbarsAction->setChecked(true);
if (settings.value(SHOW_GRAPHS_SETTING, true).toBool() == false)
showGraphs(false);
else
_showGraphsAction->setChecked(true);
settings.endGroup(); settings.endGroup();
settings.beginGroup(MAP_SETTINGS_GROUP); settings.beginGroup(MAP_SETTINGS_GROUP);
@ -1235,6 +1275,19 @@ void GUI::readSettings()
_currentMap = 0; _currentMap = 0;
settings.endGroup(); settings.endGroup();
settings.beginGroup(GRAPH_SETTINGS_GROUP);
if (settings.value(SHOW_GRAPHS_SETTING, true).toBool() == false)
showGraphs(false);
else
_showGraphsAction->setChecked(true);
if (settings.value(GRAPH_TYPE_SETTING, Graph::Distance).toInt()
== Graph::Time) {
setTimeGraph();
_timeGraphAction->setChecked(true);
} else
_distanceGraphAction->setChecked(true);
settings.endGroup();
settings.beginGroup(POI_SETTINGS_GROUP); settings.beginGroup(POI_SETTINGS_GROUP);
if (settings.value(OVERLAP_POI_SETTING, true).toBool() == false) if (settings.value(OVERLAP_POI_SETTING, true).toBool() == false)
_track->setPOIOverlap(false); _track->setPOIOverlap(false);

View File

@ -58,8 +58,6 @@ private slots:
void graphChanged(int); void graphChanged(int);
void poiFileChecked(int); void poiFileChecked(int);
void next(); void next();
void prev(); void prev();
void last(); void last();
@ -67,6 +65,8 @@ private slots:
void setMetricUnits(); void setMetricUnits();
void setImperialUnits(); void setImperialUnits();
void setDistanceGraph();
void setTimeGraph();
void sliderPositionChanged(qreal pos); void sliderPositionChanged(qreal pos);
@ -132,6 +132,8 @@ private:
QAction *_fullscreenAction; QAction *_fullscreenAction;
QAction *_clearMapCacheAction; QAction *_clearMapCacheAction;
QAction *_showGraphsAction; QAction *_showGraphsAction;
QAction *_distanceGraphAction;
QAction *_timeGraphAction;
QAction *_showToolbarsAction; QAction *_showToolbarsAction;
QAction *_nextAction; QAction *_nextAction;
QAction *_prevAction; QAction *_prevAction;

View File

@ -8,7 +8,6 @@ HeartRateGraph::HeartRateGraph(QWidget *parent) : GraphTab(parent)
_showTracks = true; _showTracks = true;
GraphView::setYUnits(tr("1/min")); GraphView::setYUnits(tr("1/min"));
setXLabel(tr("Distance"));
setYLabel(tr("Heart rate")); setYLabel(tr("Heart rate"));
setSliderPrecision(0); setSliderPrecision(0);
@ -25,30 +24,30 @@ void HeartRateGraph::setInfo()
clearInfo(); clearInfo();
} }
void HeartRateGraph::loadGPX(const GPX &gpx) void HeartRateGraph::loadGPX(const GPX &gpx, const QList<PathItem *> &paths)
{ {
for (int i = 0; i < gpx.tracks().count(); i++) { for (int i = 0; i < gpx.tracks().count(); i++) {
QVector<QPointF> data = gpx.tracks().at(i)->heartRate(); const Graph &graph = gpx.tracks().at(i)->heartRate();
qreal sum = 0, w = 0; qreal sum = 0, w = 0;
if (data.count() < 2) { if (graph.y.count() < 2) {
skipColor(); skipColor();
continue; continue;
} }
for (int j = 1; j < data.size(); j++) { for (int j = 1; j < graph.y.size(); j++) {
sum += data.at(j).y() * (data.at(j).x() - data.at(j-1).x()); qreal ds = graph.distance.at(j) - graph.distance.at(j-1);
w += data.at(j).x() - data.at(j-1).x(); sum += graph.y.at(j) * ds;
w += ds;
} }
_avg.append(QPointF(gpx.tracks().at(i)->distance(), sum/w)); _avg.append(QPointF(gpx.tracks().at(i)->distance(), sum/w));
loadData(data); GraphView::loadGraph(graph, paths.at(i));
} }
for (int i = 0; i < gpx.routes().count(); i++) for (int i = 0; i < gpx.routes().count(); i++)
skipColor(); skipColor();
setXUnits();
setInfo(); setInfo();
redraw(); redraw();
@ -74,43 +73,11 @@ void HeartRateGraph::clear()
GraphView::clear(); GraphView::clear();
} }
void HeartRateGraph::setXUnits()
{
if (_units == Metric) {
if (bounds().width() < KMINM) {
GraphView::setXUnits(tr("m"));
setXScale(1);
} else {
GraphView::setXUnits(tr("km"));
setXScale(M2KM);
}
} else {
if (bounds().width() < MIINM) {
GraphView::setXUnits(tr("ft"));
setXScale(M2FT);
} else {
GraphView::setXUnits(tr("mi"));
setXScale(M2MI);
}
}
}
void HeartRateGraph::setUnits(enum Units units)
{
_units = units;
setXUnits();
setInfo();
redraw();
}
void HeartRateGraph::showTracks(bool show) void HeartRateGraph::showTracks(bool show)
{ {
_showTracks = show; _showTracks = show;
showGraph(show); showGraph(show);
setXUnits();
setInfo(); setInfo();
redraw(); redraw();

View File

@ -13,16 +13,15 @@ public:
HeartRateGraph(QWidget *parent = 0); HeartRateGraph(QWidget *parent = 0);
QString label() const {return tr("Heart rate");} QString label() const {return tr("Heart rate");}
void loadGPX(const GPX &gpx); void loadGPX(const GPX &gpx, const QList<PathItem *> &paths);
void clear(); void clear();
void setUnits(enum Units units); void setUnits(enum Units) {}
void showTracks(bool show); void showTracks(bool show);
void showRoutes(bool show) {Q_UNUSED(show);} void showRoutes(bool show) {Q_UNUSED(show);}
private: private:
qreal avg() const; qreal avg() const;
qreal max() const {return bounds().bottom();} qreal max() const {return bounds().bottom();}
void setXUnits();
void setInfo(); void setInfo();
QList<QPointF> _avg; QList<QPointF> _avg;

View File

@ -8,6 +8,7 @@
#define CLOSE_FILE_ICON ":/icons/dialog-close.png" #define CLOSE_FILE_ICON ":/icons/dialog-close.png"
#define SHOW_POI_ICON ":/icons/flag.png" #define SHOW_POI_ICON ":/icons/flag.png"
#define SHOW_MAP_ICON ":/icons/applications-internet.png" #define SHOW_MAP_ICON ":/icons/applications-internet.png"
#define SHOW_GRAPHS_ICON ":/icons/office-chart-line-stacked.png"
#define QUIT_ICON ":/icons/application-exit.png" #define QUIT_ICON ":/icons/application-exit.png"
#define RELOAD_FILE_ICON ":/icons/view-refresh.png" #define RELOAD_FILE_ICON ":/icons/view-refresh.png"
#define NEXT_FILE_ICON ":/icons/arrow-right.png" #define NEXT_FILE_ICON ":/icons/arrow-right.png"

View File

@ -20,6 +20,8 @@
#define NEXT_MAP_SHORTCUT QKeySequence::Forward #define NEXT_MAP_SHORTCUT QKeySequence::Forward
#define PREV_MAP_SHORTCUT QKeySequence::Back #define PREV_MAP_SHORTCUT QKeySequence::Back
#define SHOW_GRAPHS_SHORTCUT QKeySequence(Qt::CTRL + Qt::Key_G) #define SHOW_GRAPHS_SHORTCUT QKeySequence(Qt::CTRL + Qt::Key_G)
#define DISTANCE_GRAPH_SHORTCUT QKeySequence(Qt::CTRL + Qt::Key_D)
#define TIME_GRAPH_SHORTCUT QKeySequence(Qt::CTRL + Qt::Key_T)
#ifdef Q_OS_MAC #ifdef Q_OS_MAC
#define FULLSCREEN_SHORTCUT QKeySequence(Qt::META + Qt::CTRL + Qt::Key_F) #define FULLSCREEN_SHORTCUT QKeySequence(Qt::META + Qt::CTRL + Qt::Key_F)
#else // Q_OS_MAC #else // Q_OS_MAC

View File

@ -1,4 +1,19 @@
#ifndef PATHITEM_H #ifndef PATHITEM_H
#define PATHITEM_H #define PATHITEM_H
#include <QGraphicsObject>
#include "units.h"
class PathItem : public QGraphicsObject
{
Q_OBJECT
public:
PathItem(QGraphicsItem *parent = 0) : QGraphicsObject(parent) {}
virtual void showMarker(bool show) = 0;
public slots:
virtual void moveMarker(qreal distance) = 0;
};
#endif // PATHITEM_H #endif // PATHITEM_H

View File

@ -12,14 +12,15 @@ Route::Route(const QVector<Waypoint> &data) : _data(data)
} }
} }
QVector<QPointF> Route::elevation() const Graph Route::elevation() const
{ {
QVector<QPointF> graph; Graph graph;
for (int i = 0; i < _data.size(); i++) for (int i = 0; i < _data.size(); i++)
if (_data.at(i).hasElevation()) if (_data.at(i).hasElevation())
graph.append(QPointF(_dd.at(i), _data.at(i).elevation() graph.y.append(_data.at(i).elevation() - _data.at(i).geoidHeight());
- _data.at(i).geoidHeight()));
graph.distance = _dd;
return graph; return graph;
} }

View File

@ -3,6 +3,7 @@
#include <QVector> #include <QVector>
#include "waypoint.h" #include "waypoint.h"
#include "graph.h"
class Route class Route
{ {
@ -10,7 +11,7 @@ public:
Route(const QVector<Waypoint> &data); Route(const QVector<Waypoint> &data);
const QVector<Waypoint> &route() const {return _data;} const QVector<Waypoint> &route() const {return _data;}
QVector<QPointF> elevation() const; Graph elevation() const;
qreal distance() const; qreal distance() const;

View File

@ -34,7 +34,7 @@ void RouteItem::updateShape()
} }
RouteItem::RouteItem(const Route &route, QGraphicsItem *parent) RouteItem::RouteItem(const Route &route, QGraphicsItem *parent)
: QGraphicsItem(parent) : PathItem(parent)
{ {
WaypointItem *wi; WaypointItem *wi;

View File

@ -1,14 +1,17 @@
#ifndef ROUTEITEM_H #ifndef ROUTEITEM_H
#define ROUTEITEM_H #define ROUTEITEM_H
#include <QGraphicsItem> #include <QPen>
#include "pathitem.h"
#include "markeritem.h" #include "markeritem.h"
#include "route.h" #include "route.h"
#include "units.h" #include "units.h"
class RouteItem : public QGraphicsItem class RouteItem : public PathItem
{ {
Q_OBJECT
public: public:
RouteItem(const Route &route, QGraphicsItem *parent = 0); RouteItem(const Route &route, QGraphicsItem *parent = 0);

View File

@ -8,7 +8,10 @@
#define SETTINGS_SETTINGS_GROUP "Settings" #define SETTINGS_SETTINGS_GROUP "Settings"
#define UNITS_SETTING "units" #define UNITS_SETTING "units"
#define SHOW_TOOLBARS_SETTING "toolbar" #define SHOW_TOOLBARS_SETTING "toolbar"
#define SHOW_GRAPHS_SETTING "graphs"
#define GRAPH_SETTINGS_GROUP "Graph"
#define SHOW_GRAPHS_SETTING "show"
#define GRAPH_TYPE_SETTING "type"
#define MAP_SETTINGS_GROUP "Map" #define MAP_SETTINGS_GROUP "Map"
#define CURRENT_MAP_SETTING "map" #define CURRENT_MAP_SETTING "map"

View File

@ -4,7 +4,7 @@
#define SIZE 10 #define SIZE 10
SliderItem::SliderItem(QGraphicsObject *parent) : QGraphicsObject(parent) SliderItem::SliderItem(QGraphicsItem *parent) : QGraphicsObject(parent)
{ {
setFlag(ItemIsMovable); setFlag(ItemIsMovable);
setFlag(ItemSendsGeometryChanges); setFlag(ItemSendsGeometryChanges);

View File

@ -1,14 +1,14 @@
#ifndef SLIDERITEM_H #ifndef SLIDERITEM_H
#define SLIDERITEM_H #define SLIDERITEM_H
#include <QGraphicsItem> #include <QGraphicsObject>
class SliderItem : public QGraphicsObject class SliderItem : public QGraphicsObject
{ {
Q_OBJECT Q_OBJECT
public: public:
SliderItem(QGraphicsObject *parent = 0); SliderItem(QGraphicsItem *parent = 0);
QRectF boundingRect() const; QRectF boundingRect() const;
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, void paint(QPainter *painter, const QStyleOptionGraphicsItem *option,

View File

@ -9,7 +9,6 @@ SpeedGraph::SpeedGraph(QWidget *parent) : GraphTab(parent)
_showTracks = true; _showTracks = true;
setYUnits(); setYUnits();
setXLabel(tr("Distance"));
setYLabel(tr("Speed")); setYLabel(tr("Speed"));
setSliderPrecision(1); setSliderPrecision(1);
@ -26,11 +25,11 @@ void SpeedGraph::setInfo()
clearInfo(); clearInfo();
} }
void SpeedGraph::loadGPX(const GPX &gpx) void SpeedGraph::loadGPX(const GPX &gpx, const QList<PathItem *> &paths)
{ {
for (int i = 0; i < gpx.tracks().count(); i++) { for (int i = 0; i < gpx.tracks().count(); i++) {
QVector<QPointF> data = gpx.tracks().at(i)->speed(); const Graph &graph = gpx.tracks().at(i)->speed();
if (data.count() < 2) { if (graph.y.count() < 2) {
skipColor(); skipColor();
continue; continue;
} }
@ -38,13 +37,12 @@ void SpeedGraph::loadGPX(const GPX &gpx)
_avg.append(QPointF(gpx.tracks().at(i)->distance(), _avg.append(QPointF(gpx.tracks().at(i)->distance(),
gpx.tracks().at(i)->distance() / gpx.tracks().at(i)->time())); gpx.tracks().at(i)->distance() / gpx.tracks().at(i)->time()));
loadData(data); GraphView::loadGraph(graph, paths.at(i));
} }
for (int i = 0; i < gpx.routes().count(); i++) for (int i = 0; i < gpx.routes().count(); i++)
skipColor(); skipColor();
setXUnits();
setInfo(); setInfo();
redraw(); redraw();
@ -70,27 +68,6 @@ void SpeedGraph::clear()
GraphView::clear(); GraphView::clear();
} }
void SpeedGraph::setXUnits()
{
if (_units == Metric) {
if (bounds().width() < KMINM) {
GraphView::setXUnits(tr("m"));
setXScale(1);
} else {
GraphView::setXUnits(tr("km"));
setXScale(M2KM);
}
} else {
if (bounds().width() < MIINM) {
GraphView::setXUnits(tr("ft"));
setXScale(M2FT);
} else {
GraphView::setXUnits(tr("mi"));
setXScale(M2MI);
}
}
}
void SpeedGraph::setYUnits() void SpeedGraph::setYUnits()
{ {
if (_units == Metric) { if (_units == Metric) {
@ -106,9 +83,9 @@ void SpeedGraph::setUnits(enum Units units)
{ {
_units = units; _units = units;
setXUnits();
setYUnits(); setYUnits();
setInfo(); setInfo();
GraphView::setUnits(units);
redraw(); redraw();
} }
@ -118,7 +95,6 @@ void SpeedGraph::showTracks(bool show)
_showTracks = show; _showTracks = show;
showGraph(show); showGraph(show);
setXUnits();
setInfo(); setInfo();
redraw(); redraw();

View File

@ -14,7 +14,7 @@ public:
SpeedGraph(QWidget *parent = 0); SpeedGraph(QWidget *parent = 0);
QString label() const {return tr("Speed");} QString label() const {return tr("Speed");}
void loadGPX(const GPX &gpx); void loadGPX(const GPX &gpx, const QList<PathItem *> &paths);
void clear(); void clear();
void setUnits(enum Units units); void setUnits(enum Units units);
void showTracks(bool show); void showTracks(bool show);
@ -23,7 +23,6 @@ public:
private: private:
qreal avg() const; qreal avg() const;
qreal max() const {return bounds().bottom();} qreal max() const {return bounds().bottom();}
void setXUnits();
void setYUnits(); void setYUnits();
void setInfo(); void setInfo();

View File

@ -8,7 +8,6 @@ TemperatureGraph::TemperatureGraph(QWidget *parent) : GraphTab(parent)
_showTracks = true; _showTracks = true;
setYUnits(); setYUnits();
setXLabel(tr("Distance"));
setYLabel(tr("Temperature")); setYLabel(tr("Temperature"));
setSliderPrecision(1); setSliderPrecision(1);
@ -27,30 +26,30 @@ void TemperatureGraph::setInfo()
clearInfo(); clearInfo();
} }
void TemperatureGraph::loadGPX(const GPX &gpx) void TemperatureGraph::loadGPX(const GPX &gpx, const QList<PathItem *> &paths)
{ {
for (int i = 0; i < gpx.tracks().count(); i++) { for (int i = 0; i < gpx.tracks().count(); i++) {
QVector<QPointF> data = gpx.tracks().at(i)->temperature(); const Graph &graph = gpx.tracks().at(i)->temperature();
qreal sum = 0, w = 0; qreal sum = 0, w = 0;
if (data.count() < 2) { if (graph.y.count() < 2) {
skipColor(); skipColor();
continue; continue;
} }
for (int j = 1; j < data.size(); j++) { for (int j = 1; j < graph.y.size(); j++) {
sum += data.at(j).y() * (data.at(j).x() - data.at(j-1).x()); qreal ds = graph.distance.at(j) - graph.distance.at(j-1);
w += data.at(j).x() - data.at(j-1).x(); sum += graph.y.at(j) * ds;
w += ds;
} }
_avg.append(QPointF(gpx.tracks().at(i)->distance(), sum/w)); _avg.append(QPointF(gpx.tracks().at(i)->distance(), sum/w));
loadData(data); GraphView::loadGraph(graph, paths.at(i));
} }
for (int i = 0; i < gpx.routes().count(); i++) for (int i = 0; i < gpx.routes().count(); i++)
skipColor(); skipColor();
setXUnits();
setInfo(); setInfo();
redraw(); redraw();
@ -76,27 +75,6 @@ void TemperatureGraph::clear()
GraphView::clear(); GraphView::clear();
} }
void TemperatureGraph::setXUnits()
{
if (_units == Metric) {
if (bounds().width() < KMINM) {
GraphView::setXUnits(tr("m"));
setXScale(1);
} else {
GraphView::setXUnits(tr("km"));
setXScale(M2KM);
}
} else {
if (bounds().width() < MIINM) {
GraphView::setXUnits(tr("ft"));
setXScale(M2FT);
} else {
GraphView::setXUnits(tr("mi"));
setXScale(M2MI);
}
}
}
void TemperatureGraph::setYUnits() void TemperatureGraph::setYUnits()
{ {
if (_units == Metric) { if (_units == Metric) {
@ -114,9 +92,9 @@ void TemperatureGraph::setUnits(enum Units units)
{ {
_units = units; _units = units;
setXUnits();
setYUnits(); setYUnits();
setInfo(); setInfo();
GraphView::setUnits(units);
redraw(); redraw();
} }
@ -126,7 +104,6 @@ void TemperatureGraph::showTracks(bool show)
_showTracks = show; _showTracks = show;
showGraph(show); showGraph(show);
setXUnits();
setInfo(); setInfo();
redraw(); redraw();

View File

@ -13,7 +13,7 @@ public:
TemperatureGraph(QWidget *parent = 0); TemperatureGraph(QWidget *parent = 0);
QString label() const {return tr("Temperature");} QString label() const {return tr("Temperature");}
void loadGPX(const GPX &gpx); void loadGPX(const GPX &gpx, const QList<PathItem *> &paths);
void clear(); void clear();
void setUnits(enum Units units); void setUnits(enum Units units);
void showTracks(bool show); void showTracks(bool show);
@ -23,7 +23,6 @@ private:
qreal avg() const; qreal avg() const;
qreal min() const {return bounds().top();} qreal min() const {return bounds().top();}
qreal max() const {return bounds().bottom();} qreal max() const {return bounds().bottom();}
void setXUnits();
void setYUnits(); void setYUnits();
void setInfo(); void setInfo();

View File

@ -8,39 +8,39 @@
#define WINDOW_HE 11 #define WINDOW_HE 11
#define WINDOW_HF 3 #define WINDOW_HF 3
static bool lt(const QPointF &p1, const QPointF &p2) static bool lt(qreal v1, qreal v2)
{ {
return p1.y() < p2.y(); return v1 < v2;
} }
static qreal median(QVector<QPointF> v) static qreal median(QVector<qreal> v)
{ {
qSort(v.begin(), v.end(), lt); qSort(v.begin(), v.end(), lt);
return v.at(v.size() / 2).y(); return v.at(v.size() / 2);
} }
static qreal MAD(QVector<QPointF> v, qreal m) static qreal MAD(QVector<qreal> v, qreal m)
{ {
for (int i = 0; i < v.size(); i++) for (int i = 0; i < v.size(); i++)
v[i].setY(qAbs(v.at(i).y() - m)); v[i] = (qAbs(v.at(i) - m));
qSort(v.begin(), v.end(), lt); qSort(v.begin(), v.end(), lt);
return v.at(v.size() / 2).y(); return v.at(v.size() / 2);
} }
static QVector<QPointF> eliminate(const QVector<QPointF> &v, int window) static QVector<qreal> eliminate(const QVector<qreal> &v, int window)
{ {
QList<int> rm; QList<int> rm;
QVector<QPointF> ret; QVector<qreal> ret;
qreal m, M; qreal m, M;
if (v.size() < window) if (v.size() < window)
return QVector<QPointF>(v); return QVector<qreal>(v);
for (int i = window/2; i < v.size() - window/2; i++) { for (int i = window/2; i < v.size() - window/2; i++) {
m = median(v.mid(i - window/2, window)); m = median(v.mid(i - window/2, window));
M = MAD(v.mid(i - window/2, window), m); M = MAD(v.mid(i - window/2, window), m);
if (qAbs((0.6745 * (v.at(i).y() - m)) / M) > 3.5) if (qAbs((0.6745 * (v.at(i) - m)) / M) > 3.5)
rm.append(i); rm.append(i);
} }
@ -55,26 +55,26 @@ static QVector<QPointF> eliminate(const QVector<QPointF> &v, int window)
return ret; return ret;
} }
static QVector<QPointF> filter(const QVector<QPointF> &v, int window) static QVector<qreal> filter(const QVector<qreal> &v, int window)
{ {
qreal acc = 0; qreal acc = 0;
QVector<QPointF> ret; QVector<qreal> ret;
if (v.size() < window) if (v.size() < window)
return QVector<QPointF>(v); return QVector<qreal>(v);
for (int i = 0; i < window; i++) for (int i = 0; i < window; i++)
acc += v.at(i).y(); acc += v.at(i);
for (int i = 0; i <= window/2; i++) for (int i = 0; i <= window/2; i++)
ret.append(QPointF(v.at(i).x(), acc/window)); ret.append(acc/window);
for (int i = window/2 + 1; i < v.size() - window/2; i++) { for (int i = window/2 + 1; i < v.size() - window/2; i++) {
acc += v.at(i + window/2).y() - v.at(i - (window/2 + 1)).y(); acc += v.at(i + window/2) - v.at(i - (window/2 + 1));
ret.append(QPointF(v.at(i).x(), acc/window)); ret.append(acc/window);
} }
for (int i = v.size() - window/2; i < v.size(); i++) for (int i = v.size() - window/2; i < v.size(); i++)
ret.append(QPointF(v.at(i).x(), acc/window)); ret.append(acc/window);
return ret; return ret;
} }
@ -82,80 +82,107 @@ static QVector<QPointF> filter(const QVector<QPointF> &v, int window)
Track::Track(const QVector<Trackpoint> &data) : _data(data) Track::Track(const QVector<Trackpoint> &data) : _data(data)
{ {
qreal dist = 0; qreal dist = 0;
qint64 time;
_dd.append(dist); _dd.append(0);
_td.append(0);
for (int i = 1; i < data.count(); i++) { for (int i = 1; i < data.count(); i++) {
dist += llDistance(data.at(i).coordinates(), data.at(i-1).coordinates()); dist += llDistance(data.at(i).coordinates(), data.at(i-1).coordinates());
_dd.append(dist); _dd.append(dist);
if (data.first().hasTimestamp() && data.at(i).hasTimestamp()) {
time = _data.first().timestamp().msecsTo(_data.at(i).timestamp());
_td.append((qreal)time / 1000.0);
} }
}
if (_dd.size() != _td.size())
_td.clear();
} }
QVector<QPointF> Track::elevation() const Graph Track::elevation() const
{ {
QVector<QPointF> raw; Graph ret;
QVector<qreal> raw;
if (!_data.size()) if (!_data.size())
return raw; return ret;
for (int i = 0; i < _data.size(); i++) for (int i = 0; i < _data.size(); i++)
if (_data.at(i).hasElevation()) if (_data.at(i).hasElevation())
raw.append(QPointF(_dd.at(i), _data.at(i).elevation() raw.append(_data.at(i).elevation() - _data.at(i).geoidHeight());
- _data.at(i).geoidHeight()));
return filter(raw, WINDOW_EF); ret.y = filter(raw, WINDOW_EF);
ret.distance = _dd;
ret.time = _td;
return ret;
} }
QVector<QPointF> Track::speed() const Graph Track::speed() const
{ {
qreal v, ds; Graph ret;
qint64 dt; qreal v, ds, dt;
QVector<QPointF> raw; QVector<qreal> raw;
if (!_data.size()) if (!_data.size())
return raw; return ret;
raw.append(QPointF(0, 0)); raw.append(0);
for (int i = 1; i < _data.size(); i++) { for (int i = 1; i < _data.size(); i++) {
if (_data.at(i).hasSpeed()) if (_data.at(i).hasSpeed())
v = _data.at(i).speed(); v = _data.at(i).speed();
else if (_data.at(i).hasTimestamp()) { else if (_data.at(i).hasTimestamp()) {
dt = _data.at(i-1).timestamp().msecsTo(_data.at(i).timestamp()); dt = _td.at(i) - _td.at(i-1);
if (!dt) if (!dt)
continue; continue;
ds = _dd.at(i) - _dd.at(i-1); ds = _dd.at(i) - _dd.at(i-1);
v = ds / ((qreal)dt / 1000.0); v = ds / dt;
} else } else
continue; continue;
raw.append(QPointF(_dd.at(i), v)); raw.append(v);
} }
return filter(eliminate(raw, WINDOW_SE), WINDOW_SF); ret.y = filter(eliminate(raw, WINDOW_SE), WINDOW_SF);
ret.distance = _dd;
ret.time = _td;
return ret;
} }
QVector<QPointF> Track::heartRate() const Graph Track::heartRate() const
{ {
QVector<QPointF> raw; Graph ret;
QVector<qreal> raw;
if (!_data.size()) if (!_data.size())
return raw; return ret;
for (int i = 0; i < _data.count(); i++) for (int i = 0; i < _data.count(); i++)
if (_data.at(i).hasHeartRate()) if (_data.at(i).hasHeartRate())
raw.append(QPointF(_dd.at(i), _data.at(i).heartRate())); raw.append(_data.at(i).heartRate());
return filter(eliminate(raw, WINDOW_HE), WINDOW_HF); ret.y = filter(eliminate(raw, WINDOW_HE), WINDOW_HF);
ret.distance = _dd;
ret.time = _td;
return ret;
} }
QVector<QPointF> Track::temperature() const Graph Track::temperature() const
{ {
QVector<QPointF> graph; Graph ret;
for (int i = 0; i < _data.size(); i++) for (int i = 0; i < _data.size(); i++)
if (_data.at(i).hasTemperature()) if (_data.at(i).hasTemperature())
graph.append(QPointF(_dd.at(i), _data.at(i).temperature())); ret.y.append(_data.at(i).temperature());
return graph; ret.distance = _dd;
ret.time = _td;
return ret;
} }
qreal Track::distance() const qreal Track::distance() const

View File

@ -4,6 +4,7 @@
#include <QVector> #include <QVector>
#include <QDateTime> #include <QDateTime>
#include "trackpoint.h" #include "trackpoint.h"
#include "graph.h"
class Track class Track
{ {
@ -11,10 +12,10 @@ public:
Track(const QVector<Trackpoint> &data); Track(const QVector<Trackpoint> &data);
const QVector<Trackpoint> &track() const {return _data;} const QVector<Trackpoint> &track() const {return _data;}
QVector<QPointF> elevation() const; Graph elevation() const;
QVector<QPointF> speed() const; Graph speed() const;
QVector<QPointF> heartRate() const; Graph heartRate() const;
QVector<QPointF> temperature() const; Graph temperature() const;
qreal distance() const; qreal distance() const;
qreal time() const; qreal time() const;
@ -25,6 +26,7 @@ public:
private: private:
const QVector<Trackpoint> &_data; const QVector<Trackpoint> &_data;
QVector<qreal> _dd; QVector<qreal> _dd;
QVector<qreal> _td;
}; };
#endif // TRACK_H #endif // TRACK_H

View File

@ -38,7 +38,7 @@ void TrackItem::updateShape()
} }
TrackItem::TrackItem(const Track &track, QGraphicsItem *parent) TrackItem::TrackItem(const Track &track, QGraphicsItem *parent)
: QGraphicsItem(parent) : PathItem(parent)
{ {
const QVector<Trackpoint> &t = track.track(); const QVector<Trackpoint> &t = track.track();
Q_ASSERT(t.count() >= 2); Q_ASSERT(t.count() >= 2);

View File

@ -1,15 +1,18 @@
#ifndef TRACKITEM_H #ifndef TRACKITEM_H
#define TRACKITEM_H #define TRACKITEM_H
#include <QGraphicsItem>
#include <QDateTime> #include <QDateTime>
#include <QPen>
#include "pathitem.h"
#include "units.h" #include "units.h"
#include "track.h" #include "track.h"
#include "markeritem.h" #include "markeritem.h"
class TrackItem : public QGraphicsItem class TrackItem : public PathItem
{ {
Q_OBJECT
public: public:
TrackItem(const Track &track, QGraphicsItem *parent = 0); TrackItem(const Track &track, QGraphicsItem *parent = 0);

View File

@ -45,7 +45,7 @@ TrackView::TrackView(QWidget *parent)
_showRouteWaypoints = true; _showRouteWaypoints = true;
_plot = false; _plot = false;
_markerPos = 0; //_markerPos = 0;
} }
TrackView::~TrackView() TrackView::~TrackView()
@ -54,11 +54,11 @@ TrackView::~TrackView()
delete _mapScale; delete _mapScale;
} }
void TrackView::addTrack(const Track &track) PathItem *TrackView::addTrack(const Track &track)
{ {
if (track.isNull()) { if (track.isNull()) {
_palette.color(); _palette.color();
return; return 0;
} }
TrackItem *ti = new TrackItem(track); TrackItem *ti = new TrackItem(track);
@ -68,15 +68,17 @@ void TrackView::addTrack(const Track &track)
ti->setScale(1.0/_scale); ti->setScale(1.0/_scale);
ti->setColor(_palette.color()); ti->setColor(_palette.color());
ti->setVisible(_showTracks); ti->setVisible(_showTracks);
ti->moveMarker(_markerPos); //ti->moveMarker(_markerPos);
_scene->addItem(ti); _scene->addItem(ti);
return ti;
} }
void TrackView::addRoute(const Route &route) PathItem *TrackView::addRoute(const Route &route)
{ {
if (route.isNull()) { if (route.isNull()) {
_palette.color(); _palette.color();
return; return 0;
} }
RouteItem *ri = new RouteItem(route); RouteItem *ri = new RouteItem(route);
@ -88,8 +90,10 @@ void TrackView::addRoute(const Route &route)
ri->setVisible(_showRoutes); ri->setVisible(_showRoutes);
ri->showWaypoints(_showRouteWaypoints); ri->showWaypoints(_showRouteWaypoints);
ri->showWaypointLabels(_showWaypointLabels); ri->showWaypointLabels(_showWaypointLabels);
ri->moveMarker(_markerPos); //ri->moveMarker(_markerPos);
_scene->addItem(ri); _scene->addItem(ri);
return ri;
} }
void TrackView::addWaypoints(const QList<Waypoint> &waypoints) void TrackView::addWaypoints(const QList<Waypoint> &waypoints)
@ -111,18 +115,25 @@ void TrackView::addWaypoints(const QList<Waypoint> &waypoints)
_scale = mapScale(_zoom); _scale = mapScale(_zoom);
} }
void TrackView::loadGPX(const GPX &gpx) QList<PathItem *> TrackView::loadGPX(const GPX &gpx)
{ {
QList<PathItem *> paths;
PathItem *pi;
int zoom = _zoom; int zoom = _zoom;
for (int i = 0; i < gpx.tracks().count(); i++) for (int i = 0; i < gpx.tracks().count(); i++) {
addTrack(*(gpx.tracks().at(i))); if ((pi = addTrack(*(gpx.tracks().at(i)))))
for (int i = 0; i < gpx.routes().count(); i++) paths.append(pi);
addRoute(*(gpx.routes().at(i))); }
for (int i = 0; i < gpx.routes().count(); i++) {
if ((pi = addRoute(*(gpx.routes().at(i)))))
paths.append(pi);
}
addWaypoints(gpx.waypoints()); addWaypoints(gpx.waypoints());
if (_tracks.empty() && _routes.empty() && _waypoints.empty()) if (_tracks.empty() && _routes.empty() && _waypoints.empty())
return; return paths;
if ((_tracks.size() > 1 && _zoom < zoom) if ((_tracks.size() > 1 && _zoom < zoom)
|| (_routes.size() > 1 && _zoom < zoom) || (_routes.size() > 1 && _zoom < zoom)
@ -138,6 +149,8 @@ void TrackView::loadGPX(const GPX &gpx)
_mapScale->setZoom(_zoom, -(br.center().ry() * _scale)); _mapScale->setZoom(_zoom, -(br.center().ry() * _scale));
if (_mapScale->scene() != _scene) if (_mapScale->scene() != _scene)
_scene->addItem(_mapScale); _scene->addItem(_mapScale);
return paths;
} }
QRectF TrackView::trackBoundingRect() const QRectF TrackView::trackBoundingRect() const
@ -478,9 +491,10 @@ void TrackView::clear()
_scene->setSceneRect(QRectF()); _scene->setSceneRect(QRectF());
_markerPos = 0; //_markerPos = 0;
} }
/*
void TrackView::movePositionMarker(qreal val) void TrackView::movePositionMarker(qreal val)
{ {
_markerPos = val; _markerPos = val;
@ -491,6 +505,7 @@ void TrackView::movePositionMarker(qreal val)
for (int i = 0; i < _routes.size(); i++) for (int i = 0; i < _routes.size(); i++)
_routes.at(i)->moveMarker(val); _routes.at(i)->moveMarker(val);
} }
*/
void TrackView::showTracks(bool show) void TrackView::showTracks(bool show)
{ {

View File

@ -18,6 +18,7 @@ class TrackItem;
class RouteItem; class RouteItem;
class WaypointItem; class WaypointItem;
class ScaleItem; class ScaleItem;
class PathItem;
class TrackView : public QGraphicsView class TrackView : public QGraphicsView
{ {
@ -27,7 +28,7 @@ public:
TrackView(QWidget *parent = 0); TrackView(QWidget *parent = 0);
~TrackView(); ~TrackView();
void loadGPX(const GPX &gpx); QList<PathItem*> loadGPX(const GPX &gpx);
void loadPOI(const POI &poi); void loadPOI(const POI &poi);
void clearPOI(); void clearPOI();
@ -43,7 +44,7 @@ public:
int waypointCount() const {return _waypoints.count();} int waypointCount() const {return _waypoints.count();}
public slots: public slots:
void movePositionMarker(qreal val); //void movePositionMarker(qreal val);
void redraw(); void redraw();
void setPOIOverlap(bool overlap); void setPOIOverlap(bool overlap);
@ -55,8 +56,8 @@ public slots:
void showRouteWaypoints(bool show); void showRouteWaypoints(bool show);
private: private:
void addTrack(const Track &track); PathItem *addTrack(const Track &track);
void addRoute(const Route &route); PathItem *addRoute(const Route &route);
void addWaypoints(const QList<Waypoint> &waypoints); void addWaypoints(const QList<Waypoint> &waypoints);
void addPOI(const QVector<Waypoint> &waypoints); void addPOI(const QVector<Waypoint> &waypoints);
@ -103,7 +104,7 @@ private:
bool _showRouteWaypoints; bool _showRouteWaypoints;
bool _plot; bool _plot;
qreal _markerPos; //qreal _markerPos;
}; };
#endif // TRACKVIEW_H #endif // TRACKVIEW_H

View File

@ -13,10 +13,14 @@ enum Units {
#define MS2MIH 2.236936290000 // m/s -> mi/h #define MS2MIH 2.236936290000 // m/s -> mi/h
#define FT2MI 0.000189393939 // ft -> mi #define FT2MI 0.000189393939 // ft -> mi
#define MM2IN 0.039370100000 // mm -> in #define MM2IN 0.039370100000 // mm -> in
#define H2S 0.000277777778 // h -> s
#define MIN2S 0.016666666667 // min -> s
#define KMINM 1000 // 1 km in m #define KMINM 1000 // 1 km in m
#define MIINFT 5280 // 1 mi in ft #define MIINFT 5280 // 1 mi in ft
#define MIINM 1609.344 // 1mi in m #define MIINM 1609.344 // 1 mi in m
#define MININS 60 // 1 min in s
#define HINS 3600 // 1 hins
#define C2FS 1.8 // Celsius to Farenheit - scale #define C2FS 1.8 // Celsius to Farenheit - scale
#define C2FO 32 // Celsius to Farenheit - offset #define C2FO 32 // Celsius to Farenheit - offset