mirror of
https://github.com/tumic0/GPXSee.git
synced 2025-07-04 22:59:29 +02:00
Compare commits
58 Commits
Author | SHA1 | Date | |
---|---|---|---|
a6b2a477a1 | |||
0ca264b176 | |||
be3c101c07 | |||
cb52ad8bc5 | |||
12d5dcc78c | |||
afd87c6fa2 | |||
c7d68f924f | |||
89304c0d5c | |||
c57a0f4061 | |||
f02ff1fa01 | |||
434df521fb | |||
9d90b97ba3 | |||
09631de5a2 | |||
6b8c0231ea | |||
eae55b14bb | |||
29fe054d57 | |||
b95fb80210 | |||
70f4010f55 | |||
014e260042 | |||
80bf57abfc | |||
473b92e8f7 | |||
1634b0715c | |||
1a07360d91 | |||
7e365cb990 | |||
19c44f56d6 | |||
799079392c | |||
1957a51570 | |||
e9b32fb582 | |||
3e421c6aba | |||
aa461a04b1 | |||
b369ffacef | |||
6034685fa0 | |||
420e96a2f4 | |||
a5f11cb77b | |||
f9fcbf5de4 | |||
058a09a426 | |||
ebf3c3bc14 | |||
eeed5ceba3 | |||
1827787fc2 | |||
3074ba9957 | |||
8624b42e0b | |||
c00ebdeefd | |||
05f1536285 | |||
bf69ef58ba | |||
adcd603eec | |||
0ee0bd882e | |||
d48a2aac93 | |||
7993e4dcb3 | |||
d20d94ef05 | |||
9f0582cbea | |||
1e6925da75 | |||
7cfc05c101 | |||
392b829733 | |||
36083d2fa1 | |||
63fd7f239c | |||
20b107581e | |||
aacc04520f | |||
dad85e46a7 |
19
gpxsee.pro
19
gpxsee.pro
@ -1,5 +1,5 @@
|
|||||||
TARGET = GPXSee
|
TARGET = GPXSee
|
||||||
VERSION = 2.17
|
VERSION = 2.20
|
||||||
QT += core \
|
QT += core \
|
||||||
gui \
|
gui \
|
||||||
network
|
network
|
||||||
@ -28,7 +28,6 @@ HEADERS += src/config.h \
|
|||||||
src/units.h \
|
src/units.h \
|
||||||
src/scaleitem.h \
|
src/scaleitem.h \
|
||||||
src/waypoint.h \
|
src/waypoint.h \
|
||||||
src/trackview.h \
|
|
||||||
src/track.h \
|
src/track.h \
|
||||||
src/graphview.h \
|
src/graphview.h \
|
||||||
src/trackpoint.h \
|
src/trackpoint.h \
|
||||||
@ -47,7 +46,13 @@ HEADERS += src/config.h \
|
|||||||
src/graphtab.h \
|
src/graphtab.h \
|
||||||
src/misc.h \
|
src/misc.h \
|
||||||
src/trackitem.h \
|
src/trackitem.h \
|
||||||
src/tooltip.h
|
src/tooltip.h \
|
||||||
|
src/route.h \
|
||||||
|
src/routeitem.h \
|
||||||
|
src/graphitem.h \
|
||||||
|
src/graph.h \
|
||||||
|
src/pathitem.h \
|
||||||
|
src/pathview.h
|
||||||
SOURCES += src/main.cpp \
|
SOURCES += src/main.cpp \
|
||||||
src/gui.cpp \
|
src/gui.cpp \
|
||||||
src/gpx.cpp \
|
src/gpx.cpp \
|
||||||
@ -66,7 +71,6 @@ SOURCES += src/main.cpp \
|
|||||||
src/maplist.cpp \
|
src/maplist.cpp \
|
||||||
src/downloader.cpp \
|
src/downloader.cpp \
|
||||||
src/scaleitem.cpp \
|
src/scaleitem.cpp \
|
||||||
src/trackview.cpp \
|
|
||||||
src/track.cpp \
|
src/track.cpp \
|
||||||
src/graphview.cpp \
|
src/graphview.cpp \
|
||||||
src/waypointitem.cpp \
|
src/waypointitem.cpp \
|
||||||
@ -82,7 +86,12 @@ SOURCES += src/main.cpp \
|
|||||||
src/misc.cpp \
|
src/misc.cpp \
|
||||||
src/waypoint.cpp \
|
src/waypoint.cpp \
|
||||||
src/trackitem.cpp \
|
src/trackitem.cpp \
|
||||||
src/tooltip.cpp
|
src/tooltip.cpp \
|
||||||
|
src/route.cpp \
|
||||||
|
src/routeitem.cpp \
|
||||||
|
src/graphitem.cpp \
|
||||||
|
src/pathitem.cpp \
|
||||||
|
src/pathview.cpp
|
||||||
RESOURCES += gpxsee.qrc
|
RESOURCES += gpxsee.qrc
|
||||||
TRANSLATIONS = lang/gpxsee_cs.ts
|
TRANSLATIONS = lang/gpxsee_cs.ts
|
||||||
macx {
|
macx {
|
||||||
|
@ -14,6 +14,7 @@
|
|||||||
<file>icons/arrow-left-double.png</file>
|
<file>icons/arrow-left-double.png</file>
|
||||||
<file>icons/arrow-right-double.png</file>
|
<file>icons/arrow-right-double.png</file>
|
||||||
<file>icons/view-fullscreen.png</file>
|
<file>icons/view-fullscreen.png</file>
|
||||||
|
<file>icons/office-chart-line-stacked.png</file>
|
||||||
<file>lang/gpxsee_cs.qm</file>
|
<file>lang/gpxsee_cs.qm</file>
|
||||||
</qresource>
|
</qresource>
|
||||||
</RCC>
|
</RCC>
|
||||||
|
BIN
icons/office-chart-line-stacked.png
Normal file
BIN
icons/office-chart-line-stacked.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 727 B |
@ -4,55 +4,38 @@
|
|||||||
<context>
|
<context>
|
||||||
<name>ElevationGraph</name>
|
<name>ElevationGraph</name>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../src/elevationgraph.cpp" line="14"/>
|
<location filename="../src/elevationgraph.cpp" line="48"/>
|
||||||
<source>Distance</source>
|
<location filename="../src/elevationgraph.h" line="13"/>
|
||||||
<translation>Vzdálenost</translation>
|
|
||||||
</message>
|
|
||||||
<message>
|
|
||||||
<location filename="../src/elevationgraph.cpp" line="15"/>
|
|
||||||
<location filename="../src/elevationgraph.h" line="15"/>
|
|
||||||
<source>Elevation</source>
|
<source>Elevation</source>
|
||||||
<translation>Výška</translation>
|
<translation>Výška</translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../src/elevationgraph.cpp" line="81"/>
|
<location filename="../src/elevationgraph.cpp" line="141"/>
|
||||||
<source>km</source>
|
|
||||||
<translation>km</translation>
|
|
||||||
</message>
|
|
||||||
<message>
|
|
||||||
<location filename="../src/elevationgraph.cpp" line="78"/>
|
|
||||||
<location filename="../src/elevationgraph.cpp" line="98"/>
|
|
||||||
<source>m</source>
|
<source>m</source>
|
||||||
<translation>m</translation>
|
<translation>m</translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../src/elevationgraph.cpp" line="22"/>
|
<location filename="../src/elevationgraph.cpp" line="58"/>
|
||||||
<source>Ascent</source>
|
<source>Ascent</source>
|
||||||
<translation>Stoupání</translation>
|
<translation>Stoupání</translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../src/elevationgraph.cpp" line="24"/>
|
<location filename="../src/elevationgraph.cpp" line="60"/>
|
||||||
<source>Descent</source>
|
<source>Descent</source>
|
||||||
<translation>Klesání</translation>
|
<translation>Klesání</translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../src/elevationgraph.cpp" line="28"/>
|
<location filename="../src/elevationgraph.cpp" line="64"/>
|
||||||
<source>Minimum</source>
|
<source>Minimum</source>
|
||||||
<translation>Minimum</translation>
|
<translation>Minimum</translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../src/elevationgraph.cpp" line="89"/>
|
<location filename="../src/elevationgraph.cpp" line="144"/>
|
||||||
<source>mi</source>
|
|
||||||
<translation>mi</translation>
|
|
||||||
</message>
|
|
||||||
<message>
|
|
||||||
<location filename="../src/elevationgraph.cpp" line="86"/>
|
|
||||||
<location filename="../src/elevationgraph.cpp" line="101"/>
|
|
||||||
<source>ft</source>
|
<source>ft</source>
|
||||||
<translation>ft</translation>
|
<translation>ft</translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../src/elevationgraph.cpp" line="26"/>
|
<location filename="../src/elevationgraph.cpp" line="62"/>
|
||||||
<source>Maximum</source>
|
<source>Maximum</source>
|
||||||
<translation>Maximum</translation>
|
<translation>Maximum</translation>
|
||||||
</message>
|
</message>
|
||||||
@ -163,331 +146,392 @@
|
|||||||
<context>
|
<context>
|
||||||
<name>GUI</name>
|
<name>GUI</name>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../src/gui.cpp" line="446"/>
|
<location filename="../src/gui.cpp" line="518"/>
|
||||||
<source>GPXSee is distributed under the terms of the GNU General Public License version 3. For more info about GPXSee visit the project homepage at </source>
|
<source>GPXSee is distributed under the terms of the GNU General Public License version 3. For more info about GPXSee visit the project homepage at </source>
|
||||||
<translation>Program GPXSee je distribuován pod podmínkami licence GNU General Public License verze 3. Pro více informací navštivte stránky programu na adrese </translation>
|
<translation>Program GPXSee je distribuován pod podmínkami licence GNU General Public License verze 3. Pro více informací navštivte stránky programu na adrese </translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../src/gui.cpp" line="510"/>
|
<location filename="../src/gui.cpp" line="582"/>
|
||||||
<source>Open file</source>
|
<source>Open file</source>
|
||||||
<translation>Otevřít soubor</translation>
|
<translation>Otevřít soubor</translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../src/gui.cpp" line="586"/>
|
<location filename="../src/gui.cpp" line="661"/>
|
||||||
<source>Open POI file</source>
|
<source>Open POI file</source>
|
||||||
<translation>Otevřít POI soubor</translation>
|
<translation>Otevřít POI soubor</translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../src/gui.cpp" line="194"/>
|
<location filename="../src/gui.cpp" line="206"/>
|
||||||
<source>Open</source>
|
<source>Open</source>
|
||||||
<translation>Otevřít</translation>
|
<translation>Otevřít</translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../src/gui.cpp" line="178"/>
|
<location filename="../src/gui.cpp" line="190"/>
|
||||||
<source>Quit</source>
|
<source>Quit</source>
|
||||||
<translation>Ukončit</translation>
|
<translation>Ukončit</translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../src/gui.cpp" line="186"/>
|
<location filename="../src/gui.cpp" line="198"/>
|
||||||
<location filename="../src/gui.cpp" line="462"/>
|
<location filename="../src/gui.cpp" line="534"/>
|
||||||
<location filename="../src/gui.cpp" line="463"/>
|
<location filename="../src/gui.cpp" line="535"/>
|
||||||
<source>Keyboard controls</source>
|
<source>Keyboard controls</source>
|
||||||
<translation>Ovládací klávesy</translation>
|
<translation>Ovládací klávesy</translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../src/gui.cpp" line="210"/>
|
<location filename="../src/gui.cpp" line="222"/>
|
||||||
<source>Close</source>
|
<source>Close</source>
|
||||||
<translation>Zavřít</translation>
|
<translation>Zavřít</translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../src/gui.cpp" line="216"/>
|
<location filename="../src/gui.cpp" line="228"/>
|
||||||
<source>Reload</source>
|
<source>Reload</source>
|
||||||
<translation>Znovu načíst</translation>
|
<translation>Znovu načíst</translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../src/gui.cpp" line="378"/>
|
<location filename="../src/gui.cpp" line="449"/>
|
||||||
<source>Show</source>
|
<source>Show</source>
|
||||||
<translation>Zobrazit</translation>
|
<translation>Zobrazit</translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../src/gui.cpp" line="317"/>
|
<location filename="../src/gui.cpp" line="373"/>
|
||||||
<location filename="../src/gui.cpp" line="372"/>
|
<location filename="../src/gui.cpp" line="443"/>
|
||||||
<source>File</source>
|
<source>File</source>
|
||||||
<translation>Soubor</translation>
|
<translation>Soubor</translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../src/gui.cpp" line="184"/>
|
<location filename="../src/gui.cpp" line="196"/>
|
||||||
<location filename="../src/gui.cpp" line="485"/>
|
<location filename="../src/gui.cpp" line="557"/>
|
||||||
<location filename="../src/gui.cpp" line="486"/>
|
<location filename="../src/gui.cpp" line="558"/>
|
||||||
<source>Data sources</source>
|
<source>Data sources</source>
|
||||||
<translation>Zdroje dat</translation>
|
<translation>Zdroje dat</translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../src/gui.cpp" line="224"/>
|
<location filename="../src/gui.cpp" line="236"/>
|
||||||
<source>Load POI file</source>
|
<source>Load POI file</source>
|
||||||
<translation>Nahrát POI soubor</translation>
|
<translation>Nahrát POI soubor</translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../src/gui.cpp" line="227"/>
|
<location filename="../src/gui.cpp" line="239"/>
|
||||||
<source>Close POI files</source>
|
<source>Close POI files</source>
|
||||||
<translation>Zavřit POI soubory</translation>
|
<translation>Zavřit POI soubory</translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../src/gui.cpp" line="229"/>
|
<location filename="../src/gui.cpp" line="241"/>
|
||||||
<source>Overlap POIs</source>
|
<source>Overlap POIs</source>
|
||||||
<translation>Překrývat POI</translation>
|
<translation>Překrývat POI</translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../src/gui.cpp" line="234"/>
|
<location filename="../src/gui.cpp" line="245"/>
|
||||||
|
<source>Show POI labels</source>
|
||||||
|
<translation>Zobrazovat názvy POI</translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<location filename="../src/gui.cpp" line="250"/>
|
||||||
<source>Show POIs</source>
|
<source>Show POIs</source>
|
||||||
<translation>Zobrazit POI</translation>
|
<translation>Zobrazit POI</translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../src/gui.cpp" line="242"/>
|
<location filename="../src/gui.cpp" line="259"/>
|
||||||
<source>Show map</source>
|
<source>Show map</source>
|
||||||
<translation>Zobrazit mapu</translation>
|
<translation>Zobrazit mapu</translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../src/gui.cpp" line="248"/>
|
<location filename="../src/gui.cpp" line="265"/>
|
||||||
<source>Clear tile cache</source>
|
<source>Clear tile cache</source>
|
||||||
<translation>Vymazat mezipaměť dlaždic</translation>
|
<translation>Vymazat mezipaměť dlaždic</translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../src/gui.cpp" line="257"/>
|
<location filename="../src/gui.cpp" line="274"/>
|
||||||
<location filename="../src/gui.cpp" line="261"/>
|
<location filename="../src/gui.cpp" line="278"/>
|
||||||
<location filename="../src/gui.cpp" line="472"/>
|
<location filename="../src/gui.cpp" line="544"/>
|
||||||
<source>Next map</source>
|
<source>Next map</source>
|
||||||
<translation>Následující mapa</translation>
|
<translation>Následující mapa</translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../src/gui.cpp" line="268"/>
|
<location filename="../src/gui.cpp" line="285"/>
|
||||||
|
<source>Show tracks</source>
|
||||||
|
<translation>Zobrazit cesty</translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<location filename="../src/gui.cpp" line="289"/>
|
||||||
|
<source>Show routes</source>
|
||||||
|
<translation>Zobrazit trasy</translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<location filename="../src/gui.cpp" line="293"/>
|
||||||
|
<source>Show waypoints</source>
|
||||||
|
<translation>Zobrazit navigační body</translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<location filename="../src/gui.cpp" line="297"/>
|
||||||
|
<source>Waypoint labels</source>
|
||||||
|
<translation>Názvy navigačních bodů</translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<location filename="../src/gui.cpp" line="308"/>
|
||||||
<source>Show graphs</source>
|
<source>Show graphs</source>
|
||||||
<translation>Zobrazovat grafy</translation>
|
<translation>Zobrazovat grafy</translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../src/gui.cpp" line="274"/>
|
<location filename="../src/gui.cpp" line="330"/>
|
||||||
<source>Show toolbars</source>
|
<source>Show toolbars</source>
|
||||||
<translation>Zobrazovat nástrojové lišty</translation>
|
<translation>Zobrazovat nástrojové lišty</translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../src/gui.cpp" line="280"/>
|
<location filename="../src/gui.cpp" line="336"/>
|
||||||
<source>Metric</source>
|
<source>Metric</source>
|
||||||
<translation>Metrické</translation>
|
<translation>Metrické</translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../src/gui.cpp" line="285"/>
|
<location filename="../src/gui.cpp" line="341"/>
|
||||||
<source>Imperial</source>
|
<source>Imperial</source>
|
||||||
<translation>Imperiální</translation>
|
<translation>Imperiální</translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../src/gui.cpp" line="291"/>
|
<location filename="../src/gui.cpp" line="347"/>
|
||||||
<source>Fullscreen mode</source>
|
<source>Fullscreen mode</source>
|
||||||
<translation>Celoobrazovkový režim</translation>
|
<translation>Celoobrazovkový režim</translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../src/gui.cpp" line="299"/>
|
<location filename="../src/gui.cpp" line="355"/>
|
||||||
<source>Next</source>
|
<source>Next</source>
|
||||||
<translation>Následující</translation>
|
<translation>Následující</translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../src/gui.cpp" line="302"/>
|
<location filename="../src/gui.cpp" line="358"/>
|
||||||
<source>Previous</source>
|
<source>Previous</source>
|
||||||
<translation>Předchozí</translation>
|
<translation>Předchozí</translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../src/gui.cpp" line="306"/>
|
<location filename="../src/gui.cpp" line="362"/>
|
||||||
<source>Last</source>
|
<source>Last</source>
|
||||||
<translation>Poslední</translation>
|
<translation>Poslední</translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../src/gui.cpp" line="309"/>
|
<location filename="../src/gui.cpp" line="365"/>
|
||||||
<source>First</source>
|
<source>First</source>
|
||||||
<translation>První</translation>
|
<translation>První</translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../src/gui.cpp" line="331"/>
|
<location filename="../src/gui.cpp" line="387"/>
|
||||||
<source>Map</source>
|
<source>Map</source>
|
||||||
<translation>Mapa</translation>
|
<translation>Mapa</translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../src/gui.cpp" line="338"/>
|
<location filename="../src/gui.cpp" line="394"/>
|
||||||
|
<source>Graph</source>
|
||||||
|
<translation>Graf</translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<location filename="../src/gui.cpp" line="400"/>
|
||||||
<source>POI</source>
|
<source>POI</source>
|
||||||
<translation>POI</translation>
|
<translation>POI</translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../src/gui.cpp" line="339"/>
|
<location filename="../src/gui.cpp" line="401"/>
|
||||||
<source>POI files</source>
|
<source>POI files</source>
|
||||||
<translation>POI soubory</translation>
|
<translation>POI soubory</translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../src/gui.cpp" line="349"/>
|
<location filename="../src/gui.cpp" line="412"/>
|
||||||
|
<source>Data</source>
|
||||||
|
<translation>Data</translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<location filename="../src/gui.cpp" line="413"/>
|
||||||
|
<source>Display</source>
|
||||||
|
<translation>Zobrazit</translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<location filename="../src/gui.cpp" line="421"/>
|
||||||
<source>Settings</source>
|
<source>Settings</source>
|
||||||
<translation>Nastavení</translation>
|
<translation>Nastavení</translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../src/gui.cpp" line="350"/>
|
<location filename="../src/gui.cpp" line="422"/>
|
||||||
<source>Units</source>
|
<source>Units</source>
|
||||||
<translation>Jednotky</translation>
|
<translation>Jednotky</translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../src/gui.cpp" line="359"/>
|
<location filename="../src/gui.cpp" line="430"/>
|
||||||
<source>Help</source>
|
<source>Help</source>
|
||||||
<translation>Nápověda</translation>
|
<translation>Nápověda</translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../src/gui.cpp" line="474"/>
|
<location filename="../src/gui.cpp" line="546"/>
|
||||||
<source>Previous map</source>
|
<source>Previous map</source>
|
||||||
<translation>Předchozí mapa</translation>
|
<translation>Předchozí mapa</translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../src/gui.cpp" line="672"/>
|
<location filename="../src/gui.cpp" line="663"/>
|
||||||
<location filename="../src/gui.cpp" line="675"/>
|
<source>GPX files (*.gpx)</source>
|
||||||
|
<translation>Soubory GPX (*.gpx)</translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<location filename="../src/gui.cpp" line="663"/>
|
||||||
|
<source>CSV files (*.csv)</source>
|
||||||
|
<translation>Soubory CSV (*.csv)</translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<location filename="../src/gui.cpp" line="664"/>
|
||||||
|
<source>All files (*)</source>
|
||||||
|
<translation>Všechny soubory (*)</translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<location filename="../src/gui.cpp" line="752"/>
|
||||||
|
<location filename="../src/gui.cpp" line="755"/>
|
||||||
<source>Date</source>
|
<source>Date</source>
|
||||||
<translation>Datum</translation>
|
<translation>Datum</translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../src/gui.cpp" line="853"/>
|
<location filename="../src/gui.cpp" line="764"/>
|
||||||
|
<source>Routes</source>
|
||||||
|
<translation>Trasy</translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<location filename="../src/gui.cpp" line="946"/>
|
||||||
<source>No GPX files loaded</source>
|
<source>No GPX files loaded</source>
|
||||||
<translation>Nejsou načteny žádné GPX soubory</translation>
|
<translation>Nejsou načteny žádné GPX soubory</translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../src/gui.cpp" line="465"/>
|
<location filename="../src/gui.cpp" line="950"/>
|
||||||
|
<source>%1 files</source>
|
||||||
|
<translation>%1 souborů</translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<location filename="../src/gui.cpp" line="537"/>
|
||||||
<source>Next file</source>
|
<source>Next file</source>
|
||||||
<translation>Následující soubor</translation>
|
<translation>Následující soubor</translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../src/gui.cpp" line="442"/>
|
<location filename="../src/gui.cpp" line="514"/>
|
||||||
<source>Version </source>
|
<source>Version </source>
|
||||||
<translation>Verze </translation>
|
<translation>Verze </translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../src/gui.cpp" line="199"/>
|
<location filename="../src/gui.cpp" line="211"/>
|
||||||
<source>Print...</source>
|
<source>Print...</source>
|
||||||
<translation>Tisknout...</translation>
|
<translation>Tisknout...</translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../src/gui.cpp" line="204"/>
|
<location filename="../src/gui.cpp" line="216"/>
|
||||||
<source>Export to PDF...</source>
|
<source>Export to PDF...</source>
|
||||||
<translation>Exportovat do PDF...</translation>
|
<translation>Exportovat do PDF...</translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../src/gui.cpp" line="466"/>
|
<location filename="../src/gui.cpp" line="662"/>
|
||||||
|
<source>All POI files (*.gpx *.csv)</source>
|
||||||
|
<translation>Všechny POI soubory (*.gpx *.csv)</translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<location filename="../src/gui.cpp" line="766"/>
|
||||||
|
<source>Waypoints</source>
|
||||||
|
<translation>Navigační body</translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<location filename="../src/gui.cpp" line="538"/>
|
||||||
<source>Previous file</source>
|
<source>Previous file</source>
|
||||||
<translation>Předchozí soubor</translation>
|
<translation>Předchozí soubor</translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../src/gui.cpp" line="468"/>
|
<location filename="../src/gui.cpp" line="301"/>
|
||||||
|
<source>Route waypoints</source>
|
||||||
|
<translation>Body tras</translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<location filename="../src/gui.cpp" line="540"/>
|
||||||
<source>First file</source>
|
<source>First file</source>
|
||||||
<translation>První soubor</translation>
|
<translation>První soubor</translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../src/gui.cpp" line="469"/>
|
<location filename="../src/gui.cpp" line="541"/>
|
||||||
<source>Last file</source>
|
<source>Last file</source>
|
||||||
<translation>Poslední soubor</translation>
|
<translation>Poslední soubor</translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../src/gui.cpp" line="470"/>
|
<location filename="../src/gui.cpp" line="542"/>
|
||||||
<source>Append modifier</source>
|
<source>Append modifier</source>
|
||||||
<translation>Modifikátor nahradit/přidat</translation>
|
<translation>Modifikátor nahradit/přidat</translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../src/gui.cpp" line="489"/>
|
<location filename="../src/gui.cpp" line="561"/>
|
||||||
<source>Map (tiles) source URLs are read on program startup from the following file:</source>
|
<source>Map (tiles) source URLs are read on program startup from the following file:</source>
|
||||||
<translation>URL mapových zdrojů (dlaždic) jsou načteny při startu programu z následujícího souboru:</translation>
|
<translation>URL mapových zdrojů (dlaždic) jsou načteny při startu programu z následujícího souboru:</translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../src/gui.cpp" line="492"/>
|
<location filename="../src/gui.cpp" line="564"/>
|
||||||
<source>The file format is one map entry per line, consisting of the map name and tiles URL delimited by a TAB character. The tile X and Y coordinates are replaced with $x and $y in the URL and the zoom level is replaced with $z. An example map file could look like:</source>
|
<source>The file format is one map entry per line, consisting of the map name and tiles URL delimited by a TAB character. The tile X and Y coordinates are replaced with $x and $y in the URL and the zoom level is replaced with $z. An example map file could look like:</source>
|
||||||
<translation>Formát souboru je jeden mapový záznam na řádku, kde mapový záznam sestává ze jména mapy a URL dlaždic navzájem oddělených tabulátorem. Souřadnice dlaždice jsou v URL nahrazeny řetězci $x a $y, úroven přiblížení (zoom) pak řetězcem $z. Příklad:</translation>
|
<translation>Formát souboru je jeden mapový záznam na řádku, kde mapový záznam sestává ze jména mapy a URL dlaždic navzájem oddělených tabulátorem. Souřadnice dlaždice jsou v URL nahrazeny řetězci $x a $y, úroven přiblížení (zoom) pak řetězcem $z. Příklad:</translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../src/gui.cpp" line="500"/>
|
<location filename="../src/gui.cpp" line="572"/>
|
||||||
<source>To make GPXSee load a POI file automatically on startup, add the file to the following directory:</source>
|
<source>To make GPXSee load a POI file automatically on startup, add the file to the following directory:</source>
|
||||||
<translation>POI soubory, které se mají automaticky nahrát při startu programu jsou načítány z následujícího adresáře:</translation>
|
<translation>POI soubory, které se mají automaticky nahrát při startu programu jsou načítány z následujícího adresáře:</translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../src/gui.cpp" line="511"/>
|
<location filename="../src/gui.cpp" line="583"/>
|
||||||
<source>GPX files (*.gpx);;All files (*)</source>
|
<source>GPX files (*.gpx);;All files (*)</source>
|
||||||
<translation>Soubory GPX (*.gpx);;Všechny soubory (*)</translation>
|
<translation>Soubory GPX (*.gpx);;Všechny soubory (*)</translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../src/gui.cpp" line="577"/>
|
<location filename="../src/gui.cpp" line="652"/>
|
||||||
<location filename="../src/gui.cpp" line="603"/>
|
<location filename="../src/gui.cpp" line="680"/>
|
||||||
<source>Line: %1</source>
|
<source>Line: %1</source>
|
||||||
<translation>Řádka: %1</translation>
|
<translation>Řádka: %1</translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../src/gui.cpp" line="587"/>
|
<location filename="../src/gui.cpp" line="762"/>
|
||||||
<source>GPX files (*.gpx);;CSV files (*.csv);;All files (*)</source>
|
|
||||||
<translation>Soubory GPX (*.gpx);;Soubory CSV (*.csv);;Všechny soubory (*)</translation>
|
|
||||||
</message>
|
|
||||||
<message>
|
|
||||||
<location filename="../src/gui.cpp" line="678"/>
|
|
||||||
<source>Tracks</source>
|
<source>Tracks</source>
|
||||||
<translation>Počet tras</translation>
|
<translation>Cesty</translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../src/gui.cpp" line="684"/>
|
<location filename="../src/gui.cpp" line="201"/>
|
||||||
<source>mi</source>
|
<location filename="../src/gui.cpp" line="512"/>
|
||||||
<translation>mi</translation>
|
|
||||||
</message>
|
|
||||||
<message>
|
|
||||||
<location filename="../src/gui.cpp" line="189"/>
|
|
||||||
<location filename="../src/gui.cpp" line="440"/>
|
|
||||||
<source>About GPXSee</source>
|
<source>About GPXSee</source>
|
||||||
<translation>O aplikaci GPXSee</translation>
|
<translation>O aplikaci GPXSee</translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../src/gui.cpp" line="382"/>
|
<location filename="../src/gui.cpp" line="454"/>
|
||||||
<source>Navigation</source>
|
<source>Navigation</source>
|
||||||
<translation>Navigace</translation>
|
<translation>Navigace</translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../src/gui.cpp" line="488"/>
|
<location filename="../src/gui.cpp" line="560"/>
|
||||||
<source>Map sources</source>
|
<source>Map sources</source>
|
||||||
<translation>Mapové zdroje</translation>
|
<translation>Mapové zdroje</translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../src/gui.cpp" line="499"/>
|
<location filename="../src/gui.cpp" line="571"/>
|
||||||
<source>POIs</source>
|
<source>POIs</source>
|
||||||
<translation>POI body</translation>
|
<translation>POI body</translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../src/gui.cpp" line="683"/>
|
<location filename="../src/gui.cpp" line="316"/>
|
||||||
<location filename="../src/gui.cpp" line="686"/>
|
<location filename="../src/gui.cpp" line="769"/>
|
||||||
<source>Distance</source>
|
<source>Distance</source>
|
||||||
<translation>Vzdálenost</translation>
|
<translation>Vzdálenost</translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../src/gui.cpp" line="691"/>
|
<location filename="../src/gui.cpp" line="322"/>
|
||||||
|
<location filename="../src/gui.cpp" line="771"/>
|
||||||
<source>Time</source>
|
<source>Time</source>
|
||||||
<translation>Čas</translation>
|
<translation>Čas</translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../src/gui.cpp" line="860"/>
|
<location filename="../src/gui.cpp" line="654"/>
|
||||||
<source>%1 tracks</source>
|
<location filename="../src/gui.cpp" line="681"/>
|
||||||
<translation>Počet tras: %1</translation>
|
|
||||||
</message>
|
|
||||||
<message>
|
|
||||||
<location filename="../src/gui.cpp" line="687"/>
|
|
||||||
<source>km</source>
|
|
||||||
<translation>km</translation>
|
|
||||||
</message>
|
|
||||||
<message>
|
|
||||||
<location filename="../src/gui.cpp" line="579"/>
|
|
||||||
<location filename="../src/gui.cpp" line="604"/>
|
|
||||||
<source>Error</source>
|
<source>Error</source>
|
||||||
<translation>Chyba</translation>
|
<translation>Chyba</translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../src/gui.cpp" line="574"/>
|
<location filename="../src/gui.cpp" line="649"/>
|
||||||
<source>Error loading GPX file:
|
<source>Error loading GPX file:
|
||||||
%1</source>
|
%1</source>
|
||||||
<translation>Soubor GPX nelze otevřít:
|
<translation>Soubor GPX nelze otevřít:
|
||||||
%1</translation>
|
%1</translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../src/gui.cpp" line="600"/>
|
<location filename="../src/gui.cpp" line="677"/>
|
||||||
<source>Error loading POI file:
|
<source>Error loading POI file:
|
||||||
%1</source>
|
%1</source>
|
||||||
<translation>Soubor POI nelze otevřít:
|
<translation>Soubor POI nelze otevřít:
|
||||||
@ -495,53 +539,76 @@
|
|||||||
</message>
|
</message>
|
||||||
</context>
|
</context>
|
||||||
<context>
|
<context>
|
||||||
<name>HeartRateGraph</name>
|
<name>GraphView</name>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../src/heartrategraph.cpp" line="10"/>
|
<location filename="../src/graphview.cpp" line="111"/>
|
||||||
<source>Distance</source>
|
|
||||||
<translation>Vzdálenost</translation>
|
|
||||||
</message>
|
|
||||||
<message>
|
|
||||||
<location filename="../src/heartrategraph.cpp" line="11"/>
|
|
||||||
<location filename="../src/heartrategraph.h" line="15"/>
|
|
||||||
<source>Heart rate</source>
|
|
||||||
<translation>Tep</translation>
|
|
||||||
</message>
|
|
||||||
<message>
|
|
||||||
<location filename="../src/heartrategraph.cpp" line="78"/>
|
|
||||||
<source>km</source>
|
|
||||||
<translation>km</translation>
|
|
||||||
</message>
|
|
||||||
<message>
|
|
||||||
<location filename="../src/heartrategraph.cpp" line="9"/>
|
|
||||||
<source>1/min</source>
|
|
||||||
<translation>1/min</translation>
|
|
||||||
</message>
|
|
||||||
<message>
|
|
||||||
<location filename="../src/heartrategraph.cpp" line="18"/>
|
|
||||||
<source>Average</source>
|
|
||||||
<translation>Průměr</translation>
|
|
||||||
</message>
|
|
||||||
<message>
|
|
||||||
<location filename="../src/heartrategraph.cpp" line="20"/>
|
|
||||||
<source>Maximum</source>
|
|
||||||
<translation>Maximum</translation>
|
|
||||||
</message>
|
|
||||||
<message>
|
|
||||||
<location filename="../src/heartrategraph.cpp" line="75"/>
|
|
||||||
<source>m</source>
|
<source>m</source>
|
||||||
<translation>m</translation>
|
<translation>m</translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../src/heartrategraph.cpp" line="83"/>
|
<location filename="../src/graphview.cpp" line="114"/>
|
||||||
|
<source>km</source>
|
||||||
|
<translation>km</translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<location filename="../src/graphview.cpp" line="119"/>
|
||||||
<source>ft</source>
|
<source>ft</source>
|
||||||
<translation>ft</translation>
|
<translation>ft</translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../src/heartrategraph.cpp" line="86"/>
|
<location filename="../src/graphview.cpp" line="122"/>
|
||||||
<source>mi</source>
|
<source>mi</source>
|
||||||
<translation>mi</translation>
|
<translation>mi</translation>
|
||||||
</message>
|
</message>
|
||||||
|
<message>
|
||||||
|
<location filename="../src/graphview.cpp" line="128"/>
|
||||||
|
<source>s</source>
|
||||||
|
<translation>s</translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<location filename="../src/graphview.cpp" line="131"/>
|
||||||
|
<source>min</source>
|
||||||
|
<translation>min</translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<location filename="../src/graphview.cpp" line="134"/>
|
||||||
|
<source>h</source>
|
||||||
|
<translation>h</translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<location filename="../src/graphview.cpp" line="160"/>
|
||||||
|
<source>Distance</source>
|
||||||
|
<translation>Vzdálenost</translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<location filename="../src/graphview.cpp" line="162"/>
|
||||||
|
<source>Time</source>
|
||||||
|
<translation>Čas</translation>
|
||||||
|
</message>
|
||||||
|
</context>
|
||||||
|
<context>
|
||||||
|
<name>HeartRateGraph</name>
|
||||||
|
<message>
|
||||||
|
<location filename="../src/heartrategraph.cpp" line="11"/>
|
||||||
|
<location filename="../src/heartrategraph.h" line="13"/>
|
||||||
|
<source>Heart rate</source>
|
||||||
|
<translation>Tep</translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<location filename="../src/heartrategraph.cpp" line="10"/>
|
||||||
|
<source>1/min</source>
|
||||||
|
<translation>1/min</translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<location filename="../src/heartrategraph.cpp" line="19"/>
|
||||||
|
<source>Average</source>
|
||||||
|
<translation>Průměr</translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<location filename="../src/heartrategraph.cpp" line="21"/>
|
||||||
|
<source>Maximum</source>
|
||||||
|
<translation>Maximum</translation>
|
||||||
|
</message>
|
||||||
</context>
|
</context>
|
||||||
<context>
|
<context>
|
||||||
<name>Misc</name>
|
<name>Misc</name>
|
||||||
@ -569,137 +636,95 @@
|
|||||||
</message>
|
</message>
|
||||||
</context>
|
</context>
|
||||||
<context>
|
<context>
|
||||||
<name>QObject</name>
|
<name>RouteItem</name>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../src/scaleitem.cpp" line="81"/>
|
<location filename="../src/routeitem.cpp" line="15"/>
|
||||||
|
<source>Distance</source>
|
||||||
|
<translation>Vzdálenost</translation>
|
||||||
|
</message>
|
||||||
|
</context>
|
||||||
|
<context>
|
||||||
|
<name>ScaleItem</name>
|
||||||
|
<message>
|
||||||
|
<location filename="../src/scaleitem.cpp" line="90"/>
|
||||||
<source>mi</source>
|
<source>mi</source>
|
||||||
<translation>mi</translation>
|
<translation>mi</translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../src/scaleitem.cpp" line="81"/>
|
<location filename="../src/scaleitem.cpp" line="91"/>
|
||||||
<source>ft</source>
|
<source>ft</source>
|
||||||
<translation>ft</translation>
|
<translation>ft</translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../src/scaleitem.cpp" line="83"/>
|
<location filename="../src/scaleitem.cpp" line="93"/>
|
||||||
<source>km</source>
|
<source>km</source>
|
||||||
<translation>km</translation>
|
<translation>km</translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../src/scaleitem.cpp" line="83"/>
|
<location filename="../src/scaleitem.cpp" line="94"/>
|
||||||
<source>m</source>
|
<source>m</source>
|
||||||
<translation>m</translation>
|
<translation>m</translation>
|
||||||
</message>
|
</message>
|
||||||
</context>
|
</context>
|
||||||
<context>
|
<context>
|
||||||
<name>SpeedGraph</name>
|
<name>SpeedGraph</name>
|
||||||
<message>
|
|
||||||
<location filename="../src/speedgraph.cpp" line="11"/>
|
|
||||||
<source>Distance</source>
|
|
||||||
<translation>Vzdálenost</translation>
|
|
||||||
</message>
|
|
||||||
<message>
|
<message>
|
||||||
<location filename="../src/speedgraph.cpp" line="12"/>
|
<location filename="../src/speedgraph.cpp" line="12"/>
|
||||||
<location filename="../src/speedgraph.h" line="16"/>
|
<location filename="../src/speedgraph.h" line="14"/>
|
||||||
<source>Speed</source>
|
<source>Speed</source>
|
||||||
<translation>Rychlost</translation>
|
<translation>Rychlost</translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../src/speedgraph.cpp" line="72"/>
|
<location filename="../src/speedgraph.cpp" line="74"/>
|
||||||
<source>m</source>
|
|
||||||
<translation>m</translation>
|
|
||||||
</message>
|
|
||||||
<message>
|
|
||||||
<location filename="../src/speedgraph.cpp" line="75"/>
|
|
||||||
<source>km</source>
|
|
||||||
<translation></translation>
|
|
||||||
</message>
|
|
||||||
<message>
|
|
||||||
<location filename="../src/speedgraph.cpp" line="80"/>
|
|
||||||
<source>ft</source>
|
|
||||||
<translation>ft</translation>
|
|
||||||
</message>
|
|
||||||
<message>
|
|
||||||
<location filename="../src/speedgraph.cpp" line="92"/>
|
|
||||||
<source>km/h</source>
|
<source>km/h</source>
|
||||||
<translation>km/h</translation>
|
<translation>km/h</translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../src/speedgraph.cpp" line="19"/>
|
<location filename="../src/speedgraph.cpp" line="20"/>
|
||||||
<source>Average</source>
|
<source>Average</source>
|
||||||
<translation>Průměr</translation>
|
<translation>Průměr</translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../src/speedgraph.cpp" line="21"/>
|
<location filename="../src/speedgraph.cpp" line="22"/>
|
||||||
<source>Maximum</source>
|
<source>Maximum</source>
|
||||||
<translation>Maximum</translation>
|
<translation>Maximum</translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../src/speedgraph.cpp" line="83"/>
|
<location filename="../src/speedgraph.cpp" line="77"/>
|
||||||
<source>mi</source>
|
|
||||||
<translation>mi</translation>
|
|
||||||
</message>
|
|
||||||
<message>
|
|
||||||
<location filename="../src/speedgraph.cpp" line="95"/>
|
|
||||||
<source>mi/h</source>
|
<source>mi/h</source>
|
||||||
<translation>mi/h</translation>
|
<translation>mi/h</translation>
|
||||||
</message>
|
</message>
|
||||||
</context>
|
</context>
|
||||||
<context>
|
<context>
|
||||||
<name>TemperatureGraph</name>
|
<name>TemperatureGraph</name>
|
||||||
<message>
|
|
||||||
<location filename="../src/temperaturegraph.cpp" line="10"/>
|
|
||||||
<source>Distance</source>
|
|
||||||
<translation>Vzdálenost</translation>
|
|
||||||
</message>
|
|
||||||
<message>
|
<message>
|
||||||
<location filename="../src/temperaturegraph.cpp" line="11"/>
|
<location filename="../src/temperaturegraph.cpp" line="11"/>
|
||||||
<location filename="../src/temperaturegraph.h" line="15"/>
|
<location filename="../src/temperaturegraph.h" line="13"/>
|
||||||
<source>Temperature</source>
|
<source>Temperature</source>
|
||||||
<translation>Teplota</translation>
|
<translation>Teplota</translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../src/temperaturegraph.cpp" line="18"/>
|
<location filename="../src/temperaturegraph.cpp" line="19"/>
|
||||||
<source>Average</source>
|
<source>Average</source>
|
||||||
<translation>Průměr</translation>
|
<translation>Průměr</translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../src/temperaturegraph.cpp" line="20"/>
|
<location filename="../src/temperaturegraph.cpp" line="21"/>
|
||||||
<source>Minimum</source>
|
<source>Minimum</source>
|
||||||
<translation>Minimum</translation>
|
<translation>Minimum</translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../src/temperaturegraph.cpp" line="22"/>
|
<location filename="../src/temperaturegraph.cpp" line="23"/>
|
||||||
<source>Maximum</source>
|
<source>Maximum</source>
|
||||||
<translation>Maximum</translation>
|
<translation>Maximum</translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../src/temperaturegraph.cpp" line="77"/>
|
<location filename="../src/temperaturegraph.cpp" line="81"/>
|
||||||
<source>m</source>
|
|
||||||
<translation>m</translation>
|
|
||||||
</message>
|
|
||||||
<message>
|
|
||||||
<location filename="../src/temperaturegraph.cpp" line="80"/>
|
|
||||||
<source>km</source>
|
|
||||||
<translation>km</translation>
|
|
||||||
</message>
|
|
||||||
<message>
|
|
||||||
<location filename="../src/temperaturegraph.cpp" line="85"/>
|
|
||||||
<source>ft</source>
|
|
||||||
<translation>ft</translation>
|
|
||||||
</message>
|
|
||||||
<message>
|
|
||||||
<location filename="../src/temperaturegraph.cpp" line="88"/>
|
|
||||||
<source>mi</source>
|
|
||||||
<translation>mi</translation>
|
|
||||||
</message>
|
|
||||||
<message>
|
|
||||||
<location filename="../src/temperaturegraph.cpp" line="97"/>
|
|
||||||
<source>C</source>
|
<source>C</source>
|
||||||
<translation>C</translation>
|
<translation>C</translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../src/temperaturegraph.cpp" line="101"/>
|
<location filename="../src/temperaturegraph.cpp" line="85"/>
|
||||||
<source>F</source>
|
<source>F</source>
|
||||||
<translation>F</translation>
|
<translation>F</translation>
|
||||||
</message>
|
</message>
|
||||||
@ -707,17 +732,17 @@
|
|||||||
<context>
|
<context>
|
||||||
<name>TrackItem</name>
|
<name>TrackItem</name>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../src/trackitem.cpp" line="16"/>
|
<location filename="../src/trackitem.cpp" line="14"/>
|
||||||
<source>Distance</source>
|
<source>Distance</source>
|
||||||
<translation>Vzdálenost</translation>
|
<translation>Vzdálenost</translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../src/trackitem.cpp" line="19"/>
|
<location filename="../src/trackitem.cpp" line="17"/>
|
||||||
<source>Time</source>
|
<source>Time</source>
|
||||||
<translation>Čas</translation>
|
<translation>Čas</translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../src/trackitem.cpp" line="21"/>
|
<location filename="../src/trackitem.cpp" line="19"/>
|
||||||
<source>Date</source>
|
<source>Date</source>
|
||||||
<translation>Datum</translation>
|
<translation>Datum</translation>
|
||||||
</message>
|
</message>
|
||||||
@ -725,22 +750,27 @@
|
|||||||
<context>
|
<context>
|
||||||
<name>WaypointItem</name>
|
<name>WaypointItem</name>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../src/waypointitem.cpp" line="16"/>
|
<location filename="../src/waypointitem.cpp" line="18"/>
|
||||||
|
<source>Name</source>
|
||||||
|
<translation>Název</translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<location filename="../src/waypointitem.cpp" line="19"/>
|
||||||
<source>Coordinates</source>
|
<source>Coordinates</source>
|
||||||
<translation>Souřadnice</translation>
|
<translation>Souřadnice</translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../src/waypointitem.cpp" line="19"/>
|
<location filename="../src/waypointitem.cpp" line="22"/>
|
||||||
<source>Elevation</source>
|
<source>Elevation</source>
|
||||||
<translation>Výška</translation>
|
<translation>Výška</translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../src/waypointitem.cpp" line="22"/>
|
<location filename="../src/waypointitem.cpp" line="25"/>
|
||||||
<source>Date</source>
|
<source>Date</source>
|
||||||
<translation>Datum</translation>
|
<translation>Datum</translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../src/waypointitem.cpp" line="25"/>
|
<location filename="../src/waypointitem.cpp" line="28"/>
|
||||||
<source>Description</source>
|
<source>Description</source>
|
||||||
<translation>Popis</translation>
|
<translation>Popis</translation>
|
||||||
</message>
|
</message>
|
||||||
|
@ -4,7 +4,7 @@
|
|||||||
; The name of the installer
|
; The name of the installer
|
||||||
Name "GPXSee"
|
Name "GPXSee"
|
||||||
; Program version
|
; Program version
|
||||||
!define VERSION "2.17"
|
!define VERSION "2.20"
|
||||||
|
|
||||||
; The file to write
|
; The file to write
|
||||||
OutFile "GPXSee-${VERSION}.exe"
|
OutFile "GPXSee-${VERSION}.exe"
|
||||||
|
@ -4,7 +4,7 @@
|
|||||||
; The name of the installer
|
; The name of the installer
|
||||||
Name "GPXSee"
|
Name "GPXSee"
|
||||||
; Program version
|
; Program version
|
||||||
!define VERSION "2.17"
|
!define VERSION "2.20"
|
||||||
|
|
||||||
; The file to write
|
; The file to write
|
||||||
OutFile "GPXSee-${VERSION}_x64.exe"
|
OutFile "GPXSee-${VERSION}_x64.exe"
|
||||||
|
@ -2,6 +2,7 @@
|
|||||||
#include <QTranslator>
|
#include <QTranslator>
|
||||||
#include <QLocale>
|
#include <QLocale>
|
||||||
#include <QFileOpenEvent>
|
#include <QFileOpenEvent>
|
||||||
|
#include <QNetworkProxyFactory>
|
||||||
#include "gui.h"
|
#include "gui.h"
|
||||||
#include "app.h"
|
#include "app.h"
|
||||||
|
|
||||||
@ -18,6 +19,8 @@ App::App(int &argc, char **argv) : QApplication(argc, argv),
|
|||||||
setAttribute(Qt::AA_DontShowIconsInMenus);
|
setAttribute(Qt::AA_DontShowIconsInMenus);
|
||||||
#endif // Q_OS_MAC
|
#endif // Q_OS_MAC
|
||||||
|
|
||||||
|
QNetworkProxyFactory::setUseSystemConfiguration(true);
|
||||||
|
|
||||||
_gui = new GUI();
|
_gui = new GUI();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -5,6 +5,7 @@
|
|||||||
#include "axisitem.h"
|
#include "axisitem.h"
|
||||||
|
|
||||||
|
|
||||||
|
#define AXIS_WIDTH 1
|
||||||
#define TICK 6
|
#define TICK 6
|
||||||
#define PADDING 6
|
#define PADDING 6
|
||||||
#define XTICKS 15
|
#define XTICKS 15
|
||||||
@ -34,6 +35,10 @@ AxisItem::AxisItem(Type type, QGraphicsItem *parent) : QGraphicsItem(parent)
|
|||||||
{
|
{
|
||||||
_type = type;
|
_type = type;
|
||||||
_size = 0;
|
_size = 0;
|
||||||
|
|
||||||
|
#ifndef Q_OS_MAC
|
||||||
|
setCacheMode(QGraphicsItem::DeviceCoordinateCache);
|
||||||
|
#endif // Q_OS_MAC
|
||||||
}
|
}
|
||||||
|
|
||||||
void AxisItem::setRange(const RangeF &range)
|
void AxisItem::setRange(const RangeF &range)
|
||||||
@ -41,6 +46,7 @@ void AxisItem::setRange(const RangeF &range)
|
|||||||
prepareGeometryChange();
|
prepareGeometryChange();
|
||||||
_range = range;
|
_range = range;
|
||||||
updateBoundingRect();
|
updateBoundingRect();
|
||||||
|
update();
|
||||||
}
|
}
|
||||||
|
|
||||||
void AxisItem::setSize(qreal size)
|
void AxisItem::setSize(qreal size)
|
||||||
@ -48,6 +54,7 @@ void AxisItem::setSize(qreal size)
|
|||||||
prepareGeometryChange();
|
prepareGeometryChange();
|
||||||
_size = size;
|
_size = size;
|
||||||
updateBoundingRect();
|
updateBoundingRect();
|
||||||
|
update();
|
||||||
}
|
}
|
||||||
|
|
||||||
void AxisItem::setLabel(const QString& label)
|
void AxisItem::setLabel(const QString& label)
|
||||||
@ -55,6 +62,7 @@ void AxisItem::setLabel(const QString& label)
|
|||||||
prepareGeometryChange();
|
prepareGeometryChange();
|
||||||
_label = label;
|
_label = label;
|
||||||
updateBoundingRect();
|
updateBoundingRect();
|
||||||
|
update();
|
||||||
}
|
}
|
||||||
|
|
||||||
void AxisItem::updateBoundingRect()
|
void AxisItem::updateBoundingRect()
|
||||||
@ -75,7 +83,7 @@ void AxisItem::updateBoundingRect()
|
|||||||
if (_type == X) {
|
if (_type == X) {
|
||||||
_boundingRect = QRectF(-ss.width()/2, -TICK/2,
|
_boundingRect = QRectF(-ss.width()/2, -TICK/2,
|
||||||
_size + es.width()/2 + ss.width()/2,
|
_size + es.width()/2 + ss.width()/2,
|
||||||
ls.height() + es.height() - fm.descent() + TICK + 2*PADDING);
|
ls.height() + es.height() - fm.descent() + TICK + 2*PADDING + 1);
|
||||||
} else {
|
} else {
|
||||||
int mtw = 0;
|
int mtw = 0;
|
||||||
QRect ts;
|
QRect ts;
|
||||||
@ -88,9 +96,8 @@ void AxisItem::updateBoundingRect()
|
|||||||
mtw = qMax(ts.width(), mtw);
|
mtw = qMax(ts.width(), mtw);
|
||||||
}
|
}
|
||||||
|
|
||||||
_boundingRect = QRectF(-(ls.height() + mtw + 2*PADDING
|
_boundingRect = QRectF(-(ls.height() + mtw + 2*PADDING + TICK/2),
|
||||||
- fm.descent() + TICK/2), -(_size + es.height()/2
|
-(_size + es.height()/2 + fm.descent()), ls.height() + mtw + 2*PADDING
|
||||||
+ fm.descent()), ls.height() -fm.descent() + mtw + 2*PADDING
|
|
||||||
+ TICK, _size + es.height()/2 + fm.descent() + ss.height()/2);
|
+ TICK, _size + es.height()/2 + fm.descent() + ss.height()/2);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -108,9 +115,11 @@ void AxisItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *option,
|
|||||||
struct Label l;
|
struct Label l;
|
||||||
qreal range = _range.size();
|
qreal range = _range.size();
|
||||||
qreal val;
|
qreal val;
|
||||||
|
QPen pen = QPen(Qt::black, AXIS_WIDTH);
|
||||||
|
|
||||||
|
|
||||||
painter->setFont(font);
|
painter->setFont(font);
|
||||||
|
painter->setPen(pen);
|
||||||
|
|
||||||
ls = fm.tightBoundingRect(_label);
|
ls = fm.tightBoundingRect(_label);
|
||||||
|
|
||||||
|
@ -1,97 +1,140 @@
|
|||||||
|
#include <cmath>
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
#include "gpx.h"
|
#include "gpx.h"
|
||||||
#include "elevationgraph.h"
|
#include "elevationgraph.h"
|
||||||
|
|
||||||
|
|
||||||
|
static qreal nMin(qreal a, qreal b)
|
||||||
|
{
|
||||||
|
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)
|
ElevationGraph::ElevationGraph(QWidget *parent) : GraphTab(parent)
|
||||||
{
|
{
|
||||||
_ascent = 0;
|
_trackAscent = 0;
|
||||||
_descent = 0;
|
_routeAscent = 0;
|
||||||
|
_trackDescent = 0;
|
||||||
|
_routeDescent = 0;
|
||||||
|
_trackMin = NAN;
|
||||||
|
_trackMax = NAN;
|
||||||
|
_routeMin = NAN;
|
||||||
|
_routeMax = NAN;
|
||||||
|
|
||||||
|
_showRoutes = true;
|
||||||
|
_showTracks = true;
|
||||||
|
|
||||||
_units = Metric;
|
_units = Metric;
|
||||||
|
|
||||||
setYUnits();
|
setYUnits();
|
||||||
setXLabel(tr("Distance"));
|
|
||||||
setYLabel(tr("Elevation"));
|
setYLabel(tr("Elevation"));
|
||||||
|
|
||||||
setMinYRange(50.0);
|
setMinYRange(50.0);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ElevationGraph::addInfo()
|
void ElevationGraph::setInfo()
|
||||||
{
|
{
|
||||||
GraphView::addInfo(tr("Ascent"), QString::number(_ascent * yScale(), 'f', 0)
|
if (std::isnan(max()) || std::isnan(min()))
|
||||||
+ UNIT_SPACE + yUnits());
|
clearInfo();
|
||||||
GraphView::addInfo(tr("Descent"), QString::number(_descent * yScale(), 'f',
|
else {
|
||||||
0) + UNIT_SPACE + yUnits());
|
GraphView::addInfo(tr("Ascent"), QString::number(ascent() * yScale(),
|
||||||
GraphView::addInfo(tr("Maximum"), QString::number(max() * yScale(), 'f', 0)
|
'f', 0) + UNIT_SPACE + yUnits());
|
||||||
+ UNIT_SPACE + yUnits());
|
GraphView::addInfo(tr("Descent"), QString::number(descent() * yScale(),
|
||||||
GraphView::addInfo(tr("Minimum"), QString::number(min() * yScale(), 'f', 0)
|
'f', 0) + UNIT_SPACE + yUnits());
|
||||||
+ 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());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void ElevationGraph::loadGraph(const Graph &graph, Type type, PathItem *path)
|
||||||
|
{
|
||||||
|
qreal ascent = 0, descent = 0;
|
||||||
|
qreal min, max;
|
||||||
|
|
||||||
|
if (graph.size() < 2) {
|
||||||
|
skipColor();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
max = min = graph.at(0).y();
|
||||||
|
for (int j = 1; j < graph.size(); j++) {
|
||||||
|
qreal cur = graph.at(j).y();
|
||||||
|
qreal prev = graph.at(j-1).y();
|
||||||
|
|
||||||
|
if (cur > prev)
|
||||||
|
ascent += cur - prev;
|
||||||
|
if (cur < prev)
|
||||||
|
descent += prev - cur;
|
||||||
|
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
|
||||||
|
GraphView::loadGraph(graph, path, type);
|
||||||
|
}
|
||||||
|
|
||||||
|
void ElevationGraph::loadGPX(const GPX &gpx, const QList<PathItem *> &paths)
|
||||||
|
{
|
||||||
|
int p = 0;
|
||||||
|
|
||||||
|
for (int i = 0; i < gpx.tracks().count(); i++)
|
||||||
|
loadGraph(gpx.tracks().at(i)->elevation(), Track, paths.at(p++));
|
||||||
|
for (int i = 0; i < gpx.routes().count(); i++)
|
||||||
|
loadGraph(gpx.routes().at(i)->elevation(), Route, paths.at(p++));
|
||||||
|
|
||||||
|
setInfo();
|
||||||
|
|
||||||
redraw();
|
redraw();
|
||||||
}
|
}
|
||||||
|
|
||||||
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);
|
|
||||||
}
|
|
||||||
|
|
||||||
setXUnits();
|
|
||||||
addInfo();
|
|
||||||
}
|
|
||||||
|
|
||||||
void ElevationGraph::clear()
|
void ElevationGraph::clear()
|
||||||
{
|
{
|
||||||
_ascent = 0;
|
_trackAscent = 0;
|
||||||
_descent = 0;
|
_routeAscent = 0;
|
||||||
|
_trackDescent = 0;
|
||||||
|
_routeDescent = 0;
|
||||||
|
_trackMin = NAN;
|
||||||
|
_trackMax = NAN;
|
||||||
|
_routeMin = NAN;
|
||||||
|
_routeMax = NAN;
|
||||||
|
|
||||||
GraphView::clear();
|
GraphView::clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
void ElevationGraph::setXUnits()
|
|
||||||
{
|
|
||||||
if (_units == Metric) {
|
|
||||||
if (bounds().width() < KMINM) {
|
|
||||||
GraphView::setXUnits(tr("m"));
|
|
||||||
setXScale(1);
|
|
||||||
} else {
|
|
||||||
GraphView::setXUnits(tr("km"));
|
|
||||||
setXScale(M2KM);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
if (bounds().width() < MIINM) {
|
|
||||||
GraphView::setXUnits(tr("ft"));
|
|
||||||
setXScale(M2FT);
|
|
||||||
} else {
|
|
||||||
GraphView::setXUnits(tr("mi"));
|
|
||||||
setXScale(M2MI);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void ElevationGraph::setYUnits()
|
void ElevationGraph::setYUnits()
|
||||||
{
|
{
|
||||||
if (_units == Metric) {
|
if (_units == Metric) {
|
||||||
@ -106,9 +149,86 @@ void ElevationGraph::setYUnits()
|
|||||||
void ElevationGraph::setUnits(enum Units units)
|
void ElevationGraph::setUnits(enum Units units)
|
||||||
{
|
{
|
||||||
_units = units;
|
_units = units;
|
||||||
setXUnits();
|
|
||||||
setYUnits();
|
|
||||||
|
|
||||||
clearInfo();
|
setYUnits();
|
||||||
addInfo();
|
setInfo();
|
||||||
|
GraphView::setUnits(units);
|
||||||
|
|
||||||
|
redraw();
|
||||||
|
}
|
||||||
|
|
||||||
|
void ElevationGraph::showTracks(bool show)
|
||||||
|
{
|
||||||
|
_showTracks = show;
|
||||||
|
|
||||||
|
setInfo();
|
||||||
|
showGraph(show, Track);
|
||||||
|
|
||||||
|
redraw();
|
||||||
|
}
|
||||||
|
|
||||||
|
void ElevationGraph::showRoutes(bool show)
|
||||||
|
{
|
||||||
|
_showRoutes = show;
|
||||||
|
|
||||||
|
showGraph(show, Route);
|
||||||
|
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;
|
||||||
}
|
}
|
||||||
|
@ -3,8 +3,6 @@
|
|||||||
|
|
||||||
#include "graphtab.h"
|
#include "graphtab.h"
|
||||||
|
|
||||||
class GPX;
|
|
||||||
|
|
||||||
class ElevationGraph : public GraphTab
|
class ElevationGraph : public GraphTab
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
@ -13,22 +11,32 @@ public:
|
|||||||
ElevationGraph(QWidget *parent = 0);
|
ElevationGraph(QWidget *parent = 0);
|
||||||
|
|
||||||
QString label() const {return tr("Elevation");}
|
QString label() const {return tr("Elevation");}
|
||||||
void loadGPX(const GPX &gpx);
|
void loadGPX(const GPX &gpx, const QList<PathItem *> &paths);
|
||||||
void clear();
|
void clear();
|
||||||
void setUnits(enum Units units);
|
void setUnits(enum Units units);
|
||||||
|
void showTracks(bool show);
|
||||||
|
void showRoutes(bool show);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
qreal ascent() const {return _ascent;}
|
enum Type {Track, Route};
|
||||||
qreal descent() const {return _descent;}
|
|
||||||
qreal max() const {return bounds().bottom();}
|
qreal max() const;
|
||||||
qreal min() const {return bounds().top();}
|
qreal min() const;
|
||||||
|
qreal ascent() const;
|
||||||
|
qreal descent() const;
|
||||||
|
|
||||||
void setXUnits();
|
|
||||||
void setYUnits();
|
void setYUnits();
|
||||||
void addInfo();
|
void setInfo();
|
||||||
|
|
||||||
|
void loadGraph(const Graph &graph, Type type, PathItem *path);
|
||||||
|
|
||||||
|
qreal _trackAscent, _trackDescent;
|
||||||
|
qreal _routeAscent, _routeDescent;
|
||||||
|
qreal _trackMax, _routeMax;
|
||||||
|
qreal _trackMin, _routeMin;
|
||||||
|
|
||||||
qreal _ascent, _descent;
|
|
||||||
enum Units _units;
|
enum Units _units;
|
||||||
|
bool _showTracks, _showRoutes;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // ELEVATIONGRAPH_H
|
#endif // ELEVATIONGRAPH_H
|
||||||
|
@ -91,6 +91,7 @@ ExportDialog::ExportDialog(QPrinter *printer, QWidget *parent)
|
|||||||
line->setFrameShadow(QFrame::Sunken);
|
line->setFrameShadow(QFrame::Sunken);
|
||||||
pageSetupLayout->addRow(line);
|
pageSetupLayout->addRow(line);
|
||||||
pageSetupLayout->addRow(tr("File:"), _fileSelect);
|
pageSetupLayout->addRow(tr("File:"), _fileSelect);
|
||||||
|
pageSetupLayout->setFieldGrowthPolicy(QFormLayout::ExpandingFieldsGrow);
|
||||||
#else // Q_OS_MAC
|
#else // Q_OS_MAC
|
||||||
pageSetupBox->setLayout(pageSetupLayout);
|
pageSetupBox->setLayout(pageSetupLayout);
|
||||||
#endif // Q_OS_MAC
|
#endif // Q_OS_MAC
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
#include <QPushButton>
|
#include <QPushButton>
|
||||||
|
#include <QToolButton>
|
||||||
#include <QFileDialog>
|
#include <QFileDialog>
|
||||||
#include <QHBoxLayout>
|
#include <QHBoxLayout>
|
||||||
#include <QFileInfo>
|
#include <QFileInfo>
|
||||||
@ -12,7 +13,13 @@ FileSelectWidget::FileSelectWidget(QWidget *parent) : QWidget(parent)
|
|||||||
QFontMetrics fm(QApplication::font());
|
QFontMetrics fm(QApplication::font());
|
||||||
_edit = new QLineEdit();
|
_edit = new QLineEdit();
|
||||||
_edit->setMinimumWidth(fm.boundingRect(QDir::homePath()).width());
|
_edit->setMinimumWidth(fm.boundingRect(QDir::homePath()).width());
|
||||||
_button = new QPushButton(tr("Browse..."));
|
#ifdef Q_OS_WIN32
|
||||||
|
_button = new QPushButton("...");
|
||||||
|
_button->setMaximumWidth(_button->sizeHint().width() / 2);
|
||||||
|
#else // Q_OS_WIN32
|
||||||
|
_button = new QToolButton();
|
||||||
|
_button->setText("...");
|
||||||
|
#endif // Q_OS_WIN32
|
||||||
connect(_button, SIGNAL(clicked()), this, SLOT(browse()));
|
connect(_button, SIGNAL(clicked()), this, SLOT(browse()));
|
||||||
|
|
||||||
QHBoxLayout *layout = new QHBoxLayout();
|
QHBoxLayout *layout = new QHBoxLayout();
|
||||||
@ -20,6 +27,9 @@ FileSelectWidget::FileSelectWidget(QWidget *parent) : QWidget(parent)
|
|||||||
layout->addWidget(_edit);
|
layout->addWidget(_edit);
|
||||||
layout->addWidget(_button);
|
layout->addWidget(_button);
|
||||||
setLayout(layout);
|
setLayout(layout);
|
||||||
|
|
||||||
|
QSizePolicy p(QSizePolicy::MinimumExpanding, QSizePolicy::Fixed);
|
||||||
|
setSizePolicy(p);
|
||||||
}
|
}
|
||||||
|
|
||||||
void FileSelectWidget::browse()
|
void FileSelectWidget::browse()
|
||||||
|
@ -5,6 +5,7 @@
|
|||||||
#include <QLineEdit>
|
#include <QLineEdit>
|
||||||
|
|
||||||
class QPushButton;
|
class QPushButton;
|
||||||
|
class QToolButton;
|
||||||
|
|
||||||
class FileSelectWidget : public QWidget
|
class FileSelectWidget : public QWidget
|
||||||
{
|
{
|
||||||
@ -22,7 +23,11 @@ private slots:
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
QLineEdit *_edit;
|
QLineEdit *_edit;
|
||||||
|
#ifdef Q_OS_WIN32
|
||||||
QPushButton *_button;
|
QPushButton *_button;
|
||||||
|
#else // Q_OS_WIN32
|
||||||
|
QToolButton *_button;
|
||||||
|
#endif // Q_OS_WIN32
|
||||||
|
|
||||||
QString _filter;
|
QString _filter;
|
||||||
};
|
};
|
||||||
|
29
src/gpx.cpp
29
src/gpx.cpp
@ -4,12 +4,24 @@
|
|||||||
#include "gpx.h"
|
#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)
|
bool GPX::loadFile(const QString &fileName)
|
||||||
{
|
{
|
||||||
QFile file(fileName);
|
|
||||||
bool ret;
|
bool ret;
|
||||||
|
QFile file(fileName);
|
||||||
|
|
||||||
|
|
||||||
_tracks.clear();
|
|
||||||
_error.clear();
|
_error.clear();
|
||||||
_errorLine = 0;
|
_errorLine = 0;
|
||||||
|
|
||||||
@ -18,11 +30,18 @@ bool GPX::loadFile(const QString &fileName)
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!(ret = _parser.loadFile(&file))) {
|
ret = _parser.loadFile(&file);
|
||||||
|
file.close();
|
||||||
|
if (ret == false) {
|
||||||
_error = _parser.errorString();
|
_error = _parser.errorString();
|
||||||
_errorLine = _parser.errorLine();
|
_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 <QString>
|
||||||
#include "waypoint.h"
|
#include "waypoint.h"
|
||||||
#include "track.h"
|
#include "track.h"
|
||||||
|
#include "route.h"
|
||||||
#include "parser.h"
|
#include "parser.h"
|
||||||
|
|
||||||
class GPX
|
class GPX
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
GPX() : _parser(_tracks, _waypoints), _errorLine(0) {}
|
GPX();
|
||||||
|
~GPX();
|
||||||
|
|
||||||
bool loadFile(const QString &fileName);
|
bool loadFile(const QString &fileName);
|
||||||
const QString &errorString() const {return _error;}
|
const QString &errorString() const {return _error;}
|
||||||
int errorLine() const {return _errorLine;}
|
int errorLine() const {return _errorLine;}
|
||||||
|
|
||||||
int trackCount() const {return _tracks.count();}
|
const QList<Track*> &tracks() const {return _tracks;}
|
||||||
Track track(int i) const {return Track(_tracks.at(i));}
|
const QList<Route*> &routes() const {return _routes;}
|
||||||
const QList<Waypoint> &waypoints() const {return _waypoints;}
|
const QList<Waypoint> &waypoints() const {return _waypoint_data;}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Parser _parser;
|
Parser _parser;
|
||||||
QString _error;
|
QString _error;
|
||||||
int _errorLine;
|
int _errorLine;
|
||||||
|
|
||||||
QList<QVector<Trackpoint> > _tracks;
|
QList<Track*> _tracks;
|
||||||
QList<Waypoint> _waypoints;
|
QList<Route*> _routes;
|
||||||
|
|
||||||
|
QList<QVector<Trackpoint> > _track_data;
|
||||||
|
QList<QVector<Waypoint> > _route_data;
|
||||||
|
QList<Waypoint> _waypoint_data;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // GPX_H
|
#endif // GPX_H
|
||||||
|
32
src/graph.h
Normal file
32
src/graph.h
Normal file
@ -0,0 +1,32 @@
|
|||||||
|
#ifndef GRAPH_H
|
||||||
|
#define GRAPH_H
|
||||||
|
|
||||||
|
#include <QVector>
|
||||||
|
#include <cmath>
|
||||||
|
|
||||||
|
enum GraphType {Distance, Time};
|
||||||
|
|
||||||
|
class GraphPoint
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
GraphPoint(qreal s = NAN, qreal t = NAN, qreal y = NAN)
|
||||||
|
: _s(s), _t(t), _y(y) {}
|
||||||
|
|
||||||
|
qreal s() const {return _s;}
|
||||||
|
qreal t() const {return _t;}
|
||||||
|
qreal y() const {return _y;}
|
||||||
|
qreal x(GraphType type) const {return (type == Distance) ? _s : _t;}
|
||||||
|
|
||||||
|
void setS(qreal s) {_s = s;}
|
||||||
|
void setT(qreal t) {_t = t;}
|
||||||
|
void setY(qreal y) {_y = y;}
|
||||||
|
|
||||||
|
private:
|
||||||
|
qreal _s;
|
||||||
|
qreal _t;
|
||||||
|
qreal _y;
|
||||||
|
};
|
||||||
|
|
||||||
|
typedef QVector<GraphPoint> Graph;
|
||||||
|
|
||||||
|
#endif // GRAPH_H
|
195
src/graphitem.cpp
Normal file
195
src/graphitem.cpp
Normal file
@ -0,0 +1,195 @@
|
|||||||
|
#include <QPainter>
|
||||||
|
#include "graphitem.h"
|
||||||
|
|
||||||
|
|
||||||
|
#define GRAPH_WIDTH 1
|
||||||
|
#define HOVER_WIDTH 2
|
||||||
|
|
||||||
|
static bool hasTime(const Graph &graph)
|
||||||
|
{
|
||||||
|
for (int i = 0; i < graph.count(); i++)
|
||||||
|
if (std::isnan(graph.at(i).t()))
|
||||||
|
return false;
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
GraphItem::GraphItem(const Graph &graph, QGraphicsItem *parent)
|
||||||
|
: QGraphicsObject(parent)
|
||||||
|
{
|
||||||
|
_id = 0;
|
||||||
|
|
||||||
|
_pen = QPen(Qt::black, GRAPH_WIDTH);
|
||||||
|
|
||||||
|
_type = Distance;
|
||||||
|
_graph = graph;
|
||||||
|
_sx = 1.0; _sy = 1.0;
|
||||||
|
_time = hasTime(_graph);
|
||||||
|
|
||||||
|
updatePath();
|
||||||
|
updateBounds();
|
||||||
|
}
|
||||||
|
|
||||||
|
void GraphItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *option,
|
||||||
|
QWidget *widget)
|
||||||
|
{
|
||||||
|
Q_UNUSED(option);
|
||||||
|
Q_UNUSED(widget);
|
||||||
|
|
||||||
|
painter->setPen(_pen);
|
||||||
|
painter->drawPath(_path);
|
||||||
|
|
||||||
|
/*
|
||||||
|
QPen p = QPen(QBrush(Qt::red), 0);
|
||||||
|
painter->setPen(p);
|
||||||
|
painter->drawRect(boundingRect());
|
||||||
|
*/
|
||||||
|
}
|
||||||
|
|
||||||
|
void GraphItem::setGraphType(GraphType type)
|
||||||
|
{
|
||||||
|
prepareGeometryChange();
|
||||||
|
|
||||||
|
_type = type;
|
||||||
|
updatePath();
|
||||||
|
updateBounds();
|
||||||
|
}
|
||||||
|
|
||||||
|
void GraphItem::setColor(const QColor &color)
|
||||||
|
{
|
||||||
|
_pen.setColor(color);
|
||||||
|
update();
|
||||||
|
}
|
||||||
|
|
||||||
|
qreal GraphItem::yAtX(qreal x)
|
||||||
|
{
|
||||||
|
int low = 0;
|
||||||
|
int high = _graph.count() - 1;
|
||||||
|
int mid = 0;
|
||||||
|
|
||||||
|
Q_ASSERT(high > low);
|
||||||
|
Q_ASSERT(x >= _graph.at(low).x(_type) && x <= _graph.at(high).x(_type));
|
||||||
|
|
||||||
|
while (low <= high) {
|
||||||
|
mid = low + ((high - low) / 2);
|
||||||
|
const GraphPoint &p = _graph.at(mid);
|
||||||
|
if (p.x(_type) > x)
|
||||||
|
high = mid - 1;
|
||||||
|
else if (p.x(_type) < x)
|
||||||
|
low = mid + 1;
|
||||||
|
else
|
||||||
|
return -p.y();
|
||||||
|
}
|
||||||
|
|
||||||
|
QLineF l;
|
||||||
|
if (_graph.at(mid).x(_type) < x)
|
||||||
|
l = QLineF(_graph.at(mid).x(_type), _graph.at(mid).y(),
|
||||||
|
_graph.at(mid+1).x(_type), _graph.at(mid+1).y());
|
||||||
|
else
|
||||||
|
l = QLineF(_graph.at(mid-1).x(_type), _graph.at(mid-1).y(),
|
||||||
|
_graph.at(mid).x(_type), _graph.at(mid).y());
|
||||||
|
|
||||||
|
return -l.pointAt((x - l.p1().x()) / (l.p2().x() - l.p1().x())).y();
|
||||||
|
}
|
||||||
|
|
||||||
|
qreal GraphItem::distanceAtTime(qreal time)
|
||||||
|
{
|
||||||
|
int low = 0;
|
||||||
|
int high = _graph.count() - 1;
|
||||||
|
int mid = 0;
|
||||||
|
|
||||||
|
Q_ASSERT(high > low);
|
||||||
|
Q_ASSERT(time >= _graph.at(low).t() && time <= _graph.at(high).t());
|
||||||
|
|
||||||
|
while (low <= high) {
|
||||||
|
mid = low + ((high - low) / 2);
|
||||||
|
const GraphPoint &p = _graph.at(mid);
|
||||||
|
if (p.t() > time)
|
||||||
|
high = mid - 1;
|
||||||
|
else if (p.t() < time)
|
||||||
|
low = mid + 1;
|
||||||
|
else
|
||||||
|
return _graph.at(mid).s();
|
||||||
|
}
|
||||||
|
|
||||||
|
QLineF l;
|
||||||
|
if (_graph.at(mid).t() < time)
|
||||||
|
l = QLineF(_graph.at(mid).t(), _graph.at(mid).s(), _graph.at(mid+1).t(),
|
||||||
|
_graph.at(mid+1).s());
|
||||||
|
else
|
||||||
|
l = QLineF(_graph.at(mid-1).t(), _graph.at(mid-1).s(),
|
||||||
|
_graph.at(mid).t(), _graph.at(mid).s());
|
||||||
|
|
||||||
|
return l.pointAt((time - l.p1().x()) / (l.p2().x() - l.p1().x())).y();
|
||||||
|
}
|
||||||
|
|
||||||
|
void GraphItem::emitSliderPositionChanged(qreal pos)
|
||||||
|
{
|
||||||
|
if (_type == Time) {
|
||||||
|
if (_time) {
|
||||||
|
if (pos <= _graph.last().t())
|
||||||
|
emit sliderPositionChanged(distanceAtTime(pos));
|
||||||
|
else
|
||||||
|
emit sliderPositionChanged(_graph.last().s() + 1);
|
||||||
|
} else
|
||||||
|
emit sliderPositionChanged(_graph.last().s() + 1);
|
||||||
|
} else
|
||||||
|
emit sliderPositionChanged(pos);
|
||||||
|
}
|
||||||
|
|
||||||
|
void GraphItem::selected(bool selected)
|
||||||
|
{
|
||||||
|
if (selected) {
|
||||||
|
_pen.setWidth(HOVER_WIDTH);
|
||||||
|
setZValue(zValue() + 1.0);
|
||||||
|
} else {
|
||||||
|
_pen.setWidth(GRAPH_WIDTH);
|
||||||
|
setZValue(zValue() - 1.0);
|
||||||
|
}
|
||||||
|
|
||||||
|
update();
|
||||||
|
}
|
||||||
|
|
||||||
|
void GraphItem::setScale(qreal sx, qreal sy)
|
||||||
|
{
|
||||||
|
if (_sx == sx && _sy == sy)
|
||||||
|
return;
|
||||||
|
|
||||||
|
prepareGeometryChange();
|
||||||
|
|
||||||
|
_sx = sx; _sy = sy;
|
||||||
|
updatePath();
|
||||||
|
}
|
||||||
|
|
||||||
|
void GraphItem::updatePath()
|
||||||
|
{
|
||||||
|
_path = QPainterPath();
|
||||||
|
|
||||||
|
if (_type == Time && !_time)
|
||||||
|
return;
|
||||||
|
|
||||||
|
_path.moveTo(_graph.first().x(_type) * _sx, -_graph.first().y() * _sy);
|
||||||
|
for (int i = 1; i < _graph.size(); i++)
|
||||||
|
_path.lineTo(_graph.at(i).x(_type) * _sx, -_graph.at(i).y() * _sy);
|
||||||
|
}
|
||||||
|
|
||||||
|
void GraphItem::updateBounds()
|
||||||
|
{
|
||||||
|
if (_type == Time && !_time) {
|
||||||
|
_bounds = QRectF();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
qreal bottom, top, left, right;
|
||||||
|
|
||||||
|
QPointF p = QPointF(_graph.first().x(_type), -_graph.first().y());
|
||||||
|
bottom = p.y(); top = p.y(); left = p.x(); right = p.x();
|
||||||
|
|
||||||
|
for (int i = 1; i < _graph.size(); i++) {
|
||||||
|
p = QPointF(_graph.at(i).x(_type), -_graph.at(i).y());
|
||||||
|
bottom = qMax(bottom, p.y()); top = qMin(top, p.y());
|
||||||
|
right = qMax(right, p.x()); left = qMin(left, p.x());
|
||||||
|
}
|
||||||
|
|
||||||
|
_bounds = QRectF(QPointF(left, top), QPointF(right, bottom));
|
||||||
|
}
|
54
src/graphitem.h
Normal file
54
src/graphitem.h
Normal file
@ -0,0 +1,54 @@
|
|||||||
|
#ifndef GRAPHITEM_H
|
||||||
|
#define GRAPHITEM_H
|
||||||
|
|
||||||
|
#include <QGraphicsObject>
|
||||||
|
#include <QPen>
|
||||||
|
#include "graph.h"
|
||||||
|
|
||||||
|
class GraphItem : public QGraphicsObject
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
|
||||||
|
public:
|
||||||
|
GraphItem(const Graph &graph, QGraphicsItem *parent = 0);
|
||||||
|
|
||||||
|
QRectF boundingRect() const
|
||||||
|
{return _path.boundingRect();}
|
||||||
|
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option,
|
||||||
|
QWidget *widget);
|
||||||
|
|
||||||
|
const QRectF &bounds() const {return _bounds;}
|
||||||
|
void setScale(qreal sx, qreal sy);
|
||||||
|
|
||||||
|
void setGraphType(GraphType type);
|
||||||
|
int id() const {return _id;}
|
||||||
|
void setId(int id) {_id = id;}
|
||||||
|
void setColor(const QColor &color);
|
||||||
|
|
||||||
|
qreal yAtX(qreal x);
|
||||||
|
qreal distanceAtTime(qreal time);
|
||||||
|
|
||||||
|
signals:
|
||||||
|
void sliderPositionChanged(qreal);
|
||||||
|
|
||||||
|
public slots:
|
||||||
|
void emitSliderPositionChanged(qreal);
|
||||||
|
void selected(bool selected);
|
||||||
|
|
||||||
|
private:
|
||||||
|
void updatePath();
|
||||||
|
void updateBounds();
|
||||||
|
|
||||||
|
int _id;
|
||||||
|
QPen _pen;
|
||||||
|
|
||||||
|
Graph _graph;
|
||||||
|
GraphType _type;
|
||||||
|
bool _time;
|
||||||
|
|
||||||
|
QPainterPath _path;
|
||||||
|
QRectF _bounds;
|
||||||
|
qreal _sx, _sy;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // GRAPHITEM_H
|
@ -1,10 +1,12 @@
|
|||||||
#ifndef GRAPHTAB_H
|
#ifndef GRAPHTAB_H
|
||||||
#define GRAPHTAB_H
|
#define GRAPHTAB_H
|
||||||
|
|
||||||
|
#include <QList>
|
||||||
#include "graphview.h"
|
#include "graphview.h"
|
||||||
#include "units.h"
|
#include "units.h"
|
||||||
|
|
||||||
class GPX;
|
class GPX;
|
||||||
|
class PathItem;
|
||||||
|
|
||||||
class GraphTab : public GraphView
|
class GraphTab : public GraphView
|
||||||
{
|
{
|
||||||
@ -15,9 +17,11 @@ public:
|
|||||||
{setFrameShape(QFrame::NoFrame);}
|
{setFrameShape(QFrame::NoFrame);}
|
||||||
|
|
||||||
virtual QString label() const = 0;
|
virtual QString label() const = 0;
|
||||||
virtual void loadGPX(const GPX &gpx) = 0;
|
virtual void loadGPX(const GPX &gpx, const QList<PathItem *> &paths) = 0;
|
||||||
virtual void clear() = 0;
|
virtual void clear() = 0;
|
||||||
virtual void setUnits(enum Units units) = 0;
|
virtual void setUnits(enum Units units) = 0;
|
||||||
|
virtual void showTracks(bool show) = 0;
|
||||||
|
virtual void showRoutes(bool show) = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // GRAPHTAB_H
|
#endif // GRAPHTAB_H
|
||||||
|
@ -1,4 +1,3 @@
|
|||||||
#include <QGraphicsView>
|
|
||||||
#include <QGraphicsSceneMouseEvent>
|
#include <QGraphicsSceneMouseEvent>
|
||||||
#include <QEvent>
|
#include <QEvent>
|
||||||
#include <QPaintEngine>
|
#include <QPaintEngine>
|
||||||
@ -8,11 +7,15 @@
|
|||||||
#include "slideritem.h"
|
#include "slideritem.h"
|
||||||
#include "sliderinfoitem.h"
|
#include "sliderinfoitem.h"
|
||||||
#include "infoitem.h"
|
#include "infoitem.h"
|
||||||
|
#include "graph.h"
|
||||||
|
#include "graphitem.h"
|
||||||
|
#include "pathitem.h"
|
||||||
#include "graphview.h"
|
#include "graphview.h"
|
||||||
|
|
||||||
|
|
||||||
#define MARGIN 10.0
|
#define MARGIN 10.0
|
||||||
|
|
||||||
|
|
||||||
void Scene::mousePressEvent(QGraphicsSceneMouseEvent *e)
|
void Scene::mousePressEvent(QGraphicsSceneMouseEvent *e)
|
||||||
{
|
{
|
||||||
if (e->button() == Qt::LeftButton)
|
if (e->button() == Qt::LeftButton)
|
||||||
@ -32,21 +35,20 @@ GraphView::GraphView(QWidget *parent)
|
|||||||
setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
|
setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
|
||||||
|
|
||||||
_xAxis = new AxisItem(AxisItem::X);
|
_xAxis = new AxisItem(AxisItem::X);
|
||||||
|
_xAxis->setZValue(1.0);
|
||||||
_yAxis = new AxisItem(AxisItem::Y);
|
_yAxis = new AxisItem(AxisItem::Y);
|
||||||
|
_yAxis->setZValue(1.0);
|
||||||
_slider = new SliderItem();
|
_slider = new SliderItem();
|
||||||
_slider->setZValue(2.0);
|
_slider->setZValue(2.0);
|
||||||
|
_sliderInfo = new SliderInfoItem(_slider);
|
||||||
|
_sliderInfo->setZValue(2.0);
|
||||||
|
_info = new InfoItem();
|
||||||
|
|
||||||
connect(_slider, SIGNAL(positionChanged(const QPointF&)), this,
|
connect(_slider, SIGNAL(positionChanged(const QPointF&)), this,
|
||||||
SLOT(emitSliderPositionChanged(const QPointF&)));
|
SLOT(emitSliderPositionChanged(const QPointF&)));
|
||||||
connect(_scene, SIGNAL(mouseClicked(const QPointF&)), this,
|
connect(_scene, SIGNAL(mouseClicked(const QPointF&)), this,
|
||||||
SLOT(newSliderPosition(const QPointF&)));
|
SLOT(newSliderPosition(const QPointF&)));
|
||||||
|
|
||||||
_info = new InfoItem();
|
|
||||||
|
|
||||||
_sliderInfo = new SliderInfoItem(_slider);
|
|
||||||
_sliderInfo->setZValue(2.0);
|
|
||||||
|
|
||||||
_xScale = 1;
|
_xScale = 1;
|
||||||
_yScale = 1;
|
_yScale = 1;
|
||||||
_yOffset = 0;
|
_yOffset = 0;
|
||||||
@ -55,6 +57,12 @@ GraphView::GraphView(QWidget *parent)
|
|||||||
_minYRange = 0.01;
|
_minYRange = 0.01;
|
||||||
|
|
||||||
_sliderPos = 0;
|
_sliderPos = 0;
|
||||||
|
|
||||||
|
_units = Metric;
|
||||||
|
_graphType = Distance;
|
||||||
|
|
||||||
|
setGraphType(_graphType);
|
||||||
|
setUnits(_units);
|
||||||
}
|
}
|
||||||
|
|
||||||
GraphView::~GraphView()
|
GraphView::~GraphView()
|
||||||
@ -63,24 +71,14 @@ GraphView::~GraphView()
|
|||||||
delete _xAxis;
|
delete _xAxis;
|
||||||
if (_yAxis->scene() != _scene)
|
if (_yAxis->scene() != _scene)
|
||||||
delete _yAxis;
|
delete _yAxis;
|
||||||
|
|
||||||
if (_slider->scene() != _scene)
|
if (_slider->scene() != _scene)
|
||||||
delete _slider;
|
delete _slider;
|
||||||
|
|
||||||
if (_info->scene() != _scene)
|
if (_info->scene() != _scene)
|
||||||
delete _info;
|
delete _info;
|
||||||
}
|
|
||||||
|
|
||||||
void GraphView::updateBounds(const QPointF &point)
|
for (int i = 0; i < _graphs.count(); i++)
|
||||||
{
|
if (_graphs.at(i)->scene() != _scene)
|
||||||
if (point.x() < _bounds.left())
|
delete _graphs[i];
|
||||||
_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());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void GraphView::createXLabel()
|
void GraphView::createXLabel()
|
||||||
@ -93,62 +91,149 @@ void GraphView::createYLabel()
|
|||||||
_yAxis->setLabel(QString("%1 [%2]").arg(_yLabel).arg(_yUnits));
|
_yAxis->setLabel(QString("%1 [%2]").arg(_yLabel).arg(_yUnits));
|
||||||
}
|
}
|
||||||
|
|
||||||
void GraphView::setXLabel(const QString &label)
|
|
||||||
{
|
|
||||||
_xLabel = label;
|
|
||||||
createXLabel();
|
|
||||||
}
|
|
||||||
|
|
||||||
void GraphView::setYLabel(const QString &label)
|
void GraphView::setYLabel(const QString &label)
|
||||||
{
|
{
|
||||||
_yLabel = label;
|
_yLabel = label;
|
||||||
createYLabel();
|
createYLabel();
|
||||||
}
|
}
|
||||||
|
|
||||||
void GraphView::setXUnits(const QString &units)
|
|
||||||
{
|
|
||||||
_xUnits = units;
|
|
||||||
createXLabel();
|
|
||||||
}
|
|
||||||
|
|
||||||
void GraphView::setYUnits(const QString &units)
|
void GraphView::setYUnits(const QString &units)
|
||||||
{
|
{
|
||||||
_yUnits = units;
|
_yUnits = units;
|
||||||
createYLabel();
|
createYLabel();
|
||||||
}
|
}
|
||||||
|
|
||||||
void GraphView::loadData(const QVector<QPointF> &data)
|
void GraphView::setXUnits()
|
||||||
{
|
{
|
||||||
QPainterPath path;
|
if (_graphType == Distance) {
|
||||||
QGraphicsPathItem *pi;
|
if (_units == Metric) {
|
||||||
|
if (bounds().width() < KMINM) {
|
||||||
|
_xUnits = tr("m");
|
||||||
if (data.size() < 2)
|
_xScale = 1;
|
||||||
return;
|
} else {
|
||||||
|
_xUnits = tr("km");
|
||||||
if (!_graphs.size())
|
_xScale = M2KM;
|
||||||
_bounds.moveTo(data.at(0));
|
}
|
||||||
|
} else {
|
||||||
updateBounds(data.at(0));
|
if (bounds().width() < MIINM) {
|
||||||
path.moveTo(data.at(0).x(), -data.at(0).y());
|
_xUnits = tr("ft");
|
||||||
for (int i = 1; i < data.size(); i++) {
|
_xScale = M2FT;
|
||||||
const QPointF &p = data.at(i);
|
} else {
|
||||||
path.lineTo(p.x(), -p.y());
|
_xUnits = tr("mi");
|
||||||
updateBounds(p);
|
_xScale = M2MI;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if (bounds().width() < MININS) {
|
||||||
|
_xUnits = tr("s");
|
||||||
|
_xScale = 1;
|
||||||
|
} else if (bounds().width() < HINS) {
|
||||||
|
_xUnits = tr("min");
|
||||||
|
_xScale = MIN2S;
|
||||||
|
} else {
|
||||||
|
_xUnits = tr("h");
|
||||||
|
_xScale = H2S;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pi = new QGraphicsPathItem(path);
|
createXLabel();
|
||||||
QBrush brush(_palette.color(), Qt::SolidPattern);
|
}
|
||||||
QPen pen(brush, 0);
|
|
||||||
pi->setPen(pen);
|
void GraphView::setUnits(Units units)
|
||||||
_scene->addItem(pi);
|
{
|
||||||
_graphs.append(pi);
|
_units = units;
|
||||||
|
setXUnits();
|
||||||
|
}
|
||||||
|
|
||||||
|
void GraphView::setGraphType(GraphType type)
|
||||||
|
{
|
||||||
|
_graphType = type;
|
||||||
|
_bounds = QRectF();
|
||||||
|
|
||||||
|
for (int i = 0; i < _graphs.count(); i++) {
|
||||||
|
_graphs.at(i)->setGraphType(type);
|
||||||
|
if (_graphs.at(i)->scene() == _scene)
|
||||||
|
_bounds |= _graphs.at(i)->bounds();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (type == Distance)
|
||||||
|
_xLabel = tr("Distance");
|
||||||
|
else
|
||||||
|
_xLabel = tr("Time");
|
||||||
|
setXUnits();
|
||||||
|
|
||||||
|
redraw();
|
||||||
|
}
|
||||||
|
|
||||||
|
void GraphView::loadGraph(const Graph &graph, PathItem *path, int id)
|
||||||
|
{
|
||||||
|
if (graph.size() < 2)
|
||||||
|
return;
|
||||||
|
|
||||||
|
GraphItem *gi = new GraphItem(graph);
|
||||||
|
gi->setGraphType(_graphType);
|
||||||
|
gi->setId(id);
|
||||||
|
gi->setColor(_palette.color());
|
||||||
|
|
||||||
|
connect(this, SIGNAL(sliderPositionChanged(qreal)), gi,
|
||||||
|
SLOT(emitSliderPositionChanged(qreal)));
|
||||||
|
connect(gi, SIGNAL(sliderPositionChanged(qreal)), path,
|
||||||
|
SLOT(moveMarker(qreal)));
|
||||||
|
connect(path, SIGNAL(selected(bool)), gi, SLOT(selected(bool)));
|
||||||
|
|
||||||
|
_graphs.append(gi);
|
||||||
|
|
||||||
|
if (!_hide.contains(id)) {
|
||||||
|
_visible.append(gi);
|
||||||
|
_scene->addItem(gi);
|
||||||
|
_bounds |= gi->bounds();
|
||||||
|
setXUnits();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
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);
|
||||||
|
_bounds |= gi->bounds();
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void GraphView::redraw()
|
void GraphView::redraw()
|
||||||
{
|
{
|
||||||
if (!_graphs.isEmpty())
|
redraw(viewport()->size() - QSizeF(MARGIN, MARGIN));
|
||||||
redraw(viewport()->size() - QSizeF(MARGIN, MARGIN));
|
}
|
||||||
|
|
||||||
|
QRectF GraphView::bounds() const
|
||||||
|
{
|
||||||
|
QRectF br(_bounds);
|
||||||
|
br.moveTopLeft(QPointF(br.left(), -br.top() - br.height()));
|
||||||
|
return br;
|
||||||
}
|
}
|
||||||
|
|
||||||
void GraphView::redraw(const QSizeF &size)
|
void GraphView::redraw(const QSizeF &size)
|
||||||
@ -156,24 +241,25 @@ void GraphView::redraw(const QSizeF &size)
|
|||||||
QRectF r;
|
QRectF r;
|
||||||
QSizeF mx, my;
|
QSizeF mx, my;
|
||||||
RangeF rx, ry;
|
RangeF rx, ry;
|
||||||
QTransform transform;
|
qreal sx, sy;
|
||||||
qreal xs, ys;
|
|
||||||
|
|
||||||
|
|
||||||
if (_xAxis->scene() == _scene)
|
if (_visible.isEmpty() || _bounds.isNull()) {
|
||||||
_scene->removeItem(_xAxis);
|
removeItem(_xAxis);
|
||||||
if (_yAxis->scene() == _scene)
|
removeItem(_yAxis);
|
||||||
_scene->removeItem(_yAxis);
|
removeItem(_slider);
|
||||||
if (_slider->scene() == _scene)
|
removeItem(_info);
|
||||||
_scene->removeItem(_slider);
|
_scene->setSceneRect(QRectF());
|
||||||
if (_info->scene() == _scene)
|
return;
|
||||||
_scene->removeItem(_info);
|
}
|
||||||
|
|
||||||
for (int i = 0; i < _graphs.size(); i++)
|
addItem(_xAxis);
|
||||||
_graphs.at(i)->resetTransform();
|
addItem(_yAxis);
|
||||||
|
addItem(_slider);
|
||||||
|
addItem(_info);
|
||||||
|
|
||||||
rx = RangeF(_bounds.left() * _xScale, _bounds.right() * _xScale);
|
rx = RangeF(bounds().left() * _xScale, bounds().right() * _xScale);
|
||||||
ry = RangeF(_bounds.top() * _yScale + _yOffset, _bounds.bottom() * _yScale
|
ry = RangeF(bounds().top() * _yScale + _yOffset, bounds().bottom() * _yScale
|
||||||
+ _yOffset);
|
+ _yOffset);
|
||||||
if (ry.size() < _minYRange)
|
if (ry.size() < _minYRange)
|
||||||
ry.resize(_minYRange);
|
ry.resize(_minYRange);
|
||||||
@ -183,52 +269,44 @@ void GraphView::redraw(const QSizeF &size)
|
|||||||
mx = _xAxis->margin();
|
mx = _xAxis->margin();
|
||||||
my = _yAxis->margin();
|
my = _yAxis->margin();
|
||||||
|
|
||||||
r = _scene->itemsBoundingRect();
|
r = _bounds;
|
||||||
if (r.height() < _minYRange)
|
if (r.height() < _minYRange)
|
||||||
r.adjust(0, -(_minYRange/2 - r.height()/2), 0,
|
r.adjust(0, -(_minYRange/2 - r.height()/2), 0,
|
||||||
_minYRange/2 - r.height()/2);
|
_minYRange/2 - r.height()/2);
|
||||||
|
|
||||||
xs = (size.width() - (my.width() + mx.width())) / r.width();
|
sx = (size.width() - (my.width() + mx.width())) / r.width();
|
||||||
ys = (size.height() - (mx.height() + my.height())
|
sy = (size.height() - (mx.height() + my.height())
|
||||||
- _info->boundingRect().height()) / r.height();
|
- _info->boundingRect().height()) / r.height();
|
||||||
transform.scale(xs, ys);
|
|
||||||
|
|
||||||
for (int i = 0; i < _graphs.size(); i++)
|
for (int i = 0; i < _visible.size(); i++)
|
||||||
_graphs.at(i)->setTransform(transform);
|
_visible.at(i)->setScale(sx, sy);
|
||||||
|
|
||||||
r = _scene->itemsBoundingRect();
|
QPointF p(r.left() * sx, r.top() * sy);
|
||||||
if (r.height() < _minYRange * ys)
|
QSizeF s(r.width() * sx, r.height() * sy);
|
||||||
r.adjust(0, -(_minYRange/2 * ys - r.height()/2), 0,
|
r = QRectF(p, s);
|
||||||
(_minYRange/2) * ys - r.height()/2);
|
if (r.height() < _minYRange * sy)
|
||||||
|
r.adjust(0, -(_minYRange/2 * sy - r.height()/2), 0,
|
||||||
|
(_minYRange/2) * sy - r.height()/2);
|
||||||
|
|
||||||
_xAxis->setSize(r.width());
|
_xAxis->setSize(r.width());
|
||||||
_yAxis->setSize(r.height());
|
_yAxis->setSize(r.height());
|
||||||
_xAxis->setPos(r.bottomLeft());
|
_xAxis->setPos(r.bottomLeft());
|
||||||
_yAxis->setPos(r.bottomLeft());
|
_yAxis->setPos(r.bottomLeft());
|
||||||
_scene->addItem(_xAxis);
|
|
||||||
_scene->addItem(_yAxis);
|
|
||||||
|
|
||||||
_slider->setArea(r);
|
_slider->setArea(r);
|
||||||
if (_sliderPos > _bounds.right() || _sliderPos < _bounds.left())
|
updateSliderPosition();
|
||||||
_slider->setVisible(false);
|
|
||||||
_slider->setPos((_sliderPos / _bounds.width()) * _slider->area().width(),
|
|
||||||
r.bottom());
|
|
||||||
_scene->addItem(_slider);
|
|
||||||
|
|
||||||
updateSliderInfo();
|
r |= _xAxis->sceneBoundingRect();
|
||||||
|
r |= _yAxis->sceneBoundingRect();
|
||||||
r = _scene->itemsBoundingRect();
|
|
||||||
_info->setPos(r.topLeft() + QPointF(r.width()/2
|
_info->setPos(r.topLeft() + QPointF(r.width()/2
|
||||||
- _info->boundingRect().width()/2, -_info->boundingRect().height()));
|
- _info->boundingRect().width()/2, -_info->boundingRect().height()));
|
||||||
_scene->addItem(_info);
|
|
||||||
|
|
||||||
_scene->setSceneRect(_scene->itemsBoundingRect());
|
_scene->setSceneRect(_scene->itemsBoundingRect());
|
||||||
}
|
}
|
||||||
|
|
||||||
void GraphView::resizeEvent(QResizeEvent *)
|
void GraphView::resizeEvent(QResizeEvent *)
|
||||||
{
|
{
|
||||||
if (!_graphs.empty())
|
redraw();
|
||||||
redraw();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void GraphView::plot(QPainter *painter, const QRectF &target)
|
void GraphView::plot(QPainter *painter, const QRectF &target)
|
||||||
@ -249,19 +327,14 @@ void GraphView::plot(QPainter *painter, const QRectF &target)
|
|||||||
|
|
||||||
void GraphView::clear()
|
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();
|
_slider->clear();
|
||||||
_info->clear();
|
_info->clear();
|
||||||
_scene->clear();
|
|
||||||
|
for (int i = 0; i < _graphs.count(); i++)
|
||||||
|
delete _graphs[i];
|
||||||
|
|
||||||
_graphs.clear();
|
_graphs.clear();
|
||||||
|
_visible.clear();
|
||||||
_palette.reset();
|
_palette.reset();
|
||||||
|
|
||||||
_bounds = QRectF();
|
_bounds = QRectF();
|
||||||
@ -270,54 +343,38 @@ void GraphView::clear()
|
|||||||
_scene->setSceneRect(0, 0, 0, 0);
|
_scene->setSceneRect(0, 0, 0, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
static qreal yAtX(const QPainterPath &path, qreal x)
|
void GraphView::updateSliderPosition()
|
||||||
{
|
{
|
||||||
int low = 0;
|
if (bounds().width() <= 0)
|
||||||
int high = path.elementCount() - 1;
|
return;
|
||||||
int mid = 0;
|
|
||||||
|
|
||||||
Q_ASSERT(high > low);
|
if (_sliderPos <= bounds().right() && _sliderPos >= bounds().left()) {
|
||||||
Q_ASSERT(x >= path.elementAt(low).x && x <= path.elementAt(high).x);
|
_slider->setPos((_sliderPos / bounds().width())
|
||||||
|
* _slider->area().width(), _slider->area().bottom());
|
||||||
while (low <= high) {
|
_slider->setVisible(!_visible.isEmpty());
|
||||||
mid = low + ((high - low) / 2);
|
} else {
|
||||||
const QPainterPath::Element &e = path.elementAt(mid);
|
_slider->setPos(_slider->area().left(), _slider->area().bottom());
|
||||||
if (e.x > x)
|
_slider->setVisible(false);
|
||||||
high = mid - 1;
|
|
||||||
else if (e.x < x)
|
|
||||||
low = mid + 1;
|
|
||||||
else
|
|
||||||
return e.y;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
QLineF l;
|
updateSliderInfo();
|
||||||
if (path.elementAt(mid).x < x)
|
|
||||||
l = QLineF(path.elementAt(mid).x, path.elementAt(mid).y,
|
|
||||||
path.elementAt(mid+1).x, path.elementAt(mid+1).y);
|
|
||||||
else
|
|
||||||
l = QLineF(path.elementAt(mid-1).x, path.elementAt(mid-1).y,
|
|
||||||
path.elementAt(mid).x, path.elementAt(mid).y);
|
|
||||||
|
|
||||||
return l.pointAt((x - l.p1().x()) / (l.p2().x() - l.p1().x())).y();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void GraphView::updateSliderInfo()
|
void GraphView::updateSliderInfo()
|
||||||
{
|
{
|
||||||
_sliderInfo->setVisible(_graphs.size() == 1);
|
_sliderInfo->setVisible(_visible.count() == 1);
|
||||||
|
|
||||||
if (!_sliderInfo->isVisible())
|
if (!_sliderInfo->isVisible())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
const QPainterPath &path = _graphs.at(0)->path();
|
QRectF br(_visible.first()->bounds());
|
||||||
QRectF br = path.boundingRect();
|
|
||||||
if (br.height() < _minYRange)
|
if (br.height() < _minYRange)
|
||||||
br.adjust(0, -(_minYRange/2 - br.height()/2), 0,
|
br.adjust(0, -(_minYRange/2 - br.height()/2), 0,
|
||||||
_minYRange/2 - br.height()/2);
|
_minYRange/2 - br.height()/2);
|
||||||
|
|
||||||
qreal y = yAtX(path, _sliderPos);
|
qreal y = _visible.first()->yAtX(_sliderPos);
|
||||||
qreal r = (y - br.bottom()) / br.height();
|
qreal r = (y - br.bottom()) / br.height();
|
||||||
|
|
||||||
qreal pos = (_sliderPos / _bounds.width()) * _slider->area().width();
|
qreal pos = (_sliderPos / bounds().width()) * _slider->area().width();
|
||||||
SliderInfoItem::Side s = (pos + _sliderInfo->boundingRect().width()
|
SliderInfoItem::Side s = (pos + _sliderInfo->boundingRect().width()
|
||||||
> _slider->area().right()) ? SliderInfoItem::Left : SliderInfoItem::Right;
|
> _slider->area().right()) ? SliderInfoItem::Left : SliderInfoItem::Right;
|
||||||
|
|
||||||
@ -329,37 +386,28 @@ void GraphView::updateSliderInfo()
|
|||||||
|
|
||||||
void GraphView::emitSliderPositionChanged(const QPointF &pos)
|
void GraphView::emitSliderPositionChanged(const QPointF &pos)
|
||||||
{
|
{
|
||||||
if (_graphs.isEmpty())
|
if (_slider->area().width() <= 0)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
_sliderPos = (pos.x() / _slider->area().width()) * _bounds.width();
|
_sliderPos = (pos.x() / _slider->area().width()) * bounds().width();
|
||||||
emit sliderPositionChanged(_sliderPos);
|
updateSliderPosition();
|
||||||
|
|
||||||
updateSliderInfo();
|
emit sliderPositionChanged(_sliderPos);
|
||||||
}
|
}
|
||||||
|
|
||||||
void GraphView::setSliderPosition(qreal pos)
|
void GraphView::setSliderPosition(qreal pos)
|
||||||
{
|
{
|
||||||
_sliderPos = pos;
|
if (_visible.isEmpty())
|
||||||
|
|
||||||
if (_graphs.isEmpty())
|
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (pos > _bounds.right() || pos < _bounds.left())
|
_sliderPos = pos;
|
||||||
_slider->setVisible(false);
|
updateSliderPosition();
|
||||||
else {
|
|
||||||
_slider->setPos((pos / _bounds.width()) * _slider->area().width(), 0);
|
|
||||||
_slider->setVisible(true);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void GraphView::newSliderPosition(const QPointF &pos)
|
void GraphView::newSliderPosition(const QPointF &pos)
|
||||||
{
|
{
|
||||||
if (_slider->area().contains(pos)) {
|
if (_slider->area().contains(pos))
|
||||||
_slider->setPos(pos);
|
_slider->setPos(pos);
|
||||||
_slider->setVisible(true);
|
|
||||||
emitSliderPositionChanged(pos);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void GraphView::addInfo(const QString &key, const QString &value)
|
void GraphView::addInfo(const QString &key, const QString &value)
|
||||||
|
@ -5,14 +5,19 @@
|
|||||||
#include <QGraphicsScene>
|
#include <QGraphicsScene>
|
||||||
#include <QVector>
|
#include <QVector>
|
||||||
#include <QList>
|
#include <QList>
|
||||||
|
#include <QSet>
|
||||||
#include <QPointF>
|
#include <QPointF>
|
||||||
#include "palette.h"
|
#include "palette.h"
|
||||||
|
#include "units.h"
|
||||||
|
#include "graph.h"
|
||||||
|
|
||||||
|
|
||||||
class AxisItem;
|
class AxisItem;
|
||||||
class SliderItem;
|
class SliderItem;
|
||||||
class SliderInfoItem;
|
class SliderInfoItem;
|
||||||
class InfoItem;
|
class InfoItem;
|
||||||
|
class GraphItem;
|
||||||
|
class PathItem;
|
||||||
|
|
||||||
class Scene : public QGraphicsScene
|
class Scene : public QGraphicsScene
|
||||||
{
|
{
|
||||||
@ -34,26 +39,21 @@ public:
|
|||||||
GraphView(QWidget *parent = 0);
|
GraphView(QWidget *parent = 0);
|
||||||
~GraphView();
|
~GraphView();
|
||||||
|
|
||||||
void loadData(const QVector<QPointF> &data);
|
void loadGraph(const Graph &graph, PathItem *path, int id = 0);
|
||||||
|
int count() const {return _graphs.count();}
|
||||||
void redraw();
|
void redraw();
|
||||||
void clear();
|
void clear();
|
||||||
|
|
||||||
int count() const {return _graphs.count();}
|
void showGraph(bool show, int id = 0);
|
||||||
|
void setGraphType(GraphType type);
|
||||||
|
void setUnits(Units units);
|
||||||
|
|
||||||
const QString &xLabel() const {return _xLabel;}
|
|
||||||
const QString &yLabel() const {return _yLabel;}
|
const QString &yLabel() const {return _yLabel;}
|
||||||
const QString &xUnits() const {return _xUnits;}
|
|
||||||
const QString &yUnits() const {return _yUnits;}
|
const QString &yUnits() const {return _yUnits;}
|
||||||
qreal xScale() const {return _xScale;}
|
|
||||||
qreal yScale() const {return _yScale;}
|
qreal yScale() const {return _yScale;}
|
||||||
qreal yOffset() const {return _yOffset;}
|
qreal yOffset() const {return _yOffset;}
|
||||||
|
|
||||||
void setXLabel(const QString &label);
|
|
||||||
void setYLabel(const QString &label);
|
void setYLabel(const QString &label);
|
||||||
void setXUnits(const QString &units);
|
|
||||||
void setYUnits(const QString &units);
|
void setYUnits(const QString &units);
|
||||||
void setXScale(qreal scale) {_xScale = scale;}
|
|
||||||
void setYScale(qreal scale) {_yScale = scale;}
|
void setYScale(qreal scale) {_yScale = scale;}
|
||||||
void setYOffset(qreal offset) {_yOffset = offset;}
|
void setYOffset(qreal offset) {_yOffset = offset;}
|
||||||
|
|
||||||
@ -69,22 +69,25 @@ signals:
|
|||||||
void sliderPositionChanged(qreal);
|
void sliderPositionChanged(qreal);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
const QRectF &bounds() const {return _bounds;}
|
QRectF bounds() const;
|
||||||
void resizeEvent(QResizeEvent *);
|
|
||||||
void redraw(const QSizeF &size);
|
void redraw(const QSizeF &size);
|
||||||
void addInfo(const QString &key, const QString &value);
|
void addInfo(const QString &key, const QString &value);
|
||||||
void clearInfo();
|
void clearInfo();
|
||||||
void skipColor() {_palette.color();}
|
void skipColor() {_palette.color();}
|
||||||
|
void resizeEvent(QResizeEvent *);
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void emitSliderPositionChanged(const QPointF &pos);
|
void emitSliderPositionChanged(const QPointF &pos);
|
||||||
void newSliderPosition(const QPointF &pos);
|
void newSliderPosition(const QPointF &pos);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
void setXUnits();
|
||||||
void createXLabel();
|
void createXLabel();
|
||||||
void createYLabel();
|
void createYLabel();
|
||||||
void updateBounds(const QPointF &point);
|
void updateSliderPosition();
|
||||||
void updateSliderInfo();
|
void updateSliderInfo();
|
||||||
|
void removeItem(QGraphicsItem *item);
|
||||||
|
void addItem(QGraphicsItem *item);
|
||||||
|
|
||||||
qreal _xScale, _yScale;
|
qreal _xScale, _yScale;
|
||||||
qreal _yOffset;
|
qreal _yOffset;
|
||||||
@ -101,9 +104,14 @@ private:
|
|||||||
SliderInfoItem *_sliderInfo;
|
SliderInfoItem *_sliderInfo;
|
||||||
InfoItem *_info;
|
InfoItem *_info;
|
||||||
|
|
||||||
QList<QGraphicsPathItem*> _graphs;
|
QList<GraphItem*> _graphs;
|
||||||
|
QList<GraphItem*> _visible;
|
||||||
|
QSet<int> _hide;
|
||||||
QRectF _bounds;
|
QRectF _bounds;
|
||||||
Palette _palette;
|
Palette _palette;
|
||||||
|
|
||||||
|
Units _units;
|
||||||
|
GraphType _graphType;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // GRAPHVIEW_H
|
#endif // GRAPHVIEW_H
|
||||||
|
564
src/gui.cpp
564
src/gui.cpp
@ -18,6 +18,9 @@
|
|||||||
#include <QLabel>
|
#include <QLabel>
|
||||||
#include <QSettings>
|
#include <QSettings>
|
||||||
#include <QLocale>
|
#include <QLocale>
|
||||||
|
#include <QMimeData>
|
||||||
|
#include <QUrl>
|
||||||
|
#include <QPixmapCache>
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
#include "icons.h"
|
#include "icons.h"
|
||||||
#include "keys.h"
|
#include "keys.h"
|
||||||
@ -29,7 +32,7 @@
|
|||||||
#include "speedgraph.h"
|
#include "speedgraph.h"
|
||||||
#include "heartrategraph.h"
|
#include "heartrategraph.h"
|
||||||
#include "temperaturegraph.h"
|
#include "temperaturegraph.h"
|
||||||
#include "trackview.h"
|
#include "pathview.h"
|
||||||
#include "trackinfo.h"
|
#include "trackinfo.h"
|
||||||
#include "filebrowser.h"
|
#include "filebrowser.h"
|
||||||
#include "cpuarch.h"
|
#include "cpuarch.h"
|
||||||
@ -44,19 +47,19 @@ GUI::GUI(QWidget *parent) : QMainWindow(parent)
|
|||||||
loadMaps();
|
loadMaps();
|
||||||
loadPOIs();
|
loadPOIs();
|
||||||
|
|
||||||
|
createPathView();
|
||||||
|
createGraphTabs();
|
||||||
|
createStatusBar();
|
||||||
createActions();
|
createActions();
|
||||||
createMenus();
|
createMenus();
|
||||||
createToolBars();
|
createToolBars();
|
||||||
createTrackView();
|
|
||||||
createTrackGraphs();
|
|
||||||
createStatusBar();
|
|
||||||
|
|
||||||
_browser = new FileBrowser(this);
|
_browser = new FileBrowser(this);
|
||||||
_browser->setFilter(QStringList("*.gpx"));
|
_browser->setFilter(QStringList("*.gpx"));
|
||||||
|
|
||||||
QVBoxLayout *layout = new QVBoxLayout;
|
QVBoxLayout *layout = new QVBoxLayout;
|
||||||
layout->addWidget(_track);
|
layout->addWidget(_pathView);
|
||||||
layout->addWidget(_trackGraphs);
|
layout->addWidget(_graphTabWidget);
|
||||||
layout->setContentsMargins(0, 0, 0, 0);
|
layout->setContentsMargins(0, 0, 0, 0);
|
||||||
#ifdef Q_OS_WIN32
|
#ifdef Q_OS_WIN32
|
||||||
layout->setSpacing(0);
|
layout->setSpacing(0);
|
||||||
@ -70,14 +73,18 @@ GUI::GUI(QWidget *parent) : QMainWindow(parent)
|
|||||||
setWindowTitle(APP_NAME);
|
setWindowTitle(APP_NAME);
|
||||||
setUnifiedTitleAndToolBarOnMac(true);
|
setUnifiedTitleAndToolBarOnMac(true);
|
||||||
|
|
||||||
_distance = 0;
|
|
||||||
_time = 0;
|
|
||||||
_trackCount = 0;
|
_trackCount = 0;
|
||||||
|
_routeCount = 0;
|
||||||
|
_waypointCount = 0;
|
||||||
|
_trackDistance = 0;
|
||||||
|
_routeDistance = 0;
|
||||||
|
_time = 0;
|
||||||
|
|
||||||
_sliderPos = 0;
|
_sliderPos = 0;
|
||||||
|
|
||||||
updateGraphTabs();
|
updateGraphTabs();
|
||||||
updateTrackView();
|
updateTrackView();
|
||||||
|
updateStatusBarInfo();
|
||||||
|
|
||||||
readSettings();
|
readSettings();
|
||||||
|
|
||||||
@ -86,12 +93,15 @@ GUI::GUI(QWidget *parent) : QMainWindow(parent)
|
|||||||
_exportOrientation = QPrinter::Portrait;
|
_exportOrientation = QPrinter::Portrait;
|
||||||
_exportFileName = QString("%1/export.pdf").arg(QDir::currentPath());
|
_exportFileName = QString("%1/export.pdf").arg(QDir::currentPath());
|
||||||
_exportMargins = MarginsF(5.0, 5.0, 5.0, 5.0);
|
_exportMargins = MarginsF(5.0, 5.0, 5.0, 5.0);
|
||||||
|
|
||||||
|
setAcceptDrops(true);
|
||||||
|
QPixmapCache::setCacheLimit(65536);
|
||||||
}
|
}
|
||||||
|
|
||||||
GUI::~GUI()
|
GUI::~GUI()
|
||||||
{
|
{
|
||||||
for (int i = 0; i < _tabs.size(); i++) {
|
for (int i = 0; i < _tabs.size(); i++) {
|
||||||
if (_trackGraphs->indexOf(_tabs.at(i)) < 0)
|
if (_graphTabWidget->indexOf(_tabs.at(i)) < 0)
|
||||||
delete _tabs.at(i);
|
delete _tabs.at(i);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -110,13 +120,15 @@ void GUI::loadPOIs()
|
|||||||
QDir userDir(USER_POI_DIR);
|
QDir userDir(USER_POI_DIR);
|
||||||
QDir globalDir(GLOBAL_POI_DIR);
|
QDir globalDir(GLOBAL_POI_DIR);
|
||||||
|
|
||||||
|
_poi = new POI(this);
|
||||||
|
|
||||||
if (userDir.exists())
|
if (userDir.exists())
|
||||||
list = userDir.entryInfoList(QStringList(), QDir::Files);
|
list = userDir.entryInfoList(QStringList(), QDir::Files);
|
||||||
else
|
else
|
||||||
list = globalDir.entryInfoList(QStringList(), QDir::Files);
|
list = globalDir.entryInfoList(QStringList(), QDir::Files);
|
||||||
|
|
||||||
for (int i = 0; i < list.size(); ++i)
|
for (int i = 0; i < list.size(); ++i)
|
||||||
_poi.loadFile(list.at(i).absoluteFilePath());
|
_poi->loadFile(list.at(i).absoluteFilePath());
|
||||||
}
|
}
|
||||||
|
|
||||||
void GUI::createMapActions()
|
void GUI::createMapActions()
|
||||||
@ -144,7 +156,7 @@ void GUI::createPOIFilesActions()
|
|||||||
{
|
{
|
||||||
_poiFilesSM = new QSignalMapper(this);
|
_poiFilesSM = new QSignalMapper(this);
|
||||||
|
|
||||||
for (int i = 0; i < _poi.files().count(); i++)
|
for (int i = 0; i < _poi->files().count(); i++)
|
||||||
createPOIFileAction(i);
|
createPOIFileAction(i);
|
||||||
|
|
||||||
connect(_poiFilesSM, SIGNAL(mapped(int)), this, SLOT(poiFileChecked(int)));
|
connect(_poiFilesSM, SIGNAL(mapped(int)), this, SLOT(poiFileChecked(int)));
|
||||||
@ -152,7 +164,7 @@ void GUI::createPOIFilesActions()
|
|||||||
|
|
||||||
QAction *GUI::createPOIFileAction(int index)
|
QAction *GUI::createPOIFileAction(int index)
|
||||||
{
|
{
|
||||||
QAction *a = new QAction(QFileInfo(_poi.files().at(index)).fileName(),
|
QAction *a = new QAction(QFileInfo(_poi->files().at(index)).fileName(),
|
||||||
this);
|
this);
|
||||||
a->setCheckable(true);
|
a->setCheckable(true);
|
||||||
|
|
||||||
@ -166,6 +178,9 @@ QAction *GUI::createPOIFileAction(int index)
|
|||||||
|
|
||||||
void GUI::createActions()
|
void GUI::createActions()
|
||||||
{
|
{
|
||||||
|
QActionGroup *ag;
|
||||||
|
|
||||||
|
|
||||||
// Action Groups
|
// Action Groups
|
||||||
_fileActionGroup = new QActionGroup(this);
|
_fileActionGroup = new QActionGroup(this);
|
||||||
_fileActionGroup->setExclusive(false);
|
_fileActionGroup->setExclusive(false);
|
||||||
@ -189,7 +204,7 @@ void GUI::createActions()
|
|||||||
tr("About GPXSee"), this);
|
tr("About GPXSee"), this);
|
||||||
connect(_aboutAction, SIGNAL(triggered()), this, SLOT(about()));
|
connect(_aboutAction, SIGNAL(triggered()), this, SLOT(about()));
|
||||||
|
|
||||||
// File related actions
|
// File actions
|
||||||
_openFileAction = new QAction(QIcon(QPixmap(OPEN_FILE_ICON)),
|
_openFileAction = new QAction(QIcon(QPixmap(OPEN_FILE_ICON)),
|
||||||
tr("Open"), this);
|
tr("Open"), this);
|
||||||
_openFileAction->setShortcut(OPEN_SHORTCUT);
|
_openFileAction->setShortcut(OPEN_SHORTCUT);
|
||||||
@ -228,13 +243,18 @@ void GUI::createActions()
|
|||||||
connect(_closePOIAction, SIGNAL(triggered()), this, SLOT(closePOIFiles()));
|
connect(_closePOIAction, SIGNAL(triggered()), this, SLOT(closePOIFiles()));
|
||||||
_overlapPOIAction = new QAction(tr("Overlap POIs"), this);
|
_overlapPOIAction = new QAction(tr("Overlap POIs"), this);
|
||||||
_overlapPOIAction->setCheckable(true);
|
_overlapPOIAction->setCheckable(true);
|
||||||
connect(_overlapPOIAction, SIGNAL(triggered(bool)), this,
|
connect(_overlapPOIAction, SIGNAL(triggered(bool)), _pathView,
|
||||||
SLOT(overlapPOIs(bool)));
|
SLOT(setPOIOverlap(bool)));
|
||||||
|
_showPOILabelsAction = new QAction(tr("Show POI labels"), this);
|
||||||
|
_showPOILabelsAction->setCheckable(true);
|
||||||
|
connect(_showPOILabelsAction, SIGNAL(triggered(bool)), _pathView,
|
||||||
|
SLOT(showPOILabels(bool)));
|
||||||
_showPOIAction = new QAction(QIcon(QPixmap(SHOW_POI_ICON)),
|
_showPOIAction = new QAction(QIcon(QPixmap(SHOW_POI_ICON)),
|
||||||
tr("Show POIs"), this);
|
tr("Show POIs"), this);
|
||||||
_showPOIAction->setCheckable(true);
|
_showPOIAction->setCheckable(true);
|
||||||
_showPOIAction->setShortcut(SHOW_POI_SHORTCUT);
|
_showPOIAction->setShortcut(SHOW_POI_SHORTCUT);
|
||||||
connect(_showPOIAction, SIGNAL(triggered(bool)), this, SLOT(showPOI(bool)));
|
connect(_showPOIAction, SIGNAL(triggered(bool)), _pathView,
|
||||||
|
SLOT(showPOI(bool)));
|
||||||
addAction(_showPOIAction);
|
addAction(_showPOIAction);
|
||||||
createPOIFilesActions();
|
createPOIFilesActions();
|
||||||
|
|
||||||
@ -264,18 +284,57 @@ void GUI::createActions()
|
|||||||
addAction(_prevMapAction);
|
addAction(_prevMapAction);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Settings actions
|
// Data actions
|
||||||
_showGraphsAction = new QAction(tr("Show graphs"), this);
|
_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)), _pathView,
|
||||||
|
SLOT(showWaypoints(bool)));
|
||||||
|
_showWaypointLabelsAction = new QAction(tr("Waypoint labels"), this);
|
||||||
|
_showWaypointLabelsAction->setCheckable(true);
|
||||||
|
connect(_showWaypointLabelsAction, SIGNAL(triggered(bool)), _pathView,
|
||||||
|
SLOT(showWaypointLabels(bool)));
|
||||||
|
_showRouteWaypointsAction = new QAction(tr("Route waypoints"), this);
|
||||||
|
_showRouteWaypointsAction->setCheckable(true);
|
||||||
|
connect(_showRouteWaypointsAction, SIGNAL(triggered(bool)), _pathView,
|
||||||
|
SLOT(showRouteWaypoints(bool)));
|
||||||
|
|
||||||
|
// Graph actions
|
||||||
|
_showGraphsAction = new QAction(QIcon(QPixmap(SHOW_GRAPHS_ICON)),
|
||||||
|
tr("Show graphs"), this);
|
||||||
_showGraphsAction->setCheckable(true);
|
_showGraphsAction->setCheckable(true);
|
||||||
_showGraphsAction->setShortcut(SHOW_GRAPHS_SHORTCUT);
|
_showGraphsAction->setShortcut(SHOW_GRAPHS_SHORTCUT);
|
||||||
connect(_showGraphsAction, SIGNAL(triggered(bool)), this,
|
connect(_showGraphsAction, SIGNAL(triggered(bool)), this,
|
||||||
SLOT(showGraphs(bool)));
|
SLOT(showGraphs(bool)));
|
||||||
addAction(_showGraphsAction);
|
addAction(_showGraphsAction);
|
||||||
|
ag = new QActionGroup(this);
|
||||||
|
ag->setExclusive(true);
|
||||||
|
_distanceGraphAction = new QAction(tr("Distance"), this);
|
||||||
|
_distanceGraphAction->setCheckable(true);
|
||||||
|
_distanceGraphAction->setActionGroup(ag);
|
||||||
|
_distanceGraphAction->setShortcut(DISTANCE_GRAPH_SHORTCUT);
|
||||||
|
connect(_distanceGraphAction, SIGNAL(triggered()), this,
|
||||||
|
SLOT(setDistanceGraph()));
|
||||||
|
_timeGraphAction = new QAction(tr("Time"), this);
|
||||||
|
_timeGraphAction->setCheckable(true);
|
||||||
|
_timeGraphAction->setActionGroup(ag);
|
||||||
|
_timeGraphAction->setShortcut(TIME_GRAPH_SHORTCUT);
|
||||||
|
connect(_timeGraphAction, SIGNAL(triggered()), this,
|
||||||
|
SLOT(setTimeGraph()));
|
||||||
|
|
||||||
|
// Settings actions
|
||||||
_showToolbarsAction = new QAction(tr("Show toolbars"), this);
|
_showToolbarsAction = new QAction(tr("Show toolbars"), this);
|
||||||
_showToolbarsAction->setCheckable(true);
|
_showToolbarsAction->setCheckable(true);
|
||||||
connect(_showToolbarsAction, SIGNAL(triggered(bool)), this,
|
connect(_showToolbarsAction, SIGNAL(triggered(bool)), this,
|
||||||
SLOT(showToolbars(bool)));
|
SLOT(showToolbars(bool)));
|
||||||
QActionGroup *ag = new QActionGroup(this);
|
ag = new QActionGroup(this);
|
||||||
ag->setExclusive(true);
|
ag->setExclusive(true);
|
||||||
_metricUnitsAction = new QAction(tr("Metric"), this);
|
_metricUnitsAction = new QAction(tr("Metric"), this);
|
||||||
_metricUnitsAction->setCheckable(true);
|
_metricUnitsAction->setCheckable(true);
|
||||||
@ -314,53 +373,68 @@ void GUI::createActions()
|
|||||||
|
|
||||||
void GUI::createMenus()
|
void GUI::createMenus()
|
||||||
{
|
{
|
||||||
_fileMenu = menuBar()->addMenu(tr("File"));
|
QMenu *fileMenu = menuBar()->addMenu(tr("File"));
|
||||||
_fileMenu->addAction(_openFileAction);
|
fileMenu->addAction(_openFileAction);
|
||||||
_fileMenu->addSeparator();
|
fileMenu->addSeparator();
|
||||||
_fileMenu->addAction(_printFileAction);
|
fileMenu->addAction(_printFileAction);
|
||||||
_fileMenu->addAction(_exportFileAction);
|
fileMenu->addAction(_exportFileAction);
|
||||||
_fileMenu->addSeparator();
|
fileMenu->addSeparator();
|
||||||
_fileMenu->addAction(_reloadFileAction);
|
fileMenu->addAction(_reloadFileAction);
|
||||||
_fileMenu->addSeparator();
|
fileMenu->addSeparator();
|
||||||
_fileMenu->addAction(_closeFileAction);
|
fileMenu->addAction(_closeFileAction);
|
||||||
#ifndef Q_OS_MAC
|
#ifndef Q_OS_MAC
|
||||||
_fileMenu->addSeparator();
|
fileMenu->addSeparator();
|
||||||
_fileMenu->addAction(_exitAction);
|
fileMenu->addAction(_exitAction);
|
||||||
#endif // Q_OS_MAC
|
#endif // Q_OS_MAC
|
||||||
|
|
||||||
_mapMenu = menuBar()->addMenu(tr("Map"));
|
QMenu *mapMenu = menuBar()->addMenu(tr("Map"));
|
||||||
_mapMenu->addActions(_mapActions);
|
mapMenu->addActions(_mapActions);
|
||||||
_mapMenu->addSeparator();
|
mapMenu->addSeparator();
|
||||||
_mapMenu->addAction(_clearMapCacheAction);
|
mapMenu->addAction(_clearMapCacheAction);
|
||||||
_mapMenu->addSeparator();
|
mapMenu->addSeparator();
|
||||||
_mapMenu->addAction(_showMapAction);
|
mapMenu->addAction(_showMapAction);
|
||||||
|
|
||||||
_poiMenu = menuBar()->addMenu(tr("POI"));
|
QMenu *graphMenu = menuBar()->addMenu(tr("Graph"));
|
||||||
_poiFilesMenu = _poiMenu->addMenu(tr("POI files"));
|
graphMenu->addAction(_distanceGraphAction);
|
||||||
|
graphMenu->addAction(_timeGraphAction);
|
||||||
|
graphMenu->addSeparator();
|
||||||
|
graphMenu->addAction(_showGraphsAction);
|
||||||
|
|
||||||
|
QMenu *poiMenu = menuBar()->addMenu(tr("POI"));
|
||||||
|
_poiFilesMenu = poiMenu->addMenu(tr("POI files"));
|
||||||
_poiFilesMenu->addActions(_poiFilesActions);
|
_poiFilesMenu->addActions(_poiFilesActions);
|
||||||
_poiMenu->addSeparator();
|
poiMenu->addSeparator();
|
||||||
_poiMenu->addAction(_openPOIAction);
|
poiMenu->addAction(_openPOIAction);
|
||||||
_poiMenu->addAction(_closePOIAction);
|
poiMenu->addAction(_closePOIAction);
|
||||||
_poiMenu->addSeparator();
|
poiMenu->addSeparator();
|
||||||
_poiMenu->addAction(_overlapPOIAction);
|
poiMenu->addAction(_showPOILabelsAction);
|
||||||
_poiMenu->addSeparator();
|
poiMenu->addAction(_overlapPOIAction);
|
||||||
_poiMenu->addAction(_showPOIAction);
|
poiMenu->addSeparator();
|
||||||
|
poiMenu->addAction(_showPOIAction);
|
||||||
|
|
||||||
_settingsMenu = menuBar()->addMenu(tr("Settings"));
|
QMenu *dataMenu = menuBar()->addMenu(tr("Data"));
|
||||||
_unitsMenu = _settingsMenu->addMenu(tr("Units"));
|
QMenu *displayMenu = dataMenu->addMenu(tr("Display"));
|
||||||
_unitsMenu->addAction(_metricUnitsAction);
|
displayMenu->addAction(_showWaypointLabelsAction);
|
||||||
_unitsMenu->addAction(_imperialUnitsAction);
|
displayMenu->addAction(_showRouteWaypointsAction);
|
||||||
_settingsMenu->addSeparator();
|
dataMenu->addSeparator();
|
||||||
_settingsMenu->addAction(_showToolbarsAction);
|
dataMenu->addAction(_showTracksAction);
|
||||||
_settingsMenu->addAction(_showGraphsAction);
|
dataMenu->addAction(_showRoutesAction);
|
||||||
_settingsMenu->addSeparator();
|
dataMenu->addAction(_showWaypointsAction);
|
||||||
_settingsMenu->addAction(_fullscreenAction);
|
|
||||||
|
|
||||||
_helpMenu = menuBar()->addMenu(tr("Help"));
|
QMenu *settingsMenu = menuBar()->addMenu(tr("Settings"));
|
||||||
_helpMenu->addAction(_dataSourcesAction);
|
QMenu *unitsMenu = settingsMenu->addMenu(tr("Units"));
|
||||||
_helpMenu->addAction(_keysAction);
|
unitsMenu->addAction(_metricUnitsAction);
|
||||||
_helpMenu->addSeparator();
|
unitsMenu->addAction(_imperialUnitsAction);
|
||||||
_helpMenu->addAction(_aboutAction);
|
settingsMenu->addSeparator();
|
||||||
|
settingsMenu->addAction(_showToolbarsAction);
|
||||||
|
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()
|
void GUI::createToolBars()
|
||||||
@ -378,6 +452,7 @@ void GUI::createToolBars()
|
|||||||
_showToolBar = addToolBar(tr("Show"));
|
_showToolBar = addToolBar(tr("Show"));
|
||||||
_showToolBar->addAction(_showPOIAction);
|
_showToolBar->addAction(_showPOIAction);
|
||||||
_showToolBar->addAction(_showMapAction);
|
_showToolBar->addAction(_showMapAction);
|
||||||
|
_showToolBar->addAction(_showGraphsAction);
|
||||||
|
|
||||||
_navigationToolBar = addToolBar(tr("Navigation"));
|
_navigationToolBar = addToolBar(tr("Navigation"));
|
||||||
_navigationToolBar->addAction(_firstAction);
|
_navigationToolBar->addAction(_firstAction);
|
||||||
@ -386,25 +461,27 @@ void GUI::createToolBars()
|
|||||||
_navigationToolBar->addAction(_lastAction);
|
_navigationToolBar->addAction(_lastAction);
|
||||||
}
|
}
|
||||||
|
|
||||||
void GUI::createTrackView()
|
void GUI::createPathView()
|
||||||
{
|
{
|
||||||
_track = new TrackView(this);
|
_pathView = new PathView(this);
|
||||||
#ifdef Q_OS_WIN32
|
#ifdef Q_OS_WIN32
|
||||||
_track->setFrameShape(QFrame::NoFrame);
|
_pathView->setFrameShape(QFrame::NoFrame);
|
||||||
#endif // Q_OS_WIN32
|
#endif // Q_OS_WIN32
|
||||||
|
|
||||||
|
_pathView->setPOI(_poi);
|
||||||
}
|
}
|
||||||
|
|
||||||
void GUI::createTrackGraphs()
|
void GUI::createGraphTabs()
|
||||||
{
|
{
|
||||||
_trackGraphs = new QTabWidget;
|
_graphTabWidget = new QTabWidget;
|
||||||
connect(_trackGraphs, SIGNAL(currentChanged(int)), this,
|
connect(_graphTabWidget, SIGNAL(currentChanged(int)), this,
|
||||||
SLOT(graphChanged(int)));
|
SLOT(graphChanged(int)));
|
||||||
|
|
||||||
_trackGraphs->setFixedHeight(200);
|
_graphTabWidget->setFixedHeight(200);
|
||||||
_trackGraphs->setSizePolicy(
|
_graphTabWidget->setSizePolicy(
|
||||||
QSizePolicy(QSizePolicy::Ignored, QSizePolicy::Fixed));
|
QSizePolicy(QSizePolicy::Ignored, QSizePolicy::Fixed));
|
||||||
#ifdef Q_OS_WIN32
|
#ifdef Q_OS_WIN32
|
||||||
_trackGraphs->setDocumentMode(true);
|
_graphTabWidget->setDocumentMode(true);
|
||||||
#endif // Q_OS_WIN32
|
#endif // Q_OS_WIN32
|
||||||
|
|
||||||
_tabs.append(new ElevationGraph);
|
_tabs.append(new ElevationGraph);
|
||||||
@ -429,8 +506,6 @@ void GUI::createStatusBar()
|
|||||||
statusBar()->addPermanentWidget(_distanceLabel, 1);
|
statusBar()->addPermanentWidget(_distanceLabel, 1);
|
||||||
statusBar()->addPermanentWidget(_timeLabel, 1);
|
statusBar()->addPermanentWidget(_timeLabel, 1);
|
||||||
statusBar()->setSizeGripEnabled(false);
|
statusBar()->setSizeGripEnabled(false);
|
||||||
|
|
||||||
updateStatusBarInfo();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void GUI::about()
|
void GUI::about()
|
||||||
@ -545,28 +620,31 @@ bool GUI::openFile(const QString &fileName)
|
|||||||
bool GUI::loadFile(const QString &fileName)
|
bool GUI::loadFile(const QString &fileName)
|
||||||
{
|
{
|
||||||
GPX gpx;
|
GPX gpx;
|
||||||
|
QList<PathItem*> paths;
|
||||||
|
|
||||||
if (gpx.loadFile(fileName)) {
|
if (gpx.loadFile(fileName)) {
|
||||||
|
paths = _pathView->loadGPX(gpx);
|
||||||
for (int i = 0; i < _tabs.count(); i++)
|
for (int i = 0; i < _tabs.count(); i++)
|
||||||
_tabs.at(i)->loadGPX(gpx);
|
_tabs.at(i)->loadGPX(gpx, paths);
|
||||||
updateGraphTabs();
|
updateGraphTabs();
|
||||||
_track->setHidden(false);
|
_pathView->setHidden(false);
|
||||||
_track->loadGPX(gpx);
|
|
||||||
if (_showPOIAction->isChecked())
|
|
||||||
_track->loadPOI(_poi);
|
|
||||||
_track->movePositionMarker(_sliderPos);
|
|
||||||
|
|
||||||
for (int i = 0; i < gpx.trackCount(); i++) {
|
for (int i = 0; i < gpx.tracks().count(); i++) {
|
||||||
_distance += gpx.track(i).distance();
|
_trackDistance += gpx.tracks().at(i)->distance();
|
||||||
_time += gpx.track(i).time();
|
_time += gpx.tracks().at(i)->time();
|
||||||
const QDate &date = gpx.track(i).date().date();
|
const QDate &date = gpx.tracks().at(i)->date().date();
|
||||||
if (_dateRange.first.isNull() || _dateRange.first > date)
|
if (_dateRange.first.isNull() || _dateRange.first > date)
|
||||||
_dateRange.first = date;
|
_dateRange.first = date;
|
||||||
if (_dateRange.second.isNull() || _dateRange.second < date)
|
if (_dateRange.second.isNull() || _dateRange.second < date)
|
||||||
_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;
|
return true;
|
||||||
} else {
|
} else {
|
||||||
@ -584,7 +662,9 @@ bool GUI::loadFile(const QString &fileName)
|
|||||||
void GUI::openPOIFile()
|
void GUI::openPOIFile()
|
||||||
{
|
{
|
||||||
QStringList files = QFileDialog::getOpenFileNames(this, tr("Open POI file"),
|
QStringList files = QFileDialog::getOpenFileNames(this, tr("Open POI file"),
|
||||||
QString(), tr("GPX files (*.gpx);;CSV files (*.csv);;All files (*)"));
|
QString(), tr("All POI files (*.gpx *.csv)") + ";;"
|
||||||
|
+ tr("GPX files (*.gpx)") + ";;" + tr("CSV files (*.csv)") + ";;"
|
||||||
|
+ tr("All files (*)"));
|
||||||
QStringList list = files;
|
QStringList list = files;
|
||||||
|
|
||||||
for (QStringList::Iterator it = list.begin(); it != list.end(); it++)
|
for (QStringList::Iterator it = list.begin(); it != list.end(); it++)
|
||||||
@ -593,21 +673,22 @@ void GUI::openPOIFile()
|
|||||||
|
|
||||||
bool GUI::openPOIFile(const QString &fileName)
|
bool GUI::openPOIFile(const QString &fileName)
|
||||||
{
|
{
|
||||||
if (fileName.isEmpty())
|
if (fileName.isEmpty() || _poi->files().contains(fileName))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
if (!_poi.loadFile(fileName)) {
|
if (!_poi->loadFile(fileName)) {
|
||||||
QString error = tr("Error loading POI file:\n%1")
|
QString error = fileName + QString("\n\n")
|
||||||
.arg(_poi.errorString()) + QString("\n");
|
+ tr("Error loading POI file:\n%1").arg(_poi->errorString())
|
||||||
if (_poi.errorLine())
|
+ QString("\n");
|
||||||
error.append(tr("Line: %1").arg(_poi.errorLine()));
|
if (_poi->errorLine())
|
||||||
|
error.append(tr("Line: %1").arg(_poi->errorLine()));
|
||||||
QMessageBox::critical(this, tr("Error"), error);
|
QMessageBox::critical(this, tr("Error"), error);
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
} else {
|
} else {
|
||||||
|
_pathView->showPOI(true);
|
||||||
_showPOIAction->setChecked(true);
|
_showPOIAction->setChecked(true);
|
||||||
_track->loadPOI(_poi);
|
QAction *action = createPOIFileAction(_poi->files().indexOf(fileName));
|
||||||
QAction *action = createPOIFileAction(_poi.files().indexOf(fileName));
|
|
||||||
action->setChecked(true);
|
action->setChecked(true);
|
||||||
_poiFilesMenu->addAction(action);
|
_poiFilesMenu->addAction(action);
|
||||||
|
|
||||||
@ -623,9 +704,7 @@ void GUI::closePOIFiles()
|
|||||||
delete _poiFilesActions[i];
|
delete _poiFilesActions[i];
|
||||||
_poiFilesActions.clear();
|
_poiFilesActions.clear();
|
||||||
|
|
||||||
_track->clearPOI();
|
_poi->clear();
|
||||||
|
|
||||||
_poi.clear();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void GUI::printFile()
|
void GUI::printFile()
|
||||||
@ -664,7 +743,9 @@ void GUI::plot(QPrinter *printer)
|
|||||||
QPainter p(printer);
|
QPainter p(printer);
|
||||||
TrackInfo info;
|
TrackInfo info;
|
||||||
qreal ih, gh, mh, ratio;
|
qreal ih, gh, mh, ratio;
|
||||||
|
Units units = _imperialUnitsAction->isChecked() ? Imperial : Metric;
|
||||||
|
qreal d = distance();
|
||||||
|
qreal t = time();
|
||||||
|
|
||||||
if (_dateRange.first.isValid()) {
|
if (_dateRange.first.isValid()) {
|
||||||
if (_dateRange.first == _dateRange.second) {
|
if (_dateRange.first == _dateRange.second) {
|
||||||
@ -675,20 +756,20 @@ void GUI::plot(QPrinter *printer)
|
|||||||
info.insert(tr("Date"), QString("%1 - %2")
|
info.insert(tr("Date"), QString("%1 - %2")
|
||||||
.arg(_dateRange.first.toString(format),
|
.arg(_dateRange.first.toString(format),
|
||||||
_dateRange.second.toString(format)));
|
_dateRange.second.toString(format)));
|
||||||
info.insert(tr("Tracks"), QString::number(_trackCount));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (_distance > 0) {
|
|
||||||
if (_imperialUnitsAction->isChecked()) {
|
if (_trackCount > 1)
|
||||||
info.insert(tr("Distance"), QString::number(_distance * M2MI, 'f',
|
info.insert(tr("Tracks"), QString::number(_trackCount));
|
||||||
1) + UNIT_SPACE + tr("mi"));
|
if (_routeCount > 1)
|
||||||
} else {
|
info.insert(tr("Routes"), QString::number(_routeCount));
|
||||||
info.insert(tr("Distance"), QString::number(_distance * M2KM, 'f',
|
if (_waypointCount > 2)
|
||||||
1) + UNIT_SPACE + tr("km"));
|
info.insert(tr("Waypoints"), QString::number(_waypointCount));
|
||||||
}
|
|
||||||
}
|
if (d > 0)
|
||||||
if (_time > 0)
|
info.insert(tr("Distance"), ::distance(d, units));
|
||||||
info.insert(tr("Time"), timeSpan(_time));
|
if (t > 0)
|
||||||
|
info.insert(tr("Time"), ::timeSpan(t));
|
||||||
|
|
||||||
|
|
||||||
ratio = p.paintEngine()->paintDevice()->logicalDpiX() / SCREEN_DPI;
|
ratio = p.paintEngine()->paintDevice()->logicalDpiX() / SCREEN_DPI;
|
||||||
@ -700,30 +781,33 @@ void GUI::plot(QPrinter *printer)
|
|||||||
mh = ih / 2;
|
mh = ih / 2;
|
||||||
info.plot(&p, QRectF(0, 0, printer->width(), ih));
|
info.plot(&p, QRectF(0, 0, printer->width(), ih));
|
||||||
}
|
}
|
||||||
if (_trackGraphs->isVisible()) {
|
if (_graphTabWidget->isVisible()) {
|
||||||
qreal r = (((qreal)(printer)->width()) / (qreal)(printer->height()));
|
qreal r = (((qreal)(printer)->width()) / (qreal)(printer->height()));
|
||||||
gh = (printer->width() > printer->height())
|
gh = (printer->width() > printer->height())
|
||||||
? 0.15 * r * (printer->height() - ih - 2*mh)
|
? 0.15 * r * (printer->height() - ih - 2*mh)
|
||||||
: 0.15 * (printer->height() - ih - 2*mh);
|
: 0.15 * (printer->height() - ih - 2*mh);
|
||||||
gh = qMax(gh, ratio * 150);
|
gh = qMax(gh, ratio * 150);
|
||||||
GraphView *gv = static_cast<GraphView*>(_trackGraphs->currentWidget());
|
GraphTab *gt = static_cast<GraphTab*>(_graphTabWidget->currentWidget());
|
||||||
gv->plot(&p, QRectF(0, printer->height() - gh, printer->width(), gh));
|
gt->plot(&p, QRectF(0, printer->height() - gh, printer->width(), gh));
|
||||||
} else
|
} else
|
||||||
gh = 0;
|
gh = 0;
|
||||||
_track->plot(&p, QRectF(0, ih + mh, printer->width(), printer->height()
|
_pathView->plot(&p, QRectF(0, ih + mh, printer->width(), printer->height()
|
||||||
- (ih + 2*mh + gh)));
|
- (ih + 2*mh + gh)));
|
||||||
}
|
}
|
||||||
|
|
||||||
void GUI::reloadFile()
|
void GUI::reloadFile()
|
||||||
{
|
{
|
||||||
_distance = 0;
|
_trackCount = 0;
|
||||||
|
_routeCount = 0;
|
||||||
|
_waypointCount = 0;
|
||||||
|
_trackDistance = 0;
|
||||||
|
_routeDistance = 0;
|
||||||
_time = 0;
|
_time = 0;
|
||||||
_dateRange = DateRange(QDate(), QDate());
|
_dateRange = DateRange(QDate(), QDate());
|
||||||
_trackCount = 0;
|
|
||||||
|
|
||||||
for (int i = 0; i < _tabs.count(); i++)
|
for (int i = 0; i < _tabs.count(); i++)
|
||||||
_tabs.at(i)->clear();
|
_tabs.at(i)->clear();
|
||||||
_track->clear();
|
_pathView->clear();
|
||||||
|
|
||||||
_sliderPos = 0;
|
_sliderPos = 0;
|
||||||
|
|
||||||
@ -746,16 +830,19 @@ void GUI::reloadFile()
|
|||||||
|
|
||||||
void GUI::closeFiles()
|
void GUI::closeFiles()
|
||||||
{
|
{
|
||||||
_distance = 0;
|
_trackCount = 0;
|
||||||
|
_routeCount = 0;
|
||||||
|
_waypointCount = 0;
|
||||||
|
_trackDistance = 0;
|
||||||
|
_routeDistance = 0;
|
||||||
_time = 0;
|
_time = 0;
|
||||||
_dateRange = DateRange(QDate(), QDate());
|
_dateRange = DateRange(QDate(), QDate());
|
||||||
_trackCount = 0;
|
|
||||||
|
|
||||||
_sliderPos = 0;
|
_sliderPos = 0;
|
||||||
|
|
||||||
for (int i = 0; i < _tabs.count(); i++)
|
for (int i = 0; i < _tabs.count(); i++)
|
||||||
_tabs.at(i)->clear();
|
_tabs.at(i)->clear();
|
||||||
_track->clear();
|
_pathView->clear();
|
||||||
|
|
||||||
_files.clear();
|
_files.clear();
|
||||||
}
|
}
|
||||||
@ -771,30 +858,17 @@ void GUI::closeAll()
|
|||||||
updateTrackView();
|
updateTrackView();
|
||||||
}
|
}
|
||||||
|
|
||||||
void GUI::overlapPOIs(bool checked)
|
|
||||||
{
|
|
||||||
_track->setPOIOverlap(checked);
|
|
||||||
}
|
|
||||||
|
|
||||||
void GUI::showPOI(bool checked)
|
|
||||||
{
|
|
||||||
if (checked)
|
|
||||||
_track->loadPOI(_poi);
|
|
||||||
else
|
|
||||||
_track->clearPOI();
|
|
||||||
}
|
|
||||||
|
|
||||||
void GUI::showMap(bool checked)
|
void GUI::showMap(bool checked)
|
||||||
{
|
{
|
||||||
if (checked)
|
if (checked)
|
||||||
_track->setMap(_currentMap);
|
_pathView->setMap(_currentMap);
|
||||||
else
|
else
|
||||||
_track->setMap(0);
|
_pathView->setMap(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
void GUI::showGraphs(bool checked)
|
void GUI::showGraphs(bool checked)
|
||||||
{
|
{
|
||||||
_trackGraphs->setHidden(!checked);
|
_graphTabWidget->setHidden(!checked);
|
||||||
}
|
}
|
||||||
|
|
||||||
void GUI::showToolbars(bool checked)
|
void GUI::showToolbars(bool checked)
|
||||||
@ -816,7 +890,7 @@ void GUI::showToolbars(bool checked)
|
|||||||
void GUI::showFullscreen(bool checked)
|
void GUI::showFullscreen(bool checked)
|
||||||
{
|
{
|
||||||
if (checked) {
|
if (checked) {
|
||||||
_frameStyle = _track->frameStyle();
|
_frameStyle = _pathView->frameStyle();
|
||||||
_showGraphs = _showGraphsAction->isChecked();
|
_showGraphs = _showGraphsAction->isChecked();
|
||||||
|
|
||||||
statusBar()->hide();
|
statusBar()->hide();
|
||||||
@ -824,7 +898,7 @@ void GUI::showFullscreen(bool checked)
|
|||||||
showToolbars(false);
|
showToolbars(false);
|
||||||
showGraphs(false);
|
showGraphs(false);
|
||||||
_showGraphsAction->setChecked(false);
|
_showGraphsAction->setChecked(false);
|
||||||
_track->setFrameStyle(QFrame::NoFrame);
|
_pathView->setFrameStyle(QFrame::NoFrame);
|
||||||
|
|
||||||
showFullScreen();
|
showFullScreen();
|
||||||
} else {
|
} else {
|
||||||
@ -835,33 +909,59 @@ void GUI::showFullscreen(bool checked)
|
|||||||
_showGraphsAction->setChecked(_showGraphs);
|
_showGraphsAction->setChecked(_showGraphs);
|
||||||
if (_showGraphsAction->isEnabled())
|
if (_showGraphsAction->isEnabled())
|
||||||
showGraphs(_showGraphs);
|
showGraphs(_showGraphs);
|
||||||
_track->setFrameStyle(_frameStyle);
|
_pathView->setFrameStyle(_frameStyle);
|
||||||
|
|
||||||
showNormal();
|
showNormal();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void GUI::showTracks(bool show)
|
||||||
|
{
|
||||||
|
_pathView->showTracks(show);
|
||||||
|
|
||||||
|
for (int i = 0; i < _tabs.size(); i++)
|
||||||
|
_tabs.at(i)->showTracks(show);
|
||||||
|
|
||||||
|
updateStatusBarInfo();
|
||||||
|
}
|
||||||
|
|
||||||
|
void GUI::showRoutes(bool show)
|
||||||
|
{
|
||||||
|
_pathView->showRoutes(show);
|
||||||
|
|
||||||
|
for (int i = 0; i < _tabs.size(); i++)
|
||||||
|
_tabs.at(i)->showRoutes(show);
|
||||||
|
|
||||||
|
updateStatusBarInfo();
|
||||||
|
}
|
||||||
|
|
||||||
void GUI::clearMapCache()
|
void GUI::clearMapCache()
|
||||||
{
|
{
|
||||||
_currentMap->clearCache();
|
_currentMap->clearCache();
|
||||||
_track->redraw();
|
_pathView->redraw();
|
||||||
}
|
}
|
||||||
|
|
||||||
void GUI::updateStatusBarInfo()
|
void GUI::updateStatusBarInfo()
|
||||||
{
|
{
|
||||||
if (_files.count() == 0) {
|
if (_files.count() == 0)
|
||||||
_fileNameLabel->setText(tr("No GPX files loaded"));
|
_fileNameLabel->setText(tr("No GPX files loaded"));
|
||||||
_distanceLabel->clear();
|
else if (_files.count() == 1)
|
||||||
_timeLabel->clear();
|
|
||||||
return;
|
|
||||||
} else if (_files.count() == 1)
|
|
||||||
_fileNameLabel->setText(_files.at(0));
|
_fileNameLabel->setText(_files.at(0));
|
||||||
else
|
else
|
||||||
_fileNameLabel->setText(tr("%1 tracks").arg(_trackCount));
|
_fileNameLabel->setText(tr("%1 files").arg(_files.count()));
|
||||||
|
|
||||||
|
qreal d = distance();
|
||||||
Units units = _imperialUnitsAction->isChecked() ? Imperial : Metric;
|
Units units = _imperialUnitsAction->isChecked() ? Imperial : Metric;
|
||||||
_distanceLabel->setText(distance(_distance, units));
|
if (d > 0)
|
||||||
_timeLabel->setText(timeSpan(_time));
|
_distanceLabel->setText(::distance(distance(), units));
|
||||||
|
else
|
||||||
|
_distanceLabel->clear();
|
||||||
|
|
||||||
|
qreal t = time();
|
||||||
|
if (t > 0)
|
||||||
|
_timeLabel->setText(::timeSpan(time()));
|
||||||
|
else
|
||||||
|
_timeLabel->clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
void GUI::updateWindowTitle()
|
void GUI::updateWindowTitle()
|
||||||
@ -878,7 +978,7 @@ void GUI::mapChanged(int index)
|
|||||||
_currentMap = _maps.at(index);
|
_currentMap = _maps.at(index);
|
||||||
|
|
||||||
if (_showMapAction->isChecked())
|
if (_showMapAction->isChecked())
|
||||||
_track->setMap(_currentMap);
|
_pathView->setMap(_currentMap);
|
||||||
}
|
}
|
||||||
|
|
||||||
void GUI::nextMap()
|
void GUI::nextMap()
|
||||||
@ -901,18 +1001,13 @@ void GUI::prevMap()
|
|||||||
|
|
||||||
void GUI::poiFileChecked(int index)
|
void GUI::poiFileChecked(int index)
|
||||||
{
|
{
|
||||||
_poi.enableFile(_poi.files().at(index),
|
_poi->enableFile(_poi->files().at(index),
|
||||||
_poiFilesActions.at(index)->isChecked());
|
_poiFilesActions.at(index)->isChecked());
|
||||||
|
|
||||||
_track->clearPOI();
|
|
||||||
if (_showPOIAction->isChecked())
|
|
||||||
_track->loadPOI(_poi);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void GUI::sliderPositionChanged(qreal pos)
|
void GUI::sliderPositionChanged(qreal pos)
|
||||||
{
|
{
|
||||||
_sliderPos = pos;
|
_sliderPos = pos;
|
||||||
_track->movePositionMarker(_sliderPos);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void GUI::graphChanged(int index)
|
void GUI::graphChanged(int index)
|
||||||
@ -920,8 +1015,8 @@ void GUI::graphChanged(int index)
|
|||||||
if (index < 0)
|
if (index < 0)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
GraphView *gv = static_cast<GraphView*>(_trackGraphs->widget(index));
|
GraphTab *gt = static_cast<GraphTab*>(_graphTabWidget->widget(index));
|
||||||
gv->setSliderPosition(_sliderPos);
|
gt->setSliderPosition(_sliderPos);
|
||||||
}
|
}
|
||||||
|
|
||||||
void GUI::updateNavigationActions()
|
void GUI::updateNavigationActions()
|
||||||
@ -950,45 +1045,48 @@ void GUI::updateGraphTabs()
|
|||||||
|
|
||||||
for (int i = 0; i < _tabs.size(); i++) {
|
for (int i = 0; i < _tabs.size(); i++) {
|
||||||
tab = _tabs.at(i);
|
tab = _tabs.at(i);
|
||||||
if (!tab->count() && (index = _trackGraphs->indexOf(tab)) >= 0)
|
if (!tab->count() && (index = _graphTabWidget->indexOf(tab)) >= 0)
|
||||||
_trackGraphs->removeTab(index);
|
_graphTabWidget->removeTab(index);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int i = 0; i < _tabs.size(); i++) {
|
for (int i = 0; i < _tabs.size(); i++) {
|
||||||
tab = _tabs.at(i);
|
tab = _tabs.at(i);
|
||||||
if (tab->count() && _trackGraphs->indexOf(tab) < 0)
|
if (tab->count() && _graphTabWidget->indexOf(tab) < 0)
|
||||||
_trackGraphs->insertTab(i, tab, _tabs.at(i)->label());
|
_graphTabWidget->insertTab(i, tab, _tabs.at(i)->label());
|
||||||
}
|
}
|
||||||
|
|
||||||
if (_trackGraphs->count()) {
|
if (_graphTabWidget->count()) {
|
||||||
if (_showGraphsAction->isChecked())
|
if (_showGraphsAction->isChecked())
|
||||||
_trackGraphs->setHidden(false);
|
_graphTabWidget->setHidden(false);
|
||||||
_showGraphsAction->setEnabled(true);
|
_showGraphsAction->setEnabled(true);
|
||||||
} else {
|
} else {
|
||||||
_trackGraphs->setHidden(true);
|
_graphTabWidget->setHidden(true);
|
||||||
_showGraphsAction->setEnabled(false);
|
_showGraphsAction->setEnabled(false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void GUI::updateTrackView()
|
void GUI::updateTrackView()
|
||||||
{
|
{
|
||||||
_track->setHidden(!(_track->trackCount() + _track->waypointCount()));
|
_pathView->setHidden(!(_pathView->trackCount() + _pathView->routeCount()
|
||||||
|
+ _pathView->waypointCount()));
|
||||||
}
|
}
|
||||||
|
|
||||||
void GUI::setMetricUnits()
|
void GUI::setUnits(Units units)
|
||||||
{
|
{
|
||||||
_track->setUnits(Metric);
|
_pathView->setUnits(units);
|
||||||
for (int i = 0; i <_tabs.count(); i++)
|
for (int i = 0; i <_tabs.count(); i++)
|
||||||
_tabs.at(i)->setUnits(Metric);
|
_tabs.at(i)->setUnits(units);
|
||||||
updateStatusBarInfo();
|
updateStatusBarInfo();
|
||||||
}
|
}
|
||||||
|
|
||||||
void GUI::setImperialUnits()
|
void GUI::setGraphType(GraphType type)
|
||||||
{
|
{
|
||||||
_track->setUnits(Imperial);
|
_sliderPos = 0;
|
||||||
for (int i = 0; i <_tabs.count(); i++)
|
|
||||||
_tabs.at(i)->setUnits(Imperial);
|
for (int i = 0; i <_tabs.count(); i++) {
|
||||||
updateStatusBarInfo();
|
_tabs.at(i)->setGraphType(type);
|
||||||
|
_tabs.at(i)->setSliderPosition(0);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void GUI::next()
|
void GUI::next()
|
||||||
@ -1070,6 +1168,28 @@ void GUI::closeEvent(QCloseEvent *event)
|
|||||||
event->accept();
|
event->accept();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void GUI::dragEnterEvent(QDragEnterEvent *event)
|
||||||
|
{
|
||||||
|
if (!event->mimeData()->hasUrls())
|
||||||
|
return;
|
||||||
|
if (event->proposedAction() != Qt::CopyAction)
|
||||||
|
return;
|
||||||
|
|
||||||
|
QList<QUrl> urls = event->mimeData()->urls();
|
||||||
|
for (int i = 0; i < urls.size(); i++)
|
||||||
|
if (!urls.at(i).isLocalFile())
|
||||||
|
return;
|
||||||
|
|
||||||
|
event->acceptProposedAction();
|
||||||
|
}
|
||||||
|
|
||||||
|
void GUI::dropEvent(QDropEvent *event)
|
||||||
|
{
|
||||||
|
QList<QUrl> urls = event->mimeData()->urls();
|
||||||
|
for (int i = 0; i < urls.size(); i++)
|
||||||
|
openFile(urls.at(i).toLocalFile());
|
||||||
|
}
|
||||||
|
|
||||||
void GUI::writeSettings()
|
void GUI::writeSettings()
|
||||||
{
|
{
|
||||||
QSettings settings(APP_NAME, APP_NAME);
|
QSettings settings(APP_NAME, APP_NAME);
|
||||||
@ -1083,7 +1203,6 @@ void GUI::writeSettings()
|
|||||||
settings.setValue(UNITS_SETTING, _imperialUnitsAction->isChecked()
|
settings.setValue(UNITS_SETTING, _imperialUnitsAction->isChecked()
|
||||||
? Imperial : Metric);
|
? Imperial : Metric);
|
||||||
settings.setValue(SHOW_TOOLBARS_SETTING, _showToolbarsAction->isChecked());
|
settings.setValue(SHOW_TOOLBARS_SETTING, _showToolbarsAction->isChecked());
|
||||||
settings.setValue(SHOW_GRAPHS_SETTING, _showGraphsAction->isChecked());
|
|
||||||
settings.endGroup();
|
settings.endGroup();
|
||||||
|
|
||||||
settings.beginGroup(MAP_SETTINGS_GROUP);
|
settings.beginGroup(MAP_SETTINGS_GROUP);
|
||||||
@ -1092,6 +1211,12 @@ void GUI::writeSettings()
|
|||||||
settings.setValue(SHOW_MAP_SETTING, _showMapAction->isChecked());
|
settings.setValue(SHOW_MAP_SETTING, _showMapAction->isChecked());
|
||||||
settings.endGroup();
|
settings.endGroup();
|
||||||
|
|
||||||
|
settings.beginGroup(GRAPH_SETTINGS_GROUP);
|
||||||
|
settings.setValue(SHOW_GRAPHS_SETTING, _showGraphsAction->isChecked());
|
||||||
|
settings.setValue(GRAPH_TYPE_SETTING, _timeGraphAction->isChecked()
|
||||||
|
? Time : Distance);
|
||||||
|
settings.endGroup();
|
||||||
|
|
||||||
settings.beginGroup(POI_SETTINGS_GROUP);
|
settings.beginGroup(POI_SETTINGS_GROUP);
|
||||||
settings.setValue(SHOW_POI_SETTING, _showPOIAction->isChecked());
|
settings.setValue(SHOW_POI_SETTING, _showPOIAction->isChecked());
|
||||||
settings.setValue(OVERLAP_POI_SETTING, _overlapPOIAction->isChecked());
|
settings.setValue(OVERLAP_POI_SETTING, _overlapPOIAction->isChecked());
|
||||||
@ -1101,11 +1226,23 @@ void GUI::writeSettings()
|
|||||||
for (int i = 0, j = 0; i < _poiFilesActions.count(); i++) {
|
for (int i = 0, j = 0; i < _poiFilesActions.count(); i++) {
|
||||||
if (!_poiFilesActions.at(i)->isChecked()) {
|
if (!_poiFilesActions.at(i)->isChecked()) {
|
||||||
settings.setArrayIndex(j++);
|
settings.setArrayIndex(j++);
|
||||||
settings.setValue(DISABLED_POI_FILE_SETTING, _poi.files().at(i));
|
settings.setValue(DISABLED_POI_FILE_SETTING, _poi->files().at(i));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
settings.endArray();
|
settings.endArray();
|
||||||
settings.endGroup();
|
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()
|
void GUI::readSettings()
|
||||||
@ -1125,16 +1262,10 @@ void GUI::readSettings()
|
|||||||
_imperialUnitsAction->setChecked(true);
|
_imperialUnitsAction->setChecked(true);
|
||||||
} else
|
} else
|
||||||
_metricUnitsAction->setChecked(true);
|
_metricUnitsAction->setChecked(true);
|
||||||
if (settings.value(SHOW_TOOLBARS_SETTING, true).toBool() == false) {
|
if (settings.value(SHOW_TOOLBARS_SETTING, true).toBool() == false)
|
||||||
showToolbars(false);
|
showToolbars(false);
|
||||||
_showToolbarsAction->setChecked(false);
|
else
|
||||||
} else
|
|
||||||
_showToolbarsAction->setChecked(true);
|
_showToolbarsAction->setChecked(true);
|
||||||
if (settings.value(SHOW_GRAPHS_SETTING, true).toBool() == false) {
|
|
||||||
showGraphs(false);
|
|
||||||
_showGraphsAction->setChecked(false);
|
|
||||||
} else
|
|
||||||
_showGraphsAction->setChecked(true);
|
|
||||||
settings.endGroup();
|
settings.endGroup();
|
||||||
|
|
||||||
settings.beginGroup(MAP_SETTINGS_GROUP);
|
settings.beginGroup(MAP_SETTINGS_GROUP);
|
||||||
@ -1145,33 +1276,77 @@ void GUI::readSettings()
|
|||||||
_mapActions.at(index)->setChecked(true);
|
_mapActions.at(index)->setChecked(true);
|
||||||
_currentMap = _maps.at(index);
|
_currentMap = _maps.at(index);
|
||||||
if (_showMapAction->isChecked())
|
if (_showMapAction->isChecked())
|
||||||
_track->setMap(_currentMap);
|
_pathView->setMap(_currentMap);
|
||||||
} else
|
} else
|
||||||
_currentMap = 0;
|
_currentMap = 0;
|
||||||
settings.endGroup();
|
settings.endGroup();
|
||||||
|
|
||||||
settings.beginGroup(POI_SETTINGS_GROUP);
|
settings.beginGroup(GRAPH_SETTINGS_GROUP);
|
||||||
if (settings.value(OVERLAP_POI_SETTING, true).toBool() == false) {
|
if (settings.value(SHOW_GRAPHS_SETTING, true).toBool() == false)
|
||||||
_track->setPOIOverlap(false);
|
showGraphs(false);
|
||||||
_overlapPOIAction->setChecked(false);
|
else
|
||||||
|
_showGraphsAction->setChecked(true);
|
||||||
|
if (settings.value(GRAPH_TYPE_SETTING, Distance).toInt() == Time) {
|
||||||
|
setTimeGraph();
|
||||||
|
_timeGraphAction->setChecked(true);
|
||||||
} else
|
} else
|
||||||
|
_distanceGraphAction->setChecked(true);
|
||||||
|
settings.endGroup();
|
||||||
|
|
||||||
|
settings.beginGroup(POI_SETTINGS_GROUP);
|
||||||
|
if (settings.value(OVERLAP_POI_SETTING, true).toBool() == false)
|
||||||
|
_pathView->setPOIOverlap(false);
|
||||||
|
else
|
||||||
_overlapPOIAction->setChecked(true);
|
_overlapPOIAction->setChecked(true);
|
||||||
|
if (settings.value(LABELS_POI_SETTING, true).toBool() == false)
|
||||||
|
_pathView->showPOILabels(false);
|
||||||
|
else
|
||||||
|
_showPOILabelsAction->setChecked(true);
|
||||||
if (settings.value(SHOW_POI_SETTING, false).toBool() == true)
|
if (settings.value(SHOW_POI_SETTING, false).toBool() == true)
|
||||||
_showPOIAction->setChecked(true);
|
_showPOIAction->setChecked(true);
|
||||||
|
else
|
||||||
|
_pathView->showPOI(false);
|
||||||
for (int i = 0; i < _poiFilesActions.count(); i++)
|
for (int i = 0; i < _poiFilesActions.count(); i++)
|
||||||
_poiFilesActions.at(i)->setChecked(true);
|
_poiFilesActions.at(i)->setChecked(true);
|
||||||
int size = settings.beginReadArray(DISABLED_POI_FILE_SETTINGS_PREFIX);
|
int size = settings.beginReadArray(DISABLED_POI_FILE_SETTINGS_PREFIX);
|
||||||
for (int i = 0; i < size; i++) {
|
for (int i = 0; i < size; i++) {
|
||||||
settings.setArrayIndex(i);
|
settings.setArrayIndex(i);
|
||||||
int index = _poi.files().indexOf(settings.value(
|
int index = _poi->files().indexOf(settings.value(
|
||||||
DISABLED_POI_FILE_SETTING).toString());
|
DISABLED_POI_FILE_SETTING).toString());
|
||||||
if (index >= 0) {
|
if (index >= 0) {
|
||||||
_poi.enableFile(_poi.files().at(index), false);
|
_poi->enableFile(_poi->files().at(index), false);
|
||||||
_poiFilesActions.at(index)->setChecked(false);
|
_poiFilesActions.at(index)->setChecked(false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
settings.endArray();
|
settings.endArray();
|
||||||
settings.endGroup();
|
settings.endGroup();
|
||||||
|
|
||||||
|
settings.beginGroup(DATA_SETTINGS_GROUP);
|
||||||
|
if (settings.value(SHOW_TRACKS_SETTING, true).toBool() == false) {
|
||||||
|
_pathView->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) {
|
||||||
|
_pathView->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)
|
||||||
|
_pathView->showWaypoints(false);
|
||||||
|
else
|
||||||
|
_showWaypointsAction->setChecked(true);
|
||||||
|
if (settings.value(SHOW_WAYPOINT_LABELS_SETTING, true).toBool() == false)
|
||||||
|
_pathView->showWaypointLabels(false);
|
||||||
|
else
|
||||||
|
_showWaypointLabelsAction->setChecked(true);
|
||||||
|
if (settings.value(SHOW_ROUTE_WAYPOINTS_SETTING, true).toBool() == false)
|
||||||
|
_pathView->showRouteWaypoints(false);
|
||||||
|
else
|
||||||
|
_showRouteWaypointsAction->setChecked(true);
|
||||||
|
settings.endGroup();
|
||||||
}
|
}
|
||||||
|
|
||||||
int GUI::mapIndex(const QString &name)
|
int GUI::mapIndex(const QString &name)
|
||||||
@ -1182,3 +1357,20 @@ int GUI::mapIndex(const QString &name)
|
|||||||
|
|
||||||
return 0;
|
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;
|
||||||
|
}
|
||||||
|
57
src/gui.h
57
src/gui.h
@ -6,6 +6,8 @@
|
|||||||
#include <QList>
|
#include <QList>
|
||||||
#include <QDate>
|
#include <QDate>
|
||||||
#include <QPrinter>
|
#include <QPrinter>
|
||||||
|
#include "units.h"
|
||||||
|
#include "graph.h"
|
||||||
#include "poi.h"
|
#include "poi.h"
|
||||||
#include "margins.h"
|
#include "margins.h"
|
||||||
|
|
||||||
@ -19,7 +21,7 @@ class QSignalMapper;
|
|||||||
class QPrinter;
|
class QPrinter;
|
||||||
class FileBrowser;
|
class FileBrowser;
|
||||||
class GraphTab;
|
class GraphTab;
|
||||||
class TrackView;
|
class PathView;
|
||||||
class Map;
|
class Map;
|
||||||
|
|
||||||
class GUI : public QMainWindow
|
class GUI : public QMainWindow
|
||||||
@ -43,12 +45,12 @@ private slots:
|
|||||||
void reloadFile();
|
void reloadFile();
|
||||||
void openPOIFile();
|
void openPOIFile();
|
||||||
void closePOIFiles();
|
void closePOIFiles();
|
||||||
void overlapPOIs(bool checked);
|
|
||||||
void showPOI(bool checked);
|
|
||||||
void showMap(bool checked);
|
void showMap(bool checked);
|
||||||
void showGraphs(bool checked);
|
void showGraphs(bool checked);
|
||||||
void showToolbars(bool checked);
|
void showToolbars(bool checked);
|
||||||
void showFullscreen(bool checked);
|
void showFullscreen(bool checked);
|
||||||
|
void showTracks(bool show);
|
||||||
|
void showRoutes(bool show);
|
||||||
void clearMapCache();
|
void clearMapCache();
|
||||||
void nextMap();
|
void nextMap();
|
||||||
void prevMap();
|
void prevMap();
|
||||||
@ -62,8 +64,10 @@ private slots:
|
|||||||
void last();
|
void last();
|
||||||
void first();
|
void first();
|
||||||
|
|
||||||
void setMetricUnits();
|
void setMetricUnits() {setUnits(Metric);}
|
||||||
void setImperialUnits();
|
void setImperialUnits() {setUnits(Imperial);}
|
||||||
|
void setDistanceGraph() {setGraphType(Distance);}
|
||||||
|
void setTimeGraph() {setGraphType(Time);}
|
||||||
|
|
||||||
void sliderPositionChanged(qreal pos);
|
void sliderPositionChanged(qreal pos);
|
||||||
|
|
||||||
@ -82,8 +86,8 @@ private:
|
|||||||
void createMenus();
|
void createMenus();
|
||||||
void createToolBars();
|
void createToolBars();
|
||||||
void createStatusBar();
|
void createStatusBar();
|
||||||
void createTrackView();
|
void createPathView();
|
||||||
void createTrackGraphs();
|
void createGraphTabs();
|
||||||
|
|
||||||
bool openPOIFile(const QString &fileName);
|
bool openPOIFile(const QString &fileName);
|
||||||
bool loadFile(const QString &fileName);
|
bool loadFile(const QString &fileName);
|
||||||
@ -94,28 +98,27 @@ private:
|
|||||||
void updateGraphTabs();
|
void updateGraphTabs();
|
||||||
void updateTrackView();
|
void updateTrackView();
|
||||||
|
|
||||||
void keyPressEvent(QKeyEvent * event);
|
void setUnits(Units units);
|
||||||
void closeEvent(QCloseEvent *event);
|
void setGraphType(GraphType type);
|
||||||
|
|
||||||
|
qreal distance();
|
||||||
|
qreal time();
|
||||||
int mapIndex(const QString &name);
|
int mapIndex(const QString &name);
|
||||||
void readSettings();
|
void readSettings();
|
||||||
void writeSettings();
|
void writeSettings();
|
||||||
|
|
||||||
QMenu *_fileMenu;
|
void keyPressEvent(QKeyEvent *event);
|
||||||
QMenu *_helpMenu;
|
void closeEvent(QCloseEvent *event);
|
||||||
QMenu *_poiMenu;
|
void dragEnterEvent(QDragEnterEvent *event);
|
||||||
QMenu *_mapMenu;
|
void dropEvent(QDropEvent *event);
|
||||||
QMenu *_settingsMenu;
|
|
||||||
QMenu *_unitsMenu;
|
|
||||||
QMenu *_poiFilesMenu;
|
|
||||||
|
|
||||||
QToolBar *_fileToolBar;
|
QToolBar *_fileToolBar;
|
||||||
QToolBar *_showToolBar;
|
QToolBar *_showToolBar;
|
||||||
QToolBar *_navigationToolBar;
|
QToolBar *_navigationToolBar;
|
||||||
QTabWidget *_trackGraphs;
|
QMenu *_poiFilesMenu;
|
||||||
|
|
||||||
QActionGroup *_fileActionGroup;
|
QActionGroup *_fileActionGroup;
|
||||||
QActionGroup *_navigationActionGroup;
|
QActionGroup *_navigationActionGroup;
|
||||||
|
|
||||||
QAction *_exitAction;
|
QAction *_exitAction;
|
||||||
QAction *_keysAction;
|
QAction *_keysAction;
|
||||||
QAction *_dataSourcesAction;
|
QAction *_dataSourcesAction;
|
||||||
@ -130,10 +133,13 @@ private:
|
|||||||
QAction *_closePOIAction;
|
QAction *_closePOIAction;
|
||||||
QAction *_showPOIAction;
|
QAction *_showPOIAction;
|
||||||
QAction *_overlapPOIAction;
|
QAction *_overlapPOIAction;
|
||||||
|
QAction *_showPOILabelsAction;
|
||||||
QAction *_showMapAction;
|
QAction *_showMapAction;
|
||||||
QAction *_fullscreenAction;
|
QAction *_fullscreenAction;
|
||||||
QAction *_clearMapCacheAction;
|
QAction *_clearMapCacheAction;
|
||||||
QAction *_showGraphsAction;
|
QAction *_showGraphsAction;
|
||||||
|
QAction *_distanceGraphAction;
|
||||||
|
QAction *_timeGraphAction;
|
||||||
QAction *_showToolbarsAction;
|
QAction *_showToolbarsAction;
|
||||||
QAction *_nextAction;
|
QAction *_nextAction;
|
||||||
QAction *_prevAction;
|
QAction *_prevAction;
|
||||||
@ -143,6 +149,11 @@ private:
|
|||||||
QAction *_imperialUnitsAction;
|
QAction *_imperialUnitsAction;
|
||||||
QAction *_nextMapAction;
|
QAction *_nextMapAction;
|
||||||
QAction *_prevMapAction;
|
QAction *_prevMapAction;
|
||||||
|
QAction *_showTracksAction;
|
||||||
|
QAction *_showRoutesAction;
|
||||||
|
QAction *_showWaypointsAction;
|
||||||
|
QAction *_showWaypointLabelsAction;
|
||||||
|
QAction *_showRouteWaypointsAction;
|
||||||
QList<QAction*> _mapActions;
|
QList<QAction*> _mapActions;
|
||||||
QList<QAction*> _poiFilesActions;
|
QList<QAction*> _poiFilesActions;
|
||||||
|
|
||||||
@ -152,10 +163,11 @@ private:
|
|||||||
QLabel *_distanceLabel;
|
QLabel *_distanceLabel;
|
||||||
QLabel *_timeLabel;
|
QLabel *_timeLabel;
|
||||||
|
|
||||||
TrackView *_track;
|
PathView *_pathView;
|
||||||
|
QTabWidget *_graphTabWidget;
|
||||||
QList<GraphTab*> _tabs;
|
QList<GraphTab*> _tabs;
|
||||||
|
|
||||||
POI _poi;
|
POI *_poi;
|
||||||
QList<Map*> _maps;
|
QList<Map*> _maps;
|
||||||
|
|
||||||
FileBrowser *_browser;
|
FileBrowser *_browser;
|
||||||
@ -163,7 +175,10 @@ private:
|
|||||||
Map *_currentMap;
|
Map *_currentMap;
|
||||||
|
|
||||||
int _trackCount;
|
int _trackCount;
|
||||||
qreal _distance;
|
int _routeCount;
|
||||||
|
int _waypointCount;
|
||||||
|
qreal _trackDistance;
|
||||||
|
qreal _routeDistance;
|
||||||
qreal _time;
|
qreal _time;
|
||||||
DateRange _dateRange;
|
DateRange _dateRange;
|
||||||
|
|
||||||
|
@ -5,47 +5,52 @@
|
|||||||
HeartRateGraph::HeartRateGraph(QWidget *parent) : GraphTab(parent)
|
HeartRateGraph::HeartRateGraph(QWidget *parent) : GraphTab(parent)
|
||||||
{
|
{
|
||||||
_units = Metric;
|
_units = Metric;
|
||||||
|
_showTracks = true;
|
||||||
|
|
||||||
GraphView::setYUnits(tr("1/min"));
|
GraphView::setYUnits(tr("1/min"));
|
||||||
setXLabel(tr("Distance"));
|
|
||||||
setYLabel(tr("Heart rate"));
|
setYLabel(tr("Heart rate"));
|
||||||
|
|
||||||
setSliderPrecision(0);
|
setSliderPrecision(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
void HeartRateGraph::addInfo()
|
void HeartRateGraph::setInfo()
|
||||||
{
|
{
|
||||||
GraphView::addInfo(tr("Average"), QString::number(avg() * yScale(), 'f', 0)
|
if (_showTracks) {
|
||||||
+ UNIT_SPACE + yUnits());
|
GraphView::addInfo(tr("Average"), QString::number(avg() * yScale(), 'f',
|
||||||
GraphView::addInfo(tr("Maximum"), QString::number(max() * yScale(), 'f', 0)
|
0) + UNIT_SPACE + yUnits());
|
||||||
+ UNIT_SPACE + yUnits());
|
GraphView::addInfo(tr("Maximum"), QString::number(max() * yScale(), 'f',
|
||||||
|
0) + UNIT_SPACE + yUnits());
|
||||||
redraw();
|
} else
|
||||||
|
clearInfo();
|
||||||
}
|
}
|
||||||
|
|
||||||
void HeartRateGraph::loadGPX(const GPX &gpx)
|
void HeartRateGraph::loadGPX(const GPX &gpx, const QList<PathItem *> &paths)
|
||||||
{
|
{
|
||||||
for (int i = 0; i < gpx.trackCount(); i++) {
|
for (int i = 0; i < gpx.tracks().count(); i++) {
|
||||||
QVector<QPointF> data;
|
const Graph &graph = gpx.tracks().at(i)->heartRate();
|
||||||
qreal sum = 0, w = 0;
|
qreal sum = 0, w = 0;
|
||||||
|
|
||||||
gpx.track(i).heartRateGraph(data);
|
if (graph.size() < 2) {
|
||||||
if (data.count() < 2) {
|
|
||||||
skipColor();
|
skipColor();
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int j = 1; j < data.size(); j++) {
|
for (int j = 1; j < graph.size(); j++) {
|
||||||
sum += data.at(j).y() * (data.at(j).x() - data.at(j-1).x());
|
qreal ds = graph.at(j).s() - graph.at(j-1).s();
|
||||||
w += data.at(j).x() - data.at(j-1).x();
|
sum += graph.at(j).y() * ds;
|
||||||
|
w += ds;
|
||||||
}
|
}
|
||||||
_avg.append(QPointF(gpx.track(i).distance(), sum/w));
|
_avg.append(QPointF(gpx.tracks().at(i)->distance(), sum/w));
|
||||||
|
|
||||||
loadData(data);
|
GraphView::loadGraph(graph, paths.at(i));
|
||||||
}
|
}
|
||||||
|
|
||||||
setXUnits();
|
for (int i = 0; i < gpx.routes().count(); i++)
|
||||||
addInfo();
|
skipColor();
|
||||||
|
|
||||||
|
setInfo();
|
||||||
|
|
||||||
|
redraw();
|
||||||
}
|
}
|
||||||
|
|
||||||
qreal HeartRateGraph::avg() const
|
qreal HeartRateGraph::avg() const
|
||||||
@ -68,32 +73,12 @@ void HeartRateGraph::clear()
|
|||||||
GraphView::clear();
|
GraphView::clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
void HeartRateGraph::setXUnits()
|
void HeartRateGraph::showTracks(bool show)
|
||||||
{
|
{
|
||||||
if (_units == Metric) {
|
_showTracks = show;
|
||||||
if (bounds().width() < KMINM) {
|
|
||||||
GraphView::setXUnits(tr("m"));
|
|
||||||
setXScale(1);
|
|
||||||
} else {
|
|
||||||
GraphView::setXUnits(tr("km"));
|
|
||||||
setXScale(M2KM);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
if (bounds().width() < MIINM) {
|
|
||||||
GraphView::setXUnits(tr("ft"));
|
|
||||||
setXScale(M2FT);
|
|
||||||
} else {
|
|
||||||
GraphView::setXUnits(tr("mi"));
|
|
||||||
setXScale(M2MI);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void HeartRateGraph::setUnits(enum Units units)
|
showGraph(show);
|
||||||
{
|
setInfo();
|
||||||
_units = units;
|
|
||||||
setXUnits();
|
|
||||||
|
|
||||||
clearInfo();
|
redraw();
|
||||||
addInfo();
|
|
||||||
}
|
}
|
||||||
|
@ -3,8 +3,6 @@
|
|||||||
|
|
||||||
#include "graphtab.h"
|
#include "graphtab.h"
|
||||||
|
|
||||||
class GPX;
|
|
||||||
|
|
||||||
class HeartRateGraph : public GraphTab
|
class HeartRateGraph : public GraphTab
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
@ -13,18 +11,21 @@ public:
|
|||||||
HeartRateGraph(QWidget *parent = 0);
|
HeartRateGraph(QWidget *parent = 0);
|
||||||
|
|
||||||
QString label() const {return tr("Heart rate");}
|
QString label() const {return tr("Heart rate");}
|
||||||
void loadGPX(const GPX &gpx);
|
void loadGPX(const GPX &gpx, const QList<PathItem *> &paths);
|
||||||
void clear();
|
void clear();
|
||||||
void setUnits(enum Units units);
|
void setUnits(enum Units) {}
|
||||||
|
void showTracks(bool show);
|
||||||
|
void showRoutes(bool show) {Q_UNUSED(show);}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
qreal avg() const;
|
qreal avg() const;
|
||||||
qreal max() const {return bounds().bottom();}
|
qreal max() const {return bounds().bottom();}
|
||||||
void setXUnits();
|
void setInfo();
|
||||||
void addInfo();
|
|
||||||
|
|
||||||
QList<QPointF> _avg;
|
QList<QPointF> _avg;
|
||||||
|
|
||||||
enum Units _units;
|
enum Units _units;
|
||||||
|
bool _showTracks;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // HEARTRATEGRAPH_H
|
#endif // HEARTRATEGRAPH_H
|
||||||
|
@ -8,6 +8,7 @@
|
|||||||
#define CLOSE_FILE_ICON ":/icons/dialog-close.png"
|
#define CLOSE_FILE_ICON ":/icons/dialog-close.png"
|
||||||
#define SHOW_POI_ICON ":/icons/flag.png"
|
#define SHOW_POI_ICON ":/icons/flag.png"
|
||||||
#define SHOW_MAP_ICON ":/icons/applications-internet.png"
|
#define SHOW_MAP_ICON ":/icons/applications-internet.png"
|
||||||
|
#define SHOW_GRAPHS_ICON ":/icons/office-chart-line-stacked.png"
|
||||||
#define QUIT_ICON ":/icons/application-exit.png"
|
#define QUIT_ICON ":/icons/application-exit.png"
|
||||||
#define RELOAD_FILE_ICON ":/icons/view-refresh.png"
|
#define RELOAD_FILE_ICON ":/icons/view-refresh.png"
|
||||||
#define NEXT_FILE_ICON ":/icons/arrow-right.png"
|
#define NEXT_FILE_ICON ":/icons/arrow-right.png"
|
||||||
|
36
src/keys.h
36
src/keys.h
@ -4,26 +4,28 @@
|
|||||||
#include <Qt>
|
#include <Qt>
|
||||||
#include <QKeySequence>
|
#include <QKeySequence>
|
||||||
|
|
||||||
#define NEXT_KEY Qt::Key_Space
|
#define NEXT_KEY Qt::Key_Space
|
||||||
#define PREV_KEY Qt::Key_Backspace
|
#define PREV_KEY Qt::Key_Backspace
|
||||||
#define FIRST_KEY Qt::Key_Home
|
#define FIRST_KEY Qt::Key_Home
|
||||||
#define LAST_KEY Qt::Key_End
|
#define LAST_KEY Qt::Key_End
|
||||||
#define MODIFIER Qt::ShiftModifier
|
#define MODIFIER Qt::ShiftModifier
|
||||||
|
|
||||||
#define QUIT_SHORTCUT QKeySequence::Quit
|
#define QUIT_SHORTCUT QKeySequence::Quit
|
||||||
#define OPEN_SHORTCUT QKeySequence::Open
|
#define OPEN_SHORTCUT QKeySequence::Open
|
||||||
#define CLOSE_SHORTCUT QKeySequence::Close
|
#define CLOSE_SHORTCUT QKeySequence::Close
|
||||||
#define RELOAD_SHORTCUT QKeySequence::Refresh
|
#define RELOAD_SHORTCUT QKeySequence::Refresh
|
||||||
#define EXPORT_SHORTCUT QKeySequence(Qt::CTRL + Qt::Key_E)
|
#define EXPORT_SHORTCUT QKeySequence(Qt::CTRL + Qt::Key_E)
|
||||||
#define SHOW_POI_SHORTCUT QKeySequence(Qt::CTRL + Qt::Key_P)
|
#define SHOW_POI_SHORTCUT QKeySequence(Qt::CTRL + Qt::Key_P)
|
||||||
#define SHOW_MAP_SHORTCUT QKeySequence(Qt::CTRL + Qt::Key_M)
|
#define SHOW_MAP_SHORTCUT QKeySequence(Qt::CTRL + Qt::Key_M)
|
||||||
#define NEXT_MAP_SHORTCUT QKeySequence::Forward
|
#define NEXT_MAP_SHORTCUT QKeySequence::Forward
|
||||||
#define PREV_MAP_SHORTCUT QKeySequence::Back
|
#define PREV_MAP_SHORTCUT QKeySequence::Back
|
||||||
#define SHOW_GRAPHS_SHORTCUT QKeySequence(Qt::CTRL + Qt::Key_G)
|
#define SHOW_GRAPHS_SHORTCUT QKeySequence(Qt::CTRL + Qt::Key_G)
|
||||||
|
#define DISTANCE_GRAPH_SHORTCUT QKeySequence(Qt::CTRL + Qt::Key_D)
|
||||||
|
#define TIME_GRAPH_SHORTCUT QKeySequence(Qt::CTRL + Qt::Key_T)
|
||||||
#ifdef Q_OS_MAC
|
#ifdef Q_OS_MAC
|
||||||
#define FULLSCREEN_SHORTCUT QKeySequence(Qt::META + Qt::CTRL + Qt::Key_F)
|
#define FULLSCREEN_SHORTCUT QKeySequence(Qt::META + Qt::CTRL + Qt::Key_F)
|
||||||
#else // Q_OS_MAC
|
#else // Q_OS_MAC
|
||||||
#define FULLSCREEN_SHORTCUT QKeySequence(Qt::Key_F11)
|
#define FULLSCREEN_SHORTCUT QKeySequence(Qt::Key_F11)
|
||||||
#endif // Q_OS_MAC
|
#endif // Q_OS_MAC
|
||||||
|
|
||||||
#endif // KEYS_H
|
#endif // KEYS_H
|
||||||
|
@ -52,6 +52,30 @@ void Parser::handleWaypointData(DataType type, const QString &value)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Parser::handleRoutepointData(DataType type, const QString &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::handleTrackpointAttributes(const QXmlStreamAttributes &attr)
|
void Parser::handleTrackpointAttributes(const QXmlStreamAttributes &attr)
|
||||||
{
|
{
|
||||||
_track->last().setCoordinates(QPointF(
|
_track->last().setCoordinates(QPointF(
|
||||||
@ -59,6 +83,13 @@ void Parser::handleTrackpointAttributes(const QXmlStreamAttributes &attr)
|
|||||||
attr.value("lat").toLatin1().toDouble()));
|
attr.value("lat").toLatin1().toDouble()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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)
|
void Parser::handleWaypointAttributes(const QXmlStreamAttributes &attr)
|
||||||
{
|
{
|
||||||
_waypoints.last().setCoordinates(QPointF(
|
_waypoints.last().setCoordinates(QPointF(
|
||||||
@ -110,6 +141,24 @@ void Parser::trackpointData()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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()
|
void Parser::trackpoints()
|
||||||
{
|
{
|
||||||
while (_reader.readNextStartElement()) {
|
while (_reader.readNextStartElement()) {
|
||||||
@ -122,6 +171,18 @@ void Parser::trackpoints()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Parser::routepoints()
|
||||||
|
{
|
||||||
|
while (_reader.readNextStartElement()) {
|
||||||
|
if (_reader.name() == "rtept") {
|
||||||
|
_route->append(Waypoint());
|
||||||
|
handleRoutepointAttributes(_reader.attributes());
|
||||||
|
routepointData();
|
||||||
|
} else
|
||||||
|
_reader.skipCurrentElement();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void Parser::track()
|
void Parser::track()
|
||||||
{
|
{
|
||||||
while (_reader.readNextStartElement()) {
|
while (_reader.readNextStartElement()) {
|
||||||
@ -157,6 +218,10 @@ void Parser::gpx()
|
|||||||
_tracks.append(QVector<Trackpoint>());
|
_tracks.append(QVector<Trackpoint>());
|
||||||
_track = &_tracks.back();
|
_track = &_tracks.back();
|
||||||
track();
|
track();
|
||||||
|
} else if (_reader.name() == "rte") {
|
||||||
|
_routes.append(QVector<Waypoint>());
|
||||||
|
_route = &_routes.back();
|
||||||
|
routepoints();
|
||||||
} else if (_reader.name() == "wpt") {
|
} else if (_reader.name() == "wpt") {
|
||||||
_waypoints.append(Waypoint());
|
_waypoints.append(Waypoint());
|
||||||
handleWaypointAttributes(_reader.attributes());
|
handleWaypointAttributes(_reader.attributes());
|
||||||
|
13
src/parser.h
13
src/parser.h
@ -11,8 +11,11 @@
|
|||||||
class Parser
|
class Parser
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
Parser(QList<QVector<Trackpoint> > &tracks, QList<Waypoint> &waypoints)
|
Parser(QList<QVector<Trackpoint> > &tracks,
|
||||||
: _tracks(tracks), _waypoints(waypoints) {_track = 0;}
|
QList<QVector<Waypoint> > &routes, QList<Waypoint> &waypoints)
|
||||||
|
: _tracks(tracks), _routes(routes), _waypoints(waypoints)
|
||||||
|
{_track = 0; _route = 0;}
|
||||||
|
|
||||||
bool loadFile(QIODevice *device);
|
bool loadFile(QIODevice *device);
|
||||||
QString errorString() const {return _reader.errorString();}
|
QString errorString() const {return _reader.errorString();}
|
||||||
int errorLine() const {return _reader.lineNumber();}
|
int errorLine() const {return _reader.lineNumber();}
|
||||||
@ -27,20 +30,26 @@ private:
|
|||||||
void gpx();
|
void gpx();
|
||||||
void track();
|
void track();
|
||||||
void trackpoints();
|
void trackpoints();
|
||||||
|
void routepoints();
|
||||||
void tpExtension();
|
void tpExtension();
|
||||||
void extensions();
|
void extensions();
|
||||||
void trackpointData();
|
void trackpointData();
|
||||||
|
void routepointData();
|
||||||
void waypointData();
|
void waypointData();
|
||||||
|
|
||||||
void handleWaypointAttributes(const QXmlStreamAttributes &attr);
|
void handleWaypointAttributes(const QXmlStreamAttributes &attr);
|
||||||
void handleWaypointData(DataType type, const QString &value);
|
void handleWaypointData(DataType type, const QString &value);
|
||||||
void handleTrackpointAttributes(const QXmlStreamAttributes &attr);
|
void handleTrackpointAttributes(const QXmlStreamAttributes &attr);
|
||||||
void handleTrackpointData(DataType type, const QString &value);
|
void handleTrackpointData(DataType type, const QString &value);
|
||||||
|
void handleRoutepointAttributes(const QXmlStreamAttributes &attr);
|
||||||
|
void handleRoutepointData(DataType type, const QString &value);
|
||||||
|
|
||||||
QXmlStreamReader _reader;
|
QXmlStreamReader _reader;
|
||||||
QList<QVector<Trackpoint> > &_tracks;
|
QList<QVector<Trackpoint> > &_tracks;
|
||||||
|
QList<QVector<Waypoint> > &_routes;
|
||||||
QList<Waypoint> &_waypoints;
|
QList<Waypoint> &_waypoints;
|
||||||
QVector<Trackpoint> *_track;
|
QVector<Trackpoint> *_track;
|
||||||
|
QVector<Waypoint> *_route;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // PARSER_H
|
#endif // PARSER_H
|
||||||
|
104
src/pathitem.cpp
Normal file
104
src/pathitem.cpp
Normal file
@ -0,0 +1,104 @@
|
|||||||
|
#include <QApplication>
|
||||||
|
#include <QCursor>
|
||||||
|
#include <QPainter>
|
||||||
|
#include "tooltip.h"
|
||||||
|
#include "pathitem.h"
|
||||||
|
|
||||||
|
|
||||||
|
#define PATH_WIDTH 3
|
||||||
|
#define HOVER_WIDTH 4
|
||||||
|
|
||||||
|
void PathItem::updateShape()
|
||||||
|
{
|
||||||
|
QPainterPathStroker s;
|
||||||
|
s.setWidth(HOVER_WIDTH * 1.0/scale());
|
||||||
|
_shape = s.createStroke(_path);
|
||||||
|
|
||||||
|
if (qMax(boundingRect().width(), boundingRect().height()) * scale() <= 768)
|
||||||
|
setCacheMode(QGraphicsItem::DeviceCoordinateCache);
|
||||||
|
else
|
||||||
|
setCacheMode(QGraphicsItem::NoCache);
|
||||||
|
}
|
||||||
|
|
||||||
|
PathItem::PathItem(QGraphicsItem *parent) : QGraphicsObject(parent)
|
||||||
|
{
|
||||||
|
QBrush brush(Qt::SolidPattern);
|
||||||
|
_pen = QPen(brush, PATH_WIDTH);
|
||||||
|
|
||||||
|
_units = Metric;
|
||||||
|
|
||||||
|
_marker = new MarkerItem(this);
|
||||||
|
|
||||||
|
setCursor(Qt::ArrowCursor);
|
||||||
|
setAcceptHoverEvents(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
void PathItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *option,
|
||||||
|
QWidget *widget)
|
||||||
|
{
|
||||||
|
Q_UNUSED(option);
|
||||||
|
Q_UNUSED(widget);
|
||||||
|
|
||||||
|
painter->setPen(_pen);
|
||||||
|
painter->drawPath(_path);
|
||||||
|
|
||||||
|
/*
|
||||||
|
QPen p = QPen(QBrush(Qt::red), 0);
|
||||||
|
painter->setPen(p);
|
||||||
|
painter->drawRect(boundingRect());
|
||||||
|
*/
|
||||||
|
}
|
||||||
|
|
||||||
|
void PathItem::setScale(qreal scale)
|
||||||
|
{
|
||||||
|
prepareGeometryChange();
|
||||||
|
|
||||||
|
_pen.setWidthF(PATH_WIDTH * 1.0/scale);
|
||||||
|
QGraphicsItem::setScale(scale);
|
||||||
|
_marker->setScale(1.0/scale);
|
||||||
|
|
||||||
|
updateShape();
|
||||||
|
}
|
||||||
|
|
||||||
|
void PathItem::setColor(const QColor &color)
|
||||||
|
{
|
||||||
|
_pen.setColor(color);
|
||||||
|
update();
|
||||||
|
}
|
||||||
|
|
||||||
|
void PathItem::setUnits(enum Units units)
|
||||||
|
{
|
||||||
|
_units = units;
|
||||||
|
}
|
||||||
|
|
||||||
|
void PathItem::moveMarker(qreal distance)
|
||||||
|
{
|
||||||
|
if (distance > _distance)
|
||||||
|
_marker->setVisible(false);
|
||||||
|
else {
|
||||||
|
_marker->setVisible(true);
|
||||||
|
_marker->setPos(_path.pointAtPercent(distance / _distance));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void PathItem::hoverEnterEvent(QGraphicsSceneHoverEvent *event)
|
||||||
|
{
|
||||||
|
Q_UNUSED(event);
|
||||||
|
|
||||||
|
_pen.setWidthF(HOVER_WIDTH * 1.0/scale());
|
||||||
|
setZValue(zValue() + 1.0);
|
||||||
|
update();
|
||||||
|
|
||||||
|
emit selected(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
void PathItem::hoverLeaveEvent(QGraphicsSceneHoverEvent *event)
|
||||||
|
{
|
||||||
|
Q_UNUSED(event);
|
||||||
|
|
||||||
|
_pen.setWidthF(PATH_WIDTH * 1.0/scale());
|
||||||
|
setZValue(zValue() - 1.0);
|
||||||
|
update();
|
||||||
|
|
||||||
|
emit selected(false);
|
||||||
|
}
|
51
src/pathitem.h
Normal file
51
src/pathitem.h
Normal file
@ -0,0 +1,51 @@
|
|||||||
|
#ifndef PATHITEM_H
|
||||||
|
#define PATHITEM_H
|
||||||
|
|
||||||
|
#include <QGraphicsObject>
|
||||||
|
#include <QPen>
|
||||||
|
#include "markeritem.h"
|
||||||
|
#include "units.h"
|
||||||
|
|
||||||
|
|
||||||
|
class PathItem : public QGraphicsObject
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
|
||||||
|
public:
|
||||||
|
PathItem(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 showMarker(bool show) {_marker->setVisible(show);}
|
||||||
|
void setScale(qreal scale);
|
||||||
|
void setUnits(enum Units units);
|
||||||
|
void setColor(const QColor &color);
|
||||||
|
|
||||||
|
public slots:
|
||||||
|
void moveMarker(qreal distance);
|
||||||
|
|
||||||
|
signals:
|
||||||
|
void selected(bool);
|
||||||
|
|
||||||
|
protected:
|
||||||
|
void updateShape();
|
||||||
|
|
||||||
|
QPainterPath _path;
|
||||||
|
QPainterPath _shape;
|
||||||
|
QPen _pen;
|
||||||
|
|
||||||
|
MarkerItem *_marker;
|
||||||
|
|
||||||
|
Units _units;
|
||||||
|
qreal _distance;
|
||||||
|
|
||||||
|
private:
|
||||||
|
void hoverEnterEvent(QGraphicsSceneHoverEvent *event);
|
||||||
|
void hoverLeaveEvent(QGraphicsSceneHoverEvent *event);
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // PATHITEM_H
|
@ -1,22 +1,21 @@
|
|||||||
#include <QGraphicsView>
|
#include <QGraphicsView>
|
||||||
#include <QGraphicsScene>
|
#include <QGraphicsScene>
|
||||||
#include <QPainterPath>
|
|
||||||
#include <QWheelEvent>
|
#include <QWheelEvent>
|
||||||
#include "ll.h"
|
#include "ll.h"
|
||||||
#include "poi.h"
|
#include "poi.h"
|
||||||
#include "gpx.h"
|
#include "gpx.h"
|
||||||
#include "map.h"
|
#include "map.h"
|
||||||
#include "trackitem.h"
|
#include "trackitem.h"
|
||||||
|
#include "routeitem.h"
|
||||||
#include "waypointitem.h"
|
#include "waypointitem.h"
|
||||||
#include "markeritem.h"
|
|
||||||
#include "scaleitem.h"
|
#include "scaleitem.h"
|
||||||
#include "trackview.h"
|
#include "pathview.h"
|
||||||
|
|
||||||
|
|
||||||
#define MARGIN 10.0
|
#define MARGIN 10.0
|
||||||
#define SCALE_OFFSET 7
|
#define SCALE_OFFSET 7
|
||||||
|
|
||||||
TrackView::TrackView(QWidget *parent)
|
PathView::PathView(QWidget *parent)
|
||||||
: QGraphicsView(parent)
|
: QGraphicsView(parent)
|
||||||
{
|
{
|
||||||
_scene = new QGraphicsScene(this);
|
_scene = new QGraphicsScene(this);
|
||||||
@ -27,6 +26,7 @@ TrackView::TrackView(QWidget *parent)
|
|||||||
setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
|
setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
|
||||||
setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
|
setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
|
||||||
setRenderHints(QPainter::Antialiasing);
|
setRenderHints(QPainter::Antialiasing);
|
||||||
|
setAcceptDrops(false);
|
||||||
|
|
||||||
_mapScale = new ScaleItem();
|
_mapScale = new ScaleItem();
|
||||||
_mapScale->setZValue(2.0);
|
_mapScale->setZValue(2.0);
|
||||||
@ -34,45 +34,75 @@ TrackView::TrackView(QWidget *parent)
|
|||||||
_zoom = ZOOM_MAX;
|
_zoom = ZOOM_MAX;
|
||||||
_scale = mapScale(_zoom);
|
_scale = mapScale(_zoom);
|
||||||
_map = 0;
|
_map = 0;
|
||||||
_maxPath = 0;
|
_poi = 0;
|
||||||
_maxDistance = 0;
|
|
||||||
|
_units = Metric;
|
||||||
|
|
||||||
|
_showTracks = true;
|
||||||
|
_showRoutes = true;
|
||||||
|
_showWaypoints = true;
|
||||||
|
_showWaypointLabels = true;
|
||||||
|
_showPOI = true;
|
||||||
|
_showPOILabels = true;
|
||||||
|
_overlapPOIs = true;
|
||||||
|
_showRouteWaypoints = true;
|
||||||
|
|
||||||
_plot = false;
|
_plot = false;
|
||||||
_units = Metric;
|
|
||||||
_overlap = true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
TrackView::~TrackView()
|
PathView::~PathView()
|
||||||
{
|
{
|
||||||
if (_mapScale->scene() != _scene)
|
if (_mapScale->scene() != _scene)
|
||||||
delete _mapScale;
|
delete _mapScale;
|
||||||
}
|
}
|
||||||
|
|
||||||
void TrackView::addTrack(const Track &track)
|
PathItem *PathView::addTrack(const Track &track)
|
||||||
{
|
{
|
||||||
if (track.isNull()) {
|
if (track.isNull()) {
|
||||||
_palette.color();
|
_palette.color();
|
||||||
return;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
TrackItem *pi = new TrackItem(track);
|
TrackItem *ti = new TrackItem(track);
|
||||||
_paths.append(pi);
|
_tracks.append(ti);
|
||||||
_zoom = qMin(_zoom, scale2zoom(trackScale()));
|
_zoom = qMin(_zoom, scale2zoom(trackScale()));
|
||||||
_scale = mapScale(_zoom);
|
_scale = mapScale(_zoom);
|
||||||
pi->setScale(1.0/_scale);
|
ti->setScale(1.0/_scale);
|
||||||
pi->setColor(_palette.color());
|
ti->setColor(_palette.color());
|
||||||
_scene->addItem(pi);
|
ti->setVisible(_showTracks);
|
||||||
|
_scene->addItem(ti);
|
||||||
|
|
||||||
MarkerItem *mi = new MarkerItem(pi);
|
if (_poi)
|
||||||
_markers.append(mi);
|
addPOI(_poi->points(ti));
|
||||||
mi->setPos(pi->path().pointAtPercent(0));
|
|
||||||
mi->setScale(_scale);
|
|
||||||
|
|
||||||
_maxPath = qMax(pi->path().length(), _maxPath);
|
return ti;
|
||||||
_maxDistance = qMax(track.distance(), _maxDistance);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void TrackView::addWaypoints(const QList<Waypoint> &waypoints)
|
PathItem *PathView::addRoute(const Route &route)
|
||||||
|
{
|
||||||
|
if (route.isNull()) {
|
||||||
|
_palette.color();
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
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);
|
||||||
|
_scene->addItem(ri);
|
||||||
|
|
||||||
|
if (_poi)
|
||||||
|
addPOI(_poi->points(ri));
|
||||||
|
|
||||||
|
return ri;
|
||||||
|
}
|
||||||
|
|
||||||
|
void PathView::addWaypoints(const QList<Waypoint> &waypoints)
|
||||||
{
|
{
|
||||||
for (int i = 0; i < waypoints.count(); i++) {
|
for (int i = 0; i < waypoints.count(); i++) {
|
||||||
const Waypoint &w = waypoints.at(i);
|
const Waypoint &w = waypoints.at(i);
|
||||||
@ -80,54 +110,79 @@ void TrackView::addWaypoints(const QList<Waypoint> &waypoints)
|
|||||||
WaypointItem *wi = new WaypointItem(w);
|
WaypointItem *wi = new WaypointItem(w);
|
||||||
wi->setScale(1.0/_scale);
|
wi->setScale(1.0/_scale);
|
||||||
wi->setZValue(1);
|
wi->setZValue(1);
|
||||||
|
wi->showLabel(_showWaypointLabels);
|
||||||
|
wi->setVisible(_showWaypoints);
|
||||||
_scene->addItem(wi);
|
_scene->addItem(wi);
|
||||||
|
|
||||||
_waypoints.append(wi);
|
_waypoints.append(wi);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (_poi)
|
||||||
|
addPOI(_poi->points(waypoints));
|
||||||
|
|
||||||
_zoom = qMin(_zoom, scale2zoom(waypointScale()));
|
_zoom = qMin(_zoom, scale2zoom(waypointScale()));
|
||||||
_scale = mapScale(_zoom);
|
_scale = mapScale(_zoom);
|
||||||
}
|
}
|
||||||
|
|
||||||
void TrackView::loadGPX(const GPX &gpx)
|
QList<PathItem *> PathView::loadGPX(const GPX &gpx)
|
||||||
{
|
{
|
||||||
|
QList<PathItem *> paths;
|
||||||
int zoom = _zoom;
|
int zoom = _zoom;
|
||||||
|
|
||||||
for (int i = 0; i < gpx.trackCount(); i++)
|
|
||||||
addTrack(gpx.track(i));
|
for (int i = 0; i < gpx.tracks().count(); i++)
|
||||||
|
paths.append(addTrack(*(gpx.tracks().at(i))));
|
||||||
|
for (int i = 0; i < gpx.routes().count(); i++)
|
||||||
|
paths.append(addRoute(*(gpx.routes().at(i))));
|
||||||
addWaypoints(gpx.waypoints());
|
addWaypoints(gpx.waypoints());
|
||||||
|
|
||||||
if (_paths.empty() && _waypoints.empty())
|
if (_tracks.empty() && _routes.empty() && _waypoints.empty())
|
||||||
return;
|
return paths;
|
||||||
|
|
||||||
if ((_paths.size() > 1 && _zoom < zoom)
|
if ((_tracks.size() + _routes.size() > 1 && _zoom < zoom)
|
||||||
|| (_waypoints.size() && _zoom < zoom))
|
|| (_waypoints.size() && _zoom < zoom))
|
||||||
rescale(_scale);
|
rescale(_scale);
|
||||||
|
else
|
||||||
|
updatePOIVisibility();
|
||||||
|
|
||||||
QRectF br = trackBoundingRect() | waypointBoundingRect();
|
QRectF br = trackBoundingRect() | routeBoundingRect()
|
||||||
|
| waypointBoundingRect();
|
||||||
QRectF ba = br.adjusted(-TILE_SIZE, -TILE_SIZE, TILE_SIZE, TILE_SIZE);
|
QRectF ba = br.adjusted(-TILE_SIZE, -TILE_SIZE, TILE_SIZE, TILE_SIZE);
|
||||||
_scene->setSceneRect(ba);
|
_scene->setSceneRect(ba);
|
||||||
centerOn(ba.center());
|
centerOn(ba.center());
|
||||||
|
|
||||||
_mapScale->setLatitude(-(br.center().ry() * _scale));
|
_mapScale->setZoom(_zoom, -(br.center().ry() * _scale));
|
||||||
_mapScale->setZoom(_zoom);
|
|
||||||
if (_mapScale->scene() != _scene)
|
if (_mapScale->scene() != _scene)
|
||||||
_scene->addItem(_mapScale);
|
_scene->addItem(_mapScale);
|
||||||
|
|
||||||
|
return paths;
|
||||||
}
|
}
|
||||||
|
|
||||||
QRectF TrackView::trackBoundingRect() const
|
QRectF PathView::trackBoundingRect() const
|
||||||
{
|
{
|
||||||
if (_paths.empty())
|
if (_tracks.empty())
|
||||||
return QRectF();
|
return QRectF();
|
||||||
|
|
||||||
QRectF br = _paths.at(0)->sceneBoundingRect();
|
QRectF br = _tracks.at(0)->sceneBoundingRect();
|
||||||
for (int i = 1; i < _paths.size(); i++)
|
for (int i = 1; i < _tracks.size(); i++)
|
||||||
br |= _paths.at(i)->sceneBoundingRect();
|
br |= _tracks.at(i)->sceneBoundingRect();
|
||||||
|
|
||||||
return br;
|
return br;
|
||||||
}
|
}
|
||||||
|
|
||||||
QRectF TrackView::waypointBoundingRect() const
|
QRectF PathView::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;
|
||||||
|
}
|
||||||
|
|
||||||
|
QRectF PathView::waypointBoundingRect() const
|
||||||
{
|
{
|
||||||
qreal bottom, top, left, right;
|
qreal bottom, top, left, right;
|
||||||
|
|
||||||
@ -151,15 +206,15 @@ QRectF TrackView::waypointBoundingRect() const
|
|||||||
return QRectF(QPointF(left, top), QPointF(right, bottom));
|
return QRectF(QPointF(left, top), QPointF(right, bottom));
|
||||||
}
|
}
|
||||||
|
|
||||||
qreal TrackView::trackScale() const
|
qreal PathView::trackScale() const
|
||||||
{
|
{
|
||||||
if (_paths.empty())
|
if (_tracks.empty())
|
||||||
return mapScale(ZOOM_MAX);
|
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++)
|
for (int i = 1; i < _tracks.size(); i++)
|
||||||
br |= _paths.at(i)->path().boundingRect();
|
br |= _tracks.at(i)->path().boundingRect();
|
||||||
|
|
||||||
QPointF sc(br.width() / (viewport()->width() - MARGIN/2),
|
QPointF sc(br.width() / (viewport()->width() - MARGIN/2),
|
||||||
br.height() / (viewport()->height() - MARGIN/2));
|
br.height() / (viewport()->height() - MARGIN/2));
|
||||||
@ -167,7 +222,23 @@ qreal TrackView::trackScale() const
|
|||||||
return qMax(sc.x(), sc.y());
|
return qMax(sc.x(), sc.y());
|
||||||
}
|
}
|
||||||
|
|
||||||
qreal TrackView::waypointScale() const
|
qreal PathView::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));
|
||||||
|
|
||||||
|
return qMax(sc.x(), sc.y());
|
||||||
|
}
|
||||||
|
|
||||||
|
qreal PathView::waypointScale() const
|
||||||
{
|
{
|
||||||
qreal bottom, top, left, right;
|
qreal bottom, top, left, right;
|
||||||
|
|
||||||
@ -195,47 +266,88 @@ qreal TrackView::waypointScale() const
|
|||||||
return qMax(sc.x(), sc.y());
|
return qMax(sc.x(), sc.y());
|
||||||
}
|
}
|
||||||
|
|
||||||
qreal TrackView::mapScale(int zoom) const
|
qreal PathView::mapScale(int zoom) const
|
||||||
{
|
{
|
||||||
return ((360.0/(qreal)(1<<zoom))/(qreal)TILE_SIZE);
|
return ((360.0/(qreal)(1<<zoom))/(qreal)TILE_SIZE);
|
||||||
}
|
}
|
||||||
|
|
||||||
void TrackView::checkPOIOverlap()
|
void PathView::updatePOIVisibility()
|
||||||
{
|
{
|
||||||
QHash<Waypoint, WaypointItem*>::const_iterator it, jt;
|
QHash<Waypoint, WaypointItem*>::const_iterator it, jt;
|
||||||
|
|
||||||
for (it = _pois.constBegin(); it != _pois.constEnd(); it++) {
|
if (!_showPOI)
|
||||||
for (jt = _pois.constBegin(); jt != _pois.constEnd(); jt++) {
|
return;
|
||||||
if (it != jt && it.value()->isVisible() && jt.value()->isVisible()
|
|
||||||
&& it.value()->collidesWithItem(jt.value()))
|
for (it = _pois.constBegin(); it != _pois.constEnd(); it++)
|
||||||
jt.value()->hide();
|
it.value()->show();
|
||||||
|
|
||||||
|
if (!_overlapPOIs) {
|
||||||
|
for (it = _pois.constBegin(); it != _pois.constEnd(); it++) {
|
||||||
|
for (jt = _pois.constBegin(); jt != _pois.constEnd(); jt++) {
|
||||||
|
if (it.value()->isVisible() && jt.value()->isVisible()
|
||||||
|
&& it != jt && it.value()->collidesWithItem(jt.value()))
|
||||||
|
jt.value()->hide();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void TrackView::rescale(qreal scale)
|
void PathView::rescale(qreal scale)
|
||||||
{
|
{
|
||||||
for (int i = 0; i < _paths.size(); i++) {
|
_scale = scale;
|
||||||
_markers.at(i)->setScale(scale);
|
|
||||||
_paths.at(i)->setScale(1.0/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++)
|
for (int i = 0; i < _waypoints.size(); i++)
|
||||||
_waypoints.at(i)->setScale(1.0/scale);
|
_waypoints.at(i)->setScale(1.0/scale);
|
||||||
|
|
||||||
QHash<Waypoint, WaypointItem*>::const_iterator it;
|
QHash<Waypoint, WaypointItem*>::const_iterator it;
|
||||||
for (it = _pois.constBegin(); it != _pois.constEnd(); it++) {
|
for (it = _pois.constBegin(); it != _pois.constEnd(); it++)
|
||||||
it.value()->setScale(1.0/scale);
|
it.value()->setScale(1.0/scale);
|
||||||
it.value()->show();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!_overlap)
|
updatePOIVisibility();
|
||||||
checkPOIOverlap();
|
|
||||||
|
|
||||||
_scale = scale;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void TrackView::addPOI(const QVector<Waypoint> &waypoints)
|
void PathView::setPOI(POI *poi)
|
||||||
|
{
|
||||||
|
if (_poi)
|
||||||
|
disconnect(_poi, SIGNAL(pointsChanged()), this, SLOT(updatePOI()));
|
||||||
|
|
||||||
|
_poi = poi;
|
||||||
|
|
||||||
|
if (_poi)
|
||||||
|
connect(_poi, SIGNAL(pointsChanged()), this, SLOT(updatePOI()));
|
||||||
|
|
||||||
|
updatePOI();
|
||||||
|
}
|
||||||
|
|
||||||
|
void PathView::updatePOI()
|
||||||
|
{
|
||||||
|
QHash<Waypoint, WaypointItem*>::const_iterator it;
|
||||||
|
|
||||||
|
for (it = _pois.constBegin(); it != _pois.constEnd(); it++) {
|
||||||
|
_scene->removeItem(it.value());
|
||||||
|
delete it.value();
|
||||||
|
}
|
||||||
|
_pois.clear();
|
||||||
|
|
||||||
|
if (!_poi)
|
||||||
|
return;
|
||||||
|
|
||||||
|
for (int i = 0; i < _tracks.size(); i++)
|
||||||
|
addPOI(_poi->points(_tracks.at(i)));
|
||||||
|
for (int i = 0; i < _routes.size(); i++)
|
||||||
|
addPOI(_poi->points(_routes.at(i)));
|
||||||
|
addPOI(_poi->points(_waypoints));
|
||||||
|
|
||||||
|
updatePOIVisibility();
|
||||||
|
}
|
||||||
|
|
||||||
|
void PathView::addPOI(const QVector<Waypoint> &waypoints)
|
||||||
{
|
{
|
||||||
for (int i = 0; i < waypoints.size(); i++) {
|
for (int i = 0; i < waypoints.size(); i++) {
|
||||||
const Waypoint &w = waypoints.at(i);
|
const Waypoint &w = waypoints.at(i);
|
||||||
@ -246,43 +358,37 @@ void TrackView::addPOI(const QVector<Waypoint> &waypoints)
|
|||||||
WaypointItem *pi = new WaypointItem(w);
|
WaypointItem *pi = new WaypointItem(w);
|
||||||
pi->setScale(1.0/_scale);
|
pi->setScale(1.0/_scale);
|
||||||
pi->setZValue(1);
|
pi->setZValue(1);
|
||||||
|
pi->showLabel(_showPOILabels);
|
||||||
|
pi->setVisible(_showPOI);
|
||||||
_scene->addItem(pi);
|
_scene->addItem(pi);
|
||||||
|
|
||||||
_pois.insert(w, pi);
|
_pois.insert(w, pi);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void TrackView::loadPOI(const POI &poi)
|
void PathView::setMap(Map *map)
|
||||||
{
|
{
|
||||||
if (!_paths.size() && !_waypoints.size())
|
|
||||||
return;
|
|
||||||
|
|
||||||
for (int i = 0; i < _paths.size(); i++)
|
|
||||||
addPOI(poi.points(_paths.at(i)->path()));
|
|
||||||
addPOI(poi.points(_waypoints));
|
|
||||||
|
|
||||||
if (!_overlap)
|
|
||||||
checkPOIOverlap();
|
|
||||||
}
|
|
||||||
|
|
||||||
void TrackView::setMap(Map *map)
|
|
||||||
{
|
|
||||||
_map = map;
|
|
||||||
if (_map)
|
if (_map)
|
||||||
connect(_map, SIGNAL(loaded()), this, SLOT(redraw()),
|
disconnect(_map, SIGNAL(loaded()), this, SLOT(redraw()));
|
||||||
Qt::UniqueConnection);
|
|
||||||
|
_map = map;
|
||||||
|
|
||||||
|
if (_map)
|
||||||
|
connect(_map, SIGNAL(loaded()), this, SLOT(redraw()));
|
||||||
|
|
||||||
resetCachedContent();
|
resetCachedContent();
|
||||||
}
|
}
|
||||||
|
|
||||||
void TrackView::setUnits(enum Units units)
|
void PathView::setUnits(enum Units units)
|
||||||
{
|
{
|
||||||
_units = units;
|
_units = units;
|
||||||
|
|
||||||
_mapScale->setUnits(units);
|
_mapScale->setUnits(units);
|
||||||
|
|
||||||
for (int i = 0; i < _paths.count(); i++)
|
for (int i = 0; i < _tracks.count(); i++)
|
||||||
_paths[i]->setUnits(units);
|
_tracks[i]->setUnits(units);
|
||||||
|
for (int i = 0; i < _routes.count(); i++)
|
||||||
|
_routes[i]->setUnits(units);
|
||||||
for (int i = 0; i < _waypoints.size(); i++)
|
for (int i = 0; i < _waypoints.size(); i++)
|
||||||
_waypoints.at(i)->setUnits(units);
|
_waypoints.at(i)->setUnits(units);
|
||||||
|
|
||||||
@ -291,28 +397,31 @@ void TrackView::setUnits(enum Units units)
|
|||||||
it.value()->setUnits(units);
|
it.value()->setUnits(units);
|
||||||
}
|
}
|
||||||
|
|
||||||
void TrackView::redraw()
|
void PathView::redraw()
|
||||||
{
|
{
|
||||||
resetCachedContent();
|
resetCachedContent();
|
||||||
}
|
}
|
||||||
|
|
||||||
void TrackView::rescale()
|
void PathView::rescale()
|
||||||
{
|
{
|
||||||
_zoom = qMin(scale2zoom(trackScale()), scale2zoom(waypointScale()));
|
_zoom = qMin(qMin(scale2zoom(trackScale()), scale2zoom(routeScale())),
|
||||||
|
scale2zoom(waypointScale()));
|
||||||
|
|
||||||
rescale(mapScale(_zoom));
|
rescale(mapScale(_zoom));
|
||||||
_mapScale->setZoom(_zoom);
|
_mapScale->setZoom(_zoom);
|
||||||
}
|
}
|
||||||
|
|
||||||
void TrackView::zoom(int z, const QPointF &pos)
|
void PathView::zoom(int z, const QPointF &pos)
|
||||||
{
|
{
|
||||||
if (_paths.isEmpty() && _waypoints.isEmpty())
|
if (_tracks.isEmpty() && _routes.isEmpty() && _waypoints.isEmpty())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
qreal scale = _scale;
|
qreal scale = _scale;
|
||||||
_zoom = z;
|
_zoom = z;
|
||||||
|
|
||||||
rescale(mapScale(_zoom));
|
rescale(mapScale(_zoom));
|
||||||
QRectF br = trackBoundingRect() | waypointBoundingRect();
|
QRectF br = trackBoundingRect() | routeBoundingRect()
|
||||||
|
| waypointBoundingRect();
|
||||||
QRectF ba = br.adjusted(-TILE_SIZE, -TILE_SIZE, TILE_SIZE, TILE_SIZE);
|
QRectF ba = br.adjusted(-TILE_SIZE, -TILE_SIZE, TILE_SIZE, TILE_SIZE);
|
||||||
_scene->setSceneRect(ba);
|
_scene->setSceneRect(ba);
|
||||||
|
|
||||||
@ -327,9 +436,9 @@ void TrackView::zoom(int z, const QPointF &pos)
|
|||||||
resetCachedContent();
|
resetCachedContent();
|
||||||
}
|
}
|
||||||
|
|
||||||
void TrackView::wheelEvent(QWheelEvent *event)
|
void PathView::wheelEvent(QWheelEvent *event)
|
||||||
{
|
{
|
||||||
if (_paths.isEmpty() && _waypoints.isEmpty())
|
if (_tracks.isEmpty() && _routes.isEmpty() && _waypoints.isEmpty())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
QPointF pos = mapToScene(event->pos());
|
QPointF pos = mapToScene(event->pos());
|
||||||
@ -339,7 +448,7 @@ void TrackView::wheelEvent(QWheelEvent *event)
|
|||||||
zoom(z, pos);
|
zoom(z, pos);
|
||||||
}
|
}
|
||||||
|
|
||||||
void TrackView::keyPressEvent(QKeyEvent *event)
|
void PathView::keyPressEvent(QKeyEvent *event)
|
||||||
{
|
{
|
||||||
int z = -1;
|
int z = -1;
|
||||||
|
|
||||||
@ -354,7 +463,7 @@ void TrackView::keyPressEvent(QKeyEvent *event)
|
|||||||
QWidget::keyPressEvent(event);
|
QWidget::keyPressEvent(event);
|
||||||
}
|
}
|
||||||
|
|
||||||
void TrackView::plot(QPainter *painter, const QRectF &target)
|
void PathView::plot(QPainter *painter, const QRectF &target)
|
||||||
{
|
{
|
||||||
QRect orig, adj;
|
QRect orig, adj;
|
||||||
qreal ratio, diff;
|
qreal ratio, diff;
|
||||||
@ -388,69 +497,100 @@ void TrackView::plot(QPainter *painter, const QRectF &target)
|
|||||||
setUpdatesEnabled(true);
|
setUpdatesEnabled(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
void TrackView::clearPOI()
|
void PathView::clear()
|
||||||
{
|
|
||||||
QHash<Waypoint, WaypointItem*>::const_iterator it;
|
|
||||||
|
|
||||||
for (it = _pois.constBegin(); it != _pois.constEnd(); it++) {
|
|
||||||
_scene->removeItem(it.value());
|
|
||||||
delete it.value();
|
|
||||||
}
|
|
||||||
|
|
||||||
_pois.clear();
|
|
||||||
}
|
|
||||||
|
|
||||||
void TrackView::clear()
|
|
||||||
{
|
{
|
||||||
if (_mapScale->scene() == _scene)
|
if (_mapScale->scene() == _scene)
|
||||||
_scene->removeItem(_mapScale);
|
_scene->removeItem(_mapScale);
|
||||||
|
|
||||||
_pois.clear();
|
_pois.clear();
|
||||||
_paths.clear();
|
_tracks.clear();
|
||||||
|
_routes.clear();
|
||||||
_waypoints.clear();
|
_waypoints.clear();
|
||||||
_markers.clear();
|
|
||||||
_scene->clear();
|
_scene->clear();
|
||||||
_palette.reset();
|
_palette.reset();
|
||||||
|
|
||||||
_maxPath = 0;
|
|
||||||
_maxDistance = 0;
|
|
||||||
_zoom = ZOOM_MAX;
|
_zoom = ZOOM_MAX;
|
||||||
_scale = mapScale(_zoom);
|
_scale = mapScale(_zoom);
|
||||||
|
|
||||||
_scene->setSceneRect(QRectF());
|
_scene->setSceneRect(QRectF());
|
||||||
}
|
}
|
||||||
|
|
||||||
void TrackView::movePositionMarker(qreal val)
|
void PathView::showTracks(bool show)
|
||||||
{
|
{
|
||||||
qreal mp = val / _maxDistance;
|
_showTracks = show;
|
||||||
|
|
||||||
for (int i = 0; i < _paths.size(); i++) {
|
for (int i = 0; i < _tracks.count(); i++)
|
||||||
qreal f = _maxPath / _paths.at(i)->path().length();
|
_tracks.at(i)->setVisible(show);
|
||||||
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);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void TrackView::setPOIOverlap(bool overlap)
|
void PathView::showRoutes(bool show)
|
||||||
{
|
{
|
||||||
_overlap = overlap;
|
_showRoutes = show;
|
||||||
|
|
||||||
if (_overlap) {
|
for (int i = 0; i < _routes.count(); i++)
|
||||||
QHash<Waypoint, WaypointItem*>::const_iterator it;
|
_routes.at(i)->setVisible(show);
|
||||||
for (it = _pois.constBegin(); it != _pois.constEnd(); it++)
|
|
||||||
it.value()->show();
|
|
||||||
} else
|
|
||||||
checkPOIOverlap();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void TrackView::drawBackground(QPainter *painter, const QRectF &rect)
|
void PathView::showWaypoints(bool show)
|
||||||
{
|
{
|
||||||
if ((_paths.isEmpty() && _waypoints.isEmpty()) || !_map) {
|
_showWaypoints = show;
|
||||||
|
|
||||||
|
for (int i = 0; i < _waypoints.count(); i++)
|
||||||
|
_waypoints.at(i)->setVisible(show);
|
||||||
|
}
|
||||||
|
|
||||||
|
void PathView::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 PathView::showRouteWaypoints(bool show)
|
||||||
|
{
|
||||||
|
_showRouteWaypoints = show;
|
||||||
|
|
||||||
|
for (int i = 0; i < _routes.size(); i++)
|
||||||
|
_routes.at(i)->showWaypoints(show);
|
||||||
|
}
|
||||||
|
|
||||||
|
void PathView::showPOI(bool show)
|
||||||
|
{
|
||||||
|
_showPOI = show;
|
||||||
|
|
||||||
|
QHash<Waypoint, WaypointItem*>::const_iterator it;
|
||||||
|
for (it = _pois.constBegin(); it != _pois.constEnd(); it++)
|
||||||
|
it.value()->setVisible(show);
|
||||||
|
|
||||||
|
updatePOIVisibility();
|
||||||
|
}
|
||||||
|
|
||||||
|
void PathView::showPOILabels(bool show)
|
||||||
|
{
|
||||||
|
_showPOILabels = show;
|
||||||
|
|
||||||
|
QHash<Waypoint, WaypointItem*>::const_iterator it;
|
||||||
|
for (it = _pois.constBegin(); it != _pois.constEnd(); it++)
|
||||||
|
it.value()->showLabel(show);
|
||||||
|
|
||||||
|
updatePOIVisibility();
|
||||||
|
}
|
||||||
|
|
||||||
|
void PathView::setPOIOverlap(bool overlap)
|
||||||
|
{
|
||||||
|
_overlapPOIs = overlap;
|
||||||
|
|
||||||
|
updatePOIVisibility();
|
||||||
|
}
|
||||||
|
|
||||||
|
void PathView::drawBackground(QPainter *painter, const QRectF &rect)
|
||||||
|
{
|
||||||
|
if ((_tracks.isEmpty() && _routes.isEmpty() && _waypoints.isEmpty())
|
||||||
|
|| !_map) {
|
||||||
painter->fillRect(rect, Qt::white);
|
painter->fillRect(rect, Qt::white);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -479,14 +619,15 @@ void TrackView::drawBackground(QPainter *painter, const QRectF &rect)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void TrackView::resizeEvent(QResizeEvent *e)
|
void PathView::resizeEvent(QResizeEvent *e)
|
||||||
{
|
{
|
||||||
if (_paths.isEmpty() && _waypoints.isEmpty())
|
if (_tracks.isEmpty() && _routes.isEmpty() && _waypoints.isEmpty())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
rescale();
|
rescale();
|
||||||
|
|
||||||
QRectF br = trackBoundingRect() | waypointBoundingRect();
|
QRectF br = trackBoundingRect() | routeBoundingRect()
|
||||||
|
| waypointBoundingRect();
|
||||||
QRectF ba = br.adjusted(-TILE_SIZE, -TILE_SIZE, TILE_SIZE, TILE_SIZE);
|
QRectF ba = br.adjusted(-TILE_SIZE, -TILE_SIZE, TILE_SIZE, TILE_SIZE);
|
||||||
|
|
||||||
if (ba.width() < e->size().width()) {
|
if (ba.width() < e->size().width()) {
|
||||||
@ -504,7 +645,7 @@ void TrackView::resizeEvent(QResizeEvent *e)
|
|||||||
resetCachedContent();
|
resetCachedContent();
|
||||||
}
|
}
|
||||||
|
|
||||||
void TrackView::paintEvent(QPaintEvent *e)
|
void PathView::paintEvent(QPaintEvent *e)
|
||||||
{
|
{
|
||||||
QPointF scenePos = mapToScene(rect().bottomRight() + QPoint(
|
QPointF scenePos = mapToScene(rect().bottomRight() + QPoint(
|
||||||
-(SCALE_OFFSET + _mapScale->boundingRect().width()),
|
-(SCALE_OFFSET + _mapScale->boundingRect().width()),
|
@ -13,52 +13,69 @@ class GPX;
|
|||||||
class POI;
|
class POI;
|
||||||
class Map;
|
class Map;
|
||||||
class Track;
|
class Track;
|
||||||
|
class Route;
|
||||||
class TrackItem;
|
class TrackItem;
|
||||||
|
class RouteItem;
|
||||||
class WaypointItem;
|
class WaypointItem;
|
||||||
class MarkerItem;
|
|
||||||
class ScaleItem;
|
class ScaleItem;
|
||||||
|
class PathItem;
|
||||||
|
|
||||||
class TrackView : public QGraphicsView
|
class PathView : public QGraphicsView
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
TrackView(QWidget *parent = 0);
|
PathView(QWidget *parent = 0);
|
||||||
~TrackView();
|
~PathView();
|
||||||
|
|
||||||
void loadGPX(const GPX &gpx);
|
QList<PathItem*> loadGPX(const GPX &gpx);
|
||||||
|
|
||||||
void loadPOI(const POI &poi);
|
|
||||||
void clearPOI();
|
|
||||||
void clear();
|
|
||||||
|
|
||||||
|
void setPOI(POI *poi);
|
||||||
void setMap(Map *map);
|
void setMap(Map *map);
|
||||||
void setUnits(enum Units units);
|
void setUnits(enum Units units);
|
||||||
void setPOIOverlap(bool overlap);
|
|
||||||
|
|
||||||
void plot(QPainter *painter, const QRectF &target);
|
void plot(QPainter *painter, const QRectF &target);
|
||||||
|
|
||||||
int trackCount() const {return _paths.count();}
|
int trackCount() const {return _tracks.count();}
|
||||||
|
int routeCount() const {return _routes.count();}
|
||||||
int waypointCount() const {return _waypoints.count();}
|
int waypointCount() const {return _waypoints.count();}
|
||||||
|
|
||||||
|
void clear();
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
void movePositionMarker(qreal val);
|
|
||||||
void redraw();
|
void redraw();
|
||||||
|
|
||||||
|
void showPOI(bool show);
|
||||||
|
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 slots:
|
||||||
|
void updatePOI();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void addTrack(const Track &track);
|
PathItem *addTrack(const Track &track);
|
||||||
|
PathItem *addRoute(const Route &route);
|
||||||
void addWaypoints(const QList<Waypoint> &waypoints);
|
void addWaypoints(const QList<Waypoint> &waypoints);
|
||||||
void addPOI(const QVector<Waypoint> &waypoints);
|
void addPOI(const QVector<Waypoint> &waypoints);
|
||||||
|
void loadPOI();
|
||||||
|
void clearPOI();
|
||||||
|
|
||||||
QRectF trackBoundingRect() const;
|
QRectF trackBoundingRect() const;
|
||||||
|
QRectF routeBoundingRect() const;
|
||||||
QRectF waypointBoundingRect() const;
|
QRectF waypointBoundingRect() const;
|
||||||
qreal trackScale() const;
|
qreal trackScale() const;
|
||||||
|
qreal routeScale() const;
|
||||||
qreal waypointScale() const;
|
qreal waypointScale() const;
|
||||||
qreal mapScale(int zoom) const;
|
qreal mapScale(int zoom) const;
|
||||||
void rescale(qreal scale);
|
void rescale(qreal scale);
|
||||||
void rescale();
|
void rescale();
|
||||||
void zoom(int z, const QPointF &pos);
|
void zoom(int z, const QPointF &pos);
|
||||||
void checkPOIOverlap();
|
void updatePOIVisibility();
|
||||||
|
|
||||||
void wheelEvent(QWheelEvent *event);
|
void wheelEvent(QWheelEvent *event);
|
||||||
void keyPressEvent(QKeyEvent *event);
|
void keyPressEvent(QKeyEvent *event);
|
||||||
@ -67,22 +84,31 @@ private:
|
|||||||
void paintEvent(QPaintEvent *e);
|
void paintEvent(QPaintEvent *e);
|
||||||
|
|
||||||
QGraphicsScene *_scene;
|
QGraphicsScene *_scene;
|
||||||
QList<TrackItem*> _paths;
|
ScaleItem *_mapScale;
|
||||||
QList<MarkerItem*> _markers;
|
QList<TrackItem*> _tracks;
|
||||||
|
QList<RouteItem*> _routes;
|
||||||
QList<WaypointItem*> _waypoints;
|
QList<WaypointItem*> _waypoints;
|
||||||
QHash<Waypoint, WaypointItem*> _pois;
|
QHash<Waypoint, WaypointItem*> _pois;
|
||||||
|
|
||||||
Map *_map;
|
Map *_map;
|
||||||
ScaleItem *_mapScale;
|
POI *_poi;
|
||||||
|
|
||||||
Palette _palette;
|
Palette _palette;
|
||||||
qreal _maxPath, _maxDistance;
|
|
||||||
|
|
||||||
qreal _scale;
|
qreal _scale;
|
||||||
int _zoom;
|
int _zoom;
|
||||||
|
|
||||||
Units _units;
|
Units _units;
|
||||||
bool _overlap;
|
|
||||||
|
bool _showTracks;
|
||||||
|
bool _showRoutes;
|
||||||
|
bool _showWaypoints;
|
||||||
|
bool _showWaypointLabels;
|
||||||
|
bool _showPOI;
|
||||||
|
bool _showPOILabels;
|
||||||
|
bool _overlapPOIs;
|
||||||
|
bool _showRouteWaypoints;
|
||||||
|
|
||||||
bool _plot;
|
bool _plot;
|
||||||
};
|
};
|
||||||
|
|
84
src/poi.cpp
84
src/poi.cpp
@ -1,13 +1,19 @@
|
|||||||
#include <QFile>
|
#include <QFile>
|
||||||
#include <QSet>
|
#include <QSet>
|
||||||
#include <QList>
|
#include <QList>
|
||||||
#include <QPainterPath>
|
#include "pathitem.h"
|
||||||
#include "waypointitem.h"
|
#include "waypointitem.h"
|
||||||
#include "ll.h"
|
#include "ll.h"
|
||||||
#include "gpx.h"
|
#include "gpx.h"
|
||||||
#include "poi.h"
|
#include "poi.h"
|
||||||
|
|
||||||
|
|
||||||
|
POI::POI(QObject *parent) : QObject(parent)
|
||||||
|
{
|
||||||
|
_errorLine = 0;
|
||||||
|
_radius = 0.01;
|
||||||
|
}
|
||||||
|
|
||||||
bool POI::loadFile(const QString &fileName)
|
bool POI::loadFile(const QString &fileName)
|
||||||
{
|
{
|
||||||
QString error;
|
QString error;
|
||||||
@ -16,15 +22,17 @@ bool POI::loadFile(const QString &fileName)
|
|||||||
_error.clear();
|
_error.clear();
|
||||||
_errorLine = 0;
|
_errorLine = 0;
|
||||||
|
|
||||||
|
if (loadCSVFile(fileName)) {
|
||||||
if (loadCSVFile(fileName))
|
emit pointsChanged();
|
||||||
return true;
|
return true;
|
||||||
else {
|
} else {
|
||||||
error = _error;
|
error = _error;
|
||||||
errorLine = _errorLine;
|
errorLine = _errorLine;
|
||||||
}
|
}
|
||||||
if (loadGPXFile(fileName))
|
if (loadGPXFile(fileName)) {
|
||||||
|
emit pointsChanged();
|
||||||
return true;
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
fprintf(stderr, "Error loading POI file: %s:\n", qPrintable(fileName));
|
fprintf(stderr, "Error loading POI file: %s:\n", qPrintable(fileName));
|
||||||
fprintf(stderr, "CSV: line %d: %s\n", errorLine, qPrintable(error));
|
fprintf(stderr, "CSV: line %d: %s\n", errorLine, qPrintable(error));
|
||||||
@ -90,20 +98,20 @@ bool POI::loadCSVFile(const QString &fileName)
|
|||||||
QByteArray line = file.readLine();
|
QByteArray line = file.readLine();
|
||||||
QList<QByteArray> list = line.split(',');
|
QList<QByteArray> list = line.split(',');
|
||||||
if (list.size() < 3) {
|
if (list.size() < 3) {
|
||||||
_error = "Parse error";
|
_error = "Parse error.";
|
||||||
_errorLine = ln;
|
_errorLine = ln;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
qreal lat = list[0].trimmed().toDouble(&ret);
|
qreal lat = list[0].trimmed().toDouble(&ret);
|
||||||
if (!ret) {
|
if (!ret) {
|
||||||
_error = "Invalid latitude";
|
_error = "Invalid latitude.";
|
||||||
_errorLine = ln;
|
_errorLine = ln;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
qreal lon = list[1].trimmed().toDouble(&ret);
|
qreal lon = list[1].trimmed().toDouble(&ret);
|
||||||
if (!ret) {
|
if (!ret) {
|
||||||
_error = "Invalid longitude";
|
_error = "Invalid longitude.";
|
||||||
_errorLine = ln;
|
_errorLine = ln;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -145,18 +153,19 @@ static bool cb(size_t data, void* context)
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
QVector<Waypoint> POI::points(const QPainterPath &path, qreal radius) const
|
QVector<Waypoint> POI::points(const PathItem *path) const
|
||||||
{
|
{
|
||||||
QVector<Waypoint> ret;
|
QVector<Waypoint> ret;
|
||||||
QSet<int> set;
|
QSet<int> set;
|
||||||
qreal min[2], max[2];
|
qreal min[2], max[2];
|
||||||
|
const QPainterPath &pp = path->path();
|
||||||
|
|
||||||
for (int i = 0; i < path.elementCount(); i++) {
|
for (int i = 0; i < pp.elementCount(); i++) {
|
||||||
QPointF p = mercator2ll(path.elementAt(i));
|
QPointF p = mercator2ll(pp.elementAt(i));
|
||||||
min[0] = p.x() - radius;
|
min[0] = p.x() - _radius;
|
||||||
min[1] = -p.y() - radius;
|
min[1] = -p.y() - _radius;
|
||||||
max[0] = p.x() + radius;
|
max[0] = p.x() + _radius;
|
||||||
max[1] = -p.y() + radius;
|
max[1] = -p.y() + _radius;
|
||||||
_tree.Search(min, max, cb, &set);
|
_tree.Search(min, max, cb, &set);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -169,7 +178,7 @@ QVector<Waypoint> POI::points(const QPainterPath &path, qreal radius) const
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
QVector<Waypoint> POI::points(const QList<WaypointItem*> &list, qreal radius)
|
QVector<Waypoint> POI::points(const QList<WaypointItem*> &list)
|
||||||
const
|
const
|
||||||
{
|
{
|
||||||
QVector<Waypoint> ret;
|
QVector<Waypoint> ret;
|
||||||
@ -178,10 +187,34 @@ QVector<Waypoint> POI::points(const QList<WaypointItem*> &list, qreal radius)
|
|||||||
|
|
||||||
for (int i = 0; i < list.count(); i++) {
|
for (int i = 0; i < list.count(); i++) {
|
||||||
const QPointF &p = list.at(i)->waypoint().coordinates();
|
const QPointF &p = list.at(i)->waypoint().coordinates();
|
||||||
min[0] = p.x() - radius;
|
min[0] = p.x() - _radius;
|
||||||
min[1] = p.y() - radius;
|
min[1] = p.y() - _radius;
|
||||||
max[0] = p.x() + radius;
|
max[0] = p.x() + _radius;
|
||||||
max[1] = p.y() + 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<Waypoint> &list) 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).coordinates();
|
||||||
|
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);
|
_tree.Search(min, max, cb, &set);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -216,6 +249,8 @@ void POI::enableFile(const QString &fileName, bool enable)
|
|||||||
_tree.Insert(c, c, j);
|
_tree.Insert(c, c, j);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
emit pointsChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
void POI::clear()
|
void POI::clear()
|
||||||
@ -224,4 +259,13 @@ void POI::clear()
|
|||||||
_data.clear();
|
_data.clear();
|
||||||
_files.clear();
|
_files.clear();
|
||||||
_indexes.clear();
|
_indexes.clear();
|
||||||
|
|
||||||
|
emit pointsChanged();
|
||||||
|
}
|
||||||
|
|
||||||
|
void POI::setRadius(qreal radius)
|
||||||
|
{
|
||||||
|
_radius = radius;
|
||||||
|
|
||||||
|
emit pointsChanged();
|
||||||
}
|
}
|
||||||
|
26
src/poi.h
26
src/poi.h
@ -8,28 +8,34 @@
|
|||||||
#include "waypoint.h"
|
#include "waypoint.h"
|
||||||
#include "rtree.h"
|
#include "rtree.h"
|
||||||
|
|
||||||
class QPainterPath;
|
class PathItem;
|
||||||
class WaypointItem;
|
class WaypointItem;
|
||||||
|
|
||||||
#define POI_RADIUS 0.01
|
class POI : public QObject
|
||||||
|
|
||||||
class POI
|
|
||||||
{
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
POI() : _errorLine(0) {}
|
POI(QObject *parent = 0);
|
||||||
|
|
||||||
bool loadFile(const QString &fileName);
|
bool loadFile(const QString &fileName);
|
||||||
const QString &errorString() const {return _error;}
|
const QString &errorString() const {return _error;}
|
||||||
int errorLine() const {return _errorLine;}
|
int errorLine() const {return _errorLine;}
|
||||||
|
|
||||||
QVector<Waypoint> points(const QPainterPath &path,
|
qreal radius() const {return _radius;}
|
||||||
qreal radius = POI_RADIUS) const;
|
void setRadius(qreal radius);
|
||||||
QVector<Waypoint> points(const QList<WaypointItem*> &list,
|
|
||||||
qreal radius = POI_RADIUS) const;
|
QVector<Waypoint> points(const PathItem *path) const;
|
||||||
|
QVector<Waypoint> points(const QList<WaypointItem*> &list) const;
|
||||||
|
QVector<Waypoint> points(const QList<Waypoint> &list) const;
|
||||||
|
|
||||||
const QStringList &files() const {return _files;}
|
const QStringList &files() const {return _files;}
|
||||||
void enableFile(const QString &fileName, bool enable);
|
void enableFile(const QString &fileName, bool enable);
|
||||||
void clear();
|
void clear();
|
||||||
|
|
||||||
|
signals:
|
||||||
|
void pointsChanged();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
typedef RTree<size_t, qreal, 2> POITree;
|
typedef RTree<size_t, qreal, 2> POITree;
|
||||||
typedef struct {
|
typedef struct {
|
||||||
@ -46,6 +52,8 @@ private:
|
|||||||
QStringList _files;
|
QStringList _files;
|
||||||
QList<FileIndex> _indexes;
|
QList<FileIndex> _indexes;
|
||||||
|
|
||||||
|
qreal _radius;
|
||||||
|
|
||||||
QString _error;
|
QString _error;
|
||||||
int _errorLine;
|
int _errorLine;
|
||||||
};
|
};
|
||||||
|
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;
|
||||||
|
|
||||||
|
_distance.append(dist);
|
||||||
|
for (int i = 1; i < data.count(); i++) {
|
||||||
|
dist += llDistance(data.at(i).coordinates(), data.at(i-1).coordinates());
|
||||||
|
_distance.append(dist);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Graph Route::elevation() const
|
||||||
|
{
|
||||||
|
Graph graph;
|
||||||
|
|
||||||
|
for (int i = 0; i < _data.size(); i++)
|
||||||
|
if (_data.at(i).hasElevation())
|
||||||
|
graph.append(GraphPoint(_distance.at(i), NAN,
|
||||||
|
_data.at(i).elevation() - _data.at(i).geoidHeight()));
|
||||||
|
|
||||||
|
return graph;
|
||||||
|
}
|
||||||
|
|
||||||
|
qreal Route::distance() const
|
||||||
|
{
|
||||||
|
return (_distance.isEmpty()) ? 0 : _distance.last();
|
||||||
|
}
|
25
src/route.h
Normal file
25
src/route.h
Normal file
@ -0,0 +1,25 @@
|
|||||||
|
#ifndef ROUTE_H
|
||||||
|
#define ROUTE_H
|
||||||
|
|
||||||
|
#include <QVector>
|
||||||
|
#include "waypoint.h"
|
||||||
|
#include "graph.h"
|
||||||
|
|
||||||
|
class Route
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
Route(const QVector<Waypoint> &data);
|
||||||
|
|
||||||
|
const QVector<Waypoint> &route() const {return _data;}
|
||||||
|
Graph elevation() const;
|
||||||
|
|
||||||
|
qreal distance() const;
|
||||||
|
|
||||||
|
bool isNull() const {return (_data.count() < 2);}
|
||||||
|
|
||||||
|
private:
|
||||||
|
const QVector<Waypoint> &_data;
|
||||||
|
QVector<qreal> _distance;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // ROUTE_H
|
79
src/routeitem.cpp
Normal file
79
src/routeitem.cpp
Normal file
@ -0,0 +1,79 @@
|
|||||||
|
#include <QApplication>
|
||||||
|
#include <QPainter>
|
||||||
|
#include "ll.h"
|
||||||
|
#include "misc.h"
|
||||||
|
#include "waypoint.h"
|
||||||
|
#include "waypointitem.h"
|
||||||
|
#include "tooltip.h"
|
||||||
|
#include "routeitem.h"
|
||||||
|
|
||||||
|
|
||||||
|
QString RouteItem::toolTip()
|
||||||
|
{
|
||||||
|
ToolTip tt;
|
||||||
|
|
||||||
|
tt.insert(qApp->translate("RouteItem", "Distance"),
|
||||||
|
::distance(_distance, _units));
|
||||||
|
|
||||||
|
return tt.toString();
|
||||||
|
}
|
||||||
|
|
||||||
|
RouteItem::RouteItem(const Route &route, QGraphicsItem *parent)
|
||||||
|
: PathItem(parent)
|
||||||
|
{
|
||||||
|
QVector<Waypoint> r = route.route();
|
||||||
|
Q_ASSERT(r.count() >= 2);
|
||||||
|
|
||||||
|
new WaypointItem(r.at(0), 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())));
|
||||||
|
new WaypointItem(r.at(i), this);
|
||||||
|
}
|
||||||
|
|
||||||
|
updateShape();
|
||||||
|
|
||||||
|
_distance = route.distance();
|
||||||
|
|
||||||
|
_marker->setPos(_path.pointAtPercent(0));
|
||||||
|
|
||||||
|
_pen.setStyle(Qt::DotLine);
|
||||||
|
|
||||||
|
setToolTip(toolTip());
|
||||||
|
}
|
||||||
|
|
||||||
|
void RouteItem::setScale(qreal scale)
|
||||||
|
{
|
||||||
|
QList<QGraphicsItem *> childs = childItems();
|
||||||
|
for (int i = 0; i < childs.count(); i++)
|
||||||
|
childs.at(i)->setScale(1.0/scale);
|
||||||
|
|
||||||
|
PathItem::setScale(scale);
|
||||||
|
}
|
||||||
|
|
||||||
|
void RouteItem::setUnits(enum Units units)
|
||||||
|
{
|
||||||
|
PathItem::setUnits(units);
|
||||||
|
setToolTip(toolTip());
|
||||||
|
}
|
||||||
|
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
25
src/routeitem.h
Normal file
25
src/routeitem.h
Normal file
@ -0,0 +1,25 @@
|
|||||||
|
#ifndef ROUTEITEM_H
|
||||||
|
#define ROUTEITEM_H
|
||||||
|
|
||||||
|
#include "pathitem.h"
|
||||||
|
#include "route.h"
|
||||||
|
|
||||||
|
|
||||||
|
class RouteItem : public PathItem
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
|
||||||
|
public:
|
||||||
|
RouteItem(const Route &route, QGraphicsItem *parent = 0);
|
||||||
|
|
||||||
|
void setUnits(enum Units units);
|
||||||
|
void setScale(qreal scale);
|
||||||
|
|
||||||
|
void showWaypoints(bool show);
|
||||||
|
void showWaypointLabels(bool show);
|
||||||
|
|
||||||
|
private:
|
||||||
|
QString toolTip();
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // ROUTEITEM_H
|
@ -5,6 +5,7 @@
|
|||||||
#include "scaleitem.h"
|
#include "scaleitem.h"
|
||||||
|
|
||||||
|
|
||||||
|
#define BORDER_WIDTH 1
|
||||||
#define SCALE_WIDTH 132
|
#define SCALE_WIDTH 132
|
||||||
#define SCALE_HEIGHT 5
|
#define SCALE_HEIGHT 5
|
||||||
#define SEGMENTS 3
|
#define SEGMENTS 3
|
||||||
@ -17,6 +18,10 @@ ScaleItem::ScaleItem(QGraphicsItem *parent) : QGraphicsItem(parent)
|
|||||||
_units = Metric;
|
_units = Metric;
|
||||||
_zoom = ZOOM_MIN;
|
_zoom = ZOOM_MIN;
|
||||||
_lat = 0;
|
_lat = 0;
|
||||||
|
|
||||||
|
#ifndef Q_OS_MAC
|
||||||
|
setCacheMode(QGraphicsItem::DeviceCoordinateCache);
|
||||||
|
#endif // Q_OS_MAC
|
||||||
}
|
}
|
||||||
|
|
||||||
void ScaleItem::updateBoundingRect()
|
void ScaleItem::updateBoundingRect()
|
||||||
@ -31,9 +36,9 @@ void ScaleItem::updateBoundingRect()
|
|||||||
es = fm.tightBoundingRect(QString::number(_length * SEGMENTS));
|
es = fm.tightBoundingRect(QString::number(_length * SEGMENTS));
|
||||||
us = fm.tightBoundingRect(units());
|
us = fm.tightBoundingRect(units());
|
||||||
|
|
||||||
_boundingRect = QRectF(-ss.width()/2, 0,
|
_boundingRect = QRectF(-ss.width()/2, 0, _width * SEGMENTS + ss.width()/2
|
||||||
_width * SEGMENTS + ss.width()/2 + qMax(us.width() + PADDING, es.width()/2),
|
+ qMax(us.width() + PADDING, es.width()/2) + 1, SCALE_HEIGHT + PADDING
|
||||||
SCALE_HEIGHT + PADDING + ss.height() + 2*fm.descent());
|
+ ss.height() + 2*fm.descent());
|
||||||
}
|
}
|
||||||
|
|
||||||
void ScaleItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *option,
|
void ScaleItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *option,
|
||||||
@ -46,6 +51,7 @@ void ScaleItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *option,
|
|||||||
font.setFamily(FONT_FAMILY);
|
font.setFamily(FONT_FAMILY);
|
||||||
QFontMetrics fm(font);
|
QFontMetrics fm(font);
|
||||||
QRect br;
|
QRect br;
|
||||||
|
QPen pen = QPen(Qt::black, BORDER_WIDTH);
|
||||||
bool aa;
|
bool aa;
|
||||||
|
|
||||||
|
|
||||||
@ -53,6 +59,7 @@ void ScaleItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *option,
|
|||||||
painter->setRenderHint(QPainter::Antialiasing, false);
|
painter->setRenderHint(QPainter::Antialiasing, false);
|
||||||
|
|
||||||
painter->setFont(font);
|
painter->setFont(font);
|
||||||
|
painter->setPen(pen);
|
||||||
|
|
||||||
for (int i = 0; i <= SEGMENTS; i++) {
|
for (int i = 0; i <= SEGMENTS; i++) {
|
||||||
QString label = QString::number(_length * i);
|
QString label = QString::number(_length * i);
|
||||||
@ -67,10 +74,12 @@ void ScaleItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *option,
|
|||||||
for (int i = 0; i < SEGMENTS; i += 2)
|
for (int i = 0; i < SEGMENTS; i += 2)
|
||||||
painter->fillRect(QRectF(i * _width, br.height() + PADDING, _width,
|
painter->fillRect(QRectF(i * _width, br.height() + PADDING, _width,
|
||||||
SCALE_HEIGHT), Qt::black);
|
SCALE_HEIGHT), Qt::black);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
painter->setPen(Qt::red);
|
painter->setPen(Qt::red);
|
||||||
painter->drawRect(boundingRect());
|
painter->drawRect(boundingRect());
|
||||||
*/
|
*/
|
||||||
|
|
||||||
if (aa)
|
if (aa)
|
||||||
painter->setRenderHint(QPainter::Antialiasing, true);
|
painter->setRenderHint(QPainter::Antialiasing, true);
|
||||||
}
|
}
|
||||||
@ -78,9 +87,11 @@ void ScaleItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *option,
|
|||||||
QString ScaleItem::units() const
|
QString ScaleItem::units() const
|
||||||
{
|
{
|
||||||
if (_units == Imperial)
|
if (_units == Imperial)
|
||||||
return _scale ? QObject::tr("mi") : QObject::tr("ft");
|
return _scale ? qApp->translate("ScaleItem", "mi")
|
||||||
|
: qApp->translate("ScaleItem", "ft");
|
||||||
else
|
else
|
||||||
return _scale ? QObject::tr("km") : QObject::tr("m");
|
return _scale ? qApp->translate("ScaleItem", "km")
|
||||||
|
: qApp->translate("ScaleItem", "m");
|
||||||
}
|
}
|
||||||
|
|
||||||
void ScaleItem::computeScale()
|
void ScaleItem::computeScale()
|
||||||
@ -110,12 +121,14 @@ void ScaleItem::computeScale()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void ScaleItem::setLatitude(qreal lat)
|
void ScaleItem::setZoom(int z, qreal lat)
|
||||||
{
|
{
|
||||||
prepareGeometryChange();
|
prepareGeometryChange();
|
||||||
|
_zoom = z;
|
||||||
_lat = lat;
|
_lat = lat;
|
||||||
computeScale();
|
computeScale();
|
||||||
updateBoundingRect();
|
updateBoundingRect();
|
||||||
|
update();
|
||||||
}
|
}
|
||||||
|
|
||||||
void ScaleItem::setZoom(int z)
|
void ScaleItem::setZoom(int z)
|
||||||
@ -124,6 +137,7 @@ void ScaleItem::setZoom(int z)
|
|||||||
_zoom = z;
|
_zoom = z;
|
||||||
computeScale();
|
computeScale();
|
||||||
updateBoundingRect();
|
updateBoundingRect();
|
||||||
|
update();
|
||||||
}
|
}
|
||||||
|
|
||||||
void ScaleItem::setUnits(enum Units units)
|
void ScaleItem::setUnits(enum Units units)
|
||||||
@ -132,4 +146,5 @@ void ScaleItem::setUnits(enum Units units)
|
|||||||
_units = units;
|
_units = units;
|
||||||
computeScale();
|
computeScale();
|
||||||
updateBoundingRect();
|
updateBoundingRect();
|
||||||
|
update();
|
||||||
}
|
}
|
||||||
|
@ -13,8 +13,8 @@ public:
|
|||||||
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option,
|
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option,
|
||||||
QWidget *widget);
|
QWidget *widget);
|
||||||
|
|
||||||
void setLatitude(qreal lat);
|
|
||||||
void setZoom(int z);
|
void setZoom(int z);
|
||||||
|
void setZoom(int z, qreal lat);
|
||||||
void setUnits(enum Units units);
|
void setUnits(enum Units units);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
@ -3,21 +3,32 @@
|
|||||||
|
|
||||||
#define WINDOW_SETTINGS_GROUP "Window"
|
#define WINDOW_SETTINGS_GROUP "Window"
|
||||||
#define WINDOW_SIZE_SETTING "size"
|
#define WINDOW_SIZE_SETTING "size"
|
||||||
#define WINDOW_POS_SETTING "pos"
|
#define WINDOW_POS_SETTING "pos"
|
||||||
|
|
||||||
#define SETTINGS_SETTINGS_GROUP "Settings"
|
#define SETTINGS_SETTINGS_GROUP "Settings"
|
||||||
#define UNITS_SETTING "units"
|
#define UNITS_SETTING "units"
|
||||||
#define SHOW_TOOLBARS_SETTING "toolbar"
|
#define SHOW_TOOLBARS_SETTING "toolbar"
|
||||||
#define SHOW_GRAPHS_SETTING "graphs"
|
|
||||||
|
#define GRAPH_SETTINGS_GROUP "Graph"
|
||||||
|
#define SHOW_GRAPHS_SETTING "show"
|
||||||
|
#define GRAPH_TYPE_SETTING "type"
|
||||||
|
|
||||||
#define MAP_SETTINGS_GROUP "Map"
|
#define MAP_SETTINGS_GROUP "Map"
|
||||||
#define CURRENT_MAP_SETTING "map"
|
#define CURRENT_MAP_SETTING "map"
|
||||||
#define SHOW_MAP_SETTING "show"
|
#define SHOW_MAP_SETTING "show"
|
||||||
|
|
||||||
#define POI_SETTINGS_GROUP "POI"
|
#define POI_SETTINGS_GROUP "POI"
|
||||||
#define OVERLAP_POI_SETTING "overlap"
|
#define OVERLAP_POI_SETTING "overlap"
|
||||||
|
#define LABELS_POI_SETTING "labels"
|
||||||
#define SHOW_POI_SETTING "show"
|
#define SHOW_POI_SETTING "show"
|
||||||
#define DISABLED_POI_FILE_SETTINGS_PREFIX "disabled"
|
#define DISABLED_POI_FILE_SETTINGS_PREFIX "disabled"
|
||||||
#define DISABLED_POI_FILE_SETTING "file"
|
#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
|
#endif // SETTINGS_H
|
||||||
|
@ -4,7 +4,7 @@
|
|||||||
|
|
||||||
#define SIZE 10
|
#define SIZE 10
|
||||||
|
|
||||||
SliderItem::SliderItem(QGraphicsObject *parent) : QGraphicsObject(parent)
|
SliderItem::SliderItem(QGraphicsItem *parent) : QGraphicsObject(parent)
|
||||||
{
|
{
|
||||||
setFlag(ItemIsMovable);
|
setFlag(ItemIsMovable);
|
||||||
setFlag(ItemSendsGeometryChanges);
|
setFlag(ItemSendsGeometryChanges);
|
||||||
@ -24,7 +24,7 @@ void SliderItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *option
|
|||||||
painter->setPen(Qt::red);
|
painter->setPen(Qt::red);
|
||||||
painter->drawLine(0, 0, 0, -_area.height());
|
painter->drawLine(0, 0, 0, -_area.height());
|
||||||
|
|
||||||
//painter->drawRect(boundingRect());
|
// painter->drawRect(boundingRect());
|
||||||
}
|
}
|
||||||
|
|
||||||
QVariant SliderItem::itemChange(GraphicsItemChange change, const QVariant &value)
|
QVariant SliderItem::itemChange(GraphicsItemChange change, const QVariant &value)
|
||||||
|
@ -1,14 +1,14 @@
|
|||||||
#ifndef SLIDERITEM_H
|
#ifndef SLIDERITEM_H
|
||||||
#define SLIDERITEM_H
|
#define SLIDERITEM_H
|
||||||
|
|
||||||
#include <QGraphicsItem>
|
#include <QGraphicsObject>
|
||||||
|
|
||||||
class SliderItem : public QGraphicsObject
|
class SliderItem : public QGraphicsObject
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
SliderItem(QGraphicsObject *parent = 0);
|
SliderItem(QGraphicsItem *parent = 0);
|
||||||
|
|
||||||
QRectF boundingRect() const;
|
QRectF boundingRect() const;
|
||||||
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option,
|
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option,
|
||||||
|
@ -6,43 +6,46 @@
|
|||||||
SpeedGraph::SpeedGraph(QWidget *parent) : GraphTab(parent)
|
SpeedGraph::SpeedGraph(QWidget *parent) : GraphTab(parent)
|
||||||
{
|
{
|
||||||
_units = Metric;
|
_units = Metric;
|
||||||
|
_showTracks = true;
|
||||||
|
|
||||||
setYUnits();
|
setYUnits();
|
||||||
setXLabel(tr("Distance"));
|
|
||||||
setYLabel(tr("Speed"));
|
setYLabel(tr("Speed"));
|
||||||
|
|
||||||
setSliderPrecision(1);
|
setSliderPrecision(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
void SpeedGraph::addInfo()
|
void SpeedGraph::setInfo()
|
||||||
{
|
{
|
||||||
GraphView::addInfo(tr("Average"), QString::number(avg() * yScale(), 'f', 1)
|
if (_showTracks) {
|
||||||
+ UNIT_SPACE + yUnits());
|
GraphView::addInfo(tr("Average"), QString::number(avg() * yScale(), 'f',
|
||||||
GraphView::addInfo(tr("Maximum"), QString::number(max() * yScale(), 'f', 1)
|
1) + UNIT_SPACE + yUnits());
|
||||||
+ UNIT_SPACE + yUnits());
|
GraphView::addInfo(tr("Maximum"), QString::number(max() * yScale(), 'f',
|
||||||
|
1) + UNIT_SPACE + yUnits());
|
||||||
redraw();
|
} else
|
||||||
|
clearInfo();
|
||||||
}
|
}
|
||||||
|
|
||||||
void SpeedGraph::loadGPX(const GPX &gpx)
|
void SpeedGraph::loadGPX(const GPX &gpx, const QList<PathItem *> &paths)
|
||||||
{
|
{
|
||||||
for (int i = 0; i < gpx.trackCount(); i++) {
|
for (int i = 0; i < gpx.tracks().count(); i++) {
|
||||||
QVector<QPointF> data;
|
const Graph &graph = gpx.tracks().at(i)->speed();
|
||||||
|
if (graph.size() < 2) {
|
||||||
gpx.track(i).speedGraph(data);
|
|
||||||
if (data.count() < 2) {
|
|
||||||
skipColor();
|
skipColor();
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
_avg.append(QPointF(gpx.track(i).distance(), gpx.track(i).distance()
|
_avg.append(QPointF(gpx.tracks().at(i)->distance(),
|
||||||
/ gpx.track(i).time()));
|
gpx.tracks().at(i)->distance() / gpx.tracks().at(i)->time()));
|
||||||
|
|
||||||
loadData(data);
|
GraphView::loadGraph(graph, paths.at(i));
|
||||||
}
|
}
|
||||||
|
|
||||||
setXUnits();
|
for (int i = 0; i < gpx.routes().count(); i++)
|
||||||
addInfo();
|
skipColor();
|
||||||
|
|
||||||
|
setInfo();
|
||||||
|
|
||||||
|
redraw();
|
||||||
}
|
}
|
||||||
|
|
||||||
qreal SpeedGraph::avg() const
|
qreal SpeedGraph::avg() const
|
||||||
@ -65,27 +68,6 @@ void SpeedGraph::clear()
|
|||||||
GraphView::clear();
|
GraphView::clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
void SpeedGraph::setXUnits()
|
|
||||||
{
|
|
||||||
if (_units == Metric) {
|
|
||||||
if (bounds().width() < KMINM) {
|
|
||||||
GraphView::setXUnits(tr("m"));
|
|
||||||
setXScale(1);
|
|
||||||
} else {
|
|
||||||
GraphView::setXUnits(tr("km"));
|
|
||||||
setXScale(M2KM);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
if (bounds().width() < MIINM) {
|
|
||||||
GraphView::setXUnits(tr("ft"));
|
|
||||||
setXScale(M2FT);
|
|
||||||
} else {
|
|
||||||
GraphView::setXUnits(tr("mi"));
|
|
||||||
setXScale(M2MI);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void SpeedGraph::setYUnits()
|
void SpeedGraph::setYUnits()
|
||||||
{
|
{
|
||||||
if (_units == Metric) {
|
if (_units == Metric) {
|
||||||
@ -100,9 +82,20 @@ void SpeedGraph::setYUnits()
|
|||||||
void SpeedGraph::setUnits(enum Units units)
|
void SpeedGraph::setUnits(enum Units units)
|
||||||
{
|
{
|
||||||
_units = units;
|
_units = units;
|
||||||
setXUnits();
|
|
||||||
setYUnits();
|
|
||||||
|
|
||||||
clearInfo();
|
setYUnits();
|
||||||
addInfo();
|
setInfo();
|
||||||
|
GraphView::setUnits(units);
|
||||||
|
|
||||||
|
redraw();
|
||||||
|
}
|
||||||
|
|
||||||
|
void SpeedGraph::showTracks(bool show)
|
||||||
|
{
|
||||||
|
_showTracks = show;
|
||||||
|
|
||||||
|
showGraph(show);
|
||||||
|
setInfo();
|
||||||
|
|
||||||
|
redraw();
|
||||||
}
|
}
|
||||||
|
@ -4,8 +4,6 @@
|
|||||||
#include <QList>
|
#include <QList>
|
||||||
#include "graphtab.h"
|
#include "graphtab.h"
|
||||||
|
|
||||||
class GPX;
|
|
||||||
|
|
||||||
class SpeedGraph : public GraphTab
|
class SpeedGraph : public GraphTab
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
@ -14,19 +12,22 @@ public:
|
|||||||
SpeedGraph(QWidget *parent = 0);
|
SpeedGraph(QWidget *parent = 0);
|
||||||
|
|
||||||
QString label() const {return tr("Speed");}
|
QString label() const {return tr("Speed");}
|
||||||
void loadGPX(const GPX &gpx);
|
void loadGPX(const GPX &gpx, const QList<PathItem *> &paths);
|
||||||
void clear();
|
void clear();
|
||||||
void setUnits(enum Units units);
|
void setUnits(enum Units units);
|
||||||
|
void showTracks(bool show);
|
||||||
|
void showRoutes(bool show) {Q_UNUSED(show);}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
qreal avg() const;
|
qreal avg() const;
|
||||||
qreal max() const {return bounds().bottom();}
|
qreal max() const {return bounds().bottom();}
|
||||||
void setXUnits();
|
|
||||||
void setYUnits();
|
void setYUnits();
|
||||||
void addInfo();
|
void setInfo();
|
||||||
|
|
||||||
QList<QPointF> _avg;
|
QList<QPointF> _avg;
|
||||||
|
|
||||||
enum Units _units;
|
enum Units _units;
|
||||||
|
bool _showTracks;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // SPEEDGRAPH_H
|
#endif // SPEEDGRAPH_H
|
||||||
|
@ -5,49 +5,54 @@
|
|||||||
TemperatureGraph::TemperatureGraph(QWidget *parent) : GraphTab(parent)
|
TemperatureGraph::TemperatureGraph(QWidget *parent) : GraphTab(parent)
|
||||||
{
|
{
|
||||||
_units = Metric;
|
_units = Metric;
|
||||||
|
_showTracks = true;
|
||||||
|
|
||||||
setYUnits();
|
setYUnits();
|
||||||
setXLabel(tr("Distance"));
|
|
||||||
setYLabel(tr("Temperature"));
|
setYLabel(tr("Temperature"));
|
||||||
|
|
||||||
setSliderPrecision(1);
|
setSliderPrecision(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
void TemperatureGraph::addInfo()
|
void TemperatureGraph::setInfo()
|
||||||
{
|
{
|
||||||
GraphView::addInfo(tr("Average"), QString::number(avg() * yScale()
|
if (_showTracks) {
|
||||||
+ yOffset(), 'f', 1) + UNIT_SPACE + yUnits());
|
GraphView::addInfo(tr("Average"), QString::number(avg() * yScale()
|
||||||
GraphView::addInfo(tr("Minimum"), QString::number(min() * yScale()
|
+ yOffset(), 'f', 1) + UNIT_SPACE + yUnits());
|
||||||
+ yOffset(), 'f', 1) + UNIT_SPACE + yUnits());
|
GraphView::addInfo(tr("Minimum"), QString::number(min() * yScale()
|
||||||
GraphView::addInfo(tr("Maximum"), QString::number(max() * yScale()
|
+ yOffset(), 'f', 1) + UNIT_SPACE + yUnits());
|
||||||
+ yOffset(), 'f', 1) + UNIT_SPACE + yUnits());
|
GraphView::addInfo(tr("Maximum"), QString::number(max() * yScale()
|
||||||
|
+ yOffset(), 'f', 1) + UNIT_SPACE + yUnits());
|
||||||
redraw();
|
} else
|
||||||
|
clearInfo();
|
||||||
}
|
}
|
||||||
|
|
||||||
void TemperatureGraph::loadGPX(const GPX &gpx)
|
void TemperatureGraph::loadGPX(const GPX &gpx, const QList<PathItem *> &paths)
|
||||||
{
|
{
|
||||||
for (int i = 0; i < gpx.trackCount(); i++) {
|
for (int i = 0; i < gpx.tracks().count(); i++) {
|
||||||
QVector<QPointF> data;
|
const Graph &graph = gpx.tracks().at(i)->temperature();
|
||||||
qreal sum = 0, w = 0;
|
qreal sum = 0, w = 0;
|
||||||
|
|
||||||
gpx.track(i).temperatureGraph(data);
|
if (graph.size() < 2) {
|
||||||
if (data.count() < 2) {
|
|
||||||
skipColor();
|
skipColor();
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int j = 1; j < data.size(); j++) {
|
for (int j = 1; j < graph.size(); j++) {
|
||||||
sum += data.at(j).y() * (data.at(j).x() - data.at(j-1).x());
|
qreal ds = graph.at(j).s() - graph.at(j-1).s();
|
||||||
w += data.at(j).x() - data.at(j-1).x();
|
sum += graph.at(j).y() * ds;
|
||||||
|
w += ds;
|
||||||
}
|
}
|
||||||
_avg.append(QPointF(gpx.track(i).distance(), sum/w));
|
_avg.append(QPointF(gpx.tracks().at(i)->distance(), sum/w));
|
||||||
|
|
||||||
loadData(data);
|
GraphView::loadGraph(graph, paths.at(i));
|
||||||
}
|
}
|
||||||
|
|
||||||
setXUnits();
|
for (int i = 0; i < gpx.routes().count(); i++)
|
||||||
addInfo();
|
skipColor();
|
||||||
|
|
||||||
|
setInfo();
|
||||||
|
|
||||||
|
redraw();
|
||||||
}
|
}
|
||||||
|
|
||||||
qreal TemperatureGraph::avg() const
|
qreal TemperatureGraph::avg() const
|
||||||
@ -70,27 +75,6 @@ void TemperatureGraph::clear()
|
|||||||
GraphView::clear();
|
GraphView::clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
void TemperatureGraph::setXUnits()
|
|
||||||
{
|
|
||||||
if (_units == Metric) {
|
|
||||||
if (bounds().width() < KMINM) {
|
|
||||||
GraphView::setXUnits(tr("m"));
|
|
||||||
setXScale(1);
|
|
||||||
} else {
|
|
||||||
GraphView::setXUnits(tr("km"));
|
|
||||||
setXScale(M2KM);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
if (bounds().width() < MIINM) {
|
|
||||||
GraphView::setXUnits(tr("ft"));
|
|
||||||
setXScale(M2FT);
|
|
||||||
} else {
|
|
||||||
GraphView::setXUnits(tr("mi"));
|
|
||||||
setXScale(M2MI);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void TemperatureGraph::setYUnits()
|
void TemperatureGraph::setYUnits()
|
||||||
{
|
{
|
||||||
if (_units == Metric) {
|
if (_units == Metric) {
|
||||||
@ -107,9 +91,20 @@ void TemperatureGraph::setYUnits()
|
|||||||
void TemperatureGraph::setUnits(enum Units units)
|
void TemperatureGraph::setUnits(enum Units units)
|
||||||
{
|
{
|
||||||
_units = units;
|
_units = units;
|
||||||
setXUnits();
|
|
||||||
setYUnits();
|
|
||||||
|
|
||||||
clearInfo();
|
setYUnits();
|
||||||
addInfo();
|
setInfo();
|
||||||
|
GraphView::setUnits(units);
|
||||||
|
|
||||||
|
redraw();
|
||||||
|
}
|
||||||
|
|
||||||
|
void TemperatureGraph::showTracks(bool show)
|
||||||
|
{
|
||||||
|
_showTracks = show;
|
||||||
|
|
||||||
|
showGraph(show);
|
||||||
|
setInfo();
|
||||||
|
|
||||||
|
redraw();
|
||||||
}
|
}
|
||||||
|
@ -3,8 +3,6 @@
|
|||||||
|
|
||||||
#include "graphtab.h"
|
#include "graphtab.h"
|
||||||
|
|
||||||
class GPX;
|
|
||||||
|
|
||||||
class TemperatureGraph : public GraphTab
|
class TemperatureGraph : public GraphTab
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
@ -13,20 +11,23 @@ public:
|
|||||||
TemperatureGraph(QWidget *parent = 0);
|
TemperatureGraph(QWidget *parent = 0);
|
||||||
|
|
||||||
QString label() const {return tr("Temperature");}
|
QString label() const {return tr("Temperature");}
|
||||||
void loadGPX(const GPX &gpx);
|
void loadGPX(const GPX &gpx, const QList<PathItem *> &paths);
|
||||||
void clear();
|
void clear();
|
||||||
void setUnits(enum Units units);
|
void setUnits(enum Units units);
|
||||||
|
void showTracks(bool show);
|
||||||
|
void showRoutes(bool show) {Q_UNUSED(show);}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
qreal avg() const;
|
qreal avg() const;
|
||||||
qreal min() const {return bounds().top();}
|
qreal min() const {return bounds().top();}
|
||||||
qreal max() const {return bounds().bottom();}
|
qreal max() const {return bounds().bottom();}
|
||||||
void setXUnits();
|
|
||||||
void setYUnits();
|
void setYUnits();
|
||||||
void addInfo();
|
void setInfo();
|
||||||
|
|
||||||
QList<QPointF> _avg;
|
QList<QPointF> _avg;
|
||||||
|
|
||||||
enum Units _units;
|
enum Units _units;
|
||||||
|
bool _showTracks;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // TEMPERATUREGRAPH_H
|
#endif // TEMPERATUREGRAPH_H
|
||||||
|
116
src/track.cpp
116
src/track.cpp
@ -8,18 +8,19 @@
|
|||||||
#define WINDOW_HE 11
|
#define WINDOW_HE 11
|
||||||
#define WINDOW_HF 3
|
#define WINDOW_HF 3
|
||||||
|
|
||||||
static bool lt(const QPointF &p1, const QPointF &p2)
|
|
||||||
|
static bool lt(const GraphPoint &v1, const GraphPoint &v2)
|
||||||
{
|
{
|
||||||
return p1.y() < p2.y();
|
return v1.y() < v2.y();
|
||||||
}
|
}
|
||||||
|
|
||||||
static qreal median(QVector<QPointF> v)
|
static qreal median(QVector<GraphPoint> v)
|
||||||
{
|
{
|
||||||
qSort(v.begin(), v.end(), lt);
|
qSort(v.begin(), v.end(), lt);
|
||||||
return v.at(v.size() / 2).y();
|
return v.at(v.size() / 2).y();
|
||||||
}
|
}
|
||||||
|
|
||||||
static qreal MAD(QVector<QPointF> v, qreal m)
|
static qreal MAD(QVector<GraphPoint> v, qreal m)
|
||||||
{
|
{
|
||||||
for (int i = 0; i < v.size(); i++)
|
for (int i = 0; i < v.size(); i++)
|
||||||
v[i].setY(qAbs(v.at(i).y() - m));
|
v[i].setY(qAbs(v.at(i).y() - m));
|
||||||
@ -27,15 +28,15 @@ static qreal MAD(QVector<QPointF> v, qreal m)
|
|||||||
return v.at(v.size() / 2).y();
|
return v.at(v.size() / 2).y();
|
||||||
}
|
}
|
||||||
|
|
||||||
static QVector<QPointF> eliminate(const QVector<QPointF> &v, int window)
|
static QVector<GraphPoint> eliminate(const QVector<GraphPoint> &v, int window)
|
||||||
{
|
{
|
||||||
QList<int> rm;
|
QList<int> rm;
|
||||||
QVector<QPointF> ret;
|
QVector<GraphPoint> ret;
|
||||||
qreal m, M;
|
qreal m, M;
|
||||||
|
|
||||||
|
|
||||||
if (v.size() < window)
|
if (v.size() < window)
|
||||||
return QVector<QPointF>(v);
|
return QVector<GraphPoint>(v);
|
||||||
|
|
||||||
for (int i = window/2; i < v.size() - window/2; i++) {
|
for (int i = window/2; i < v.size() - window/2; i++) {
|
||||||
m = median(v.mid(i - window/2, window));
|
m = median(v.mid(i - window/2, window));
|
||||||
@ -55,26 +56,26 @@ static QVector<QPointF> eliminate(const QVector<QPointF> &v, int window)
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
static QVector<QPointF> filter(const QVector<QPointF> &v, int window)
|
static QVector<GraphPoint> filter(const QVector<GraphPoint> &v, int window)
|
||||||
{
|
{
|
||||||
qreal acc = 0;
|
qreal acc = 0;
|
||||||
QVector<QPointF> ret;
|
QVector<GraphPoint> ret;
|
||||||
|
|
||||||
if (v.size() < window)
|
if (v.size() < window)
|
||||||
return QVector<QPointF>(v);
|
return QVector<GraphPoint>(v);
|
||||||
|
|
||||||
for (int i = 0; i < window; i++)
|
for (int i = 0; i < window; i++)
|
||||||
acc += v.at(i).y();
|
acc += v.at(i).y();
|
||||||
for (int i = 0; i <= window/2; i++)
|
for (int i = 0; i <= window/2; i++)
|
||||||
ret.append(QPointF(v.at(i).x(), acc/window));
|
ret.append(GraphPoint(v.at(i).s(), v.at(i).t(), acc/window));
|
||||||
|
|
||||||
for (int i = window/2 + 1; i < v.size() - window/2; i++) {
|
for (int i = window/2 + 1; i < v.size() - window/2; i++) {
|
||||||
acc += v.at(i + window/2).y() - v.at(i - (window/2 + 1)).y();
|
acc += v.at(i + window/2).y() - v.at(i - (window/2 + 1)).y();
|
||||||
ret.append(QPointF(v.at(i).x(), acc/window));
|
ret.append(GraphPoint(v.at(i).s(), v.at(i).t(), acc/window));
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int i = v.size() - window/2; i < v.size(); i++)
|
for (int i = v.size() - window/2; i < v.size(); i++)
|
||||||
ret.append(QPointF(v.at(i).x(), acc/window));
|
ret.append(GraphPoint(v.at(i).s(), v.at(i).t(), acc/window));
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
@ -83,100 +84,101 @@ Track::Track(const QVector<Trackpoint> &data) : _data(data)
|
|||||||
{
|
{
|
||||||
qreal dist = 0;
|
qreal dist = 0;
|
||||||
|
|
||||||
_dd.append(dist);
|
_distance.append(0);
|
||||||
for (int i = 1; i < _data.count(); i++) {
|
_time.append(0);
|
||||||
dist += llDistance(_data.at(i).coordinates(),
|
for (int i = 1; i < data.count(); i++) {
|
||||||
_data.at(i-1).coordinates());
|
dist += llDistance(data.at(i).coordinates(), data.at(i-1).coordinates());
|
||||||
_dd.append(dist);
|
_distance.append(dist);
|
||||||
|
|
||||||
|
if (data.first().hasTimestamp() && data.at(i).hasTimestamp())
|
||||||
|
_time.append(_data.first().timestamp().msecsTo(
|
||||||
|
_data.at(i).timestamp()) / 1000.0);
|
||||||
|
else
|
||||||
|
_time.append(NAN);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Track::elevationGraph(QVector<QPointF> &graph) const
|
Graph Track::elevation() const
|
||||||
{
|
{
|
||||||
QVector<QPointF> raw;
|
QVector<GraphPoint> raw;
|
||||||
|
|
||||||
if (!_data.size())
|
if (!_data.size())
|
||||||
return;
|
return raw;
|
||||||
|
|
||||||
for (int i = 0; i < _data.size(); i++)
|
for (int i = 0; i < _data.size(); i++)
|
||||||
if (_data.at(i).hasElevation())
|
if (_data.at(i).hasElevation())
|
||||||
raw.append(QPointF(_dd.at(i), _data.at(i).elevation()
|
raw.append(GraphPoint(_distance.at(i), _time.at(i),
|
||||||
- _data.at(i).geoidHeight()));
|
_data.at(i).elevation() - _data.at(i).geoidHeight()));
|
||||||
|
|
||||||
graph = filter(raw, WINDOW_EF);
|
return filter(raw, WINDOW_EF);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Track::speedGraph(QVector<QPointF> &graph) const
|
Graph Track::speed() const
|
||||||
{
|
{
|
||||||
qreal v, ds;
|
QVector<GraphPoint> raw;
|
||||||
qint64 dt;
|
qreal v, ds, dt;
|
||||||
QVector<QPointF> raw;
|
|
||||||
|
|
||||||
if (!_data.size())
|
if (!_data.size())
|
||||||
return;
|
return raw;
|
||||||
|
|
||||||
raw.append(QPointF(0, 0));
|
raw.append(GraphPoint(_distance.at(0), _time.at(0), 0));
|
||||||
for (int i = 1; i < _data.size(); i++) {
|
for (int i = 1; i < _data.size(); i++) {
|
||||||
if (_data.at(i).hasSpeed())
|
if (_data.at(i).hasSpeed())
|
||||||
v = _data.at(i).speed();
|
v = _data.at(i).speed();
|
||||||
else if (_data.at(i).hasTimestamp()) {
|
else if (_data.at(i).hasTimestamp() && _data.at(i-1).hasTimestamp()) {
|
||||||
dt = _data.at(i-1).timestamp().msecsTo(_data.at(i).timestamp());
|
dt = _time.at(i) - _time.at(i-1);
|
||||||
if (!dt)
|
if (!dt)
|
||||||
continue;
|
continue;
|
||||||
ds = _dd.at(i) - _dd.at(i-1);
|
ds = _distance.at(i) - _distance.at(i-1);
|
||||||
v = ds / ((qreal)dt / 1000.0);
|
v = ds / dt;
|
||||||
} else
|
} else
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
raw.append(QPointF(_dd.at(i), v));
|
raw.append(GraphPoint(_distance.at(i), _time.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
|
Graph Track::heartRate() const
|
||||||
{
|
{
|
||||||
QVector<QPointF> raw;
|
QVector<GraphPoint> raw;
|
||||||
|
|
||||||
if (!_data.size())
|
if (!_data.size())
|
||||||
return;
|
return raw;
|
||||||
|
|
||||||
for (int i = 0; i < _data.count(); i++)
|
for (int i = 0; i < _data.count(); i++)
|
||||||
if (_data.at(i).hasHeartRate())
|
if (_data.at(i).hasHeartRate())
|
||||||
raw.append(QPointF(_dd.at(i), _data.at(i).heartRate()));
|
raw.append(GraphPoint(_distance.at(i), _time.at(i),
|
||||||
|
_data.at(i).heartRate()));
|
||||||
|
|
||||||
graph = filter(eliminate(raw, WINDOW_HE), WINDOW_HF);
|
return filter(eliminate(raw, WINDOW_HE), WINDOW_HF);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Track::temperatureGraph(QVector<QPointF> &graph) const
|
Graph Track::temperature() const
|
||||||
{
|
{
|
||||||
if (!_data.size())
|
QVector<GraphPoint> raw;
|
||||||
return;
|
|
||||||
|
|
||||||
for (int i = 0; i < _data.size(); i++)
|
for (int i = 0; i < _data.size(); i++)
|
||||||
if (_data.at(i).hasTemperature())
|
if (_data.at(i).hasTemperature())
|
||||||
graph.append(QPointF(_dd.at(i), _data.at(i).temperature()));
|
raw.append(GraphPoint(_distance.at(i), _time.at(i),
|
||||||
|
_data.at(i).temperature()));
|
||||||
|
|
||||||
|
return Graph(raw);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Track::track(QVector<QPointF> &track) const
|
qreal Track::distance() const
|
||||||
{
|
{
|
||||||
for (int i = 0; i < _data.size(); i++)
|
return (_distance.isEmpty()) ? 0 : _distance.last();
|
||||||
track.append(_data.at(i).coordinates());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
qreal Track::time() const
|
qreal Track::time() const
|
||||||
{
|
{
|
||||||
if (_data.size() < 2)
|
return (_data.size() < 2) ? 0 :
|
||||||
return 0;
|
(_data.first().timestamp().msecsTo(_data.last().timestamp()) / 1000.0);
|
||||||
|
|
||||||
return (_data.first().timestamp().msecsTo(_data.last().timestamp())
|
|
||||||
/ 1000.0);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
QDateTime Track::date() const
|
QDateTime Track::date() const
|
||||||
{
|
{
|
||||||
if (_data.size())
|
return (_data.size()) ? _data.first().timestamp() : QDateTime();
|
||||||
return _data.first().timestamp();
|
|
||||||
else
|
|
||||||
return QDateTime();
|
|
||||||
}
|
}
|
||||||
|
20
src/track.h
20
src/track.h
@ -4,27 +4,29 @@
|
|||||||
#include <QVector>
|
#include <QVector>
|
||||||
#include <QDateTime>
|
#include <QDateTime>
|
||||||
#include "trackpoint.h"
|
#include "trackpoint.h"
|
||||||
|
#include "graph.h"
|
||||||
|
|
||||||
class Track
|
class Track
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
Track(const QVector<Trackpoint> &data);
|
Track(const QVector<Trackpoint> &data);
|
||||||
|
|
||||||
void elevationGraph(QVector<QPointF> &graph) const;
|
const QVector<Trackpoint> &track() const {return _data;}
|
||||||
void speedGraph(QVector<QPointF> &graph) const;
|
Graph elevation() const;
|
||||||
void heartRateGraph(QVector<QPointF> &graph) const;
|
Graph speed() const;
|
||||||
void temperatureGraph(QVector<QPointF> &graph) const;
|
Graph heartRate() const;
|
||||||
void track(QVector<QPointF> &track) const;
|
Graph temperature() const;
|
||||||
qreal distance() const {return _dd.last();}
|
|
||||||
|
qreal distance() const;
|
||||||
qreal time() const;
|
qreal time() const;
|
||||||
QDateTime date() const;
|
QDateTime date() const;
|
||||||
|
|
||||||
bool isNull() const {return (_data.count() < 2) ? true : false;}
|
bool isNull() const {return (_data.size() < 2);}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
const QVector<Trackpoint> &_data;
|
const QVector<Trackpoint> &_data;
|
||||||
QVector<qreal> _dd;
|
QVector<qreal> _distance;
|
||||||
qreal _distance;
|
QVector<qreal> _time;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // TRACK_H
|
#endif // TRACK_H
|
||||||
|
@ -1,14 +1,12 @@
|
|||||||
#include <QApplication>
|
#include <QApplication>
|
||||||
#include <QCursor>
|
#include <QCursor>
|
||||||
#include <QPen>
|
#include <QPainter>
|
||||||
#include "ll.h"
|
#include "ll.h"
|
||||||
#include "misc.h"
|
#include "misc.h"
|
||||||
#include "tooltip.h"
|
#include "tooltip.h"
|
||||||
#include "trackitem.h"
|
#include "trackitem.h"
|
||||||
|
|
||||||
|
|
||||||
#define TRACK_WIDTH 3
|
|
||||||
|
|
||||||
QString TrackItem::toolTip()
|
QString TrackItem::toolTip()
|
||||||
{
|
{
|
||||||
ToolTip tt;
|
ToolTip tt;
|
||||||
@ -24,64 +22,32 @@ QString TrackItem::toolTip()
|
|||||||
return tt.toString();
|
return tt.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
void TrackItem::updateShape()
|
|
||||||
{
|
|
||||||
QPainterPathStroker s;
|
|
||||||
s.setWidth(TRACK_WIDTH * 1.0/scale());
|
|
||||||
_shape = s.createStroke(path().simplified());
|
|
||||||
}
|
|
||||||
|
|
||||||
TrackItem::TrackItem(const Track &track, QGraphicsItem *parent)
|
TrackItem::TrackItem(const Track &track, QGraphicsItem *parent)
|
||||||
: QGraphicsPathItem(parent)
|
: PathItem(parent)
|
||||||
{
|
{
|
||||||
QVector<QPointF> t;
|
const QVector<Trackpoint> &t = track.track();
|
||||||
QPainterPath path;
|
|
||||||
|
|
||||||
track.track(t);
|
|
||||||
Q_ASSERT(t.count() >= 2);
|
Q_ASSERT(t.count() >= 2);
|
||||||
|
|
||||||
const QPointF &p = t.at(0);
|
const QPointF &p = t.at(0).coordinates();
|
||||||
path.moveTo(ll2mercator(QPointF(p.x(), -p.y())));
|
_path.moveTo(ll2mercator(QPointF(p.x(), -p.y())));
|
||||||
for (int i = 1; i < t.size(); i++) {
|
for (int i = 1; i < t.size(); i++) {
|
||||||
const QPointF &p = t.at(i);
|
const QPointF &p = t.at(i).coordinates();
|
||||||
path.lineTo(ll2mercator(QPointF(p.x(), -p.y())));
|
_path.lineTo(ll2mercator(QPointF(p.x(), -p.y())));
|
||||||
}
|
}
|
||||||
|
|
||||||
_units = Metric;
|
updateShape();
|
||||||
|
|
||||||
_date = track.date();
|
_date = track.date();
|
||||||
_distance = track.distance();
|
_distance = track.distance();
|
||||||
_time = track.time();
|
_time = track.time();
|
||||||
|
|
||||||
setPath(path);
|
_marker->setPos(_path.pointAtPercent(0));
|
||||||
|
|
||||||
setToolTip(toolTip());
|
setToolTip(toolTip());
|
||||||
setCursor(Qt::ArrowCursor);
|
|
||||||
|
|
||||||
updateShape();
|
|
||||||
|
|
||||||
QBrush brush(Qt::SolidPattern);
|
|
||||||
QPen pen(brush, TRACK_WIDTH);
|
|
||||||
setPen(pen);
|
|
||||||
}
|
|
||||||
|
|
||||||
void TrackItem::setScale(qreal scale)
|
|
||||||
{
|
|
||||||
QGraphicsPathItem::setScale(scale);
|
|
||||||
updateShape();
|
|
||||||
|
|
||||||
QPen p(pen());
|
|
||||||
p.setWidthF(TRACK_WIDTH * 1.0/scale);
|
|
||||||
setPen(p);
|
|
||||||
}
|
|
||||||
|
|
||||||
void TrackItem::setColor(const QColor &color)
|
|
||||||
{
|
|
||||||
QPen p(pen());
|
|
||||||
p.setColor(color);
|
|
||||||
setPen(p);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void TrackItem::setUnits(enum Units units)
|
void TrackItem::setUnits(enum Units units)
|
||||||
{
|
{
|
||||||
_units = units;
|
PathItem::setUnits(units);
|
||||||
setToolTip(toolTip());
|
setToolTip(toolTip());
|
||||||
}
|
}
|
||||||
|
@ -1,32 +1,26 @@
|
|||||||
#ifndef TRACKITEM_H
|
#ifndef TRACKITEM_H
|
||||||
#define TRACKITEM_H
|
#define TRACKITEM_H
|
||||||
|
|
||||||
#include <QGraphicsPathItem>
|
|
||||||
#include <QDateTime>
|
#include <QDateTime>
|
||||||
#include "units.h"
|
#include <QPen>
|
||||||
#include "track.h"
|
#include "track.h"
|
||||||
|
#include "pathitem.h"
|
||||||
|
|
||||||
class TrackItem : public QGraphicsPathItem
|
|
||||||
|
class TrackItem : public PathItem
|
||||||
{
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
TrackItem(const Track &track, QGraphicsItem *parent = 0);
|
TrackItem(const Track &track, QGraphicsItem *parent = 0);
|
||||||
|
|
||||||
QPainterPath shape() const {return _shape;}
|
|
||||||
void setScale(qreal scale);
|
|
||||||
|
|
||||||
void setUnits(enum Units units);
|
void setUnits(enum Units units);
|
||||||
void setColor(const QColor &color);
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void updateShape();
|
|
||||||
QString toolTip();
|
QString toolTip();
|
||||||
|
|
||||||
QPainterPath _shape;
|
|
||||||
|
|
||||||
Units _units;
|
|
||||||
QDateTime _date;
|
QDateTime _date;
|
||||||
qreal _time;
|
qreal _time;
|
||||||
qreal _distance;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // TRACKITEM_H
|
#endif // TRACKITEM_H
|
||||||
|
@ -13,10 +13,14 @@ enum Units {
|
|||||||
#define MS2MIH 2.236936290000 // m/s -> mi/h
|
#define MS2MIH 2.236936290000 // m/s -> mi/h
|
||||||
#define FT2MI 0.000189393939 // ft -> mi
|
#define FT2MI 0.000189393939 // ft -> mi
|
||||||
#define MM2IN 0.039370100000 // mm -> in
|
#define MM2IN 0.039370100000 // mm -> in
|
||||||
|
#define H2S 0.000277777778 // h -> s
|
||||||
|
#define MIN2S 0.016666666667 // min -> s
|
||||||
|
|
||||||
#define KMINM 1000 // 1 km in m
|
#define KMINM 1000 // 1 km in m
|
||||||
#define MIINFT 5280 // 1 mi in ft
|
#define MIINFT 5280 // 1 mi in ft
|
||||||
#define MIINM 1609.344 // 1mi in m
|
#define MIINM 1609.344 // 1 mi in m
|
||||||
|
#define MININS 60 // 1 min in s
|
||||||
|
#define HINS 3600 // 1 hins
|
||||||
|
|
||||||
#define C2FS 1.8 // Celsius to Farenheit - scale
|
#define C2FS 1.8 // Celsius to Farenheit - scale
|
||||||
#define C2FO 32 // Celsius to Farenheit - offset
|
#define C2FO 32 // Celsius to Farenheit - offset
|
||||||
|
@ -31,6 +31,8 @@ public:
|
|||||||
void setElevation(qreal elevation) {_elevation = elevation;}
|
void setElevation(qreal elevation) {_elevation = elevation;}
|
||||||
void setGeoidHeight(qreal geoidHeight) {_geoidHeight = geoidHeight;}
|
void setGeoidHeight(qreal geoidHeight) {_geoidHeight = geoidHeight;}
|
||||||
|
|
||||||
|
bool hasElevation() const {return !std::isnan(_elevation);}
|
||||||
|
|
||||||
bool operator==(const Waypoint &other) const
|
bool operator==(const Waypoint &other) const
|
||||||
{return this->_name == other._name
|
{return this->_name == other._name
|
||||||
&& this->_coordinates == other._coordinates;}
|
&& this->_coordinates == other._coordinates;}
|
||||||
|
@ -7,12 +7,15 @@
|
|||||||
#include "waypointitem.h"
|
#include "waypointitem.h"
|
||||||
|
|
||||||
|
|
||||||
#define POINT_SIZE 8
|
#define POINT_SIZE 8
|
||||||
|
#define HOVER_SIZE 10
|
||||||
|
|
||||||
QString WaypointItem::toolTip()
|
QString WaypointItem::toolTip()
|
||||||
{
|
{
|
||||||
ToolTip tt;
|
ToolTip tt;
|
||||||
|
|
||||||
|
if (!_waypoint.name().isEmpty() && !_showLabel)
|
||||||
|
tt.insert(qApp->translate("WaypointItem", "Name"), _waypoint.name());
|
||||||
tt.insert(qApp->translate("WaypointItem", "Coordinates"),
|
tt.insert(qApp->translate("WaypointItem", "Coordinates"),
|
||||||
::coordinates(_waypoint.coordinates()));
|
::coordinates(_waypoint.coordinates()));
|
||||||
if (!std::isnan(_waypoint.elevation()))
|
if (!std::isnan(_waypoint.elevation()))
|
||||||
@ -32,28 +35,42 @@ WaypointItem::WaypointItem(const Waypoint &waypoint, QGraphicsItem *parent)
|
|||||||
: QGraphicsItem(parent)
|
: QGraphicsItem(parent)
|
||||||
{
|
{
|
||||||
_units = Metric;
|
_units = Metric;
|
||||||
|
_showLabel = true;
|
||||||
|
_hover = false;
|
||||||
|
|
||||||
_waypoint = waypoint;
|
_waypoint = waypoint;
|
||||||
_coordinates = ll2mercator(QPointF(waypoint.coordinates().x(),
|
_coordinates = ll2mercator(QPointF(waypoint.coordinates().x(),
|
||||||
-waypoint.coordinates().y()));
|
-waypoint.coordinates().y()));
|
||||||
|
|
||||||
updateBoundingRect();
|
updateShape();
|
||||||
|
|
||||||
setPos(_coordinates);
|
setPos(_coordinates);
|
||||||
setToolTip(toolTip());
|
setToolTip(toolTip());
|
||||||
setCursor(Qt::ArrowCursor);
|
setCursor(Qt::ArrowCursor);
|
||||||
|
setAcceptHoverEvents(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
void WaypointItem::updateBoundingRect()
|
void WaypointItem::updateShape()
|
||||||
{
|
{
|
||||||
QFont font;
|
QPainterPath p;
|
||||||
font.setPixelSize(FONT_SIZE);
|
qreal pointSize = _hover ? HOVER_SIZE : POINT_SIZE;
|
||||||
font.setFamily(FONT_FAMILY);
|
|
||||||
QFontMetrics fm(font);
|
|
||||||
QRect ts = fm.tightBoundingRect(_waypoint.name());
|
|
||||||
|
|
||||||
_boundingRect = QRectF(-POINT_SIZE/2, -POINT_SIZE/2, ts.width()
|
if (_showLabel) {
|
||||||
+ POINT_SIZE, ts.height() + fm.descent() + POINT_SIZE);
|
QFont font;
|
||||||
|
font.setPixelSize(FONT_SIZE);
|
||||||
|
font.setFamily(FONT_FAMILY);
|
||||||
|
if (_hover)
|
||||||
|
font.setBold(true);
|
||||||
|
QFontMetrics fm(font);
|
||||||
|
QRect ts = fm.tightBoundingRect(_waypoint.name());
|
||||||
|
|
||||||
|
p.addRect(-pointSize/2, -pointSize/2, pointSize, pointSize);
|
||||||
|
p.addRect(pointSize/2, pointSize/2,
|
||||||
|
ts.width(), ts.height() + fm.descent());
|
||||||
|
} else
|
||||||
|
p.addRect(-pointSize/2, -pointSize/2, pointSize, pointSize);
|
||||||
|
|
||||||
|
_shape = p;
|
||||||
}
|
}
|
||||||
|
|
||||||
void WaypointItem::paint(QPainter *painter,
|
void WaypointItem::paint(QPainter *painter,
|
||||||
@ -61,22 +78,30 @@ void WaypointItem::paint(QPainter *painter,
|
|||||||
{
|
{
|
||||||
Q_UNUSED(option);
|
Q_UNUSED(option);
|
||||||
Q_UNUSED(widget);
|
Q_UNUSED(widget);
|
||||||
QFont font;
|
|
||||||
font.setPixelSize(FONT_SIZE);
|
|
||||||
font.setFamily(FONT_FAMILY);
|
|
||||||
QFontMetrics fm(font);
|
|
||||||
QRect ts = fm.tightBoundingRect(_waypoint.name());
|
|
||||||
|
|
||||||
painter->setFont(font);
|
qreal pointSize = _hover ? HOVER_SIZE : POINT_SIZE;
|
||||||
painter->drawText(POINT_SIZE/2 - qMax(ts.x(), 0), POINT_SIZE/2 + ts.height(),
|
|
||||||
_waypoint.name());
|
if (_showLabel) {
|
||||||
|
QFont font;
|
||||||
|
font.setPixelSize(FONT_SIZE);
|
||||||
|
font.setFamily(FONT_FAMILY);
|
||||||
|
if (_hover)
|
||||||
|
font.setBold(true);
|
||||||
|
QFontMetrics fm(font);
|
||||||
|
QRect ts = fm.tightBoundingRect(_waypoint.name());
|
||||||
|
|
||||||
|
painter->setFont(font);
|
||||||
|
painter->drawText(pointSize/2 - qMax(ts.x(), 0), pointSize/2
|
||||||
|
+ ts.height(), _waypoint.name());
|
||||||
|
}
|
||||||
|
|
||||||
painter->setBrush(Qt::SolidPattern);
|
painter->setBrush(Qt::SolidPattern);
|
||||||
painter->drawEllipse(-POINT_SIZE/2, -POINT_SIZE/2, POINT_SIZE, POINT_SIZE);
|
painter->drawEllipse(-pointSize/2, -pointSize/2, pointSize, pointSize);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
painter->setPen(Qt::red);
|
painter->setPen(Qt::red);
|
||||||
painter->setBrush(Qt::NoBrush);
|
painter->setBrush(Qt::NoBrush);
|
||||||
painter->drawRect(boundingRect());
|
painter->drawPath(_shape);
|
||||||
*/
|
*/
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -90,3 +115,31 @@ void WaypointItem::setUnits(enum Units units)
|
|||||||
_units = units;
|
_units = units;
|
||||||
setToolTip(toolTip());
|
setToolTip(toolTip());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void WaypointItem::showLabel(bool show)
|
||||||
|
{
|
||||||
|
prepareGeometryChange();
|
||||||
|
_showLabel = show;
|
||||||
|
updateShape();
|
||||||
|
setToolTip(toolTip());
|
||||||
|
}
|
||||||
|
|
||||||
|
void WaypointItem::hoverEnterEvent(QGraphicsSceneHoverEvent *event)
|
||||||
|
{
|
||||||
|
Q_UNUSED(event);
|
||||||
|
|
||||||
|
prepareGeometryChange();
|
||||||
|
_hover = true;
|
||||||
|
updateShape();
|
||||||
|
setZValue(zValue() + 1.0);
|
||||||
|
}
|
||||||
|
|
||||||
|
void WaypointItem::hoverLeaveEvent(QGraphicsSceneHoverEvent *event)
|
||||||
|
{
|
||||||
|
Q_UNUSED(event);
|
||||||
|
|
||||||
|
prepareGeometryChange();
|
||||||
|
_hover = false;
|
||||||
|
updateShape();
|
||||||
|
setZValue(zValue() - 1.0);
|
||||||
|
}
|
||||||
|
@ -15,19 +15,27 @@ public:
|
|||||||
|
|
||||||
void setUnits(enum Units units);
|
void setUnits(enum Units units);
|
||||||
void setScale(qreal scale);
|
void setScale(qreal scale);
|
||||||
|
void showLabel(bool show);
|
||||||
|
|
||||||
QRectF boundingRect() const {return _boundingRect;}
|
QPainterPath shape() const {return _shape;}
|
||||||
|
QRectF boundingRect() const {return _shape.boundingRect();}
|
||||||
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option,
|
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option,
|
||||||
QWidget *widget);
|
QWidget *widget);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void updateBoundingRect();
|
void hoverEnterEvent(QGraphicsSceneHoverEvent *event);
|
||||||
|
void hoverLeaveEvent(QGraphicsSceneHoverEvent *event);
|
||||||
|
|
||||||
|
void updateShape();
|
||||||
QString toolTip();
|
QString toolTip();
|
||||||
|
|
||||||
QRectF _boundingRect;
|
QPainterPath _shape;
|
||||||
QPointF _coordinates;
|
QPointF _coordinates;
|
||||||
Waypoint _waypoint;
|
Waypoint _waypoint;
|
||||||
Units _units;
|
Units _units;
|
||||||
|
|
||||||
|
bool _hover;
|
||||||
|
bool _showLabel;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // WAYPOINTITEM_H
|
#endif // WAYPOINTITEM_H
|
||||||
|
Reference in New Issue
Block a user