mirror of
https://github.com/tumic0/GPXSee.git
synced 2025-07-01 21:39:15 +02:00
Compare commits
46 Commits
Author | SHA1 | Date | |
---|---|---|---|
e05069d653 | |||
1928b579ab | |||
501431207f | |||
0d41341086 | |||
13f383ab7a | |||
5253698602 | |||
6bcb6ceb8d | |||
9da82a978c | |||
64a343dd2e | |||
ac93ccba29 | |||
7cd005873d | |||
9c16c3498c | |||
a2eaacc017 | |||
58bed99d14 | |||
de71aa0d0c | |||
14290bf1f0 | |||
e0fd77bbfd | |||
b1b8d68610 | |||
a0b64b4227 | |||
93670d3026 | |||
b212ccf594 | |||
a80de92691 | |||
17ab241a6d | |||
816e1d1768 | |||
50c768e12d | |||
72dda5fdd6 | |||
ee3a6adf2b | |||
56f15da550 | |||
61c82a0836 | |||
201b3f6dae | |||
04f2a08b78 | |||
a736e3204f | |||
08f503249d | |||
f05e6ce29f | |||
209f58412a | |||
919d53ade9 | |||
4cba2ddefd | |||
e52a163529 | |||
70238062f2 | |||
7d749dfe5b | |||
64e65679fe | |||
7a6e60b83d | |||
a1ac09f615 | |||
236d045492 | |||
ba4ac9fe51 | |||
59d8b3cc77 |
@ -4,7 +4,7 @@ GPX viewer and analyzer.
|
||||
* User-definable map sources.
|
||||
* Track and elevation/speed graphs.
|
||||
* Support for multiple tracks in one view.
|
||||
* Support for POI files (Garmin CSV format).
|
||||
* Support for POI files.
|
||||
* Export to PDF.
|
||||
* Native GUI for Windows, Mac OS X and Linux.
|
||||
|
||||
@ -23,7 +23,8 @@ nmake release
|
||||
```
|
||||
|
||||
## Binaries
|
||||
Available at Sourceforge: http://sourceforge.net/projects/gpxsee
|
||||
* Windows & OS X builds: http://sourceforge.net/projects/gpxsee
|
||||
* Linux packages: https://build.opensuse.org/project/repositories/home:tumic:GPXSee
|
||||
|
||||
## Homepage
|
||||
GPXSee homepage: http://tumic.wz.cz/gpxsee
|
||||
|
@ -55,8 +55,9 @@ Section "GPXSee (required)" SEC_APP
|
||||
; Set output path to the installation directory.
|
||||
SetOutPath $INSTDIR
|
||||
|
||||
; Put file there
|
||||
; Put the files there
|
||||
File "gpxsee.exe"
|
||||
File "maps.txt"
|
||||
|
||||
; Write the installation path into the registry
|
||||
WriteRegStr HKLM SOFTWARE\GPXSee "Install_Dir" "$INSTDIR"
|
||||
@ -64,7 +65,7 @@ Section "GPXSee (required)" SEC_APP
|
||||
; Write the uninstall keys for Windows
|
||||
WriteRegStr HKLM "${REGENTRY}" "DisplayName" "GPXSee"
|
||||
WriteRegStr HKLM "${REGENTRY}" "Publisher" "Martin Tuma"
|
||||
WriteRegStr HKLM "${REGENTRY}" "DisplayVersion" "2.7"
|
||||
WriteRegStr HKLM "${REGENTRY}" "DisplayVersion" "2.10"
|
||||
WriteRegStr HKLM "${REGENTRY}" "UninstallString" '"$INSTDIR\uninstall.exe"'
|
||||
WriteRegDWORD HKLM "${REGENTRY}" "NoModify" 1
|
||||
WriteRegDWORD HKLM "${REGENTRY}" "NoRepair" 1
|
||||
|
14
gpxsee.pro
14
gpxsee.pro
@ -13,8 +13,6 @@ HEADERS += src/config.h \
|
||||
src/rtree.h \
|
||||
src/ll.h \
|
||||
src/axisitem.h \
|
||||
src/poiitem.h \
|
||||
src/colorshop.h \
|
||||
src/keys.h \
|
||||
src/slideritem.h \
|
||||
src/markeritem.h \
|
||||
@ -33,7 +31,10 @@ HEADERS += src/config.h \
|
||||
src/trackview.h \
|
||||
src/track.h \
|
||||
src/graphview.h \
|
||||
src/trackpoint.h
|
||||
src/trackpoint.h \
|
||||
src/waypointitem.h \
|
||||
src/palette.h \
|
||||
src/heartrategraph.h
|
||||
SOURCES += src/main.cpp \
|
||||
src/gui.cpp \
|
||||
src/gpx.cpp \
|
||||
@ -41,8 +42,6 @@ SOURCES += src/main.cpp \
|
||||
src/poi.cpp \
|
||||
src/ll.cpp \
|
||||
src/axisitem.cpp \
|
||||
src/poiitem.cpp \
|
||||
src/colorshop.cpp \
|
||||
src/slideritem.cpp \
|
||||
src/markeritem.cpp \
|
||||
src/infoitem.cpp \
|
||||
@ -57,7 +56,10 @@ SOURCES += src/main.cpp \
|
||||
src/nicenum.cpp \
|
||||
src/trackview.cpp \
|
||||
src/track.cpp \
|
||||
src/graphview.cpp
|
||||
src/graphview.cpp \
|
||||
src/waypointitem.cpp \
|
||||
src/palette.cpp \
|
||||
src/heartrategraph.cpp
|
||||
RESOURCES += gpxsee.qrc
|
||||
TRANSLATIONS = lang/gpxsee_cs.ts
|
||||
macx:ICON = icons/gpxsee.icns
|
||||
|
@ -14,6 +14,5 @@
|
||||
<file>icons/arrow-left-double.png</file>
|
||||
<file>icons/arrow-right-double.png</file>
|
||||
<file>lang/gpxsee_cs.qm</file>
|
||||
<file>maps.txt</file>
|
||||
</qresource>
|
||||
</RCC>
|
||||
|
@ -1,6 +1,6 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!DOCTYPE TS>
|
||||
<TS version="2.0" language="cs_CZ">
|
||||
<TS version="2.1" language="cs_CZ">
|
||||
<context>
|
||||
<name>ElevationGraph</name>
|
||||
<message>
|
||||
@ -15,43 +15,43 @@
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/elevationgraph.cpp" line="16"/>
|
||||
<location filename="../src/elevationgraph.cpp" line="83"/>
|
||||
<location filename="../src/elevationgraph.cpp" line="86"/>
|
||||
<source>km</source>
|
||||
<translation>km</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/elevationgraph.cpp" line="17"/>
|
||||
<location filename="../src/elevationgraph.cpp" line="84"/>
|
||||
<location filename="../src/elevationgraph.cpp" line="87"/>
|
||||
<source>m</source>
|
||||
<translation>m</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/elevationgraph.cpp" line="23"/>
|
||||
<location filename="../src/elevationgraph.cpp" line="24"/>
|
||||
<source>Ascent</source>
|
||||
<translation>Stoupání</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/elevationgraph.cpp" line="25"/>
|
||||
<location filename="../src/elevationgraph.cpp" line="26"/>
|
||||
<source>Descent</source>
|
||||
<translation>Klesání</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/elevationgraph.cpp" line="29"/>
|
||||
<location filename="../src/elevationgraph.cpp" line="30"/>
|
||||
<source>Minimum</source>
|
||||
<translation>Minimum</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/elevationgraph.cpp" line="88"/>
|
||||
<location filename="../src/elevationgraph.cpp" line="91"/>
|
||||
<source>mi</source>
|
||||
<translation>mi</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/elevationgraph.cpp" line="89"/>
|
||||
<location filename="../src/elevationgraph.cpp" line="92"/>
|
||||
<source>ft</source>
|
||||
<translation>ft</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/elevationgraph.cpp" line="27"/>
|
||||
<location filename="../src/elevationgraph.cpp" line="28"/>
|
||||
<source>Maximum</source>
|
||||
<translation>Maximum</translation>
|
||||
</message>
|
||||
@ -59,336 +59,356 @@
|
||||
<context>
|
||||
<name>GUI</name>
|
||||
<message>
|
||||
<location filename="../src/gui.cpp" line="140"/>
|
||||
<location filename="../src/gui.cpp" line="186"/>
|
||||
<source>About Qt</source>
|
||||
<translation>O Qt</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/gui.cpp" line="350"/>
|
||||
<location filename="../src/gui.cpp" line="406"/>
|
||||
<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>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/gui.cpp" line="411"/>
|
||||
<location filename="../src/gui.cpp" line="465"/>
|
||||
<source>Open file</source>
|
||||
<translation>Otevřít soubor</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/gui.cpp" line="154"/>
|
||||
<location filename="../src/gui.cpp" line="200"/>
|
||||
<source>Save as</source>
|
||||
<translation>Uložit jako</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/gui.cpp" line="471"/>
|
||||
<location filename="../src/gui.cpp" line="532"/>
|
||||
<source>Open POI file</source>
|
||||
<translation>Otevřít POI soubor</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/gui.cpp" line="145"/>
|
||||
<location filename="../src/gui.cpp" line="191"/>
|
||||
<source>Open</source>
|
||||
<translation>Otevřít</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/gui.cpp" line="128"/>
|
||||
<location filename="../src/gui.cpp" line="174"/>
|
||||
<source>Quit</source>
|
||||
<translation>Ukončit</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/gui.cpp" line="135"/>
|
||||
<location filename="../src/gui.cpp" line="366"/>
|
||||
<location filename="../src/gui.cpp" line="367"/>
|
||||
<location filename="../src/gui.cpp" line="181"/>
|
||||
<location filename="../src/gui.cpp" line="422"/>
|
||||
<location filename="../src/gui.cpp" line="423"/>
|
||||
<source>Keyboard controls</source>
|
||||
<translation>Ovládací klávesy</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/gui.cpp" line="149"/>
|
||||
<location filename="../src/gui.cpp" line="195"/>
|
||||
<source>Save</source>
|
||||
<translation>Uložit</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/gui.cpp" line="159"/>
|
||||
<location filename="../src/gui.cpp" line="205"/>
|
||||
<source>Close</source>
|
||||
<translation>Zavřít</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/gui.cpp" line="164"/>
|
||||
<location filename="../src/gui.cpp" line="210"/>
|
||||
<source>Reload</source>
|
||||
<translation>Znovu načíst</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/gui.cpp" line="287"/>
|
||||
<location filename="../src/gui.cpp" line="342"/>
|
||||
<source>Show</source>
|
||||
<translation>Zobrazit</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/gui.cpp" line="237"/>
|
||||
<location filename="../src/gui.cpp" line="278"/>
|
||||
<location filename="../src/gui.cpp" line="287"/>
|
||||
<location filename="../src/gui.cpp" line="333"/>
|
||||
<source>File</source>
|
||||
<translation>Soubor</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/gui.cpp" line="133"/>
|
||||
<location filename="../src/gui.cpp" line="384"/>
|
||||
<location filename="../src/gui.cpp" line="385"/>
|
||||
<location filename="../src/gui.cpp" line="179"/>
|
||||
<location filename="../src/gui.cpp" line="440"/>
|
||||
<location filename="../src/gui.cpp" line="441"/>
|
||||
<source>Data sources</source>
|
||||
<translation>Zdroje dat</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/gui.cpp" line="171"/>
|
||||
<location filename="../src/gui.cpp" line="217"/>
|
||||
<source>Load POI file</source>
|
||||
<translation>Nahrát POI soubor</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/gui.cpp" line="174"/>
|
||||
<location filename="../src/gui.cpp" line="220"/>
|
||||
<source>Close POI files</source>
|
||||
<translation>Zavřit soubory POI</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/gui.cpp" line="223"/>
|
||||
<source>Show POIs</source>
|
||||
<translation>Zobrazit POI</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/gui.cpp" line="180"/>
|
||||
<location filename="../src/gui.cpp" line="230"/>
|
||||
<source>Show map</source>
|
||||
<translation>Zobrazit mapu</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/gui.cpp" line="193"/>
|
||||
<location filename="../src/gui.cpp" line="243"/>
|
||||
<source>Show graphs</source>
|
||||
<translation>Zobrazovat grafy</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/gui.cpp" line="199"/>
|
||||
<location filename="../src/gui.cpp" line="249"/>
|
||||
<source>Show toolbars</source>
|
||||
<translation>Zobrazovat nástrojové lišty</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/gui.cpp" line="206"/>
|
||||
<location filename="../src/gui.cpp" line="256"/>
|
||||
<source>Metric</source>
|
||||
<translation>Metrické</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/gui.cpp" line="212"/>
|
||||
<location filename="../src/gui.cpp" line="262"/>
|
||||
<source>Imperial</source>
|
||||
<translation>Imperiální</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/gui.cpp" line="219"/>
|
||||
<location filename="../src/gui.cpp" line="269"/>
|
||||
<source>Next</source>
|
||||
<translation>Následující</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/gui.cpp" line="222"/>
|
||||
<location filename="../src/gui.cpp" line="272"/>
|
||||
<source>Previous</source>
|
||||
<translation>Předchozí</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/gui.cpp" line="226"/>
|
||||
<location filename="../src/gui.cpp" line="276"/>
|
||||
<source>Last</source>
|
||||
<translation>Poslední</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/gui.cpp" line="229"/>
|
||||
<location filename="../src/gui.cpp" line="279"/>
|
||||
<source>First</source>
|
||||
<translation>První</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/gui.cpp" line="251"/>
|
||||
<location filename="../src/gui.cpp" line="301"/>
|
||||
<source>Map</source>
|
||||
<translation>Mapa</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/gui.cpp" line="256"/>
|
||||
<location filename="../src/gui.cpp" line="306"/>
|
||||
<source>POI</source>
|
||||
<translation>POI</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/gui.cpp" line="260"/>
|
||||
<location filename="../src/gui.cpp" line="307"/>
|
||||
<source>POI files</source>
|
||||
<translation>POI soubory</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/gui.cpp" line="315"/>
|
||||
<source>Settings</source>
|
||||
<translation>Nastavení</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/gui.cpp" line="261"/>
|
||||
<location filename="../src/gui.cpp" line="316"/>
|
||||
<source>Units</source>
|
||||
<translation>Jednotky</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/gui.cpp" line="268"/>
|
||||
<location filename="../src/gui.cpp" line="323"/>
|
||||
<source>Help</source>
|
||||
<translation>Nápověda</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/gui.cpp" line="318"/>
|
||||
<location filename="../src/gui.cpp" line="732"/>
|
||||
<source>No GPX files loaded</source>
|
||||
<translation>Nejsou načteny žádné GPX soubory</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/gui.cpp" line="804"/>
|
||||
<source>Elevation</source>
|
||||
<translation>Výška</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/gui.cpp" line="319"/>
|
||||
<location filename="../src/gui.cpp" line="805"/>
|
||||
<source>Speed</source>
|
||||
<translation>Rychlost</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/gui.cpp" line="369"/>
|
||||
<location filename="../src/gui.cpp" line="806"/>
|
||||
<source>Heart rate</source>
|
||||
<translation>Tep</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/gui.cpp" line="425"/>
|
||||
<source>Next file</source>
|
||||
<translation>Následující soubor</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/gui.cpp" line="370"/>
|
||||
<location filename="../src/gui.cpp" line="426"/>
|
||||
<source>Previous file</source>
|
||||
<translation>Předchozí soubor</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/gui.cpp" line="372"/>
|
||||
<location filename="../src/gui.cpp" line="428"/>
|
||||
<source>First file</source>
|
||||
<translation>První soubor</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/gui.cpp" line="373"/>
|
||||
<location filename="../src/gui.cpp" line="429"/>
|
||||
<source>Last file</source>
|
||||
<translation>Poslední soubor</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/gui.cpp" line="374"/>
|
||||
<location filename="../src/gui.cpp" line="430"/>
|
||||
<source>Append modifier</source>
|
||||
<translation>Modifikátor nahradit/přidat</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/gui.cpp" line="388"/>
|
||||
<location filename="../src/gui.cpp" line="444"/>
|
||||
<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>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/gui.cpp" line="392"/>
|
||||
<location filename="../src/gui.cpp" line="447"/>
|
||||
<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>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/gui.cpp" line="400"/>
|
||||
<location filename="../src/gui.cpp" line="455"/>
|
||||
<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>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/gui.cpp" line="412"/>
|
||||
<location filename="../src/gui.cpp" line="466"/>
|
||||
<source>GPX files (*.gpx);;All files (*)</source>
|
||||
<translation>soubory GPX (*.gpx);;všechny soubory (*)</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/gui.cpp" line="462"/>
|
||||
<location filename="../src/gui.cpp" line="479"/>
|
||||
<location filename="../src/gui.cpp" line="523"/>
|
||||
<location filename="../src/gui.cpp" line="549"/>
|
||||
<source>Line: %1</source>
|
||||
<translation>Řádka: %1</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/gui.cpp" line="472"/>
|
||||
<location filename="../src/gui.cpp" line="533"/>
|
||||
<source>GPX files (*.gpx);;CSV files (*.csv);;All files (*)</source>
|
||||
<translation>soubory GPX (*.gpx);;soubory CSV (*.csv);;všechny soubory (*)</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/gui.cpp" line="526"/>
|
||||
<location filename="../src/gui.cpp" line="645"/>
|
||||
<location filename="../src/gui.cpp" line="614"/>
|
||||
<location filename="../src/gui.cpp" line="743"/>
|
||||
<source>mi</source>
|
||||
<translation>mi</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/gui.cpp" line="529"/>
|
||||
<location filename="../src/gui.cpp" line="531"/>
|
||||
<location filename="../src/gui.cpp" line="533"/>
|
||||
<location filename="../src/gui.cpp" line="535"/>
|
||||
<location filename="../src/gui.cpp" line="617"/>
|
||||
<location filename="../src/gui.cpp" line="619"/>
|
||||
<location filename="../src/gui.cpp" line="621"/>
|
||||
<location filename="../src/gui.cpp" line="623"/>
|
||||
<source>ft</source>
|
||||
<translation>ft</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/gui.cpp" line="532"/>
|
||||
<location filename="../src/gui.cpp" line="544"/>
|
||||
<location filename="../src/gui.cpp" line="620"/>
|
||||
<location filename="../src/gui.cpp" line="632"/>
|
||||
<source>Maximum</source>
|
||||
<translation>Maximum</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/gui.cpp" line="534"/>
|
||||
<location filename="../src/gui.cpp" line="546"/>
|
||||
<location filename="../src/gui.cpp" line="622"/>
|
||||
<location filename="../src/gui.cpp" line="634"/>
|
||||
<source>Minimum</source>
|
||||
<translation>Minimum</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/gui.cpp" line="138"/>
|
||||
<location filename="../src/gui.cpp" line="346"/>
|
||||
<location filename="../src/gui.cpp" line="184"/>
|
||||
<location filename="../src/gui.cpp" line="402"/>
|
||||
<source>About GPXSee</source>
|
||||
<translation>O aplikaci GPXSee</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/gui.cpp" line="294"/>
|
||||
<location filename="../src/gui.cpp" line="349"/>
|
||||
<source>Navigation</source>
|
||||
<translation>Navigace</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/gui.cpp" line="348"/>
|
||||
<location filename="../src/gui.cpp" line="404"/>
|
||||
<source>GPX viewer and analyzer</source>
|
||||
<translation>Prohlížeč a analyzátor GPX</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/gui.cpp" line="387"/>
|
||||
<location filename="../src/gui.cpp" line="443"/>
|
||||
<source>Map sources</source>
|
||||
<translation>Mapové zdroje</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/gui.cpp" line="399"/>
|
||||
<location filename="../src/gui.cpp" line="454"/>
|
||||
<source>POIs</source>
|
||||
<translation>POI body</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/gui.cpp" line="525"/>
|
||||
<location filename="../src/gui.cpp" line="537"/>
|
||||
<location filename="../src/gui.cpp" line="613"/>
|
||||
<location filename="../src/gui.cpp" line="625"/>
|
||||
<source>Distance</source>
|
||||
<translation>Vzdálenost</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/gui.cpp" line="527"/>
|
||||
<location filename="../src/gui.cpp" line="539"/>
|
||||
<location filename="../src/gui.cpp" line="615"/>
|
||||
<location filename="../src/gui.cpp" line="627"/>
|
||||
<source>Time</source>
|
||||
<translation>Čas</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/gui.cpp" line="528"/>
|
||||
<location filename="../src/gui.cpp" line="540"/>
|
||||
<location filename="../src/gui.cpp" line="616"/>
|
||||
<location filename="../src/gui.cpp" line="628"/>
|
||||
<source>Ascent</source>
|
||||
<translation>Stoupání</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/gui.cpp" line="541"/>
|
||||
<location filename="../src/gui.cpp" line="543"/>
|
||||
<location filename="../src/gui.cpp" line="545"/>
|
||||
<location filename="../src/gui.cpp" line="547"/>
|
||||
<location filename="../src/gui.cpp" line="629"/>
|
||||
<location filename="../src/gui.cpp" line="631"/>
|
||||
<location filename="../src/gui.cpp" line="633"/>
|
||||
<location filename="../src/gui.cpp" line="635"/>
|
||||
<source>m</source>
|
||||
<translation>m</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/gui.cpp" line="530"/>
|
||||
<location filename="../src/gui.cpp" line="542"/>
|
||||
<location filename="../src/gui.cpp" line="618"/>
|
||||
<location filename="../src/gui.cpp" line="630"/>
|
||||
<source>Descent</source>
|
||||
<translation>Klesání</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/gui.cpp" line="641"/>
|
||||
<location filename="../src/gui.cpp" line="739"/>
|
||||
<source>%1 tracks</source>
|
||||
<translation>Počet tras: %1</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/gui.cpp" line="538"/>
|
||||
<location filename="../src/gui.cpp" line="648"/>
|
||||
<location filename="../src/gui.cpp" line="626"/>
|
||||
<location filename="../src/gui.cpp" line="746"/>
|
||||
<source>km</source>
|
||||
<translation>km</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/gui.cpp" line="464"/>
|
||||
<location filename="../src/gui.cpp" line="480"/>
|
||||
<location filename="../src/gui.cpp" line="525"/>
|
||||
<location filename="../src/gui.cpp" line="550"/>
|
||||
<source>Error</source>
|
||||
<translation>Chyba</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/gui.cpp" line="459"/>
|
||||
<location filename="../src/gui.cpp" line="520"/>
|
||||
<source>Error loading GPX file:
|
||||
%1</source>
|
||||
<translation>Soubor GPX nelze otevřít:
|
||||
%1</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/gui.cpp" line="476"/>
|
||||
<location filename="../src/gui.cpp" line="546"/>
|
||||
<source>Error loading POI file:
|
||||
%1</source>
|
||||
<translation>Soubor POI nelze otevřít:
|
||||
@ -396,24 +416,63 @@
|
||||
</message>
|
||||
</context>
|
||||
<context>
|
||||
<name>QObject</name>
|
||||
<name>HeartRateGraph</name>
|
||||
<message>
|
||||
<location filename="../src/scaleitem.cpp" line="75"/>
|
||||
<source>mi</source>
|
||||
<translation>mi</translation>
|
||||
<location filename="../src/heartrategraph.cpp" line="9"/>
|
||||
<source>Distance</source>
|
||||
<translation>Vzdálenost</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/scaleitem.cpp" line="75"/>
|
||||
<source>ft</source>
|
||||
<translation>ft</translation>
|
||||
<location filename="../src/heartrategraph.cpp" line="10"/>
|
||||
<source>Heart rate</source>
|
||||
<translation>Tep</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/scaleitem.cpp" line="77"/>
|
||||
<location filename="../src/heartrategraph.cpp" line="11"/>
|
||||
<location filename="../src/heartrategraph.cpp" line="76"/>
|
||||
<source>km</source>
|
||||
<translation>km</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/scaleitem.cpp" line="77"/>
|
||||
<location filename="../src/heartrategraph.cpp" line="12"/>
|
||||
<source>1/min</source>
|
||||
<translation>1/min</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/heartrategraph.cpp" line="19"/>
|
||||
<source>Average</source>
|
||||
<translation>Průměr</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/heartrategraph.cpp" line="21"/>
|
||||
<source>Maximum</source>
|
||||
<translation>Maximum</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/heartrategraph.cpp" line="79"/>
|
||||
<source>mi</source>
|
||||
<translation>mi</translation>
|
||||
</message>
|
||||
</context>
|
||||
<context>
|
||||
<name>QObject</name>
|
||||
<message>
|
||||
<location filename="../src/scaleitem.cpp" line="83"/>
|
||||
<source>mi</source>
|
||||
<translation>mi</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/scaleitem.cpp" line="83"/>
|
||||
<source>ft</source>
|
||||
<translation>ft</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/scaleitem.cpp" line="85"/>
|
||||
<source>km</source>
|
||||
<translation>km</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/scaleitem.cpp" line="85"/>
|
||||
<source>m</source>
|
||||
<translation>m</translation>
|
||||
</message>
|
||||
@ -432,13 +491,13 @@
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/speedgraph.cpp" line="12"/>
|
||||
<location filename="../src/speedgraph.cpp" line="73"/>
|
||||
<location filename="../src/speedgraph.cpp" line="75"/>
|
||||
<source>km</source>
|
||||
<translation></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/speedgraph.cpp" line="13"/>
|
||||
<location filename="../src/speedgraph.cpp" line="74"/>
|
||||
<location filename="../src/speedgraph.cpp" line="76"/>
|
||||
<source>km/h</source>
|
||||
<translation>km/h</translation>
|
||||
</message>
|
||||
@ -453,12 +512,12 @@
|
||||
<translation>Maximum</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/speedgraph.cpp" line="78"/>
|
||||
<location filename="../src/speedgraph.cpp" line="80"/>
|
||||
<source>mi</source>
|
||||
<translation>mi</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/speedgraph.cpp" line="79"/>
|
||||
<location filename="../src/speedgraph.cpp" line="81"/>
|
||||
<source>mi/h</source>
|
||||
<translation>mi/h</translation>
|
||||
</message>
|
||||
|
@ -77,9 +77,20 @@ void AxisItem::updateBoundingRect()
|
||||
_size + es.width()/2 + ss.width()/2,
|
||||
ls.height() + es.height() - fm.descent() + TICK + 2*PADDING);
|
||||
} else {
|
||||
_boundingRect = QRectF(-(ls.height() + es.width() + 2*PADDING
|
||||
int mtw = 0;
|
||||
QRect ts;
|
||||
qreal val;
|
||||
|
||||
for (int i = 0; i < ((l.max - l.min) / l.d) + 1; i++) {
|
||||
val = l.min + i * l.d;
|
||||
QString str = QString::number(val);
|
||||
ts = fm.tightBoundingRect(str);
|
||||
mtw = qMax(ts.width(), mtw);
|
||||
}
|
||||
|
||||
_boundingRect = QRectF(-(ls.height() + mtw + 2*PADDING
|
||||
- fm.descent() + TICK/2), -(_size + es.height()/2
|
||||
+ fm.descent()), ls.height() -fm.descent() + es.width() + 2*PADDING
|
||||
+ fm.descent()), ls.height() -fm.descent() + mtw + 2*PADDING
|
||||
+ TICK, _size + es.height()/2 + fm.descent() + ss.height()/2);
|
||||
}
|
||||
}
|
||||
@ -124,6 +135,7 @@ void AxisItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *option,
|
||||
painter->drawLine(0, 0, 0, -_size);
|
||||
|
||||
l = label(_range.x(), _range.y(), YTICKS);
|
||||
int mtw = 0;
|
||||
for (int i = 0; i < ((l.max - l.min) / l.d) + 1; i++) {
|
||||
val = l.min + i * l.d;
|
||||
QString str = QString::number(val);
|
||||
@ -131,13 +143,14 @@ void AxisItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *option,
|
||||
painter->drawLine(TICK/2, -((_size/range) * (val - _range.x())),
|
||||
-TICK/2, -((_size/range) * (val - _range.x())));
|
||||
ts = fm.tightBoundingRect(str);
|
||||
mtw = qMax(ts.width(), mtw);
|
||||
painter->drawText(-(ts.width() + PADDING + TICK/2), -((_size/range)
|
||||
* (val - _range.x())) + (ts.height()/2), str);
|
||||
}
|
||||
|
||||
painter->rotate(-90);
|
||||
painter->drawText(_size/2 - ls.width()/2, -(ts.width()
|
||||
+ 2*PADDING + TICK/2), _label);
|
||||
painter->drawText(_size/2 - ls.width()/2, -(mtw + 2*PADDING + TICK/2),
|
||||
_label);
|
||||
painter->rotate(90);
|
||||
}
|
||||
|
||||
@ -147,7 +160,7 @@ void AxisItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *option,
|
||||
*/
|
||||
}
|
||||
|
||||
QSizeF AxisItem::margin()
|
||||
QSizeF AxisItem::margin() const
|
||||
{
|
||||
QFont font;
|
||||
font.setPixelSize(FONT_SIZE);
|
||||
@ -165,7 +178,18 @@ QSizeF AxisItem::margin()
|
||||
return QSizeF(es.width()/2,
|
||||
ls.height() + es.height() - fm.descent() + TICK/2 + 2*PADDING);
|
||||
} else {
|
||||
return QSizeF(ls.height() -fm.descent() + es.width() + 2*PADDING
|
||||
int mtw = 0;
|
||||
QRect ts;
|
||||
qreal val;
|
||||
|
||||
for (int i = 0; i < ((l.max - l.min) / l.d) + 1; i++) {
|
||||
val = l.min + i * l.d;
|
||||
QString str = QString::number(val);
|
||||
ts = fm.tightBoundingRect(str);
|
||||
mtw = qMax(ts.width(), mtw);
|
||||
}
|
||||
|
||||
return QSizeF(ls.height() -fm.descent() + mtw + 2*PADDING
|
||||
+ TICK/2, es.height()/2 + fm.descent());
|
||||
}
|
||||
}
|
||||
|
@ -18,7 +18,7 @@ public:
|
||||
void setSize(qreal size);
|
||||
void setLabel(const QString& label);
|
||||
|
||||
QSizeF margin();
|
||||
QSizeF margin() const;
|
||||
|
||||
private:
|
||||
void updateBoundingRect();
|
||||
|
34
src/config.h
34
src/config.h
@ -1,20 +1,34 @@
|
||||
#ifndef CONFIG_H
|
||||
#define CONFIG_H
|
||||
|
||||
#define APP_NAME "GPXSee"
|
||||
#define APP_HOMEPAGE "http://tumic.wz.cz/gpxsee"
|
||||
#define APP_VERSION "2.7"
|
||||
#include <QtGlobal>
|
||||
|
||||
#define FONT_FAMILY "Arial"
|
||||
#define FONT_SIZE 12
|
||||
#define APP_NAME "GPXSee"
|
||||
#define APP_HOMEPAGE "http://tumic.wz.cz/gpxsee"
|
||||
#define APP_VERSION "2.10"
|
||||
|
||||
#define FONT_FAMILY "Arial"
|
||||
#define FONT_SIZE 12
|
||||
|
||||
#define MAP_FILE QString("maps.txt")
|
||||
#define POI_DIR QString("POI")
|
||||
|
||||
#if defined(Q_OS_WIN32)
|
||||
#define APP_DIR "GPXSee"
|
||||
#define USER_DIR QDir::homePath() + QString("/GPXSee")
|
||||
#define GLOBAL_DIR QApplication::applicationDirPath()
|
||||
#elif defined(Q_OS_MAC)
|
||||
#define USER_DIR QDir::homePath() + QString("/.gpxsee")
|
||||
#define GLOBAL_DIR QApplication::applicationDirPath() \
|
||||
+ QString("/../Resources")
|
||||
#else
|
||||
#define APP_DIR ".gpxsee"
|
||||
#define USER_DIR QDir::homePath() + QString("/.gpxsee")
|
||||
#define GLOBAL_DIR QString("/usr/share/gpxsee")
|
||||
#endif
|
||||
#define POI_DIR APP_DIR"/POI"
|
||||
#define TILES_DIR APP_DIR"/tiles"
|
||||
#define MAP_LIST_FILE APP_DIR"/maps.txt"
|
||||
|
||||
#define USER_MAP_FILE USER_DIR + QString("/") + MAP_FILE
|
||||
#define USER_POI_DIR USER_DIR + QString("/") + POI_DIR
|
||||
#define GLOBAL_MAP_FILE GLOBAL_DIR + QString("/") + MAP_FILE
|
||||
#define GLOBAL_POI_DIR GLOBAL_DIR + QString("/") + POI_DIR
|
||||
#define TILES_DIR USER_DIR + QString("/tiles")
|
||||
|
||||
#endif /* CONFIG_H */
|
||||
|
@ -11,11 +11,12 @@ ElevationGraph::ElevationGraph(QWidget *parent) : GraphView(parent)
|
||||
_max = -FLT_MAX;
|
||||
_min = FLT_MAX;
|
||||
|
||||
GraphView::setXLabel(tr("Distance"));
|
||||
GraphView::setYLabel(tr("Elevation"));
|
||||
GraphView::setXUnits(tr("km"));
|
||||
GraphView::setYUnits(tr("m"));
|
||||
GraphView::setXScale(M2KM);
|
||||
setXLabel(tr("Distance"));
|
||||
setYLabel(tr("Elevation"));
|
||||
setXUnits(tr("km"));
|
||||
setYUnits(tr("m"));
|
||||
setXScale(M2KM);
|
||||
setMinRange(50.0);
|
||||
}
|
||||
|
||||
void ElevationGraph::addInfo()
|
||||
@ -37,14 +38,16 @@ void ElevationGraph::loadGPX(const GPX &gpx)
|
||||
qreal min, max, ascent = 0, descent = 0;
|
||||
|
||||
gpx.track(i).elevationGraph(data);
|
||||
if (data.isEmpty())
|
||||
return;
|
||||
if (data.count() < 2) {
|
||||
skipColor();
|
||||
continue;
|
||||
}
|
||||
|
||||
min = max = data.at(0).y();
|
||||
|
||||
for (int i = 1; i < data.size(); i++) {
|
||||
qreal cur = data.at(i).y();
|
||||
qreal prev = data.at(i-1).y();
|
||||
for (int j = 1; j < data.size(); j++) {
|
||||
qreal cur = data.at(j).y();
|
||||
qreal prev = data.at(j-1).y();
|
||||
|
||||
if (cur > prev)
|
||||
ascent += cur - prev;
|
||||
@ -80,15 +83,15 @@ void ElevationGraph::clear()
|
||||
void ElevationGraph::setUnits(enum Units units)
|
||||
{
|
||||
if (units == Metric) {
|
||||
GraphView::setXUnits(tr("km"));
|
||||
GraphView::setYUnits(tr("m"));
|
||||
GraphView::setXScale(M2KM);
|
||||
GraphView::setYScale(1);
|
||||
setXUnits(tr("km"));
|
||||
setYUnits(tr("m"));
|
||||
setXScale(M2KM);
|
||||
setYScale(1);
|
||||
} else {
|
||||
GraphView::setXUnits(tr("mi"));
|
||||
GraphView::setYUnits(tr("ft"));
|
||||
GraphView::setXScale(M2MI);
|
||||
GraphView::setYScale(M2FT);
|
||||
setXUnits(tr("mi"));
|
||||
setYUnits(tr("ft"));
|
||||
setXScale(M2MI);
|
||||
setYScale(M2FT);
|
||||
}
|
||||
|
||||
clearInfo();
|
||||
|
@ -41,12 +41,12 @@ void FileBrowser::setFilter(const QStringList &filter)
|
||||
reloadDirectory(_files.last().canonicalPath());
|
||||
}
|
||||
|
||||
bool FileBrowser::isLast()
|
||||
bool FileBrowser::isLast() const
|
||||
{
|
||||
return (_files.size() > 0 && _index == _files.size() - 1);
|
||||
}
|
||||
|
||||
bool FileBrowser::isFirst()
|
||||
bool FileBrowser::isFirst() const
|
||||
{
|
||||
return (_files.size() > 0 && _index == 0);
|
||||
}
|
||||
|
@ -23,8 +23,8 @@ public:
|
||||
QString last();
|
||||
QString first();
|
||||
|
||||
bool isLast();
|
||||
bool isFirst();
|
||||
bool isLast() const;
|
||||
bool isFirst() const;
|
||||
|
||||
private slots:
|
||||
void reloadDirectory(const QString &path);
|
||||
|
@ -12,22 +12,22 @@
|
||||
class GPX
|
||||
{
|
||||
public:
|
||||
GPX() : _parser(_tracks, _waypoints) {}
|
||||
GPX() : _parser(_tracks, _waypoints), _errorLine(0) {}
|
||||
bool loadFile(const QString &fileName);
|
||||
const QString &errorString() const {return _error;}
|
||||
int errorLine() const {return _errorLine;}
|
||||
|
||||
int trackCount() const {return _tracks.count();}
|
||||
Track track(int i) const {return Track(_tracks.at(i));}
|
||||
const QList<WayPoint> &waypoints() const {return _waypoints;}
|
||||
const QList<Waypoint> &waypoints() const {return _waypoints;}
|
||||
|
||||
private:
|
||||
Parser _parser;
|
||||
QString _error;
|
||||
int _errorLine;
|
||||
|
||||
QList<QVector<TrackPoint> > _tracks;
|
||||
QList<WayPoint> _waypoints;
|
||||
QList<QVector<Trackpoint> > _tracks;
|
||||
QList<Waypoint> _waypoints;
|
||||
};
|
||||
|
||||
#endif // GPX_H
|
||||
|
@ -53,6 +53,7 @@ GraphView::GraphView(QWidget *parent)
|
||||
_yScale = 1;
|
||||
|
||||
_precision = 0;
|
||||
_minRange = 0.01;
|
||||
}
|
||||
|
||||
GraphView::~GraphView()
|
||||
@ -131,7 +132,6 @@ void GraphView::loadData(const QVector<QPointF> &data)
|
||||
{
|
||||
QPainterPath path;
|
||||
QGraphicsPathItem *pi;
|
||||
QColor color = _colorShop.color();
|
||||
|
||||
|
||||
if (data.size() < 2)
|
||||
@ -140,12 +140,13 @@ void GraphView::loadData(const QVector<QPointF> &data)
|
||||
updateBounds(data.at(0));
|
||||
path.moveTo(data.at(0).x(), -data.at(0).y());
|
||||
for (int i = 1; i < data.size(); i++) {
|
||||
path.lineTo(data.at(i).x(), -data.at(i).y());
|
||||
updateBounds(data.at(i));
|
||||
const QPointF &p = data.at(i);
|
||||
path.lineTo(p.x(), -p.y());
|
||||
updateBounds(p);
|
||||
}
|
||||
|
||||
pi = new QGraphicsPathItem(path);
|
||||
QBrush brush(color, Qt::SolidPattern);
|
||||
QBrush brush(_palette.color(), Qt::SolidPattern);
|
||||
QPen pen(brush, 0);
|
||||
pi->setPen(pen);
|
||||
_scene->addItem(pi);
|
||||
@ -160,15 +161,16 @@ void GraphView::loadData(const QVector<QPointF> &data)
|
||||
void GraphView::redraw()
|
||||
{
|
||||
if (!_graphs.isEmpty())
|
||||
resize(viewport()->size() - QSizeF(MARGIN, MARGIN));
|
||||
redraw(viewport()->size() - QSizeF(MARGIN, MARGIN));
|
||||
}
|
||||
|
||||
void GraphView::resize(const QSizeF &size)
|
||||
void GraphView::redraw(const QSizeF &size)
|
||||
{
|
||||
QRectF r;
|
||||
QSizeF mx, my;
|
||||
QPointF rx, ry;
|
||||
QTransform transform;
|
||||
qreal xs, ys;
|
||||
qreal xs, ys, diff;
|
||||
|
||||
|
||||
if (_xAxis->scene() == _scene)
|
||||
@ -183,11 +185,21 @@ void GraphView::resize(const QSizeF &size)
|
||||
for (int i = 0; i < _graphs.size(); i++)
|
||||
_graphs.at(i)->resetTransform();
|
||||
|
||||
_xAxis->setRange(QPointF(_xMin * _xScale, _xMax * _xScale));
|
||||
_yAxis->setRange(QPointF(_yMin * _yScale, _yMax * _yScale));
|
||||
rx = QPointF(_xMin * _xScale, _xMax * _xScale);
|
||||
ry = QPointF(_yMin * _yScale, _yMax * _yScale);
|
||||
if ((diff = ry.y() - ry.x()) < _minRange)
|
||||
ry = QPointF(ry.x() - (_minRange/2 - diff/2),
|
||||
ry.y() + (_minRange/2 - diff/2));
|
||||
_xAxis->setRange(rx);
|
||||
_yAxis->setRange(ry);
|
||||
mx = _xAxis->margin();
|
||||
my = _yAxis->margin();
|
||||
|
||||
r = _scene->itemsBoundingRect();
|
||||
if (r.height() < _minRange)
|
||||
r.adjust(0, -(_minRange/2 - r.height()/2), 0,
|
||||
_minRange/2 - r.height()/2);
|
||||
|
||||
xs = (size.width() - (my.width() + mx.width())) / r.width();
|
||||
ys = (size.height() - (mx.height() + my.height())
|
||||
- _info->boundingRect().height()) / r.height();
|
||||
@ -197,6 +209,10 @@ void GraphView::resize(const QSizeF &size)
|
||||
_graphs.at(i)->setTransform(transform);
|
||||
|
||||
r = _scene->itemsBoundingRect();
|
||||
if (r.height() < _minRange * ys)
|
||||
r.adjust(0, -(_minRange/2 * ys - r.height()/2), 0,
|
||||
(_minRange/2) * ys - r.height()/2);
|
||||
|
||||
_xAxis->setSize(r.width());
|
||||
_yAxis->setSize(r.height());
|
||||
_xAxis->setPos(r.bottomLeft());
|
||||
@ -204,6 +220,7 @@ void GraphView::resize(const QSizeF &size)
|
||||
_scene->addItem(_xAxis);
|
||||
_scene->addItem(_yAxis);
|
||||
|
||||
|
||||
qreal sp = (_slider->pos().x() == _slider->area().left())
|
||||
? 0 : (_slider->pos().x() - _slider->area().left())
|
||||
/ _slider->area().width();
|
||||
@ -235,13 +252,13 @@ void GraphView::plot(QPainter *painter, const QRectF &target)
|
||||
QSizeF orig = _scene->sceneRect().size();
|
||||
QSizeF canvas = QSizeF(orig.height() * ratio, orig.height());
|
||||
|
||||
resize(canvas);
|
||||
redraw(canvas);
|
||||
_slider->hide();
|
||||
_info->hide();
|
||||
_scene->render(painter, target, QRectF());
|
||||
_slider->show();
|
||||
_info->show();
|
||||
resize(orig);
|
||||
redraw(orig);
|
||||
}
|
||||
|
||||
void GraphView::clear()
|
||||
@ -262,7 +279,7 @@ void GraphView::clear()
|
||||
_info->clear();
|
||||
_scene->clear();
|
||||
_graphs.clear();
|
||||
_colorShop.reset();
|
||||
_palette.reset();
|
||||
|
||||
_xMax = -FLT_MAX;
|
||||
_xMin = FLT_MAX;
|
||||
@ -272,36 +289,86 @@ void GraphView::clear()
|
||||
_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;
|
||||
|
||||
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) {
|
||||
Q_ASSERT(mid >= 0 && mid+1 < path.elementCount());
|
||||
l = QLineF(path.elementAt(mid).x, path.elementAt(mid).y,
|
||||
path.elementAt(mid+1).x, path.elementAt(mid+1).y);
|
||||
} else {
|
||||
Q_ASSERT(mid-1 >= 0 && mid < path.elementCount());
|
||||
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::emitSliderPositionChanged(const QPointF &pos)
|
||||
{
|
||||
if (_graphs.isEmpty())
|
||||
return;
|
||||
|
||||
qreal val = pos.x() / _slider->area().width();
|
||||
emit sliderPositionChanged(val);
|
||||
emit sliderPositionChanged(val * (_xMax - _xMin));
|
||||
|
||||
if (!_sliderInfo->isVisible())
|
||||
return;
|
||||
|
||||
const QPainterPath &path = _graphs.at(0)->path();
|
||||
QPointF p = path.pointAtPercent(val);
|
||||
qreal r = (p.y() - path.boundingRect().bottom())
|
||||
/ path.boundingRect().height();
|
||||
QRectF br = path.boundingRect();
|
||||
if (br.height() < _minRange)
|
||||
br.adjust(0, -(_minRange/2 - br.height()/2), 0,
|
||||
_minRange/2 - br.height()/2);
|
||||
|
||||
qreal y = yAtX(path, val * (_xMax - _xMin));
|
||||
qreal r = (y - br.bottom()) / br.height();
|
||||
_sliderInfo->setPos(QPointF(0, _slider->boundingRect().height() * r));
|
||||
_sliderInfo->setText(QString::number(-p.y() * _yScale, 'f', _precision));
|
||||
_sliderInfo->setText(QString::number(-y * _yScale, 'f', _precision));
|
||||
}
|
||||
|
||||
qreal GraphView::sliderPosition() const
|
||||
{
|
||||
return _slider->pos().x() / _slider->area().width();
|
||||
if (!_slider->isVisible())
|
||||
return -1;
|
||||
else
|
||||
return (_slider->pos().x() / _slider->area().width()) * (_xMax - _xMin);
|
||||
}
|
||||
|
||||
void GraphView::setSliderPosition(qreal pos)
|
||||
{
|
||||
_slider->setPos(pos * _slider->area().width(), 0);
|
||||
if (_graphs.isEmpty())
|
||||
return;
|
||||
|
||||
if (pos > (_xMax - _xMin))
|
||||
_slider->setVisible(false);
|
||||
else {
|
||||
_slider->setPos((pos / (_xMax - _xMin)) * _slider->area().width(), 0);
|
||||
_slider->setVisible(true);
|
||||
}
|
||||
}
|
||||
|
||||
void GraphView::newSliderPosition(const QPointF &pos)
|
||||
{
|
||||
if (_slider->area().contains(pos)) {
|
||||
_slider->setPos(pos);
|
||||
_slider->setVisible(true);
|
||||
emitSliderPositionChanged(pos);
|
||||
}
|
||||
}
|
||||
|
@ -6,7 +6,7 @@
|
||||
#include <QVector>
|
||||
#include <QList>
|
||||
#include <QPointF>
|
||||
#include "colorshop.h"
|
||||
#include "palette.h"
|
||||
|
||||
|
||||
class AxisItem;
|
||||
@ -41,9 +41,8 @@ public:
|
||||
void setYUnits(const QString &units);
|
||||
void setXScale(qreal scale);
|
||||
void setYScale(qreal scale);
|
||||
void setPrecision(int p) {_precision = p;}
|
||||
|
||||
void redraw();
|
||||
void setPrecision(int precision) {_precision = precision;}
|
||||
void setMinRange(qreal range) {_minRange = range;}
|
||||
|
||||
void plot(QPainter *painter, const QRectF &target);
|
||||
void clear();
|
||||
@ -51,19 +50,23 @@ public:
|
||||
qreal sliderPosition() const;
|
||||
void setSliderPosition(qreal pos);
|
||||
|
||||
void addInfo(const QString &key, const QString &value);
|
||||
void clearInfo();
|
||||
int count() const {return _graphs.count();}
|
||||
|
||||
signals:
|
||||
void sliderPositionChanged(qreal);
|
||||
|
||||
protected:
|
||||
void resizeEvent(QResizeEvent *);
|
||||
void redraw();
|
||||
void addInfo(const QString &key, const QString &value);
|
||||
void clearInfo();
|
||||
void skipColor() {_palette.color();}
|
||||
|
||||
qreal _xScale, _yScale;
|
||||
QString _xUnits, _yUnits;
|
||||
QString _xLabel, _yLabel;
|
||||
int _precision;
|
||||
qreal _minRange;
|
||||
|
||||
private slots:
|
||||
void emitSliderPositionChanged(const QPointF &pos);
|
||||
@ -73,7 +76,7 @@ private:
|
||||
void createXLabel();
|
||||
void createYLabel();
|
||||
void updateBounds(const QPointF &point);
|
||||
void resize(const QSizeF &size);
|
||||
void redraw(const QSizeF &size);
|
||||
|
||||
Scene *_scene;
|
||||
|
||||
@ -84,7 +87,7 @@ private:
|
||||
|
||||
QList<QGraphicsPathItem*> _graphs;
|
||||
qreal _xMin, _xMax, _yMin, _yMax;
|
||||
ColorShop _colorShop;
|
||||
Palette _palette;
|
||||
};
|
||||
|
||||
#endif // GRAPHVIEW_H
|
||||
|
264
src/gui.cpp
264
src/gui.cpp
@ -8,6 +8,12 @@
|
||||
#include <QPainter>
|
||||
#include <QKeyEvent>
|
||||
#include <QSignalMapper>
|
||||
#include <QMenu>
|
||||
#include <QToolBar>
|
||||
#include <QTabWidget>
|
||||
#include <QActionGroup>
|
||||
#include <QAction>
|
||||
#include <QLabel>
|
||||
#include "config.h"
|
||||
#include "icons.h"
|
||||
#include "keys.h"
|
||||
@ -16,12 +22,20 @@
|
||||
#include "maplist.h"
|
||||
#include "elevationgraph.h"
|
||||
#include "speedgraph.h"
|
||||
#include "heartrategraph.h"
|
||||
#include "trackview.h"
|
||||
#include "infoitem.h"
|
||||
#include "filebrowser.h"
|
||||
#include "gui.h"
|
||||
|
||||
|
||||
#define ARRAY_SIZE(a) (sizeof(a)/sizeof(a[0]))
|
||||
|
||||
struct GraphTab {
|
||||
GraphView *view;
|
||||
QString label;
|
||||
};
|
||||
|
||||
static QString timeSpan(qreal time)
|
||||
{
|
||||
unsigned h, m, s;
|
||||
@ -37,7 +51,8 @@ static QString timeSpan(qreal time)
|
||||
|
||||
GUI::GUI(QWidget *parent) : QMainWindow(parent)
|
||||
{
|
||||
loadFiles();
|
||||
loadMaps();
|
||||
loadPOIs();
|
||||
|
||||
createActions();
|
||||
createMenus();
|
||||
@ -50,6 +65,8 @@ GUI::GUI(QWidget *parent) : QMainWindow(parent)
|
||||
SLOT(movePositionMarker(qreal)));
|
||||
connect(_speedGraph, SIGNAL(sliderPositionChanged(qreal)), _track,
|
||||
SLOT(movePositionMarker(qreal)));
|
||||
connect(_heartRateGraph, SIGNAL(sliderPositionChanged(qreal)), _track,
|
||||
SLOT(movePositionMarker(qreal)));
|
||||
|
||||
_browser = new FileBrowser(this);
|
||||
_browser->setFilter(QStringList("*.gpx"));
|
||||
@ -69,19 +86,33 @@ GUI::GUI(QWidget *parent) : QMainWindow(parent)
|
||||
_time = 0;
|
||||
_trackCount = 0;
|
||||
|
||||
_lastGraph = 0;
|
||||
_lastSliderPos = -1.0;
|
||||
updateGraphTabs();
|
||||
updateTrackView();
|
||||
|
||||
resize(600, 800);
|
||||
}
|
||||
|
||||
void GUI::loadFiles()
|
||||
void GUI::loadMaps()
|
||||
{
|
||||
// Maps
|
||||
_maps = MapList::load(this, QString("%1/" MAP_LIST_FILE)
|
||||
.arg(QDir::homePath()));
|
||||
_maps += MapList::load(this, ":/maps.txt");
|
||||
if (QFile::exists(USER_MAP_FILE))
|
||||
_maps = MapList::load(this, USER_MAP_FILE);
|
||||
else
|
||||
_maps = MapList::load(this, GLOBAL_MAP_FILE);
|
||||
}
|
||||
|
||||
void GUI::loadPOIs()
|
||||
{
|
||||
QFileInfoList list;
|
||||
QDir userDir(USER_POI_DIR);
|
||||
QDir globalDir(GLOBAL_POI_DIR);
|
||||
|
||||
if (userDir.exists())
|
||||
list = userDir.entryInfoList(QStringList(), QDir::Files);
|
||||
else
|
||||
list = globalDir.entryInfoList(QStringList(), QDir::Files);
|
||||
|
||||
// POI files
|
||||
QDir dir(QString("%1/" POI_DIR).arg(QDir::homePath()));
|
||||
QFileInfoList list = dir.entryInfoList(QStringList(), QDir::Files);
|
||||
for (int i = 0; i < list.size(); ++i)
|
||||
_poi.loadFile(list.at(i).absoluteFilePath());
|
||||
}
|
||||
@ -110,6 +141,31 @@ void GUI::createMapActions()
|
||||
_currentMap = _maps.at(0);
|
||||
}
|
||||
|
||||
void GUI::createPOIFilesActions()
|
||||
{
|
||||
_poiFilesSM = new QSignalMapper(this);
|
||||
|
||||
for (int i = 0; i < _poi.files().count(); i++)
|
||||
createPOIFileAction(i);
|
||||
|
||||
connect(_poiFilesSM, SIGNAL(mapped(int)), this, SLOT(poiFileChecked(int)));
|
||||
}
|
||||
|
||||
QAction *GUI::createPOIFileAction(int index)
|
||||
{
|
||||
QAction *a = new QAction(QFileInfo(_poi.files().at(index)).fileName(),
|
||||
this);
|
||||
a->setCheckable(true);
|
||||
a->setChecked(true);
|
||||
|
||||
_poiFilesSM->setMapping(a, index);
|
||||
connect(a, SIGNAL(triggered()), _poiFilesSM, SLOT(map()));
|
||||
|
||||
_poiFilesActions.append(a);
|
||||
|
||||
return a;
|
||||
}
|
||||
|
||||
void GUI::createActions()
|
||||
{
|
||||
// Action Groups
|
||||
@ -155,7 +211,7 @@ void GUI::createActions()
|
||||
tr("Close"), this);
|
||||
_closeFileAction->setShortcut(QKeySequence::Close);
|
||||
_closeFileAction->setActionGroup(_fileActionGroup);
|
||||
connect(_closeFileAction, SIGNAL(triggered()), this, SLOT(closeFile()));
|
||||
connect(_closeFileAction, SIGNAL(triggered()), this, SLOT(closeAll()));
|
||||
_reloadFileAction = new QAction(QIcon(QPixmap(RELOAD_FILE_ICON)),
|
||||
tr("Reload"), this);
|
||||
_reloadFileAction->setShortcut(QKeySequence::Refresh);
|
||||
@ -166,11 +222,15 @@ void GUI::createActions()
|
||||
_openPOIAction = new QAction(QIcon(QPixmap(OPEN_FILE_ICON)),
|
||||
tr("Load POI file"), this);
|
||||
connect(_openPOIAction, SIGNAL(triggered()), this, SLOT(openPOIFile()));
|
||||
_closePOIAction = new QAction(QIcon(QPixmap(CLOSE_FILE_ICON)),
|
||||
tr("Close POI files"), this);
|
||||
connect(_closePOIAction, SIGNAL(triggered()), this, SLOT(closePOIFiles()));
|
||||
_showPOIAction = new QAction(QIcon(QPixmap(SHOW_POI_ICON)),
|
||||
tr("Show POIs"), this);
|
||||
_showPOIAction->setCheckable(true);
|
||||
_showPOIAction->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_P));
|
||||
connect(_showPOIAction, SIGNAL(triggered(bool)), this, SLOT(showPOI(bool)));
|
||||
createPOIFilesActions();
|
||||
|
||||
// Map actions
|
||||
_showMapAction = new QAction(QIcon(QPixmap(SHOW_MAP_ICON)), tr("Show map"),
|
||||
@ -250,7 +310,12 @@ void GUI::createMenus()
|
||||
_mapMenu->addAction(_showMapAction);
|
||||
|
||||
_poiMenu = menuBar()->addMenu(tr("POI"));
|
||||
_poiFilesMenu = _poiMenu->addMenu(tr("POI files"));
|
||||
_poiFilesMenu->addActions(_poiFilesActions);
|
||||
_poiMenu->addSeparator();
|
||||
_poiMenu->addAction(_openPOIAction);
|
||||
_poiMenu->addAction(_closePOIAction);
|
||||
_poiMenu->addSeparator();
|
||||
_poiMenu->addAction(_showPOIAction);
|
||||
|
||||
_settingsMenu = menuBar()->addMenu(tr("Settings"));
|
||||
@ -309,10 +374,9 @@ void GUI::createTrackGraphs()
|
||||
{
|
||||
_elevationGraph = new ElevationGraph;
|
||||
_speedGraph = new SpeedGraph;
|
||||
_heartRateGraph = new HeartRateGraph;
|
||||
|
||||
_trackGraphs = new QTabWidget;
|
||||
_trackGraphs->addTab(_elevationGraph, tr("Elevation"));
|
||||
_trackGraphs->addTab(_speedGraph, tr("Speed"));
|
||||
connect(_trackGraphs, SIGNAL(currentChanged(int)), this,
|
||||
SLOT(graphChanged(int)));
|
||||
|
||||
@ -333,6 +397,8 @@ void GUI::createStatusBar()
|
||||
statusBar()->addPermanentWidget(_distanceLabel, 1);
|
||||
statusBar()->addPermanentWidget(_timeLabel, 1);
|
||||
statusBar()->setSizeGripEnabled(false);
|
||||
|
||||
updateStatusBarInfo();
|
||||
}
|
||||
|
||||
void GUI::about()
|
||||
@ -383,8 +449,7 @@ void GUI::dataSources()
|
||||
QString("<h4>") + tr("Map sources") + QString("</h4><p>")
|
||||
+ tr("Map (tiles) source URLs are read on program startup from the "
|
||||
"following file:")
|
||||
+ QString("</p><p><code>") + QDir::homePath()
|
||||
+ QString("/" MAP_LIST_FILE "</code></p><p>")
|
||||
+ QString("</p><p><code>") + USER_MAP_FILE + QString("</code></p><p>")
|
||||
+ tr("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 "
|
||||
@ -395,8 +460,7 @@ void GUI::dataSources()
|
||||
+ QString("<h4>") + tr("POIs") + QString("</h4><p>")
|
||||
+ tr("To make GPXSee load a POI file automatically on startup, add "
|
||||
"the file to the following directory:")
|
||||
+ QString("</p><p><code>") + QDir::homePath()
|
||||
+ QString("/" POI_DIR "</code></p>")
|
||||
+ QString("</p><p><code>") + USER_POI_DIR + QString("</code></p>")
|
||||
);
|
||||
|
||||
msgBox.exec();
|
||||
@ -414,21 +478,27 @@ void GUI::openFile()
|
||||
|
||||
bool GUI::openFile(const QString &fileName)
|
||||
{
|
||||
bool ret = true;
|
||||
|
||||
if (fileName.isEmpty() || _files.contains(fileName))
|
||||
return false;
|
||||
|
||||
if (loadFile(fileName)) {
|
||||
_files.append(fileName);
|
||||
_browser->setCurrent(fileName);
|
||||
updateStatusBarInfo();
|
||||
_fileActionGroup->setEnabled(true);
|
||||
_navigationActionGroup->setEnabled(true);
|
||||
updateNavigationActions();
|
||||
return true;
|
||||
} else {
|
||||
updateNavigationActions();
|
||||
return false;
|
||||
_fileActionGroup->setEnabled(false);
|
||||
ret = false;
|
||||
}
|
||||
|
||||
updateNavigationActions();
|
||||
updateStatusBarInfo();
|
||||
updateGraphTabs();
|
||||
updateTrackView();
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
bool GUI::loadFile(const QString &fileName)
|
||||
@ -438,6 +508,9 @@ bool GUI::loadFile(const QString &fileName)
|
||||
if (gpx.loadFile(fileName)) {
|
||||
_elevationGraph->loadGPX(gpx);
|
||||
_speedGraph->loadGPX(gpx);
|
||||
_heartRateGraph->loadGPX(gpx);
|
||||
updateGraphTabs();
|
||||
_track->setHidden(false);
|
||||
_track->loadGPX(gpx);
|
||||
if (_showPOIAction->isChecked())
|
||||
_track->loadPOI(_poi);
|
||||
@ -464,23 +537,50 @@ bool GUI::loadFile(const QString &fileName)
|
||||
|
||||
void GUI::openPOIFile()
|
||||
{
|
||||
QString fileName = QFileDialog::getOpenFileName(this, tr("Open POI file"),
|
||||
QStringList files = QFileDialog::getOpenFileNames(this, tr("Open POI file"),
|
||||
QString(), tr("GPX files (*.gpx);;CSV files (*.csv);;All files (*)"));
|
||||
QStringList list = files;
|
||||
|
||||
if (!fileName.isEmpty()) {
|
||||
if (!_poi.loadFile(fileName)) {
|
||||
QString error = tr("Error loading POI file:\n%1")
|
||||
.arg(_poi.errorString()) + QString("\n");
|
||||
if (_poi.errorLine())
|
||||
error.append(tr("Line: %1").arg(_poi.errorLine()));
|
||||
QMessageBox::critical(this, tr("Error"), error);
|
||||
} else {
|
||||
_showPOIAction->setChecked(true);
|
||||
_track->loadPOI(_poi);
|
||||
}
|
||||
for (QStringList::Iterator it = list.begin(); it != list.end(); it++)
|
||||
openPOIFile(*it);
|
||||
}
|
||||
|
||||
bool GUI::openPOIFile(const QString &fileName)
|
||||
{
|
||||
if (fileName.isEmpty())
|
||||
return false;
|
||||
|
||||
if (!_poi.loadFile(fileName)) {
|
||||
QString error = tr("Error loading POI file:\n%1")
|
||||
.arg(_poi.errorString()) + QString("\n");
|
||||
if (_poi.errorLine())
|
||||
error.append(tr("Line: %1").arg(_poi.errorLine()));
|
||||
QMessageBox::critical(this, tr("Error"), error);
|
||||
|
||||
return false;
|
||||
} else {
|
||||
_showPOIAction->setChecked(true);
|
||||
_track->loadPOI(_poi);
|
||||
_poiFilesMenu->addAction(createPOIFileAction(
|
||||
_poi.files().indexOf(fileName)));
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
void GUI::closePOIFiles()
|
||||
{
|
||||
_poiFilesMenu->clear();
|
||||
|
||||
for (int i = 0; i < _poiFilesActions.count(); i++)
|
||||
delete _poiFilesActions[i];
|
||||
_poiFilesActions.clear();
|
||||
|
||||
_track->clearPOI();
|
||||
|
||||
_poi.clear();
|
||||
}
|
||||
|
||||
void GUI::saveAs()
|
||||
{
|
||||
QString fileName = QFileDialog::getSaveFileName(this, "Export to PDF",
|
||||
@ -544,17 +644,17 @@ void GUI::saveFile(const QString &fileName)
|
||||
}
|
||||
scene.addItem(&info);
|
||||
scene.render(&p, QRectF(0, 0, printer.width(), 200));
|
||||
|
||||
p.end();
|
||||
}
|
||||
|
||||
void GUI::reloadFile()
|
||||
{
|
||||
_distance = 0;
|
||||
_time = 0;
|
||||
_trackCount = 0;
|
||||
|
||||
_elevationGraph->clear();
|
||||
_speedGraph->clear();
|
||||
_heartRateGraph->clear();
|
||||
_track->clear();
|
||||
|
||||
for (int i = 0; i < _files.size(); i++) {
|
||||
@ -565,13 +665,15 @@ void GUI::reloadFile()
|
||||
}
|
||||
|
||||
updateStatusBarInfo();
|
||||
updateGraphTabs();
|
||||
updateTrackView();
|
||||
if (_files.isEmpty())
|
||||
_fileActionGroup->setEnabled(false);
|
||||
else
|
||||
_browser->setCurrent(_files.last());
|
||||
}
|
||||
|
||||
void GUI::closeFile()
|
||||
void GUI::closeFiles()
|
||||
{
|
||||
_distance = 0;
|
||||
_time = 0;
|
||||
@ -579,12 +681,20 @@ void GUI::closeFile()
|
||||
|
||||
_elevationGraph->clear();
|
||||
_speedGraph->clear();
|
||||
_heartRateGraph->clear();
|
||||
_track->clear();
|
||||
|
||||
_files.clear();
|
||||
}
|
||||
|
||||
void GUI::closeAll()
|
||||
{
|
||||
closeFiles();
|
||||
|
||||
_fileActionGroup->setEnabled(false);
|
||||
updateStatusBarInfo();
|
||||
updateGraphTabs();
|
||||
updateTrackView();
|
||||
}
|
||||
|
||||
void GUI::showPOI(bool checked)
|
||||
@ -627,7 +737,7 @@ void GUI::showToolbars(bool checked)
|
||||
void GUI::updateStatusBarInfo()
|
||||
{
|
||||
if (_files.count() == 0) {
|
||||
_fileNameLabel->clear();
|
||||
_fileNameLabel->setText(tr("No GPX files loaded"));
|
||||
_distanceLabel->clear();
|
||||
_timeLabel->clear();
|
||||
return;
|
||||
@ -638,10 +748,10 @@ void GUI::updateStatusBarInfo()
|
||||
|
||||
if (_imperialUnitsAction->isChecked())
|
||||
_distanceLabel->setText(QString::number(_distance * M2MI, 'f', 1)
|
||||
+ " " + tr("mi"));
|
||||
+ UNIT_SPACE + tr("mi"));
|
||||
else
|
||||
_distanceLabel->setText(QString::number(_distance * M2KM, 'f', 1)
|
||||
+ " " + tr("km"));
|
||||
+ UNIT_SPACE + tr("km"));
|
||||
_timeLabel->setText(timeSpan(_time));
|
||||
}
|
||||
|
||||
@ -653,12 +763,28 @@ void GUI::mapChanged(int index)
|
||||
_track->setMap(_currentMap);
|
||||
}
|
||||
|
||||
void GUI::poiFileChecked(int index)
|
||||
{
|
||||
_poi.enableFile(_poi.files().at(index),
|
||||
_poiFilesActions.at(index)->isChecked());
|
||||
|
||||
_track->clearPOI();
|
||||
if (_showPOIAction->isChecked())
|
||||
_track->loadPOI(_poi);
|
||||
}
|
||||
|
||||
void GUI::graphChanged(int index)
|
||||
{
|
||||
if (_trackGraphs->widget(index) == _elevationGraph)
|
||||
_elevationGraph->setSliderPosition(_speedGraph->sliderPosition());
|
||||
else if (_trackGraphs->widget(index) == _speedGraph)
|
||||
_speedGraph->setSliderPosition(_elevationGraph->sliderPosition());
|
||||
if (index < 0)
|
||||
return;
|
||||
|
||||
GraphView *tv = static_cast<GraphView*>(_trackGraphs->widget(index));
|
||||
if (_lastGraph) {
|
||||
if (_lastGraph->sliderPosition() >= 0)
|
||||
_lastSliderPos = _lastGraph->sliderPosition();
|
||||
tv->setSliderPosition(_lastSliderPos);
|
||||
}
|
||||
_lastGraph = tv;
|
||||
}
|
||||
|
||||
void GUI::updateNavigationActions()
|
||||
@ -680,11 +806,52 @@ void GUI::updateNavigationActions()
|
||||
}
|
||||
}
|
||||
|
||||
void GUI::updateGraphTabs()
|
||||
{
|
||||
struct GraphTab tabs[] = {
|
||||
{_elevationGraph, tr("Elevation")},
|
||||
{_speedGraph, tr("Speed")},
|
||||
{_heartRateGraph, tr("Heart rate")}
|
||||
};
|
||||
int index;
|
||||
GraphView *gv;
|
||||
|
||||
for (int i = 0; i < (int)ARRAY_SIZE(tabs); i++) {
|
||||
gv = tabs[i].view;
|
||||
if (!gv->count() && (index = _trackGraphs->indexOf(gv)) >= 0)
|
||||
_trackGraphs->removeTab(index);
|
||||
}
|
||||
|
||||
for (int i = 0; i < (int)ARRAY_SIZE(tabs); i++) {
|
||||
gv = tabs[i].view;
|
||||
if (gv->count() && _trackGraphs->indexOf(gv) < 0)
|
||||
_trackGraphs->insertTab(i, gv, tabs[i].label);
|
||||
}
|
||||
|
||||
for (int i = 0; i < (int)ARRAY_SIZE(tabs); i++) {
|
||||
if (tabs[i].view->count()) {
|
||||
if (_showGraphsAction->isChecked())
|
||||
_trackGraphs->setHidden(false);
|
||||
_showGraphsAction->setEnabled(true);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
_trackGraphs->setHidden(true);
|
||||
_showGraphsAction->setEnabled(false);
|
||||
}
|
||||
|
||||
void GUI::updateTrackView()
|
||||
{
|
||||
_track->setHidden(!(_track->trackCount() + _track->waypointCount()));
|
||||
}
|
||||
|
||||
void GUI::setMetricUnits()
|
||||
{
|
||||
_track->setUnits(Metric);
|
||||
_elevationGraph->setUnits(Metric);
|
||||
_speedGraph->setUnits(Metric);
|
||||
_heartRateGraph->setUnits(Metric);
|
||||
updateStatusBarInfo();
|
||||
}
|
||||
|
||||
@ -693,6 +860,7 @@ void GUI::setImperialUnits()
|
||||
_track->setUnits(Imperial);
|
||||
_elevationGraph->setUnits(Imperial);
|
||||
_speedGraph->setUnits(Imperial);
|
||||
_heartRateGraph->setUnits(Imperial);
|
||||
updateStatusBarInfo();
|
||||
}
|
||||
|
||||
@ -702,7 +870,7 @@ void GUI::next()
|
||||
if (file.isNull())
|
||||
return;
|
||||
|
||||
closeFile();
|
||||
closeFiles();
|
||||
openFile(file);
|
||||
}
|
||||
|
||||
@ -712,7 +880,7 @@ void GUI::prev()
|
||||
if (file.isNull())
|
||||
return;
|
||||
|
||||
closeFile();
|
||||
closeFiles();
|
||||
openFile(file);
|
||||
}
|
||||
|
||||
@ -722,7 +890,7 @@ void GUI::last()
|
||||
if (file.isNull())
|
||||
return;
|
||||
|
||||
closeFile();
|
||||
closeFiles();
|
||||
openFile(file);
|
||||
}
|
||||
|
||||
@ -732,7 +900,7 @@ void GUI::first()
|
||||
if (file.isNull())
|
||||
return;
|
||||
|
||||
closeFile();
|
||||
closeFiles();
|
||||
openFile(file);
|
||||
}
|
||||
|
||||
@ -757,7 +925,7 @@ void GUI::keyPressEvent(QKeyEvent *event)
|
||||
|
||||
if (!file.isNull()) {
|
||||
if (!(event->modifiers() & MODIFIER))
|
||||
closeFile();
|
||||
closeFiles();
|
||||
openFile(file);
|
||||
}
|
||||
}
|
||||
|
41
src/gui.h
41
src/gui.h
@ -2,19 +2,22 @@
|
||||
#define GUI_H
|
||||
|
||||
#include <QMainWindow>
|
||||
#include <QMenu>
|
||||
#include <QToolBar>
|
||||
#include <QTabWidget>
|
||||
#include <QGraphicsView>
|
||||
#include <QActionGroup>
|
||||
#include <QAction>
|
||||
#include <QLabel>
|
||||
#include <QString>
|
||||
#include <QList>
|
||||
#include "poi.h"
|
||||
|
||||
|
||||
class QMenu;
|
||||
class QToolBar;
|
||||
class QTabWidget;
|
||||
class QActionGroup;
|
||||
class QAction;
|
||||
class QLabel;
|
||||
class QSignalMapper;
|
||||
class FileBrowser;
|
||||
class GraphView;
|
||||
class ElevationGraph;
|
||||
class SpeedGraph;
|
||||
class HeartRateGraph;
|
||||
class TrackView;
|
||||
class Map;
|
||||
|
||||
@ -34,9 +37,10 @@ private slots:
|
||||
void saveFile();
|
||||
void saveAs();
|
||||
void openFile();
|
||||
void closeFile();
|
||||
void closeAll();
|
||||
void reloadFile();
|
||||
void openPOIFile();
|
||||
void closePOIFiles();
|
||||
void showPOI(bool checked);
|
||||
void showMap(bool checked);
|
||||
void showGraphs(bool checked);
|
||||
@ -44,6 +48,7 @@ private slots:
|
||||
|
||||
void mapChanged(int);
|
||||
void graphChanged(int);
|
||||
void poiFileChecked(int);
|
||||
|
||||
void next();
|
||||
void prev();
|
||||
@ -54,8 +59,12 @@ private slots:
|
||||
void setImperialUnits();
|
||||
|
||||
private:
|
||||
void loadFiles();
|
||||
void loadMaps();
|
||||
void loadPOIs();
|
||||
void closeFiles();
|
||||
|
||||
QAction *createPOIFileAction(int index);
|
||||
void createPOIFilesActions();
|
||||
void createMapActions();
|
||||
void createActions();
|
||||
void createMenus();
|
||||
@ -64,10 +73,13 @@ private:
|
||||
void createTrackView();
|
||||
void createTrackGraphs();
|
||||
|
||||
bool openPOIFile(const QString &fileName);
|
||||
bool loadFile(const QString &fileName);
|
||||
void saveFile(const QString &fileName);
|
||||
void updateStatusBarInfo();
|
||||
void updateNavigationActions();
|
||||
void updateGraphTabs();
|
||||
void updateTrackView();
|
||||
|
||||
void keyPressEvent(QKeyEvent * event);
|
||||
|
||||
@ -77,6 +89,7 @@ private:
|
||||
QMenu *_mapMenu;
|
||||
QMenu *_settingsMenu;
|
||||
QMenu *_unitsMenu;
|
||||
QMenu *_poiFilesMenu;
|
||||
|
||||
QToolBar *_fileToolBar;
|
||||
QToolBar *_showToolBar;
|
||||
@ -96,6 +109,7 @@ private:
|
||||
QAction *_closeFileAction;
|
||||
QAction *_reloadFileAction;
|
||||
QAction *_openPOIAction;
|
||||
QAction *_closePOIAction;
|
||||
QAction *_showPOIAction;
|
||||
QAction *_showMapAction;
|
||||
QAction *_showGraphsAction;
|
||||
@ -107,6 +121,9 @@ private:
|
||||
QAction *_metricUnitsAction;
|
||||
QAction *_imperialUnitsAction;
|
||||
QList<QAction*> _mapActions;
|
||||
QList<QAction*> _poiFilesActions;
|
||||
|
||||
QSignalMapper *_poiFilesSM;
|
||||
|
||||
QLabel *_fileNameLabel;
|
||||
QLabel *_distanceLabel;
|
||||
@ -114,6 +131,7 @@ private:
|
||||
|
||||
ElevationGraph *_elevationGraph;
|
||||
SpeedGraph *_speedGraph;
|
||||
HeartRateGraph *_heartRateGraph;
|
||||
TrackView *_track;
|
||||
|
||||
POI _poi;
|
||||
@ -127,6 +145,9 @@ private:
|
||||
qreal _distance;
|
||||
qreal _time;
|
||||
int _trackCount;
|
||||
|
||||
GraphView *_lastGraph;
|
||||
qreal _lastSliderPos;
|
||||
};
|
||||
|
||||
#endif // GUI_H
|
||||
|
87
src/heartrategraph.cpp
Normal file
87
src/heartrategraph.cpp
Normal file
@ -0,0 +1,87 @@
|
||||
#include "gpx.h"
|
||||
#include "heartrategraph.h"
|
||||
|
||||
|
||||
HeartRateGraph::HeartRateGraph(QWidget *parent) : GraphView(parent)
|
||||
{
|
||||
_max = 0;
|
||||
|
||||
setXLabel(tr("Distance"));
|
||||
setYLabel(tr("Heart rate"));
|
||||
setXUnits(tr("km"));
|
||||
setYUnits(tr("1/min"));
|
||||
setXScale(M2KM);
|
||||
setPrecision(0);
|
||||
}
|
||||
|
||||
void HeartRateGraph::addInfo()
|
||||
{
|
||||
GraphView::addInfo(tr("Average"), QString::number(avg() * _yScale, 'f', 0)
|
||||
+ UNIT_SPACE + _yUnits);
|
||||
GraphView::addInfo(tr("Maximum"), QString::number(_max * _yScale, 'f', 0)
|
||||
+ UNIT_SPACE + _yUnits);
|
||||
}
|
||||
|
||||
void HeartRateGraph::loadGPX(const GPX &gpx)
|
||||
{
|
||||
for (int i = 0; i < gpx.trackCount(); i++) {
|
||||
QVector<QPointF> data;
|
||||
qreal max = 0, sum = 0, w = 0;
|
||||
|
||||
gpx.track(i).heartRateGraph(data);
|
||||
if (data.count() < 2) {
|
||||
skipColor();
|
||||
continue;
|
||||
}
|
||||
|
||||
for (int j = 1; j < data.size(); j++) {
|
||||
sum += data.at(j).y() * (data.at(j).x() - data.at(j-1).x());
|
||||
w += data.at(j).x() - data.at(j-1).x();
|
||||
}
|
||||
_avg.append(QPointF(gpx.track(i).distance(), sum/w));
|
||||
|
||||
for (int j = 0; j < data.size(); j++)
|
||||
max = qMax(max, data.at(j).y());
|
||||
_max = qMax(_max, max);
|
||||
|
||||
addInfo();
|
||||
loadData(data);
|
||||
}
|
||||
}
|
||||
|
||||
qreal HeartRateGraph::avg() const
|
||||
{
|
||||
qreal sum = 0, w = 0;
|
||||
QList<QPointF>::const_iterator it;
|
||||
|
||||
for (it = _avg.begin(); it != _avg.end(); it++) {
|
||||
sum += it->y() * it->x();
|
||||
w += it->x();
|
||||
}
|
||||
|
||||
return (sum / w);
|
||||
}
|
||||
|
||||
void HeartRateGraph::clear()
|
||||
{
|
||||
_max = 0;
|
||||
_avg.clear();
|
||||
|
||||
GraphView::clear();
|
||||
}
|
||||
|
||||
void HeartRateGraph::setUnits(enum Units units)
|
||||
{
|
||||
if (units == Metric) {
|
||||
setXUnits(tr("km"));
|
||||
setXScale(M2KM);
|
||||
} else {
|
||||
setXUnits(tr("mi"));
|
||||
setXScale(M2MI);
|
||||
}
|
||||
|
||||
clearInfo();
|
||||
addInfo();
|
||||
|
||||
redraw();
|
||||
}
|
30
src/heartrategraph.h
Normal file
30
src/heartrategraph.h
Normal file
@ -0,0 +1,30 @@
|
||||
#ifndef HEARTRATEGRAPH_H
|
||||
#define HEARTRATEGRAPH_H
|
||||
|
||||
#include "graphview.h"
|
||||
#include "units.h"
|
||||
|
||||
class GPX;
|
||||
|
||||
class HeartRateGraph : public GraphView
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
HeartRateGraph(QWidget *parent = 0);
|
||||
|
||||
void loadGPX(const GPX &gpx);
|
||||
void clear();
|
||||
void setUnits(enum Units units);
|
||||
|
||||
qreal avg() const;
|
||||
qreal max() const {return _max;}
|
||||
|
||||
private:
|
||||
void addInfo();
|
||||
|
||||
qreal _max;
|
||||
QList<QPointF> _avg;
|
||||
};
|
||||
|
||||
#endif // HEARTRATEGRAPH_H
|
@ -15,7 +15,7 @@ Map::Map(QObject *parent, const QString &name, const QString &url)
|
||||
connect(&Downloader::instance(), SIGNAL(finished()), this,
|
||||
SLOT(emitLoaded()));
|
||||
|
||||
QString path = QString(TILES_DIR"/") + _name;
|
||||
QString path = TILES_DIR + QString("/") + _name;
|
||||
if (!QDir::home().mkpath(path))
|
||||
fprintf(stderr, "Error creating tiles dir: %s\n", qPrintable(path));
|
||||
}
|
||||
@ -31,9 +31,8 @@ void Map::loadTiles(QList<Tile> &list)
|
||||
|
||||
for (int i = 0; i < list.size(); ++i) {
|
||||
Tile &t = list[i];
|
||||
QString file = QString("%1/" TILES_DIR "/%2/%3-%4-%5")
|
||||
.arg(QDir::homePath()).arg(_name).arg(t.zoom()).arg(t.xy().rx())
|
||||
.arg(t.xy().ry());
|
||||
QString file = TILES_DIR + QString("/%1/%2-%3-%4")
|
||||
.arg(_name).arg(t.zoom()).arg(t.xy().rx()).arg(t.xy().ry());
|
||||
QFileInfo fi(file);
|
||||
|
||||
if (fi.exists()) {
|
||||
|
@ -9,7 +9,7 @@ public:
|
||||
Tile(const QPoint &xy, int zoom)
|
||||
{_xy = xy; _zoom = zoom;}
|
||||
|
||||
int zoom() {return _zoom;}
|
||||
int zoom() const {return _zoom;}
|
||||
QPoint& xy() {return _xy;}
|
||||
QPixmap& pixmap() {return _pixmap;}
|
||||
|
||||
|
@ -19,10 +19,18 @@ void MarkerItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *option
|
||||
{
|
||||
Q_UNUSED(option);
|
||||
Q_UNUSED(widget);
|
||||
bool aa;
|
||||
|
||||
|
||||
if ((aa = painter->testRenderHint(QPainter::Antialiasing)))
|
||||
painter->setRenderHint(QPainter::Antialiasing, false);
|
||||
|
||||
painter->setPen(Qt::red);
|
||||
painter->drawLine(-SIZE/2, 0, SIZE/2, 0);
|
||||
painter->drawLine(0, -SIZE/2, 0, SIZE/2);
|
||||
|
||||
if (aa)
|
||||
painter->setRenderHint(QPainter::Antialiasing, true);
|
||||
|
||||
// painter->drawRect(boundingRect());
|
||||
}
|
||||
|
@ -1,4 +1,4 @@
|
||||
#include "colorshop.h"
|
||||
#include "palette.h"
|
||||
|
||||
|
||||
#define HUE_INIT 0.1f
|
||||
@ -43,12 +43,12 @@ static unsigned hsv2rgb(float h, float s, float v)
|
||||
+ (unsigned)(b * 256);
|
||||
}
|
||||
|
||||
ColorShop::ColorShop()
|
||||
Palette::Palette()
|
||||
{
|
||||
_hueState = HUE_INIT;
|
||||
}
|
||||
|
||||
QColor ColorShop::color()
|
||||
QColor Palette::color()
|
||||
{
|
||||
_hueState += HUE_INCREMENT;
|
||||
_hueState -= (int) _hueState;
|
||||
@ -56,7 +56,7 @@ QColor ColorShop::color()
|
||||
return QColor(hsv2rgb(_hueState, SATURATION, VALUE));
|
||||
}
|
||||
|
||||
void ColorShop::reset()
|
||||
void Palette::reset()
|
||||
{
|
||||
_hueState = HUE_INIT;
|
||||
}
|
@ -1,12 +1,12 @@
|
||||
#ifndef COLORSHOP_H
|
||||
#define COLORSHOP_H
|
||||
#ifndef PALETTE_H
|
||||
#define PALETTE_H
|
||||
|
||||
#include <QColor>
|
||||
|
||||
class ColorShop
|
||||
class Palette
|
||||
{
|
||||
public:
|
||||
ColorShop();
|
||||
Palette();
|
||||
QColor color();
|
||||
void reset();
|
||||
|
||||
@ -14,4 +14,4 @@ private:
|
||||
float _hueState;
|
||||
};
|
||||
|
||||
#endif // COLORSHOP_H
|
||||
#endif // PALLETE_H
|
@ -5,16 +5,18 @@ void Parser::handleExtensionData(QStringRef element, const QString &value)
|
||||
{
|
||||
if (element == "speed")
|
||||
_track->last().speed = value.toDouble();
|
||||
else if (element == "hr" || element == "heartrate")
|
||||
_track->last().heartRate = value.toDouble();
|
||||
}
|
||||
|
||||
void Parser::handleTrekPointData(QStringRef element, const QString &value)
|
||||
{
|
||||
if (element == "ele")
|
||||
_track->last().elevation = value.toLatin1().toDouble();
|
||||
if (element == "time")
|
||||
else if (element == "time")
|
||||
_track->last().timestamp = QDateTime::fromString(value.toLatin1(),
|
||||
Qt::ISODate);
|
||||
if (element == "geoidheight")
|
||||
else if (element == "geoidheight")
|
||||
_track->last().geoidheight = value.toLatin1().toDouble();
|
||||
}
|
||||
|
||||
@ -37,11 +39,24 @@ void Parser::handleWayPointAttributes(const QXmlStreamAttributes &attr)
|
||||
attr.value("lat").toLatin1().toDouble()));
|
||||
}
|
||||
|
||||
void Parser::tpExtension()
|
||||
{
|
||||
while (_reader.readNextStartElement()) {
|
||||
if (_reader.name() == "hr")
|
||||
handleExtensionData(_reader.name(), _reader.readElementText());
|
||||
else
|
||||
_reader.skipCurrentElement();
|
||||
}
|
||||
}
|
||||
|
||||
void Parser::extensions()
|
||||
{
|
||||
while (_reader.readNextStartElement()) {
|
||||
if (_reader.name() == "speed")
|
||||
if (_reader.name() == "speed" || _reader.name() == "hr"
|
||||
|| _reader.name() == "heartrate")
|
||||
handleExtensionData(_reader.name(), _reader.readElementText());
|
||||
else if (_reader.name() == "TrackPointExtension")
|
||||
tpExtension();
|
||||
else
|
||||
_reader.skipCurrentElement();
|
||||
}
|
||||
@ -64,7 +79,7 @@ void Parser::trackPoints()
|
||||
{
|
||||
while (_reader.readNextStartElement()) {
|
||||
if (_reader.name() == "trkpt") {
|
||||
_track->append(TrackPoint());
|
||||
_track->append(Trackpoint());
|
||||
handleTrekPointAttributes(_reader.attributes());
|
||||
trackPointData();
|
||||
} else
|
||||
@ -96,11 +111,11 @@ void Parser::gpx()
|
||||
{
|
||||
while (_reader.readNextStartElement()) {
|
||||
if (_reader.name() == "trk") {
|
||||
_tracks.append(QVector<TrackPoint>());
|
||||
_tracks.append(QVector<Trackpoint>());
|
||||
_track = &_tracks.back();
|
||||
track();
|
||||
} else if (_reader.name() == "wpt") {
|
||||
_waypoints.append(WayPoint());
|
||||
_waypoints.append(Waypoint());
|
||||
handleWayPointAttributes(_reader.attributes());
|
||||
wayPointData();
|
||||
} else
|
||||
|
@ -11,7 +11,7 @@
|
||||
class Parser
|
||||
{
|
||||
public:
|
||||
Parser(QList<QVector<TrackPoint> > &tracks, QList<WayPoint> &waypoints)
|
||||
Parser(QList<QVector<Trackpoint> > &tracks, QList<Waypoint> &waypoints)
|
||||
: _tracks(tracks), _waypoints(waypoints) {_track = 0;}
|
||||
bool loadFile(QIODevice *device);
|
||||
QString errorString() const {return _reader.errorString();}
|
||||
@ -22,6 +22,7 @@ private:
|
||||
void gpx();
|
||||
void track();
|
||||
void trackPoints();
|
||||
void tpExtension();
|
||||
void extensions();
|
||||
void trackPointData();
|
||||
void wayPointData();
|
||||
@ -33,9 +34,9 @@ private:
|
||||
void handleExtensionData(QStringRef element, const QString &value);
|
||||
|
||||
QXmlStreamReader _reader;
|
||||
QList<QVector<TrackPoint> > &_tracks;
|
||||
QList<WayPoint> &_waypoints;
|
||||
QVector<TrackPoint> *_track;
|
||||
QList<QVector<Trackpoint> > &_tracks;
|
||||
QList<Waypoint> &_waypoints;
|
||||
QVector<Trackpoint> *_track;
|
||||
};
|
||||
|
||||
#endif // PARSER_H
|
||||
|
80
src/poi.cpp
80
src/poi.cpp
@ -6,8 +6,6 @@
|
||||
#include "poi.h"
|
||||
|
||||
|
||||
#define BOUNDING_RECT_SIZE 0.01
|
||||
|
||||
bool POI::loadFile(const QString &fileName)
|
||||
{
|
||||
QString error;
|
||||
@ -41,21 +39,27 @@ bool POI::loadFile(const QString &fileName)
|
||||
bool POI::loadGPXFile(const QString &fileName)
|
||||
{
|
||||
GPX gpx;
|
||||
int cnt = _data.size();
|
||||
FileIndex index;
|
||||
|
||||
index.enabled = true;
|
||||
index.start = _data.size();
|
||||
|
||||
if (gpx.loadFile(fileName)) {
|
||||
for (int i = 0; i < gpx.waypoints().size(); i++)
|
||||
_data.append(WayPoint(
|
||||
ll2mercator(gpx.waypoints().at(i).coordinates()),
|
||||
gpx.waypoints().at(i).description()));
|
||||
_data.append(gpx.waypoints().at(i));
|
||||
index.end = _data.size() - 1;
|
||||
|
||||
for (int i = cnt; i < _data.size(); ++i) {
|
||||
for (int i = index.start; i <= index.end; i++) {
|
||||
const QPointF &p = _data.at(i).coordinates();
|
||||
qreal c[2];
|
||||
c[0] = _data.at(i).coordinates().x();
|
||||
c[1] = _data.at(i).coordinates().y();
|
||||
c[0] = p.x();
|
||||
c[1] = p.y();
|
||||
_tree.Insert(c, c, i);
|
||||
}
|
||||
|
||||
_files.append(fileName);
|
||||
_indexes.append(index);
|
||||
|
||||
return true;
|
||||
} else {
|
||||
_error = gpx.errorString();
|
||||
@ -68,8 +72,12 @@ bool POI::loadGPXFile(const QString &fileName)
|
||||
bool POI::loadCSVFile(const QString &fileName)
|
||||
{
|
||||
QFile file(fileName);
|
||||
FileIndex index;
|
||||
bool ret;
|
||||
int ln = 1, cnt = _data.size();
|
||||
int ln = 1;
|
||||
|
||||
index.enabled = true;
|
||||
index.start = _data.size();
|
||||
|
||||
if (!file.open(QFile::ReadOnly | QFile::Text)) {
|
||||
_error = qPrintable(file.errorString());
|
||||
@ -99,18 +107,23 @@ bool POI::loadCSVFile(const QString &fileName)
|
||||
}
|
||||
QByteArray ba = list[2].trimmed();
|
||||
|
||||
_data.append(WayPoint(ll2mercator(QPointF(lon, lat)),
|
||||
_data.append(Waypoint(QPointF(lon, lat),
|
||||
QString::fromUtf8(ba.data(), ba.size())));
|
||||
ln++;
|
||||
}
|
||||
index.end = _data.size() - 1;
|
||||
|
||||
for (int i = cnt; i < _data.size(); ++i) {
|
||||
for (int i = index.start; i <= index.end; i++) {
|
||||
const QPointF &p = _data.at(i).coordinates();
|
||||
qreal c[2];
|
||||
c[0] = _data.at(i).coordinates().x();
|
||||
c[1] = _data.at(i).coordinates().y();
|
||||
c[0] = p.x();
|
||||
c[1] = p.y();
|
||||
_tree.Insert(c, c, i);
|
||||
}
|
||||
|
||||
_files.append(fileName);
|
||||
_indexes.append(index);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -122,17 +135,18 @@ static bool cb(size_t data, void* context)
|
||||
return true;
|
||||
}
|
||||
|
||||
QVector<WayPoint> POI::points(const QVector<QPointF> &path) const
|
||||
QVector<Waypoint> POI::points(const QVector<QPointF> &path, qreal radius) const
|
||||
{
|
||||
QVector<WayPoint> ret;
|
||||
QVector<Waypoint> ret;
|
||||
QSet<int> set;
|
||||
qreal min[2], max[2];
|
||||
|
||||
for (int i = 0; i < path.count(); i++) {
|
||||
min[0] = path.at(i).x() - BOUNDING_RECT_SIZE;
|
||||
min[1] = path.at(i).y() - BOUNDING_RECT_SIZE;
|
||||
max[0] = path.at(i).x() + BOUNDING_RECT_SIZE;
|
||||
max[1] = path.at(i).y() + BOUNDING_RECT_SIZE;
|
||||
const QPointF &p = path.at(i);
|
||||
min[0] = p.x() - radius;
|
||||
min[1] = p.y() - radius;
|
||||
max[0] = p.x() + radius;
|
||||
max[1] = p.y() + radius;
|
||||
_tree.Search(min, max, cb, &set);
|
||||
}
|
||||
|
||||
@ -145,8 +159,34 @@ QVector<WayPoint> POI::points(const QVector<QPointF> &path) const
|
||||
return ret;
|
||||
}
|
||||
|
||||
void POI::enableFile(const QString &fileName, bool enable)
|
||||
{
|
||||
int i;
|
||||
|
||||
i = _files.indexOf(fileName);
|
||||
Q_ASSERT(i >= 0);
|
||||
_indexes[i].enabled = enable;
|
||||
|
||||
_tree.RemoveAll();
|
||||
for (int i = 0; i < _indexes.count(); i++) {
|
||||
FileIndex idx = _indexes.at(i);
|
||||
if (!idx.enabled)
|
||||
continue;
|
||||
|
||||
for (int j = idx.start; j <= idx.end; j++) {
|
||||
const QPointF &p = _data.at(j).coordinates();
|
||||
qreal c[2];
|
||||
c[0] = p.x();
|
||||
c[1] = p.y();
|
||||
_tree.Insert(c, c, j);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void POI::clear()
|
||||
{
|
||||
_tree.RemoveAll();
|
||||
_data.clear();
|
||||
_files.clear();
|
||||
_indexes.clear();
|
||||
}
|
||||
|
20
src/poi.h
20
src/poi.h
@ -4,6 +4,7 @@
|
||||
#include <QVector>
|
||||
#include <QPointF>
|
||||
#include <QString>
|
||||
#include <QStringList>
|
||||
#include "waypoint.h"
|
||||
#include "rtree.h"
|
||||
|
||||
@ -11,22 +12,33 @@
|
||||
class POI
|
||||
{
|
||||
public:
|
||||
POI() : _errorLine(0) {}
|
||||
bool loadFile(const QString &fileName);
|
||||
QString errorString() const {return _error;}
|
||||
const QString &errorString() const {return _error;}
|
||||
int errorLine() const {return _errorLine;}
|
||||
|
||||
QVector<WayPoint> points(const QVector<QPointF> &path) const;
|
||||
|
||||
QVector<Waypoint> points(const QVector<QPointF> &path,
|
||||
qreal radius = 0.01) const;
|
||||
const QStringList &files() const {return _files;}
|
||||
void enableFile(const QString &fileName, bool enable);
|
||||
void clear();
|
||||
|
||||
private:
|
||||
typedef RTree<size_t, qreal, 2> POITree;
|
||||
typedef struct {
|
||||
int start;
|
||||
int end;
|
||||
bool enabled;
|
||||
} FileIndex;
|
||||
|
||||
bool loadCSVFile(const QString &fileName);
|
||||
bool loadGPXFile(const QString &fileName);
|
||||
|
||||
POITree _tree;
|
||||
QVector<WayPoint> _data;
|
||||
QVector<Waypoint> _data;
|
||||
QStringList _files;
|
||||
QList<FileIndex> _indexes;
|
||||
|
||||
QString _error;
|
||||
int _errorLine;
|
||||
};
|
||||
|
@ -46,6 +46,11 @@ void ScaleItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *option,
|
||||
font.setFamily(FONT_FAMILY);
|
||||
QFontMetrics fm(font);
|
||||
QRect br;
|
||||
bool aa;
|
||||
|
||||
|
||||
if ((aa = painter->testRenderHint(QPainter::Antialiasing)))
|
||||
painter->setRenderHint(QPainter::Antialiasing, false);
|
||||
|
||||
painter->setFont(font);
|
||||
|
||||
@ -63,6 +68,9 @@ void ScaleItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *option,
|
||||
painter->fillRect(QRectF(i * _width, br.height() + PADDING, _width,
|
||||
SCALE_HEIGHT), Qt::black);
|
||||
|
||||
if (aa)
|
||||
painter->setRenderHint(QPainter::Antialiasing, true);
|
||||
|
||||
/*
|
||||
painter->setPen(Qt::red);
|
||||
painter->drawRect(boundingRect());
|
||||
|
@ -7,7 +7,6 @@
|
||||
|
||||
SliderInfoItem::SliderInfoItem(QGraphicsItem *parent) : QGraphicsItem(parent)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void SliderInfoItem::updateBoundingRect()
|
||||
|
@ -14,7 +14,7 @@ public:
|
||||
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option,
|
||||
QWidget *widget);
|
||||
|
||||
QRectF area() {return _area;}
|
||||
const QRectF &area() const {return _area;}
|
||||
void setArea(const QRectF &area) {_area = area;}
|
||||
|
||||
void clear();
|
||||
|
@ -7,13 +7,13 @@ SpeedGraph::SpeedGraph(QWidget *parent) : GraphView(parent)
|
||||
{
|
||||
_max = 0;
|
||||
|
||||
GraphView::setXLabel(tr("Distance"));
|
||||
GraphView::setYLabel(tr("Speed"));
|
||||
GraphView::setXUnits(tr("km"));
|
||||
GraphView::setYUnits(tr("km/h"));
|
||||
GraphView::setXScale(M2KM);
|
||||
GraphView::setYScale(MS2KMH);
|
||||
GraphView::setPrecision(1);
|
||||
setXLabel(tr("Distance"));
|
||||
setYLabel(tr("Speed"));
|
||||
setXUnits(tr("km"));
|
||||
setYUnits(tr("km/h"));
|
||||
setXScale(M2KM);
|
||||
setYScale(MS2KMH);
|
||||
setPrecision(1);
|
||||
}
|
||||
|
||||
void SpeedGraph::addInfo()
|
||||
@ -31,14 +31,16 @@ void SpeedGraph::loadGPX(const GPX &gpx)
|
||||
qreal max = 0;
|
||||
|
||||
gpx.track(i).speedGraph(data);
|
||||
if (data.isEmpty())
|
||||
return;
|
||||
if (data.count() < 2) {
|
||||
skipColor();
|
||||
continue;
|
||||
}
|
||||
|
||||
_avg.append(QPointF(gpx.track(i).distance(), gpx.track(i).distance()
|
||||
/ gpx.track(i).time()));
|
||||
|
||||
for (int i = 0; i < data.size(); i++)
|
||||
max = qMax(max, data.at(i).y());
|
||||
for (int j = 0; j < data.size(); j++)
|
||||
max = qMax(max, data.at(j).y());
|
||||
_max = qMax(_max, max);
|
||||
|
||||
addInfo();
|
||||
@ -70,15 +72,15 @@ void SpeedGraph::clear()
|
||||
void SpeedGraph::setUnits(enum Units units)
|
||||
{
|
||||
if (units == Metric) {
|
||||
GraphView::setXUnits(tr("km"));
|
||||
GraphView::setYUnits(tr("km/h"));
|
||||
GraphView::setXScale(M2KM);
|
||||
GraphView::setYScale(MS2KMH);
|
||||
setXUnits(tr("km"));
|
||||
setYUnits(tr("km/h"));
|
||||
setXScale(M2KM);
|
||||
setYScale(MS2KMH);
|
||||
} else {
|
||||
GraphView::setXUnits(tr("mi"));
|
||||
GraphView::setYUnits(tr("mi/h"));
|
||||
GraphView::setXScale(M2MI);
|
||||
GraphView::setYScale(MS2MIH);
|
||||
setXUnits(tr("mi"));
|
||||
setYUnits(tr("mi/h"));
|
||||
setXScale(M2MI);
|
||||
setYScale(MS2MIH);
|
||||
}
|
||||
|
||||
clearInfo();
|
||||
|
@ -1,9 +1,13 @@
|
||||
#include <cmath>
|
||||
#include "ll.h"
|
||||
#include "track.h"
|
||||
|
||||
|
||||
#define WINDOW_EF 3
|
||||
#define WINDOW_SE 11
|
||||
#define WINDOW_SF 11
|
||||
#define WINDOW_SF 7
|
||||
#define WINDOW_HE 11
|
||||
#define WINDOW_HF 3
|
||||
|
||||
static bool lt(const QPointF &p1, const QPointF &p2)
|
||||
{
|
||||
@ -76,6 +80,18 @@ static QVector<QPointF> filter(const QVector<QPointF> &v, int window)
|
||||
return ret;
|
||||
}
|
||||
|
||||
Track::Track(const QVector<Trackpoint> &data) : _data(data)
|
||||
{
|
||||
_distance = 0;
|
||||
|
||||
for (int i = 1; i < _data.count(); i++)
|
||||
_dd.append(llDistance(_data.at(i).coordinates,
|
||||
_data.at(i-1).coordinates));
|
||||
|
||||
for (int i = 0; i < _dd.size(); i++)
|
||||
_distance += _dd.at(i);
|
||||
}
|
||||
|
||||
void Track::elevationGraph(QVector<QPointF> &graph) const
|
||||
{
|
||||
qreal dist = 0;
|
||||
@ -84,9 +100,13 @@ void Track::elevationGraph(QVector<QPointF> &graph) const
|
||||
if (!_data.size())
|
||||
return;
|
||||
|
||||
if (std::isnan(_data.at(0).elevation))
|
||||
return;
|
||||
raw.append(QPointF(0, _data.at(0).elevation));
|
||||
for (int i = 1; i < _data.size(); i++) {
|
||||
dist += llDistance(_data.at(i).coordinates, _data.at(i-1).coordinates);
|
||||
dist += _dd.at(i-1);
|
||||
if (std::isnan(_data.at(i).elevation))
|
||||
return;
|
||||
raw.append(QPointF(dist, _data.at(i).elevation
|
||||
- _data.at(i).geoidheight));
|
||||
}
|
||||
@ -104,11 +124,11 @@ void Track::speedGraph(QVector<QPointF> &graph) const
|
||||
|
||||
raw.append(QPointF(0, 0));
|
||||
for (int i = 1; i < _data.size(); i++) {
|
||||
ds = llDistance(_data.at(i).coordinates, _data.at(i-1).coordinates);
|
||||
ds = _dd.at(i-1);
|
||||
dt = _data.at(i-1).timestamp.msecsTo(_data.at(i).timestamp) / 1000.0;
|
||||
dist += ds;
|
||||
|
||||
if (_data.at(i).speed < 0) {
|
||||
if (std::isnan(_data.at(i).speed)) {
|
||||
if (dt == 0)
|
||||
continue;
|
||||
v = ds / dt;
|
||||
@ -121,20 +141,31 @@ void Track::speedGraph(QVector<QPointF> &graph) const
|
||||
graph = filter(eliminate(raw, WINDOW_SE), WINDOW_SF);
|
||||
}
|
||||
|
||||
void Track::heartRateGraph(QVector<QPointF> &graph) const
|
||||
{
|
||||
qreal dist = 0;
|
||||
QVector<QPointF> raw;
|
||||
|
||||
if (!_data.size())
|
||||
return;
|
||||
|
||||
if (std::isnan(_data.at(0).heartRate))
|
||||
return;
|
||||
raw.append(QPointF(0, _data.at(0).heartRate));
|
||||
for (int i = 1; i < _data.count(); i++) {
|
||||
if (std::isnan(_data.at(i).heartRate))
|
||||
return;
|
||||
dist += _dd.at(i-1);
|
||||
raw.append(QPointF(dist, _data.at(i).heartRate));
|
||||
}
|
||||
|
||||
graph = filter(eliminate(raw, WINDOW_HE), WINDOW_HF);
|
||||
}
|
||||
|
||||
void Track::track(QVector<QPointF> &track) const
|
||||
{
|
||||
for (int i = 0; i < _data.size(); i++)
|
||||
track.append(ll2mercator(_data.at(i).coordinates));
|
||||
}
|
||||
|
||||
qreal Track::distance() const
|
||||
{
|
||||
qreal dist = 0;
|
||||
|
||||
for (int i = 1; i < _data.size(); i++)
|
||||
dist += llDistance(_data.at(i).coordinates, _data.at(i-1).coordinates);
|
||||
|
||||
return dist;
|
||||
track.append(_data.at(i).coordinates);
|
||||
}
|
||||
|
||||
qreal Track::time() const
|
||||
|
@ -8,17 +8,20 @@
|
||||
class Track
|
||||
{
|
||||
public:
|
||||
Track(const QVector<TrackPoint> &data) : _data(data) {}
|
||||
Track(const QVector<Trackpoint> &data);
|
||||
|
||||
void elevationGraph(QVector<QPointF> &graph) const;
|
||||
void speedGraph(QVector<QPointF> &graph) const;
|
||||
void heartRateGraph(QVector<QPointF> &graph) const;
|
||||
void track(QVector<QPointF> &track) const;
|
||||
qreal distance() const;
|
||||
qreal distance() const {return _distance;}
|
||||
qreal time() const;
|
||||
QDateTime date() const;
|
||||
|
||||
private:
|
||||
const QVector<TrackPoint> &_data;
|
||||
const QVector<Trackpoint> &_data;
|
||||
QVector<qreal> _dd;
|
||||
qreal _distance;
|
||||
};
|
||||
|
||||
#endif // TRACK_H
|
||||
|
@ -3,16 +3,23 @@
|
||||
|
||||
#include <QPointF>
|
||||
#include <QDateTime>
|
||||
#include <cmath>
|
||||
|
||||
struct TrackPoint
|
||||
struct Trackpoint
|
||||
{
|
||||
QPointF coordinates;
|
||||
QDateTime timestamp;
|
||||
qreal elevation;
|
||||
qreal geoidheight;
|
||||
qreal speed;
|
||||
qreal heartRate;
|
||||
|
||||
TrackPoint() {elevation = 0; geoidheight = 0; speed = -1;}
|
||||
Trackpoint() {
|
||||
elevation = NAN;
|
||||
geoidheight = 0;
|
||||
speed = NAN;
|
||||
heartRate = NAN;
|
||||
}
|
||||
};
|
||||
|
||||
#endif // TRACKPOINT_H
|
||||
|
@ -1,4 +1,3 @@
|
||||
#include <cmath>
|
||||
#include <QGraphicsView>
|
||||
#include <QGraphicsScene>
|
||||
#include <QPainterPath>
|
||||
@ -6,7 +5,7 @@
|
||||
#include "poi.h"
|
||||
#include "gpx.h"
|
||||
#include "map.h"
|
||||
#include "poiitem.h"
|
||||
#include "waypointitem.h"
|
||||
#include "markeritem.h"
|
||||
#include "scaleitem.h"
|
||||
#include "ll.h"
|
||||
@ -27,14 +26,16 @@ TrackView::TrackView(QWidget *parent)
|
||||
setViewportUpdateMode(QGraphicsView::FullViewportUpdate);
|
||||
setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
|
||||
setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
|
||||
setRenderHints(QPainter::Antialiasing);
|
||||
|
||||
_mapScale = new ScaleItem();
|
||||
_mapScale->setZValue(2.0);
|
||||
|
||||
_zoom = -1;
|
||||
_scale = 1.0;
|
||||
_zoom = ZOOM_MAX;
|
||||
_scale = mapScale(_zoom);
|
||||
_map = 0;
|
||||
_maxLen = 0;
|
||||
_maxPath = 0;
|
||||
_maxDistance = 0;
|
||||
}
|
||||
|
||||
TrackView::~TrackView()
|
||||
@ -42,95 +43,167 @@ TrackView::~TrackView()
|
||||
delete _scene;
|
||||
}
|
||||
|
||||
void TrackView::addTrack(const QVector<QPointF> &track)
|
||||
{
|
||||
QPainterPath path;
|
||||
QGraphicsPathItem *pi;
|
||||
MarkerItem *mi;
|
||||
|
||||
|
||||
if (track.size() < 2) {
|
||||
_palette.color();
|
||||
return;
|
||||
}
|
||||
|
||||
_tracks.append(track);
|
||||
|
||||
const QPointF &p = track.at(0);
|
||||
path.moveTo(ll2mercator(QPointF(p.x(), -p.y())));
|
||||
for (int i = 1; i < track.size(); i++) {
|
||||
const QPointF &p = track.at(i);
|
||||
path.lineTo(ll2mercator(QPointF(p.x(), -p.y())));
|
||||
}
|
||||
|
||||
_maxPath = qMax(path.length(), _maxPath);
|
||||
|
||||
pi = new QGraphicsPathItem(path);
|
||||
_paths.append(pi);
|
||||
_zoom = qMin(_zoom, scale2zoom(trackScale()));
|
||||
_scale = mapScale(_zoom);
|
||||
QBrush brush(_palette.color(), Qt::SolidPattern);
|
||||
QPen pen(brush, TRACK_WIDTH * _scale);
|
||||
pi->setPen(pen);
|
||||
pi->setScale(1.0/_scale);
|
||||
_scene->addItem(pi);
|
||||
|
||||
mi = new MarkerItem(pi);
|
||||
_markers.append(mi);
|
||||
mi->setPos(pi->path().pointAtPercent(0));
|
||||
mi->setScale(_scale);
|
||||
}
|
||||
|
||||
void TrackView::addWaypoints(const QList<Waypoint> &waypoints)
|
||||
{
|
||||
for (int i = 0; i < waypoints.count(); i++) {
|
||||
const Waypoint &w = waypoints.at(i);
|
||||
WaypointItem *wi = new WaypointItem(
|
||||
Waypoint(ll2mercator(QPointF(w.coordinates().x(),
|
||||
-w.coordinates().y())), w.description()));
|
||||
|
||||
wi->setPos(wi->entry().coordinates() * 1.0/_scale);
|
||||
wi->setZValue(1);
|
||||
_scene->addItem(wi);
|
||||
|
||||
_locations.append(wi);
|
||||
_waypoints.append(w.coordinates());
|
||||
}
|
||||
|
||||
_zoom = qMin(_zoom, scale2zoom(waypointScale()));
|
||||
_scale = mapScale(_zoom);
|
||||
}
|
||||
|
||||
void TrackView::loadGPX(const GPX &gpx)
|
||||
{
|
||||
int zoom = _zoom;
|
||||
|
||||
for (int i = 0; i < gpx.trackCount(); i++) {
|
||||
QVector<QPointF> track;
|
||||
QPainterPath path;
|
||||
QGraphicsPathItem *pi;
|
||||
MarkerItem *mi;
|
||||
QColor color = _colorShop.color();
|
||||
qreal prevScale = _scale;
|
||||
|
||||
|
||||
gpx.track(i).track(track);
|
||||
|
||||
if (track.size() < 2)
|
||||
continue;
|
||||
|
||||
_tracks.append(track);
|
||||
|
||||
path.moveTo(track.at(0).x(), -track.at(0).y());
|
||||
for (int i = 1; i < track.size(); i++)
|
||||
path.lineTo(track.at(i).x(), -track.at(i).y());
|
||||
|
||||
_maxLen = qMax(path.length(), _maxLen);
|
||||
|
||||
|
||||
pi = new QGraphicsPathItem(path);
|
||||
_trackPaths.append(pi);
|
||||
_zoom = scale2zoom(trackScale());
|
||||
_scale = mapScale();
|
||||
QBrush brush(color, Qt::SolidPattern);
|
||||
QPen pen(brush, TRACK_WIDTH * _scale);
|
||||
pi->setPen(pen);
|
||||
pi->setScale(1.0/_scale);
|
||||
_scene->addItem(pi);
|
||||
|
||||
mi = new MarkerItem(pi);
|
||||
_markers.append(mi);
|
||||
mi->setPos(pi->path().pointAtPercent(0));
|
||||
mi->setScale(_scale);
|
||||
|
||||
if (_trackPaths.size() > 1 && prevScale != _scale)
|
||||
rescale(_scale);
|
||||
|
||||
QRectF br = trackBoundingRect();
|
||||
QRectF ba = br.adjusted(-TILE_SIZE, -TILE_SIZE, TILE_SIZE, TILE_SIZE);
|
||||
_scene->setSceneRect(ba);
|
||||
centerOn(ba.center());
|
||||
|
||||
if (_mapScale->scene() != _scene)
|
||||
_scene->addItem(_mapScale);
|
||||
|
||||
_mapScale->setLatitude(track.at(track.size() / 2).y());
|
||||
_mapScale->setZoom(_zoom);
|
||||
addTrack(track);
|
||||
_maxDistance = qMax(gpx.track(i).distance(), _maxDistance);
|
||||
}
|
||||
|
||||
addWaypoints(gpx.waypoints());
|
||||
|
||||
if (_paths.empty() && _locations.empty())
|
||||
return;
|
||||
|
||||
if ((_paths.size() > 1 && _zoom < zoom)
|
||||
|| (_locations.size() && _zoom < zoom))
|
||||
rescale(_scale);
|
||||
|
||||
QRectF br = trackBoundingRect() | waypointBoundingRect();
|
||||
QRectF ba = br.adjusted(-TILE_SIZE, -TILE_SIZE, TILE_SIZE, TILE_SIZE);
|
||||
_scene->setSceneRect(ba);
|
||||
centerOn(ba.center());
|
||||
|
||||
_mapScale->setLatitude(-(br.center().ry() * _scale));
|
||||
_mapScale->setZoom(_zoom);
|
||||
if (_mapScale->scene() != _scene)
|
||||
_scene->addItem(_mapScale);
|
||||
}
|
||||
|
||||
QRectF TrackView::trackBoundingRect() const
|
||||
{
|
||||
if (_paths.empty())
|
||||
return QRectF();
|
||||
|
||||
QRectF br = _paths.at(0)->sceneBoundingRect();
|
||||
for (int i = 1; i < _paths.size(); i++)
|
||||
br |= _paths.at(i)->sceneBoundingRect();
|
||||
|
||||
return br;
|
||||
}
|
||||
|
||||
QRectF TrackView::waypointBoundingRect() const
|
||||
{
|
||||
qreal bottom, top, left, right;
|
||||
|
||||
bottom = _trackPaths.at(0)->sceneBoundingRect().bottom();
|
||||
top = _trackPaths.at(0)->sceneBoundingRect().top();
|
||||
left = _trackPaths.at(0)->sceneBoundingRect().left();
|
||||
right = _trackPaths.at(0)->sceneBoundingRect().right();
|
||||
if (_locations.empty())
|
||||
return QRectF();
|
||||
|
||||
for (int i = 1; i < _trackPaths.size(); i++) {
|
||||
bottom = qMax(bottom, _trackPaths.at(i)->sceneBoundingRect().bottom());
|
||||
top = qMin(top, _trackPaths.at(i)->sceneBoundingRect().top());
|
||||
right = qMax(right, _trackPaths.at(i)->sceneBoundingRect().right());
|
||||
left = qMin(left, _trackPaths.at(i)->sceneBoundingRect().left());
|
||||
const QPointF &p = _locations.at(0)->pos();
|
||||
bottom = p.y();
|
||||
top = p.y();
|
||||
left = p.x();
|
||||
right = p.x();
|
||||
|
||||
for (int i = 1; i < _locations.size(); i++) {
|
||||
const QPointF &p = _locations.at(i)->pos();
|
||||
bottom = qMax(bottom, p.y());
|
||||
top = qMin(top, p.y());
|
||||
right = qMax(right, p.x());
|
||||
left = qMin(left, p.x());
|
||||
}
|
||||
|
||||
return QRectF(QPointF(left, top), QPointF(right, bottom));
|
||||
}
|
||||
|
||||
qreal TrackView::trackScale() const
|
||||
{
|
||||
if (_paths.empty())
|
||||
return mapScale(ZOOM_MAX);
|
||||
|
||||
QRectF br = _paths.at(0)->path().boundingRect();
|
||||
|
||||
for (int i = 1; i < _paths.size(); i++)
|
||||
br |= _paths.at(i)->path().boundingRect();
|
||||
|
||||
QPointF sc(br.width() / (viewport()->width() - MARGIN/2),
|
||||
br.height() / (viewport()->height() - MARGIN/2));
|
||||
|
||||
return qMax(sc.x(), sc.y());
|
||||
}
|
||||
|
||||
qreal TrackView::waypointScale() const
|
||||
{
|
||||
qreal bottom, top, left, right;
|
||||
|
||||
bottom = _trackPaths.at(0)->path().boundingRect().bottom();
|
||||
top = _trackPaths.at(0)->path().boundingRect().top();
|
||||
left = _trackPaths.at(0)->path().boundingRect().left();
|
||||
right = _trackPaths.at(0)->path().boundingRect().right();
|
||||
if (_locations.size() < 2)
|
||||
return mapScale(ZOOM_MAX);
|
||||
|
||||
for (int i = 1; i < _trackPaths.size(); i++) {
|
||||
bottom = qMax(bottom, _trackPaths.at(i)->path().boundingRect().bottom());
|
||||
top = qMin(top, _trackPaths.at(i)->path().boundingRect().top());
|
||||
right = qMax(right, _trackPaths.at(i)->path().boundingRect().right());
|
||||
left = qMin(left, _trackPaths.at(i)->path().boundingRect().left());
|
||||
const QPointF &p = _locations.at(0)->entry().coordinates();
|
||||
bottom = p.y();
|
||||
top = p.y();
|
||||
left = p.x();
|
||||
right = p.x();
|
||||
|
||||
for (int i = 1; i < _locations.size(); i++) {
|
||||
const QPointF &p = _locations.at(i)->entry().coordinates();
|
||||
bottom = qMax(bottom, p.y());
|
||||
top = qMin(top, p.y());
|
||||
right = qMax(right, p.x());
|
||||
left = qMin(left, p.x());
|
||||
}
|
||||
|
||||
QRectF br(QPointF(left, top), QPointF(right, bottom));
|
||||
@ -140,26 +213,29 @@ qreal TrackView::trackScale() const
|
||||
return qMax(sc.x(), sc.y());
|
||||
}
|
||||
|
||||
qreal TrackView::mapScale() const
|
||||
qreal TrackView::mapScale(int zoom) const
|
||||
{
|
||||
return ((360.0/(qreal)(1<<_zoom))/(qreal)TILE_SIZE);
|
||||
return ((360.0/(qreal)(1<<zoom))/(qreal)TILE_SIZE);
|
||||
}
|
||||
|
||||
void TrackView::rescale(qreal scale)
|
||||
{
|
||||
for (int i = 0; i < _trackPaths.size(); i++) {
|
||||
for (int i = 0; i < _paths.size(); i++) {
|
||||
_markers.at(i)->setScale(scale);
|
||||
_trackPaths.at(i)->setScale(1.0/scale);
|
||||
_paths.at(i)->setScale(1.0/scale);
|
||||
|
||||
QPen pen(_trackPaths.at(i)->pen());
|
||||
QPen pen(_paths.at(i)->pen());
|
||||
pen.setWidthF(TRACK_WIDTH * scale);
|
||||
_trackPaths.at(i)->setPen(pen);
|
||||
_paths.at(i)->setPen(pen);
|
||||
}
|
||||
|
||||
QHash<WayPoint, POIItem*>::const_iterator it, jt;
|
||||
for (int i = 0; i < _locations.size(); i++)
|
||||
_locations.at(i)->setPos(_locations.at(i)->entry().coordinates()
|
||||
* 1.0/scale);
|
||||
|
||||
QHash<Waypoint, WaypointItem*>::const_iterator it, jt;
|
||||
for (it = _pois.constBegin(); it != _pois.constEnd(); it++) {
|
||||
it.value()->setPos(QPointF(it.value()->entry().coordinates().x()
|
||||
* 1.0/scale, -it.value()->entry().coordinates().y() * 1.0/scale));
|
||||
it.value()->setPos(it.value()->entry().coordinates() * 1.0/scale);
|
||||
it.value()->show();
|
||||
}
|
||||
|
||||
@ -174,29 +250,36 @@ void TrackView::rescale(qreal scale)
|
||||
_scale = scale;
|
||||
}
|
||||
|
||||
void TrackView::addPOI(const QVector<Waypoint> &waypoints)
|
||||
{
|
||||
for (int i = 0; i < waypoints.size(); i++) {
|
||||
const Waypoint &w = waypoints.at(i);
|
||||
|
||||
if (_pois.contains(w))
|
||||
continue;
|
||||
|
||||
WaypointItem *pi = new WaypointItem(
|
||||
Waypoint(ll2mercator(QPointF(w.coordinates().x(),
|
||||
-w.coordinates().y())), w.description()));
|
||||
|
||||
pi->setPos(pi->entry().coordinates() * 1.0/_scale);
|
||||
pi->setZValue(1);
|
||||
_scene->addItem(pi);
|
||||
|
||||
_pois.insert(w, pi);
|
||||
}
|
||||
}
|
||||
|
||||
void TrackView::loadPOI(const POI &poi)
|
||||
{
|
||||
QHash<WayPoint, POIItem*>::const_iterator it,jt;
|
||||
QHash<Waypoint, WaypointItem*>::const_iterator it,jt;
|
||||
|
||||
if (!_tracks.size())
|
||||
if (!_tracks.size() && !_waypoints.size())
|
||||
return;
|
||||
|
||||
for (int i = 0; i < _tracks.size(); i++) {
|
||||
QVector<WayPoint> p = poi.points(_tracks.at(i));
|
||||
|
||||
for (int i = 0; i < p.size(); i++) {
|
||||
if (_pois.contains(p.at(i)))
|
||||
continue;
|
||||
|
||||
POIItem *pi = new POIItem(p.at(i));
|
||||
pi->setPos(p.at(i).coordinates().x() * 1.0/_scale,
|
||||
-p.at(i).coordinates().y() * 1.0/_scale);
|
||||
pi->setZValue(1);
|
||||
_scene->addItem(pi);
|
||||
|
||||
_pois.insert(p.at(i), pi);
|
||||
}
|
||||
}
|
||||
for (int i = 0; i < _tracks.size(); i++)
|
||||
addPOI(poi.points(_tracks.at(i)));
|
||||
addPOI(poi.points(_waypoints));
|
||||
|
||||
for (it = _pois.constBegin(); it != _pois.constEnd(); it++) {
|
||||
for (jt = _pois.constBegin(); jt != _pois.constEnd(); jt++) {
|
||||
@ -227,7 +310,7 @@ void TrackView::redraw()
|
||||
|
||||
void TrackView::wheelEvent(QWheelEvent *event)
|
||||
{
|
||||
if (_tracks.isEmpty())
|
||||
if (_paths.isEmpty() && _locations.isEmpty())
|
||||
return;
|
||||
|
||||
QPointF pos = mapToScene(event->pos());
|
||||
@ -236,8 +319,8 @@ void TrackView::wheelEvent(QWheelEvent *event)
|
||||
_zoom = (event->delta() > 0) ?
|
||||
qMin(_zoom + 1, ZOOM_MAX) : qMax(_zoom - 1, ZOOM_MIN);
|
||||
|
||||
rescale(mapScale());
|
||||
QRectF br = trackBoundingRect();
|
||||
rescale(mapScale(_zoom));
|
||||
QRectF br = trackBoundingRect() | waypointBoundingRect();
|
||||
QRectF ba = br.adjusted(-TILE_SIZE, -TILE_SIZE, TILE_SIZE, TILE_SIZE);
|
||||
_scene->setSceneRect(ba);
|
||||
|
||||
@ -254,10 +337,10 @@ void TrackView::wheelEvent(QWheelEvent *event)
|
||||
|
||||
void TrackView::setTrackLineWidth(qreal width)
|
||||
{
|
||||
for (int i = 0; i < _trackPaths.size(); i++) {
|
||||
QPen pen(_trackPaths.at(i)->pen());
|
||||
for (int i = 0; i < _paths.size(); i++) {
|
||||
QPen pen(_paths.at(i)->pen());
|
||||
pen.setWidthF(width);
|
||||
_trackPaths.at(i)->setPen(pen);
|
||||
_paths.at(i)->setPen(pen);
|
||||
}
|
||||
}
|
||||
|
||||
@ -298,7 +381,7 @@ enum QPrinter::Orientation TrackView::orientation() const
|
||||
|
||||
void TrackView::clearPOI()
|
||||
{
|
||||
QHash<WayPoint, POIItem*>::const_iterator it;
|
||||
QHash<Waypoint, WaypointItem*>::const_iterator it;
|
||||
|
||||
for (it = _pois.constBegin(); it != _pois.constEnd(); it++) {
|
||||
_scene->removeItem(it.value());
|
||||
@ -314,30 +397,42 @@ void TrackView::clear()
|
||||
_scene->removeItem(_mapScale);
|
||||
|
||||
_pois.clear();
|
||||
_tracks.clear();
|
||||
_trackPaths.clear();
|
||||
_paths.clear();
|
||||
_locations.clear();
|
||||
_markers.clear();
|
||||
_scene->clear();
|
||||
_colorShop.reset();
|
||||
_palette.reset();
|
||||
|
||||
_maxLen = 0;
|
||||
_tracks.clear();
|
||||
_waypoints.clear();
|
||||
|
||||
_scene->setSceneRect(0, 0, 0, 0);
|
||||
_maxPath = 0;
|
||||
_maxDistance = 0;
|
||||
_zoom = ZOOM_MAX;
|
||||
_scale = mapScale(_zoom);
|
||||
|
||||
_scene->setSceneRect(QRectF());
|
||||
}
|
||||
|
||||
void TrackView::movePositionMarker(qreal val)
|
||||
{
|
||||
for (int i = 0; i < _trackPaths.size(); i++) {
|
||||
qreal f = _maxLen / _trackPaths.at(i)->path().length();
|
||||
QPointF pos = _trackPaths.at(i)->path().pointAtPercent(qMin(val * f,
|
||||
1.0));
|
||||
_markers.at(i)->setPos(pos);
|
||||
qreal mp = val / _maxDistance;
|
||||
|
||||
for (int i = 0; i < _paths.size(); i++) {
|
||||
qreal f = _maxPath / _paths.at(i)->path().length();
|
||||
if (mp * f > 1.0)
|
||||
_markers.at(i)->setVisible(false);
|
||||
else {
|
||||
QPointF pos = _paths.at(i)->path().pointAtPercent(mp * f);
|
||||
_markers.at(i)->setPos(pos);
|
||||
_markers.at(i)->setVisible(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void TrackView::drawBackground(QPainter *painter, const QRectF &rect)
|
||||
{
|
||||
if (_tracks.isEmpty() || !_map) {
|
||||
if ((_paths.isEmpty() && _locations.isEmpty())|| !_map) {
|
||||
painter->fillRect(rect, Qt::white);
|
||||
return;
|
||||
}
|
||||
@ -369,10 +464,10 @@ void TrackView::drawBackground(QPainter *painter, const QRectF &rect)
|
||||
|
||||
void TrackView::resizeEvent(QResizeEvent *e)
|
||||
{
|
||||
if (_tracks.isEmpty())
|
||||
if (_paths.isEmpty() && _locations.isEmpty())
|
||||
return;
|
||||
|
||||
QRectF br = trackBoundingRect();
|
||||
QRectF br = trackBoundingRect() | waypointBoundingRect();
|
||||
QRectF ba = br.adjusted(-TILE_SIZE, -TILE_SIZE, TILE_SIZE, TILE_SIZE);
|
||||
|
||||
if (ba.width() < e->size().width()) {
|
||||
|
@ -7,13 +7,13 @@
|
||||
#include <QList>
|
||||
#include <QPrinter>
|
||||
#include "units.h"
|
||||
#include "colorshop.h"
|
||||
#include "palette.h"
|
||||
#include "waypoint.h"
|
||||
|
||||
class GPX;
|
||||
class POI;
|
||||
class Map;
|
||||
class POIItem;
|
||||
class WaypointItem;
|
||||
class MarkerItem;
|
||||
class ScaleItem;
|
||||
|
||||
@ -37,6 +37,9 @@ public:
|
||||
void plot(QPainter *painter, const QRectF &target);
|
||||
enum QPrinter::Orientation orientation() const;
|
||||
|
||||
int trackCount() const {return _paths.count();}
|
||||
int waypointCount() const {return _locations.count();}
|
||||
|
||||
public slots:
|
||||
void movePositionMarker(qreal val);
|
||||
|
||||
@ -44,9 +47,15 @@ private slots:
|
||||
void redraw();
|
||||
|
||||
private:
|
||||
void addTrack(const QVector<QPointF> &track);
|
||||
void addWaypoints(const QList<Waypoint> &waypoints);
|
||||
void addPOI(const QVector<Waypoint> &waypoints);
|
||||
|
||||
QRectF trackBoundingRect() const;
|
||||
QRectF waypointBoundingRect() const;
|
||||
qreal trackScale() const;
|
||||
qreal mapScale() const;
|
||||
qreal waypointScale() const;
|
||||
qreal mapScale(int zoom) const;
|
||||
void rescale(qreal scale);
|
||||
|
||||
void showMarkers(bool show);
|
||||
@ -58,15 +67,18 @@ private:
|
||||
void paintEvent(QPaintEvent *e);
|
||||
|
||||
QGraphicsScene *_scene;
|
||||
QList<QVector<QPointF> > _tracks;
|
||||
QList<QGraphicsPathItem*> _trackPaths;
|
||||
QList<QGraphicsPathItem*> _paths;
|
||||
QList<MarkerItem*> _markers;
|
||||
QHash<WayPoint, POIItem*> _pois;
|
||||
QList<WaypointItem*> _locations;
|
||||
QHash<Waypoint, WaypointItem*> _pois;
|
||||
QList<QVector<QPointF> > _tracks;
|
||||
QVector<QPointF> _waypoints;
|
||||
|
||||
Map *_map;
|
||||
ScaleItem *_mapScale;
|
||||
|
||||
ColorShop _colorShop;
|
||||
qreal _maxLen;
|
||||
Palette _palette;
|
||||
qreal _maxPath, _maxDistance;
|
||||
|
||||
qreal _scale;
|
||||
int _zoom;
|
||||
|
@ -5,11 +5,11 @@
|
||||
#include <QString>
|
||||
#include <QHash>
|
||||
|
||||
class WayPoint
|
||||
class Waypoint
|
||||
{
|
||||
public:
|
||||
WayPoint() {}
|
||||
WayPoint(const QPointF &coordinates, const QString &description)
|
||||
Waypoint() {}
|
||||
Waypoint(const QPointF &coordinates, const QString &description)
|
||||
: _coordinates(coordinates), _description(description) {}
|
||||
|
||||
const QPointF &coordinates() const {return _coordinates;}
|
||||
@ -19,7 +19,7 @@ public:
|
||||
void setDescription(const QString &description)
|
||||
{_description = description;}
|
||||
|
||||
bool operator==(const WayPoint &other) const
|
||||
bool operator==(const Waypoint &other) const
|
||||
{return this->_description == other._description
|
||||
&& this->_coordinates == other._coordinates;}
|
||||
|
||||
@ -28,7 +28,7 @@ private:
|
||||
QString _description;
|
||||
};
|
||||
|
||||
inline uint qHash(const WayPoint &key)
|
||||
inline uint qHash(const Waypoint &key)
|
||||
{
|
||||
return ::qHash(key.description());
|
||||
}
|
||||
|
@ -1,18 +1,18 @@
|
||||
#include <QPainter>
|
||||
#include "config.h"
|
||||
#include "poiitem.h"
|
||||
#include "waypointitem.h"
|
||||
|
||||
|
||||
#define POINT_SIZE 8
|
||||
|
||||
POIItem::POIItem(const WayPoint &entry, QGraphicsItem *parent)
|
||||
WaypointItem::WaypointItem(const Waypoint &entry, QGraphicsItem *parent)
|
||||
: QGraphicsItem(parent)
|
||||
{
|
||||
_entry = entry;
|
||||
updateBoundingRect();
|
||||
}
|
||||
|
||||
void POIItem::updateBoundingRect()
|
||||
void WaypointItem::updateBoundingRect()
|
||||
{
|
||||
QFont font;
|
||||
font.setPixelSize(FONT_SIZE);
|
||||
@ -20,11 +20,11 @@ void POIItem::updateBoundingRect()
|
||||
QFontMetrics fm(font);
|
||||
QRect ts = fm.tightBoundingRect(_entry.description());
|
||||
|
||||
_boundingRect = QRectF(0, 0, ts.width() + POINT_SIZE,
|
||||
ts.height() + fm.descent() + POINT_SIZE);
|
||||
_boundingRect = QRectF(-POINT_SIZE/2, -POINT_SIZE/2, ts.width()
|
||||
+ POINT_SIZE, ts.height() + fm.descent() + POINT_SIZE);
|
||||
}
|
||||
|
||||
void POIItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *option,
|
||||
void WaypointItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *option,
|
||||
QWidget *widget)
|
||||
{
|
||||
Q_UNUSED(option);
|
||||
@ -36,10 +36,10 @@ void POIItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *option,
|
||||
QRect ts = fm.tightBoundingRect(_entry.description());
|
||||
|
||||
painter->setFont(font);
|
||||
painter->drawText(POINT_SIZE - qMax(ts.x(), 0), POINT_SIZE + ts.height(),
|
||||
painter->drawText(POINT_SIZE/2 - qMax(ts.x(), 0), POINT_SIZE/2 + ts.height(),
|
||||
_entry.description());
|
||||
painter->setBrush(Qt::SolidPattern);
|
||||
painter->drawEllipse(0, 0, POINT_SIZE, POINT_SIZE);
|
||||
painter->drawEllipse(-POINT_SIZE/2, -POINT_SIZE/2, POINT_SIZE, POINT_SIZE);
|
||||
|
||||
/*
|
||||
painter->setPen(Qt::red);
|
@ -1,14 +1,14 @@
|
||||
#ifndef POIITEM_H
|
||||
#define POIITEM_H
|
||||
#ifndef WAYPOINTITEM_H
|
||||
#define WAYPOINTITEM_H
|
||||
|
||||
#include <QGraphicsItem>
|
||||
#include "waypoint.h"
|
||||
|
||||
class POIItem : public QGraphicsItem
|
||||
class WaypointItem : public QGraphicsItem
|
||||
{
|
||||
public:
|
||||
POIItem(const WayPoint &entry, QGraphicsItem *parent = 0);
|
||||
const WayPoint &entry() const {return _entry;}
|
||||
WaypointItem(const Waypoint &entry, QGraphicsItem *parent = 0);
|
||||
const Waypoint &entry() const {return _entry;}
|
||||
|
||||
QRectF boundingRect() const {return _boundingRect;}
|
||||
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option,
|
||||
@ -17,8 +17,8 @@ public:
|
||||
private:
|
||||
void updateBoundingRect();
|
||||
|
||||
WayPoint _entry;
|
||||
Waypoint _entry;
|
||||
QRectF _boundingRect;
|
||||
};
|
||||
|
||||
#endif // POIITEM_H
|
||||
#endif // WAYPOINTITEM_H
|
Reference in New Issue
Block a user