mirror of
https://github.com/tumic0/GPXSee.git
synced 2025-07-01 05:19:15 +02:00
Compare commits
64 Commits
Author | SHA1 | Date | |
---|---|---|---|
8624b42e0b | |||
c00ebdeefd | |||
05f1536285 | |||
bf69ef58ba | |||
adcd603eec | |||
0ee0bd882e | |||
d48a2aac93 | |||
7993e4dcb3 | |||
d20d94ef05 | |||
9f0582cbea | |||
1e6925da75 | |||
7cfc05c101 | |||
392b829733 | |||
36083d2fa1 | |||
63fd7f239c | |||
20b107581e | |||
aacc04520f | |||
dad85e46a7 | |||
5912506292 | |||
e3c23d0ffc | |||
efdb31ddc5 | |||
ee2f471ca0 | |||
dafadbab60 | |||
7de08d116a | |||
dac06b9537 | |||
33b6e8954c | |||
2695745d82 | |||
fc67f6f19a | |||
07cd536867 | |||
c3d6294b7a | |||
68671ed994 | |||
46989bd7a0 | |||
0ce2f02178 | |||
1289762365 | |||
f0c3f9b8c8 | |||
31f6eeac26 | |||
40803d68c1 | |||
35dea229b4 | |||
330b6547c4 | |||
498d33b77d | |||
3592d9e68f | |||
7d38b55f60 | |||
82df1bec0e | |||
82cbbbb52a | |||
b8e404b789 | |||
2ad94947d7 | |||
b713da0012 | |||
daf4ef894c | |||
eae8e23c6c | |||
b9f7af33d7 | |||
f334901db3 | |||
ffcba53b91 | |||
f326c7e002 | |||
15d4bd05f9 | |||
43bc7dd682 | |||
a8cc02c1f9 | |||
511deada2e | |||
36937d8f2d | |||
969d87ec51 | |||
07255aa8ae | |||
e73f9448e9 | |||
ee9a8df51f | |||
dcdd250858 | |||
6f73740da6 |
@ -5,15 +5,15 @@
|
||||
<key>NSPrincipalClass</key>
|
||||
<string>NSApplication</string>
|
||||
<key>CFBundleIconFile</key>
|
||||
<string>gpxsee.icns</string>
|
||||
<string>@ICON@</string>
|
||||
<key>CFBundlePackageType</key>
|
||||
<string>APPL</string>
|
||||
<key>CFBundleShortVersionString</key>
|
||||
<string>2.13</string>
|
||||
<string>@SHORT_VERSION@</string>
|
||||
<key>CFBundleSignature</key>
|
||||
<string>????</string>
|
||||
<key>CFBundleExecutable</key>
|
||||
<string>GPXSee</string>
|
||||
<string>@EXECUTABLE@</string>
|
||||
<key>CFBundleIdentifier</key>
|
||||
<string>cz.wz.tumic.GPXSee</string>
|
||||
|
||||
|
32
gpxsee.pro
32
gpxsee.pro
@ -1,5 +1,5 @@
|
||||
TARGET = GPXSee
|
||||
VERSION = 2.13
|
||||
VERSION = 2.18
|
||||
QT += core \
|
||||
gui \
|
||||
network
|
||||
@ -27,7 +27,6 @@ HEADERS += src/config.h \
|
||||
src/downloader.h \
|
||||
src/units.h \
|
||||
src/scaleitem.h \
|
||||
src/nicenum.h \
|
||||
src/waypoint.h \
|
||||
src/trackview.h \
|
||||
src/track.h \
|
||||
@ -39,7 +38,19 @@ HEADERS += src/config.h \
|
||||
src/range.h \
|
||||
src/cpuarch.h \
|
||||
src/settings.h \
|
||||
src/app.h
|
||||
src/app.h \
|
||||
src/trackinfo.h \
|
||||
src/exportdialog.h \
|
||||
src/fileselectwidget.h \
|
||||
src/margins.h \
|
||||
src/temperaturegraph.h \
|
||||
src/graphtab.h \
|
||||
src/misc.h \
|
||||
src/trackitem.h \
|
||||
src/tooltip.h \
|
||||
src/route.h \
|
||||
src/routeitem.h \
|
||||
src/graphitem.h
|
||||
SOURCES += src/main.cpp \
|
||||
src/gui.cpp \
|
||||
src/gpx.cpp \
|
||||
@ -58,7 +69,6 @@ SOURCES += src/main.cpp \
|
||||
src/maplist.cpp \
|
||||
src/downloader.cpp \
|
||||
src/scaleitem.cpp \
|
||||
src/nicenum.cpp \
|
||||
src/trackview.cpp \
|
||||
src/track.cpp \
|
||||
src/graphview.cpp \
|
||||
@ -66,7 +76,19 @@ SOURCES += src/main.cpp \
|
||||
src/palette.cpp \
|
||||
src/heartrategraph.cpp \
|
||||
src/range.cpp \
|
||||
src/app.cpp
|
||||
src/app.cpp \
|
||||
src/trackinfo.cpp \
|
||||
src/exportdialog.cpp \
|
||||
src/fileselectwidget.cpp \
|
||||
src/temperaturegraph.cpp \
|
||||
src/trackpoint.cpp \
|
||||
src/misc.cpp \
|
||||
src/waypoint.cpp \
|
||||
src/trackitem.cpp \
|
||||
src/tooltip.cpp \
|
||||
src/route.cpp \
|
||||
src/routeitem.cpp \
|
||||
src/graphitem.cpp
|
||||
RESOURCES += gpxsee.qrc
|
||||
TRANSLATIONS = lang/gpxsee_cs.ts
|
||||
macx {
|
||||
|
@ -2,8 +2,8 @@
|
||||
<qresource prefix="/">
|
||||
<file>icons/dialog-close.png</file>
|
||||
<file>icons/document-open.png</file>
|
||||
<file>icons/document-save-as.png</file>
|
||||
<file>icons/document-save.png</file>
|
||||
<file>icons/document-print.png</file>
|
||||
<file>icons/document-export.png</file>
|
||||
<file>icons/flag.png</file>
|
||||
<file>icons/gpxsee.png</file>
|
||||
<file>icons/application-exit.png</file>
|
||||
|
BIN
icons/document-export.png
Normal file
BIN
icons/document-export.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 865 B |
BIN
icons/document-print.png
Normal file
BIN
icons/document-print.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 880 B |
Binary file not shown.
Before Width: | Height: | Size: 1.2 KiB |
Binary file not shown.
Before Width: | Height: | Size: 798 B |
@ -4,102 +4,196 @@
|
||||
<context>
|
||||
<name>ElevationGraph</name>
|
||||
<message>
|
||||
<location filename="../src/elevationgraph.cpp" line="14"/>
|
||||
<location filename="../src/elevationgraph.cpp" line="48"/>
|
||||
<source>Distance</source>
|
||||
<translation>Vzdálenost</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/elevationgraph.cpp" line="15"/>
|
||||
<location filename="../src/elevationgraph.cpp" line="49"/>
|
||||
<location filename="../src/elevationgraph.h" line="15"/>
|
||||
<source>Elevation</source>
|
||||
<translation>Výška</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/elevationgraph.cpp" line="81"/>
|
||||
<location filename="../src/elevationgraph.cpp" line="145"/>
|
||||
<source>km</source>
|
||||
<translation>km</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/elevationgraph.cpp" line="78"/>
|
||||
<location filename="../src/elevationgraph.cpp" line="98"/>
|
||||
<location filename="../src/elevationgraph.cpp" line="142"/>
|
||||
<location filename="../src/elevationgraph.cpp" line="162"/>
|
||||
<source>m</source>
|
||||
<translation>m</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/elevationgraph.cpp" line="22"/>
|
||||
<location filename="../src/elevationgraph.cpp" line="59"/>
|
||||
<source>Ascent</source>
|
||||
<translation>Stoupání</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/elevationgraph.cpp" line="24"/>
|
||||
<location filename="../src/elevationgraph.cpp" line="61"/>
|
||||
<source>Descent</source>
|
||||
<translation>Klesání</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/elevationgraph.cpp" line="28"/>
|
||||
<location filename="../src/elevationgraph.cpp" line="65"/>
|
||||
<source>Minimum</source>
|
||||
<translation>Minimum</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/elevationgraph.cpp" line="89"/>
|
||||
<location filename="../src/elevationgraph.cpp" line="153"/>
|
||||
<source>mi</source>
|
||||
<translation>mi</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/elevationgraph.cpp" line="86"/>
|
||||
<location filename="../src/elevationgraph.cpp" line="101"/>
|
||||
<location filename="../src/elevationgraph.cpp" line="150"/>
|
||||
<location filename="../src/elevationgraph.cpp" line="165"/>
|
||||
<source>ft</source>
|
||||
<translation>ft</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/elevationgraph.cpp" line="26"/>
|
||||
<location filename="../src/elevationgraph.cpp" line="63"/>
|
||||
<source>Maximum</source>
|
||||
<translation>Maximum</translation>
|
||||
</message>
|
||||
</context>
|
||||
<context>
|
||||
<name>ExportDialog</name>
|
||||
<message>
|
||||
<location filename="../src/exportdialog.cpp" line="121"/>
|
||||
<source>Export to PDF</source>
|
||||
<translation>Exportovat do PDF</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/exportdialog.cpp" line="29"/>
|
||||
<source>PDF files (*.pdf);;All files (*)</source>
|
||||
<translation>Soubory PDF (*.pdf);;Všechny soubory (*)</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/exportdialog.cpp" line="42"/>
|
||||
<source>Portrait</source>
|
||||
<translation>Na výšku</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/exportdialog.cpp" line="43"/>
|
||||
<source>Landscape</source>
|
||||
<translation>Na šířku</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/exportdialog.cpp" line="85"/>
|
||||
<source>Page size:</source>
|
||||
<translation>Velikost stránky:</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/exportdialog.cpp" line="86"/>
|
||||
<source>Orientation:</source>
|
||||
<translation>Orientace:</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/exportdialog.cpp" line="82"/>
|
||||
<source>Page Setup</source>
|
||||
<translation>Nastavení stránky</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/exportdialog.cpp" line="55"/>
|
||||
<source>in</source>
|
||||
<translation>in</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/exportdialog.cpp" line="55"/>
|
||||
<source>mm</source>
|
||||
<translation>mm</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/exportdialog.cpp" line="87"/>
|
||||
<source>Margins:</source>
|
||||
<translation>Okraje:</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/exportdialog.cpp" line="93"/>
|
||||
<source>File:</source>
|
||||
<translation>Soubor:</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/exportdialog.cpp" line="99"/>
|
||||
<source>Output file</source>
|
||||
<translation>Výstupní soubor</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/exportdialog.cpp" line="106"/>
|
||||
<source>Export</source>
|
||||
<translation>Exportovat</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/exportdialog.cpp" line="128"/>
|
||||
<location filename="../src/exportdialog.cpp" line="138"/>
|
||||
<location filename="../src/exportdialog.cpp" line="143"/>
|
||||
<source>Error</source>
|
||||
<translation>Chyba</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/exportdialog.cpp" line="128"/>
|
||||
<source>No output file selected.</source>
|
||||
<translation>Nebyl zvolen žádný výstupní soubor.</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/exportdialog.cpp" line="138"/>
|
||||
<source>%1 is a directory.</source>
|
||||
<translation>%1 je adresář.</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/exportdialog.cpp" line="143"/>
|
||||
<source>%1 is not writable.</source>
|
||||
<translation>%1 nelze zapsat.</translation>
|
||||
</message>
|
||||
</context>
|
||||
<context>
|
||||
<name>FileSelectWidget</name>
|
||||
<message>
|
||||
<location filename="../src/fileselectwidget.cpp" line="15"/>
|
||||
<source>Browse...</source>
|
||||
<translation>Procházet...</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/fileselectwidget.cpp" line="28"/>
|
||||
<source>Select file</source>
|
||||
<translation>Vybrat soubor</translation>
|
||||
</message>
|
||||
</context>
|
||||
<context>
|
||||
<name>GUI</name>
|
||||
<message>
|
||||
<location filename="../src/gui.cpp" line="448"/>
|
||||
<location filename="../src/gui.cpp" line="484"/>
|
||||
<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="512"/>
|
||||
<location filename="../src/gui.cpp" line="548"/>
|
||||
<source>Open file</source>
|
||||
<translation>Otevřít soubor</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/gui.cpp" line="208"/>
|
||||
<source>Save as</source>
|
||||
<translation>Uložit jako</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/gui.cpp" line="583"/>
|
||||
<location filename="../src/gui.cpp" line="628"/>
|
||||
<source>Open POI file</source>
|
||||
<translation>Otevřít POI soubor</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/gui.cpp" line="197"/>
|
||||
<location filename="../src/gui.cpp" line="198"/>
|
||||
<source>Open</source>
|
||||
<translation>Otevřít</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/gui.cpp" line="181"/>
|
||||
<location filename="../src/gui.cpp" line="182"/>
|
||||
<source>Quit</source>
|
||||
<translation>Ukončit</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/gui.cpp" line="189"/>
|
||||
<location filename="../src/gui.cpp" line="464"/>
|
||||
<location filename="../src/gui.cpp" line="465"/>
|
||||
<location filename="../src/gui.cpp" line="190"/>
|
||||
<location filename="../src/gui.cpp" line="500"/>
|
||||
<location filename="../src/gui.cpp" line="501"/>
|
||||
<source>Keyboard controls</source>
|
||||
<translation>Ovládací klávesy</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/gui.cpp" line="202"/>
|
||||
<source>Save</source>
|
||||
<translation>Uložit</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/gui.cpp" line="214"/>
|
||||
<source>Close</source>
|
||||
@ -111,20 +205,20 @@
|
||||
<translation>Znovu načíst</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/gui.cpp" line="379"/>
|
||||
<location filename="../src/gui.cpp" line="418"/>
|
||||
<source>Show</source>
|
||||
<translation>Zobrazit</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/gui.cpp" line="321"/>
|
||||
<location filename="../src/gui.cpp" line="370"/>
|
||||
<location filename="../src/gui.cpp" line="347"/>
|
||||
<location filename="../src/gui.cpp" line="412"/>
|
||||
<source>File</source>
|
||||
<translation>Soubor</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/gui.cpp" line="187"/>
|
||||
<location filename="../src/gui.cpp" line="487"/>
|
||||
<location filename="../src/gui.cpp" line="488"/>
|
||||
<location filename="../src/gui.cpp" line="188"/>
|
||||
<location filename="../src/gui.cpp" line="523"/>
|
||||
<location filename="../src/gui.cpp" line="524"/>
|
||||
<source>Data sources</source>
|
||||
<translation>Zdroje dat</translation>
|
||||
</message>
|
||||
@ -139,295 +233,300 @@
|
||||
<translation>Zavřit POI soubory</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/gui.cpp" line="234"/>
|
||||
<location filename="../src/gui.cpp" line="233"/>
|
||||
<source>Overlap POIs</source>
|
||||
<translation>Překrývat POI</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/gui.cpp" line="237"/>
|
||||
<source>Show POI labels</source>
|
||||
<translation>Zobrazovat názvy POI</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/gui.cpp" line="242"/>
|
||||
<source>Show POIs</source>
|
||||
<translation>Zobrazit POI</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/gui.cpp" line="242"/>
|
||||
<location filename="../src/gui.cpp" line="250"/>
|
||||
<source>Show map</source>
|
||||
<translation>Zobrazit mapu</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/gui.cpp" line="248"/>
|
||||
<location filename="../src/gui.cpp" line="256"/>
|
||||
<source>Clear tile cache</source>
|
||||
<translation>Vymazat mezipaměť dlaždic</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/gui.cpp" line="258"/>
|
||||
<location filename="../src/gui.cpp" line="262"/>
|
||||
<location filename="../src/gui.cpp" line="474"/>
|
||||
<location filename="../src/gui.cpp" line="265"/>
|
||||
<location filename="../src/gui.cpp" line="269"/>
|
||||
<location filename="../src/gui.cpp" line="510"/>
|
||||
<source>Next map</source>
|
||||
<translation>Následující mapa</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/gui.cpp" line="269"/>
|
||||
<location filename="../src/gui.cpp" line="276"/>
|
||||
<source>Show tracks</source>
|
||||
<translation>Zobrazit cesty</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/gui.cpp" line="280"/>
|
||||
<source>Show routes</source>
|
||||
<translation>Zobrazit trasy</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/gui.cpp" line="284"/>
|
||||
<source>Show waypoints</source>
|
||||
<translation>Zobrazit navigační body</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/gui.cpp" line="288"/>
|
||||
<source>Waypoint labels</source>
|
||||
<translation>Názvy navigačních bodů</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/gui.cpp" line="298"/>
|
||||
<source>Show graphs</source>
|
||||
<translation>Zobrazovat grafy</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/gui.cpp" line="276"/>
|
||||
<location filename="../src/gui.cpp" line="304"/>
|
||||
<source>Show toolbars</source>
|
||||
<translation>Zobrazovat nástrojové lišty</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/gui.cpp" line="283"/>
|
||||
<location filename="../src/gui.cpp" line="310"/>
|
||||
<source>Metric</source>
|
||||
<translation>Metrické</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/gui.cpp" line="289"/>
|
||||
<location filename="../src/gui.cpp" line="315"/>
|
||||
<source>Imperial</source>
|
||||
<translation>Imperiální</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/gui.cpp" line="295"/>
|
||||
<location filename="../src/gui.cpp" line="321"/>
|
||||
<source>Fullscreen mode</source>
|
||||
<translation>Celoobrazovkový režim</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/gui.cpp" line="303"/>
|
||||
<location filename="../src/gui.cpp" line="329"/>
|
||||
<source>Next</source>
|
||||
<translation>Následující</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/gui.cpp" line="306"/>
|
||||
<location filename="../src/gui.cpp" line="332"/>
|
||||
<source>Previous</source>
|
||||
<translation>Předchozí</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/gui.cpp" line="310"/>
|
||||
<location filename="../src/gui.cpp" line="336"/>
|
||||
<source>Last</source>
|
||||
<translation>Poslední</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/gui.cpp" line="313"/>
|
||||
<location filename="../src/gui.cpp" line="339"/>
|
||||
<source>First</source>
|
||||
<translation>První</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/gui.cpp" line="335"/>
|
||||
<location filename="../src/gui.cpp" line="361"/>
|
||||
<source>Map</source>
|
||||
<translation>Mapa</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/gui.cpp" line="342"/>
|
||||
<location filename="../src/gui.cpp" line="368"/>
|
||||
<source>POI</source>
|
||||
<translation>POI</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/gui.cpp" line="343"/>
|
||||
<location filename="../src/gui.cpp" line="369"/>
|
||||
<source>POI files</source>
|
||||
<translation>POI soubory</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/gui.cpp" line="351"/>
|
||||
<location filename="../src/gui.cpp" line="380"/>
|
||||
<source>Data</source>
|
||||
<translation>Data</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/gui.cpp" line="381"/>
|
||||
<source>Display</source>
|
||||
<translation>Zobrazit</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/gui.cpp" line="389"/>
|
||||
<source>Settings</source>
|
||||
<translation>Nastavení</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/gui.cpp" line="352"/>
|
||||
<location filename="../src/gui.cpp" line="390"/>
|
||||
<source>Units</source>
|
||||
<translation>Jednotky</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/gui.cpp" line="361"/>
|
||||
<location filename="../src/gui.cpp" line="399"/>
|
||||
<source>Help</source>
|
||||
<translation>Nápověda</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/gui.cpp" line="476"/>
|
||||
<location filename="../src/gui.cpp" line="512"/>
|
||||
<source>Previous map</source>
|
||||
<translation>Předchozí mapa</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/gui.cpp" line="822"/>
|
||||
<location filename="../src/gui.cpp" line="716"/>
|
||||
<location filename="../src/gui.cpp" line="719"/>
|
||||
<source>Date</source>
|
||||
<translation>Datum</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/gui.cpp" line="728"/>
|
||||
<source>Routes</source>
|
||||
<translation>Trasy</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/gui.cpp" line="918"/>
|
||||
<source>No GPX files loaded</source>
|
||||
<translation>Nejsou načteny žádné GPX soubory</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/gui.cpp" line="922"/>
|
||||
<source>Elevation</source>
|
||||
<translation>Výška</translation>
|
||||
<source>%1 files</source>
|
||||
<translation>%1 souborů</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/gui.cpp" line="923"/>
|
||||
<source>Speed</source>
|
||||
<translation>Rychlost</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/gui.cpp" line="924"/>
|
||||
<source>Heart rate</source>
|
||||
<translation>Tep</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/gui.cpp" line="467"/>
|
||||
<location filename="../src/gui.cpp" line="503"/>
|
||||
<source>Next file</source>
|
||||
<translation>Následující soubor</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/gui.cpp" line="444"/>
|
||||
<location filename="../src/gui.cpp" line="480"/>
|
||||
<source>Version </source>
|
||||
<translation>Verze </translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/gui.cpp" line="468"/>
|
||||
<location filename="../src/gui.cpp" line="203"/>
|
||||
<source>Print...</source>
|
||||
<translation>Tisknout...</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/gui.cpp" line="208"/>
|
||||
<source>Export to PDF...</source>
|
||||
<translation>Exportovat do PDF...</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/gui.cpp" line="730"/>
|
||||
<source>Waypoints</source>
|
||||
<translation>Navigační body</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/gui.cpp" line="504"/>
|
||||
<source>Previous file</source>
|
||||
<translation>Předchozí soubor</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/gui.cpp" line="470"/>
|
||||
<location filename="../src/gui.cpp" line="292"/>
|
||||
<source>Route waypoints</source>
|
||||
<translation>Body tras</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/gui.cpp" line="506"/>
|
||||
<source>First file</source>
|
||||
<translation>První soubor</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/gui.cpp" line="471"/>
|
||||
<location filename="../src/gui.cpp" line="507"/>
|
||||
<source>Last file</source>
|
||||
<translation>Poslední soubor</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/gui.cpp" line="472"/>
|
||||
<location filename="../src/gui.cpp" line="508"/>
|
||||
<source>Append modifier</source>
|
||||
<translation>Modifikátor nahradit/přidat</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/gui.cpp" line="491"/>
|
||||
<location filename="../src/gui.cpp" line="527"/>
|
||||
<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="494"/>
|
||||
<location filename="../src/gui.cpp" line="530"/>
|
||||
<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="502"/>
|
||||
<location filename="../src/gui.cpp" line="538"/>
|
||||
<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="513"/>
|
||||
<location filename="../src/gui.cpp" line="549"/>
|
||||
<source>GPX files (*.gpx);;All files (*)</source>
|
||||
<translation>soubory GPX (*.gpx);;všechny soubory (*)</translation>
|
||||
<translation>Soubory GPX (*.gpx);;Všechny soubory (*)</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/gui.cpp" line="574"/>
|
||||
<location filename="../src/gui.cpp" line="600"/>
|
||||
<location filename="../src/gui.cpp" line="619"/>
|
||||
<location filename="../src/gui.cpp" line="645"/>
|
||||
<source>Line: %1</source>
|
||||
<translation>Řádka: %1</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/gui.cpp" line="584"/>
|
||||
<location filename="../src/gui.cpp" line="629"/>
|
||||
<source>GPX files (*.gpx);;CSV files (*.csv);;All files (*)</source>
|
||||
<translation>soubory GPX (*.gpx);;soubory CSV (*.csv);;všechny soubory (*)</translation>
|
||||
<translation>Soubory GPX (*.gpx);;Soubory CSV (*.csv);;Všechny soubory (*)</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/gui.cpp" line="665"/>
|
||||
<location filename="../src/gui.cpp" line="837"/>
|
||||
<source>mi</source>
|
||||
<translation>mi</translation>
|
||||
<location filename="../src/gui.cpp" line="726"/>
|
||||
<source>Tracks</source>
|
||||
<translation>Cesty</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/gui.cpp" line="668"/>
|
||||
<location filename="../src/gui.cpp" line="670"/>
|
||||
<location filename="../src/gui.cpp" line="672"/>
|
||||
<location filename="../src/gui.cpp" line="674"/>
|
||||
<location filename="../src/gui.cpp" line="834"/>
|
||||
<source>ft</source>
|
||||
<translation>ft</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/gui.cpp" line="671"/>
|
||||
<location filename="../src/gui.cpp" line="683"/>
|
||||
<source>Maximum</source>
|
||||
<translation>Maximum</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/gui.cpp" line="673"/>
|
||||
<location filename="../src/gui.cpp" line="685"/>
|
||||
<source>Minimum</source>
|
||||
<translation>Minimum</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/gui.cpp" line="192"/>
|
||||
<location filename="../src/gui.cpp" line="442"/>
|
||||
<location filename="../src/gui.cpp" line="193"/>
|
||||
<location filename="../src/gui.cpp" line="478"/>
|
||||
<source>About GPXSee</source>
|
||||
<translation>O aplikaci GPXSee</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/gui.cpp" line="386"/>
|
||||
<location filename="../src/gui.cpp" line="422"/>
|
||||
<source>Navigation</source>
|
||||
<translation>Navigace</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/gui.cpp" line="490"/>
|
||||
<location filename="../src/gui.cpp" line="526"/>
|
||||
<source>Map sources</source>
|
||||
<translation>Mapové zdroje</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/gui.cpp" line="501"/>
|
||||
<location filename="../src/gui.cpp" line="537"/>
|
||||
<source>POIs</source>
|
||||
<translation>POI body</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/gui.cpp" line="664"/>
|
||||
<location filename="../src/gui.cpp" line="676"/>
|
||||
<location filename="../src/gui.cpp" line="733"/>
|
||||
<source>Distance</source>
|
||||
<translation>Vzdálenost</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/gui.cpp" line="666"/>
|
||||
<location filename="../src/gui.cpp" line="678"/>
|
||||
<location filename="../src/gui.cpp" line="735"/>
|
||||
<source>Time</source>
|
||||
<translation>Čas</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/gui.cpp" line="667"/>
|
||||
<location filename="../src/gui.cpp" line="679"/>
|
||||
<source>Ascent</source>
|
||||
<translation>Stoupání</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/gui.cpp" line="680"/>
|
||||
<location filename="../src/gui.cpp" line="682"/>
|
||||
<location filename="../src/gui.cpp" line="684"/>
|
||||
<location filename="../src/gui.cpp" line="686"/>
|
||||
<location filename="../src/gui.cpp" line="841"/>
|
||||
<source>m</source>
|
||||
<translation>m</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/gui.cpp" line="669"/>
|
||||
<location filename="../src/gui.cpp" line="681"/>
|
||||
<source>Descent</source>
|
||||
<translation>Klesání</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/gui.cpp" line="829"/>
|
||||
<source>%1 tracks</source>
|
||||
<translation>Počet tras: %1</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/gui.cpp" line="677"/>
|
||||
<location filename="../src/gui.cpp" line="844"/>
|
||||
<source>km</source>
|
||||
<translation>km</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/gui.cpp" line="576"/>
|
||||
<location filename="../src/gui.cpp" line="601"/>
|
||||
<location filename="../src/gui.cpp" line="621"/>
|
||||
<location filename="../src/gui.cpp" line="646"/>
|
||||
<source>Error</source>
|
||||
<translation>Chyba</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/gui.cpp" line="571"/>
|
||||
<location filename="../src/gui.cpp" line="616"/>
|
||||
<source>Error loading GPX file:
|
||||
%1</source>
|
||||
<translation>Soubor GPX nelze otevřít:
|
||||
%1</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/gui.cpp" line="597"/>
|
||||
<location filename="../src/gui.cpp" line="642"/>
|
||||
<source>Error loading POI file:
|
||||
%1</source>
|
||||
<translation>Soubor POI nelze otevřít:
|
||||
@ -437,65 +536,99 @@
|
||||
<context>
|
||||
<name>HeartRateGraph</name>
|
||||
<message>
|
||||
<location filename="../src/heartrategraph.cpp" line="10"/>
|
||||
<location filename="../src/heartrategraph.cpp" line="11"/>
|
||||
<source>Distance</source>
|
||||
<translation>Vzdálenost</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/heartrategraph.cpp" line="11"/>
|
||||
<location filename="../src/heartrategraph.cpp" line="12"/>
|
||||
<location filename="../src/heartrategraph.h" line="15"/>
|
||||
<source>Heart rate</source>
|
||||
<translation>Tep</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/heartrategraph.cpp" line="78"/>
|
||||
<location filename="../src/heartrategraph.cpp" line="84"/>
|
||||
<source>km</source>
|
||||
<translation>km</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/heartrategraph.cpp" line="9"/>
|
||||
<location filename="../src/heartrategraph.cpp" line="10"/>
|
||||
<source>1/min</source>
|
||||
<translation>1/min</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/heartrategraph.cpp" line="18"/>
|
||||
<location filename="../src/heartrategraph.cpp" line="20"/>
|
||||
<source>Average</source>
|
||||
<translation>Průměr</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/heartrategraph.cpp" line="20"/>
|
||||
<location filename="../src/heartrategraph.cpp" line="22"/>
|
||||
<source>Maximum</source>
|
||||
<translation>Maximum</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/heartrategraph.cpp" line="75"/>
|
||||
<location filename="../src/heartrategraph.cpp" line="81"/>
|
||||
<source>m</source>
|
||||
<translation>m</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/heartrategraph.cpp" line="83"/>
|
||||
<location filename="../src/heartrategraph.cpp" line="89"/>
|
||||
<source>ft</source>
|
||||
<translation>ft</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/heartrategraph.cpp" line="86"/>
|
||||
<location filename="../src/heartrategraph.cpp" line="92"/>
|
||||
<source>mi</source>
|
||||
<translation>mi</translation>
|
||||
</message>
|
||||
</context>
|
||||
<context>
|
||||
<name>QObject</name>
|
||||
<name>Misc</name>
|
||||
<message>
|
||||
<location filename="../src/scaleitem.cpp" line="83"/>
|
||||
<source>mi</source>
|
||||
<translation>mi</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/scaleitem.cpp" line="83"/>
|
||||
<location filename="../src/misc.cpp" line="55"/>
|
||||
<location filename="../src/misc.cpp" line="76"/>
|
||||
<source>ft</source>
|
||||
<translation>ft</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/scaleitem.cpp" line="85"/>
|
||||
<location filename="../src/misc.cpp" line="58"/>
|
||||
<source>mi</source>
|
||||
<translation>mi</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/misc.cpp" line="62"/>
|
||||
<location filename="../src/misc.cpp" line="73"/>
|
||||
<source>m</source>
|
||||
<translation>m</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/misc.cpp" line="65"/>
|
||||
<source>km</source>
|
||||
<translation>km</translation>
|
||||
</message>
|
||||
</context>
|
||||
<context>
|
||||
<name>RouteItem</name>
|
||||
<message>
|
||||
<location filename="../src/routeitem.cpp" line="17"/>
|
||||
<source>Distance</source>
|
||||
<translation>Vzdálenost</translation>
|
||||
</message>
|
||||
</context>
|
||||
<context>
|
||||
<name>ScaleItem</name>
|
||||
<message>
|
||||
<location filename="../src/scaleitem.cpp" line="81"/>
|
||||
<source>mi</source>
|
||||
<translation>mi</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/scaleitem.cpp" line="82"/>
|
||||
<source>ft</source>
|
||||
<translation>ft</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/scaleitem.cpp" line="84"/>
|
||||
<source>km</source>
|
||||
<translation>km</translation>
|
||||
</message>
|
||||
@ -508,54 +641,160 @@
|
||||
<context>
|
||||
<name>SpeedGraph</name>
|
||||
<message>
|
||||
<location filename="../src/speedgraph.cpp" line="11"/>
|
||||
<location filename="../src/speedgraph.cpp" line="12"/>
|
||||
<source>Distance</source>
|
||||
<translation>Vzdálenost</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/speedgraph.cpp" line="12"/>
|
||||
<location filename="../src/speedgraph.cpp" line="13"/>
|
||||
<location filename="../src/speedgraph.h" line="16"/>
|
||||
<source>Speed</source>
|
||||
<translation>Rychlost</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/speedgraph.cpp" line="72"/>
|
||||
<location filename="../src/speedgraph.cpp" line="77"/>
|
||||
<source>m</source>
|
||||
<translation>m</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/speedgraph.cpp" line="75"/>
|
||||
<location filename="../src/speedgraph.cpp" line="80"/>
|
||||
<source>km</source>
|
||||
<translation></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/speedgraph.cpp" line="80"/>
|
||||
<location filename="../src/speedgraph.cpp" line="85"/>
|
||||
<source>ft</source>
|
||||
<translation>ft</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/speedgraph.cpp" line="92"/>
|
||||
<location filename="../src/speedgraph.cpp" line="97"/>
|
||||
<source>km/h</source>
|
||||
<translation>km/h</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/speedgraph.cpp" line="19"/>
|
||||
<location filename="../src/speedgraph.cpp" line="21"/>
|
||||
<source>Average</source>
|
||||
<translation>Průměr</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/speedgraph.cpp" line="21"/>
|
||||
<location filename="../src/speedgraph.cpp" line="23"/>
|
||||
<source>Maximum</source>
|
||||
<translation>Maximum</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/speedgraph.cpp" line="83"/>
|
||||
<location filename="../src/speedgraph.cpp" line="88"/>
|
||||
<source>mi</source>
|
||||
<translation>mi</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/speedgraph.cpp" line="95"/>
|
||||
<location filename="../src/speedgraph.cpp" line="100"/>
|
||||
<source>mi/h</source>
|
||||
<translation>mi/h</translation>
|
||||
</message>
|
||||
</context>
|
||||
<context>
|
||||
<name>TemperatureGraph</name>
|
||||
<message>
|
||||
<location filename="../src/temperaturegraph.cpp" line="11"/>
|
||||
<source>Distance</source>
|
||||
<translation>Vzdálenost</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/temperaturegraph.cpp" line="12"/>
|
||||
<location filename="../src/temperaturegraph.h" line="15"/>
|
||||
<source>Temperature</source>
|
||||
<translation>Teplota</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/temperaturegraph.cpp" line="20"/>
|
||||
<source>Average</source>
|
||||
<translation>Průměr</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/temperaturegraph.cpp" line="22"/>
|
||||
<source>Minimum</source>
|
||||
<translation>Minimum</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/temperaturegraph.cpp" line="24"/>
|
||||
<source>Maximum</source>
|
||||
<translation>Maximum</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/temperaturegraph.cpp" line="83"/>
|
||||
<source>m</source>
|
||||
<translation>m</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/temperaturegraph.cpp" line="86"/>
|
||||
<source>km</source>
|
||||
<translation>km</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/temperaturegraph.cpp" line="91"/>
|
||||
<source>ft</source>
|
||||
<translation>ft</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/temperaturegraph.cpp" line="94"/>
|
||||
<source>mi</source>
|
||||
<translation>mi</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/temperaturegraph.cpp" line="103"/>
|
||||
<source>C</source>
|
||||
<translation>C</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/temperaturegraph.cpp" line="107"/>
|
||||
<source>F</source>
|
||||
<translation>F</translation>
|
||||
</message>
|
||||
</context>
|
||||
<context>
|
||||
<name>TrackItem</name>
|
||||
<message>
|
||||
<location filename="../src/trackitem.cpp" line="16"/>
|
||||
<source>Distance</source>
|
||||
<translation>Vzdálenost</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/trackitem.cpp" line="19"/>
|
||||
<source>Time</source>
|
||||
<translation>Čas</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/trackitem.cpp" line="21"/>
|
||||
<source>Date</source>
|
||||
<translation>Datum</translation>
|
||||
</message>
|
||||
</context>
|
||||
<context>
|
||||
<name>WaypointItem</name>
|
||||
<message>
|
||||
<location filename="../src/waypointitem.cpp" line="17"/>
|
||||
<source>Name</source>
|
||||
<translation>Název</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/waypointitem.cpp" line="18"/>
|
||||
<source>Coordinates</source>
|
||||
<translation>Souřadnice</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/waypointitem.cpp" line="21"/>
|
||||
<source>Elevation</source>
|
||||
<translation>Výška</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/waypointitem.cpp" line="24"/>
|
||||
<source>Date</source>
|
||||
<translation>Datum</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/waypointitem.cpp" line="27"/>
|
||||
<source>Description</source>
|
||||
<translation>Popis</translation>
|
||||
</message>
|
||||
</context>
|
||||
</TS>
|
||||
|
@ -3,9 +3,11 @@
|
||||
|
||||
; The name of the installer
|
||||
Name "GPXSee"
|
||||
; Program version
|
||||
!define VERSION "2.18"
|
||||
|
||||
; The file to write
|
||||
OutFile "install.exe"
|
||||
OutFile "GPXSee-${VERSION}.exe"
|
||||
|
||||
; Required execution level
|
||||
RequestExecutionLevel admin
|
||||
@ -67,7 +69,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.13"
|
||||
WriteRegStr HKLM "${REGENTRY}" "DisplayVersion" "${VERSION}"
|
||||
WriteRegStr HKLM "${REGENTRY}" "UninstallString" '"$INSTDIR\uninstall.exe"'
|
||||
WriteRegDWORD HKLM "${REGENTRY}" "NoModify" 1
|
||||
WriteRegDWORD HKLM "${REGENTRY}" "NoRepair" 1
|
||||
@ -100,6 +102,7 @@ Section "QT libs" SEC_QT
|
||||
File "libGLESv2.dll"
|
||||
File /r "platforms"
|
||||
File /r "imageformats"
|
||||
File /r "printsupport"
|
||||
|
||||
SectionEnd
|
||||
|
||||
|
@ -3,9 +3,11 @@
|
||||
|
||||
; The name of the installer
|
||||
Name "GPXSee"
|
||||
; Program version
|
||||
!define VERSION "2.18"
|
||||
|
||||
; The file to write
|
||||
OutFile "install.exe"
|
||||
OutFile "GPXSee-${VERSION}_x64.exe"
|
||||
|
||||
; Required execution level
|
||||
RequestExecutionLevel admin
|
||||
@ -75,7 +77,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.13"
|
||||
WriteRegStr HKLM "${REGENTRY}" "DisplayVersion" "${VERSION}"
|
||||
WriteRegStr HKLM "${REGENTRY}" "UninstallString" '"$INSTDIR\uninstall.exe"'
|
||||
WriteRegDWORD HKLM "${REGENTRY}" "NoModify" 1
|
||||
WriteRegDWORD HKLM "${REGENTRY}" "NoRepair" 1
|
||||
@ -108,6 +110,7 @@ Section "QT libs" SEC_QT
|
||||
File "libGLESv2.dll"
|
||||
File /r "platforms"
|
||||
File /r "imageformats"
|
||||
File /r "printsupport"
|
||||
|
||||
SectionEnd
|
||||
|
||||
|
@ -1,7 +1,7 @@
|
||||
#include <cmath>
|
||||
#include <QPainter>
|
||||
#include "config.h"
|
||||
#include "nicenum.h"
|
||||
#include "misc.h"
|
||||
#include "axisitem.h"
|
||||
|
||||
|
||||
|
@ -11,6 +11,7 @@
|
||||
|
||||
#define FONT_FAMILY "Arial"
|
||||
#define FONT_SIZE 12
|
||||
#define SCREEN_DPI 96.0
|
||||
|
||||
#define MAP_FILE QString("maps.txt")
|
||||
#define POI_DIR QString("POI")
|
||||
|
@ -23,12 +23,12 @@ Downloader::Downloader()
|
||||
SLOT(downloadFinished(QNetworkReply*)));
|
||||
}
|
||||
|
||||
void Downloader::doDownload(const Download &dl)
|
||||
bool Downloader::doDownload(const Download &dl)
|
||||
{
|
||||
QUrl url(dl.url());
|
||||
|
||||
if (_errorDownloads.contains(url))
|
||||
return;
|
||||
return false;
|
||||
|
||||
QNetworkRequest request(url);
|
||||
request.setAttribute(QNetworkRequest::User, QVariant(dl.file()));
|
||||
@ -36,6 +36,8 @@ void Downloader::doDownload(const Download &dl)
|
||||
QNetworkReply *reply = _manager.get(request);
|
||||
|
||||
_currentDownloads.append(reply);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool Downloader::saveToDisk(const QString &filename, QIODevice *data)
|
||||
@ -62,9 +64,17 @@ void Downloader::downloadFinished(QNetworkReply *reply)
|
||||
fprintf(stderr, "Error downloading map tile: %s: %s\n",
|
||||
url.toEncoded().constData(), qPrintable(reply->errorString()));
|
||||
} else {
|
||||
QUrl redirect = reply->attribute(
|
||||
QNetworkRequest::RedirectionTargetAttribute).toUrl();
|
||||
QString filename = reply->request().attribute(QNetworkRequest::User)
|
||||
.toString();
|
||||
saveToDisk(filename, reply);
|
||||
|
||||
if (!redirect.isEmpty()) {
|
||||
Download dl(redirect, filename);
|
||||
doDownload(dl);
|
||||
} else
|
||||
if (!saveToDisk(filename, reply))
|
||||
_errorDownloads.insert(url);
|
||||
}
|
||||
|
||||
_currentDownloads.removeAll(reply);
|
||||
@ -74,8 +84,12 @@ void Downloader::downloadFinished(QNetworkReply *reply)
|
||||
emit finished();
|
||||
}
|
||||
|
||||
void Downloader::get(const QList<Download> &list)
|
||||
bool Downloader::get(const QList<Download> &list)
|
||||
{
|
||||
bool finishEmitted = false;
|
||||
|
||||
for (int i = 0; i < list.count(); i++)
|
||||
doDownload(list.at(i));
|
||||
finishEmitted |= doDownload(list.at(i));
|
||||
|
||||
return finishEmitted;
|
||||
}
|
||||
|
@ -12,13 +12,13 @@
|
||||
class Download
|
||||
{
|
||||
public:
|
||||
Download(const QString &url, const QString &file)
|
||||
Download(const QUrl &url, const QString &file)
|
||||
{_url = url; _file = file;}
|
||||
const QString& url() const {return _url;}
|
||||
const QUrl& url() const {return _url;}
|
||||
const QString& file() const {return _file;}
|
||||
|
||||
private:
|
||||
QString _url;
|
||||
QUrl _url;
|
||||
QString _file;
|
||||
};
|
||||
|
||||
@ -30,7 +30,7 @@ class Downloader : public QObject
|
||||
public:
|
||||
static Downloader& instance()
|
||||
{static Downloader i; return i;}
|
||||
void get(const QList<Download> &list);
|
||||
bool get(const QList<Download> &list);
|
||||
|
||||
signals:
|
||||
void finished();
|
||||
@ -43,7 +43,7 @@ private:
|
||||
Downloader(Downloader const&);
|
||||
void operator=(Downloader const&);
|
||||
|
||||
void doDownload(const Download &dl);
|
||||
bool doDownload(const Download &dl);
|
||||
bool saveToDisk(const QString &filename, QIODevice *data);
|
||||
|
||||
QNetworkAccessManager _manager;
|
||||
|
@ -1,12 +1,46 @@
|
||||
#include <cmath>
|
||||
#include "config.h"
|
||||
#include "gpx.h"
|
||||
#include "elevationgraph.h"
|
||||
|
||||
|
||||
ElevationGraph::ElevationGraph(QWidget *parent) : GraphView(parent)
|
||||
static qreal nMin(qreal a, qreal b)
|
||||
{
|
||||
_ascent = 0;
|
||||
_descent = 0;
|
||||
if (!std::isnan(a) && !std::isnan(b))
|
||||
return qMin(a, b);
|
||||
else if (!std::isnan(a))
|
||||
return a;
|
||||
else if (!std::isnan(b))
|
||||
return b;
|
||||
else
|
||||
return NAN;
|
||||
}
|
||||
|
||||
static qreal nMax(qreal a, qreal b)
|
||||
{
|
||||
if (!std::isnan(a) && !std::isnan(b))
|
||||
return qMax(a, b);
|
||||
else if (!std::isnan(a))
|
||||
return a;
|
||||
else if (!std::isnan(b))
|
||||
return b;
|
||||
else
|
||||
return NAN;
|
||||
}
|
||||
|
||||
ElevationGraph::ElevationGraph(QWidget *parent) : GraphTab(parent)
|
||||
{
|
||||
_trackAscent = 0;
|
||||
_routeAscent = 0;
|
||||
_trackDescent = 0;
|
||||
_routeDescent = 0;
|
||||
_trackMin = NAN;
|
||||
_trackMax = NAN;
|
||||
_routeMin = NAN;
|
||||
_routeMax = NAN;
|
||||
|
||||
_showRoutes = true;
|
||||
_showTracks = true;
|
||||
|
||||
_units = Metric;
|
||||
|
||||
@ -17,56 +51,86 @@ ElevationGraph::ElevationGraph(QWidget *parent) : GraphView(parent)
|
||||
setMinYRange(50.0);
|
||||
}
|
||||
|
||||
void ElevationGraph::addInfo()
|
||||
void ElevationGraph::setInfo()
|
||||
{
|
||||
GraphView::addInfo(tr("Ascent"), QString::number(_ascent * yScale(), 'f', 0)
|
||||
+ UNIT_SPACE + yUnits());
|
||||
GraphView::addInfo(tr("Descent"), QString::number(_descent * yScale(), 'f',
|
||||
0) + UNIT_SPACE + yUnits());
|
||||
GraphView::addInfo(tr("Maximum"), QString::number(max() * yScale(), 'f', 0)
|
||||
+ UNIT_SPACE + yUnits());
|
||||
GraphView::addInfo(tr("Minimum"), QString::number(min() * yScale(), 'f', 0)
|
||||
+ UNIT_SPACE + yUnits());
|
||||
if (std::isnan(max()) || std::isnan(min()))
|
||||
clearInfo();
|
||||
else {
|
||||
GraphView::addInfo(tr("Ascent"), QString::number(ascent() * yScale(),
|
||||
'f', 0) + UNIT_SPACE + yUnits());
|
||||
GraphView::addInfo(tr("Descent"), QString::number(descent() * yScale(),
|
||||
'f', 0) + UNIT_SPACE + yUnits());
|
||||
GraphView::addInfo(tr("Maximum"), QString::number(max() * yScale(), 'f',
|
||||
0) + UNIT_SPACE + yUnits());
|
||||
GraphView::addInfo(tr("Minimum"), QString::number(min() * yScale(), 'f',
|
||||
0) + UNIT_SPACE + yUnits());
|
||||
}
|
||||
}
|
||||
|
||||
redraw();
|
||||
void ElevationGraph::loadPath(const QVector<QPointF> &data, Type type)
|
||||
{
|
||||
qreal ascent = 0, descent = 0;
|
||||
qreal min, max;
|
||||
|
||||
if (data.count() < 2) {
|
||||
skipColor();
|
||||
return;
|
||||
}
|
||||
|
||||
max = min = data.at(0).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;
|
||||
if (cur < prev)
|
||||
descent += prev - cur;
|
||||
|
||||
if (cur < min)
|
||||
min = cur;
|
||||
if (cur > max)
|
||||
max = cur;
|
||||
}
|
||||
|
||||
if (type == Track) {
|
||||
_trackAscent += ascent;
|
||||
_trackDescent += descent;
|
||||
_trackMax = nMax(_trackMax, max);
|
||||
_trackMin = nMin(_trackMin, min);
|
||||
} else {
|
||||
_routeAscent += ascent;
|
||||
_routeDescent += descent;
|
||||
_routeMax = nMax(_routeMax, max);
|
||||
_routeMin = nMin(_routeMin, min);
|
||||
}
|
||||
|
||||
loadData(data, type);
|
||||
}
|
||||
|
||||
void ElevationGraph::loadGPX(const GPX &gpx)
|
||||
{
|
||||
for (int i = 0; i < gpx.trackCount(); i++) {
|
||||
QVector<QPointF> data;
|
||||
qreal ascent = 0, descent = 0;
|
||||
|
||||
gpx.track(i).elevationGraph(data);
|
||||
if (data.count() < 2) {
|
||||
skipColor();
|
||||
continue;
|
||||
}
|
||||
|
||||
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;
|
||||
if (cur < prev)
|
||||
descent += prev - cur;
|
||||
}
|
||||
|
||||
_ascent += ascent;
|
||||
_descent += descent;
|
||||
|
||||
loadData(data);
|
||||
}
|
||||
for (int i = 0; i < gpx.tracks().count(); i++)
|
||||
loadPath(gpx.tracks().at(i)->elevation(), Track);
|
||||
for (int i = 0; i < gpx.routes().count(); i++)
|
||||
loadPath(gpx.routes().at(i)->elevation(), Route);
|
||||
|
||||
setXUnits();
|
||||
addInfo();
|
||||
setInfo();
|
||||
|
||||
redraw();
|
||||
}
|
||||
|
||||
void ElevationGraph::clear()
|
||||
{
|
||||
_ascent = 0;
|
||||
_descent = 0;
|
||||
_trackAscent = 0;
|
||||
_routeAscent = 0;
|
||||
_trackDescent = 0;
|
||||
_routeDescent = 0;
|
||||
_trackMin = NAN;
|
||||
_trackMax = NAN;
|
||||
_routeMin = NAN;
|
||||
_routeMax = NAN;
|
||||
|
||||
GraphView::clear();
|
||||
}
|
||||
@ -106,9 +170,88 @@ void ElevationGraph::setYUnits()
|
||||
void ElevationGraph::setUnits(enum Units units)
|
||||
{
|
||||
_units = units;
|
||||
|
||||
setXUnits();
|
||||
setYUnits();
|
||||
setInfo();
|
||||
|
||||
clearInfo();
|
||||
addInfo();
|
||||
redraw();
|
||||
}
|
||||
|
||||
void ElevationGraph::showTracks(bool show)
|
||||
{
|
||||
_showTracks = show;
|
||||
|
||||
setInfo();
|
||||
showGraph(show, Track);
|
||||
setXUnits();
|
||||
|
||||
redraw();
|
||||
}
|
||||
|
||||
void ElevationGraph::showRoutes(bool show)
|
||||
{
|
||||
_showRoutes = show;
|
||||
|
||||
showGraph(show, Route);
|
||||
setXUnits();
|
||||
setInfo();
|
||||
|
||||
redraw();
|
||||
}
|
||||
|
||||
qreal ElevationGraph::ascent() const
|
||||
{
|
||||
qreal val = 0;
|
||||
|
||||
if (_showRoutes)
|
||||
val += _routeAscent;
|
||||
if (_showTracks)
|
||||
val += _trackAscent;
|
||||
|
||||
return val;
|
||||
}
|
||||
|
||||
qreal ElevationGraph::descent() const
|
||||
{
|
||||
qreal val = 0;
|
||||
|
||||
if (_showRoutes)
|
||||
val += _routeDescent;
|
||||
if (_showTracks)
|
||||
val += _trackDescent;
|
||||
|
||||
return val;
|
||||
}
|
||||
|
||||
qreal ElevationGraph::max() const
|
||||
{
|
||||
qreal val;
|
||||
|
||||
if (_showRoutes && _showTracks)
|
||||
val = nMax(_routeMax, _trackMax);
|
||||
else if (_showTracks)
|
||||
val = _trackMax;
|
||||
else if (_showRoutes)
|
||||
val = _routeMax;
|
||||
else
|
||||
val = NAN;
|
||||
|
||||
return val;
|
||||
}
|
||||
|
||||
qreal ElevationGraph::min() const
|
||||
{
|
||||
qreal val;
|
||||
|
||||
if (_showRoutes && _showTracks)
|
||||
val = nMin(_routeMin, _trackMin);
|
||||
else if (_showTracks)
|
||||
val = _trackMin;
|
||||
else if (_showRoutes)
|
||||
val = _routeMin;
|
||||
else
|
||||
val = NAN;
|
||||
|
||||
return val;
|
||||
}
|
||||
|
@ -1,34 +1,45 @@
|
||||
#ifndef ELEVATIONGRAPH_H
|
||||
#define ELEVATIONGRAPH_H
|
||||
|
||||
#include "graphview.h"
|
||||
#include "units.h"
|
||||
#include "graphtab.h"
|
||||
|
||||
class GPX;
|
||||
|
||||
class ElevationGraph : public GraphView
|
||||
class ElevationGraph : public GraphTab
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
ElevationGraph(QWidget *parent = 0);
|
||||
|
||||
QString label() const {return tr("Elevation");}
|
||||
void loadGPX(const GPX &gpx);
|
||||
void clear();
|
||||
void setUnits(enum Units units);
|
||||
|
||||
qreal ascent() const {return _ascent;}
|
||||
qreal descent() const {return _descent;}
|
||||
qreal max() const {return bounds().bottom();}
|
||||
qreal min() const {return bounds().top();}
|
||||
void showTracks(bool show);
|
||||
void showRoutes(bool show);
|
||||
|
||||
private:
|
||||
enum Type {Track, Route};
|
||||
|
||||
qreal max() const;
|
||||
qreal min() const;
|
||||
qreal ascent() const;
|
||||
qreal descent() const;
|
||||
|
||||
void setXUnits();
|
||||
void setYUnits();
|
||||
void addInfo();
|
||||
void setInfo();
|
||||
|
||||
void loadPath(const QVector<QPointF> &data, Type type);
|
||||
|
||||
qreal _trackAscent, _trackDescent;
|
||||
qreal _routeAscent, _routeDescent;
|
||||
qreal _trackMax, _routeMax;
|
||||
qreal _trackMin, _routeMin;
|
||||
|
||||
qreal _ascent, _descent;
|
||||
enum Units _units;
|
||||
bool _showTracks, _showRoutes;
|
||||
};
|
||||
|
||||
#endif // ELEVATIONGRAPH_H
|
||||
|
174
src/exportdialog.cpp
Normal file
174
src/exportdialog.cpp
Normal file
@ -0,0 +1,174 @@
|
||||
#include <QVBoxLayout>
|
||||
#include <QHBoxLayout>
|
||||
#include <QFormLayout>
|
||||
#include <QGridLayout>
|
||||
#include <QDialogButtonBox>
|
||||
#include <QGroupBox>
|
||||
#include <QComboBox>
|
||||
#include <QRadioButton>
|
||||
#include <QPushButton>
|
||||
#include <QFileInfo>
|
||||
#include <QMessageBox>
|
||||
#include <QTabWidget>
|
||||
#include <QDoubleSpinBox>
|
||||
#include <QLocale>
|
||||
#include "fileselectwidget.h"
|
||||
#include "units.h"
|
||||
#include "exportdialog.h"
|
||||
|
||||
|
||||
ExportDialog::ExportDialog(QPrinter *printer, QWidget *parent)
|
||||
: QDialog(parent), _printer(printer)
|
||||
{
|
||||
int index;
|
||||
|
||||
_units = (QLocale::system().measurementSystem()
|
||||
== QLocale::ImperialSystem) ? QPrinter::Inch : QPrinter::Millimeter;
|
||||
|
||||
_fileSelect = new FileSelectWidget();
|
||||
_fileSelect->setFilter(tr("PDF files (*.pdf);;All files (*)"));
|
||||
_fileSelect->setFile(_printer->outputFileName());
|
||||
|
||||
_paperSize = new QComboBox();
|
||||
_paperSize->addItem("A3", QPrinter::A3);
|
||||
_paperSize->addItem("A4", QPrinter::A4);
|
||||
_paperSize->addItem("A5", QPrinter::A5);
|
||||
_paperSize->addItem("Tabloid", QPrinter::Tabloid);
|
||||
_paperSize->addItem("Legal", QPrinter::Legal);
|
||||
_paperSize->addItem("Letter", QPrinter::Letter);
|
||||
if ((index = _paperSize->findData(_printer->paperSize())) >= 0)
|
||||
_paperSize->setCurrentIndex(index);
|
||||
|
||||
_portrait = new QRadioButton(tr("Portrait"));
|
||||
_landscape = new QRadioButton(tr("Landscape"));
|
||||
QHBoxLayout *orientationLayout = new QHBoxLayout();
|
||||
orientationLayout->addWidget(_portrait);
|
||||
orientationLayout->addWidget(_landscape);
|
||||
if (_printer->orientation() == QPrinter::Portrait)
|
||||
_portrait->setChecked(true);
|
||||
else
|
||||
_landscape->setChecked(true);
|
||||
|
||||
qreal top, bottom, left, right;
|
||||
|
||||
_printer->getPageMargins(&left, &top, &right, &bottom, _units);
|
||||
QString us = _units == QPrinter::Inch ? tr("in") : tr("mm");
|
||||
_topMargin = new QDoubleSpinBox();
|
||||
_bottomMargin = new QDoubleSpinBox();
|
||||
_leftMargin = new QDoubleSpinBox();
|
||||
_rightMargin = new QDoubleSpinBox();
|
||||
_topMargin->setValue(top);
|
||||
_topMargin->setSuffix(UNIT_SPACE + us);
|
||||
_bottomMargin->setValue(bottom);
|
||||
_bottomMargin->setSuffix(UNIT_SPACE + us);
|
||||
_leftMargin->setValue(left);
|
||||
_leftMargin->setSuffix(UNIT_SPACE + us);
|
||||
_rightMargin->setValue(right);
|
||||
_rightMargin->setSuffix(UNIT_SPACE + us);
|
||||
if (_units == QPrinter::Inch) {
|
||||
_topMargin->setSingleStep(0.1);
|
||||
_bottomMargin->setSingleStep(0.1);
|
||||
_leftMargin->setSingleStep(0.1);
|
||||
_rightMargin->setSingleStep(0.1);
|
||||
}
|
||||
|
||||
QGridLayout *marginsLayout = new QGridLayout();
|
||||
marginsLayout->addWidget(_topMargin, 0, 0, 1, 2, Qt::AlignCenter);
|
||||
marginsLayout->addWidget(_leftMargin, 1, 0, 1, 1, Qt::AlignRight);
|
||||
marginsLayout->addWidget(_rightMargin, 1, 1, 1, 1, Qt::AlignLeft);
|
||||
marginsLayout->addWidget(_bottomMargin, 2, 0, 1, 2, Qt::AlignCenter);
|
||||
|
||||
#ifndef Q_OS_MAC
|
||||
QGroupBox *pageSetupBox = new QGroupBox(tr("Page Setup"));
|
||||
#endif // Q_OS_MAC
|
||||
QFormLayout *pageSetupLayout = new QFormLayout;
|
||||
pageSetupLayout->addRow(tr("Page size:"), _paperSize);
|
||||
pageSetupLayout->addRow(tr("Orientation:"), orientationLayout);
|
||||
pageSetupLayout->addRow(tr("Margins:"), marginsLayout);
|
||||
#ifdef Q_OS_MAC
|
||||
QFrame *line = new QFrame();
|
||||
line->setFrameShape(QFrame::HLine);
|
||||
line->setFrameShadow(QFrame::Sunken);
|
||||
pageSetupLayout->addRow(line);
|
||||
pageSetupLayout->addRow(tr("File:"), _fileSelect);
|
||||
#else // Q_OS_MAC
|
||||
pageSetupBox->setLayout(pageSetupLayout);
|
||||
#endif // Q_OS_MAC
|
||||
|
||||
#ifndef Q_OS_MAC
|
||||
QGroupBox *outputFileBox = new QGroupBox(tr("Output file"));
|
||||
QHBoxLayout *outputFileLayout = new QHBoxLayout();
|
||||
outputFileLayout->addWidget(_fileSelect);
|
||||
outputFileBox->setLayout(outputFileLayout);
|
||||
#endif // Q_OS_MAC
|
||||
|
||||
QDialogButtonBox *buttonBox = new QDialogButtonBox();
|
||||
buttonBox->addButton(tr("Export"), QDialogButtonBox::AcceptRole);
|
||||
buttonBox->addButton(QDialogButtonBox::Cancel);
|
||||
connect(buttonBox, SIGNAL(accepted()), this, SLOT(accept()));
|
||||
connect(buttonBox, SIGNAL(rejected()), this, SLOT(reject()));
|
||||
|
||||
QVBoxLayout *layout = new QVBoxLayout;
|
||||
#ifdef Q_OS_MAC
|
||||
layout->addLayout(pageSetupLayout);
|
||||
#else // Q_OS_MAC
|
||||
layout->addWidget(pageSetupBox);
|
||||
layout->addWidget(outputFileBox);
|
||||
#endif // Q_OS_MAC
|
||||
layout->addWidget(buttonBox);
|
||||
setLayout(layout);
|
||||
|
||||
setWindowTitle(tr("Export to PDF"));
|
||||
setWindowFlags(windowFlags() & ~Qt::WindowContextHelpButtonHint);
|
||||
}
|
||||
|
||||
bool ExportDialog::checkFile()
|
||||
{
|
||||
if (_fileSelect->file().isEmpty()) {
|
||||
QMessageBox::warning(this, tr("Error"), tr("No output file selected."));
|
||||
return false;
|
||||
}
|
||||
|
||||
QFile file(_fileSelect->file());
|
||||
QFileInfo fi(file);
|
||||
bool exists = fi.exists();
|
||||
bool opened = false;
|
||||
|
||||
if (exists && fi.isDir()) {
|
||||
QMessageBox::warning(this, tr("Error"), tr("%1 is a directory.")
|
||||
.arg(file.fileName()));
|
||||
return false;
|
||||
} else if ((exists && !fi.isWritable())
|
||||
|| !(opened = file.open(QFile::Append))) {
|
||||
QMessageBox::warning(this, tr("Error"), tr("%1 is not writable.")
|
||||
.arg(file.fileName()));
|
||||
return false;
|
||||
}
|
||||
if (opened) {
|
||||
file.close();
|
||||
if (!exists)
|
||||
file.remove();
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void ExportDialog::accept()
|
||||
{
|
||||
if (!checkFile())
|
||||
return;
|
||||
|
||||
QPrinter::Orientation orientation = _portrait->isChecked()
|
||||
? QPrinter::Portrait : QPrinter::Landscape;
|
||||
QPrinter::PaperSize paperSize = static_cast<QPrinter::PaperSize>
|
||||
(_paperSize->itemData(_paperSize->currentIndex()).toInt());
|
||||
|
||||
_printer->setOutputFormat(QPrinter::PdfFormat);
|
||||
_printer->setOutputFileName(_fileSelect->file());
|
||||
_printer->setPaperSize(paperSize);
|
||||
_printer->setOrientation(orientation);
|
||||
_printer->setPageMargins(_leftMargin->value(), _topMargin->value(),
|
||||
_rightMargin->value(), _bottomMargin->value(), _units);
|
||||
|
||||
QDialog::accept();
|
||||
}
|
39
src/exportdialog.h
Normal file
39
src/exportdialog.h
Normal file
@ -0,0 +1,39 @@
|
||||
#ifndef EXPORTDIALOG_H
|
||||
#define EXPORTDIALOG_H
|
||||
|
||||
#include <QDialog>
|
||||
#include <QPrinter>
|
||||
|
||||
class QComboBox;
|
||||
class QRadioButton;
|
||||
class FileSelectWidget;
|
||||
class QDoubleSpinBox;
|
||||
|
||||
class ExportDialog : public QDialog
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
ExportDialog(QPrinter *printer, QWidget *parent = 0);
|
||||
|
||||
public slots:
|
||||
void accept();
|
||||
|
||||
private:
|
||||
bool checkFile();
|
||||
|
||||
QPrinter *_printer;
|
||||
|
||||
QPrinter::Unit _units;
|
||||
|
||||
FileSelectWidget *_fileSelect;
|
||||
QComboBox *_paperSize;
|
||||
QRadioButton *_portrait;
|
||||
QRadioButton *_landscape;
|
||||
QDoubleSpinBox *_topMargin;
|
||||
QDoubleSpinBox *_bottomMargin;
|
||||
QDoubleSpinBox *_leftMargin;
|
||||
QDoubleSpinBox *_rightMargin;
|
||||
};
|
||||
|
||||
#endif // EXPORTDIALOG_H
|
33
src/fileselectwidget.cpp
Normal file
33
src/fileselectwidget.cpp
Normal file
@ -0,0 +1,33 @@
|
||||
#include <QPushButton>
|
||||
#include <QFileDialog>
|
||||
#include <QHBoxLayout>
|
||||
#include <QFileInfo>
|
||||
#include <QApplication>
|
||||
#include <QFontMetrics>
|
||||
#include "fileselectwidget.h"
|
||||
|
||||
|
||||
FileSelectWidget::FileSelectWidget(QWidget *parent) : QWidget(parent)
|
||||
{
|
||||
QFontMetrics fm(QApplication::font());
|
||||
_edit = new QLineEdit();
|
||||
_edit->setMinimumWidth(fm.boundingRect(QDir::homePath()).width());
|
||||
_button = new QPushButton(tr("Browse..."));
|
||||
connect(_button, SIGNAL(clicked()), this, SLOT(browse()));
|
||||
|
||||
QHBoxLayout *layout = new QHBoxLayout();
|
||||
layout->setMargin(0);
|
||||
layout->addWidget(_edit);
|
||||
layout->addWidget(_button);
|
||||
setLayout(layout);
|
||||
}
|
||||
|
||||
void FileSelectWidget::browse()
|
||||
{
|
||||
QFileInfo fi(_edit->text());
|
||||
QString fileName = QFileDialog::getSaveFileName(this, tr("Select file"),
|
||||
fi.dir().absolutePath(), _filter);
|
||||
|
||||
if (!fileName.isEmpty())
|
||||
_edit->setText(fileName);
|
||||
}
|
30
src/fileselectwidget.h
Normal file
30
src/fileselectwidget.h
Normal file
@ -0,0 +1,30 @@
|
||||
#ifndef FILESELECTWIDGET_H
|
||||
#define FILESELECTWIDGET_H
|
||||
|
||||
#include <QWidget>
|
||||
#include <QLineEdit>
|
||||
|
||||
class QPushButton;
|
||||
|
||||
class FileSelectWidget : public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
FileSelectWidget(QWidget *parent = 0);
|
||||
|
||||
QString file() {return _edit->text();}
|
||||
void setFile(const QString &file) {_edit->setText(file);}
|
||||
void setFilter(const QString &filter) {_filter = filter;}
|
||||
|
||||
private slots:
|
||||
void browse();
|
||||
|
||||
private:
|
||||
QLineEdit *_edit;
|
||||
QPushButton *_button;
|
||||
|
||||
QString _filter;
|
||||
};
|
||||
|
||||
#endif // FILESELECTWIDGET_H
|
29
src/gpx.cpp
29
src/gpx.cpp
@ -4,12 +4,24 @@
|
||||
#include "gpx.h"
|
||||
|
||||
|
||||
GPX::GPX() : _parser(_track_data, _route_data, _waypoint_data), _errorLine(0)
|
||||
{
|
||||
}
|
||||
|
||||
GPX::~GPX()
|
||||
{
|
||||
for (int i = 0; i < _tracks.count(); i++)
|
||||
delete _tracks.at(i);
|
||||
for (int i = 0; i < _routes.count(); i++)
|
||||
delete _routes.at(i);
|
||||
}
|
||||
|
||||
bool GPX::loadFile(const QString &fileName)
|
||||
{
|
||||
QFile file(fileName);
|
||||
bool ret;
|
||||
QFile file(fileName);
|
||||
|
||||
|
||||
_tracks.clear();
|
||||
_error.clear();
|
||||
_errorLine = 0;
|
||||
|
||||
@ -18,11 +30,18 @@ bool GPX::loadFile(const QString &fileName)
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!(ret = _parser.loadFile(&file))) {
|
||||
ret = _parser.loadFile(&file);
|
||||
file.close();
|
||||
if (ret == false) {
|
||||
_error = _parser.errorString();
|
||||
_errorLine = _parser.errorLine();
|
||||
return false;
|
||||
}
|
||||
file.close();
|
||||
|
||||
return ret;
|
||||
for (int i = 0; i < _track_data.count(); i++)
|
||||
_tracks.append(new Track(_track_data.at(i)));
|
||||
for (int i = 0; i < _route_data.count(); i++)
|
||||
_routes.append(new Route(_route_data.at(i)));
|
||||
|
||||
return true;
|
||||
}
|
||||
|
19
src/gpx.h
19
src/gpx.h
@ -7,27 +7,34 @@
|
||||
#include <QString>
|
||||
#include "waypoint.h"
|
||||
#include "track.h"
|
||||
#include "route.h"
|
||||
#include "parser.h"
|
||||
|
||||
class GPX
|
||||
{
|
||||
public:
|
||||
GPX() : _parser(_tracks, _waypoints), _errorLine(0) {}
|
||||
GPX();
|
||||
~GPX();
|
||||
|
||||
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<Track*> &tracks() const {return _tracks;}
|
||||
const QList<Route*> &routes() const {return _routes;}
|
||||
const QList<Waypoint> &waypoints() const {return _waypoint_data;}
|
||||
|
||||
private:
|
||||
Parser _parser;
|
||||
QString _error;
|
||||
int _errorLine;
|
||||
|
||||
QList<QVector<Trackpoint> > _tracks;
|
||||
QList<Waypoint> _waypoints;
|
||||
QList<Track*> _tracks;
|
||||
QList<Route*> _routes;
|
||||
|
||||
QList<QVector<Trackpoint> > _track_data;
|
||||
QList<QVector<Waypoint> > _route_data;
|
||||
QList<Waypoint> _waypoint_data;
|
||||
};
|
||||
|
||||
#endif // GPX_H
|
||||
|
10
src/graphitem.cpp
Normal file
10
src/graphitem.cpp
Normal file
@ -0,0 +1,10 @@
|
||||
#include <QBrush>
|
||||
#include <QPen>
|
||||
#include "graphitem.h"
|
||||
|
||||
void GraphItem::setColor(const QColor &color)
|
||||
{
|
||||
QBrush brush(color, Qt::SolidPattern);
|
||||
QPen pen(brush, 0);
|
||||
setPen(pen);
|
||||
}
|
20
src/graphitem.h
Normal file
20
src/graphitem.h
Normal file
@ -0,0 +1,20 @@
|
||||
#ifndef GRAPHITEM_H
|
||||
#define GRAPHITEM_H
|
||||
|
||||
#include <QGraphicsPathItem>
|
||||
|
||||
class GraphItem : public QGraphicsPathItem
|
||||
{
|
||||
public:
|
||||
GraphItem(const QPainterPath &path, QGraphicsItem * parent = 0)
|
||||
: QGraphicsPathItem(path, parent) {_id = 0;}
|
||||
|
||||
int id() const {return _id;}
|
||||
void setId(int id) {_id = id;}
|
||||
void setColor(const QColor &color);
|
||||
|
||||
private:
|
||||
int _id;
|
||||
};
|
||||
|
||||
#endif // GRAPHITEM_H
|
25
src/graphtab.h
Normal file
25
src/graphtab.h
Normal file
@ -0,0 +1,25 @@
|
||||
#ifndef GRAPHTAB_H
|
||||
#define GRAPHTAB_H
|
||||
|
||||
#include "graphview.h"
|
||||
#include "units.h"
|
||||
|
||||
class GPX;
|
||||
|
||||
class GraphTab : public GraphView
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
GraphTab(QWidget *parent = 0) : GraphView(parent)
|
||||
{setFrameShape(QFrame::NoFrame);}
|
||||
|
||||
virtual QString label() const = 0;
|
||||
virtual void loadGPX(const GPX &gpx) = 0;
|
||||
virtual void clear() = 0;
|
||||
virtual void setUnits(enum Units units) = 0;
|
||||
virtual void showTracks(bool show) = 0;
|
||||
virtual void showRoutes(bool show) = 0;
|
||||
};
|
||||
|
||||
#endif // GRAPHTAB_H
|
@ -1,17 +1,19 @@
|
||||
#include <QGraphicsView>
|
||||
#include <QGraphicsSceneMouseEvent>
|
||||
#include <QEvent>
|
||||
#include <QGraphicsSimpleTextItem>
|
||||
#include <QPaintEngine>
|
||||
#include <QPaintDevice>
|
||||
#include "config.h"
|
||||
#include "axisitem.h"
|
||||
#include "slideritem.h"
|
||||
#include "sliderinfoitem.h"
|
||||
#include "infoitem.h"
|
||||
#include "graphitem.h"
|
||||
#include "graphview.h"
|
||||
|
||||
|
||||
#define MARGIN 10.0
|
||||
|
||||
|
||||
void Scene::mousePressEvent(QGraphicsSceneMouseEvent *e)
|
||||
{
|
||||
if (e->button() == Qt::LeftButton)
|
||||
@ -32,22 +34,20 @@ GraphView::GraphView(QWidget *parent)
|
||||
|
||||
_xAxis = new AxisItem(AxisItem::X);
|
||||
_yAxis = new AxisItem(AxisItem::Y);
|
||||
|
||||
_slider = new SliderItem();
|
||||
_slider->setZValue(2.0);
|
||||
_sliderInfo = new SliderInfoItem(_slider);
|
||||
_sliderInfo->setZValue(2.0);
|
||||
_info = new InfoItem();
|
||||
|
||||
connect(_slider, SIGNAL(positionChanged(const QPointF&)), this,
|
||||
SLOT(emitSliderPositionChanged(const QPointF&)));
|
||||
connect(_scene, SIGNAL(mouseClicked(const QPointF&)), this,
|
||||
SLOT(newSliderPosition(const QPointF&)));
|
||||
|
||||
_info = new InfoItem();
|
||||
|
||||
_sliderInfo = new SliderInfoItem(_slider);
|
||||
_sliderInfo->setZValue(2.0);
|
||||
|
||||
_xScale = 1;
|
||||
_yScale = 1;
|
||||
_yOffset = 0;
|
||||
|
||||
_precision = 0;
|
||||
_minYRange = 0.01;
|
||||
@ -61,26 +61,14 @@ GraphView::~GraphView()
|
||||
delete _xAxis;
|
||||
if (_yAxis->scene() != _scene)
|
||||
delete _yAxis;
|
||||
|
||||
if (_slider->scene() != _scene)
|
||||
delete _slider;
|
||||
|
||||
if (_info->scene() != _scene)
|
||||
delete _info;
|
||||
|
||||
delete _scene;
|
||||
}
|
||||
|
||||
void GraphView::updateBounds(const QPointF &point)
|
||||
{
|
||||
if (point.x() < _bounds.left())
|
||||
_bounds.setLeft(point.x());
|
||||
if (point.x() > _bounds.right())
|
||||
_bounds.setRight(point.x());
|
||||
if (point.y() > _bounds.bottom())
|
||||
_bounds.setBottom(point.y());
|
||||
if (point.y() < _bounds.top())
|
||||
_bounds.setTop(point.y());
|
||||
for (int i = 0; i < _graphs.count(); i++)
|
||||
if (_graphs.at(i)->scene() != _scene)
|
||||
delete _graphs[i];
|
||||
}
|
||||
|
||||
void GraphView::createXLabel()
|
||||
@ -117,48 +105,87 @@ void GraphView::setYUnits(const QString &units)
|
||||
createYLabel();
|
||||
}
|
||||
|
||||
void GraphView::setXScale(qreal scale)
|
||||
{
|
||||
_xScale = scale;
|
||||
}
|
||||
|
||||
void GraphView::setYScale(qreal scale)
|
||||
{
|
||||
_yScale = scale;
|
||||
}
|
||||
|
||||
void GraphView::loadData(const QVector<QPointF> &data)
|
||||
void GraphView::loadData(const QVector<QPointF> &data, int id)
|
||||
{
|
||||
QPainterPath path;
|
||||
QGraphicsPathItem *pi;
|
||||
GraphItem *pi;
|
||||
|
||||
|
||||
if (data.size() < 2)
|
||||
return;
|
||||
|
||||
if (!_graphs.size())
|
||||
_bounds.moveTo(data.at(0));
|
||||
|
||||
updateBounds(data.at(0));
|
||||
path.moveTo(data.at(0).x(), -data.at(0).y());
|
||||
for (int i = 1; i < data.size(); i++) {
|
||||
const QPointF &p = data.at(i);
|
||||
path.lineTo(p.x(), -p.y());
|
||||
updateBounds(p);
|
||||
}
|
||||
|
||||
pi = new QGraphicsPathItem(path);
|
||||
QBrush brush(_palette.color(), Qt::SolidPattern);
|
||||
QPen pen(brush, 0);
|
||||
pi->setPen(pen);
|
||||
_scene->addItem(pi);
|
||||
pi = new GraphItem(path);
|
||||
pi->setId(id);
|
||||
pi->setColor(_palette.color());
|
||||
|
||||
_graphs.append(pi);
|
||||
|
||||
if (!_hide.contains(id)) {
|
||||
_visible.append(pi);
|
||||
_scene->addItem(pi);
|
||||
updateBounds(path);
|
||||
}
|
||||
}
|
||||
|
||||
void GraphView::removeItem(QGraphicsItem *item)
|
||||
{
|
||||
if (item->scene() == _scene)
|
||||
_scene->removeItem(item);
|
||||
}
|
||||
|
||||
void GraphView::addItem(QGraphicsItem *item)
|
||||
{
|
||||
if (item->scene() != _scene)
|
||||
_scene->addItem(item);
|
||||
}
|
||||
|
||||
void GraphView::showGraph(bool show, int id)
|
||||
{
|
||||
if (show)
|
||||
_hide.remove(id);
|
||||
else
|
||||
_hide.insert(id);
|
||||
|
||||
_visible.clear();
|
||||
_bounds = QRectF();
|
||||
for (int i = 0; i < _graphs.count(); i++) {
|
||||
GraphItem* gi = _graphs.at(i);
|
||||
if (_hide.contains(gi->id()))
|
||||
removeItem(gi);
|
||||
else {
|
||||
addItem(gi);
|
||||
_visible.append(gi);
|
||||
updateBounds(gi->path());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void GraphView::redraw()
|
||||
{
|
||||
if (!_graphs.isEmpty())
|
||||
redraw(viewport()->size() - QSizeF(MARGIN, MARGIN));
|
||||
redraw(viewport()->size() - QSizeF(MARGIN, MARGIN));
|
||||
}
|
||||
|
||||
void GraphView::updateBounds(const QPainterPath &path)
|
||||
{
|
||||
QRectF br = path.boundingRect();
|
||||
br.moveTopLeft(QPointF(br.left(), -br.top() - br.height()));
|
||||
_bounds |= br;
|
||||
}
|
||||
|
||||
QRectF GraphView::graphsBoundingRect() const
|
||||
{
|
||||
QRectF rect;
|
||||
|
||||
for (int i = 0; i < _visible.count(); i++)
|
||||
rect |= _visible.at(i)->boundingRect();
|
||||
|
||||
return rect;
|
||||
}
|
||||
|
||||
void GraphView::redraw(const QSizeF &size)
|
||||
@ -170,20 +197,23 @@ void GraphView::redraw(const QSizeF &size)
|
||||
qreal xs, ys;
|
||||
|
||||
|
||||
if (_xAxis->scene() == _scene)
|
||||
_scene->removeItem(_xAxis);
|
||||
if (_yAxis->scene() == _scene)
|
||||
_scene->removeItem(_yAxis);
|
||||
if (_slider->scene() == _scene)
|
||||
_scene->removeItem(_slider);
|
||||
if (_info->scene() == _scene)
|
||||
_scene->removeItem(_info);
|
||||
if (_visible.isEmpty()) {
|
||||
removeItem(_xAxis);
|
||||
removeItem(_yAxis);
|
||||
removeItem(_slider);
|
||||
removeItem(_info);
|
||||
_scene->setSceneRect(QRectF());
|
||||
return;
|
||||
}
|
||||
|
||||
for (int i = 0; i < _graphs.size(); i++)
|
||||
_graphs.at(i)->resetTransform();
|
||||
addItem(_xAxis);
|
||||
addItem(_yAxis);
|
||||
addItem(_slider);
|
||||
addItem(_info);
|
||||
|
||||
rx = RangeF(_bounds.left() * _xScale, _bounds.right() * _xScale);
|
||||
ry = RangeF(_bounds.top() * _yScale, _bounds.bottom() * _yScale);
|
||||
ry = RangeF(_bounds.top() * _yScale + _yOffset, _bounds.bottom() * _yScale
|
||||
+ _yOffset);
|
||||
if (ry.size() < _minYRange)
|
||||
ry.resize(_minYRange);
|
||||
|
||||
@ -192,7 +222,7 @@ void GraphView::redraw(const QSizeF &size)
|
||||
mx = _xAxis->margin();
|
||||
my = _yAxis->margin();
|
||||
|
||||
r = _scene->itemsBoundingRect();
|
||||
r = graphsBoundingRect();
|
||||
if (r.height() < _minYRange)
|
||||
r.adjust(0, -(_minYRange/2 - r.height()/2), 0,
|
||||
_minYRange/2 - r.height()/2);
|
||||
@ -202,10 +232,12 @@ void GraphView::redraw(const QSizeF &size)
|
||||
- _info->boundingRect().height()) / r.height();
|
||||
transform.scale(xs, ys);
|
||||
|
||||
for (int i = 0; i < _graphs.size(); i++)
|
||||
_graphs.at(i)->setTransform(transform);
|
||||
for (int i = 0; i < _visible.size(); i++)
|
||||
_visible.at(i)->setTransform(transform);
|
||||
|
||||
r = _scene->itemsBoundingRect();
|
||||
QPointF p(r.left() * xs, r.top() * ys);
|
||||
QSizeF s(r.width() * xs, r.height() * ys);
|
||||
r = QRectF(p, s);
|
||||
if (r.height() < _minYRange * ys)
|
||||
r.adjust(0, -(_minYRange/2 * ys - r.height()/2), 0,
|
||||
(_minYRange/2) * ys - r.height()/2);
|
||||
@ -214,60 +246,49 @@ void GraphView::redraw(const QSizeF &size)
|
||||
_yAxis->setSize(r.height());
|
||||
_xAxis->setPos(r.bottomLeft());
|
||||
_yAxis->setPos(r.bottomLeft());
|
||||
_scene->addItem(_xAxis);
|
||||
_scene->addItem(_yAxis);
|
||||
|
||||
_slider->setArea(r);
|
||||
_slider->setPos((_sliderPos / _bounds.width()) * _slider->area().width(),
|
||||
r.bottom());
|
||||
_scene->addItem(_slider);
|
||||
updateSliderPosition();
|
||||
|
||||
updateSliderInfo();
|
||||
|
||||
r = _scene->itemsBoundingRect();
|
||||
r |= _xAxis->sceneBoundingRect();
|
||||
r |= _yAxis->sceneBoundingRect();
|
||||
_info->setPos(r.topLeft() + QPointF(r.width()/2
|
||||
- _info->boundingRect().width()/2, -_info->boundingRect().height()));
|
||||
_scene->addItem(_info);
|
||||
|
||||
_scene->setSceneRect(_scene->itemsBoundingRect());
|
||||
}
|
||||
|
||||
void GraphView::resizeEvent(QResizeEvent *)
|
||||
{
|
||||
if (!_graphs.empty())
|
||||
redraw();
|
||||
redraw();
|
||||
}
|
||||
|
||||
void GraphView::plot(QPainter *painter, const QRectF &target)
|
||||
{
|
||||
qreal ratio = target.width() / target.height();
|
||||
QSizeF orig = _scene->sceneRect().size();
|
||||
QSizeF canvas = QSizeF(orig.height() * ratio, orig.height());
|
||||
qreal ratio = painter->paintEngine()->paintDevice()->logicalDpiX()
|
||||
/ SCREEN_DPI;
|
||||
QSizeF canvas = QSizeF(target.width() / ratio, target.height() / ratio);
|
||||
|
||||
setUpdatesEnabled(false);
|
||||
redraw(canvas);
|
||||
_slider->hide();
|
||||
_info->hide();
|
||||
_scene->render(painter, target, QRectF());
|
||||
if (_slider->pos().x() == _slider->area().left())
|
||||
_slider->hide();
|
||||
_scene->render(painter, target);
|
||||
_slider->show();
|
||||
_info->show();
|
||||
redraw(orig);
|
||||
redraw();
|
||||
setUpdatesEnabled(true);
|
||||
}
|
||||
|
||||
void GraphView::clear()
|
||||
{
|
||||
if (_xAxis->scene() == _scene)
|
||||
_scene->removeItem(_xAxis);
|
||||
if (_yAxis->scene() == _scene)
|
||||
_scene->removeItem(_yAxis);
|
||||
if (_slider->scene() == _scene)
|
||||
_scene->removeItem(_slider);
|
||||
if (_info->scene() == _scene)
|
||||
_scene->removeItem(_info);
|
||||
|
||||
_slider->clear();
|
||||
_info->clear();
|
||||
_scene->clear();
|
||||
|
||||
for (int i = 0; i < _graphs.count(); i++)
|
||||
delete _graphs[i];
|
||||
|
||||
_graphs.clear();
|
||||
_visible.clear();
|
||||
_palette.reset();
|
||||
|
||||
_bounds = QRectF();
|
||||
@ -307,14 +328,30 @@ static qreal yAtX(const QPainterPath &path, qreal x)
|
||||
return l.pointAt((x - l.p1().x()) / (l.p2().x() - l.p1().x())).y();
|
||||
}
|
||||
|
||||
void GraphView::updateSliderInfo()
|
||||
void GraphView::updateSliderPosition()
|
||||
{
|
||||
_sliderInfo->setVisible(_graphs.size() == 1);
|
||||
|
||||
if (_graphs.size() != 1)
|
||||
if (_bounds.width() <= 0)
|
||||
return;
|
||||
|
||||
const QPainterPath &path = _graphs.at(0)->path();
|
||||
if (_sliderPos <= _bounds.right() && _sliderPos >= _bounds.left()) {
|
||||
_slider->setPos((_sliderPos / _bounds.width()) * _slider->area().width(),
|
||||
_slider->area().bottom());
|
||||
_slider->setVisible(!_visible.isEmpty());
|
||||
} else {
|
||||
_slider->setPos(_slider->area().left(), _slider->area().bottom());
|
||||
_slider->setVisible(false);
|
||||
}
|
||||
|
||||
updateSliderInfo();
|
||||
}
|
||||
|
||||
void GraphView::updateSliderInfo()
|
||||
{
|
||||
_sliderInfo->setVisible(_visible.count() == 1);
|
||||
if (!_sliderInfo->isVisible())
|
||||
return;
|
||||
|
||||
const QPainterPath &path = _visible.first()->path();
|
||||
QRectF br = path.boundingRect();
|
||||
if (br.height() < _minYRange)
|
||||
br.adjust(0, -(_minYRange/2 - br.height()/2), 0,
|
||||
@ -329,42 +366,34 @@ void GraphView::updateSliderInfo()
|
||||
|
||||
_sliderInfo->setSide(s);
|
||||
_sliderInfo->setPos(QPointF(0, _slider->boundingRect().height() * r));
|
||||
_sliderInfo->setText(QString::number(-y * _yScale, 'f', _precision));
|
||||
_sliderInfo->setText(QString::number(-y * _yScale + _yOffset, 'f',
|
||||
_precision));
|
||||
}
|
||||
|
||||
void GraphView::emitSliderPositionChanged(const QPointF &pos)
|
||||
{
|
||||
if (_graphs.isEmpty())
|
||||
if (_slider->area().width() <= 0)
|
||||
return;
|
||||
|
||||
_sliderPos = (pos.x() / _slider->area().width()) * _bounds.width();
|
||||
emit sliderPositionChanged(_sliderPos);
|
||||
updateSliderPosition();
|
||||
|
||||
updateSliderInfo();
|
||||
emit sliderPositionChanged(_sliderPos);
|
||||
}
|
||||
|
||||
void GraphView::setSliderPosition(qreal pos)
|
||||
{
|
||||
_sliderPos = pos;
|
||||
|
||||
if (_graphs.isEmpty())
|
||||
if (_visible.isEmpty())
|
||||
return;
|
||||
|
||||
if (pos > _bounds.right() || pos < _bounds.left())
|
||||
_slider->setVisible(false);
|
||||
else {
|
||||
_slider->setPos((pos / _bounds.width()) * _slider->area().width(), 0);
|
||||
_slider->setVisible(true);
|
||||
}
|
||||
_sliderPos = pos;
|
||||
updateSliderPosition();
|
||||
}
|
||||
|
||||
void GraphView::newSliderPosition(const QPointF &pos)
|
||||
{
|
||||
if (_slider->area().contains(pos)) {
|
||||
if (_slider->area().contains(pos))
|
||||
_slider->setPos(pos);
|
||||
_slider->setVisible(true);
|
||||
emitSliderPositionChanged(pos);
|
||||
}
|
||||
}
|
||||
|
||||
void GraphView::addInfo(const QString &key, const QString &value)
|
||||
|
@ -5,14 +5,15 @@
|
||||
#include <QGraphicsScene>
|
||||
#include <QVector>
|
||||
#include <QList>
|
||||
#include <QSet>
|
||||
#include <QPointF>
|
||||
#include "palette.h"
|
||||
|
||||
|
||||
class AxisItem;
|
||||
class SliderItem;
|
||||
class SliderInfoItem;
|
||||
class InfoItem;
|
||||
class GraphItem;
|
||||
|
||||
class Scene : public QGraphicsScene
|
||||
{
|
||||
@ -34,12 +35,12 @@ public:
|
||||
GraphView(QWidget *parent = 0);
|
||||
~GraphView();
|
||||
|
||||
void loadData(const QVector<QPointF> &data);
|
||||
|
||||
void loadData(const QVector<QPointF> &data, int id = 0);
|
||||
int count() const {return _graphs.count();}
|
||||
void redraw();
|
||||
void clear();
|
||||
|
||||
int count() const {return _graphs.count();}
|
||||
void showGraph(bool show, int id = 0);
|
||||
|
||||
const QString &xLabel() const {return _xLabel;}
|
||||
const QString &yLabel() const {return _yLabel;}
|
||||
@ -47,13 +48,15 @@ public:
|
||||
const QString &yUnits() const {return _yUnits;}
|
||||
qreal xScale() const {return _xScale;}
|
||||
qreal yScale() const {return _yScale;}
|
||||
qreal yOffset() const {return _yOffset;}
|
||||
|
||||
void setXLabel(const QString &label);
|
||||
void setYLabel(const QString &label);
|
||||
void setXUnits(const QString &units);
|
||||
void setYUnits(const QString &units);
|
||||
void setXScale(qreal scale);
|
||||
void setYScale(qreal scale);
|
||||
void setXScale(qreal scale) {_xScale = scale;}
|
||||
void setYScale(qreal scale) {_yScale = scale;}
|
||||
void setYOffset(qreal offset) {_yOffset = offset;}
|
||||
|
||||
void setSliderPrecision(int precision) {_precision = precision;}
|
||||
void setMinYRange(qreal range) {_minYRange = range;}
|
||||
@ -68,11 +71,11 @@ signals:
|
||||
|
||||
protected:
|
||||
const QRectF &bounds() const {return _bounds;}
|
||||
void resizeEvent(QResizeEvent *);
|
||||
void redraw(const QSizeF &size);
|
||||
void addInfo(const QString &key, const QString &value);
|
||||
void clearInfo();
|
||||
void skipColor() {_palette.color();}
|
||||
void resizeEvent(QResizeEvent *);
|
||||
|
||||
private slots:
|
||||
void emitSliderPositionChanged(const QPointF &pos);
|
||||
@ -81,10 +84,15 @@ private slots:
|
||||
private:
|
||||
void createXLabel();
|
||||
void createYLabel();
|
||||
void updateBounds(const QPointF &point);
|
||||
void updateSliderPosition();
|
||||
void updateSliderInfo();
|
||||
void updateBounds(const QPainterPath &path);
|
||||
QRectF graphsBoundingRect() const;
|
||||
void removeItem(QGraphicsItem *item);
|
||||
void addItem(QGraphicsItem *item);
|
||||
|
||||
qreal _xScale, _yScale;
|
||||
qreal _yOffset;
|
||||
QString _xUnits, _yUnits;
|
||||
QString _xLabel, _yLabel;
|
||||
int _precision;
|
||||
@ -98,7 +106,9 @@ private:
|
||||
SliderInfoItem *_sliderInfo;
|
||||
InfoItem *_info;
|
||||
|
||||
QList<QGraphicsPathItem*> _graphs;
|
||||
QList<GraphItem*> _graphs;
|
||||
QList<GraphItem*> _visible;
|
||||
QSet<int> _hide;
|
||||
QRectF _bounds;
|
||||
Palette _palette;
|
||||
};
|
||||
|
610
src/gui.cpp
610
src/gui.cpp
@ -4,8 +4,10 @@
|
||||
#include <QStatusBar>
|
||||
#include <QMessageBox>
|
||||
#include <QFileDialog>
|
||||
#include <QPrinter>
|
||||
#include <QPrintDialog>
|
||||
#include <QPainter>
|
||||
#include <QPaintEngine>
|
||||
#include <QPaintDevice>
|
||||
#include <QKeyEvent>
|
||||
#include <QSignalMapper>
|
||||
#include <QMenu>
|
||||
@ -15,6 +17,7 @@
|
||||
#include <QAction>
|
||||
#include <QLabel>
|
||||
#include <QSettings>
|
||||
#include <QLocale>
|
||||
#include "config.h"
|
||||
#include "icons.h"
|
||||
#include "keys.h"
|
||||
@ -25,51 +28,28 @@
|
||||
#include "elevationgraph.h"
|
||||
#include "speedgraph.h"
|
||||
#include "heartrategraph.h"
|
||||
#include "temperaturegraph.h"
|
||||
#include "trackview.h"
|
||||
#include "infoitem.h"
|
||||
#include "trackinfo.h"
|
||||
#include "filebrowser.h"
|
||||
#include "cpuarch.h"
|
||||
#include "exportdialog.h"
|
||||
#include "graphtab.h"
|
||||
#include "misc.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;
|
||||
|
||||
h = time / 3600;
|
||||
m = (time - (h * 3600)) / 60;
|
||||
s = time - (h * 3600) - (m * 60);
|
||||
|
||||
return QString("%1:%2:%3").arg(h).arg(m, 2, 10, QChar('0'))
|
||||
.arg(s, 2, 10, QChar('0'));
|
||||
}
|
||||
|
||||
|
||||
GUI::GUI(QWidget *parent) : QMainWindow(parent)
|
||||
{
|
||||
loadMaps();
|
||||
loadPOIs();
|
||||
|
||||
createActions();
|
||||
createMenus();
|
||||
createToolBars();
|
||||
createTrackView();
|
||||
createTrackGraphs();
|
||||
createStatusBar();
|
||||
|
||||
connect(_elevationGraph, SIGNAL(sliderPositionChanged(qreal)), this,
|
||||
SLOT(sliderPositionChanged(qreal)));
|
||||
connect(_speedGraph, SIGNAL(sliderPositionChanged(qreal)), this,
|
||||
SLOT(sliderPositionChanged(qreal)));
|
||||
connect(_heartRateGraph, SIGNAL(sliderPositionChanged(qreal)), this,
|
||||
SLOT(sliderPositionChanged(qreal)));
|
||||
createActions();
|
||||
createMenus();
|
||||
createToolBars();
|
||||
|
||||
_browser = new FileBrowser(this);
|
||||
_browser->setFilter(QStringList("*.gpx"));
|
||||
@ -90,16 +70,34 @@ GUI::GUI(QWidget *parent) : QMainWindow(parent)
|
||||
setWindowTitle(APP_NAME);
|
||||
setUnifiedTitleAndToolBarOnMac(true);
|
||||
|
||||
_distance = 0;
|
||||
_time = 0;
|
||||
_trackCount = 0;
|
||||
_routeCount = 0;
|
||||
_waypointCount = 0;
|
||||
_trackDistance = 0;
|
||||
_routeDistance = 0;
|
||||
_time = 0;
|
||||
|
||||
_sliderPos = 0;
|
||||
|
||||
updateGraphTabs();
|
||||
updateTrackView();
|
||||
updateStatusBarInfo();
|
||||
|
||||
readSettings();
|
||||
|
||||
_exportPaperSize = (QLocale::system().measurementSystem()
|
||||
== QLocale::ImperialSystem) ? QPrinter::Letter : QPrinter::A4;
|
||||
_exportOrientation = QPrinter::Portrait;
|
||||
_exportFileName = QString("%1/export.pdf").arg(QDir::currentPath());
|
||||
_exportMargins = MarginsF(5.0, 5.0, 5.0, 5.0);
|
||||
}
|
||||
|
||||
GUI::~GUI()
|
||||
{
|
||||
for (int i = 0; i < _tabs.size(); i++) {
|
||||
if (_trackGraphs->indexOf(_tabs.at(i)) < 0)
|
||||
delete _tabs.at(i);
|
||||
}
|
||||
}
|
||||
|
||||
void GUI::loadMaps()
|
||||
@ -195,24 +193,23 @@ void GUI::createActions()
|
||||
tr("About GPXSee"), this);
|
||||
connect(_aboutAction, SIGNAL(triggered()), this, SLOT(about()));
|
||||
|
||||
// File related actions
|
||||
// File actions
|
||||
_openFileAction = new QAction(QIcon(QPixmap(OPEN_FILE_ICON)),
|
||||
tr("Open"), this);
|
||||
_openFileAction->setShortcut(OPEN_SHORTCUT);
|
||||
connect(_openFileAction, SIGNAL(triggered()), this, SLOT(openFile()));
|
||||
addAction(_openFileAction);
|
||||
_saveFileAction = new QAction(QIcon(QPixmap(SAVE_FILE_ICON)),
|
||||
tr("Save"), this);
|
||||
_saveFileAction->setShortcut(SAVE_SHORTCUT);
|
||||
_saveFileAction->setActionGroup(_fileActionGroup);
|
||||
connect(_saveFileAction, SIGNAL(triggered()), this, SLOT(saveFile()));
|
||||
addAction(_saveFileAction);
|
||||
_saveAsAction = new QAction(QIcon(QPixmap(SAVE_AS_ICON)),
|
||||
tr("Save as"), this);
|
||||
_saveAsAction->setShortcut(SAVE_AS_SHORTCUT);
|
||||
_saveAsAction->setActionGroup(_fileActionGroup);
|
||||
connect(_saveAsAction, SIGNAL(triggered()), this, SLOT(saveAs()));
|
||||
addAction(_saveAsAction);
|
||||
_printFileAction = new QAction(QIcon(QPixmap(PRINT_FILE_ICON)),
|
||||
tr("Print..."), this);
|
||||
_printFileAction->setActionGroup(_fileActionGroup);
|
||||
connect(_printFileAction, SIGNAL(triggered()), this, SLOT(printFile()));
|
||||
addAction(_printFileAction);
|
||||
_exportFileAction = new QAction(QIcon(QPixmap(EXPORT_FILE_ICON)),
|
||||
tr("Export to PDF..."), this);
|
||||
_exportFileAction->setShortcut(EXPORT_SHORTCUT);
|
||||
_exportFileAction->setActionGroup(_fileActionGroup);
|
||||
connect(_exportFileAction, SIGNAL(triggered()), this, SLOT(exportFile()));
|
||||
addAction(_exportFileAction);
|
||||
_closeFileAction = new QAction(QIcon(QPixmap(CLOSE_FILE_ICON)),
|
||||
tr("Close"), this);
|
||||
_closeFileAction->setShortcut(CLOSE_SHORTCUT);
|
||||
@ -233,6 +230,14 @@ void GUI::createActions()
|
||||
_closePOIAction = new QAction(QIcon(QPixmap(CLOSE_FILE_ICON)),
|
||||
tr("Close POI files"), this);
|
||||
connect(_closePOIAction, SIGNAL(triggered()), this, SLOT(closePOIFiles()));
|
||||
_overlapPOIAction = new QAction(tr("Overlap POIs"), this);
|
||||
_overlapPOIAction->setCheckable(true);
|
||||
connect(_overlapPOIAction, SIGNAL(triggered(bool)), _track,
|
||||
SLOT(setPOIOverlap(bool)));
|
||||
_showPOILabelsAction = new QAction(tr("Show POI labels"), this);
|
||||
_showPOILabelsAction->setCheckable(true);
|
||||
connect(_showPOILabelsAction, SIGNAL(triggered(bool)), _track,
|
||||
SLOT(showPOILabels(bool)));
|
||||
_showPOIAction = new QAction(QIcon(QPixmap(SHOW_POI_ICON)),
|
||||
tr("Show POIs"), this);
|
||||
_showPOIAction->setCheckable(true);
|
||||
@ -267,6 +272,28 @@ void GUI::createActions()
|
||||
addAction(_prevMapAction);
|
||||
}
|
||||
|
||||
// Data actions
|
||||
_showTracksAction = new QAction(tr("Show tracks"), this);
|
||||
_showTracksAction->setCheckable(true);
|
||||
connect(_showTracksAction, SIGNAL(triggered(bool)), this,
|
||||
SLOT(showTracks(bool)));
|
||||
_showRoutesAction = new QAction(tr("Show routes"), this);
|
||||
_showRoutesAction->setCheckable(true);
|
||||
connect(_showRoutesAction, SIGNAL(triggered(bool)), this,
|
||||
SLOT(showRoutes(bool)));
|
||||
_showWaypointsAction = new QAction(tr("Show waypoints"), this);
|
||||
_showWaypointsAction->setCheckable(true);
|
||||
connect(_showWaypointsAction, SIGNAL(triggered(bool)), _track,
|
||||
SLOT(showWaypoints(bool)));
|
||||
_showWaypointLabelsAction = new QAction(tr("Waypoint labels"), this);
|
||||
_showWaypointLabelsAction->setCheckable(true);
|
||||
connect(_showWaypointLabelsAction, SIGNAL(triggered(bool)), _track,
|
||||
SLOT(showWaypointLabels(bool)));
|
||||
_showRouteWaypointsAction = new QAction(tr("Route waypoints"), this);
|
||||
_showRouteWaypointsAction->setCheckable(true);
|
||||
connect(_showRouteWaypointsAction, SIGNAL(triggered(bool)), _track,
|
||||
SLOT(showRouteWaypoints(bool)));
|
||||
|
||||
// Settings actions
|
||||
_showGraphsAction = new QAction(tr("Show graphs"), this);
|
||||
_showGraphsAction->setCheckable(true);
|
||||
@ -317,79 +344,86 @@ void GUI::createActions()
|
||||
|
||||
void GUI::createMenus()
|
||||
{
|
||||
_fileMenu = menuBar()->addMenu(tr("File"));
|
||||
_fileMenu->addAction(_openFileAction);
|
||||
_fileMenu->addSeparator();
|
||||
_fileMenu->addAction(_saveFileAction);
|
||||
_fileMenu->addAction(_saveAsAction);
|
||||
_fileMenu->addSeparator();
|
||||
_fileMenu->addAction(_reloadFileAction);
|
||||
_fileMenu->addSeparator();
|
||||
_fileMenu->addAction(_closeFileAction);
|
||||
QMenu *fileMenu = menuBar()->addMenu(tr("File"));
|
||||
fileMenu->addAction(_openFileAction);
|
||||
fileMenu->addSeparator();
|
||||
fileMenu->addAction(_printFileAction);
|
||||
fileMenu->addAction(_exportFileAction);
|
||||
fileMenu->addSeparator();
|
||||
fileMenu->addAction(_reloadFileAction);
|
||||
fileMenu->addSeparator();
|
||||
fileMenu->addAction(_closeFileAction);
|
||||
#ifndef Q_OS_MAC
|
||||
_fileMenu->addSeparator();
|
||||
_fileMenu->addAction(_exitAction);
|
||||
fileMenu->addSeparator();
|
||||
fileMenu->addAction(_exitAction);
|
||||
#endif // Q_OS_MAC
|
||||
|
||||
_mapMenu = menuBar()->addMenu(tr("Map"));
|
||||
_mapMenu->addActions(_mapActions);
|
||||
_mapMenu->addSeparator();
|
||||
_mapMenu->addAction(_clearMapCacheAction);
|
||||
_mapMenu->addSeparator();
|
||||
_mapMenu->addAction(_showMapAction);
|
||||
QMenu *mapMenu = menuBar()->addMenu(tr("Map"));
|
||||
mapMenu->addActions(_mapActions);
|
||||
mapMenu->addSeparator();
|
||||
mapMenu->addAction(_clearMapCacheAction);
|
||||
mapMenu->addSeparator();
|
||||
mapMenu->addAction(_showMapAction);
|
||||
|
||||
_poiMenu = menuBar()->addMenu(tr("POI"));
|
||||
_poiFilesMenu = _poiMenu->addMenu(tr("POI files"));
|
||||
QMenu *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);
|
||||
poiMenu->addSeparator();
|
||||
poiMenu->addAction(_openPOIAction);
|
||||
poiMenu->addAction(_closePOIAction);
|
||||
poiMenu->addSeparator();
|
||||
poiMenu->addAction(_showPOILabelsAction);
|
||||
poiMenu->addAction(_overlapPOIAction);
|
||||
poiMenu->addSeparator();
|
||||
poiMenu->addAction(_showPOIAction);
|
||||
|
||||
_settingsMenu = menuBar()->addMenu(tr("Settings"));
|
||||
_unitsMenu = _settingsMenu->addMenu(tr("Units"));
|
||||
_unitsMenu->addAction(_metricUnitsAction);
|
||||
_unitsMenu->addAction(_imperialUnitsAction);
|
||||
_settingsMenu->addSeparator();
|
||||
_settingsMenu->addAction(_showToolbarsAction);
|
||||
_settingsMenu->addAction(_showGraphsAction);
|
||||
_settingsMenu->addSeparator();
|
||||
_settingsMenu->addAction(_fullscreenAction);
|
||||
QMenu *dataMenu = menuBar()->addMenu(tr("Data"));
|
||||
QMenu *displayMenu = dataMenu->addMenu(tr("Display"));
|
||||
displayMenu->addAction(_showWaypointLabelsAction);
|
||||
displayMenu->addAction(_showRouteWaypointsAction);
|
||||
dataMenu->addSeparator();
|
||||
dataMenu->addAction(_showTracksAction);
|
||||
dataMenu->addAction(_showRoutesAction);
|
||||
dataMenu->addAction(_showWaypointsAction);
|
||||
|
||||
_helpMenu = menuBar()->addMenu(tr("Help"));
|
||||
_helpMenu->addAction(_dataSourcesAction);
|
||||
_helpMenu->addAction(_keysAction);
|
||||
_helpMenu->addSeparator();
|
||||
_helpMenu->addAction(_aboutAction);
|
||||
QMenu *settingsMenu = menuBar()->addMenu(tr("Settings"));
|
||||
QMenu *unitsMenu = settingsMenu->addMenu(tr("Units"));
|
||||
unitsMenu->addAction(_metricUnitsAction);
|
||||
unitsMenu->addAction(_imperialUnitsAction);
|
||||
settingsMenu->addSeparator();
|
||||
settingsMenu->addAction(_showToolbarsAction);
|
||||
settingsMenu->addAction(_showGraphsAction);
|
||||
settingsMenu->addSeparator();
|
||||
settingsMenu->addAction(_fullscreenAction);
|
||||
|
||||
QMenu *helpMenu = menuBar()->addMenu(tr("Help"));
|
||||
helpMenu->addAction(_dataSourcesAction);
|
||||
helpMenu->addAction(_keysAction);
|
||||
helpMenu->addSeparator();
|
||||
helpMenu->addAction(_aboutAction);
|
||||
}
|
||||
|
||||
void GUI::createToolBars()
|
||||
{
|
||||
#ifdef Q_OS_MAC
|
||||
setToolButtonStyle(Qt::ToolButtonTextUnderIcon);
|
||||
#endif // Q_OS_MAC
|
||||
|
||||
_fileToolBar = addToolBar(tr("File"));
|
||||
_fileToolBar->addAction(_openFileAction);
|
||||
_fileToolBar->addAction(_saveFileAction);
|
||||
_fileToolBar->addAction(_reloadFileAction);
|
||||
_fileToolBar->addAction(_closeFileAction);
|
||||
#ifdef Q_OS_MAC
|
||||
_fileToolBar->setToolButtonStyle(Qt::ToolButtonTextUnderIcon);
|
||||
#endif // Q_OS_MAC
|
||||
_fileToolBar->addAction(_printFileAction);
|
||||
|
||||
_showToolBar = addToolBar(tr("Show"));
|
||||
_showToolBar->addAction(_showPOIAction);
|
||||
_showToolBar->addAction(_showMapAction);
|
||||
#ifdef Q_OS_MAC
|
||||
_showToolBar->setToolButtonStyle(Qt::ToolButtonTextUnderIcon);
|
||||
#endif // Q_OS_MAC
|
||||
|
||||
_navigationToolBar = addToolBar(tr("Navigation"));
|
||||
_navigationToolBar->addAction(_firstAction);
|
||||
_navigationToolBar->addAction(_prevAction);
|
||||
_navigationToolBar->addAction(_nextAction);
|
||||
_navigationToolBar->addAction(_lastAction);
|
||||
#ifdef Q_OS_MAC
|
||||
_navigationToolBar->setToolButtonStyle(Qt::ToolButtonTextUnderIcon);
|
||||
#endif // Q_OS_MAC
|
||||
}
|
||||
|
||||
void GUI::createTrackView()
|
||||
@ -402,13 +436,6 @@ void GUI::createTrackView()
|
||||
|
||||
void GUI::createTrackGraphs()
|
||||
{
|
||||
_elevationGraph = new ElevationGraph;
|
||||
_elevationGraph->setFrameShape(QFrame::NoFrame);
|
||||
_speedGraph = new SpeedGraph;
|
||||
_speedGraph->setFrameShape(QFrame::NoFrame);
|
||||
_heartRateGraph = new HeartRateGraph;
|
||||
_heartRateGraph->setFrameShape(QFrame::NoFrame);
|
||||
|
||||
_trackGraphs = new QTabWidget;
|
||||
connect(_trackGraphs, SIGNAL(currentChanged(int)), this,
|
||||
SLOT(graphChanged(int)));
|
||||
@ -419,6 +446,15 @@ void GUI::createTrackGraphs()
|
||||
#ifdef Q_OS_WIN32
|
||||
_trackGraphs->setDocumentMode(true);
|
||||
#endif // Q_OS_WIN32
|
||||
|
||||
_tabs.append(new ElevationGraph);
|
||||
_tabs.append(new SpeedGraph);
|
||||
_tabs.append(new HeartRateGraph);
|
||||
_tabs.append(new TemperatureGraph);
|
||||
|
||||
for (int i = 0; i < _tabs.count(); i++)
|
||||
connect(_tabs.at(i), SIGNAL(sliderPositionChanged(qreal)), this,
|
||||
SLOT(sliderPositionChanged(qreal)));
|
||||
}
|
||||
|
||||
void GUI::createStatusBar()
|
||||
@ -433,8 +469,6 @@ void GUI::createStatusBar()
|
||||
statusBar()->addPermanentWidget(_distanceLabel, 1);
|
||||
statusBar()->addPermanentWidget(_timeLabel, 1);
|
||||
statusBar()->setSizeGripEnabled(false);
|
||||
|
||||
updateStatusBarInfo();
|
||||
}
|
||||
|
||||
void GUI::about()
|
||||
@ -551,22 +585,30 @@ bool GUI::loadFile(const QString &fileName)
|
||||
GPX gpx;
|
||||
|
||||
if (gpx.loadFile(fileName)) {
|
||||
_elevationGraph->loadGPX(gpx);
|
||||
_speedGraph->loadGPX(gpx);
|
||||
_heartRateGraph->loadGPX(gpx);
|
||||
for (int i = 0; i < _tabs.count(); i++)
|
||||
_tabs.at(i)->loadGPX(gpx);
|
||||
updateGraphTabs();
|
||||
_track->setHidden(false);
|
||||
_track->loadGPX(gpx);
|
||||
if (_showPOIAction->isChecked())
|
||||
_track->loadPOI(_poi);
|
||||
_track->movePositionMarker(_sliderPos);
|
||||
|
||||
for (int i = 0; i < gpx.trackCount(); i++) {
|
||||
_distance += gpx.track(i).distance();
|
||||
_time += gpx.track(i).time();
|
||||
for (int i = 0; i < gpx.tracks().count(); i++) {
|
||||
_trackDistance += gpx.tracks().at(i)->distance();
|
||||
_time += gpx.tracks().at(i)->time();
|
||||
const QDate &date = gpx.tracks().at(i)->date().date();
|
||||
if (_dateRange.first.isNull() || _dateRange.first > date)
|
||||
_dateRange.first = date;
|
||||
if (_dateRange.second.isNull() || _dateRange.second < date)
|
||||
_dateRange.second = date;
|
||||
}
|
||||
_trackCount += gpx.tracks().count();
|
||||
|
||||
_trackCount += gpx.trackCount();
|
||||
for (int i = 0; i < gpx.routes().count(); i++)
|
||||
_routeDistance += gpx.routes().at(i)->distance();
|
||||
_routeCount += gpx.routes().count();
|
||||
|
||||
_waypointCount += gpx.waypoints().count();
|
||||
|
||||
return true;
|
||||
} else {
|
||||
@ -607,8 +649,9 @@ bool GUI::openPOIFile(const QString &fileName)
|
||||
} else {
|
||||
_showPOIAction->setChecked(true);
|
||||
_track->loadPOI(_poi);
|
||||
_poiFilesMenu->addAction(createPOIFileAction(
|
||||
_poi.files().indexOf(fileName)));
|
||||
QAction *action = createPOIFileAction(_poi.files().indexOf(fileName));
|
||||
action->setChecked(true);
|
||||
_poiFilesMenu->addAction(action);
|
||||
|
||||
return true;
|
||||
}
|
||||
@ -627,82 +670,110 @@ void GUI::closePOIFiles()
|
||||
_poi.clear();
|
||||
}
|
||||
|
||||
void GUI::saveAs()
|
||||
{
|
||||
QString fileName = QFileDialog::getSaveFileName(this, "Export to PDF",
|
||||
QString(), "*.pdf");
|
||||
|
||||
if (!fileName.isEmpty()) {
|
||||
saveFile(fileName);
|
||||
_saveFileName = fileName;
|
||||
}
|
||||
}
|
||||
|
||||
void GUI::saveFile()
|
||||
{
|
||||
if (_saveFileName.isEmpty())
|
||||
emit saveAs();
|
||||
else
|
||||
saveFile(_saveFileName);
|
||||
}
|
||||
|
||||
void GUI::saveFile(const QString &fileName)
|
||||
void GUI::printFile()
|
||||
{
|
||||
QPrinter printer(QPrinter::HighResolution);
|
||||
printer.setPageSize(QPrinter::A4);
|
||||
printer.setOrientation(_track->orientation());
|
||||
printer.setOutputFormat(QPrinter::PdfFormat);
|
||||
printer.setOutputFileName(fileName);
|
||||
QPrintDialog dialog(&printer, this);
|
||||
|
||||
QPainter p(&printer);
|
||||
if (dialog.exec() == QDialog::Accepted)
|
||||
plot(&printer);
|
||||
}
|
||||
|
||||
_track->plot(&p, QRectF(0, 300, printer.width(), (0.80 * printer.height())
|
||||
- 400));
|
||||
_elevationGraph->plot(&p, QRectF(0, 0.80 * printer.height(),
|
||||
printer.width(), printer.height() * 0.20));
|
||||
void GUI::exportFile()
|
||||
{
|
||||
QPrinter printer(QPrinter::HighResolution);
|
||||
printer.setCreator(QString(APP_NAME) + QString(" ") + QString(APP_VERSION));
|
||||
printer.setOrientation(_exportOrientation);
|
||||
printer.setOutputFileName(_exportFileName);
|
||||
printer.setPaperSize(_exportPaperSize);
|
||||
printer.setPageMargins(_exportMargins.left(), _exportMargins.top(),
|
||||
_exportMargins.right(), _exportMargins.bottom(), QPrinter::Millimeter);
|
||||
ExportDialog dialog(&printer, this);
|
||||
|
||||
QGraphicsScene scene;
|
||||
InfoItem info;
|
||||
if (_imperialUnitsAction->isChecked()) {
|
||||
info.insert(tr("Distance"), QString::number(_distance * M2MI, 'f', 1)
|
||||
+ UNIT_SPACE + tr("mi"));
|
||||
info.insert(tr("Time"), timeSpan(_time));
|
||||
info.insert(tr("Ascent"), QString::number(_elevationGraph->ascent()
|
||||
* M2FT, 'f', 0) + UNIT_SPACE + tr("ft"));
|
||||
info.insert(tr("Descent"), QString::number(_elevationGraph->descent()
|
||||
* M2FT, 'f', 0) + UNIT_SPACE + tr("ft"));
|
||||
info.insert(tr("Maximum"), QString::number(_elevationGraph->max()
|
||||
* M2FT, 'f', 0) + UNIT_SPACE + tr("ft"));
|
||||
info.insert(tr("Minimum"), QString::number(_elevationGraph->min()
|
||||
* M2FT, 'f', 0) + UNIT_SPACE + tr("ft"));
|
||||
} else {
|
||||
info.insert(tr("Distance"), QString::number(_distance * M2KM, 'f', 1)
|
||||
+ UNIT_SPACE + tr("km"));
|
||||
info.insert(tr("Time"), timeSpan(_time));
|
||||
info.insert(tr("Ascent"), QString::number(_elevationGraph->ascent(),
|
||||
'f', 0) + UNIT_SPACE + tr("m"));
|
||||
info.insert(tr("Descent"), QString::number(_elevationGraph->descent(),
|
||||
'f', 0) + UNIT_SPACE + tr("m"));
|
||||
info.insert(tr("Maximum"), QString::number(_elevationGraph->max(), 'f',
|
||||
0) + UNIT_SPACE + tr("m"));
|
||||
info.insert(tr("Minimum"), QString::number(_elevationGraph->min(), 'f',
|
||||
0) + UNIT_SPACE + tr("m"));
|
||||
if (dialog.exec() == QDialog::Accepted) {
|
||||
_exportFileName = printer.outputFileName();
|
||||
_exportPaperSize = printer.paperSize();
|
||||
_exportOrientation = printer.orientation();
|
||||
printer.getPageMargins(&(_exportMargins.rleft()),
|
||||
&(_exportMargins.rtop()), &(_exportMargins.rright()),
|
||||
&(_exportMargins.rbottom()), QPrinter::Millimeter);
|
||||
plot(&printer);
|
||||
}
|
||||
scene.addItem(&info);
|
||||
scene.render(&p, QRectF(0, 0, printer.width(), 200));
|
||||
}
|
||||
|
||||
void GUI::plot(QPrinter *printer)
|
||||
{
|
||||
QPainter p(printer);
|
||||
TrackInfo info;
|
||||
qreal ih, gh, mh, ratio;
|
||||
Units units = _imperialUnitsAction->isChecked() ? Imperial : Metric;
|
||||
qreal d = distance();
|
||||
qreal t = time();
|
||||
|
||||
if (_dateRange.first.isValid()) {
|
||||
if (_dateRange.first == _dateRange.second) {
|
||||
QString format = QLocale::system().dateFormat(QLocale::LongFormat);
|
||||
info.insert(tr("Date"), _dateRange.first.toString(format));
|
||||
} else {
|
||||
QString format = QLocale::system().dateFormat(QLocale::ShortFormat);
|
||||
info.insert(tr("Date"), QString("%1 - %2")
|
||||
.arg(_dateRange.first.toString(format),
|
||||
_dateRange.second.toString(format)));
|
||||
}
|
||||
}
|
||||
|
||||
if (_trackCount > 1)
|
||||
info.insert(tr("Tracks"), QString::number(_trackCount));
|
||||
if (_routeCount > 1)
|
||||
info.insert(tr("Routes"), QString::number(_routeCount));
|
||||
if (_waypointCount > 2)
|
||||
info.insert(tr("Waypoints"), QString::number(_waypointCount));
|
||||
|
||||
if (d > 0)
|
||||
info.insert(tr("Distance"), ::distance(d, units));
|
||||
if (t > 0)
|
||||
info.insert(tr("Time"), ::timeSpan(t));
|
||||
|
||||
|
||||
ratio = p.paintEngine()->paintDevice()->logicalDpiX() / SCREEN_DPI;
|
||||
if (info.isEmpty()) {
|
||||
ih = 0;
|
||||
mh = 0;
|
||||
} else {
|
||||
ih = info.contentSize().height() * ratio;
|
||||
mh = ih / 2;
|
||||
info.plot(&p, QRectF(0, 0, printer->width(), ih));
|
||||
}
|
||||
if (_trackGraphs->isVisible()) {
|
||||
qreal r = (((qreal)(printer)->width()) / (qreal)(printer->height()));
|
||||
gh = (printer->width() > printer->height())
|
||||
? 0.15 * r * (printer->height() - ih - 2*mh)
|
||||
: 0.15 * (printer->height() - ih - 2*mh);
|
||||
gh = qMax(gh, ratio * 150);
|
||||
GraphTab *gt = static_cast<GraphTab*>(_trackGraphs->currentWidget());
|
||||
gt->plot(&p, QRectF(0, printer->height() - gh, printer->width(), gh));
|
||||
} else
|
||||
gh = 0;
|
||||
_track->plot(&p, QRectF(0, ih + mh, printer->width(), printer->height()
|
||||
- (ih + 2*mh + gh)));
|
||||
}
|
||||
|
||||
void GUI::reloadFile()
|
||||
{
|
||||
_distance = 0;
|
||||
_time = 0;
|
||||
_trackCount = 0;
|
||||
_routeCount = 0;
|
||||
_waypointCount = 0;
|
||||
_trackDistance = 0;
|
||||
_routeDistance = 0;
|
||||
_time = 0;
|
||||
_dateRange = DateRange(QDate(), QDate());
|
||||
|
||||
_elevationGraph->clear();
|
||||
_speedGraph->clear();
|
||||
_heartRateGraph->clear();
|
||||
for (int i = 0; i < _tabs.count(); i++)
|
||||
_tabs.at(i)->clear();
|
||||
_track->clear();
|
||||
|
||||
_sliderPos = 0;
|
||||
|
||||
for (int i = 0; i < _files.size(); i++) {
|
||||
if (!loadFile(_files.at(i))) {
|
||||
_files.removeAt(i);
|
||||
@ -722,15 +793,18 @@ void GUI::reloadFile()
|
||||
|
||||
void GUI::closeFiles()
|
||||
{
|
||||
_distance = 0;
|
||||
_time = 0;
|
||||
_trackCount = 0;
|
||||
_routeCount = 0;
|
||||
_waypointCount = 0;
|
||||
_trackDistance = 0;
|
||||
_routeDistance = 0;
|
||||
_time = 0;
|
||||
_dateRange = DateRange(QDate(), QDate());
|
||||
|
||||
_sliderPos = 0;
|
||||
|
||||
_elevationGraph->clear();
|
||||
_speedGraph->clear();
|
||||
_heartRateGraph->clear();
|
||||
for (int i = 0; i < _tabs.count(); i++)
|
||||
_tabs.at(i)->clear();
|
||||
_track->clear();
|
||||
|
||||
_files.clear();
|
||||
@ -812,6 +886,26 @@ void GUI::showFullscreen(bool checked)
|
||||
}
|
||||
}
|
||||
|
||||
void GUI::showTracks(bool show)
|
||||
{
|
||||
_track->showTracks(show);
|
||||
|
||||
for (int i = 0; i < _tabs.size(); i++)
|
||||
_tabs.at(i)->showTracks(show);
|
||||
|
||||
updateStatusBarInfo();
|
||||
}
|
||||
|
||||
void GUI::showRoutes(bool show)
|
||||
{
|
||||
_track->showRoutes(show);
|
||||
|
||||
for (int i = 0; i < _tabs.size(); i++)
|
||||
_tabs.at(i)->showRoutes(show);
|
||||
|
||||
updateStatusBarInfo();
|
||||
}
|
||||
|
||||
void GUI::clearMapCache()
|
||||
{
|
||||
_currentMap->clearCache();
|
||||
@ -820,32 +914,25 @@ void GUI::clearMapCache()
|
||||
|
||||
void GUI::updateStatusBarInfo()
|
||||
{
|
||||
if (_files.count() == 0) {
|
||||
if (_files.count() == 0)
|
||||
_fileNameLabel->setText(tr("No GPX files loaded"));
|
||||
_distanceLabel->clear();
|
||||
_timeLabel->clear();
|
||||
return;
|
||||
} else if (_files.count() == 1)
|
||||
else if (_files.count() == 1)
|
||||
_fileNameLabel->setText(_files.at(0));
|
||||
else
|
||||
_fileNameLabel->setText(tr("%1 tracks").arg(_trackCount));
|
||||
_fileNameLabel->setText(tr("%1 files").arg(_files.count()));
|
||||
|
||||
if (_imperialUnitsAction->isChecked()) {
|
||||
if (_distance < MIINM)
|
||||
_distanceLabel->setText(QString::number(_distance * M2FT, 'f', 0)
|
||||
+ UNIT_SPACE + tr("ft"));
|
||||
else
|
||||
_distanceLabel->setText(QString::number(_distance * M2MI, 'f', 1)
|
||||
+ UNIT_SPACE + tr("mi"));
|
||||
} else {
|
||||
if (_distance < KMINM)
|
||||
_distanceLabel->setText(QString::number(_distance, 'f', 0)
|
||||
+ UNIT_SPACE + tr("m"));
|
||||
else
|
||||
_distanceLabel->setText(QString::number(_distance * M2KM, 'f', 1)
|
||||
+ UNIT_SPACE + tr("km"));
|
||||
}
|
||||
_timeLabel->setText(timeSpan(_time));
|
||||
qreal d = distance();
|
||||
Units units = _imperialUnitsAction->isChecked() ? Imperial : Metric;
|
||||
if (d > 0)
|
||||
_distanceLabel->setText(::distance(distance(), units));
|
||||
else
|
||||
_distanceLabel->clear();
|
||||
|
||||
qreal t = time();
|
||||
if (t > 0)
|
||||
_timeLabel->setText(::timeSpan(time()));
|
||||
else
|
||||
_timeLabel->clear();
|
||||
}
|
||||
|
||||
void GUI::updateWindowTitle()
|
||||
@ -904,8 +991,8 @@ void GUI::graphChanged(int index)
|
||||
if (index < 0)
|
||||
return;
|
||||
|
||||
GraphView *gv = static_cast<GraphView*>(_trackGraphs->widget(index));
|
||||
gv->setSliderPosition(_sliderPos);
|
||||
GraphTab *gt = static_cast<GraphTab*>(_trackGraphs->widget(index));
|
||||
gt->setSliderPosition(_sliderPos);
|
||||
}
|
||||
|
||||
void GUI::updateNavigationActions()
|
||||
@ -929,24 +1016,19 @@ void GUI::updateNavigationActions()
|
||||
|
||||
void GUI::updateGraphTabs()
|
||||
{
|
||||
struct GraphTab tabs[] = {
|
||||
{_elevationGraph, tr("Elevation")},
|
||||
{_speedGraph, tr("Speed")},
|
||||
{_heartRateGraph, tr("Heart rate")}
|
||||
};
|
||||
int index;
|
||||
GraphView *gv;
|
||||
GraphTab *tab;
|
||||
|
||||
for (int i = 0; i < (int)ARRAY_SIZE(tabs); i++) {
|
||||
gv = tabs[i].view;
|
||||
if (!gv->count() && (index = _trackGraphs->indexOf(gv)) >= 0)
|
||||
for (int i = 0; i < _tabs.size(); i++) {
|
||||
tab = _tabs.at(i);
|
||||
if (!tab->count() && (index = _trackGraphs->indexOf(tab)) >= 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 < _tabs.size(); i++) {
|
||||
tab = _tabs.at(i);
|
||||
if (tab->count() && _trackGraphs->indexOf(tab) < 0)
|
||||
_trackGraphs->insertTab(i, tab, _tabs.at(i)->label());
|
||||
}
|
||||
|
||||
if (_trackGraphs->count()) {
|
||||
@ -961,24 +1043,23 @@ void GUI::updateGraphTabs()
|
||||
|
||||
void GUI::updateTrackView()
|
||||
{
|
||||
_track->setHidden(!(_track->trackCount() + _track->waypointCount()));
|
||||
_track->setHidden(!(_track->trackCount() + _track->routeCount()
|
||||
+ _track->waypointCount()));
|
||||
}
|
||||
|
||||
void GUI::setMetricUnits()
|
||||
{
|
||||
_track->setUnits(Metric);
|
||||
_elevationGraph->setUnits(Metric);
|
||||
_speedGraph->setUnits(Metric);
|
||||
_heartRateGraph->setUnits(Metric);
|
||||
for (int i = 0; i <_tabs.count(); i++)
|
||||
_tabs.at(i)->setUnits(Metric);
|
||||
updateStatusBarInfo();
|
||||
}
|
||||
|
||||
void GUI::setImperialUnits()
|
||||
{
|
||||
_track->setUnits(Imperial);
|
||||
_elevationGraph->setUnits(Imperial);
|
||||
_speedGraph->setUnits(Imperial);
|
||||
_heartRateGraph->setUnits(Imperial);
|
||||
for (int i = 0; i <_tabs.count(); i++)
|
||||
_tabs.at(i)->setUnits(Imperial);
|
||||
updateStatusBarInfo();
|
||||
}
|
||||
|
||||
@ -1085,6 +1166,7 @@ void GUI::writeSettings()
|
||||
|
||||
settings.beginGroup(POI_SETTINGS_GROUP);
|
||||
settings.setValue(SHOW_POI_SETTING, _showPOIAction->isChecked());
|
||||
settings.setValue(OVERLAP_POI_SETTING, _overlapPOIAction->isChecked());
|
||||
|
||||
settings.remove(DISABLED_POI_FILE_SETTINGS_PREFIX);
|
||||
settings.beginWriteArray(DISABLED_POI_FILE_SETTINGS_PREFIX);
|
||||
@ -1096,6 +1178,18 @@ void GUI::writeSettings()
|
||||
}
|
||||
settings.endArray();
|
||||
settings.endGroup();
|
||||
|
||||
settings.beginGroup(DATA_SETTINGS_GROUP);
|
||||
settings.setValue(SHOW_TRACKS_SETTING, _showTracksAction->isChecked());
|
||||
settings.setValue(SHOW_ROUTES_SETTING, _showRoutesAction->isChecked());
|
||||
settings.setValue(SHOW_WAYPOINTS_SETTING,
|
||||
_showWaypointsAction->isChecked());
|
||||
settings.setValue(SHOW_WAYPOINT_LABELS_SETTING,
|
||||
_showWaypointLabelsAction->isChecked());
|
||||
settings.setValue(SHOW_ROUTE_WAYPOINTS_SETTING,
|
||||
_showRouteWaypointsAction->isChecked());
|
||||
|
||||
settings.endGroup();
|
||||
}
|
||||
|
||||
void GUI::readSettings()
|
||||
@ -1108,20 +1202,20 @@ void GUI::readSettings()
|
||||
settings.endGroup();
|
||||
|
||||
settings.beginGroup(SETTINGS_SETTINGS_GROUP);
|
||||
if (settings.value(UNITS_SETTING, Metric).toInt() == Imperial) {
|
||||
Units u = QLocale::system().measurementSystem() == QLocale::ImperialSystem
|
||||
? Imperial : Metric;
|
||||
if (settings.value(UNITS_SETTING, u).toInt() == Imperial) {
|
||||
setImperialUnits();
|
||||
_imperialUnitsAction->setChecked(true);
|
||||
} else
|
||||
_metricUnitsAction->setChecked(true);
|
||||
if (settings.value(SHOW_TOOLBARS_SETTING, true).toBool() == false) {
|
||||
if (settings.value(SHOW_TOOLBARS_SETTING, true).toBool() == false)
|
||||
showToolbars(false);
|
||||
_showToolbarsAction->setChecked(false);
|
||||
} else
|
||||
else
|
||||
_showToolbarsAction->setChecked(true);
|
||||
if (settings.value(SHOW_GRAPHS_SETTING, true).toBool() == false) {
|
||||
if (settings.value(SHOW_GRAPHS_SETTING, true).toBool() == false)
|
||||
showGraphs(false);
|
||||
_showGraphsAction->setChecked(false);
|
||||
} else
|
||||
else
|
||||
_showGraphsAction->setChecked(true);
|
||||
settings.endGroup();
|
||||
|
||||
@ -1139,6 +1233,14 @@ void GUI::readSettings()
|
||||
settings.endGroup();
|
||||
|
||||
settings.beginGroup(POI_SETTINGS_GROUP);
|
||||
if (settings.value(OVERLAP_POI_SETTING, true).toBool() == false)
|
||||
_track->setPOIOverlap(false);
|
||||
else
|
||||
_overlapPOIAction->setChecked(true);
|
||||
if (settings.value(LABELS_POI_SETTING, true).toBool() == false)
|
||||
_track->showPOILabels(false);
|
||||
else
|
||||
_showPOILabelsAction->setChecked(true);
|
||||
if (settings.value(SHOW_POI_SETTING, false).toBool() == true)
|
||||
_showPOIAction->setChecked(true);
|
||||
for (int i = 0; i < _poiFilesActions.count(); i++)
|
||||
@ -1155,6 +1257,33 @@ void GUI::readSettings()
|
||||
}
|
||||
settings.endArray();
|
||||
settings.endGroup();
|
||||
|
||||
settings.beginGroup(DATA_SETTINGS_GROUP);
|
||||
if (settings.value(SHOW_TRACKS_SETTING, true).toBool() == false) {
|
||||
_track->showTracks(false);
|
||||
for (int i = 0; i < _tabs.count(); i++)
|
||||
_tabs.at(i)->showTracks(false);
|
||||
} else
|
||||
_showTracksAction->setChecked(true);
|
||||
if (settings.value(SHOW_ROUTES_SETTING, true).toBool() == false) {
|
||||
_track->showRoutes(false);
|
||||
for (int i = 0; i < _tabs.count(); i++)
|
||||
_tabs.at(i)->showRoutes(false);
|
||||
} else
|
||||
_showRoutesAction->setChecked(true);
|
||||
if (settings.value(SHOW_WAYPOINTS_SETTING, true).toBool() == false)
|
||||
_track->showWaypoints(false);
|
||||
else
|
||||
_showWaypointsAction->setChecked(true);
|
||||
if (settings.value(SHOW_WAYPOINT_LABELS_SETTING, true).toBool() == false)
|
||||
_track->showWaypointLabels(false);
|
||||
else
|
||||
_showWaypointLabelsAction->setChecked(true);
|
||||
if (settings.value(SHOW_ROUTE_WAYPOINTS_SETTING, true).toBool() == false)
|
||||
_track->showRouteWaypoints(false);
|
||||
else
|
||||
_showRouteWaypointsAction->setChecked(true);
|
||||
settings.endGroup();
|
||||
}
|
||||
|
||||
int GUI::mapIndex(const QString &name)
|
||||
@ -1165,3 +1294,20 @@ int GUI::mapIndex(const QString &name)
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
qreal GUI::distance()
|
||||
{
|
||||
qreal dist = 0;
|
||||
|
||||
if (_showTracksAction->isChecked())
|
||||
dist += _trackDistance;
|
||||
if (_showRoutesAction->isChecked())
|
||||
dist += _routeDistance;
|
||||
|
||||
return dist;
|
||||
}
|
||||
|
||||
qreal GUI::time()
|
||||
{
|
||||
return (_showTracksAction->isChecked()) ? _time : 0;
|
||||
}
|
||||
|
69
src/gui.h
69
src/gui.h
@ -4,7 +4,10 @@
|
||||
#include <QMainWindow>
|
||||
#include <QString>
|
||||
#include <QList>
|
||||
#include <QDate>
|
||||
#include <QPrinter>
|
||||
#include "poi.h"
|
||||
#include "margins.h"
|
||||
|
||||
class QMenu;
|
||||
class QToolBar;
|
||||
@ -13,11 +16,9 @@ class QActionGroup;
|
||||
class QAction;
|
||||
class QLabel;
|
||||
class QSignalMapper;
|
||||
class QPrinter;
|
||||
class FileBrowser;
|
||||
class GraphView;
|
||||
class ElevationGraph;
|
||||
class SpeedGraph;
|
||||
class HeartRateGraph;
|
||||
class GraphTab;
|
||||
class TrackView;
|
||||
class Map;
|
||||
|
||||
@ -27,6 +28,7 @@ class GUI : public QMainWindow
|
||||
|
||||
public:
|
||||
GUI(QWidget *parent = 0);
|
||||
~GUI();
|
||||
|
||||
bool openFile(const QString &fileName);
|
||||
|
||||
@ -34,8 +36,8 @@ private slots:
|
||||
void about();
|
||||
void keys();
|
||||
void dataSources();
|
||||
void saveFile();
|
||||
void saveAs();
|
||||
void printFile();
|
||||
void exportFile();
|
||||
void openFile();
|
||||
void closeAll();
|
||||
void reloadFile();
|
||||
@ -46,6 +48,8 @@ private slots:
|
||||
void showGraphs(bool checked);
|
||||
void showToolbars(bool checked);
|
||||
void showFullscreen(bool checked);
|
||||
void showTracks(bool show);
|
||||
void showRoutes(bool show);
|
||||
void clearMapCache();
|
||||
void nextMap();
|
||||
void prevMap();
|
||||
@ -54,6 +58,8 @@ private slots:
|
||||
void graphChanged(int);
|
||||
void poiFileChecked(int);
|
||||
|
||||
|
||||
|
||||
void next();
|
||||
void prev();
|
||||
void last();
|
||||
@ -65,9 +71,12 @@ private slots:
|
||||
void sliderPositionChanged(qreal pos);
|
||||
|
||||
private:
|
||||
typedef QPair<QDate, QDate> DateRange;
|
||||
|
||||
void loadMaps();
|
||||
void loadPOIs();
|
||||
void closeFiles();
|
||||
void plot(QPrinter *printer);
|
||||
|
||||
QAction *createPOIFileAction(int index);
|
||||
void createPOIFilesActions();
|
||||
@ -81,48 +90,44 @@ private:
|
||||
|
||||
bool openPOIFile(const QString &fileName);
|
||||
bool loadFile(const QString &fileName);
|
||||
void saveFile(const QString &fileName);
|
||||
void exportFile(const QString &fileName);
|
||||
void updateStatusBarInfo();
|
||||
void updateWindowTitle();
|
||||
void updateNavigationActions();
|
||||
void updateGraphTabs();
|
||||
void updateTrackView();
|
||||
|
||||
void keyPressEvent(QKeyEvent * event);
|
||||
void keyPressEvent(QKeyEvent *event);
|
||||
void closeEvent(QCloseEvent *event);
|
||||
|
||||
qreal distance();
|
||||
qreal time();
|
||||
int mapIndex(const QString &name);
|
||||
void readSettings();
|
||||
void writeSettings();
|
||||
|
||||
QMenu *_fileMenu;
|
||||
QMenu *_helpMenu;
|
||||
QMenu *_poiMenu;
|
||||
QMenu *_mapMenu;
|
||||
QMenu *_settingsMenu;
|
||||
QMenu *_unitsMenu;
|
||||
QMenu *_poiFilesMenu;
|
||||
|
||||
QToolBar *_fileToolBar;
|
||||
QToolBar *_showToolBar;
|
||||
QToolBar *_navigationToolBar;
|
||||
QTabWidget *_trackGraphs;
|
||||
QMenu *_poiFilesMenu;
|
||||
|
||||
QActionGroup *_fileActionGroup;
|
||||
QActionGroup *_navigationActionGroup;
|
||||
|
||||
QAction *_exitAction;
|
||||
QAction *_keysAction;
|
||||
QAction *_dataSourcesAction;
|
||||
QAction *_aboutAction;
|
||||
QAction *_aboutQtAction;
|
||||
QAction *_saveFileAction;
|
||||
QAction *_saveAsAction;
|
||||
QAction *_printFileAction;
|
||||
QAction *_exportFileAction;
|
||||
QAction *_openFileAction;
|
||||
QAction *_closeFileAction;
|
||||
QAction *_reloadFileAction;
|
||||
QAction *_openPOIAction;
|
||||
QAction *_closePOIAction;
|
||||
QAction *_showPOIAction;
|
||||
QAction *_overlapPOIAction;
|
||||
QAction *_showPOILabelsAction;
|
||||
QAction *_showMapAction;
|
||||
QAction *_fullscreenAction;
|
||||
QAction *_clearMapCacheAction;
|
||||
@ -136,6 +141,11 @@ private:
|
||||
QAction *_imperialUnitsAction;
|
||||
QAction *_nextMapAction;
|
||||
QAction *_prevMapAction;
|
||||
QAction *_showTracksAction;
|
||||
QAction *_showRoutesAction;
|
||||
QAction *_showWaypointsAction;
|
||||
QAction *_showWaypointLabelsAction;
|
||||
QAction *_showRouteWaypointsAction;
|
||||
QList<QAction*> _mapActions;
|
||||
QList<QAction*> _poiFilesActions;
|
||||
|
||||
@ -145,27 +155,34 @@ private:
|
||||
QLabel *_distanceLabel;
|
||||
QLabel *_timeLabel;
|
||||
|
||||
ElevationGraph *_elevationGraph;
|
||||
SpeedGraph *_speedGraph;
|
||||
HeartRateGraph *_heartRateGraph;
|
||||
TrackView *_track;
|
||||
QTabWidget *_trackGraphs;
|
||||
QList<GraphTab*> _tabs;
|
||||
|
||||
POI _poi;
|
||||
QList<Map*> _maps;
|
||||
|
||||
FileBrowser *_browser;
|
||||
QList<QString> _files;
|
||||
QString _saveFileName;
|
||||
Map *_currentMap;
|
||||
|
||||
qreal _distance;
|
||||
qreal _time;
|
||||
int _trackCount;
|
||||
int _routeCount;
|
||||
int _waypointCount;
|
||||
qreal _trackDistance;
|
||||
qreal _routeDistance;
|
||||
qreal _time;
|
||||
DateRange _dateRange;
|
||||
|
||||
qreal _sliderPos;
|
||||
|
||||
int _frameStyle;
|
||||
bool _showGraphs;
|
||||
|
||||
QString _exportFileName;
|
||||
QPrinter::PaperSize _exportPaperSize;
|
||||
QPrinter::Orientation _exportOrientation;
|
||||
MarginsF _exportMargins;
|
||||
};
|
||||
|
||||
#endif // GUI_H
|
||||
|
@ -2,9 +2,10 @@
|
||||
#include "heartrategraph.h"
|
||||
|
||||
|
||||
HeartRateGraph::HeartRateGraph(QWidget *parent) : GraphView(parent)
|
||||
HeartRateGraph::HeartRateGraph(QWidget *parent) : GraphTab(parent)
|
||||
{
|
||||
_units = Metric;
|
||||
_showTracks = true;
|
||||
|
||||
GraphView::setYUnits(tr("1/min"));
|
||||
setXLabel(tr("Distance"));
|
||||
@ -13,23 +14,23 @@ HeartRateGraph::HeartRateGraph(QWidget *parent) : GraphView(parent)
|
||||
setSliderPrecision(0);
|
||||
}
|
||||
|
||||
void HeartRateGraph::addInfo()
|
||||
void HeartRateGraph::setInfo()
|
||||
{
|
||||
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());
|
||||
|
||||
redraw();
|
||||
if (_showTracks) {
|
||||
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());
|
||||
} else
|
||||
clearInfo();
|
||||
}
|
||||
|
||||
void HeartRateGraph::loadGPX(const GPX &gpx)
|
||||
{
|
||||
for (int i = 0; i < gpx.trackCount(); i++) {
|
||||
QVector<QPointF> data;
|
||||
for (int i = 0; i < gpx.tracks().count(); i++) {
|
||||
QVector<QPointF> data = gpx.tracks().at(i)->heartRate();
|
||||
qreal sum = 0, w = 0;
|
||||
|
||||
gpx.track(i).heartRateGraph(data);
|
||||
if (data.count() < 2) {
|
||||
skipColor();
|
||||
continue;
|
||||
@ -39,13 +40,18 @@ void HeartRateGraph::loadGPX(const GPX &gpx)
|
||||
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));
|
||||
_avg.append(QPointF(gpx.tracks().at(i)->distance(), sum/w));
|
||||
|
||||
loadData(data);
|
||||
}
|
||||
|
||||
for (int i = 0; i < gpx.routes().count(); i++)
|
||||
skipColor();
|
||||
|
||||
setXUnits();
|
||||
addInfo();
|
||||
setInfo();
|
||||
|
||||
redraw();
|
||||
}
|
||||
|
||||
qreal HeartRateGraph::avg() const
|
||||
@ -92,8 +98,20 @@ void HeartRateGraph::setXUnits()
|
||||
void HeartRateGraph::setUnits(enum Units units)
|
||||
{
|
||||
_units = units;
|
||||
setXUnits();
|
||||
|
||||
clearInfo();
|
||||
addInfo();
|
||||
setXUnits();
|
||||
setInfo();
|
||||
|
||||
redraw();
|
||||
}
|
||||
|
||||
void HeartRateGraph::showTracks(bool show)
|
||||
{
|
||||
_showTracks = show;
|
||||
|
||||
showGraph(show);
|
||||
setXUnits();
|
||||
setInfo();
|
||||
|
||||
redraw();
|
||||
}
|
||||
|
@ -1,31 +1,34 @@
|
||||
#ifndef HEARTRATEGRAPH_H
|
||||
#define HEARTRATEGRAPH_H
|
||||
|
||||
#include "graphview.h"
|
||||
#include "units.h"
|
||||
#include "graphtab.h"
|
||||
|
||||
class GPX;
|
||||
|
||||
class HeartRateGraph : public GraphView
|
||||
class HeartRateGraph : public GraphTab
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
HeartRateGraph(QWidget *parent = 0);
|
||||
|
||||
QString label() const {return tr("Heart rate");}
|
||||
void loadGPX(const GPX &gpx);
|
||||
void clear();
|
||||
void setUnits(enum Units units);
|
||||
|
||||
qreal avg() const;
|
||||
qreal max() const {return bounds().bottom();}
|
||||
void showTracks(bool show);
|
||||
void showRoutes(bool show) {Q_UNUSED(show);}
|
||||
|
||||
private:
|
||||
qreal avg() const;
|
||||
qreal max() const {return bounds().bottom();}
|
||||
void setXUnits();
|
||||
void addInfo();
|
||||
void setInfo();
|
||||
|
||||
QList<QPointF> _avg;
|
||||
|
||||
enum Units _units;
|
||||
bool _showTracks;
|
||||
};
|
||||
|
||||
#endif // HEARTRATEGRAPH_H
|
||||
|
@ -3,8 +3,8 @@
|
||||
|
||||
#define APP_ICON ":/icons/gpxsee.png"
|
||||
#define OPEN_FILE_ICON ":/icons/document-open.png"
|
||||
#define SAVE_FILE_ICON ":/icons/document-save.png"
|
||||
#define SAVE_AS_ICON ":/icons/document-save-as.png"
|
||||
#define EXPORT_FILE_ICON ":/icons/document-export.png"
|
||||
#define PRINT_FILE_ICON ":/icons/document-print.png"
|
||||
#define CLOSE_FILE_ICON ":/icons/dialog-close.png"
|
||||
#define SHOW_POI_ICON ":/icons/flag.png"
|
||||
#define SHOW_MAP_ICON ":/icons/applications-internet.png"
|
||||
|
@ -15,6 +15,7 @@ public:
|
||||
|
||||
void insert(const QString &key, const QString &value);
|
||||
void clear();
|
||||
bool isEmpty() {return _list.isEmpty();}
|
||||
|
||||
private:
|
||||
void updateBoundingRect();
|
||||
|
@ -12,10 +12,9 @@
|
||||
|
||||
#define QUIT_SHORTCUT QKeySequence::Quit
|
||||
#define OPEN_SHORTCUT QKeySequence::Open
|
||||
#define SAVE_SHORTCUT QKeySequence::Save
|
||||
#define SAVE_AS_SHORTCUT QKeySequence::SaveAs
|
||||
#define CLOSE_SHORTCUT QKeySequence::Close
|
||||
#define RELOAD_SHORTCUT QKeySequence::Refresh
|
||||
#define EXPORT_SHORTCUT QKeySequence(Qt::CTRL + Qt::Key_E)
|
||||
#define SHOW_POI_SHORTCUT QKeySequence(Qt::CTRL + Qt::Key_P)
|
||||
#define SHOW_MAP_SHORTCUT QKeySequence(Qt::CTRL + Qt::Key_M)
|
||||
#define NEXT_MAP_SHORTCUT QKeySequence::Forward
|
||||
|
10
src/ll.cpp
10
src/ll.cpp
@ -35,6 +35,16 @@ QPointF ll2mercator(const QPointF &ll)
|
||||
return m;
|
||||
}
|
||||
|
||||
QPointF mercator2ll(const QPointF &m)
|
||||
{
|
||||
QPointF ll;
|
||||
|
||||
ll.setX(m.x());
|
||||
ll.setY(rad2deg(2 * atan(exp(deg2rad(m.y()))) - M_PI/2));
|
||||
|
||||
return ll;
|
||||
}
|
||||
|
||||
QPoint mercator2tile(const QPointF &m, int z)
|
||||
{
|
||||
QPoint tile;
|
||||
|
1
src/ll.h
1
src/ll.h
@ -8,6 +8,7 @@
|
||||
#define ZOOM_MIN 3
|
||||
|
||||
QPointF ll2mercator(const QPointF &ll);
|
||||
QPointF mercator2ll(const QPointF &m);
|
||||
qreal llDistance(const QPointF &p1, const QPointF &p2);
|
||||
QPoint mercator2tile(const QPointF &m, int zoom);
|
||||
QPointF tile2mercator(const QPoint &tile, int zoom);
|
||||
|
105
src/map.cpp
105
src/map.cpp
@ -25,36 +25,105 @@ void Map::emitLoaded()
|
||||
emit loaded();
|
||||
}
|
||||
|
||||
void Map::loadTiles(QList<Tile> &list)
|
||||
void Map::loadTiles(QList<Tile> &list, bool block)
|
||||
{
|
||||
if (block)
|
||||
loadTilesSync(list);
|
||||
else
|
||||
loadTilesAsync(list);
|
||||
}
|
||||
|
||||
void Map::loadTilesAsync(QList<Tile> &list)
|
||||
{
|
||||
QList<Download> dl;
|
||||
|
||||
for (int i = 0; i < list.size(); ++i) {
|
||||
for (int i = 0; i < list.size(); i++) {
|
||||
Tile &t = list[i];
|
||||
QString file = TILES_DIR + QString("/%1/%2-%3-%4")
|
||||
.arg(_name).arg(t.zoom()).arg(t.xy().rx()).arg(t.xy().ry());
|
||||
QString file = tileFile(t);
|
||||
QFileInfo fi(file);
|
||||
|
||||
if (fi.exists()) {
|
||||
if (!t.pixmap().load(file))
|
||||
fprintf(stderr, "Error loading map tile: %s\n",
|
||||
qPrintable(file));
|
||||
} else {
|
||||
t.pixmap() = QPixmap(TILE_SIZE, TILE_SIZE);
|
||||
t.pixmap().fill();
|
||||
|
||||
QString url(_url);
|
||||
url.replace("$z", QString::number(t.zoom()));
|
||||
url.replace("$x", QString::number(t.xy().x()));
|
||||
url.replace("$y", QString::number(t.xy().y()));
|
||||
dl.append(Download(url, file));
|
||||
}
|
||||
if (!fi.exists()) {
|
||||
fillTile(t);
|
||||
dl.append(Download(tileUrl(t), file));
|
||||
} else
|
||||
loadTileFile(t, file);
|
||||
}
|
||||
|
||||
if (!dl.empty())
|
||||
Downloader::instance().get(dl);
|
||||
}
|
||||
|
||||
void Map::loadTilesSync(QList<Tile> &list)
|
||||
{
|
||||
QList<Download> dl;
|
||||
|
||||
for (int i = 0; i < list.size(); i++) {
|
||||
Tile &t = list[i];
|
||||
QString file = tileFile(t);
|
||||
QFileInfo fi(file);
|
||||
|
||||
if (!fi.exists())
|
||||
dl.append(Download(tileUrl(t), file));
|
||||
else
|
||||
loadTileFile(t, file);
|
||||
}
|
||||
|
||||
if (dl.empty())
|
||||
return;
|
||||
|
||||
QEventLoop wait;
|
||||
connect(&Downloader::instance(), SIGNAL(finished()), &wait, SLOT(quit()));
|
||||
if (Downloader::instance().get(dl))
|
||||
wait.exec();
|
||||
|
||||
for (int i = 0; i < list.size(); i++) {
|
||||
Tile &t = list[i];
|
||||
|
||||
if (t.pixmap().isNull()) {
|
||||
QString file = tileFile(t);
|
||||
QFileInfo fi(file);
|
||||
|
||||
if (!(fi.exists() && loadTileFile(t, file)))
|
||||
fillTile(t);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void Map::fillTile(Tile &tile)
|
||||
{
|
||||
tile.pixmap() = QPixmap(TILE_SIZE, TILE_SIZE);
|
||||
tile.pixmap().fill();
|
||||
}
|
||||
|
||||
bool Map::loadTileFile(Tile &tile, const QString &file)
|
||||
{
|
||||
if (!tile.pixmap().load(file)) {
|
||||
fprintf(stderr, "%s: error loading tile file\n", qPrintable(file));
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
QString Map::tileUrl(const Tile &tile)
|
||||
{
|
||||
QString url(_url);
|
||||
|
||||
url.replace("$z", QString::number(tile.zoom()));
|
||||
url.replace("$x", QString::number(tile.xy().x()));
|
||||
url.replace("$y", QString::number(tile.xy().y()));
|
||||
|
||||
return url;
|
||||
}
|
||||
|
||||
QString Map::tileFile(const Tile &tile)
|
||||
{
|
||||
QString file = TILES_DIR + QString("/%1/%2-%3-%4").arg(_name)
|
||||
.arg(tile.zoom()).arg(tile.xy().x()).arg(tile.xy().y());
|
||||
|
||||
return file;
|
||||
}
|
||||
|
||||
void Map::clearCache()
|
||||
{
|
||||
QString path = TILES_DIR + QString("/") + _name;
|
||||
|
12
src/map.h
12
src/map.h
@ -10,7 +10,7 @@ public:
|
||||
{_xy = xy; _zoom = zoom;}
|
||||
|
||||
int zoom() const {return _zoom;}
|
||||
QPoint& xy() {return _xy;}
|
||||
const QPoint& xy() const {return _xy;}
|
||||
QPixmap& pixmap() {return _pixmap;}
|
||||
|
||||
private:
|
||||
@ -29,7 +29,7 @@ public:
|
||||
const QString &url = QString());
|
||||
|
||||
const QString &name() const {return _name;}
|
||||
void loadTiles(QList<Tile> &list);
|
||||
void loadTiles(QList<Tile> &list, bool block);
|
||||
void clearCache();
|
||||
|
||||
signals:
|
||||
@ -39,6 +39,14 @@ private slots:
|
||||
void emitLoaded();
|
||||
|
||||
private:
|
||||
QString tileUrl(const Tile &tile);
|
||||
QString tileFile(const Tile &tile);
|
||||
bool loadTileFile(Tile &tile, const QString &file);
|
||||
void fillTile(Tile &tile);
|
||||
|
||||
void loadTilesAsync(QList<Tile> &list);
|
||||
void loadTilesSync(QList<Tile> &list);
|
||||
|
||||
QString _name;
|
||||
QString _url;
|
||||
};
|
||||
|
9
src/margins.cpp
Normal file
9
src/margins.cpp
Normal file
@ -0,0 +1,9 @@
|
||||
#include "margins.h"
|
||||
|
||||
|
||||
QDebug operator<<(QDebug dbg, const MarginsF &margins)
|
||||
{
|
||||
dbg.nospace() << "MarginsF(" << margins.left() << ", " << margins.top()
|
||||
<< ", " << margins.right() << margins.bottom() << ")";
|
||||
return dbg.maybeSpace();
|
||||
}
|
30
src/margins.h
Normal file
30
src/margins.h
Normal file
@ -0,0 +1,30 @@
|
||||
#ifndef MARGINS_H
|
||||
#define MARGINS_H
|
||||
|
||||
#include <QtGlobal>
|
||||
#include <QDebug>
|
||||
|
||||
class MarginsF
|
||||
{
|
||||
public:
|
||||
MarginsF() {_left = 0; _top = 0; _right = 0; _bottom = 0;}
|
||||
MarginsF(qreal left, qreal top, qreal right, qreal bottom)
|
||||
{_left = left, _top = top; _right = right; _bottom = bottom;}
|
||||
|
||||
qreal left() const {return _left;}
|
||||
qreal top() const {return _top;}
|
||||
qreal right() const {return _right;}
|
||||
qreal bottom() const {return _bottom;}
|
||||
|
||||
qreal &rleft() {return _left;}
|
||||
qreal &rtop() {return _top;}
|
||||
qreal &rright() {return _right;}
|
||||
qreal &rbottom() {return _bottom;}
|
||||
|
||||
private:
|
||||
qreal _left, _top, _right, _bottom;
|
||||
};
|
||||
|
||||
QDebug operator<<(QDebug dbg, const MarginsF &margins);
|
||||
|
||||
#endif // MARGINS_H
|
86
src/misc.cpp
Normal file
86
src/misc.cpp
Normal file
@ -0,0 +1,86 @@
|
||||
#include <cmath>
|
||||
#include <QApplication>
|
||||
#include "misc.h"
|
||||
|
||||
|
||||
double niceNum(double x, int round)
|
||||
{
|
||||
int expv;
|
||||
double f;
|
||||
double nf;
|
||||
|
||||
expv = (int)floor(log10(x));
|
||||
f = x / pow(10.0, expv);
|
||||
|
||||
if (round) {
|
||||
if (f < 1.5)
|
||||
nf = 1.0;
|
||||
else if (f < 3.0)
|
||||
nf = 2.0;
|
||||
else if (f < 7.0)
|
||||
nf = 5.0;
|
||||
else
|
||||
nf = 10.0;
|
||||
} else {
|
||||
if (f <= 1.0)
|
||||
nf = 1.0;
|
||||
else if (f <= 2.0)
|
||||
nf = 2.0;
|
||||
else if (f <= 5.0)
|
||||
nf = 5.0;
|
||||
else
|
||||
nf = 10.0;
|
||||
}
|
||||
|
||||
return nf * pow(10.0, expv);
|
||||
}
|
||||
|
||||
QString timeSpan(qreal time)
|
||||
{
|
||||
unsigned h, m, s;
|
||||
|
||||
h = time / 3600;
|
||||
m = (time - (h * 3600)) / 60;
|
||||
s = time - (h * 3600) - (m * 60);
|
||||
|
||||
return QString("%1:%2:%3").arg(h).arg(m, 2, 10, QChar('0'))
|
||||
.arg(s, 2, 10, QChar('0'));
|
||||
}
|
||||
|
||||
QString distance(qreal value, Units units)
|
||||
{
|
||||
if (units == Imperial) {
|
||||
if (value < MIINM)
|
||||
return QString::number(value * M2FT, 'f', 0) + UNIT_SPACE
|
||||
+ qApp->translate("Misc", "ft");
|
||||
else
|
||||
return QString::number(value * M2MI, 'f', 1) + UNIT_SPACE
|
||||
+ qApp->translate("Misc", "mi");
|
||||
} else {
|
||||
if (value < KMINM)
|
||||
return QString::number(value, 'f', 0) + UNIT_SPACE
|
||||
+ qApp->translate("Misc", "m");
|
||||
else
|
||||
return QString::number(value * M2KM, 'f', 1) + UNIT_SPACE
|
||||
+ qApp->translate("Misc", "km");
|
||||
}
|
||||
}
|
||||
|
||||
QString elevation(qreal value, Units units)
|
||||
{
|
||||
if (units == Metric)
|
||||
return QString::number(value, 'f', 0) + UNIT_SPACE
|
||||
+ qApp->translate("Misc", "m");
|
||||
else
|
||||
return QString::number(value * M2FT, 'f', 0) + UNIT_SPACE
|
||||
+ qApp->translate("Misc", "ft");
|
||||
}
|
||||
|
||||
QString coordinates(const QPointF &value)
|
||||
{
|
||||
QChar yH = (value.y() < 0) ? 'S' : 'N';
|
||||
QChar xH = (value.x() < 0) ? 'W' : 'E';
|
||||
|
||||
return QString::number(qAbs(value.y()), 'f', 5) + yH + "," + QChar(0x00A0)
|
||||
+ QString::number(qAbs(value.x()), 'f', 5) + xH;
|
||||
}
|
15
src/misc.h
Normal file
15
src/misc.h
Normal file
@ -0,0 +1,15 @@
|
||||
#ifndef MISC_H
|
||||
#define MISC_H
|
||||
|
||||
#include <QString>
|
||||
#include <QPoint>
|
||||
#include "units.h"
|
||||
|
||||
double niceNum(double x, int round);
|
||||
|
||||
QString timeSpan(qreal time);
|
||||
QString distance(qreal value, Units units);
|
||||
QString elevation(qreal value, Units units);
|
||||
QString coordinates(const QPointF &value);
|
||||
|
||||
#endif // MISC_H
|
@ -1,34 +0,0 @@
|
||||
#include <cmath>
|
||||
#include "nicenum.h"
|
||||
|
||||
double niceNum(double x, int round)
|
||||
{
|
||||
int expv;
|
||||
double f;
|
||||
double nf;
|
||||
|
||||
expv = (int)floor(log10(x));
|
||||
f = x / pow(10.0, expv);
|
||||
|
||||
if (round) {
|
||||
if (f < 1.5)
|
||||
nf = 1.0;
|
||||
else if (f < 3.0)
|
||||
nf = 2.0;
|
||||
else if (f < 7.0)
|
||||
nf = 5.0;
|
||||
else
|
||||
nf = 10.0;
|
||||
} else {
|
||||
if (f <= 1.0)
|
||||
nf = 1.0;
|
||||
else if (f <= 2.0)
|
||||
nf = 2.0;
|
||||
else if (f <= 5.0)
|
||||
nf = 5.0;
|
||||
else
|
||||
nf = 10.0;
|
||||
}
|
||||
|
||||
return nf * pow(10.0, expv);
|
||||
}
|
@ -1,6 +0,0 @@
|
||||
#ifndef NICENUM_H
|
||||
#define NICENUM_H
|
||||
|
||||
double niceNum(double x, int round);
|
||||
|
||||
#endif // NICENUM_H
|
180
src/parser.cpp
180
src/parser.cpp
@ -1,38 +1,96 @@
|
||||
#include "parser.h"
|
||||
|
||||
|
||||
void Parser::handleExtensionData(QStringRef element, const QString &value)
|
||||
void Parser::handleTrackpointData(DataType type, const QString &value)
|
||||
{
|
||||
if (element == "speed")
|
||||
_track->last().speed = value.toDouble();
|
||||
else if (element == "hr" || element == "heartrate")
|
||||
_track->last().heartRate = value.toDouble();
|
||||
switch (type) {
|
||||
case Elevation:
|
||||
_track->last().setElevation(value.toLatin1().toDouble());
|
||||
break;
|
||||
case Time:
|
||||
_track->last().setTimestamp(QDateTime::fromString(value.toLatin1(),
|
||||
Qt::ISODate));
|
||||
break;
|
||||
case Geoidheight:
|
||||
_track->last().setGeoidHeight(value.toLatin1().toDouble());
|
||||
break;
|
||||
case Speed:
|
||||
_track->last().setSpeed(value.toDouble());
|
||||
break;
|
||||
case HeartRate:
|
||||
_track->last().setHeartRate(value.toDouble());
|
||||
break;
|
||||
case Temperature:
|
||||
_track->last().setTemperature(value.toDouble());
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void Parser::handleTrekPointData(QStringRef element, const QString &value)
|
||||
void Parser::handleWaypointData(DataType type, const QString &value)
|
||||
{
|
||||
if (element == "ele")
|
||||
_track->last().elevation = value.toLatin1().toDouble();
|
||||
else if (element == "time")
|
||||
_track->last().timestamp = QDateTime::fromString(value.toLatin1(),
|
||||
Qt::ISODate);
|
||||
else if (element == "geoidheight")
|
||||
_track->last().geoidheight = value.toLatin1().toDouble();
|
||||
switch (type) {
|
||||
case Name:
|
||||
_waypoints.last().setName(value);
|
||||
break;
|
||||
case Description:
|
||||
_waypoints.last().setDescription(value);
|
||||
break;
|
||||
case Time:
|
||||
_waypoints.last().setTimestamp(QDateTime::fromString(
|
||||
value.toLatin1(), Qt::ISODate));
|
||||
break;
|
||||
case Elevation:
|
||||
_waypoints.last().setElevation(value.toLatin1().toDouble());
|
||||
break;
|
||||
case Geoidheight:
|
||||
_waypoints.last().setGeoidHeight(value.toLatin1().toDouble());
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void Parser::handleWayPointData(QStringRef element, const QString &value)
|
||||
void Parser::handleRoutepointData(DataType type, const QString &value)
|
||||
{
|
||||
if (element == "name")
|
||||
_waypoints.last().setDescription(value);
|
||||
switch (type) {
|
||||
case Name:
|
||||
_route->last().setName(value);
|
||||
break;
|
||||
case Description:
|
||||
_route->last().setDescription(value);
|
||||
break;
|
||||
case Time:
|
||||
_route->last().setTimestamp(QDateTime::fromString(
|
||||
value.toLatin1(), Qt::ISODate));
|
||||
break;
|
||||
case Elevation:
|
||||
_route->last().setElevation(value.toLatin1().toDouble());
|
||||
break;
|
||||
case Geoidheight:
|
||||
_route->last().setGeoidHeight(value.toLatin1().toDouble());
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void Parser::handleTrekPointAttributes(const QXmlStreamAttributes &attr)
|
||||
void Parser::handleTrackpointAttributes(const QXmlStreamAttributes &attr)
|
||||
{
|
||||
_track->last().coordinates.setY(attr.value("lat").toLatin1().toDouble());
|
||||
_track->last().coordinates.setX(attr.value("lon").toLatin1().toDouble());
|
||||
_track->last().setCoordinates(QPointF(
|
||||
attr.value("lon").toLatin1().toDouble(),
|
||||
attr.value("lat").toLatin1().toDouble()));
|
||||
}
|
||||
|
||||
void Parser::handleWayPointAttributes(const QXmlStreamAttributes &attr)
|
||||
void Parser::handleRoutepointAttributes(const QXmlStreamAttributes &attr)
|
||||
{
|
||||
_route->last().setCoordinates(QPointF(
|
||||
attr.value("lon").toLatin1().toDouble(),
|
||||
attr.value("lat").toLatin1().toDouble()));
|
||||
}
|
||||
|
||||
void Parser::handleWaypointAttributes(const QXmlStreamAttributes &attr)
|
||||
{
|
||||
_waypoints.last().setCoordinates(QPointF(
|
||||
attr.value("lon").toLatin1().toDouble(),
|
||||
@ -43,7 +101,9 @@ void Parser::tpExtension()
|
||||
{
|
||||
while (_reader.readNextStartElement()) {
|
||||
if (_reader.name() == "hr")
|
||||
handleExtensionData(_reader.name(), _reader.readElementText());
|
||||
handleTrackpointData(HeartRate, _reader.readElementText());
|
||||
else if (_reader.name() == "atemp")
|
||||
handleTrackpointData(Temperature, _reader.readElementText());
|
||||
else
|
||||
_reader.skipCurrentElement();
|
||||
}
|
||||
@ -52,9 +112,12 @@ void Parser::tpExtension()
|
||||
void Parser::extensions()
|
||||
{
|
||||
while (_reader.readNextStartElement()) {
|
||||
if (_reader.name() == "speed" || _reader.name() == "hr"
|
||||
|| _reader.name() == "heartrate")
|
||||
handleExtensionData(_reader.name(), _reader.readElementText());
|
||||
if (_reader.name() == "speed")
|
||||
handleTrackpointData(Speed, _reader.readElementText());
|
||||
else if (_reader.name() == "hr" || _reader.name() == "heartrate")
|
||||
handleTrackpointData(HeartRate, _reader.readElementText());
|
||||
else if (_reader.name() == "temp")
|
||||
handleTrackpointData(Temperature, _reader.readElementText());
|
||||
else if (_reader.name() == "TrackPointExtension")
|
||||
tpExtension();
|
||||
else
|
||||
@ -62,12 +125,15 @@ void Parser::extensions()
|
||||
}
|
||||
}
|
||||
|
||||
void Parser::trackPointData()
|
||||
void Parser::trackpointData()
|
||||
{
|
||||
while (_reader.readNextStartElement()) {
|
||||
if (_reader.name() == "ele" || _reader.name() == "time"
|
||||
|| _reader.name() == "geoidheight")
|
||||
handleTrekPointData(_reader.name(), _reader.readElementText());
|
||||
if (_reader.name() == "ele")
|
||||
handleTrackpointData(Elevation, _reader.readElementText());
|
||||
else if (_reader.name() == "time")
|
||||
handleTrackpointData(Time, _reader.readElementText());
|
||||
else if (_reader.name() == "geoidheight")
|
||||
handleTrackpointData(Geoidheight, _reader.readElementText());
|
||||
else if (_reader.name() == "extensions")
|
||||
extensions();
|
||||
else
|
||||
@ -75,13 +141,43 @@ void Parser::trackPointData()
|
||||
}
|
||||
}
|
||||
|
||||
void Parser::trackPoints()
|
||||
void Parser::routepointData()
|
||||
{
|
||||
while (_reader.readNextStartElement()) {
|
||||
if (_reader.name() == "name")
|
||||
handleRoutepointData(Name, _reader.readElementText());
|
||||
else if (_reader.name() == "desc")
|
||||
handleRoutepointData(Description, _reader.readElementText());
|
||||
else if (_reader.name() == "ele")
|
||||
handleRoutepointData(Elevation, _reader.readElementText());
|
||||
else if (_reader.name() == "geoidheight")
|
||||
handleRoutepointData(Geoidheight, _reader.readElementText());
|
||||
else if (_reader.name() == "time")
|
||||
handleRoutepointData(Time, _reader.readElementText());
|
||||
else
|
||||
_reader.skipCurrentElement();
|
||||
}
|
||||
}
|
||||
|
||||
void Parser::trackpoints()
|
||||
{
|
||||
while (_reader.readNextStartElement()) {
|
||||
if (_reader.name() == "trkpt") {
|
||||
_track->append(Trackpoint());
|
||||
handleTrekPointAttributes(_reader.attributes());
|
||||
trackPointData();
|
||||
handleTrackpointAttributes(_reader.attributes());
|
||||
trackpointData();
|
||||
} else
|
||||
_reader.skipCurrentElement();
|
||||
}
|
||||
}
|
||||
|
||||
void Parser::routepoints()
|
||||
{
|
||||
while (_reader.readNextStartElement()) {
|
||||
if (_reader.name() == "rtept") {
|
||||
_route->append(Waypoint());
|
||||
handleRoutepointAttributes(_reader.attributes());
|
||||
routepointData();
|
||||
} else
|
||||
_reader.skipCurrentElement();
|
||||
}
|
||||
@ -91,17 +187,25 @@ void Parser::track()
|
||||
{
|
||||
while (_reader.readNextStartElement()) {
|
||||
if (_reader.name() == "trkseg") {
|
||||
trackPoints();
|
||||
trackpoints();
|
||||
} else
|
||||
_reader.skipCurrentElement();
|
||||
}
|
||||
}
|
||||
|
||||
void Parser::wayPointData()
|
||||
void Parser::waypointData()
|
||||
{
|
||||
while (_reader.readNextStartElement()) {
|
||||
if (_reader.name() == "name")
|
||||
handleWayPointData(_reader.name(), _reader.readElementText());
|
||||
handleWaypointData(Name, _reader.readElementText());
|
||||
else if (_reader.name() == "desc")
|
||||
handleWaypointData(Description, _reader.readElementText());
|
||||
else if (_reader.name() == "ele")
|
||||
handleWaypointData(Elevation, _reader.readElementText());
|
||||
else if (_reader.name() == "geoidheight")
|
||||
handleWaypointData(Geoidheight, _reader.readElementText());
|
||||
else if (_reader.name() == "time")
|
||||
handleWaypointData(Time, _reader.readElementText());
|
||||
else
|
||||
_reader.skipCurrentElement();
|
||||
}
|
||||
@ -114,10 +218,14 @@ void Parser::gpx()
|
||||
_tracks.append(QVector<Trackpoint>());
|
||||
_track = &_tracks.back();
|
||||
track();
|
||||
} else if (_reader.name() == "rte") {
|
||||
_routes.append(QVector<Waypoint>());
|
||||
_route = &_routes.back();
|
||||
routepoints();
|
||||
} else if (_reader.name() == "wpt") {
|
||||
_waypoints.append(Waypoint());
|
||||
handleWayPointAttributes(_reader.attributes());
|
||||
wayPointData();
|
||||
handleWaypointAttributes(_reader.attributes());
|
||||
waypointData();
|
||||
} else
|
||||
_reader.skipCurrentElement();
|
||||
}
|
||||
|
33
src/parser.h
33
src/parser.h
@ -11,32 +11,45 @@
|
||||
class Parser
|
||||
{
|
||||
public:
|
||||
Parser(QList<QVector<Trackpoint> > &tracks, QList<Waypoint> &waypoints)
|
||||
: _tracks(tracks), _waypoints(waypoints) {_track = 0;}
|
||||
Parser(QList<QVector<Trackpoint> > &tracks,
|
||||
QList<QVector<Waypoint> > &routes, QList<Waypoint> &waypoints)
|
||||
: _tracks(tracks), _routes(routes), _waypoints(waypoints)
|
||||
{_track = 0; _route = 0;}
|
||||
|
||||
bool loadFile(QIODevice *device);
|
||||
QString errorString() const {return _reader.errorString();}
|
||||
int errorLine() const {return _reader.lineNumber();}
|
||||
|
||||
private:
|
||||
enum DataType {
|
||||
Name, Description, Elevation, Time, Geoidheight, Speed, HeartRate,
|
||||
Temperature
|
||||
};
|
||||
|
||||
bool parse();
|
||||
void gpx();
|
||||
void track();
|
||||
void trackPoints();
|
||||
void trackpoints();
|
||||
void routepoints();
|
||||
void tpExtension();
|
||||
void extensions();
|
||||
void trackPointData();
|
||||
void wayPointData();
|
||||
void trackpointData();
|
||||
void routepointData();
|
||||
void waypointData();
|
||||
|
||||
void handleWayPointAttributes(const QXmlStreamAttributes &attr);
|
||||
void handleWayPointData(QStringRef element, const QString &value);
|
||||
void handleTrekPointAttributes(const QXmlStreamAttributes &attr);
|
||||
void handleTrekPointData(QStringRef element, const QString &value);
|
||||
void handleExtensionData(QStringRef element, const QString &value);
|
||||
void handleWaypointAttributes(const QXmlStreamAttributes &attr);
|
||||
void handleWaypointData(DataType type, const QString &value);
|
||||
void handleTrackpointAttributes(const QXmlStreamAttributes &attr);
|
||||
void handleTrackpointData(DataType type, const QString &value);
|
||||
void handleRoutepointAttributes(const QXmlStreamAttributes &attr);
|
||||
void handleRoutepointData(DataType type, const QString &value);
|
||||
|
||||
QXmlStreamReader _reader;
|
||||
QList<QVector<Trackpoint> > &_tracks;
|
||||
QList<QVector<Waypoint> > &_routes;
|
||||
QList<Waypoint> &_waypoints;
|
||||
QVector<Trackpoint> *_track;
|
||||
QVector<Waypoint> *_route;
|
||||
};
|
||||
|
||||
#endif // PARSER_H
|
||||
|
47
src/poi.cpp
47
src/poi.cpp
@ -1,6 +1,8 @@
|
||||
#include <QFile>
|
||||
#include <QSet>
|
||||
#include <QList>
|
||||
#include <QPainterPath>
|
||||
#include "waypointitem.h"
|
||||
#include "ll.h"
|
||||
#include "gpx.h"
|
||||
#include "poi.h"
|
||||
@ -105,10 +107,18 @@ bool POI::loadCSVFile(const QString &fileName)
|
||||
_errorLine = ln;
|
||||
return false;
|
||||
}
|
||||
QByteArray ba = list[2].trimmed();
|
||||
Waypoint wp(QPointF(lon, lat));
|
||||
|
||||
_data.append(Waypoint(QPointF(lon, lat),
|
||||
QString::fromUtf8(ba.data(), ba.size())));
|
||||
QByteArray ba = list[2].trimmed();
|
||||
QString name = QString::fromUtf8(ba.data(), ba.size());
|
||||
wp.setName(name);
|
||||
|
||||
if (list.size() > 3) {
|
||||
ba = list[3].trimmed();
|
||||
wp.setDescription(QString::fromUtf8(ba.data(), ba.size()));
|
||||
}
|
||||
|
||||
_data.append(wp);
|
||||
ln++;
|
||||
}
|
||||
index.end = _data.size() - 1;
|
||||
@ -135,14 +145,39 @@ static bool cb(size_t data, void* context)
|
||||
return true;
|
||||
}
|
||||
|
||||
QVector<Waypoint> POI::points(const QVector<QPointF> &path, qreal radius) const
|
||||
QVector<Waypoint> POI::points(const QPainterPath &path, qreal radius) const
|
||||
{
|
||||
QVector<Waypoint> ret;
|
||||
QSet<int> set;
|
||||
qreal min[2], max[2];
|
||||
|
||||
for (int i = 0; i < path.count(); i++) {
|
||||
const QPointF &p = path.at(i);
|
||||
for (int i = 0; i < path.elementCount(); i++) {
|
||||
QPointF p = mercator2ll(path.elementAt(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);
|
||||
}
|
||||
|
||||
QSet<int>::const_iterator i = set.constBegin();
|
||||
while (i != set.constEnd()) {
|
||||
ret.append(_data.at(*i));
|
||||
++i;
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
QVector<Waypoint> POI::points(const QList<WaypointItem*> &list, qreal radius)
|
||||
const
|
||||
{
|
||||
QVector<Waypoint> ret;
|
||||
QSet<int> set;
|
||||
qreal min[2], max[2];
|
||||
|
||||
for (int i = 0; i < list.count(); i++) {
|
||||
const QPointF &p = list.at(i)->waypoint().coordinates();
|
||||
min[0] = p.x() - radius;
|
||||
min[1] = p.y() - radius;
|
||||
max[0] = p.x() + radius;
|
||||
|
11
src/poi.h
11
src/poi.h
@ -8,6 +8,10 @@
|
||||
#include "waypoint.h"
|
||||
#include "rtree.h"
|
||||
|
||||
class QPainterPath;
|
||||
class WaypointItem;
|
||||
|
||||
#define POI_RADIUS 0.01
|
||||
|
||||
class POI
|
||||
{
|
||||
@ -17,8 +21,11 @@ public:
|
||||
const QString &errorString() const {return _error;}
|
||||
int errorLine() const {return _errorLine;}
|
||||
|
||||
QVector<Waypoint> points(const QVector<QPointF> &path,
|
||||
qreal radius = 0.01) const;
|
||||
QVector<Waypoint> points(const QPainterPath &path,
|
||||
qreal radius = POI_RADIUS) const;
|
||||
QVector<Waypoint> points(const QList<WaypointItem*> &list,
|
||||
qreal radius = POI_RADIUS) const;
|
||||
|
||||
const QStringList &files() const {return _files;}
|
||||
void enableFile(const QString &fileName, bool enable);
|
||||
void clear();
|
||||
|
30
src/route.cpp
Normal file
30
src/route.cpp
Normal file
@ -0,0 +1,30 @@
|
||||
#include "ll.h"
|
||||
#include "route.h"
|
||||
|
||||
Route::Route(const QVector<Waypoint> &data) : _data(data)
|
||||
{
|
||||
qreal dist = 0;
|
||||
|
||||
_dd.append(dist);
|
||||
for (int i = 1; i < data.count(); i++) {
|
||||
dist += llDistance(data.at(i).coordinates(), data.at(i-1).coordinates());
|
||||
_dd.append(dist);
|
||||
}
|
||||
}
|
||||
|
||||
QVector<QPointF> Route::elevation() const
|
||||
{
|
||||
QVector<QPointF> graph;
|
||||
|
||||
for (int i = 0; i < _data.size(); i++)
|
||||
if (_data.at(i).hasElevation())
|
||||
graph.append(QPointF(_dd.at(i), _data.at(i).elevation()
|
||||
- _data.at(i).geoidHeight()));
|
||||
|
||||
return graph;
|
||||
}
|
||||
|
||||
qreal Route::distance() const
|
||||
{
|
||||
return (_dd.isEmpty()) ? 0 : _dd.last();
|
||||
}
|
24
src/route.h
Normal file
24
src/route.h
Normal file
@ -0,0 +1,24 @@
|
||||
#ifndef ROUTE_H
|
||||
#define ROUTE_H
|
||||
|
||||
#include <QVector>
|
||||
#include "waypoint.h"
|
||||
|
||||
class Route
|
||||
{
|
||||
public:
|
||||
Route(const QVector<Waypoint> &data);
|
||||
|
||||
const QVector<Waypoint> &route() const {return _data;}
|
||||
QVector<QPointF> elevation() const;
|
||||
|
||||
qreal distance() const;
|
||||
|
||||
bool isNull() const {return (_dd.count() < 2);}
|
||||
|
||||
private:
|
||||
const QVector<Waypoint> &_data;
|
||||
QVector<qreal> _dd;
|
||||
};
|
||||
|
||||
#endif // ROUTE_H
|
132
src/routeitem.cpp
Normal file
132
src/routeitem.cpp
Normal file
@ -0,0 +1,132 @@
|
||||
#include <QApplication>
|
||||
#include <QPainter>
|
||||
#include "ll.h"
|
||||
#include "misc.h"
|
||||
#include "waypoint.h"
|
||||
#include "waypointitem.h"
|
||||
#include "tooltip.h"
|
||||
#include "routeitem.h"
|
||||
|
||||
|
||||
#define ROUTE_WIDTH 3
|
||||
|
||||
QString RouteItem::toolTip()
|
||||
{
|
||||
ToolTip tt;
|
||||
|
||||
tt.insert(qApp->translate("RouteItem", "Distance"),
|
||||
::distance(_distance, _units));
|
||||
|
||||
return tt.toString();
|
||||
}
|
||||
|
||||
void RouteItem::updateShape()
|
||||
{
|
||||
QPainterPathStroker s;
|
||||
s.setWidth(ROUTE_WIDTH * 1.0/scale());
|
||||
_shape = s.createStroke(_path);
|
||||
}
|
||||
|
||||
RouteItem::RouteItem(const Route &route, QGraphicsItem *parent)
|
||||
: QGraphicsItem(parent)
|
||||
{
|
||||
WaypointItem *wi;
|
||||
|
||||
QVector<Waypoint> r = route.route();
|
||||
Q_ASSERT(r.count() >= 2);
|
||||
|
||||
wi = new WaypointItem(r.at(0));
|
||||
wi->setParentItem(this);
|
||||
const QPointF &p = r.at(0).coordinates();
|
||||
_path.moveTo(ll2mercator(QPointF(p.x(), -p.y())));
|
||||
for (int i = 1; i < r.size(); i++) {
|
||||
const QPointF &p = r.at(i).coordinates();
|
||||
_path.lineTo(ll2mercator(QPointF(p.x(), -p.y())));
|
||||
wi = new WaypointItem(r.at(i));
|
||||
wi->setParentItem(this);
|
||||
}
|
||||
|
||||
_units = Metric;
|
||||
_distance = route.distance();
|
||||
|
||||
setToolTip(toolTip());
|
||||
setCursor(Qt::ArrowCursor);
|
||||
|
||||
updateShape();
|
||||
|
||||
QBrush brush(Qt::SolidPattern);
|
||||
_pen = QPen(brush, ROUTE_WIDTH, Qt::DotLine);
|
||||
|
||||
_marker = new MarkerItem(this);
|
||||
_marker->setPos(_path.pointAtPercent(0));
|
||||
}
|
||||
|
||||
void RouteItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *option,
|
||||
QWidget *widget)
|
||||
{
|
||||
Q_UNUSED(option);
|
||||
Q_UNUSED(widget);
|
||||
|
||||
painter->setPen(_pen);
|
||||
painter->drawPath(_path);
|
||||
|
||||
/*
|
||||
painter->setPen(Qt::red);
|
||||
painter->drawRect(boundingRect());
|
||||
*/
|
||||
}
|
||||
|
||||
void RouteItem::setScale(qreal scale)
|
||||
{
|
||||
prepareGeometryChange();
|
||||
|
||||
_pen.setWidthF(ROUTE_WIDTH * 1.0/scale);
|
||||
QGraphicsItem::setScale(scale);
|
||||
|
||||
QList<QGraphicsItem *> childs = childItems();
|
||||
for (int i = 0; i < childs.count(); i++)
|
||||
childs.at(i)->setScale(1.0/scale);
|
||||
|
||||
updateShape();
|
||||
}
|
||||
|
||||
void RouteItem::setColor(const QColor &color)
|
||||
{
|
||||
_pen.setColor(color);
|
||||
update();
|
||||
}
|
||||
|
||||
void RouteItem::setUnits(enum Units units)
|
||||
{
|
||||
_units = units;
|
||||
setToolTip(toolTip());
|
||||
}
|
||||
|
||||
void RouteItem::moveMarker(qreal distance)
|
||||
{
|
||||
if (distance > _distance)
|
||||
_marker->setVisible(false);
|
||||
else {
|
||||
_marker->setVisible(true);
|
||||
_marker->setPos(_path.pointAtPercent(distance / _distance));
|
||||
}
|
||||
}
|
||||
|
||||
void RouteItem::showWaypoints(bool show)
|
||||
{
|
||||
QList<QGraphicsItem *> childs = childItems();
|
||||
for (int i = 0; i < childs.count(); i++)
|
||||
if (childs.at(i) != _marker)
|
||||
childs.at(i)->setVisible(show);
|
||||
}
|
||||
|
||||
void RouteItem::showWaypointLabels(bool show)
|
||||
{
|
||||
QList<QGraphicsItem *> childs = childItems();
|
||||
for (int i = 0; i < childs.count(); i++) {
|
||||
if (childs.at(i) != _marker) {
|
||||
WaypointItem *wi = static_cast<WaypointItem*>(childs.at(i));
|
||||
wi->showLabel(show);
|
||||
}
|
||||
}
|
||||
}
|
46
src/routeitem.h
Normal file
46
src/routeitem.h
Normal file
@ -0,0 +1,46 @@
|
||||
#ifndef ROUTEITEM_H
|
||||
#define ROUTEITEM_H
|
||||
|
||||
#include <QGraphicsItem>
|
||||
#include "markeritem.h"
|
||||
#include "route.h"
|
||||
#include "units.h"
|
||||
|
||||
|
||||
class RouteItem : public QGraphicsItem
|
||||
{
|
||||
public:
|
||||
RouteItem(const Route &route, QGraphicsItem *parent = 0);
|
||||
|
||||
QPainterPath shape() const {return _shape;}
|
||||
QRectF boundingRect() const {return _shape.boundingRect();}
|
||||
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option,
|
||||
QWidget *widget);
|
||||
|
||||
const QPainterPath &path() const {return _path;}
|
||||
|
||||
void setScale(qreal scale);
|
||||
void setColor(const QColor &color);
|
||||
void setUnits(enum Units units);
|
||||
|
||||
void showMarker(bool show) {_marker->setVisible(show);}
|
||||
void moveMarker(qreal distance);
|
||||
|
||||
void showWaypoints(bool show);
|
||||
void showWaypointLabels(bool show);
|
||||
|
||||
private:
|
||||
void updateShape();
|
||||
QString toolTip();
|
||||
|
||||
QPainterPath _path;
|
||||
QPainterPath _shape;
|
||||
QPen _pen;
|
||||
|
||||
MarkerItem *_marker;
|
||||
|
||||
Units _units;
|
||||
qreal _distance;
|
||||
};
|
||||
|
||||
#endif // ROUTEITEM_H
|
@ -1,7 +1,7 @@
|
||||
#include <QPainter>
|
||||
#include "config.h"
|
||||
#include "ll.h"
|
||||
#include "nicenum.h"
|
||||
#include "misc.h"
|
||||
#include "scaleitem.h"
|
||||
|
||||
|
||||
@ -67,22 +67,22 @@ void ScaleItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *option,
|
||||
for (int i = 0; i < SEGMENTS; i += 2)
|
||||
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());
|
||||
*/
|
||||
if (aa)
|
||||
painter->setRenderHint(QPainter::Antialiasing, true);
|
||||
}
|
||||
|
||||
QString ScaleItem::units() const
|
||||
{
|
||||
if (_units == Imperial)
|
||||
return _scale ? QObject::tr("mi") : QObject::tr("ft");
|
||||
return _scale ? qApp->translate("ScaleItem", "mi")
|
||||
: qApp->translate("ScaleItem", "ft");
|
||||
else
|
||||
return _scale ? QObject::tr("km") : QObject::tr("m");
|
||||
return _scale ? qApp->translate("ScaleItem", "km")
|
||||
: qApp->translate("ScaleItem", "m");
|
||||
}
|
||||
|
||||
void ScaleItem::computeScale()
|
||||
|
@ -3,20 +3,29 @@
|
||||
|
||||
#define WINDOW_SETTINGS_GROUP "Window"
|
||||
#define WINDOW_SIZE_SETTING "size"
|
||||
#define WINDOW_POS_SETTING "pos"
|
||||
#define WINDOW_POS_SETTING "pos"
|
||||
|
||||
#define SETTINGS_SETTINGS_GROUP "Settings"
|
||||
#define UNITS_SETTING "units"
|
||||
#define UNITS_SETTING "units"
|
||||
#define SHOW_TOOLBARS_SETTING "toolbar"
|
||||
#define SHOW_GRAPHS_SETTING "graphs"
|
||||
#define SHOW_GRAPHS_SETTING "graphs"
|
||||
|
||||
#define MAP_SETTINGS_GROUP "Map"
|
||||
#define CURRENT_MAP_SETTING "map"
|
||||
#define CURRENT_MAP_SETTING "map"
|
||||
#define SHOW_MAP_SETTING "show"
|
||||
|
||||
#define POI_SETTINGS_GROUP "POI"
|
||||
#define POI_SETTINGS_GROUP "POI"
|
||||
#define OVERLAP_POI_SETTING "overlap"
|
||||
#define LABELS_POI_SETTING "labels"
|
||||
#define SHOW_POI_SETTING "show"
|
||||
#define DISABLED_POI_FILE_SETTINGS_PREFIX "disabled"
|
||||
#define DISABLED_POI_FILE_SETTING "file"
|
||||
|
||||
#define DATA_SETTINGS_GROUP "Data"
|
||||
#define SHOW_TRACKS_SETTING "tracks"
|
||||
#define SHOW_ROUTES_SETTING "routes"
|
||||
#define SHOW_WAYPOINTS_SETTING "waypoints"
|
||||
#define SHOW_ROUTE_WAYPOINTS_SETTING "routeWaypoints"
|
||||
#define SHOW_WAYPOINT_LABELS_SETTING "waypointLabels"
|
||||
|
||||
#endif // SETTINGS_H
|
||||
|
@ -24,7 +24,7 @@ void SliderItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *option
|
||||
painter->setPen(Qt::red);
|
||||
painter->drawLine(0, 0, 0, -_area.height());
|
||||
|
||||
//painter->drawRect(boundingRect());
|
||||
// painter->drawRect(boundingRect());
|
||||
}
|
||||
|
||||
QVariant SliderItem::itemChange(GraphicsItemChange change, const QVariant &value)
|
||||
|
@ -3,9 +3,10 @@
|
||||
#include "speedgraph.h"
|
||||
|
||||
|
||||
SpeedGraph::SpeedGraph(QWidget *parent) : GraphView(parent)
|
||||
SpeedGraph::SpeedGraph(QWidget *parent) : GraphTab(parent)
|
||||
{
|
||||
_units = Metric;
|
||||
_showTracks = true;
|
||||
|
||||
setYUnits();
|
||||
setXLabel(tr("Distance"));
|
||||
@ -14,35 +15,39 @@ SpeedGraph::SpeedGraph(QWidget *parent) : GraphView(parent)
|
||||
setSliderPrecision(1);
|
||||
}
|
||||
|
||||
void SpeedGraph::addInfo()
|
||||
void SpeedGraph::setInfo()
|
||||
{
|
||||
GraphView::addInfo(tr("Average"), QString::number(avg() * yScale(), 'f', 1)
|
||||
+ UNIT_SPACE + yUnits());
|
||||
GraphView::addInfo(tr("Maximum"), QString::number(max() * yScale(), 'f', 1)
|
||||
+ UNIT_SPACE + yUnits());
|
||||
|
||||
redraw();
|
||||
if (_showTracks) {
|
||||
GraphView::addInfo(tr("Average"), QString::number(avg() * yScale(), 'f',
|
||||
1) + UNIT_SPACE + yUnits());
|
||||
GraphView::addInfo(tr("Maximum"), QString::number(max() * yScale(), 'f',
|
||||
1) + UNIT_SPACE + yUnits());
|
||||
} else
|
||||
clearInfo();
|
||||
}
|
||||
|
||||
void SpeedGraph::loadGPX(const GPX &gpx)
|
||||
{
|
||||
for (int i = 0; i < gpx.trackCount(); i++) {
|
||||
QVector<QPointF> data;
|
||||
|
||||
gpx.track(i).speedGraph(data);
|
||||
for (int i = 0; i < gpx.tracks().count(); i++) {
|
||||
QVector<QPointF> data = gpx.tracks().at(i)->speed();
|
||||
if (data.count() < 2) {
|
||||
skipColor();
|
||||
continue;
|
||||
}
|
||||
|
||||
_avg.append(QPointF(gpx.track(i).distance(), gpx.track(i).distance()
|
||||
/ gpx.track(i).time()));
|
||||
_avg.append(QPointF(gpx.tracks().at(i)->distance(),
|
||||
gpx.tracks().at(i)->distance() / gpx.tracks().at(i)->time()));
|
||||
|
||||
loadData(data);
|
||||
}
|
||||
|
||||
for (int i = 0; i < gpx.routes().count(); i++)
|
||||
skipColor();
|
||||
|
||||
setXUnits();
|
||||
addInfo();
|
||||
setInfo();
|
||||
|
||||
redraw();
|
||||
}
|
||||
|
||||
qreal SpeedGraph::avg() const
|
||||
@ -100,9 +105,21 @@ void SpeedGraph::setYUnits()
|
||||
void SpeedGraph::setUnits(enum Units units)
|
||||
{
|
||||
_units = units;
|
||||
|
||||
setXUnits();
|
||||
setYUnits();
|
||||
setInfo();
|
||||
|
||||
clearInfo();
|
||||
addInfo();
|
||||
redraw();
|
||||
}
|
||||
|
||||
void SpeedGraph::showTracks(bool show)
|
||||
{
|
||||
_showTracks = show;
|
||||
|
||||
showGraph(show);
|
||||
setXUnits();
|
||||
setInfo();
|
||||
|
||||
redraw();
|
||||
}
|
||||
|
@ -2,32 +2,35 @@
|
||||
#define SPEEDGRAPH_H
|
||||
|
||||
#include <QList>
|
||||
#include "graphview.h"
|
||||
#include "units.h"
|
||||
#include "graphtab.h"
|
||||
|
||||
class GPX;
|
||||
|
||||
class SpeedGraph : public GraphView
|
||||
class SpeedGraph : public GraphTab
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
SpeedGraph(QWidget *parent = 0);
|
||||
|
||||
QString label() const {return tr("Speed");}
|
||||
void loadGPX(const GPX &gpx);
|
||||
void clear();
|
||||
void setUnits(enum Units units);
|
||||
|
||||
qreal avg() const;
|
||||
qreal max() const {return bounds().bottom();}
|
||||
void showTracks(bool show);
|
||||
void showRoutes(bool show) {Q_UNUSED(show);}
|
||||
|
||||
private:
|
||||
qreal avg() const;
|
||||
qreal max() const {return bounds().bottom();}
|
||||
void setXUnits();
|
||||
void setYUnits();
|
||||
void addInfo();
|
||||
void setInfo();
|
||||
|
||||
QList<QPointF> _avg;
|
||||
|
||||
enum Units _units;
|
||||
bool _showTracks;
|
||||
};
|
||||
|
||||
#endif // SPEEDGRAPH_H
|
||||
|
133
src/temperaturegraph.cpp
Normal file
133
src/temperaturegraph.cpp
Normal file
@ -0,0 +1,133 @@
|
||||
#include "gpx.h"
|
||||
#include "temperaturegraph.h"
|
||||
|
||||
|
||||
TemperatureGraph::TemperatureGraph(QWidget *parent) : GraphTab(parent)
|
||||
{
|
||||
_units = Metric;
|
||||
_showTracks = true;
|
||||
|
||||
setYUnits();
|
||||
setXLabel(tr("Distance"));
|
||||
setYLabel(tr("Temperature"));
|
||||
|
||||
setSliderPrecision(1);
|
||||
}
|
||||
|
||||
void TemperatureGraph::setInfo()
|
||||
{
|
||||
if (_showTracks) {
|
||||
GraphView::addInfo(tr("Average"), QString::number(avg() * yScale()
|
||||
+ yOffset(), 'f', 1) + UNIT_SPACE + yUnits());
|
||||
GraphView::addInfo(tr("Minimum"), QString::number(min() * yScale()
|
||||
+ yOffset(), 'f', 1) + UNIT_SPACE + yUnits());
|
||||
GraphView::addInfo(tr("Maximum"), QString::number(max() * yScale()
|
||||
+ yOffset(), 'f', 1) + UNIT_SPACE + yUnits());
|
||||
} else
|
||||
clearInfo();
|
||||
}
|
||||
|
||||
void TemperatureGraph::loadGPX(const GPX &gpx)
|
||||
{
|
||||
for (int i = 0; i < gpx.tracks().count(); i++) {
|
||||
QVector<QPointF> data = gpx.tracks().at(i)->temperature();
|
||||
qreal sum = 0, w = 0;
|
||||
|
||||
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.tracks().at(i)->distance(), sum/w));
|
||||
|
||||
loadData(data);
|
||||
}
|
||||
|
||||
for (int i = 0; i < gpx.routes().count(); i++)
|
||||
skipColor();
|
||||
|
||||
setXUnits();
|
||||
setInfo();
|
||||
|
||||
redraw();
|
||||
}
|
||||
|
||||
qreal TemperatureGraph::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 TemperatureGraph::clear()
|
||||
{
|
||||
_avg.clear();
|
||||
|
||||
GraphView::clear();
|
||||
}
|
||||
|
||||
void TemperatureGraph::setXUnits()
|
||||
{
|
||||
if (_units == Metric) {
|
||||
if (bounds().width() < KMINM) {
|
||||
GraphView::setXUnits(tr("m"));
|
||||
setXScale(1);
|
||||
} else {
|
||||
GraphView::setXUnits(tr("km"));
|
||||
setXScale(M2KM);
|
||||
}
|
||||
} else {
|
||||
if (bounds().width() < MIINM) {
|
||||
GraphView::setXUnits(tr("ft"));
|
||||
setXScale(M2FT);
|
||||
} else {
|
||||
GraphView::setXUnits(tr("mi"));
|
||||
setXScale(M2MI);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void TemperatureGraph::setYUnits()
|
||||
{
|
||||
if (_units == Metric) {
|
||||
GraphView::setYUnits(QChar(0x00B0) + tr("C"));
|
||||
setYScale(1);
|
||||
setYOffset(0);
|
||||
} else {
|
||||
GraphView::setYUnits(QChar(0x00B0) + tr("F"));
|
||||
setYScale(C2FS);
|
||||
setYOffset(C2FO);
|
||||
}
|
||||
}
|
||||
|
||||
void TemperatureGraph::setUnits(enum Units units)
|
||||
{
|
||||
_units = units;
|
||||
|
||||
setXUnits();
|
||||
setYUnits();
|
||||
setInfo();
|
||||
|
||||
redraw();
|
||||
}
|
||||
|
||||
void TemperatureGraph::showTracks(bool show)
|
||||
{
|
||||
_showTracks = show;
|
||||
|
||||
showGraph(show);
|
||||
setXUnits();
|
||||
setInfo();
|
||||
|
||||
redraw();
|
||||
}
|
36
src/temperaturegraph.h
Normal file
36
src/temperaturegraph.h
Normal file
@ -0,0 +1,36 @@
|
||||
#ifndef TEMPERATUREGRAPH_H
|
||||
#define TEMPERATUREGRAPH_H
|
||||
|
||||
#include "graphtab.h"
|
||||
|
||||
class GPX;
|
||||
|
||||
class TemperatureGraph : public GraphTab
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
TemperatureGraph(QWidget *parent = 0);
|
||||
|
||||
QString label() const {return tr("Temperature");}
|
||||
void loadGPX(const GPX &gpx);
|
||||
void clear();
|
||||
void setUnits(enum Units units);
|
||||
void showTracks(bool show);
|
||||
void showRoutes(bool show) {Q_UNUSED(show);}
|
||||
|
||||
private:
|
||||
qreal avg() const;
|
||||
qreal min() const {return bounds().top();}
|
||||
qreal max() const {return bounds().bottom();}
|
||||
void setXUnits();
|
||||
void setYUnits();
|
||||
void setInfo();
|
||||
|
||||
QList<QPointF> _avg;
|
||||
|
||||
enum Units _units;
|
||||
bool _showTracks;
|
||||
};
|
||||
|
||||
#endif // TEMPERATUREGRAPH_H
|
20
src/tooltip.cpp
Normal file
20
src/tooltip.cpp
Normal file
@ -0,0 +1,20 @@
|
||||
#include "tooltip.h"
|
||||
|
||||
void ToolTip::insert(const QString &key, const QString &value)
|
||||
{
|
||||
QPair<QString, QString> entry(key, value);
|
||||
_list.append(entry);
|
||||
}
|
||||
|
||||
QString ToolTip::toString()
|
||||
{
|
||||
QString ret = "<table>";
|
||||
|
||||
for (int i = 0; i < _list.count(); i++)
|
||||
ret += "<tr><td align=\"right\"><b>" + _list.at(i).first
|
||||
+ ": </b></td><td>" + _list.at(i).second + "</td></tr>";
|
||||
|
||||
ret += "</table>";
|
||||
|
||||
return ret;
|
||||
}
|
18
src/tooltip.h
Normal file
18
src/tooltip.h
Normal file
@ -0,0 +1,18 @@
|
||||
#ifndef TOOLTIP_H
|
||||
#define TOOLTIP_H
|
||||
|
||||
#include <QString>
|
||||
#include <QList>
|
||||
#include <QPair>
|
||||
|
||||
class ToolTip
|
||||
{
|
||||
public:
|
||||
void insert(const QString &key, const QString &value);
|
||||
QString toString();
|
||||
|
||||
private:
|
||||
QList<QPair<QString, QString> > _list;
|
||||
};
|
||||
|
||||
#endif // TOOLTIP_H
|
118
src/track.cpp
118
src/track.cpp
@ -80,106 +80,96 @@ static QVector<QPointF> filter(const QVector<QPointF> &v, int window)
|
||||
}
|
||||
|
||||
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;
|
||||
QVector<QPointF> raw;
|
||||
|
||||
if (!_data.size())
|
||||
return;
|
||||
|
||||
if (!_data.at(0).hasElevation())
|
||||
return;
|
||||
raw.append(QPointF(0, _data.at(0).elevation - _data.at(0).geoidheight));
|
||||
for (int i = 1; i < _data.size(); i++) {
|
||||
dist += _dd.at(i-1);
|
||||
if (!_data.at(i).hasElevation())
|
||||
return;
|
||||
raw.append(QPointF(dist, _data.at(i).elevation
|
||||
- _data.at(i).geoidheight));
|
||||
_dd.append(dist);
|
||||
for (int i = 1; i < data.count(); i++) {
|
||||
dist += llDistance(data.at(i).coordinates(), data.at(i-1).coordinates());
|
||||
_dd.append(dist);
|
||||
}
|
||||
|
||||
graph = filter(raw, WINDOW_EF);
|
||||
}
|
||||
|
||||
void Track::speedGraph(QVector<QPointF> &graph) const
|
||||
QVector<QPointF> Track::elevation() const
|
||||
{
|
||||
qreal dist = 0, v, ds, dt;
|
||||
QVector<QPointF> raw;
|
||||
|
||||
if (!_data.size())
|
||||
return;
|
||||
return raw;
|
||||
|
||||
for (int i = 0; i < _data.size(); i++)
|
||||
if (_data.at(i).hasElevation())
|
||||
raw.append(QPointF(_dd.at(i), _data.at(i).elevation()
|
||||
- _data.at(i).geoidHeight()));
|
||||
|
||||
return filter(raw, WINDOW_EF);
|
||||
}
|
||||
|
||||
QVector<QPointF> Track::speed() const
|
||||
{
|
||||
qreal v, ds;
|
||||
qint64 dt;
|
||||
QVector<QPointF> raw;
|
||||
|
||||
if (!_data.size())
|
||||
return raw;
|
||||
|
||||
raw.append(QPointF(0, 0));
|
||||
for (int i = 1; i < _data.size(); i++) {
|
||||
ds = _dd.at(i-1);
|
||||
dt = _data.at(i-1).timestamp.msecsTo(_data.at(i).timestamp) / 1000.0;
|
||||
dist += ds;
|
||||
|
||||
if (!_data.at(i).hasSpeed()) {
|
||||
if (dt == 0)
|
||||
if (_data.at(i).hasSpeed())
|
||||
v = _data.at(i).speed();
|
||||
else if (_data.at(i).hasTimestamp()) {
|
||||
dt = _data.at(i-1).timestamp().msecsTo(_data.at(i).timestamp());
|
||||
if (!dt)
|
||||
continue;
|
||||
v = ds / dt;
|
||||
ds = _dd.at(i) - _dd.at(i-1);
|
||||
v = ds / ((qreal)dt / 1000.0);
|
||||
} else
|
||||
v = _data.at(i).speed;
|
||||
continue;
|
||||
|
||||
raw.append(QPointF(dist, v));
|
||||
raw.append(QPointF(_dd.at(i), v));
|
||||
}
|
||||
|
||||
graph = filter(eliminate(raw, WINDOW_SE), WINDOW_SF);
|
||||
return filter(eliminate(raw, WINDOW_SE), WINDOW_SF);
|
||||
}
|
||||
|
||||
void Track::heartRateGraph(QVector<QPointF> &graph) const
|
||||
QVector<QPointF> Track::heartRate() const
|
||||
{
|
||||
qreal dist = 0;
|
||||
QVector<QPointF> raw;
|
||||
|
||||
if (!_data.size())
|
||||
return;
|
||||
return raw;
|
||||
|
||||
if (!_data.at(0).hasHeartRate())
|
||||
return;
|
||||
raw.append(QPointF(0, _data.at(0).heartRate));
|
||||
for (int i = 1; i < _data.count(); i++) {
|
||||
if (!_data.at(i).hasHeartRate())
|
||||
return;
|
||||
dist += _dd.at(i-1);
|
||||
raw.append(QPointF(dist, _data.at(i).heartRate));
|
||||
}
|
||||
for (int i = 0; i < _data.count(); i++)
|
||||
if (_data.at(i).hasHeartRate())
|
||||
raw.append(QPointF(_dd.at(i), _data.at(i).heartRate()));
|
||||
|
||||
graph = filter(eliminate(raw, WINDOW_HE), WINDOW_HF);
|
||||
return filter(eliminate(raw, WINDOW_HE), WINDOW_HF);
|
||||
}
|
||||
|
||||
void Track::track(QVector<QPointF> &track) const
|
||||
QVector<QPointF> Track::temperature() const
|
||||
{
|
||||
QVector<QPointF> graph;
|
||||
|
||||
for (int i = 0; i < _data.size(); i++)
|
||||
track.append(_data.at(i).coordinates);
|
||||
if (_data.at(i).hasTemperature())
|
||||
graph.append(QPointF(_dd.at(i), _data.at(i).temperature()));
|
||||
|
||||
return graph;
|
||||
}
|
||||
|
||||
qreal Track::distance() const
|
||||
{
|
||||
return (_dd.isEmpty()) ? 0 : _dd.last();
|
||||
}
|
||||
|
||||
qreal Track::time() const
|
||||
{
|
||||
if (_data.size() < 2)
|
||||
return 0;
|
||||
|
||||
return (_data.at(0).timestamp.msecsTo(_data.at(_data.size() - 1).timestamp)
|
||||
/ 1000.0);
|
||||
return (_data.size() < 2) ? 0 :
|
||||
(_data.first().timestamp().msecsTo(_data.last().timestamp()) / 1000.0);
|
||||
}
|
||||
|
||||
QDateTime Track::date() const
|
||||
{
|
||||
if (_data.size())
|
||||
return _data.at(0).timestamp;
|
||||
else
|
||||
return QDateTime();
|
||||
return (_data.size()) ? _data.first().timestamp() : QDateTime();
|
||||
}
|
||||
|
15
src/track.h
15
src/track.h
@ -10,18 +10,21 @@ class Track
|
||||
public:
|
||||
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 {return _distance;}
|
||||
const QVector<Trackpoint> &track() const {return _data;}
|
||||
QVector<QPointF> elevation() const;
|
||||
QVector<QPointF> speed() const;
|
||||
QVector<QPointF> heartRate() const;
|
||||
QVector<QPointF> temperature() const;
|
||||
|
||||
qreal distance() const;
|
||||
qreal time() const;
|
||||
QDateTime date() const;
|
||||
|
||||
bool isNull() const {return (_dd.count() < 2);}
|
||||
|
||||
private:
|
||||
const QVector<Trackpoint> &_data;
|
||||
QVector<qreal> _dd;
|
||||
qreal _distance;
|
||||
};
|
||||
|
||||
#endif // TRACK_H
|
||||
|
40
src/trackinfo.cpp
Normal file
40
src/trackinfo.cpp
Normal file
@ -0,0 +1,40 @@
|
||||
#include <QPaintEngine>
|
||||
#include <QPaintDevice>
|
||||
#include "config.h"
|
||||
#include "infoitem.h"
|
||||
#include "trackinfo.h"
|
||||
|
||||
|
||||
TrackInfo::TrackInfo(QObject *parent) : QGraphicsScene(parent)
|
||||
{
|
||||
_info = new InfoItem();
|
||||
addItem(_info);
|
||||
}
|
||||
|
||||
void TrackInfo::insert(const QString &key, const QString &value)
|
||||
{
|
||||
_info->insert(key, value);
|
||||
}
|
||||
|
||||
void TrackInfo::plot(QPainter *painter, const QRectF &target)
|
||||
{
|
||||
qreal ratio = painter->paintEngine()->paintDevice()->logicalDpiX()
|
||||
/ SCREEN_DPI;
|
||||
QSizeF canvas = QSizeF(target.width() / ratio, target.height() / ratio);
|
||||
QSizeF diff = QSizeF(qAbs(canvas.width() - sceneRect().width()),
|
||||
qAbs(canvas.height() - sceneRect().height()));
|
||||
QRectF adj = sceneRect().adjusted(0, -diff.height()/2, diff.width(),
|
||||
diff.height()/2);
|
||||
|
||||
render(painter, target, adj);
|
||||
}
|
||||
|
||||
bool TrackInfo::isEmpty() const
|
||||
{
|
||||
return _info->isEmpty();
|
||||
}
|
||||
|
||||
QSizeF TrackInfo::contentSize() const
|
||||
{
|
||||
return sceneRect().size();
|
||||
}
|
24
src/trackinfo.h
Normal file
24
src/trackinfo.h
Normal file
@ -0,0 +1,24 @@
|
||||
#ifndef TRACKINFO_H
|
||||
#define TRACKINFO_H
|
||||
|
||||
#include <QGraphicsScene>
|
||||
|
||||
class InfoItem;
|
||||
|
||||
class TrackInfo : public QGraphicsScene
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
TrackInfo(QObject *parent = 0);
|
||||
|
||||
void insert(const QString &key, const QString &value);
|
||||
void plot(QPainter *painter, const QRectF &target);
|
||||
bool isEmpty() const;
|
||||
QSizeF contentSize() const;
|
||||
|
||||
private:
|
||||
InfoItem *_info;
|
||||
};
|
||||
|
||||
#endif // TRACKINFO_H
|
110
src/trackitem.cpp
Normal file
110
src/trackitem.cpp
Normal file
@ -0,0 +1,110 @@
|
||||
#include <QApplication>
|
||||
#include <QCursor>
|
||||
#include <QPainter>
|
||||
#include "ll.h"
|
||||
#include "misc.h"
|
||||
#include "tooltip.h"
|
||||
#include "trackitem.h"
|
||||
|
||||
|
||||
#define TRACK_WIDTH 3
|
||||
|
||||
QString TrackItem::toolTip()
|
||||
{
|
||||
ToolTip tt;
|
||||
|
||||
tt.insert(qApp->translate("TrackItem", "Distance"),
|
||||
::distance(_distance, _units));
|
||||
if (_time > 0)
|
||||
tt.insert(qApp->translate("TrackItem", "Time"), ::timeSpan(_time));
|
||||
if (!_date.isNull())
|
||||
tt.insert(qApp->translate("TrackItem", "Date"),
|
||||
_date.toString(Qt::SystemLocaleShortDate));
|
||||
|
||||
return tt.toString();
|
||||
}
|
||||
|
||||
void TrackItem::updateShape()
|
||||
{
|
||||
QPainterPathStroker s;
|
||||
s.setWidth(TRACK_WIDTH * 1.0/scale());
|
||||
_shape = s.createStroke(_path);
|
||||
}
|
||||
|
||||
TrackItem::TrackItem(const Track &track, QGraphicsItem *parent)
|
||||
: QGraphicsItem(parent)
|
||||
{
|
||||
const QVector<Trackpoint> &t = track.track();
|
||||
Q_ASSERT(t.count() >= 2);
|
||||
|
||||
const QPointF &p = t.at(0).coordinates();
|
||||
_path.moveTo(ll2mercator(QPointF(p.x(), -p.y())));
|
||||
for (int i = 1; i < t.size(); i++) {
|
||||
const QPointF &p = t.at(i).coordinates();
|
||||
_path.lineTo(ll2mercator(QPointF(p.x(), -p.y())));
|
||||
}
|
||||
|
||||
_units = Metric;
|
||||
_date = track.date();
|
||||
_distance = track.distance();
|
||||
_time = track.time();
|
||||
|
||||
setToolTip(toolTip());
|
||||
setCursor(Qt::ArrowCursor);
|
||||
|
||||
updateShape();
|
||||
|
||||
QBrush brush(Qt::SolidPattern);
|
||||
_pen = QPen(brush, TRACK_WIDTH);
|
||||
|
||||
_marker = new MarkerItem(this);
|
||||
_marker->setPos(_path.pointAtPercent(0));
|
||||
}
|
||||
|
||||
void TrackItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *option,
|
||||
QWidget *widget)
|
||||
{
|
||||
Q_UNUSED(option);
|
||||
Q_UNUSED(widget);
|
||||
|
||||
painter->setPen(_pen);
|
||||
painter->drawPath(_path);
|
||||
|
||||
/*
|
||||
painter->setPen(Qt::red);
|
||||
painter->drawRect(boundingRect());
|
||||
*/
|
||||
}
|
||||
|
||||
void TrackItem::setScale(qreal scale)
|
||||
{
|
||||
prepareGeometryChange();
|
||||
|
||||
_pen.setWidthF(TRACK_WIDTH * 1.0/scale);
|
||||
QGraphicsItem::setScale(scale);
|
||||
_marker->setScale(1.0/scale);
|
||||
|
||||
updateShape();
|
||||
}
|
||||
|
||||
void TrackItem::setColor(const QColor &color)
|
||||
{
|
||||
_pen.setColor(color);
|
||||
update();
|
||||
}
|
||||
|
||||
void TrackItem::setUnits(enum Units units)
|
||||
{
|
||||
_units = units;
|
||||
setToolTip(toolTip());
|
||||
}
|
||||
|
||||
void TrackItem::moveMarker(qreal distance)
|
||||
{
|
||||
if (distance > _distance)
|
||||
_marker->setVisible(false);
|
||||
else {
|
||||
_marker->setVisible(true);
|
||||
_marker->setPos(_path.pointAtPercent(distance / _distance));
|
||||
}
|
||||
}
|
46
src/trackitem.h
Normal file
46
src/trackitem.h
Normal file
@ -0,0 +1,46 @@
|
||||
#ifndef TRACKITEM_H
|
||||
#define TRACKITEM_H
|
||||
|
||||
#include <QGraphicsItem>
|
||||
#include <QDateTime>
|
||||
#include "units.h"
|
||||
#include "track.h"
|
||||
#include "markeritem.h"
|
||||
|
||||
|
||||
class TrackItem : public QGraphicsItem
|
||||
{
|
||||
public:
|
||||
TrackItem(const Track &track, QGraphicsItem *parent = 0);
|
||||
|
||||
QPainterPath shape() const {return _shape;}
|
||||
QRectF boundingRect() const {return _shape.boundingRect();}
|
||||
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option,
|
||||
QWidget *widget);
|
||||
|
||||
const QPainterPath &path() const {return _path;}
|
||||
|
||||
void setScale(qreal scale);
|
||||
void setUnits(enum Units units);
|
||||
void setColor(const QColor &color);
|
||||
|
||||
void showMarker(bool show) {_marker->setVisible(show);}
|
||||
void moveMarker(qreal distance);
|
||||
|
||||
private:
|
||||
void updateShape();
|
||||
QString toolTip();
|
||||
|
||||
QPainterPath _path;
|
||||
QPainterPath _shape;
|
||||
QPen _pen;
|
||||
|
||||
MarkerItem *_marker;
|
||||
|
||||
Units _units;
|
||||
QDateTime _date;
|
||||
qreal _time;
|
||||
qreal _distance;
|
||||
};
|
||||
|
||||
#endif // TRACKITEM_H
|
11
src/trackpoint.cpp
Normal file
11
src/trackpoint.cpp
Normal file
@ -0,0 +1,11 @@
|
||||
#include "trackpoint.h"
|
||||
|
||||
QDebug operator<<(QDebug dbg, const Trackpoint &trackpoint)
|
||||
{
|
||||
dbg.nospace() << "Trackpoint(" << trackpoint.coordinates() << ", "
|
||||
<< trackpoint.timestamp() << ", " << trackpoint.elevation() << ", "
|
||||
<< trackpoint.geoidHeight() << ", " << trackpoint.speed() << ", "
|
||||
<< trackpoint.heartRate() << ", " << trackpoint.temperature() << ")";
|
||||
|
||||
return dbg.maybeSpace();
|
||||
}
|
@ -3,28 +3,51 @@
|
||||
|
||||
#include <QPointF>
|
||||
#include <QDateTime>
|
||||
#include <QDebug>
|
||||
#include <cmath>
|
||||
|
||||
class Trackpoint
|
||||
{
|
||||
public:
|
||||
Trackpoint() {
|
||||
elevation = NAN;
|
||||
geoidheight = 0;
|
||||
speed = NAN;
|
||||
heartRate = NAN;
|
||||
_elevation = NAN; _geoidHeight = 0; _speed = NAN; _heartRate = NAN;
|
||||
_temperature = NAN;
|
||||
}
|
||||
Trackpoint(const QPointF &coordinates) {_coordinates = coordinates;}
|
||||
|
||||
bool hasElevation() const {return !std::isnan(elevation);}
|
||||
bool hasSpeed() const {return !std::isnan(speed);}
|
||||
bool hasHeartRate() const {return !std::isnan(heartRate);}
|
||||
const QPointF &coordinates() const {return _coordinates;}
|
||||
const QDateTime ×tamp() const {return _timestamp;}
|
||||
qreal elevation() const {return _elevation;}
|
||||
qreal geoidHeight() const {return _geoidHeight;}
|
||||
qreal speed() const {return _speed;}
|
||||
qreal heartRate() const {return _heartRate;}
|
||||
qreal temperature() const {return _temperature;}
|
||||
|
||||
QPointF coordinates;
|
||||
QDateTime timestamp;
|
||||
qreal elevation;
|
||||
qreal geoidheight;
|
||||
qreal speed;
|
||||
qreal heartRate;
|
||||
void setCoordinates(const QPointF &coordinates)
|
||||
{_coordinates = coordinates;}
|
||||
void setTimestamp(const QDateTime ×tamp) {_timestamp = timestamp;}
|
||||
void setElevation(qreal elevation) {_elevation = elevation;}
|
||||
void setGeoidHeight(qreal geoidHeight) {_geoidHeight = geoidHeight;}
|
||||
void setSpeed(qreal speed) {_speed = speed;}
|
||||
void setHeartRate(qreal heartRate) {_heartRate = heartRate;}
|
||||
void setTemperature(qreal temperature) {_temperature = temperature;}
|
||||
|
||||
bool hasTimestamp() const {return !_timestamp.isNull();}
|
||||
bool hasElevation() const {return !std::isnan(_elevation);}
|
||||
bool hasSpeed() const {return !std::isnan(_speed);}
|
||||
bool hasHeartRate() const {return !std::isnan(_heartRate);}
|
||||
bool hasTemperature() const {return !std::isnan(_temperature);}
|
||||
|
||||
private:
|
||||
QPointF _coordinates;
|
||||
QDateTime _timestamp;
|
||||
qreal _elevation;
|
||||
qreal _geoidHeight;
|
||||
qreal _speed;
|
||||
qreal _heartRate;
|
||||
qreal _temperature;
|
||||
};
|
||||
|
||||
QDebug operator<<(QDebug dbg, const Trackpoint &trackpoint);
|
||||
|
||||
#endif // TRACKPOINT_H
|
||||
|
@ -2,18 +2,18 @@
|
||||
#include <QGraphicsScene>
|
||||
#include <QPainterPath>
|
||||
#include <QWheelEvent>
|
||||
#include "ll.h"
|
||||
#include "poi.h"
|
||||
#include "gpx.h"
|
||||
#include "map.h"
|
||||
#include "trackitem.h"
|
||||
#include "routeitem.h"
|
||||
#include "waypointitem.h"
|
||||
#include "markeritem.h"
|
||||
#include "scaleitem.h"
|
||||
#include "ll.h"
|
||||
#include "trackview.h"
|
||||
|
||||
|
||||
#define MARGIN 10.0
|
||||
#define TRACK_WIDTH 3
|
||||
#define SCALE_OFFSET 7
|
||||
|
||||
TrackView::TrackView(QWidget *parent)
|
||||
@ -34,68 +34,78 @@ TrackView::TrackView(QWidget *parent)
|
||||
_zoom = ZOOM_MAX;
|
||||
_scale = mapScale(_zoom);
|
||||
_map = 0;
|
||||
_maxPath = 0;
|
||||
_maxDistance = 0;
|
||||
|
||||
_units = Metric;
|
||||
|
||||
_showTracks = true;
|
||||
_showRoutes = true;
|
||||
_showWaypoints = true;
|
||||
_showWaypointLabels = true;
|
||||
_showPOILabels = true;
|
||||
_overlapPOIs = true;
|
||||
_showRouteWaypoints = true;
|
||||
|
||||
_plot = false;
|
||||
_markerPos = 0;
|
||||
}
|
||||
|
||||
TrackView::~TrackView()
|
||||
{
|
||||
delete _scene;
|
||||
if (_mapScale->scene() != _scene)
|
||||
delete _mapScale;
|
||||
}
|
||||
|
||||
void TrackView::addTrack(const QVector<QPointF> &track)
|
||||
void TrackView::addTrack(const Track &track)
|
||||
{
|
||||
QPainterPath path;
|
||||
QGraphicsPathItem *pi;
|
||||
MarkerItem *mi;
|
||||
|
||||
|
||||
if (track.size() < 2) {
|
||||
if (track.isNull()) {
|
||||
_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);
|
||||
TrackItem *ti = new TrackItem(track);
|
||||
_tracks.append(ti);
|
||||
_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);
|
||||
ti->setScale(1.0/_scale);
|
||||
ti->setColor(_palette.color());
|
||||
ti->setVisible(_showTracks);
|
||||
ti->moveMarker(_markerPos);
|
||||
_scene->addItem(ti);
|
||||
}
|
||||
|
||||
mi = new MarkerItem(pi);
|
||||
_markers.append(mi);
|
||||
mi->setPos(pi->path().pointAtPercent(0));
|
||||
mi->setScale(_scale);
|
||||
void TrackView::addRoute(const Route &route)
|
||||
{
|
||||
if (route.isNull()) {
|
||||
_palette.color();
|
||||
return;
|
||||
}
|
||||
|
||||
RouteItem *ri = new RouteItem(route);
|
||||
_routes.append(ri);
|
||||
_zoom = qMin(_zoom, scale2zoom(routeScale()));
|
||||
_scale = mapScale(_zoom);
|
||||
ri->setScale(1.0/_scale);
|
||||
ri->setColor(_palette.color());
|
||||
ri->setVisible(_showRoutes);
|
||||
ri->showWaypoints(_showRouteWaypoints);
|
||||
ri->showWaypointLabels(_showWaypointLabels);
|
||||
ri->moveMarker(_markerPos);
|
||||
_scene->addItem(ri);
|
||||
}
|
||||
|
||||
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);
|
||||
WaypointItem *wi = new WaypointItem(w);
|
||||
wi->setScale(1.0/_scale);
|
||||
wi->setZValue(1);
|
||||
wi->showLabel(_showWaypointLabels);
|
||||
wi->setVisible(_showWaypoints);
|
||||
_scene->addItem(wi);
|
||||
|
||||
_locations.append(wi);
|
||||
_waypoints.append(w.coordinates());
|
||||
_waypoints.append(wi);
|
||||
}
|
||||
|
||||
_zoom = qMin(_zoom, scale2zoom(waypointScale()));
|
||||
@ -106,23 +116,22 @@ void TrackView::loadGPX(const GPX &gpx)
|
||||
{
|
||||
int zoom = _zoom;
|
||||
|
||||
for (int i = 0; i < gpx.trackCount(); i++) {
|
||||
QVector<QPointF> track;
|
||||
gpx.track(i).track(track);
|
||||
addTrack(track);
|
||||
_maxDistance = qMax(gpx.track(i).distance(), _maxDistance);
|
||||
}
|
||||
|
||||
for (int i = 0; i < gpx.tracks().count(); i++)
|
||||
addTrack(*(gpx.tracks().at(i)));
|
||||
for (int i = 0; i < gpx.routes().count(); i++)
|
||||
addRoute(*(gpx.routes().at(i)));
|
||||
addWaypoints(gpx.waypoints());
|
||||
|
||||
if (_paths.empty() && _locations.empty())
|
||||
if (_tracks.empty() && _routes.empty() && _waypoints.empty())
|
||||
return;
|
||||
|
||||
if ((_paths.size() > 1 && _zoom < zoom)
|
||||
|| (_locations.size() && _zoom < zoom))
|
||||
if ((_tracks.size() > 1 && _zoom < zoom)
|
||||
|| (_routes.size() > 1 && _zoom < zoom)
|
||||
|| (_waypoints.size() && _zoom < zoom))
|
||||
rescale(_scale);
|
||||
|
||||
QRectF br = trackBoundingRect() | waypointBoundingRect();
|
||||
QRectF br = trackBoundingRect() | routeBoundingRect()
|
||||
| waypointBoundingRect();
|
||||
QRectF ba = br.adjusted(-TILE_SIZE, -TILE_SIZE, TILE_SIZE, TILE_SIZE);
|
||||
_scene->setSceneRect(ba);
|
||||
centerOn(ba.center());
|
||||
@ -135,12 +144,24 @@ void TrackView::loadGPX(const GPX &gpx)
|
||||
|
||||
QRectF TrackView::trackBoundingRect() const
|
||||
{
|
||||
if (_paths.empty())
|
||||
if (_tracks.empty())
|
||||
return QRectF();
|
||||
|
||||
QRectF br = _paths.at(0)->sceneBoundingRect();
|
||||
for (int i = 1; i < _paths.size(); i++)
|
||||
br |= _paths.at(i)->sceneBoundingRect();
|
||||
QRectF br = _tracks.at(0)->sceneBoundingRect();
|
||||
for (int i = 1; i < _tracks.size(); i++)
|
||||
br |= _tracks.at(i)->sceneBoundingRect();
|
||||
|
||||
return br;
|
||||
}
|
||||
|
||||
QRectF TrackView::routeBoundingRect() const
|
||||
{
|
||||
if (_routes.empty())
|
||||
return QRectF();
|
||||
|
||||
QRectF br = _routes.at(0)->sceneBoundingRect();
|
||||
for (int i = 1; i < _routes.size(); i++)
|
||||
br |= _routes.at(i)->sceneBoundingRect();
|
||||
|
||||
return br;
|
||||
}
|
||||
@ -149,17 +170,17 @@ QRectF TrackView::waypointBoundingRect() const
|
||||
{
|
||||
qreal bottom, top, left, right;
|
||||
|
||||
if (_locations.empty())
|
||||
if (_waypoints.empty())
|
||||
return QRectF();
|
||||
|
||||
const QPointF &p = _locations.at(0)->pos();
|
||||
const QPointF &p = _waypoints.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();
|
||||
for (int i = 1; i < _waypoints.size(); i++) {
|
||||
const QPointF &p = _waypoints.at(i)->pos();
|
||||
bottom = qMax(bottom, p.y());
|
||||
top = qMin(top, p.y());
|
||||
right = qMax(right, p.x());
|
||||
@ -171,13 +192,29 @@ QRectF TrackView::waypointBoundingRect() const
|
||||
|
||||
qreal TrackView::trackScale() const
|
||||
{
|
||||
if (_paths.empty())
|
||||
if (_tracks.empty())
|
||||
return mapScale(ZOOM_MAX);
|
||||
|
||||
QRectF br = _paths.at(0)->path().boundingRect();
|
||||
QRectF br = _tracks.at(0)->path().boundingRect();
|
||||
|
||||
for (int i = 1; i < _paths.size(); i++)
|
||||
br |= _paths.at(i)->path().boundingRect();
|
||||
for (int i = 1; i < _tracks.size(); i++)
|
||||
br |= _tracks.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::routeScale() const
|
||||
{
|
||||
if (_routes.empty())
|
||||
return mapScale(ZOOM_MAX);
|
||||
|
||||
QRectF br = _routes.at(0)->path().boundingRect();
|
||||
|
||||
for (int i = 1; i < _routes.size(); i++)
|
||||
br |= _routes.at(i)->path().boundingRect();
|
||||
|
||||
QPointF sc(br.width() / (viewport()->width() - MARGIN/2),
|
||||
br.height() / (viewport()->height() - MARGIN/2));
|
||||
@ -189,17 +226,17 @@ qreal TrackView::waypointScale() const
|
||||
{
|
||||
qreal bottom, top, left, right;
|
||||
|
||||
if (_locations.size() < 2)
|
||||
if (_waypoints.size() < 2)
|
||||
return mapScale(ZOOM_MAX);
|
||||
|
||||
const QPointF &p = _locations.at(0)->entry().coordinates();
|
||||
const QPointF &p = _waypoints.at(0)->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();
|
||||
for (int i = 1; i < _waypoints.size(); i++) {
|
||||
const QPointF &p = _waypoints.at(i)->coordinates();
|
||||
bottom = qMax(bottom, p.y());
|
||||
top = qMin(top, p.y());
|
||||
right = qMax(right, p.x());
|
||||
@ -218,26 +255,9 @@ qreal TrackView::mapScale(int zoom) const
|
||||
return ((360.0/(qreal)(1<<zoom))/(qreal)TILE_SIZE);
|
||||
}
|
||||
|
||||
void TrackView::rescale(qreal scale)
|
||||
void TrackView::checkPOIOverlap()
|
||||
{
|
||||
for (int i = 0; i < _paths.size(); i++) {
|
||||
_markers.at(i)->setScale(scale);
|
||||
_paths.at(i)->setScale(1.0/scale);
|
||||
|
||||
QPen pen(_paths.at(i)->pen());
|
||||
pen.setWidthF(TRACK_WIDTH * scale);
|
||||
_paths.at(i)->setPen(pen);
|
||||
}
|
||||
|
||||
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(it.value()->entry().coordinates() * 1.0/scale);
|
||||
it.value()->show();
|
||||
}
|
||||
|
||||
for (it = _pois.constBegin(); it != _pois.constEnd(); it++) {
|
||||
for (jt = _pois.constBegin(); jt != _pois.constEnd(); jt++) {
|
||||
@ -246,6 +266,27 @@ void TrackView::rescale(qreal scale)
|
||||
jt.value()->hide();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void TrackView::rescale(qreal scale)
|
||||
{
|
||||
for (int i = 0; i < _tracks.size(); i++)
|
||||
_tracks.at(i)->setScale(1.0/scale);
|
||||
|
||||
for (int i = 0; i < _routes.size(); i++)
|
||||
_routes.at(i)->setScale(1.0/scale);
|
||||
|
||||
for (int i = 0; i < _waypoints.size(); i++)
|
||||
_waypoints.at(i)->setScale(1.0/scale);
|
||||
|
||||
QHash<Waypoint, WaypointItem*>::const_iterator it;
|
||||
for (it = _pois.constBegin(); it != _pois.constEnd(); it++) {
|
||||
it.value()->setScale(1.0/scale);
|
||||
it.value()->show();
|
||||
}
|
||||
|
||||
if (!_overlapPOIs)
|
||||
checkPOIOverlap();
|
||||
|
||||
_scale = scale;
|
||||
}
|
||||
@ -258,12 +299,10 @@ void TrackView::addPOI(const QVector<Waypoint> &waypoints)
|
||||
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);
|
||||
WaypointItem *pi = new WaypointItem(w);
|
||||
pi->setScale(1.0/_scale);
|
||||
pi->setZValue(1);
|
||||
pi->showLabel(_showPOILabels);
|
||||
_scene->addItem(pi);
|
||||
|
||||
_pois.insert(w, pi);
|
||||
@ -272,35 +311,44 @@ void TrackView::addPOI(const QVector<Waypoint> &waypoints)
|
||||
|
||||
void TrackView::loadPOI(const POI &poi)
|
||||
{
|
||||
QHash<Waypoint, WaypointItem*>::const_iterator it,jt;
|
||||
|
||||
if (!_tracks.size() && !_waypoints.size())
|
||||
if (!_tracks.size() && !_routes.size() && !_waypoints.size())
|
||||
return;
|
||||
|
||||
for (int i = 0; i < _tracks.size(); i++)
|
||||
addPOI(poi.points(_tracks.at(i)));
|
||||
addPOI(poi.points(_tracks.at(i)->path()));
|
||||
for (int i = 0; i < _routes.size(); i++)
|
||||
addPOI(poi.points(_routes.at(i)->path()));
|
||||
addPOI(poi.points(_waypoints));
|
||||
|
||||
for (it = _pois.constBegin(); it != _pois.constEnd(); it++) {
|
||||
for (jt = _pois.constBegin(); jt != _pois.constEnd(); jt++) {
|
||||
if (it != jt && it.value()->isVisible() && jt.value()->isVisible()
|
||||
&& it.value()->collidesWithItem(jt.value()))
|
||||
jt.value()->hide();
|
||||
}
|
||||
}
|
||||
if (!_overlapPOIs)
|
||||
checkPOIOverlap();
|
||||
}
|
||||
|
||||
void TrackView::setMap(Map *map)
|
||||
{
|
||||
_map = map;
|
||||
if (_map)
|
||||
connect(_map, SIGNAL(loaded()), this, SLOT(redraw()));
|
||||
connect(_map, SIGNAL(loaded()), this, SLOT(redraw()),
|
||||
Qt::UniqueConnection);
|
||||
resetCachedContent();
|
||||
}
|
||||
|
||||
void TrackView::setUnits(enum Units units)
|
||||
{
|
||||
_units = units;
|
||||
|
||||
_mapScale->setUnits(units);
|
||||
|
||||
for (int i = 0; i < _tracks.count(); i++)
|
||||
_tracks[i]->setUnits(units);
|
||||
for (int i = 0; i < _routes.count(); i++)
|
||||
_routes[i]->setUnits(units);
|
||||
for (int i = 0; i < _waypoints.size(); i++)
|
||||
_waypoints.at(i)->setUnits(units);
|
||||
|
||||
QHash<Waypoint, WaypointItem*>::const_iterator it;
|
||||
for (it = _pois.constBegin(); it != _pois.constEnd(); it++)
|
||||
it.value()->setUnits(units);
|
||||
}
|
||||
|
||||
void TrackView::redraw()
|
||||
@ -310,24 +358,24 @@ void TrackView::redraw()
|
||||
|
||||
void TrackView::rescale()
|
||||
{
|
||||
_zoom = qMin(scale2zoom(trackScale()), scale2zoom(waypointScale()));
|
||||
_zoom = qMin(qMin(scale2zoom(trackScale()), scale2zoom(routeScale())),
|
||||
scale2zoom(waypointScale()));
|
||||
|
||||
rescale(mapScale(_zoom));
|
||||
_mapScale->setZoom(_zoom);
|
||||
}
|
||||
|
||||
void TrackView::wheelEvent(QWheelEvent *event)
|
||||
void TrackView::zoom(int z, const QPointF &pos)
|
||||
{
|
||||
if (_paths.isEmpty() && _locations.isEmpty())
|
||||
if (_tracks.isEmpty() && _routes.isEmpty() && _waypoints.isEmpty())
|
||||
return;
|
||||
|
||||
QPointF pos = mapToScene(event->pos());
|
||||
qreal scale = _scale;
|
||||
|
||||
_zoom = (event->delta() > 0) ?
|
||||
qMin(_zoom + 1, ZOOM_MAX) : qMax(_zoom - 1, ZOOM_MIN);
|
||||
_zoom = z;
|
||||
|
||||
rescale(mapScale(_zoom));
|
||||
QRectF br = trackBoundingRect() | waypointBoundingRect();
|
||||
QRectF br = trackBoundingRect() | routeBoundingRect()
|
||||
| waypointBoundingRect();
|
||||
QRectF ba = br.adjusted(-TILE_SIZE, -TILE_SIZE, TILE_SIZE, TILE_SIZE);
|
||||
_scene->setSceneRect(ba);
|
||||
|
||||
@ -342,48 +390,65 @@ void TrackView::wheelEvent(QWheelEvent *event)
|
||||
resetCachedContent();
|
||||
}
|
||||
|
||||
void TrackView::setTrackLineWidth(qreal width)
|
||||
void TrackView::wheelEvent(QWheelEvent *event)
|
||||
{
|
||||
for (int i = 0; i < _paths.size(); i++) {
|
||||
QPen pen(_paths.at(i)->pen());
|
||||
pen.setWidthF(width);
|
||||
_paths.at(i)->setPen(pen);
|
||||
}
|
||||
if (_tracks.isEmpty() && _routes.isEmpty() && _waypoints.isEmpty())
|
||||
return;
|
||||
|
||||
QPointF pos = mapToScene(event->pos());
|
||||
int z = (event->delta() > 0) ?
|
||||
qMin(_zoom + 1, ZOOM_MAX) : qMax(_zoom - 1, ZOOM_MIN);
|
||||
|
||||
zoom(z, pos);
|
||||
}
|
||||
|
||||
void TrackView::keyPressEvent(QKeyEvent *event)
|
||||
{
|
||||
int z = -1;
|
||||
|
||||
if (event->matches(QKeySequence::ZoomIn))
|
||||
z = qMin(_zoom + 1, ZOOM_MAX);
|
||||
if (event->matches(QKeySequence::ZoomOut))
|
||||
z = qMax(_zoom - 1, ZOOM_MIN);
|
||||
|
||||
if (z >= 0)
|
||||
zoom(z, mapToScene(QRect(QPoint(), size()).center()));
|
||||
else
|
||||
QWidget::keyPressEvent(event);
|
||||
}
|
||||
|
||||
void TrackView::plot(QPainter *painter, const QRectF &target)
|
||||
{
|
||||
QRectF orig, adj;
|
||||
QRect orig, adj;
|
||||
qreal ratio, diff;
|
||||
|
||||
_scene->removeItem(_mapScale);
|
||||
orig = _scene->itemsBoundingRect().adjusted(0, 0, 0,
|
||||
_mapScale->boundingRect().height());
|
||||
_scene->addItem(_mapScale);
|
||||
|
||||
if (target.width()/target.height() > orig.width()/orig.height()) {
|
||||
ratio = target.width()/target.height();
|
||||
diff = qAbs((orig.height() * ratio) - orig.width());
|
||||
adj = orig.adjusted(-diff/2, 0, diff/2, 0);
|
||||
} else {
|
||||
orig = viewport()->rect();
|
||||
|
||||
if (orig.height() * (target.width() / target.height()) - orig.width() < 0) {
|
||||
ratio = target.height()/target.width();
|
||||
diff = fabs((orig.width() * ratio) - orig.height());
|
||||
diff = (orig.width() * ratio) - orig.height();
|
||||
adj = orig.adjusted(0, -diff/2, 0, diff/2);
|
||||
} else {
|
||||
ratio = target.width() / target.height();
|
||||
diff = (orig.height() * ratio) - orig.width();
|
||||
adj = orig.adjusted(-diff/2, 0, diff/2, 0);
|
||||
}
|
||||
|
||||
_mapScale->setPos(adj.bottomRight()
|
||||
+ QPoint(-_mapScale->boundingRect().width(),
|
||||
-_mapScale->boundingRect().height()));
|
||||
setUpdatesEnabled(false);
|
||||
_plot = true;
|
||||
|
||||
setTrackLineWidth(0);
|
||||
_scene->render(painter, target, adj);
|
||||
setTrackLineWidth(TRACK_WIDTH * _scale);
|
||||
}
|
||||
QPointF pos = _mapScale->pos();
|
||||
_mapScale->setPos(mapToScene(QPoint(adj.bottomRight() + QPoint(
|
||||
-(SCALE_OFFSET + _mapScale->boundingRect().width()),
|
||||
-(SCALE_OFFSET + _mapScale->boundingRect().height())))));
|
||||
|
||||
enum QPrinter::Orientation TrackView::orientation() const
|
||||
{
|
||||
return (sceneRect().width() > sceneRect().height())
|
||||
? QPrinter::Landscape : QPrinter::Portrait;
|
||||
render(painter, target, adj);
|
||||
|
||||
_mapScale->setPos(pos);
|
||||
|
||||
_plot = false;
|
||||
setUpdatesEnabled(true);
|
||||
}
|
||||
|
||||
void TrackView::clearPOI()
|
||||
@ -404,53 +469,111 @@ void TrackView::clear()
|
||||
_scene->removeItem(_mapScale);
|
||||
|
||||
_pois.clear();
|
||||
_paths.clear();
|
||||
_locations.clear();
|
||||
_markers.clear();
|
||||
_tracks.clear();
|
||||
_routes.clear();
|
||||
_waypoints.clear();
|
||||
_scene->clear();
|
||||
_palette.reset();
|
||||
|
||||
_tracks.clear();
|
||||
_waypoints.clear();
|
||||
|
||||
_maxPath = 0;
|
||||
_maxDistance = 0;
|
||||
_zoom = ZOOM_MAX;
|
||||
_scale = mapScale(_zoom);
|
||||
|
||||
_scene->setSceneRect(QRectF());
|
||||
|
||||
_markerPos = 0;
|
||||
}
|
||||
|
||||
void TrackView::movePositionMarker(qreal val)
|
||||
{
|
||||
qreal mp = val / _maxDistance;
|
||||
_markerPos = val;
|
||||
|
||||
for (int i = 0; i < _paths.size(); i++) {
|
||||
qreal f = _maxPath / _paths.at(i)->path().length();
|
||||
if (mp * f < 0 || 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);
|
||||
}
|
||||
}
|
||||
for (int i = 0; i < _tracks.size(); i++)
|
||||
_tracks.at(i)->moveMarker(val);
|
||||
|
||||
for (int i = 0; i < _routes.size(); i++)
|
||||
_routes.at(i)->moveMarker(val);
|
||||
}
|
||||
|
||||
void TrackView::showTracks(bool show)
|
||||
{
|
||||
_showTracks = show;
|
||||
|
||||
for (int i = 0; i < _tracks.count(); i++)
|
||||
_tracks.at(i)->setVisible(show);
|
||||
}
|
||||
|
||||
void TrackView::showRoutes(bool show)
|
||||
{
|
||||
_showRoutes = show;
|
||||
|
||||
for (int i = 0; i < _routes.count(); i++)
|
||||
_routes.at(i)->setVisible(show);
|
||||
}
|
||||
|
||||
void TrackView::showWaypoints(bool show)
|
||||
{
|
||||
_showWaypoints = show;
|
||||
|
||||
for (int i = 0; i < _waypoints.count(); i++)
|
||||
_waypoints.at(i)->setVisible(show);
|
||||
}
|
||||
|
||||
void TrackView::showWaypointLabels(bool show)
|
||||
{
|
||||
_showWaypointLabels = show;
|
||||
|
||||
for (int i = 0; i < _waypoints.size(); i++)
|
||||
_waypoints.at(i)->showLabel(show);
|
||||
|
||||
for (int i = 0; i < _routes.size(); i++)
|
||||
_routes.at(i)->showWaypointLabels(show);
|
||||
}
|
||||
|
||||
void TrackView::showRouteWaypoints(bool show)
|
||||
{
|
||||
_showRouteWaypoints = show;
|
||||
|
||||
for (int i = 0; i < _routes.size(); i++)
|
||||
_routes.at(i)->showWaypoints(show);
|
||||
}
|
||||
|
||||
void TrackView::showPOILabels(bool show)
|
||||
{
|
||||
_showPOILabels = show;
|
||||
|
||||
QHash<Waypoint, WaypointItem*>::const_iterator it;
|
||||
for (it = _pois.constBegin(); it != _pois.constEnd(); it++)
|
||||
it.value()->showLabel(show);
|
||||
|
||||
setPOIOverlap(_overlapPOIs);
|
||||
}
|
||||
|
||||
void TrackView::setPOIOverlap(bool overlap)
|
||||
{
|
||||
_overlapPOIs = overlap;
|
||||
|
||||
if (_overlapPOIs) {
|
||||
QHash<Waypoint, WaypointItem*>::const_iterator it;
|
||||
for (it = _pois.constBegin(); it != _pois.constEnd(); it++)
|
||||
it.value()->show();
|
||||
} else
|
||||
checkPOIOverlap();
|
||||
}
|
||||
|
||||
void TrackView::drawBackground(QPainter *painter, const QRectF &rect)
|
||||
{
|
||||
if ((_paths.isEmpty() && _locations.isEmpty())|| !_map) {
|
||||
if ((_tracks.isEmpty() && _routes.isEmpty() && _waypoints.isEmpty())
|
||||
|| !_map) {
|
||||
painter->fillRect(rect, Qt::white);
|
||||
return;
|
||||
}
|
||||
|
||||
painter->setWorldMatrixEnabled(false);
|
||||
|
||||
QRectF rr(rect.topLeft() * _scale, rect.size());
|
||||
QPoint tile = mercator2tile(QPointF(rr.topLeft().x(), -rr.topLeft().y()),
|
||||
_zoom);
|
||||
QPointF tm = tile2mercator(tile, _zoom);
|
||||
QPoint tl = mapFromScene(QPointF(tm.x() / _scale, -tm.y() / _scale));
|
||||
QPoint tl = mapToScene(mapFromScene(QPointF(tm.x() / _scale,
|
||||
-tm.y() / _scale))).toPoint();
|
||||
|
||||
QList<Tile> tiles;
|
||||
for (int i = 0; i <= rr.size().width() / TILE_SIZE + 1; i++) {
|
||||
@ -459,24 +582,25 @@ void TrackView::drawBackground(QPainter *painter, const QRectF &rect)
|
||||
}
|
||||
}
|
||||
|
||||
_map->loadTiles(tiles);
|
||||
_map->loadTiles(tiles, _plot);
|
||||
|
||||
for (int i = 0; i < tiles.count(); i++) {
|
||||
Tile &t = tiles[i];
|
||||
QPoint tp(tl.x() + (t.xy().rx() - tile.rx()) * TILE_SIZE,
|
||||
tl.y() + (t.xy().ry() - tile.ry()) * TILE_SIZE);
|
||||
QPoint tp(tl.x() + (t.xy().x() - tile.x()) * TILE_SIZE,
|
||||
tl.y() + (t.xy().y() - tile.y()) * TILE_SIZE);
|
||||
painter->drawPixmap(tp, t.pixmap());
|
||||
}
|
||||
}
|
||||
|
||||
void TrackView::resizeEvent(QResizeEvent *e)
|
||||
{
|
||||
if (_paths.isEmpty() && _locations.isEmpty())
|
||||
if (_tracks.isEmpty() && _routes.isEmpty() && _waypoints.isEmpty())
|
||||
return;
|
||||
|
||||
rescale();
|
||||
|
||||
QRectF br = trackBoundingRect() | waypointBoundingRect();
|
||||
QRectF br = trackBoundingRect() | routeBoundingRect()
|
||||
| waypointBoundingRect();
|
||||
QRectF ba = br.adjusted(-TILE_SIZE, -TILE_SIZE, TILE_SIZE, TILE_SIZE);
|
||||
|
||||
if (ba.width() < e->size().width()) {
|
||||
@ -496,9 +620,10 @@ void TrackView::resizeEvent(QResizeEvent *e)
|
||||
|
||||
void TrackView::paintEvent(QPaintEvent *e)
|
||||
{
|
||||
QPointF scenePos = mapToScene(rect().bottomLeft() + QPoint(SCALE_OFFSET,
|
||||
QPointF scenePos = mapToScene(rect().bottomRight() + QPoint(
|
||||
-(SCALE_OFFSET + _mapScale->boundingRect().width()),
|
||||
-(SCALE_OFFSET + _mapScale->boundingRect().height())));
|
||||
if (_mapScale->pos() != scenePos)
|
||||
if (_mapScale->pos() != scenePos && !_plot)
|
||||
_mapScale->setPos(scenePos);
|
||||
|
||||
QGraphicsView::paintEvent(e);
|
||||
|
@ -5,7 +5,6 @@
|
||||
#include <QVector>
|
||||
#include <QHash>
|
||||
#include <QList>
|
||||
#include <QPrinter>
|
||||
#include "units.h"
|
||||
#include "palette.h"
|
||||
#include "waypoint.h"
|
||||
@ -13,8 +12,11 @@
|
||||
class GPX;
|
||||
class POI;
|
||||
class Map;
|
||||
class Track;
|
||||
class Route;
|
||||
class TrackItem;
|
||||
class RouteItem;
|
||||
class WaypointItem;
|
||||
class MarkerItem;
|
||||
class ScaleItem;
|
||||
|
||||
class TrackView : public QGraphicsView
|
||||
@ -35,52 +37,73 @@ public:
|
||||
void setUnits(enum Units units);
|
||||
|
||||
void plot(QPainter *painter, const QRectF &target);
|
||||
enum QPrinter::Orientation orientation() const;
|
||||
|
||||
int trackCount() const {return _paths.count();}
|
||||
int waypointCount() const {return _locations.count();}
|
||||
int trackCount() const {return _tracks.count();}
|
||||
int routeCount() const {return _routes.count();}
|
||||
int waypointCount() const {return _waypoints.count();}
|
||||
|
||||
public slots:
|
||||
void movePositionMarker(qreal val);
|
||||
void redraw();
|
||||
|
||||
void setPOIOverlap(bool overlap);
|
||||
void showWaypointLabels(bool show);
|
||||
void showPOILabels(bool show);
|
||||
void showTracks(bool show);
|
||||
void showRoutes(bool show);
|
||||
void showWaypoints(bool show);
|
||||
void showRouteWaypoints(bool show);
|
||||
|
||||
private:
|
||||
void addTrack(const QVector<QPointF> &track);
|
||||
void addTrack(const Track &track);
|
||||
void addRoute(const Route &route);
|
||||
void addWaypoints(const QList<Waypoint> &waypoints);
|
||||
void addPOI(const QVector<Waypoint> &waypoints);
|
||||
|
||||
QRectF trackBoundingRect() const;
|
||||
QRectF routeBoundingRect() const;
|
||||
QRectF waypointBoundingRect() const;
|
||||
qreal trackScale() const;
|
||||
qreal routeScale() const;
|
||||
qreal waypointScale() const;
|
||||
qreal mapScale(int zoom) const;
|
||||
void rescale(qreal scale);
|
||||
void rescale();
|
||||
|
||||
void showMarkers(bool show);
|
||||
void setTrackLineWidth(qreal width);
|
||||
void zoom(int z, const QPointF &pos);
|
||||
void checkPOIOverlap();
|
||||
|
||||
void wheelEvent(QWheelEvent *event);
|
||||
void keyPressEvent(QKeyEvent *event);
|
||||
void drawBackground(QPainter *painter, const QRectF &rect);
|
||||
void resizeEvent(QResizeEvent *e);
|
||||
void paintEvent(QPaintEvent *e);
|
||||
|
||||
QGraphicsScene *_scene;
|
||||
QList<QGraphicsPathItem*> _paths;
|
||||
QList<MarkerItem*> _markers;
|
||||
QList<WaypointItem*> _locations;
|
||||
QList<TrackItem*> _tracks;
|
||||
QList<RouteItem*> _routes;
|
||||
QList<WaypointItem*> _waypoints;
|
||||
QHash<Waypoint, WaypointItem*> _pois;
|
||||
QList<QVector<QPointF> > _tracks;
|
||||
QVector<QPointF> _waypoints;
|
||||
|
||||
Map *_map;
|
||||
ScaleItem *_mapScale;
|
||||
|
||||
Palette _palette;
|
||||
qreal _maxPath, _maxDistance;
|
||||
|
||||
qreal _scale;
|
||||
int _zoom;
|
||||
|
||||
Units _units;
|
||||
|
||||
bool _showTracks;
|
||||
bool _showRoutes;
|
||||
bool _showWaypoints;
|
||||
bool _showWaypointLabels;
|
||||
bool _showPOILabels;
|
||||
bool _overlapPOIs;
|
||||
bool _showRouteWaypoints;
|
||||
|
||||
bool _plot;
|
||||
qreal _markerPos;
|
||||
};
|
||||
|
||||
#endif // TRACKVIEW_H
|
||||
|
@ -12,13 +12,17 @@ enum Units {
|
||||
#define MS2KMH 3.600000000000 // m/s -> km/h
|
||||
#define MS2MIH 2.236936290000 // m/s -> mi/h
|
||||
#define FT2MI 0.000189393939 // ft -> mi
|
||||
#define MM2IN 0.039370100000 // mm -> in
|
||||
|
||||
#define KMINM 1000 // 1 km in m
|
||||
#define MIINFT 5280 // 1 mi in ft
|
||||
#define MIINM 1609.344 // 1mi in m
|
||||
|
||||
#define C2FS 1.8 // Celsius to Farenheit - scale
|
||||
#define C2FO 32 // Celsius to Farenheit - offset
|
||||
|
||||
#ifdef Q_OS_WIN32
|
||||
#define UNIT_SPACE " "
|
||||
#define UNIT_SPACE QString(" ")
|
||||
#else // Q_OS_WIN32
|
||||
#define UNIT_SPACE QString::fromUtf8("\xE2\x80\x89")
|
||||
#endif // Q_OS_WIN32
|
||||
|
9
src/waypoint.cpp
Normal file
9
src/waypoint.cpp
Normal file
@ -0,0 +1,9 @@
|
||||
#include "waypoint.h"
|
||||
|
||||
QDebug operator<<(QDebug dbg, const Waypoint &waypoint)
|
||||
{
|
||||
dbg.nospace() << "Waypoint(" << waypoint.coordinates() << ", "
|
||||
<< waypoint.name() << ", " << waypoint.description() << ")";
|
||||
|
||||
return dbg.maybeSpace();
|
||||
}
|
@ -3,34 +3,54 @@
|
||||
|
||||
#include <QPointF>
|
||||
#include <QString>
|
||||
#include <QDateTime>
|
||||
#include <QHash>
|
||||
#include <QDebug>
|
||||
#include <cmath>
|
||||
|
||||
class Waypoint
|
||||
{
|
||||
public:
|
||||
Waypoint() {}
|
||||
Waypoint(const QPointF &coordinates, const QString &description)
|
||||
: _coordinates(coordinates), _description(description) {}
|
||||
Waypoint() {_elevation = NAN; _geoidHeight = 0;}
|
||||
Waypoint(const QPointF &coordinates)
|
||||
: _coordinates(coordinates) {_elevation = NAN; _geoidHeight = 0;}
|
||||
|
||||
const QPointF &coordinates() const {return _coordinates;}
|
||||
const QString &name() const {return _name;}
|
||||
const QString &description() const {return _description;}
|
||||
const QDateTime ×tamp() const {return _timestamp;}
|
||||
qreal elevation() const {return _elevation;}
|
||||
qreal geoidHeight() const {return _geoidHeight;}
|
||||
|
||||
void setCoordinates(const QPointF &coordinates)
|
||||
{_coordinates = coordinates;}
|
||||
void setName(const QString &name) {_name = name;}
|
||||
void setDescription(const QString &description)
|
||||
{_description = description;}
|
||||
void setTimestamp(const QDateTime ×tamp) {_timestamp = timestamp;}
|
||||
void setElevation(qreal elevation) {_elevation = elevation;}
|
||||
void setGeoidHeight(qreal geoidHeight) {_geoidHeight = geoidHeight;}
|
||||
|
||||
bool hasElevation() const {return !std::isnan(_elevation);}
|
||||
|
||||
bool operator==(const Waypoint &other) const
|
||||
{return this->_description == other._description
|
||||
{return this->_name == other._name
|
||||
&& this->_coordinates == other._coordinates;}
|
||||
|
||||
private:
|
||||
QPointF _coordinates;
|
||||
QString _name;
|
||||
QString _description;
|
||||
QDateTime _timestamp;
|
||||
qreal _elevation;
|
||||
qreal _geoidHeight;
|
||||
};
|
||||
|
||||
inline uint qHash(const Waypoint &key)
|
||||
{
|
||||
return ::qHash(key.description());
|
||||
return ::qHash(key.name());
|
||||
}
|
||||
|
||||
QDebug operator<<(QDebug dbg, const Waypoint &Waypoint);
|
||||
|
||||
#endif // WAYPOINT_H
|
||||
|
@ -1,43 +1,86 @@
|
||||
#include <QApplication>
|
||||
#include <QPainter>
|
||||
#include "config.h"
|
||||
#include "ll.h"
|
||||
#include "misc.h"
|
||||
#include "tooltip.h"
|
||||
#include "waypointitem.h"
|
||||
|
||||
|
||||
#define POINT_SIZE 8
|
||||
|
||||
WaypointItem::WaypointItem(const Waypoint &entry, QGraphicsItem *parent)
|
||||
QString WaypointItem::toolTip()
|
||||
{
|
||||
ToolTip tt;
|
||||
|
||||
if (!_waypoint.name().isEmpty() && !_showLabel)
|
||||
tt.insert(qApp->translate("WaypointItem", "Name"), _waypoint.name());
|
||||
tt.insert(qApp->translate("WaypointItem", "Coordinates"),
|
||||
::coordinates(_waypoint.coordinates()));
|
||||
if (!std::isnan(_waypoint.elevation()))
|
||||
tt.insert(qApp->translate("WaypointItem", "Elevation"),
|
||||
::elevation(_waypoint.elevation() - _waypoint.geoidHeight(), _units));
|
||||
if (!_waypoint.timestamp().isNull())
|
||||
tt.insert(qApp->translate("WaypointItem", "Date"),
|
||||
_waypoint.timestamp().toString(Qt::SystemLocaleShortDate));
|
||||
if (!_waypoint.description().isNull())
|
||||
tt.insert(qApp->translate("WaypointItem", "Description"),
|
||||
_waypoint.description());
|
||||
|
||||
return tt.toString();
|
||||
}
|
||||
|
||||
WaypointItem::WaypointItem(const Waypoint &waypoint, QGraphicsItem *parent)
|
||||
: QGraphicsItem(parent)
|
||||
{
|
||||
_entry = entry;
|
||||
_units = Metric;
|
||||
_showLabel = true;
|
||||
|
||||
_waypoint = waypoint;
|
||||
_coordinates = ll2mercator(QPointF(waypoint.coordinates().x(),
|
||||
-waypoint.coordinates().y()));
|
||||
|
||||
updateBoundingRect();
|
||||
|
||||
setPos(_coordinates);
|
||||
setToolTip(toolTip());
|
||||
setCursor(Qt::ArrowCursor);
|
||||
}
|
||||
|
||||
void WaypointItem::updateBoundingRect()
|
||||
{
|
||||
QFont font;
|
||||
font.setPixelSize(FONT_SIZE);
|
||||
font.setFamily(FONT_FAMILY);
|
||||
QFontMetrics fm(font);
|
||||
QRect ts = fm.tightBoundingRect(_entry.description());
|
||||
if (_showLabel) {
|
||||
QFont font;
|
||||
font.setPixelSize(FONT_SIZE);
|
||||
font.setFamily(FONT_FAMILY);
|
||||
QFontMetrics fm(font);
|
||||
QRect ts = fm.tightBoundingRect(_waypoint.name());
|
||||
|
||||
_boundingRect = QRectF(-POINT_SIZE/2, -POINT_SIZE/2, 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);
|
||||
} else
|
||||
_boundingRect = QRectF(-POINT_SIZE/2, -POINT_SIZE/2, POINT_SIZE,
|
||||
POINT_SIZE);
|
||||
}
|
||||
|
||||
void WaypointItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *option,
|
||||
QWidget *widget)
|
||||
void WaypointItem::paint(QPainter *painter,
|
||||
const QStyleOptionGraphicsItem *option, QWidget *widget)
|
||||
{
|
||||
Q_UNUSED(option);
|
||||
Q_UNUSED(widget);
|
||||
QFont font;
|
||||
font.setPixelSize(FONT_SIZE);
|
||||
font.setFamily(FONT_FAMILY);
|
||||
QFontMetrics fm(font);
|
||||
QRect ts = fm.tightBoundingRect(_entry.description());
|
||||
|
||||
painter->setFont(font);
|
||||
painter->drawText(POINT_SIZE/2 - qMax(ts.x(), 0), POINT_SIZE/2 + ts.height(),
|
||||
_entry.description());
|
||||
if (_showLabel) {
|
||||
QFont font;
|
||||
font.setPixelSize(FONT_SIZE);
|
||||
font.setFamily(FONT_FAMILY);
|
||||
QFontMetrics fm(font);
|
||||
QRect ts = fm.tightBoundingRect(_waypoint.name());
|
||||
|
||||
painter->setFont(font);
|
||||
painter->drawText(POINT_SIZE/2 - qMax(ts.x(), 0), POINT_SIZE/2
|
||||
+ ts.height(), _waypoint.name());
|
||||
}
|
||||
|
||||
painter->setBrush(Qt::SolidPattern);
|
||||
painter->drawEllipse(-POINT_SIZE/2, -POINT_SIZE/2, POINT_SIZE, POINT_SIZE);
|
||||
|
||||
@ -47,3 +90,22 @@ void WaypointItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *opti
|
||||
painter->drawRect(boundingRect());
|
||||
*/
|
||||
}
|
||||
|
||||
void WaypointItem::setScale(qreal scale)
|
||||
{
|
||||
setPos(_coordinates * scale);
|
||||
}
|
||||
|
||||
void WaypointItem::setUnits(enum Units units)
|
||||
{
|
||||
_units = units;
|
||||
setToolTip(toolTip());
|
||||
}
|
||||
|
||||
void WaypointItem::showLabel(bool show)
|
||||
{
|
||||
prepareGeometryChange();
|
||||
_showLabel = show;
|
||||
updateBoundingRect();
|
||||
setToolTip(toolTip());
|
||||
}
|
||||
|
@ -3,12 +3,19 @@
|
||||
|
||||
#include <QGraphicsItem>
|
||||
#include "waypoint.h"
|
||||
#include "units.h"
|
||||
|
||||
class WaypointItem : public QGraphicsItem
|
||||
{
|
||||
public:
|
||||
WaypointItem(const Waypoint &entry, QGraphicsItem *parent = 0);
|
||||
const Waypoint &entry() const {return _entry;}
|
||||
WaypointItem(const Waypoint &waypoint, QGraphicsItem *parent = 0);
|
||||
|
||||
const Waypoint &waypoint() const {return _waypoint;}
|
||||
const QPointF &coordinates() const {return _coordinates;}
|
||||
|
||||
void setUnits(enum Units units);
|
||||
void setScale(qreal scale);
|
||||
void showLabel(bool show);
|
||||
|
||||
QRectF boundingRect() const {return _boundingRect;}
|
||||
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option,
|
||||
@ -16,9 +23,13 @@ public:
|
||||
|
||||
private:
|
||||
void updateBoundingRect();
|
||||
QString toolTip();
|
||||
|
||||
Waypoint _entry;
|
||||
QRectF _boundingRect;
|
||||
QPointF _coordinates;
|
||||
Waypoint _waypoint;
|
||||
Units _units;
|
||||
bool _showLabel;
|
||||
};
|
||||
|
||||
#endif // WAYPOINTITEM_H
|
||||
|
Reference in New Issue
Block a user