mirror of
https://github.com/tumic0/GPXSee.git
synced 2025-07-01 13:29:16 +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
|
||||
VERSION = 2.17
|
||||
VERSION = 2.20
|
||||
QT += core \
|
||||
gui \
|
||||
network
|
||||
@ -28,7 +28,6 @@ HEADERS += src/config.h \
|
||||
src/units.h \
|
||||
src/scaleitem.h \
|
||||
src/waypoint.h \
|
||||
src/trackview.h \
|
||||
src/track.h \
|
||||
src/graphview.h \
|
||||
src/trackpoint.h \
|
||||
@ -47,7 +46,13 @@ HEADERS += src/config.h \
|
||||
src/graphtab.h \
|
||||
src/misc.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 \
|
||||
src/gui.cpp \
|
||||
src/gpx.cpp \
|
||||
@ -66,7 +71,6 @@ SOURCES += src/main.cpp \
|
||||
src/maplist.cpp \
|
||||
src/downloader.cpp \
|
||||
src/scaleitem.cpp \
|
||||
src/trackview.cpp \
|
||||
src/track.cpp \
|
||||
src/graphview.cpp \
|
||||
src/waypointitem.cpp \
|
||||
@ -82,7 +86,12 @@ SOURCES += src/main.cpp \
|
||||
src/misc.cpp \
|
||||
src/waypoint.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
|
||||
TRANSLATIONS = lang/gpxsee_cs.ts
|
||||
macx {
|
||||
|
@ -14,6 +14,7 @@
|
||||
<file>icons/arrow-left-double.png</file>
|
||||
<file>icons/arrow-right-double.png</file>
|
||||
<file>icons/view-fullscreen.png</file>
|
||||
<file>icons/office-chart-line-stacked.png</file>
|
||||
<file>lang/gpxsee_cs.qm</file>
|
||||
</qresource>
|
||||
</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>
|
||||
<name>ElevationGraph</name>
|
||||
<message>
|
||||
<location filename="../src/elevationgraph.cpp" line="14"/>
|
||||
<source>Distance</source>
|
||||
<translation>Vzdálenost</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/elevationgraph.cpp" line="15"/>
|
||||
<location filename="../src/elevationgraph.h" line="15"/>
|
||||
<location filename="../src/elevationgraph.cpp" line="48"/>
|
||||
<location filename="../src/elevationgraph.h" line="13"/>
|
||||
<source>Elevation</source>
|
||||
<translation>Výška</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/elevationgraph.cpp" line="81"/>
|
||||
<source>km</source>
|
||||
<translation>km</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/elevationgraph.cpp" line="78"/>
|
||||
<location filename="../src/elevationgraph.cpp" line="98"/>
|
||||
<location filename="../src/elevationgraph.cpp" line="141"/>
|
||||
<source>m</source>
|
||||
<translation>m</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/elevationgraph.cpp" line="22"/>
|
||||
<location filename="../src/elevationgraph.cpp" line="58"/>
|
||||
<source>Ascent</source>
|
||||
<translation>Stoupání</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/elevationgraph.cpp" line="24"/>
|
||||
<location filename="../src/elevationgraph.cpp" line="60"/>
|
||||
<source>Descent</source>
|
||||
<translation>Klesání</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/elevationgraph.cpp" line="28"/>
|
||||
<location filename="../src/elevationgraph.cpp" line="64"/>
|
||||
<source>Minimum</source>
|
||||
<translation>Minimum</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/elevationgraph.cpp" line="89"/>
|
||||
<source>mi</source>
|
||||
<translation>mi</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/elevationgraph.cpp" line="86"/>
|
||||
<location filename="../src/elevationgraph.cpp" line="101"/>
|
||||
<location filename="../src/elevationgraph.cpp" line="144"/>
|
||||
<source>ft</source>
|
||||
<translation>ft</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/elevationgraph.cpp" line="26"/>
|
||||
<location filename="../src/elevationgraph.cpp" line="62"/>
|
||||
<source>Maximum</source>
|
||||
<translation>Maximum</translation>
|
||||
</message>
|
||||
@ -163,331 +146,392 @@
|
||||
<context>
|
||||
<name>GUI</name>
|
||||
<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>
|
||||
<translation>Program GPXSee je distribuován pod podmínkami licence GNU General Public License verze 3. Pro více informací navštivte stránky programu na adrese </translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/gui.cpp" line="510"/>
|
||||
<location filename="../src/gui.cpp" line="582"/>
|
||||
<source>Open file</source>
|
||||
<translation>Otevřít soubor</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/gui.cpp" line="586"/>
|
||||
<location filename="../src/gui.cpp" line="661"/>
|
||||
<source>Open POI file</source>
|
||||
<translation>Otevřít POI soubor</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/gui.cpp" line="194"/>
|
||||
<location filename="../src/gui.cpp" line="206"/>
|
||||
<source>Open</source>
|
||||
<translation>Otevřít</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/gui.cpp" line="178"/>
|
||||
<location filename="../src/gui.cpp" line="190"/>
|
||||
<source>Quit</source>
|
||||
<translation>Ukončit</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/gui.cpp" line="186"/>
|
||||
<location filename="../src/gui.cpp" line="462"/>
|
||||
<location filename="../src/gui.cpp" line="463"/>
|
||||
<location filename="../src/gui.cpp" line="198"/>
|
||||
<location filename="../src/gui.cpp" line="534"/>
|
||||
<location filename="../src/gui.cpp" line="535"/>
|
||||
<source>Keyboard controls</source>
|
||||
<translation>Ovládací klávesy</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/gui.cpp" line="210"/>
|
||||
<location filename="../src/gui.cpp" line="222"/>
|
||||
<source>Close</source>
|
||||
<translation>Zavřít</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/gui.cpp" line="216"/>
|
||||
<location filename="../src/gui.cpp" line="228"/>
|
||||
<source>Reload</source>
|
||||
<translation>Znovu načíst</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/gui.cpp" line="378"/>
|
||||
<location filename="../src/gui.cpp" line="449"/>
|
||||
<source>Show</source>
|
||||
<translation>Zobrazit</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/gui.cpp" line="317"/>
|
||||
<location filename="../src/gui.cpp" line="372"/>
|
||||
<location filename="../src/gui.cpp" line="373"/>
|
||||
<location filename="../src/gui.cpp" line="443"/>
|
||||
<source>File</source>
|
||||
<translation>Soubor</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/gui.cpp" line="184"/>
|
||||
<location filename="../src/gui.cpp" line="485"/>
|
||||
<location filename="../src/gui.cpp" line="486"/>
|
||||
<location filename="../src/gui.cpp" line="196"/>
|
||||
<location filename="../src/gui.cpp" line="557"/>
|
||||
<location filename="../src/gui.cpp" line="558"/>
|
||||
<source>Data sources</source>
|
||||
<translation>Zdroje dat</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/gui.cpp" line="224"/>
|
||||
<location filename="../src/gui.cpp" line="236"/>
|
||||
<source>Load POI file</source>
|
||||
<translation>Nahrát POI soubor</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/gui.cpp" line="227"/>
|
||||
<location filename="../src/gui.cpp" line="239"/>
|
||||
<source>Close POI files</source>
|
||||
<translation>Zavřit POI soubory</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/gui.cpp" line="229"/>
|
||||
<location filename="../src/gui.cpp" line="241"/>
|
||||
<source>Overlap POIs</source>
|
||||
<translation>Překrývat POI</translation>
|
||||
</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>
|
||||
<translation>Zobrazit POI</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/gui.cpp" line="242"/>
|
||||
<location filename="../src/gui.cpp" line="259"/>
|
||||
<source>Show map</source>
|
||||
<translation>Zobrazit mapu</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/gui.cpp" line="248"/>
|
||||
<location filename="../src/gui.cpp" line="265"/>
|
||||
<source>Clear tile cache</source>
|
||||
<translation>Vymazat mezipaměť dlaždic</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/gui.cpp" line="257"/>
|
||||
<location filename="../src/gui.cpp" line="261"/>
|
||||
<location filename="../src/gui.cpp" line="472"/>
|
||||
<location filename="../src/gui.cpp" line="274"/>
|
||||
<location filename="../src/gui.cpp" line="278"/>
|
||||
<location filename="../src/gui.cpp" line="544"/>
|
||||
<source>Next map</source>
|
||||
<translation>Následující mapa</translation>
|
||||
</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>
|
||||
<translation>Zobrazovat grafy</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/gui.cpp" line="274"/>
|
||||
<location filename="../src/gui.cpp" line="330"/>
|
||||
<source>Show toolbars</source>
|
||||
<translation>Zobrazovat nástrojové lišty</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/gui.cpp" line="280"/>
|
||||
<location filename="../src/gui.cpp" line="336"/>
|
||||
<source>Metric</source>
|
||||
<translation>Metrické</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/gui.cpp" line="285"/>
|
||||
<location filename="../src/gui.cpp" line="341"/>
|
||||
<source>Imperial</source>
|
||||
<translation>Imperiální</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/gui.cpp" line="291"/>
|
||||
<location filename="../src/gui.cpp" line="347"/>
|
||||
<source>Fullscreen mode</source>
|
||||
<translation>Celoobrazovkový režim</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/gui.cpp" line="299"/>
|
||||
<location filename="../src/gui.cpp" line="355"/>
|
||||
<source>Next</source>
|
||||
<translation>Následující</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/gui.cpp" line="302"/>
|
||||
<location filename="../src/gui.cpp" line="358"/>
|
||||
<source>Previous</source>
|
||||
<translation>Předchozí</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/gui.cpp" line="306"/>
|
||||
<location filename="../src/gui.cpp" line="362"/>
|
||||
<source>Last</source>
|
||||
<translation>Poslední</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/gui.cpp" line="309"/>
|
||||
<location filename="../src/gui.cpp" line="365"/>
|
||||
<source>First</source>
|
||||
<translation>První</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/gui.cpp" line="331"/>
|
||||
<location filename="../src/gui.cpp" line="387"/>
|
||||
<source>Map</source>
|
||||
<translation>Mapa</translation>
|
||||
</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>
|
||||
<translation>POI</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/gui.cpp" line="339"/>
|
||||
<location filename="../src/gui.cpp" line="401"/>
|
||||
<source>POI files</source>
|
||||
<translation>POI soubory</translation>
|
||||
</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>
|
||||
<translation>Nastavení</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/gui.cpp" line="350"/>
|
||||
<location filename="../src/gui.cpp" line="422"/>
|
||||
<source>Units</source>
|
||||
<translation>Jednotky</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/gui.cpp" line="359"/>
|
||||
<location filename="../src/gui.cpp" line="430"/>
|
||||
<source>Help</source>
|
||||
<translation>Nápověda</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/gui.cpp" line="474"/>
|
||||
<location filename="../src/gui.cpp" line="546"/>
|
||||
<source>Previous map</source>
|
||||
<translation>Předchozí mapa</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/gui.cpp" line="672"/>
|
||||
<location filename="../src/gui.cpp" line="675"/>
|
||||
<location filename="../src/gui.cpp" line="663"/>
|
||||
<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>
|
||||
<translation>Datum</translation>
|
||||
</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>
|
||||
<translation>Nejsou načteny žádné GPX soubory</translation>
|
||||
</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>
|
||||
<translation>Následující soubor</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/gui.cpp" line="442"/>
|
||||
<location filename="../src/gui.cpp" line="514"/>
|
||||
<source>Version </source>
|
||||
<translation>Verze </translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/gui.cpp" line="199"/>
|
||||
<location filename="../src/gui.cpp" line="211"/>
|
||||
<source>Print...</source>
|
||||
<translation>Tisknout...</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/gui.cpp" line="204"/>
|
||||
<location filename="../src/gui.cpp" line="216"/>
|
||||
<source>Export to PDF...</source>
|
||||
<translation>Exportovat do PDF...</translation>
|
||||
</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>
|
||||
<translation>Předchozí soubor</translation>
|
||||
</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>
|
||||
<translation>První soubor</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/gui.cpp" line="469"/>
|
||||
<location filename="../src/gui.cpp" line="541"/>
|
||||
<source>Last file</source>
|
||||
<translation>Poslední soubor</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/gui.cpp" line="470"/>
|
||||
<location filename="../src/gui.cpp" line="542"/>
|
||||
<source>Append modifier</source>
|
||||
<translation>Modifikátor nahradit/přidat</translation>
|
||||
</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>
|
||||
<translation>URL mapových zdrojů (dlaždic) jsou načteny při startu programu z následujícího souboru:</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/gui.cpp" line="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>
|
||||
<translation>Formát souboru je jeden mapový záznam na řádku, kde mapový záznam sestává ze jména mapy a URL dlaždic navzájem oddělených tabulátorem. Souřadnice dlaždice jsou v URL nahrazeny řetězci $x a $y, úroven přiblížení (zoom) pak řetězcem $z. Příklad:</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/gui.cpp" line="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>
|
||||
<translation>POI soubory, které se mají automaticky nahrát při startu programu jsou načítány z následujícího adresáře:</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/gui.cpp" line="511"/>
|
||||
<location filename="../src/gui.cpp" line="583"/>
|
||||
<source>GPX files (*.gpx);;All files (*)</source>
|
||||
<translation>Soubory GPX (*.gpx);;Všechny soubory (*)</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/gui.cpp" line="577"/>
|
||||
<location filename="../src/gui.cpp" line="603"/>
|
||||
<location filename="../src/gui.cpp" line="652"/>
|
||||
<location filename="../src/gui.cpp" line="680"/>
|
||||
<source>Line: %1</source>
|
||||
<translation>Řádka: %1</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/gui.cpp" line="587"/>
|
||||
<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"/>
|
||||
<location filename="../src/gui.cpp" line="762"/>
|
||||
<source>Tracks</source>
|
||||
<translation>Počet tras</translation>
|
||||
<translation>Cesty</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/gui.cpp" line="684"/>
|
||||
<source>mi</source>
|
||||
<translation>mi</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/gui.cpp" line="189"/>
|
||||
<location filename="../src/gui.cpp" line="440"/>
|
||||
<location filename="../src/gui.cpp" line="201"/>
|
||||
<location filename="../src/gui.cpp" line="512"/>
|
||||
<source>About GPXSee</source>
|
||||
<translation>O aplikaci GPXSee</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/gui.cpp" line="382"/>
|
||||
<location filename="../src/gui.cpp" line="454"/>
|
||||
<source>Navigation</source>
|
||||
<translation>Navigace</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/gui.cpp" line="488"/>
|
||||
<location filename="../src/gui.cpp" line="560"/>
|
||||
<source>Map sources</source>
|
||||
<translation>Mapové zdroje</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/gui.cpp" line="499"/>
|
||||
<location filename="../src/gui.cpp" line="571"/>
|
||||
<source>POIs</source>
|
||||
<translation>POI body</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/gui.cpp" line="683"/>
|
||||
<location filename="../src/gui.cpp" line="686"/>
|
||||
<location filename="../src/gui.cpp" line="316"/>
|
||||
<location filename="../src/gui.cpp" line="769"/>
|
||||
<source>Distance</source>
|
||||
<translation>Vzdálenost</translation>
|
||||
</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>
|
||||
<translation>Čas</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/gui.cpp" line="860"/>
|
||||
<source>%1 tracks</source>
|
||||
<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"/>
|
||||
<location filename="../src/gui.cpp" line="654"/>
|
||||
<location filename="../src/gui.cpp" line="681"/>
|
||||
<source>Error</source>
|
||||
<translation>Chyba</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/gui.cpp" line="574"/>
|
||||
<location filename="../src/gui.cpp" line="649"/>
|
||||
<source>Error loading GPX file:
|
||||
%1</source>
|
||||
<translation>Soubor GPX nelze otevřít:
|
||||
%1</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/gui.cpp" line="600"/>
|
||||
<location filename="../src/gui.cpp" line="677"/>
|
||||
<source>Error loading POI file:
|
||||
%1</source>
|
||||
<translation>Soubor POI nelze otevřít:
|
||||
@ -495,53 +539,76 @@
|
||||
</message>
|
||||
</context>
|
||||
<context>
|
||||
<name>HeartRateGraph</name>
|
||||
<name>GraphView</name>
|
||||
<message>
|
||||
<location filename="../src/heartrategraph.cpp" line="10"/>
|
||||
<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"/>
|
||||
<location filename="../src/graphview.cpp" line="111"/>
|
||||
<source>m</source>
|
||||
<translation>m</translation>
|
||||
</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>
|
||||
<translation>ft</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/heartrategraph.cpp" line="86"/>
|
||||
<location filename="../src/graphview.cpp" line="122"/>
|
||||
<source>mi</source>
|
||||
<translation>mi</translation>
|
||||
</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>
|
||||
<name>Misc</name>
|
||||
@ -569,137 +636,95 @@
|
||||
</message>
|
||||
</context>
|
||||
<context>
|
||||
<name>QObject</name>
|
||||
<name>RouteItem</name>
|
||||
<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>
|
||||
<translation>mi</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/scaleitem.cpp" line="81"/>
|
||||
<location filename="../src/scaleitem.cpp" line="91"/>
|
||||
<source>ft</source>
|
||||
<translation>ft</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/scaleitem.cpp" line="83"/>
|
||||
<location filename="../src/scaleitem.cpp" line="93"/>
|
||||
<source>km</source>
|
||||
<translation>km</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/scaleitem.cpp" line="83"/>
|
||||
<location filename="../src/scaleitem.cpp" line="94"/>
|
||||
<source>m</source>
|
||||
<translation>m</translation>
|
||||
</message>
|
||||
</context>
|
||||
<context>
|
||||
<name>SpeedGraph</name>
|
||||
<message>
|
||||
<location filename="../src/speedgraph.cpp" line="11"/>
|
||||
<source>Distance</source>
|
||||
<translation>Vzdálenost</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/speedgraph.cpp" line="12"/>
|
||||
<location filename="../src/speedgraph.h" line="16"/>
|
||||
<location filename="../src/speedgraph.h" line="14"/>
|
||||
<source>Speed</source>
|
||||
<translation>Rychlost</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/speedgraph.cpp" line="72"/>
|
||||
<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"/>
|
||||
<location filename="../src/speedgraph.cpp" line="74"/>
|
||||
<source>km/h</source>
|
||||
<translation>km/h</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/speedgraph.cpp" line="19"/>
|
||||
<location filename="../src/speedgraph.cpp" line="20"/>
|
||||
<source>Average</source>
|
||||
<translation>Průměr</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/speedgraph.cpp" line="21"/>
|
||||
<location filename="../src/speedgraph.cpp" line="22"/>
|
||||
<source>Maximum</source>
|
||||
<translation>Maximum</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/speedgraph.cpp" line="83"/>
|
||||
<source>mi</source>
|
||||
<translation>mi</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/speedgraph.cpp" line="95"/>
|
||||
<location filename="../src/speedgraph.cpp" line="77"/>
|
||||
<source>mi/h</source>
|
||||
<translation>mi/h</translation>
|
||||
</message>
|
||||
</context>
|
||||
<context>
|
||||
<name>TemperatureGraph</name>
|
||||
<message>
|
||||
<location filename="../src/temperaturegraph.cpp" line="10"/>
|
||||
<source>Distance</source>
|
||||
<translation>Vzdálenost</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/temperaturegraph.cpp" line="11"/>
|
||||
<location filename="../src/temperaturegraph.h" line="15"/>
|
||||
<location filename="../src/temperaturegraph.h" line="13"/>
|
||||
<source>Temperature</source>
|
||||
<translation>Teplota</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/temperaturegraph.cpp" line="18"/>
|
||||
<location filename="../src/temperaturegraph.cpp" line="19"/>
|
||||
<source>Average</source>
|
||||
<translation>Průměr</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/temperaturegraph.cpp" line="20"/>
|
||||
<location filename="../src/temperaturegraph.cpp" line="21"/>
|
||||
<source>Minimum</source>
|
||||
<translation>Minimum</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/temperaturegraph.cpp" line="22"/>
|
||||
<location filename="../src/temperaturegraph.cpp" line="23"/>
|
||||
<source>Maximum</source>
|
||||
<translation>Maximum</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/temperaturegraph.cpp" line="77"/>
|
||||
<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"/>
|
||||
<location filename="../src/temperaturegraph.cpp" line="81"/>
|
||||
<source>C</source>
|
||||
<translation>C</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/temperaturegraph.cpp" line="101"/>
|
||||
<location filename="../src/temperaturegraph.cpp" line="85"/>
|
||||
<source>F</source>
|
||||
<translation>F</translation>
|
||||
</message>
|
||||
@ -707,17 +732,17 @@
|
||||
<context>
|
||||
<name>TrackItem</name>
|
||||
<message>
|
||||
<location filename="../src/trackitem.cpp" line="16"/>
|
||||
<location filename="../src/trackitem.cpp" line="14"/>
|
||||
<source>Distance</source>
|
||||
<translation>Vzdálenost</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/trackitem.cpp" line="19"/>
|
||||
<location filename="../src/trackitem.cpp" line="17"/>
|
||||
<source>Time</source>
|
||||
<translation>Čas</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/trackitem.cpp" line="21"/>
|
||||
<location filename="../src/trackitem.cpp" line="19"/>
|
||||
<source>Date</source>
|
||||
<translation>Datum</translation>
|
||||
</message>
|
||||
@ -725,22 +750,27 @@
|
||||
<context>
|
||||
<name>WaypointItem</name>
|
||||
<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>
|
||||
<translation>Souřadnice</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/waypointitem.cpp" line="19"/>
|
||||
<location filename="../src/waypointitem.cpp" line="22"/>
|
||||
<source>Elevation</source>
|
||||
<translation>Výška</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/waypointitem.cpp" line="22"/>
|
||||
<location filename="../src/waypointitem.cpp" line="25"/>
|
||||
<source>Date</source>
|
||||
<translation>Datum</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/waypointitem.cpp" line="25"/>
|
||||
<location filename="../src/waypointitem.cpp" line="28"/>
|
||||
<source>Description</source>
|
||||
<translation>Popis</translation>
|
||||
</message>
|
||||
|
@ -4,7 +4,7 @@
|
||||
; The name of the installer
|
||||
Name "GPXSee"
|
||||
; Program version
|
||||
!define VERSION "2.17"
|
||||
!define VERSION "2.20"
|
||||
|
||||
; The file to write
|
||||
OutFile "GPXSee-${VERSION}.exe"
|
||||
|
@ -4,7 +4,7 @@
|
||||
; The name of the installer
|
||||
Name "GPXSee"
|
||||
; Program version
|
||||
!define VERSION "2.17"
|
||||
!define VERSION "2.20"
|
||||
|
||||
; The file to write
|
||||
OutFile "GPXSee-${VERSION}_x64.exe"
|
||||
|
@ -2,6 +2,7 @@
|
||||
#include <QTranslator>
|
||||
#include <QLocale>
|
||||
#include <QFileOpenEvent>
|
||||
#include <QNetworkProxyFactory>
|
||||
#include "gui.h"
|
||||
#include "app.h"
|
||||
|
||||
@ -18,6 +19,8 @@ App::App(int &argc, char **argv) : QApplication(argc, argv),
|
||||
setAttribute(Qt::AA_DontShowIconsInMenus);
|
||||
#endif // Q_OS_MAC
|
||||
|
||||
QNetworkProxyFactory::setUseSystemConfiguration(true);
|
||||
|
||||
_gui = new GUI();
|
||||
}
|
||||
|
||||
|
@ -5,6 +5,7 @@
|
||||
#include "axisitem.h"
|
||||
|
||||
|
||||
#define AXIS_WIDTH 1
|
||||
#define TICK 6
|
||||
#define PADDING 6
|
||||
#define XTICKS 15
|
||||
@ -34,6 +35,10 @@ AxisItem::AxisItem(Type type, QGraphicsItem *parent) : QGraphicsItem(parent)
|
||||
{
|
||||
_type = type;
|
||||
_size = 0;
|
||||
|
||||
#ifndef Q_OS_MAC
|
||||
setCacheMode(QGraphicsItem::DeviceCoordinateCache);
|
||||
#endif // Q_OS_MAC
|
||||
}
|
||||
|
||||
void AxisItem::setRange(const RangeF &range)
|
||||
@ -41,6 +46,7 @@ void AxisItem::setRange(const RangeF &range)
|
||||
prepareGeometryChange();
|
||||
_range = range;
|
||||
updateBoundingRect();
|
||||
update();
|
||||
}
|
||||
|
||||
void AxisItem::setSize(qreal size)
|
||||
@ -48,6 +54,7 @@ void AxisItem::setSize(qreal size)
|
||||
prepareGeometryChange();
|
||||
_size = size;
|
||||
updateBoundingRect();
|
||||
update();
|
||||
}
|
||||
|
||||
void AxisItem::setLabel(const QString& label)
|
||||
@ -55,6 +62,7 @@ void AxisItem::setLabel(const QString& label)
|
||||
prepareGeometryChange();
|
||||
_label = label;
|
||||
updateBoundingRect();
|
||||
update();
|
||||
}
|
||||
|
||||
void AxisItem::updateBoundingRect()
|
||||
@ -75,7 +83,7 @@ void AxisItem::updateBoundingRect()
|
||||
if (_type == X) {
|
||||
_boundingRect = QRectF(-ss.width()/2, -TICK/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 {
|
||||
int mtw = 0;
|
||||
QRect ts;
|
||||
@ -88,9 +96,8 @@ void AxisItem::updateBoundingRect()
|
||||
mtw = qMax(ts.width(), mtw);
|
||||
}
|
||||
|
||||
_boundingRect = QRectF(-(ls.height() + mtw + 2*PADDING
|
||||
- fm.descent() + TICK/2), -(_size + es.height()/2
|
||||
+ fm.descent()), ls.height() -fm.descent() + mtw + 2*PADDING
|
||||
_boundingRect = QRectF(-(ls.height() + mtw + 2*PADDING + TICK/2),
|
||||
-(_size + es.height()/2 + fm.descent()), ls.height() + mtw + 2*PADDING
|
||||
+ 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;
|
||||
qreal range = _range.size();
|
||||
qreal val;
|
||||
QPen pen = QPen(Qt::black, AXIS_WIDTH);
|
||||
|
||||
|
||||
painter->setFont(font);
|
||||
painter->setPen(pen);
|
||||
|
||||
ls = fm.tightBoundingRect(_label);
|
||||
|
||||
|
@ -1,97 +1,140 @@
|
||||
#include <cmath>
|
||||
#include "config.h"
|
||||
#include "gpx.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)
|
||||
{
|
||||
_ascent = 0;
|
||||
_descent = 0;
|
||||
_trackAscent = 0;
|
||||
_routeAscent = 0;
|
||||
_trackDescent = 0;
|
||||
_routeDescent = 0;
|
||||
_trackMin = NAN;
|
||||
_trackMax = NAN;
|
||||
_routeMin = NAN;
|
||||
_routeMax = NAN;
|
||||
|
||||
_showRoutes = true;
|
||||
_showTracks = true;
|
||||
|
||||
_units = Metric;
|
||||
|
||||
setYUnits();
|
||||
setXLabel(tr("Distance"));
|
||||
setYLabel(tr("Elevation"));
|
||||
|
||||
setMinYRange(50.0);
|
||||
}
|
||||
|
||||
void ElevationGraph::addInfo()
|
||||
void ElevationGraph::setInfo()
|
||||
{
|
||||
GraphView::addInfo(tr("Ascent"), QString::number(_ascent * yScale(), 'f', 0)
|
||||
+ UNIT_SPACE + yUnits());
|
||||
GraphView::addInfo(tr("Descent"), QString::number(_descent * yScale(), 'f',
|
||||
0) + UNIT_SPACE + yUnits());
|
||||
GraphView::addInfo(tr("Maximum"), QString::number(max() * yScale(), 'f', 0)
|
||||
+ UNIT_SPACE + yUnits());
|
||||
GraphView::addInfo(tr("Minimum"), QString::number(min() * yScale(), 'f', 0)
|
||||
+ UNIT_SPACE + yUnits());
|
||||
if (std::isnan(max()) || std::isnan(min()))
|
||||
clearInfo();
|
||||
else {
|
||||
GraphView::addInfo(tr("Ascent"), QString::number(ascent() * yScale(),
|
||||
'f', 0) + UNIT_SPACE + yUnits());
|
||||
GraphView::addInfo(tr("Descent"), QString::number(descent() * yScale(),
|
||||
'f', 0) + UNIT_SPACE + yUnits());
|
||||
GraphView::addInfo(tr("Maximum"), QString::number(max() * yScale(), 'f',
|
||||
0) + UNIT_SPACE + yUnits());
|
||||
GraphView::addInfo(tr("Minimum"), QString::number(min() * yScale(), 'f',
|
||||
0) + UNIT_SPACE + yUnits());
|
||||
}
|
||||
}
|
||||
|
||||
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();
|
||||
}
|
||||
|
||||
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()
|
||||
{
|
||||
_ascent = 0;
|
||||
_descent = 0;
|
||||
_trackAscent = 0;
|
||||
_routeAscent = 0;
|
||||
_trackDescent = 0;
|
||||
_routeDescent = 0;
|
||||
_trackMin = NAN;
|
||||
_trackMax = NAN;
|
||||
_routeMin = NAN;
|
||||
_routeMax = NAN;
|
||||
|
||||
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()
|
||||
{
|
||||
if (_units == Metric) {
|
||||
@ -106,9 +149,86 @@ void ElevationGraph::setYUnits()
|
||||
void ElevationGraph::setUnits(enum Units units)
|
||||
{
|
||||
_units = units;
|
||||
setXUnits();
|
||||
setYUnits();
|
||||
|
||||
clearInfo();
|
||||
addInfo();
|
||||
setYUnits();
|
||||
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"
|
||||
|
||||
class GPX;
|
||||
|
||||
class ElevationGraph : public GraphTab
|
||||
{
|
||||
Q_OBJECT
|
||||
@ -13,22 +11,32 @@ public:
|
||||
ElevationGraph(QWidget *parent = 0);
|
||||
|
||||
QString label() const {return tr("Elevation");}
|
||||
void loadGPX(const GPX &gpx);
|
||||
void loadGPX(const GPX &gpx, const QList<PathItem *> &paths);
|
||||
void clear();
|
||||
void setUnits(enum Units units);
|
||||
void showTracks(bool show);
|
||||
void showRoutes(bool show);
|
||||
|
||||
private:
|
||||
qreal ascent() const {return _ascent;}
|
||||
qreal descent() const {return _descent;}
|
||||
qreal max() const {return bounds().bottom();}
|
||||
qreal min() const {return bounds().top();}
|
||||
enum Type {Track, Route};
|
||||
|
||||
qreal max() const;
|
||||
qreal min() const;
|
||||
qreal ascent() const;
|
||||
qreal descent() const;
|
||||
|
||||
void setXUnits();
|
||||
void setYUnits();
|
||||
void addInfo();
|
||||
void setInfo();
|
||||
|
||||
void 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;
|
||||
bool _showTracks, _showRoutes;
|
||||
};
|
||||
|
||||
#endif // ELEVATIONGRAPH_H
|
||||
|
@ -91,6 +91,7 @@ ExportDialog::ExportDialog(QPrinter *printer, QWidget *parent)
|
||||
line->setFrameShadow(QFrame::Sunken);
|
||||
pageSetupLayout->addRow(line);
|
||||
pageSetupLayout->addRow(tr("File:"), _fileSelect);
|
||||
pageSetupLayout->setFieldGrowthPolicy(QFormLayout::ExpandingFieldsGrow);
|
||||
#else // Q_OS_MAC
|
||||
pageSetupBox->setLayout(pageSetupLayout);
|
||||
#endif // Q_OS_MAC
|
||||
|
@ -1,4 +1,5 @@
|
||||
#include <QPushButton>
|
||||
#include <QToolButton>
|
||||
#include <QFileDialog>
|
||||
#include <QHBoxLayout>
|
||||
#include <QFileInfo>
|
||||
@ -12,7 +13,13 @@ FileSelectWidget::FileSelectWidget(QWidget *parent) : QWidget(parent)
|
||||
QFontMetrics fm(QApplication::font());
|
||||
_edit = new QLineEdit();
|
||||
_edit->setMinimumWidth(fm.boundingRect(QDir::homePath()).width());
|
||||
_button = new QPushButton(tr("Browse..."));
|
||||
#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()));
|
||||
|
||||
QHBoxLayout *layout = new QHBoxLayout();
|
||||
@ -20,6 +27,9 @@ FileSelectWidget::FileSelectWidget(QWidget *parent) : QWidget(parent)
|
||||
layout->addWidget(_edit);
|
||||
layout->addWidget(_button);
|
||||
setLayout(layout);
|
||||
|
||||
QSizePolicy p(QSizePolicy::MinimumExpanding, QSizePolicy::Fixed);
|
||||
setSizePolicy(p);
|
||||
}
|
||||
|
||||
void FileSelectWidget::browse()
|
||||
|
@ -5,6 +5,7 @@
|
||||
#include <QLineEdit>
|
||||
|
||||
class QPushButton;
|
||||
class QToolButton;
|
||||
|
||||
class FileSelectWidget : public QWidget
|
||||
{
|
||||
@ -22,7 +23,11 @@ private slots:
|
||||
|
||||
private:
|
||||
QLineEdit *_edit;
|
||||
#ifdef Q_OS_WIN32
|
||||
QPushButton *_button;
|
||||
#else // Q_OS_WIN32
|
||||
QToolButton *_button;
|
||||
#endif // Q_OS_WIN32
|
||||
|
||||
QString _filter;
|
||||
};
|
||||
|
29
src/gpx.cpp
29
src/gpx.cpp
@ -4,12 +4,24 @@
|
||||
#include "gpx.h"
|
||||
|
||||
|
||||
GPX::GPX() : _parser(_track_data, _route_data, _waypoint_data), _errorLine(0)
|
||||
{
|
||||
}
|
||||
|
||||
GPX::~GPX()
|
||||
{
|
||||
for (int i = 0; i < _tracks.count(); i++)
|
||||
delete _tracks.at(i);
|
||||
for (int i = 0; i < _routes.count(); i++)
|
||||
delete _routes.at(i);
|
||||
}
|
||||
|
||||
bool GPX::loadFile(const QString &fileName)
|
||||
{
|
||||
QFile file(fileName);
|
||||
bool ret;
|
||||
QFile file(fileName);
|
||||
|
||||
|
||||
_tracks.clear();
|
||||
_error.clear();
|
||||
_errorLine = 0;
|
||||
|
||||
@ -18,11 +30,18 @@ bool GPX::loadFile(const QString &fileName)
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!(ret = _parser.loadFile(&file))) {
|
||||
ret = _parser.loadFile(&file);
|
||||
file.close();
|
||||
if (ret == false) {
|
||||
_error = _parser.errorString();
|
||||
_errorLine = _parser.errorLine();
|
||||
return false;
|
||||
}
|
||||
file.close();
|
||||
|
||||
return ret;
|
||||
for (int i = 0; i < _track_data.count(); i++)
|
||||
_tracks.append(new Track(_track_data.at(i)));
|
||||
for (int i = 0; i < _route_data.count(); i++)
|
||||
_routes.append(new Route(_route_data.at(i)));
|
||||
|
||||
return true;
|
||||
}
|
||||
|
19
src/gpx.h
19
src/gpx.h
@ -7,27 +7,34 @@
|
||||
#include <QString>
|
||||
#include "waypoint.h"
|
||||
#include "track.h"
|
||||
#include "route.h"
|
||||
#include "parser.h"
|
||||
|
||||
class GPX
|
||||
{
|
||||
public:
|
||||
GPX() : _parser(_tracks, _waypoints), _errorLine(0) {}
|
||||
GPX();
|
||||
~GPX();
|
||||
|
||||
bool loadFile(const QString &fileName);
|
||||
const QString &errorString() const {return _error;}
|
||||
int errorLine() const {return _errorLine;}
|
||||
|
||||
int trackCount() const {return _tracks.count();}
|
||||
Track track(int i) const {return Track(_tracks.at(i));}
|
||||
const QList<Waypoint> &waypoints() const {return _waypoints;}
|
||||
const QList<Track*> &tracks() const {return _tracks;}
|
||||
const QList<Route*> &routes() const {return _routes;}
|
||||
const QList<Waypoint> &waypoints() const {return _waypoint_data;}
|
||||
|
||||
private:
|
||||
Parser _parser;
|
||||
QString _error;
|
||||
int _errorLine;
|
||||
|
||||
QList<QVector<Trackpoint> > _tracks;
|
||||
QList<Waypoint> _waypoints;
|
||||
QList<Track*> _tracks;
|
||||
QList<Route*> _routes;
|
||||
|
||||
QList<QVector<Trackpoint> > _track_data;
|
||||
QList<QVector<Waypoint> > _route_data;
|
||||
QList<Waypoint> _waypoint_data;
|
||||
};
|
||||
|
||||
#endif // GPX_H
|
||||
|
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
|
||||
#define GRAPHTAB_H
|
||||
|
||||
#include <QList>
|
||||
#include "graphview.h"
|
||||
#include "units.h"
|
||||
|
||||
class GPX;
|
||||
class PathItem;
|
||||
|
||||
class GraphTab : public GraphView
|
||||
{
|
||||
@ -15,9 +17,11 @@ public:
|
||||
{setFrameShape(QFrame::NoFrame);}
|
||||
|
||||
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 setUnits(enum Units units) = 0;
|
||||
virtual void showTracks(bool show) = 0;
|
||||
virtual void showRoutes(bool show) = 0;
|
||||
};
|
||||
|
||||
#endif // GRAPHTAB_H
|
||||
|
@ -1,4 +1,3 @@
|
||||
#include <QGraphicsView>
|
||||
#include <QGraphicsSceneMouseEvent>
|
||||
#include <QEvent>
|
||||
#include <QPaintEngine>
|
||||
@ -8,11 +7,15 @@
|
||||
#include "slideritem.h"
|
||||
#include "sliderinfoitem.h"
|
||||
#include "infoitem.h"
|
||||
#include "graph.h"
|
||||
#include "graphitem.h"
|
||||
#include "pathitem.h"
|
||||
#include "graphview.h"
|
||||
|
||||
|
||||
#define MARGIN 10.0
|
||||
|
||||
|
||||
void Scene::mousePressEvent(QGraphicsSceneMouseEvent *e)
|
||||
{
|
||||
if (e->button() == Qt::LeftButton)
|
||||
@ -32,21 +35,20 @@ GraphView::GraphView(QWidget *parent)
|
||||
setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
|
||||
|
||||
_xAxis = new AxisItem(AxisItem::X);
|
||||
_xAxis->setZValue(1.0);
|
||||
_yAxis = new AxisItem(AxisItem::Y);
|
||||
|
||||
_yAxis->setZValue(1.0);
|
||||
_slider = new SliderItem();
|
||||
_slider->setZValue(2.0);
|
||||
_sliderInfo = new SliderInfoItem(_slider);
|
||||
_sliderInfo->setZValue(2.0);
|
||||
_info = new InfoItem();
|
||||
|
||||
connect(_slider, SIGNAL(positionChanged(const QPointF&)), this,
|
||||
SLOT(emitSliderPositionChanged(const QPointF&)));
|
||||
connect(_scene, SIGNAL(mouseClicked(const QPointF&)), this,
|
||||
SLOT(newSliderPosition(const QPointF&)));
|
||||
|
||||
_info = new InfoItem();
|
||||
|
||||
_sliderInfo = new SliderInfoItem(_slider);
|
||||
_sliderInfo->setZValue(2.0);
|
||||
|
||||
_xScale = 1;
|
||||
_yScale = 1;
|
||||
_yOffset = 0;
|
||||
@ -55,6 +57,12 @@ GraphView::GraphView(QWidget *parent)
|
||||
_minYRange = 0.01;
|
||||
|
||||
_sliderPos = 0;
|
||||
|
||||
_units = Metric;
|
||||
_graphType = Distance;
|
||||
|
||||
setGraphType(_graphType);
|
||||
setUnits(_units);
|
||||
}
|
||||
|
||||
GraphView::~GraphView()
|
||||
@ -63,24 +71,14 @@ GraphView::~GraphView()
|
||||
delete _xAxis;
|
||||
if (_yAxis->scene() != _scene)
|
||||
delete _yAxis;
|
||||
|
||||
if (_slider->scene() != _scene)
|
||||
delete _slider;
|
||||
|
||||
if (_info->scene() != _scene)
|
||||
delete _info;
|
||||
}
|
||||
|
||||
void GraphView::updateBounds(const QPointF &point)
|
||||
{
|
||||
if (point.x() < _bounds.left())
|
||||
_bounds.setLeft(point.x());
|
||||
if (point.x() > _bounds.right())
|
||||
_bounds.setRight(point.x());
|
||||
if (point.y() > _bounds.bottom())
|
||||
_bounds.setBottom(point.y());
|
||||
if (point.y() < _bounds.top())
|
||||
_bounds.setTop(point.y());
|
||||
for (int i = 0; i < _graphs.count(); i++)
|
||||
if (_graphs.at(i)->scene() != _scene)
|
||||
delete _graphs[i];
|
||||
}
|
||||
|
||||
void GraphView::createXLabel()
|
||||
@ -93,62 +91,149 @@ void GraphView::createYLabel()
|
||||
_yAxis->setLabel(QString("%1 [%2]").arg(_yLabel).arg(_yUnits));
|
||||
}
|
||||
|
||||
void GraphView::setXLabel(const QString &label)
|
||||
{
|
||||
_xLabel = label;
|
||||
createXLabel();
|
||||
}
|
||||
|
||||
void GraphView::setYLabel(const QString &label)
|
||||
{
|
||||
_yLabel = label;
|
||||
createYLabel();
|
||||
}
|
||||
|
||||
void GraphView::setXUnits(const QString &units)
|
||||
{
|
||||
_xUnits = units;
|
||||
createXLabel();
|
||||
}
|
||||
|
||||
void GraphView::setYUnits(const QString &units)
|
||||
{
|
||||
_yUnits = units;
|
||||
createYLabel();
|
||||
}
|
||||
|
||||
void GraphView::loadData(const QVector<QPointF> &data)
|
||||
void GraphView::setXUnits()
|
||||
{
|
||||
QPainterPath path;
|
||||
QGraphicsPathItem *pi;
|
||||
|
||||
|
||||
if (data.size() < 2)
|
||||
return;
|
||||
|
||||
if (!_graphs.size())
|
||||
_bounds.moveTo(data.at(0));
|
||||
|
||||
updateBounds(data.at(0));
|
||||
path.moveTo(data.at(0).x(), -data.at(0).y());
|
||||
for (int i = 1; i < data.size(); i++) {
|
||||
const QPointF &p = data.at(i);
|
||||
path.lineTo(p.x(), -p.y());
|
||||
updateBounds(p);
|
||||
if (_graphType == Distance) {
|
||||
if (_units == Metric) {
|
||||
if (bounds().width() < KMINM) {
|
||||
_xUnits = tr("m");
|
||||
_xScale = 1;
|
||||
} else {
|
||||
_xUnits = tr("km");
|
||||
_xScale = M2KM;
|
||||
}
|
||||
} else {
|
||||
if (bounds().width() < MIINM) {
|
||||
_xUnits = tr("ft");
|
||||
_xScale = M2FT;
|
||||
} else {
|
||||
_xUnits = tr("mi");
|
||||
_xScale = M2MI;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (bounds().width() < MININS) {
|
||||
_xUnits = tr("s");
|
||||
_xScale = 1;
|
||||
} else if (bounds().width() < HINS) {
|
||||
_xUnits = tr("min");
|
||||
_xScale = MIN2S;
|
||||
} else {
|
||||
_xUnits = tr("h");
|
||||
_xScale = H2S;
|
||||
}
|
||||
}
|
||||
|
||||
pi = new QGraphicsPathItem(path);
|
||||
QBrush brush(_palette.color(), Qt::SolidPattern);
|
||||
QPen pen(brush, 0);
|
||||
pi->setPen(pen);
|
||||
_scene->addItem(pi);
|
||||
_graphs.append(pi);
|
||||
createXLabel();
|
||||
}
|
||||
|
||||
void GraphView::setUnits(Units units)
|
||||
{
|
||||
_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()
|
||||
{
|
||||
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)
|
||||
@ -156,24 +241,25 @@ void GraphView::redraw(const QSizeF &size)
|
||||
QRectF r;
|
||||
QSizeF mx, my;
|
||||
RangeF rx, ry;
|
||||
QTransform transform;
|
||||
qreal xs, ys;
|
||||
qreal sx, sy;
|
||||
|
||||
|
||||
if (_xAxis->scene() == _scene)
|
||||
_scene->removeItem(_xAxis);
|
||||
if (_yAxis->scene() == _scene)
|
||||
_scene->removeItem(_yAxis);
|
||||
if (_slider->scene() == _scene)
|
||||
_scene->removeItem(_slider);
|
||||
if (_info->scene() == _scene)
|
||||
_scene->removeItem(_info);
|
||||
if (_visible.isEmpty() || _bounds.isNull()) {
|
||||
removeItem(_xAxis);
|
||||
removeItem(_yAxis);
|
||||
removeItem(_slider);
|
||||
removeItem(_info);
|
||||
_scene->setSceneRect(QRectF());
|
||||
return;
|
||||
}
|
||||
|
||||
for (int i = 0; i < _graphs.size(); i++)
|
||||
_graphs.at(i)->resetTransform();
|
||||
addItem(_xAxis);
|
||||
addItem(_yAxis);
|
||||
addItem(_slider);
|
||||
addItem(_info);
|
||||
|
||||
rx = RangeF(_bounds.left() * _xScale, _bounds.right() * _xScale);
|
||||
ry = RangeF(_bounds.top() * _yScale + _yOffset, _bounds.bottom() * _yScale
|
||||
rx = RangeF(bounds().left() * _xScale, bounds().right() * _xScale);
|
||||
ry = RangeF(bounds().top() * _yScale + _yOffset, bounds().bottom() * _yScale
|
||||
+ _yOffset);
|
||||
if (ry.size() < _minYRange)
|
||||
ry.resize(_minYRange);
|
||||
@ -183,52 +269,44 @@ void GraphView::redraw(const QSizeF &size)
|
||||
mx = _xAxis->margin();
|
||||
my = _yAxis->margin();
|
||||
|
||||
r = _scene->itemsBoundingRect();
|
||||
r = _bounds;
|
||||
if (r.height() < _minYRange)
|
||||
r.adjust(0, -(_minYRange/2 - r.height()/2), 0,
|
||||
_minYRange/2 - r.height()/2);
|
||||
|
||||
xs = (size.width() - (my.width() + mx.width())) / r.width();
|
||||
ys = (size.height() - (mx.height() + my.height())
|
||||
sx = (size.width() - (my.width() + mx.width())) / r.width();
|
||||
sy = (size.height() - (mx.height() + my.height())
|
||||
- _info->boundingRect().height()) / r.height();
|
||||
transform.scale(xs, ys);
|
||||
|
||||
for (int i = 0; i < _graphs.size(); i++)
|
||||
_graphs.at(i)->setTransform(transform);
|
||||
for (int i = 0; i < _visible.size(); i++)
|
||||
_visible.at(i)->setScale(sx, sy);
|
||||
|
||||
r = _scene->itemsBoundingRect();
|
||||
if (r.height() < _minYRange * ys)
|
||||
r.adjust(0, -(_minYRange/2 * ys - r.height()/2), 0,
|
||||
(_minYRange/2) * ys - r.height()/2);
|
||||
QPointF p(r.left() * sx, r.top() * sy);
|
||||
QSizeF s(r.width() * sx, r.height() * sy);
|
||||
r = QRectF(p, s);
|
||||
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());
|
||||
_yAxis->setSize(r.height());
|
||||
_xAxis->setPos(r.bottomLeft());
|
||||
_yAxis->setPos(r.bottomLeft());
|
||||
_scene->addItem(_xAxis);
|
||||
_scene->addItem(_yAxis);
|
||||
|
||||
_slider->setArea(r);
|
||||
if (_sliderPos > _bounds.right() || _sliderPos < _bounds.left())
|
||||
_slider->setVisible(false);
|
||||
_slider->setPos((_sliderPos / _bounds.width()) * _slider->area().width(),
|
||||
r.bottom());
|
||||
_scene->addItem(_slider);
|
||||
updateSliderPosition();
|
||||
|
||||
updateSliderInfo();
|
||||
|
||||
r = _scene->itemsBoundingRect();
|
||||
r |= _xAxis->sceneBoundingRect();
|
||||
r |= _yAxis->sceneBoundingRect();
|
||||
_info->setPos(r.topLeft() + QPointF(r.width()/2
|
||||
- _info->boundingRect().width()/2, -_info->boundingRect().height()));
|
||||
_scene->addItem(_info);
|
||||
|
||||
_scene->setSceneRect(_scene->itemsBoundingRect());
|
||||
}
|
||||
|
||||
void GraphView::resizeEvent(QResizeEvent *)
|
||||
{
|
||||
if (!_graphs.empty())
|
||||
redraw();
|
||||
redraw();
|
||||
}
|
||||
|
||||
void GraphView::plot(QPainter *painter, const QRectF &target)
|
||||
@ -249,19 +327,14 @@ void GraphView::plot(QPainter *painter, const QRectF &target)
|
||||
|
||||
void GraphView::clear()
|
||||
{
|
||||
if (_xAxis->scene() == _scene)
|
||||
_scene->removeItem(_xAxis);
|
||||
if (_yAxis->scene() == _scene)
|
||||
_scene->removeItem(_yAxis);
|
||||
if (_slider->scene() == _scene)
|
||||
_scene->removeItem(_slider);
|
||||
if (_info->scene() == _scene)
|
||||
_scene->removeItem(_info);
|
||||
|
||||
_slider->clear();
|
||||
_info->clear();
|
||||
_scene->clear();
|
||||
|
||||
for (int i = 0; i < _graphs.count(); i++)
|
||||
delete _graphs[i];
|
||||
|
||||
_graphs.clear();
|
||||
_visible.clear();
|
||||
_palette.reset();
|
||||
|
||||
_bounds = QRectF();
|
||||
@ -270,54 +343,38 @@ void GraphView::clear()
|
||||
_scene->setSceneRect(0, 0, 0, 0);
|
||||
}
|
||||
|
||||
static qreal yAtX(const QPainterPath &path, qreal x)
|
||||
void GraphView::updateSliderPosition()
|
||||
{
|
||||
int low = 0;
|
||||
int high = path.elementCount() - 1;
|
||||
int mid = 0;
|
||||
if (bounds().width() <= 0)
|
||||
return;
|
||||
|
||||
Q_ASSERT(high > low);
|
||||
Q_ASSERT(x >= path.elementAt(low).x && x <= path.elementAt(high).x);
|
||||
|
||||
while (low <= high) {
|
||||
mid = low + ((high - low) / 2);
|
||||
const QPainterPath::Element &e = path.elementAt(mid);
|
||||
if (e.x > x)
|
||||
high = mid - 1;
|
||||
else if (e.x < x)
|
||||
low = mid + 1;
|
||||
else
|
||||
return e.y;
|
||||
if (_sliderPos <= bounds().right() && _sliderPos >= bounds().left()) {
|
||||
_slider->setPos((_sliderPos / bounds().width())
|
||||
* _slider->area().width(), _slider->area().bottom());
|
||||
_slider->setVisible(!_visible.isEmpty());
|
||||
} else {
|
||||
_slider->setPos(_slider->area().left(), _slider->area().bottom());
|
||||
_slider->setVisible(false);
|
||||
}
|
||||
|
||||
QLineF l;
|
||||
if (path.elementAt(mid).x < x)
|
||||
l = QLineF(path.elementAt(mid).x, path.elementAt(mid).y,
|
||||
path.elementAt(mid+1).x, path.elementAt(mid+1).y);
|
||||
else
|
||||
l = QLineF(path.elementAt(mid-1).x, path.elementAt(mid-1).y,
|
||||
path.elementAt(mid).x, path.elementAt(mid).y);
|
||||
|
||||
return l.pointAt((x - l.p1().x()) / (l.p2().x() - l.p1().x())).y();
|
||||
updateSliderInfo();
|
||||
}
|
||||
|
||||
void GraphView::updateSliderInfo()
|
||||
{
|
||||
_sliderInfo->setVisible(_graphs.size() == 1);
|
||||
|
||||
_sliderInfo->setVisible(_visible.count() == 1);
|
||||
if (!_sliderInfo->isVisible())
|
||||
return;
|
||||
|
||||
const QPainterPath &path = _graphs.at(0)->path();
|
||||
QRectF br = path.boundingRect();
|
||||
QRectF br(_visible.first()->bounds());
|
||||
if (br.height() < _minYRange)
|
||||
br.adjust(0, -(_minYRange/2 - br.height()/2), 0,
|
||||
_minYRange/2 - br.height()/2);
|
||||
|
||||
qreal y = yAtX(path, _sliderPos);
|
||||
qreal y = _visible.first()->yAtX(_sliderPos);
|
||||
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()
|
||||
> _slider->area().right()) ? SliderInfoItem::Left : SliderInfoItem::Right;
|
||||
|
||||
@ -329,37 +386,28 @@ void GraphView::updateSliderInfo()
|
||||
|
||||
void GraphView::emitSliderPositionChanged(const QPointF &pos)
|
||||
{
|
||||
if (_graphs.isEmpty())
|
||||
if (_slider->area().width() <= 0)
|
||||
return;
|
||||
|
||||
_sliderPos = (pos.x() / _slider->area().width()) * _bounds.width();
|
||||
emit sliderPositionChanged(_sliderPos);
|
||||
_sliderPos = (pos.x() / _slider->area().width()) * bounds().width();
|
||||
updateSliderPosition();
|
||||
|
||||
updateSliderInfo();
|
||||
emit sliderPositionChanged(_sliderPos);
|
||||
}
|
||||
|
||||
void GraphView::setSliderPosition(qreal pos)
|
||||
{
|
||||
_sliderPos = pos;
|
||||
|
||||
if (_graphs.isEmpty())
|
||||
if (_visible.isEmpty())
|
||||
return;
|
||||
|
||||
if (pos > _bounds.right() || pos < _bounds.left())
|
||||
_slider->setVisible(false);
|
||||
else {
|
||||
_slider->setPos((pos / _bounds.width()) * _slider->area().width(), 0);
|
||||
_slider->setVisible(true);
|
||||
}
|
||||
_sliderPos = pos;
|
||||
updateSliderPosition();
|
||||
}
|
||||
|
||||
void GraphView::newSliderPosition(const QPointF &pos)
|
||||
{
|
||||
if (_slider->area().contains(pos)) {
|
||||
if (_slider->area().contains(pos))
|
||||
_slider->setPos(pos);
|
||||
_slider->setVisible(true);
|
||||
emitSliderPositionChanged(pos);
|
||||
}
|
||||
}
|
||||
|
||||
void GraphView::addInfo(const QString &key, const QString &value)
|
||||
|
@ -5,14 +5,19 @@
|
||||
#include <QGraphicsScene>
|
||||
#include <QVector>
|
||||
#include <QList>
|
||||
#include <QSet>
|
||||
#include <QPointF>
|
||||
#include "palette.h"
|
||||
#include "units.h"
|
||||
#include "graph.h"
|
||||
|
||||
|
||||
class AxisItem;
|
||||
class SliderItem;
|
||||
class SliderInfoItem;
|
||||
class InfoItem;
|
||||
class GraphItem;
|
||||
class PathItem;
|
||||
|
||||
class Scene : public QGraphicsScene
|
||||
{
|
||||
@ -34,26 +39,21 @@ public:
|
||||
GraphView(QWidget *parent = 0);
|
||||
~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 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 &xUnits() const {return _xUnits;}
|
||||
const QString &yUnits() const {return _yUnits;}
|
||||
qreal xScale() const {return _xScale;}
|
||||
qreal yScale() const {return _yScale;}
|
||||
qreal yOffset() const {return _yOffset;}
|
||||
|
||||
void setXLabel(const QString &label);
|
||||
void setYLabel(const QString &label);
|
||||
void setXUnits(const QString &units);
|
||||
void setYUnits(const QString &units);
|
||||
void setXScale(qreal scale) {_xScale = scale;}
|
||||
void setYScale(qreal scale) {_yScale = scale;}
|
||||
void setYOffset(qreal offset) {_yOffset = offset;}
|
||||
|
||||
@ -69,22 +69,25 @@ signals:
|
||||
void sliderPositionChanged(qreal);
|
||||
|
||||
protected:
|
||||
const QRectF &bounds() const {return _bounds;}
|
||||
void resizeEvent(QResizeEvent *);
|
||||
QRectF bounds() const;
|
||||
void redraw(const QSizeF &size);
|
||||
void addInfo(const QString &key, const QString &value);
|
||||
void clearInfo();
|
||||
void skipColor() {_palette.color();}
|
||||
void resizeEvent(QResizeEvent *);
|
||||
|
||||
private slots:
|
||||
void emitSliderPositionChanged(const QPointF &pos);
|
||||
void newSliderPosition(const QPointF &pos);
|
||||
|
||||
private:
|
||||
void setXUnits();
|
||||
void createXLabel();
|
||||
void createYLabel();
|
||||
void updateBounds(const QPointF &point);
|
||||
void updateSliderPosition();
|
||||
void updateSliderInfo();
|
||||
void removeItem(QGraphicsItem *item);
|
||||
void addItem(QGraphicsItem *item);
|
||||
|
||||
qreal _xScale, _yScale;
|
||||
qreal _yOffset;
|
||||
@ -101,9 +104,14 @@ private:
|
||||
SliderInfoItem *_sliderInfo;
|
||||
InfoItem *_info;
|
||||
|
||||
QList<QGraphicsPathItem*> _graphs;
|
||||
QList<GraphItem*> _graphs;
|
||||
QList<GraphItem*> _visible;
|
||||
QSet<int> _hide;
|
||||
QRectF _bounds;
|
||||
Palette _palette;
|
||||
|
||||
Units _units;
|
||||
GraphType _graphType;
|
||||
};
|
||||
|
||||
#endif // GRAPHVIEW_H
|
||||
|
564
src/gui.cpp
564
src/gui.cpp
@ -18,6 +18,9 @@
|
||||
#include <QLabel>
|
||||
#include <QSettings>
|
||||
#include <QLocale>
|
||||
#include <QMimeData>
|
||||
#include <QUrl>
|
||||
#include <QPixmapCache>
|
||||
#include "config.h"
|
||||
#include "icons.h"
|
||||
#include "keys.h"
|
||||
@ -29,7 +32,7 @@
|
||||
#include "speedgraph.h"
|
||||
#include "heartrategraph.h"
|
||||
#include "temperaturegraph.h"
|
||||
#include "trackview.h"
|
||||
#include "pathview.h"
|
||||
#include "trackinfo.h"
|
||||
#include "filebrowser.h"
|
||||
#include "cpuarch.h"
|
||||
@ -44,19 +47,19 @@ GUI::GUI(QWidget *parent) : QMainWindow(parent)
|
||||
loadMaps();
|
||||
loadPOIs();
|
||||
|
||||
createPathView();
|
||||
createGraphTabs();
|
||||
createStatusBar();
|
||||
createActions();
|
||||
createMenus();
|
||||
createToolBars();
|
||||
createTrackView();
|
||||
createTrackGraphs();
|
||||
createStatusBar();
|
||||
|
||||
_browser = new FileBrowser(this);
|
||||
_browser->setFilter(QStringList("*.gpx"));
|
||||
|
||||
QVBoxLayout *layout = new QVBoxLayout;
|
||||
layout->addWidget(_track);
|
||||
layout->addWidget(_trackGraphs);
|
||||
layout->addWidget(_pathView);
|
||||
layout->addWidget(_graphTabWidget);
|
||||
layout->setContentsMargins(0, 0, 0, 0);
|
||||
#ifdef Q_OS_WIN32
|
||||
layout->setSpacing(0);
|
||||
@ -70,14 +73,18 @@ GUI::GUI(QWidget *parent) : QMainWindow(parent)
|
||||
setWindowTitle(APP_NAME);
|
||||
setUnifiedTitleAndToolBarOnMac(true);
|
||||
|
||||
_distance = 0;
|
||||
_time = 0;
|
||||
_trackCount = 0;
|
||||
_routeCount = 0;
|
||||
_waypointCount = 0;
|
||||
_trackDistance = 0;
|
||||
_routeDistance = 0;
|
||||
_time = 0;
|
||||
|
||||
_sliderPos = 0;
|
||||
|
||||
updateGraphTabs();
|
||||
updateTrackView();
|
||||
updateStatusBarInfo();
|
||||
|
||||
readSettings();
|
||||
|
||||
@ -86,12 +93,15 @@ GUI::GUI(QWidget *parent) : QMainWindow(parent)
|
||||
_exportOrientation = QPrinter::Portrait;
|
||||
_exportFileName = QString("%1/export.pdf").arg(QDir::currentPath());
|
||||
_exportMargins = MarginsF(5.0, 5.0, 5.0, 5.0);
|
||||
|
||||
setAcceptDrops(true);
|
||||
QPixmapCache::setCacheLimit(65536);
|
||||
}
|
||||
|
||||
GUI::~GUI()
|
||||
{
|
||||
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);
|
||||
}
|
||||
}
|
||||
@ -110,13 +120,15 @@ void GUI::loadPOIs()
|
||||
QDir userDir(USER_POI_DIR);
|
||||
QDir globalDir(GLOBAL_POI_DIR);
|
||||
|
||||
_poi = new POI(this);
|
||||
|
||||
if (userDir.exists())
|
||||
list = userDir.entryInfoList(QStringList(), QDir::Files);
|
||||
else
|
||||
list = globalDir.entryInfoList(QStringList(), QDir::Files);
|
||||
|
||||
for (int i = 0; i < list.size(); ++i)
|
||||
_poi.loadFile(list.at(i).absoluteFilePath());
|
||||
_poi->loadFile(list.at(i).absoluteFilePath());
|
||||
}
|
||||
|
||||
void GUI::createMapActions()
|
||||
@ -144,7 +156,7 @@ void GUI::createPOIFilesActions()
|
||||
{
|
||||
_poiFilesSM = new QSignalMapper(this);
|
||||
|
||||
for (int i = 0; i < _poi.files().count(); i++)
|
||||
for (int i = 0; i < _poi->files().count(); i++)
|
||||
createPOIFileAction(i);
|
||||
|
||||
connect(_poiFilesSM, SIGNAL(mapped(int)), this, SLOT(poiFileChecked(int)));
|
||||
@ -152,7 +164,7 @@ void GUI::createPOIFilesActions()
|
||||
|
||||
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);
|
||||
a->setCheckable(true);
|
||||
|
||||
@ -166,6 +178,9 @@ QAction *GUI::createPOIFileAction(int index)
|
||||
|
||||
void GUI::createActions()
|
||||
{
|
||||
QActionGroup *ag;
|
||||
|
||||
|
||||
// Action Groups
|
||||
_fileActionGroup = new QActionGroup(this);
|
||||
_fileActionGroup->setExclusive(false);
|
||||
@ -189,7 +204,7 @@ void GUI::createActions()
|
||||
tr("About GPXSee"), this);
|
||||
connect(_aboutAction, SIGNAL(triggered()), this, SLOT(about()));
|
||||
|
||||
// File related actions
|
||||
// File actions
|
||||
_openFileAction = new QAction(QIcon(QPixmap(OPEN_FILE_ICON)),
|
||||
tr("Open"), this);
|
||||
_openFileAction->setShortcut(OPEN_SHORTCUT);
|
||||
@ -228,13 +243,18 @@ void GUI::createActions()
|
||||
connect(_closePOIAction, SIGNAL(triggered()), this, SLOT(closePOIFiles()));
|
||||
_overlapPOIAction = new QAction(tr("Overlap POIs"), this);
|
||||
_overlapPOIAction->setCheckable(true);
|
||||
connect(_overlapPOIAction, SIGNAL(triggered(bool)), this,
|
||||
SLOT(overlapPOIs(bool)));
|
||||
connect(_overlapPOIAction, SIGNAL(triggered(bool)), _pathView,
|
||||
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)),
|
||||
tr("Show POIs"), this);
|
||||
_showPOIAction->setCheckable(true);
|
||||
_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);
|
||||
createPOIFilesActions();
|
||||
|
||||
@ -264,18 +284,57 @@ void GUI::createActions()
|
||||
addAction(_prevMapAction);
|
||||
}
|
||||
|
||||
// Settings actions
|
||||
_showGraphsAction = new QAction(tr("Show graphs"), this);
|
||||
// Data actions
|
||||
_showTracksAction = new QAction(tr("Show tracks"), this);
|
||||
_showTracksAction->setCheckable(true);
|
||||
connect(_showTracksAction, SIGNAL(triggered(bool)), this,
|
||||
SLOT(showTracks(bool)));
|
||||
_showRoutesAction = new QAction(tr("Show routes"), this);
|
||||
_showRoutesAction->setCheckable(true);
|
||||
connect(_showRoutesAction, SIGNAL(triggered(bool)), this,
|
||||
SLOT(showRoutes(bool)));
|
||||
_showWaypointsAction = new QAction(tr("Show waypoints"), this);
|
||||
_showWaypointsAction->setCheckable(true);
|
||||
connect(_showWaypointsAction, SIGNAL(triggered(bool)), _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->setShortcut(SHOW_GRAPHS_SHORTCUT);
|
||||
connect(_showGraphsAction, SIGNAL(triggered(bool)), this,
|
||||
SLOT(showGraphs(bool)));
|
||||
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->setCheckable(true);
|
||||
connect(_showToolbarsAction, SIGNAL(triggered(bool)), this,
|
||||
SLOT(showToolbars(bool)));
|
||||
QActionGroup *ag = new QActionGroup(this);
|
||||
ag = new QActionGroup(this);
|
||||
ag->setExclusive(true);
|
||||
_metricUnitsAction = new QAction(tr("Metric"), this);
|
||||
_metricUnitsAction->setCheckable(true);
|
||||
@ -314,53 +373,68 @@ void GUI::createActions()
|
||||
|
||||
void GUI::createMenus()
|
||||
{
|
||||
_fileMenu = menuBar()->addMenu(tr("File"));
|
||||
_fileMenu->addAction(_openFileAction);
|
||||
_fileMenu->addSeparator();
|
||||
_fileMenu->addAction(_printFileAction);
|
||||
_fileMenu->addAction(_exportFileAction);
|
||||
_fileMenu->addSeparator();
|
||||
_fileMenu->addAction(_reloadFileAction);
|
||||
_fileMenu->addSeparator();
|
||||
_fileMenu->addAction(_closeFileAction);
|
||||
QMenu *fileMenu = menuBar()->addMenu(tr("File"));
|
||||
fileMenu->addAction(_openFileAction);
|
||||
fileMenu->addSeparator();
|
||||
fileMenu->addAction(_printFileAction);
|
||||
fileMenu->addAction(_exportFileAction);
|
||||
fileMenu->addSeparator();
|
||||
fileMenu->addAction(_reloadFileAction);
|
||||
fileMenu->addSeparator();
|
||||
fileMenu->addAction(_closeFileAction);
|
||||
#ifndef Q_OS_MAC
|
||||
_fileMenu->addSeparator();
|
||||
_fileMenu->addAction(_exitAction);
|
||||
fileMenu->addSeparator();
|
||||
fileMenu->addAction(_exitAction);
|
||||
#endif // Q_OS_MAC
|
||||
|
||||
_mapMenu = menuBar()->addMenu(tr("Map"));
|
||||
_mapMenu->addActions(_mapActions);
|
||||
_mapMenu->addSeparator();
|
||||
_mapMenu->addAction(_clearMapCacheAction);
|
||||
_mapMenu->addSeparator();
|
||||
_mapMenu->addAction(_showMapAction);
|
||||
QMenu *mapMenu = menuBar()->addMenu(tr("Map"));
|
||||
mapMenu->addActions(_mapActions);
|
||||
mapMenu->addSeparator();
|
||||
mapMenu->addAction(_clearMapCacheAction);
|
||||
mapMenu->addSeparator();
|
||||
mapMenu->addAction(_showMapAction);
|
||||
|
||||
_poiMenu = menuBar()->addMenu(tr("POI"));
|
||||
_poiFilesMenu = _poiMenu->addMenu(tr("POI files"));
|
||||
QMenu *graphMenu = menuBar()->addMenu(tr("Graph"));
|
||||
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);
|
||||
_poiMenu->addSeparator();
|
||||
_poiMenu->addAction(_openPOIAction);
|
||||
_poiMenu->addAction(_closePOIAction);
|
||||
_poiMenu->addSeparator();
|
||||
_poiMenu->addAction(_overlapPOIAction);
|
||||
_poiMenu->addSeparator();
|
||||
_poiMenu->addAction(_showPOIAction);
|
||||
poiMenu->addSeparator();
|
||||
poiMenu->addAction(_openPOIAction);
|
||||
poiMenu->addAction(_closePOIAction);
|
||||
poiMenu->addSeparator();
|
||||
poiMenu->addAction(_showPOILabelsAction);
|
||||
poiMenu->addAction(_overlapPOIAction);
|
||||
poiMenu->addSeparator();
|
||||
poiMenu->addAction(_showPOIAction);
|
||||
|
||||
_settingsMenu = menuBar()->addMenu(tr("Settings"));
|
||||
_unitsMenu = _settingsMenu->addMenu(tr("Units"));
|
||||
_unitsMenu->addAction(_metricUnitsAction);
|
||||
_unitsMenu->addAction(_imperialUnitsAction);
|
||||
_settingsMenu->addSeparator();
|
||||
_settingsMenu->addAction(_showToolbarsAction);
|
||||
_settingsMenu->addAction(_showGraphsAction);
|
||||
_settingsMenu->addSeparator();
|
||||
_settingsMenu->addAction(_fullscreenAction);
|
||||
QMenu *dataMenu = menuBar()->addMenu(tr("Data"));
|
||||
QMenu *displayMenu = dataMenu->addMenu(tr("Display"));
|
||||
displayMenu->addAction(_showWaypointLabelsAction);
|
||||
displayMenu->addAction(_showRouteWaypointsAction);
|
||||
dataMenu->addSeparator();
|
||||
dataMenu->addAction(_showTracksAction);
|
||||
dataMenu->addAction(_showRoutesAction);
|
||||
dataMenu->addAction(_showWaypointsAction);
|
||||
|
||||
_helpMenu = menuBar()->addMenu(tr("Help"));
|
||||
_helpMenu->addAction(_dataSourcesAction);
|
||||
_helpMenu->addAction(_keysAction);
|
||||
_helpMenu->addSeparator();
|
||||
_helpMenu->addAction(_aboutAction);
|
||||
QMenu *settingsMenu = menuBar()->addMenu(tr("Settings"));
|
||||
QMenu *unitsMenu = settingsMenu->addMenu(tr("Units"));
|
||||
unitsMenu->addAction(_metricUnitsAction);
|
||||
unitsMenu->addAction(_imperialUnitsAction);
|
||||
settingsMenu->addSeparator();
|
||||
settingsMenu->addAction(_showToolbarsAction);
|
||||
settingsMenu->addSeparator();
|
||||
settingsMenu->addAction(_fullscreenAction);
|
||||
|
||||
QMenu *helpMenu = menuBar()->addMenu(tr("Help"));
|
||||
helpMenu->addAction(_dataSourcesAction);
|
||||
helpMenu->addAction(_keysAction);
|
||||
helpMenu->addSeparator();
|
||||
helpMenu->addAction(_aboutAction);
|
||||
}
|
||||
|
||||
void GUI::createToolBars()
|
||||
@ -378,6 +452,7 @@ void GUI::createToolBars()
|
||||
_showToolBar = addToolBar(tr("Show"));
|
||||
_showToolBar->addAction(_showPOIAction);
|
||||
_showToolBar->addAction(_showMapAction);
|
||||
_showToolBar->addAction(_showGraphsAction);
|
||||
|
||||
_navigationToolBar = addToolBar(tr("Navigation"));
|
||||
_navigationToolBar->addAction(_firstAction);
|
||||
@ -386,25 +461,27 @@ void GUI::createToolBars()
|
||||
_navigationToolBar->addAction(_lastAction);
|
||||
}
|
||||
|
||||
void GUI::createTrackView()
|
||||
void GUI::createPathView()
|
||||
{
|
||||
_track = new TrackView(this);
|
||||
_pathView = new PathView(this);
|
||||
#ifdef Q_OS_WIN32
|
||||
_track->setFrameShape(QFrame::NoFrame);
|
||||
_pathView->setFrameShape(QFrame::NoFrame);
|
||||
#endif // Q_OS_WIN32
|
||||
|
||||
_pathView->setPOI(_poi);
|
||||
}
|
||||
|
||||
void GUI::createTrackGraphs()
|
||||
void GUI::createGraphTabs()
|
||||
{
|
||||
_trackGraphs = new QTabWidget;
|
||||
connect(_trackGraphs, SIGNAL(currentChanged(int)), this,
|
||||
_graphTabWidget = new QTabWidget;
|
||||
connect(_graphTabWidget, SIGNAL(currentChanged(int)), this,
|
||||
SLOT(graphChanged(int)));
|
||||
|
||||
_trackGraphs->setFixedHeight(200);
|
||||
_trackGraphs->setSizePolicy(
|
||||
_graphTabWidget->setFixedHeight(200);
|
||||
_graphTabWidget->setSizePolicy(
|
||||
QSizePolicy(QSizePolicy::Ignored, QSizePolicy::Fixed));
|
||||
#ifdef Q_OS_WIN32
|
||||
_trackGraphs->setDocumentMode(true);
|
||||
_graphTabWidget->setDocumentMode(true);
|
||||
#endif // Q_OS_WIN32
|
||||
|
||||
_tabs.append(new ElevationGraph);
|
||||
@ -429,8 +506,6 @@ void GUI::createStatusBar()
|
||||
statusBar()->addPermanentWidget(_distanceLabel, 1);
|
||||
statusBar()->addPermanentWidget(_timeLabel, 1);
|
||||
statusBar()->setSizeGripEnabled(false);
|
||||
|
||||
updateStatusBarInfo();
|
||||
}
|
||||
|
||||
void GUI::about()
|
||||
@ -545,28 +620,31 @@ bool GUI::openFile(const QString &fileName)
|
||||
bool GUI::loadFile(const QString &fileName)
|
||||
{
|
||||
GPX gpx;
|
||||
QList<PathItem*> paths;
|
||||
|
||||
if (gpx.loadFile(fileName)) {
|
||||
paths = _pathView->loadGPX(gpx);
|
||||
for (int i = 0; i < _tabs.count(); i++)
|
||||
_tabs.at(i)->loadGPX(gpx);
|
||||
_tabs.at(i)->loadGPX(gpx, paths);
|
||||
updateGraphTabs();
|
||||
_track->setHidden(false);
|
||||
_track->loadGPX(gpx);
|
||||
if (_showPOIAction->isChecked())
|
||||
_track->loadPOI(_poi);
|
||||
_track->movePositionMarker(_sliderPos);
|
||||
_pathView->setHidden(false);
|
||||
|
||||
for (int i = 0; i < gpx.trackCount(); i++) {
|
||||
_distance += gpx.track(i).distance();
|
||||
_time += gpx.track(i).time();
|
||||
const QDate &date = gpx.track(i).date().date();
|
||||
for (int i = 0; i < gpx.tracks().count(); i++) {
|
||||
_trackDistance += gpx.tracks().at(i)->distance();
|
||||
_time += gpx.tracks().at(i)->time();
|
||||
const QDate &date = gpx.tracks().at(i)->date().date();
|
||||
if (_dateRange.first.isNull() || _dateRange.first > date)
|
||||
_dateRange.first = date;
|
||||
if (_dateRange.second.isNull() || _dateRange.second < date)
|
||||
_dateRange.second = date;
|
||||
}
|
||||
_trackCount += gpx.tracks().count();
|
||||
|
||||
_trackCount += gpx.trackCount();
|
||||
for (int i = 0; i < gpx.routes().count(); i++)
|
||||
_routeDistance += gpx.routes().at(i)->distance();
|
||||
_routeCount += gpx.routes().count();
|
||||
|
||||
_waypointCount += gpx.waypoints().count();
|
||||
|
||||
return true;
|
||||
} else {
|
||||
@ -584,7 +662,9 @@ bool GUI::loadFile(const QString &fileName)
|
||||
void GUI::openPOIFile()
|
||||
{
|
||||
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;
|
||||
|
||||
for (QStringList::Iterator it = list.begin(); it != list.end(); it++)
|
||||
@ -593,21 +673,22 @@ void GUI::openPOIFile()
|
||||
|
||||
bool GUI::openPOIFile(const QString &fileName)
|
||||
{
|
||||
if (fileName.isEmpty())
|
||||
if (fileName.isEmpty() || _poi->files().contains(fileName))
|
||||
return false;
|
||||
|
||||
if (!_poi.loadFile(fileName)) {
|
||||
QString error = tr("Error loading POI file:\n%1")
|
||||
.arg(_poi.errorString()) + QString("\n");
|
||||
if (_poi.errorLine())
|
||||
error.append(tr("Line: %1").arg(_poi.errorLine()));
|
||||
if (!_poi->loadFile(fileName)) {
|
||||
QString error = fileName + QString("\n\n")
|
||||
+ tr("Error loading POI file:\n%1").arg(_poi->errorString())
|
||||
+ QString("\n");
|
||||
if (_poi->errorLine())
|
||||
error.append(tr("Line: %1").arg(_poi->errorLine()));
|
||||
QMessageBox::critical(this, tr("Error"), error);
|
||||
|
||||
return false;
|
||||
} else {
|
||||
_pathView->showPOI(true);
|
||||
_showPOIAction->setChecked(true);
|
||||
_track->loadPOI(_poi);
|
||||
QAction *action = createPOIFileAction(_poi.files().indexOf(fileName));
|
||||
QAction *action = createPOIFileAction(_poi->files().indexOf(fileName));
|
||||
action->setChecked(true);
|
||||
_poiFilesMenu->addAction(action);
|
||||
|
||||
@ -623,9 +704,7 @@ void GUI::closePOIFiles()
|
||||
delete _poiFilesActions[i];
|
||||
_poiFilesActions.clear();
|
||||
|
||||
_track->clearPOI();
|
||||
|
||||
_poi.clear();
|
||||
_poi->clear();
|
||||
}
|
||||
|
||||
void GUI::printFile()
|
||||
@ -664,7 +743,9 @@ void GUI::plot(QPrinter *printer)
|
||||
QPainter p(printer);
|
||||
TrackInfo info;
|
||||
qreal ih, gh, mh, ratio;
|
||||
|
||||
Units units = _imperialUnitsAction->isChecked() ? Imperial : Metric;
|
||||
qreal d = distance();
|
||||
qreal t = time();
|
||||
|
||||
if (_dateRange.first.isValid()) {
|
||||
if (_dateRange.first == _dateRange.second) {
|
||||
@ -675,20 +756,20 @@ void GUI::plot(QPrinter *printer)
|
||||
info.insert(tr("Date"), QString("%1 - %2")
|
||||
.arg(_dateRange.first.toString(format),
|
||||
_dateRange.second.toString(format)));
|
||||
info.insert(tr("Tracks"), QString::number(_trackCount));
|
||||
}
|
||||
}
|
||||
if (_distance > 0) {
|
||||
if (_imperialUnitsAction->isChecked()) {
|
||||
info.insert(tr("Distance"), QString::number(_distance * M2MI, 'f',
|
||||
1) + UNIT_SPACE + tr("mi"));
|
||||
} else {
|
||||
info.insert(tr("Distance"), QString::number(_distance * M2KM, 'f',
|
||||
1) + UNIT_SPACE + tr("km"));
|
||||
}
|
||||
}
|
||||
if (_time > 0)
|
||||
info.insert(tr("Time"), timeSpan(_time));
|
||||
|
||||
if (_trackCount > 1)
|
||||
info.insert(tr("Tracks"), QString::number(_trackCount));
|
||||
if (_routeCount > 1)
|
||||
info.insert(tr("Routes"), QString::number(_routeCount));
|
||||
if (_waypointCount > 2)
|
||||
info.insert(tr("Waypoints"), QString::number(_waypointCount));
|
||||
|
||||
if (d > 0)
|
||||
info.insert(tr("Distance"), ::distance(d, units));
|
||||
if (t > 0)
|
||||
info.insert(tr("Time"), ::timeSpan(t));
|
||||
|
||||
|
||||
ratio = p.paintEngine()->paintDevice()->logicalDpiX() / SCREEN_DPI;
|
||||
@ -700,30 +781,33 @@ void GUI::plot(QPrinter *printer)
|
||||
mh = ih / 2;
|
||||
info.plot(&p, QRectF(0, 0, printer->width(), ih));
|
||||
}
|
||||
if (_trackGraphs->isVisible()) {
|
||||
if (_graphTabWidget->isVisible()) {
|
||||
qreal r = (((qreal)(printer)->width()) / (qreal)(printer->height()));
|
||||
gh = (printer->width() > printer->height())
|
||||
? 0.15 * r * (printer->height() - ih - 2*mh)
|
||||
: 0.15 * (printer->height() - ih - 2*mh);
|
||||
gh = qMax(gh, ratio * 150);
|
||||
GraphView *gv = static_cast<GraphView*>(_trackGraphs->currentWidget());
|
||||
gv->plot(&p, QRectF(0, printer->height() - gh, printer->width(), gh));
|
||||
GraphTab *gt = static_cast<GraphTab*>(_graphTabWidget->currentWidget());
|
||||
gt->plot(&p, QRectF(0, printer->height() - gh, printer->width(), gh));
|
||||
} else
|
||||
gh = 0;
|
||||
_track->plot(&p, QRectF(0, ih + mh, printer->width(), printer->height()
|
||||
_pathView->plot(&p, QRectF(0, ih + mh, printer->width(), printer->height()
|
||||
- (ih + 2*mh + gh)));
|
||||
}
|
||||
|
||||
void GUI::reloadFile()
|
||||
{
|
||||
_distance = 0;
|
||||
_trackCount = 0;
|
||||
_routeCount = 0;
|
||||
_waypointCount = 0;
|
||||
_trackDistance = 0;
|
||||
_routeDistance = 0;
|
||||
_time = 0;
|
||||
_dateRange = DateRange(QDate(), QDate());
|
||||
_trackCount = 0;
|
||||
|
||||
for (int i = 0; i < _tabs.count(); i++)
|
||||
_tabs.at(i)->clear();
|
||||
_track->clear();
|
||||
_pathView->clear();
|
||||
|
||||
_sliderPos = 0;
|
||||
|
||||
@ -746,16 +830,19 @@ void GUI::reloadFile()
|
||||
|
||||
void GUI::closeFiles()
|
||||
{
|
||||
_distance = 0;
|
||||
_trackCount = 0;
|
||||
_routeCount = 0;
|
||||
_waypointCount = 0;
|
||||
_trackDistance = 0;
|
||||
_routeDistance = 0;
|
||||
_time = 0;
|
||||
_dateRange = DateRange(QDate(), QDate());
|
||||
_trackCount = 0;
|
||||
|
||||
_sliderPos = 0;
|
||||
|
||||
for (int i = 0; i < _tabs.count(); i++)
|
||||
_tabs.at(i)->clear();
|
||||
_track->clear();
|
||||
_pathView->clear();
|
||||
|
||||
_files.clear();
|
||||
}
|
||||
@ -771,30 +858,17 @@ void GUI::closeAll()
|
||||
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)
|
||||
{
|
||||
if (checked)
|
||||
_track->setMap(_currentMap);
|
||||
_pathView->setMap(_currentMap);
|
||||
else
|
||||
_track->setMap(0);
|
||||
_pathView->setMap(0);
|
||||
}
|
||||
|
||||
void GUI::showGraphs(bool checked)
|
||||
{
|
||||
_trackGraphs->setHidden(!checked);
|
||||
_graphTabWidget->setHidden(!checked);
|
||||
}
|
||||
|
||||
void GUI::showToolbars(bool checked)
|
||||
@ -816,7 +890,7 @@ void GUI::showToolbars(bool checked)
|
||||
void GUI::showFullscreen(bool checked)
|
||||
{
|
||||
if (checked) {
|
||||
_frameStyle = _track->frameStyle();
|
||||
_frameStyle = _pathView->frameStyle();
|
||||
_showGraphs = _showGraphsAction->isChecked();
|
||||
|
||||
statusBar()->hide();
|
||||
@ -824,7 +898,7 @@ void GUI::showFullscreen(bool checked)
|
||||
showToolbars(false);
|
||||
showGraphs(false);
|
||||
_showGraphsAction->setChecked(false);
|
||||
_track->setFrameStyle(QFrame::NoFrame);
|
||||
_pathView->setFrameStyle(QFrame::NoFrame);
|
||||
|
||||
showFullScreen();
|
||||
} else {
|
||||
@ -835,33 +909,59 @@ void GUI::showFullscreen(bool checked)
|
||||
_showGraphsAction->setChecked(_showGraphs);
|
||||
if (_showGraphsAction->isEnabled())
|
||||
showGraphs(_showGraphs);
|
||||
_track->setFrameStyle(_frameStyle);
|
||||
_pathView->setFrameStyle(_frameStyle);
|
||||
|
||||
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()
|
||||
{
|
||||
_currentMap->clearCache();
|
||||
_track->redraw();
|
||||
_pathView->redraw();
|
||||
}
|
||||
|
||||
void GUI::updateStatusBarInfo()
|
||||
{
|
||||
if (_files.count() == 0) {
|
||||
if (_files.count() == 0)
|
||||
_fileNameLabel->setText(tr("No GPX files loaded"));
|
||||
_distanceLabel->clear();
|
||||
_timeLabel->clear();
|
||||
return;
|
||||
} else if (_files.count() == 1)
|
||||
else if (_files.count() == 1)
|
||||
_fileNameLabel->setText(_files.at(0));
|
||||
else
|
||||
_fileNameLabel->setText(tr("%1 tracks").arg(_trackCount));
|
||||
_fileNameLabel->setText(tr("%1 files").arg(_files.count()));
|
||||
|
||||
qreal d = distance();
|
||||
Units units = _imperialUnitsAction->isChecked() ? Imperial : Metric;
|
||||
_distanceLabel->setText(distance(_distance, units));
|
||||
_timeLabel->setText(timeSpan(_time));
|
||||
if (d > 0)
|
||||
_distanceLabel->setText(::distance(distance(), units));
|
||||
else
|
||||
_distanceLabel->clear();
|
||||
|
||||
qreal t = time();
|
||||
if (t > 0)
|
||||
_timeLabel->setText(::timeSpan(time()));
|
||||
else
|
||||
_timeLabel->clear();
|
||||
}
|
||||
|
||||
void GUI::updateWindowTitle()
|
||||
@ -878,7 +978,7 @@ void GUI::mapChanged(int index)
|
||||
_currentMap = _maps.at(index);
|
||||
|
||||
if (_showMapAction->isChecked())
|
||||
_track->setMap(_currentMap);
|
||||
_pathView->setMap(_currentMap);
|
||||
}
|
||||
|
||||
void GUI::nextMap()
|
||||
@ -901,18 +1001,13 @@ void GUI::prevMap()
|
||||
|
||||
void GUI::poiFileChecked(int index)
|
||||
{
|
||||
_poi.enableFile(_poi.files().at(index),
|
||||
_poi->enableFile(_poi->files().at(index),
|
||||
_poiFilesActions.at(index)->isChecked());
|
||||
|
||||
_track->clearPOI();
|
||||
if (_showPOIAction->isChecked())
|
||||
_track->loadPOI(_poi);
|
||||
}
|
||||
|
||||
void GUI::sliderPositionChanged(qreal pos)
|
||||
{
|
||||
_sliderPos = pos;
|
||||
_track->movePositionMarker(_sliderPos);
|
||||
}
|
||||
|
||||
void GUI::graphChanged(int index)
|
||||
@ -920,8 +1015,8 @@ void GUI::graphChanged(int index)
|
||||
if (index < 0)
|
||||
return;
|
||||
|
||||
GraphView *gv = static_cast<GraphView*>(_trackGraphs->widget(index));
|
||||
gv->setSliderPosition(_sliderPos);
|
||||
GraphTab *gt = static_cast<GraphTab*>(_graphTabWidget->widget(index));
|
||||
gt->setSliderPosition(_sliderPos);
|
||||
}
|
||||
|
||||
void GUI::updateNavigationActions()
|
||||
@ -950,45 +1045,48 @@ void GUI::updateGraphTabs()
|
||||
|
||||
for (int i = 0; i < _tabs.size(); i++) {
|
||||
tab = _tabs.at(i);
|
||||
if (!tab->count() && (index = _trackGraphs->indexOf(tab)) >= 0)
|
||||
_trackGraphs->removeTab(index);
|
||||
if (!tab->count() && (index = _graphTabWidget->indexOf(tab)) >= 0)
|
||||
_graphTabWidget->removeTab(index);
|
||||
}
|
||||
|
||||
for (int i = 0; i < _tabs.size(); i++) {
|
||||
tab = _tabs.at(i);
|
||||
if (tab->count() && _trackGraphs->indexOf(tab) < 0)
|
||||
_trackGraphs->insertTab(i, tab, _tabs.at(i)->label());
|
||||
if (tab->count() && _graphTabWidget->indexOf(tab) < 0)
|
||||
_graphTabWidget->insertTab(i, tab, _tabs.at(i)->label());
|
||||
}
|
||||
|
||||
if (_trackGraphs->count()) {
|
||||
if (_graphTabWidget->count()) {
|
||||
if (_showGraphsAction->isChecked())
|
||||
_trackGraphs->setHidden(false);
|
||||
_graphTabWidget->setHidden(false);
|
||||
_showGraphsAction->setEnabled(true);
|
||||
} else {
|
||||
_trackGraphs->setHidden(true);
|
||||
_graphTabWidget->setHidden(true);
|
||||
_showGraphsAction->setEnabled(false);
|
||||
}
|
||||
}
|
||||
|
||||
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++)
|
||||
_tabs.at(i)->setUnits(Metric);
|
||||
_tabs.at(i)->setUnits(units);
|
||||
updateStatusBarInfo();
|
||||
}
|
||||
|
||||
void GUI::setImperialUnits()
|
||||
void GUI::setGraphType(GraphType type)
|
||||
{
|
||||
_track->setUnits(Imperial);
|
||||
for (int i = 0; i <_tabs.count(); i++)
|
||||
_tabs.at(i)->setUnits(Imperial);
|
||||
updateStatusBarInfo();
|
||||
_sliderPos = 0;
|
||||
|
||||
for (int i = 0; i <_tabs.count(); i++) {
|
||||
_tabs.at(i)->setGraphType(type);
|
||||
_tabs.at(i)->setSliderPosition(0);
|
||||
}
|
||||
}
|
||||
|
||||
void GUI::next()
|
||||
@ -1070,6 +1168,28 @@ void GUI::closeEvent(QCloseEvent *event)
|
||||
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()
|
||||
{
|
||||
QSettings settings(APP_NAME, APP_NAME);
|
||||
@ -1083,7 +1203,6 @@ void GUI::writeSettings()
|
||||
settings.setValue(UNITS_SETTING, _imperialUnitsAction->isChecked()
|
||||
? Imperial : Metric);
|
||||
settings.setValue(SHOW_TOOLBARS_SETTING, _showToolbarsAction->isChecked());
|
||||
settings.setValue(SHOW_GRAPHS_SETTING, _showGraphsAction->isChecked());
|
||||
settings.endGroup();
|
||||
|
||||
settings.beginGroup(MAP_SETTINGS_GROUP);
|
||||
@ -1092,6 +1211,12 @@ void GUI::writeSettings()
|
||||
settings.setValue(SHOW_MAP_SETTING, _showMapAction->isChecked());
|
||||
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.setValue(SHOW_POI_SETTING, _showPOIAction->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++) {
|
||||
if (!_poiFilesActions.at(i)->isChecked()) {
|
||||
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.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()
|
||||
@ -1125,16 +1262,10 @@ void GUI::readSettings()
|
||||
_imperialUnitsAction->setChecked(true);
|
||||
} else
|
||||
_metricUnitsAction->setChecked(true);
|
||||
if (settings.value(SHOW_TOOLBARS_SETTING, true).toBool() == false) {
|
||||
if (settings.value(SHOW_TOOLBARS_SETTING, true).toBool() == false)
|
||||
showToolbars(false);
|
||||
_showToolbarsAction->setChecked(false);
|
||||
} else
|
||||
else
|
||||
_showToolbarsAction->setChecked(true);
|
||||
if (settings.value(SHOW_GRAPHS_SETTING, true).toBool() == false) {
|
||||
showGraphs(false);
|
||||
_showGraphsAction->setChecked(false);
|
||||
} else
|
||||
_showGraphsAction->setChecked(true);
|
||||
settings.endGroup();
|
||||
|
||||
settings.beginGroup(MAP_SETTINGS_GROUP);
|
||||
@ -1145,33 +1276,77 @@ void GUI::readSettings()
|
||||
_mapActions.at(index)->setChecked(true);
|
||||
_currentMap = _maps.at(index);
|
||||
if (_showMapAction->isChecked())
|
||||
_track->setMap(_currentMap);
|
||||
_pathView->setMap(_currentMap);
|
||||
} else
|
||||
_currentMap = 0;
|
||||
settings.endGroup();
|
||||
|
||||
settings.beginGroup(POI_SETTINGS_GROUP);
|
||||
if (settings.value(OVERLAP_POI_SETTING, true).toBool() == false) {
|
||||
_track->setPOIOverlap(false);
|
||||
_overlapPOIAction->setChecked(false);
|
||||
settings.beginGroup(GRAPH_SETTINGS_GROUP);
|
||||
if (settings.value(SHOW_GRAPHS_SETTING, true).toBool() == false)
|
||||
showGraphs(false);
|
||||
else
|
||||
_showGraphsAction->setChecked(true);
|
||||
if (settings.value(GRAPH_TYPE_SETTING, Distance).toInt() == Time) {
|
||||
setTimeGraph();
|
||||
_timeGraphAction->setChecked(true);
|
||||
} 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);
|
||||
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)
|
||||
_showPOIAction->setChecked(true);
|
||||
else
|
||||
_pathView->showPOI(false);
|
||||
for (int i = 0; i < _poiFilesActions.count(); i++)
|
||||
_poiFilesActions.at(i)->setChecked(true);
|
||||
int size = settings.beginReadArray(DISABLED_POI_FILE_SETTINGS_PREFIX);
|
||||
for (int i = 0; i < size; i++) {
|
||||
settings.setArrayIndex(i);
|
||||
int index = _poi.files().indexOf(settings.value(
|
||||
int index = _poi->files().indexOf(settings.value(
|
||||
DISABLED_POI_FILE_SETTING).toString());
|
||||
if (index >= 0) {
|
||||
_poi.enableFile(_poi.files().at(index), false);
|
||||
_poi->enableFile(_poi->files().at(index), false);
|
||||
_poiFilesActions.at(index)->setChecked(false);
|
||||
}
|
||||
}
|
||||
settings.endArray();
|
||||
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)
|
||||
@ -1182,3 +1357,20 @@ int GUI::mapIndex(const QString &name)
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
qreal GUI::distance()
|
||||
{
|
||||
qreal dist = 0;
|
||||
|
||||
if (_showTracksAction->isChecked())
|
||||
dist += _trackDistance;
|
||||
if (_showRoutesAction->isChecked())
|
||||
dist += _routeDistance;
|
||||
|
||||
return dist;
|
||||
}
|
||||
|
||||
qreal GUI::time()
|
||||
{
|
||||
return (_showTracksAction->isChecked()) ? _time : 0;
|
||||
}
|
||||
|
57
src/gui.h
57
src/gui.h
@ -6,6 +6,8 @@
|
||||
#include <QList>
|
||||
#include <QDate>
|
||||
#include <QPrinter>
|
||||
#include "units.h"
|
||||
#include "graph.h"
|
||||
#include "poi.h"
|
||||
#include "margins.h"
|
||||
|
||||
@ -19,7 +21,7 @@ class QSignalMapper;
|
||||
class QPrinter;
|
||||
class FileBrowser;
|
||||
class GraphTab;
|
||||
class TrackView;
|
||||
class PathView;
|
||||
class Map;
|
||||
|
||||
class GUI : public QMainWindow
|
||||
@ -43,12 +45,12 @@ private slots:
|
||||
void reloadFile();
|
||||
void openPOIFile();
|
||||
void closePOIFiles();
|
||||
void overlapPOIs(bool checked);
|
||||
void showPOI(bool checked);
|
||||
void showMap(bool checked);
|
||||
void showGraphs(bool checked);
|
||||
void showToolbars(bool checked);
|
||||
void showFullscreen(bool checked);
|
||||
void showTracks(bool show);
|
||||
void showRoutes(bool show);
|
||||
void clearMapCache();
|
||||
void nextMap();
|
||||
void prevMap();
|
||||
@ -62,8 +64,10 @@ private slots:
|
||||
void last();
|
||||
void first();
|
||||
|
||||
void setMetricUnits();
|
||||
void setImperialUnits();
|
||||
void setMetricUnits() {setUnits(Metric);}
|
||||
void setImperialUnits() {setUnits(Imperial);}
|
||||
void setDistanceGraph() {setGraphType(Distance);}
|
||||
void setTimeGraph() {setGraphType(Time);}
|
||||
|
||||
void sliderPositionChanged(qreal pos);
|
||||
|
||||
@ -82,8 +86,8 @@ private:
|
||||
void createMenus();
|
||||
void createToolBars();
|
||||
void createStatusBar();
|
||||
void createTrackView();
|
||||
void createTrackGraphs();
|
||||
void createPathView();
|
||||
void createGraphTabs();
|
||||
|
||||
bool openPOIFile(const QString &fileName);
|
||||
bool loadFile(const QString &fileName);
|
||||
@ -94,28 +98,27 @@ private:
|
||||
void updateGraphTabs();
|
||||
void updateTrackView();
|
||||
|
||||
void keyPressEvent(QKeyEvent * event);
|
||||
void closeEvent(QCloseEvent *event);
|
||||
void setUnits(Units units);
|
||||
void setGraphType(GraphType type);
|
||||
|
||||
qreal distance();
|
||||
qreal time();
|
||||
int mapIndex(const QString &name);
|
||||
void readSettings();
|
||||
void writeSettings();
|
||||
|
||||
QMenu *_fileMenu;
|
||||
QMenu *_helpMenu;
|
||||
QMenu *_poiMenu;
|
||||
QMenu *_mapMenu;
|
||||
QMenu *_settingsMenu;
|
||||
QMenu *_unitsMenu;
|
||||
QMenu *_poiFilesMenu;
|
||||
void keyPressEvent(QKeyEvent *event);
|
||||
void closeEvent(QCloseEvent *event);
|
||||
void dragEnterEvent(QDragEnterEvent *event);
|
||||
void dropEvent(QDropEvent *event);
|
||||
|
||||
QToolBar *_fileToolBar;
|
||||
QToolBar *_showToolBar;
|
||||
QToolBar *_navigationToolBar;
|
||||
QTabWidget *_trackGraphs;
|
||||
QMenu *_poiFilesMenu;
|
||||
|
||||
QActionGroup *_fileActionGroup;
|
||||
QActionGroup *_navigationActionGroup;
|
||||
|
||||
QAction *_exitAction;
|
||||
QAction *_keysAction;
|
||||
QAction *_dataSourcesAction;
|
||||
@ -130,10 +133,13 @@ private:
|
||||
QAction *_closePOIAction;
|
||||
QAction *_showPOIAction;
|
||||
QAction *_overlapPOIAction;
|
||||
QAction *_showPOILabelsAction;
|
||||
QAction *_showMapAction;
|
||||
QAction *_fullscreenAction;
|
||||
QAction *_clearMapCacheAction;
|
||||
QAction *_showGraphsAction;
|
||||
QAction *_distanceGraphAction;
|
||||
QAction *_timeGraphAction;
|
||||
QAction *_showToolbarsAction;
|
||||
QAction *_nextAction;
|
||||
QAction *_prevAction;
|
||||
@ -143,6 +149,11 @@ private:
|
||||
QAction *_imperialUnitsAction;
|
||||
QAction *_nextMapAction;
|
||||
QAction *_prevMapAction;
|
||||
QAction *_showTracksAction;
|
||||
QAction *_showRoutesAction;
|
||||
QAction *_showWaypointsAction;
|
||||
QAction *_showWaypointLabelsAction;
|
||||
QAction *_showRouteWaypointsAction;
|
||||
QList<QAction*> _mapActions;
|
||||
QList<QAction*> _poiFilesActions;
|
||||
|
||||
@ -152,10 +163,11 @@ private:
|
||||
QLabel *_distanceLabel;
|
||||
QLabel *_timeLabel;
|
||||
|
||||
TrackView *_track;
|
||||
PathView *_pathView;
|
||||
QTabWidget *_graphTabWidget;
|
||||
QList<GraphTab*> _tabs;
|
||||
|
||||
POI _poi;
|
||||
POI *_poi;
|
||||
QList<Map*> _maps;
|
||||
|
||||
FileBrowser *_browser;
|
||||
@ -163,7 +175,10 @@ private:
|
||||
Map *_currentMap;
|
||||
|
||||
int _trackCount;
|
||||
qreal _distance;
|
||||
int _routeCount;
|
||||
int _waypointCount;
|
||||
qreal _trackDistance;
|
||||
qreal _routeDistance;
|
||||
qreal _time;
|
||||
DateRange _dateRange;
|
||||
|
||||
|
@ -5,47 +5,52 @@
|
||||
HeartRateGraph::HeartRateGraph(QWidget *parent) : GraphTab(parent)
|
||||
{
|
||||
_units = Metric;
|
||||
_showTracks = true;
|
||||
|
||||
GraphView::setYUnits(tr("1/min"));
|
||||
setXLabel(tr("Distance"));
|
||||
setYLabel(tr("Heart rate"));
|
||||
|
||||
setSliderPrecision(0);
|
||||
}
|
||||
|
||||
void HeartRateGraph::addInfo()
|
||||
void HeartRateGraph::setInfo()
|
||||
{
|
||||
GraphView::addInfo(tr("Average"), QString::number(avg() * yScale(), 'f', 0)
|
||||
+ UNIT_SPACE + yUnits());
|
||||
GraphView::addInfo(tr("Maximum"), QString::number(max() * yScale(), 'f', 0)
|
||||
+ UNIT_SPACE + yUnits());
|
||||
|
||||
redraw();
|
||||
if (_showTracks) {
|
||||
GraphView::addInfo(tr("Average"), QString::number(avg() * yScale(), 'f',
|
||||
0) + UNIT_SPACE + yUnits());
|
||||
GraphView::addInfo(tr("Maximum"), QString::number(max() * yScale(), 'f',
|
||||
0) + UNIT_SPACE + yUnits());
|
||||
} else
|
||||
clearInfo();
|
||||
}
|
||||
|
||||
void HeartRateGraph::loadGPX(const GPX &gpx)
|
||||
void HeartRateGraph::loadGPX(const GPX &gpx, const QList<PathItem *> &paths)
|
||||
{
|
||||
for (int i = 0; i < gpx.trackCount(); i++) {
|
||||
QVector<QPointF> data;
|
||||
for (int i = 0; i < gpx.tracks().count(); i++) {
|
||||
const Graph &graph = gpx.tracks().at(i)->heartRate();
|
||||
qreal sum = 0, w = 0;
|
||||
|
||||
gpx.track(i).heartRateGraph(data);
|
||||
if (data.count() < 2) {
|
||||
if (graph.size() < 2) {
|
||||
skipColor();
|
||||
continue;
|
||||
}
|
||||
|
||||
for (int j = 1; j < data.size(); j++) {
|
||||
sum += data.at(j).y() * (data.at(j).x() - data.at(j-1).x());
|
||||
w += data.at(j).x() - data.at(j-1).x();
|
||||
for (int j = 1; j < graph.size(); j++) {
|
||||
qreal ds = graph.at(j).s() - graph.at(j-1).s();
|
||||
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();
|
||||
addInfo();
|
||||
for (int i = 0; i < gpx.routes().count(); i++)
|
||||
skipColor();
|
||||
|
||||
setInfo();
|
||||
|
||||
redraw();
|
||||
}
|
||||
|
||||
qreal HeartRateGraph::avg() const
|
||||
@ -68,32 +73,12 @@ void HeartRateGraph::clear()
|
||||
GraphView::clear();
|
||||
}
|
||||
|
||||
void HeartRateGraph::setXUnits()
|
||||
void HeartRateGraph::showTracks(bool show)
|
||||
{
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
_showTracks = show;
|
||||
|
||||
void HeartRateGraph::setUnits(enum Units units)
|
||||
{
|
||||
_units = units;
|
||||
setXUnits();
|
||||
showGraph(show);
|
||||
setInfo();
|
||||
|
||||
clearInfo();
|
||||
addInfo();
|
||||
redraw();
|
||||
}
|
||||
|
@ -3,8 +3,6 @@
|
||||
|
||||
#include "graphtab.h"
|
||||
|
||||
class GPX;
|
||||
|
||||
class HeartRateGraph : public GraphTab
|
||||
{
|
||||
Q_OBJECT
|
||||
@ -13,18 +11,21 @@ public:
|
||||
HeartRateGraph(QWidget *parent = 0);
|
||||
|
||||
QString label() const {return tr("Heart rate");}
|
||||
void loadGPX(const GPX &gpx);
|
||||
void loadGPX(const GPX &gpx, const QList<PathItem *> &paths);
|
||||
void clear();
|
||||
void setUnits(enum Units units);
|
||||
void setUnits(enum Units) {}
|
||||
void showTracks(bool show);
|
||||
void showRoutes(bool show) {Q_UNUSED(show);}
|
||||
|
||||
private:
|
||||
qreal avg() const;
|
||||
qreal max() const {return bounds().bottom();}
|
||||
void setXUnits();
|
||||
void addInfo();
|
||||
void setInfo();
|
||||
|
||||
QList<QPointF> _avg;
|
||||
|
||||
enum Units _units;
|
||||
bool _showTracks;
|
||||
};
|
||||
|
||||
#endif // HEARTRATEGRAPH_H
|
||||
|
@ -8,6 +8,7 @@
|
||||
#define CLOSE_FILE_ICON ":/icons/dialog-close.png"
|
||||
#define SHOW_POI_ICON ":/icons/flag.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 RELOAD_FILE_ICON ":/icons/view-refresh.png"
|
||||
#define NEXT_FILE_ICON ":/icons/arrow-right.png"
|
||||
|
36
src/keys.h
36
src/keys.h
@ -4,26 +4,28 @@
|
||||
#include <Qt>
|
||||
#include <QKeySequence>
|
||||
|
||||
#define NEXT_KEY Qt::Key_Space
|
||||
#define PREV_KEY Qt::Key_Backspace
|
||||
#define FIRST_KEY Qt::Key_Home
|
||||
#define LAST_KEY Qt::Key_End
|
||||
#define MODIFIER Qt::ShiftModifier
|
||||
#define NEXT_KEY Qt::Key_Space
|
||||
#define PREV_KEY Qt::Key_Backspace
|
||||
#define FIRST_KEY Qt::Key_Home
|
||||
#define LAST_KEY Qt::Key_End
|
||||
#define MODIFIER Qt::ShiftModifier
|
||||
|
||||
#define QUIT_SHORTCUT QKeySequence::Quit
|
||||
#define OPEN_SHORTCUT QKeySequence::Open
|
||||
#define CLOSE_SHORTCUT QKeySequence::Close
|
||||
#define RELOAD_SHORTCUT QKeySequence::Refresh
|
||||
#define EXPORT_SHORTCUT QKeySequence(Qt::CTRL + Qt::Key_E)
|
||||
#define SHOW_POI_SHORTCUT QKeySequence(Qt::CTRL + Qt::Key_P)
|
||||
#define SHOW_MAP_SHORTCUT QKeySequence(Qt::CTRL + Qt::Key_M)
|
||||
#define NEXT_MAP_SHORTCUT QKeySequence::Forward
|
||||
#define PREV_MAP_SHORTCUT QKeySequence::Back
|
||||
#define SHOW_GRAPHS_SHORTCUT QKeySequence(Qt::CTRL + Qt::Key_G)
|
||||
#define QUIT_SHORTCUT QKeySequence::Quit
|
||||
#define OPEN_SHORTCUT QKeySequence::Open
|
||||
#define CLOSE_SHORTCUT QKeySequence::Close
|
||||
#define RELOAD_SHORTCUT QKeySequence::Refresh
|
||||
#define EXPORT_SHORTCUT QKeySequence(Qt::CTRL + Qt::Key_E)
|
||||
#define SHOW_POI_SHORTCUT QKeySequence(Qt::CTRL + Qt::Key_P)
|
||||
#define SHOW_MAP_SHORTCUT QKeySequence(Qt::CTRL + Qt::Key_M)
|
||||
#define NEXT_MAP_SHORTCUT QKeySequence::Forward
|
||||
#define PREV_MAP_SHORTCUT QKeySequence::Back
|
||||
#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
|
||||
#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
|
||||
#define FULLSCREEN_SHORTCUT QKeySequence(Qt::Key_F11)
|
||||
#define FULLSCREEN_SHORTCUT QKeySequence(Qt::Key_F11)
|
||||
#endif // Q_OS_MAC
|
||||
|
||||
#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)
|
||||
{
|
||||
_track->last().setCoordinates(QPointF(
|
||||
@ -59,6 +83,13 @@ void Parser::handleTrackpointAttributes(const QXmlStreamAttributes &attr)
|
||||
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)
|
||||
{
|
||||
_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()
|
||||
{
|
||||
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()
|
||||
{
|
||||
while (_reader.readNextStartElement()) {
|
||||
@ -157,6 +218,10 @@ void Parser::gpx()
|
||||
_tracks.append(QVector<Trackpoint>());
|
||||
_track = &_tracks.back();
|
||||
track();
|
||||
} else if (_reader.name() == "rte") {
|
||||
_routes.append(QVector<Waypoint>());
|
||||
_route = &_routes.back();
|
||||
routepoints();
|
||||
} else if (_reader.name() == "wpt") {
|
||||
_waypoints.append(Waypoint());
|
||||
handleWaypointAttributes(_reader.attributes());
|
||||
|
13
src/parser.h
13
src/parser.h
@ -11,8 +11,11 @@
|
||||
class Parser
|
||||
{
|
||||
public:
|
||||
Parser(QList<QVector<Trackpoint> > &tracks, QList<Waypoint> &waypoints)
|
||||
: _tracks(tracks), _waypoints(waypoints) {_track = 0;}
|
||||
Parser(QList<QVector<Trackpoint> > &tracks,
|
||||
QList<QVector<Waypoint> > &routes, QList<Waypoint> &waypoints)
|
||||
: _tracks(tracks), _routes(routes), _waypoints(waypoints)
|
||||
{_track = 0; _route = 0;}
|
||||
|
||||
bool loadFile(QIODevice *device);
|
||||
QString errorString() const {return _reader.errorString();}
|
||||
int errorLine() const {return _reader.lineNumber();}
|
||||
@ -27,20 +30,26 @@ private:
|
||||
void gpx();
|
||||
void track();
|
||||
void trackpoints();
|
||||
void routepoints();
|
||||
void tpExtension();
|
||||
void extensions();
|
||||
void trackpointData();
|
||||
void routepointData();
|
||||
void waypointData();
|
||||
|
||||
void handleWaypointAttributes(const QXmlStreamAttributes &attr);
|
||||
void handleWaypointData(DataType type, const QString &value);
|
||||
void handleTrackpointAttributes(const QXmlStreamAttributes &attr);
|
||||
void handleTrackpointData(DataType type, const QString &value);
|
||||
void handleRoutepointAttributes(const QXmlStreamAttributes &attr);
|
||||
void handleRoutepointData(DataType type, const QString &value);
|
||||
|
||||
QXmlStreamReader _reader;
|
||||
QList<QVector<Trackpoint> > &_tracks;
|
||||
QList<QVector<Waypoint> > &_routes;
|
||||
QList<Waypoint> &_waypoints;
|
||||
QVector<Trackpoint> *_track;
|
||||
QVector<Waypoint> *_route;
|
||||
};
|
||||
|
||||
#endif // PARSER_H
|
||||
|
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 <QGraphicsScene>
|
||||
#include <QPainterPath>
|
||||
#include <QWheelEvent>
|
||||
#include "ll.h"
|
||||
#include "poi.h"
|
||||
#include "gpx.h"
|
||||
#include "map.h"
|
||||
#include "trackitem.h"
|
||||
#include "routeitem.h"
|
||||
#include "waypointitem.h"
|
||||
#include "markeritem.h"
|
||||
#include "scaleitem.h"
|
||||
#include "trackview.h"
|
||||
#include "pathview.h"
|
||||
|
||||
|
||||
#define MARGIN 10.0
|
||||
#define SCALE_OFFSET 7
|
||||
|
||||
TrackView::TrackView(QWidget *parent)
|
||||
PathView::PathView(QWidget *parent)
|
||||
: QGraphicsView(parent)
|
||||
{
|
||||
_scene = new QGraphicsScene(this);
|
||||
@ -27,6 +26,7 @@ TrackView::TrackView(QWidget *parent)
|
||||
setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
|
||||
setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
|
||||
setRenderHints(QPainter::Antialiasing);
|
||||
setAcceptDrops(false);
|
||||
|
||||
_mapScale = new ScaleItem();
|
||||
_mapScale->setZValue(2.0);
|
||||
@ -34,45 +34,75 @@ TrackView::TrackView(QWidget *parent)
|
||||
_zoom = ZOOM_MAX;
|
||||
_scale = mapScale(_zoom);
|
||||
_map = 0;
|
||||
_maxPath = 0;
|
||||
_maxDistance = 0;
|
||||
_poi = 0;
|
||||
|
||||
_units = Metric;
|
||||
|
||||
_showTracks = true;
|
||||
_showRoutes = true;
|
||||
_showWaypoints = true;
|
||||
_showWaypointLabels = true;
|
||||
_showPOI = true;
|
||||
_showPOILabels = true;
|
||||
_overlapPOIs = true;
|
||||
_showRouteWaypoints = true;
|
||||
|
||||
_plot = false;
|
||||
_units = Metric;
|
||||
_overlap = true;
|
||||
}
|
||||
|
||||
TrackView::~TrackView()
|
||||
PathView::~PathView()
|
||||
{
|
||||
if (_mapScale->scene() != _scene)
|
||||
delete _mapScale;
|
||||
}
|
||||
|
||||
void TrackView::addTrack(const Track &track)
|
||||
PathItem *PathView::addTrack(const Track &track)
|
||||
{
|
||||
if (track.isNull()) {
|
||||
_palette.color();
|
||||
return;
|
||||
return 0;
|
||||
}
|
||||
|
||||
TrackItem *pi = new TrackItem(track);
|
||||
_paths.append(pi);
|
||||
TrackItem *ti = new TrackItem(track);
|
||||
_tracks.append(ti);
|
||||
_zoom = qMin(_zoom, scale2zoom(trackScale()));
|
||||
_scale = mapScale(_zoom);
|
||||
pi->setScale(1.0/_scale);
|
||||
pi->setColor(_palette.color());
|
||||
_scene->addItem(pi);
|
||||
ti->setScale(1.0/_scale);
|
||||
ti->setColor(_palette.color());
|
||||
ti->setVisible(_showTracks);
|
||||
_scene->addItem(ti);
|
||||
|
||||
MarkerItem *mi = new MarkerItem(pi);
|
||||
_markers.append(mi);
|
||||
mi->setPos(pi->path().pointAtPercent(0));
|
||||
mi->setScale(_scale);
|
||||
if (_poi)
|
||||
addPOI(_poi->points(ti));
|
||||
|
||||
_maxPath = qMax(pi->path().length(), _maxPath);
|
||||
_maxDistance = qMax(track.distance(), _maxDistance);
|
||||
return ti;
|
||||
}
|
||||
|
||||
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++) {
|
||||
const Waypoint &w = waypoints.at(i);
|
||||
@ -80,54 +110,79 @@ void TrackView::addWaypoints(const QList<Waypoint> &waypoints)
|
||||
WaypointItem *wi = new WaypointItem(w);
|
||||
wi->setScale(1.0/_scale);
|
||||
wi->setZValue(1);
|
||||
wi->showLabel(_showWaypointLabels);
|
||||
wi->setVisible(_showWaypoints);
|
||||
_scene->addItem(wi);
|
||||
|
||||
_waypoints.append(wi);
|
||||
}
|
||||
|
||||
if (_poi)
|
||||
addPOI(_poi->points(waypoints));
|
||||
|
||||
_zoom = qMin(_zoom, scale2zoom(waypointScale()));
|
||||
_scale = mapScale(_zoom);
|
||||
}
|
||||
|
||||
void TrackView::loadGPX(const GPX &gpx)
|
||||
QList<PathItem *> PathView::loadGPX(const GPX &gpx)
|
||||
{
|
||||
QList<PathItem *> paths;
|
||||
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());
|
||||
|
||||
if (_paths.empty() && _waypoints.empty())
|
||||
return;
|
||||
if (_tracks.empty() && _routes.empty() && _waypoints.empty())
|
||||
return paths;
|
||||
|
||||
if ((_paths.size() > 1 && _zoom < zoom)
|
||||
if ((_tracks.size() + _routes.size() > 1 && _zoom < zoom)
|
||||
|| (_waypoints.size() && _zoom < zoom))
|
||||
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);
|
||||
_scene->setSceneRect(ba);
|
||||
centerOn(ba.center());
|
||||
|
||||
_mapScale->setLatitude(-(br.center().ry() * _scale));
|
||||
_mapScale->setZoom(_zoom);
|
||||
_mapScale->setZoom(_zoom, -(br.center().ry() * _scale));
|
||||
if (_mapScale->scene() != _scene)
|
||||
_scene->addItem(_mapScale);
|
||||
|
||||
return paths;
|
||||
}
|
||||
|
||||
QRectF TrackView::trackBoundingRect() const
|
||||
QRectF PathView::trackBoundingRect() const
|
||||
{
|
||||
if (_paths.empty())
|
||||
if (_tracks.empty())
|
||||
return QRectF();
|
||||
|
||||
QRectF br = _paths.at(0)->sceneBoundingRect();
|
||||
for (int i = 1; i < _paths.size(); i++)
|
||||
br |= _paths.at(i)->sceneBoundingRect();
|
||||
QRectF br = _tracks.at(0)->sceneBoundingRect();
|
||||
for (int i = 1; i < _tracks.size(); i++)
|
||||
br |= _tracks.at(i)->sceneBoundingRect();
|
||||
|
||||
return br;
|
||||
}
|
||||
|
||||
QRectF TrackView::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;
|
||||
|
||||
@ -151,15 +206,15 @@ QRectF TrackView::waypointBoundingRect() const
|
||||
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);
|
||||
|
||||
QRectF br = _paths.at(0)->path().boundingRect();
|
||||
QRectF br = _tracks.at(0)->path().boundingRect();
|
||||
|
||||
for (int i = 1; i < _paths.size(); i++)
|
||||
br |= _paths.at(i)->path().boundingRect();
|
||||
for (int i = 1; i < _tracks.size(); i++)
|
||||
br |= _tracks.at(i)->path().boundingRect();
|
||||
|
||||
QPointF sc(br.width() / (viewport()->width() - MARGIN/2),
|
||||
br.height() / (viewport()->height() - MARGIN/2));
|
||||
@ -167,7 +222,23 @@ qreal TrackView::trackScale() const
|
||||
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;
|
||||
|
||||
@ -195,47 +266,88 @@ qreal TrackView::waypointScale() const
|
||||
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);
|
||||
}
|
||||
|
||||
void TrackView::checkPOIOverlap()
|
||||
void PathView::updatePOIVisibility()
|
||||
{
|
||||
QHash<Waypoint, WaypointItem*>::const_iterator it, jt;
|
||||
|
||||
for (it = _pois.constBegin(); it != _pois.constEnd(); it++) {
|
||||
for (jt = _pois.constBegin(); jt != _pois.constEnd(); jt++) {
|
||||
if (it != jt && it.value()->isVisible() && jt.value()->isVisible()
|
||||
&& it.value()->collidesWithItem(jt.value()))
|
||||
jt.value()->hide();
|
||||
if (!_showPOI)
|
||||
return;
|
||||
|
||||
for (it = _pois.constBegin(); it != _pois.constEnd(); it++)
|
||||
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++) {
|
||||
_markers.at(i)->setScale(scale);
|
||||
_paths.at(i)->setScale(1.0/scale);
|
||||
}
|
||||
_scale = scale;
|
||||
|
||||
for (int i = 0; i < _tracks.size(); i++)
|
||||
_tracks.at(i)->setScale(1.0/scale);
|
||||
|
||||
for (int i = 0; i < _routes.size(); i++)
|
||||
_routes.at(i)->setScale(1.0/scale);
|
||||
|
||||
for (int i = 0; i < _waypoints.size(); i++)
|
||||
_waypoints.at(i)->setScale(1.0/scale);
|
||||
|
||||
QHash<Waypoint, WaypointItem*>::const_iterator it;
|
||||
for (it = _pois.constBegin(); it != _pois.constEnd(); it++) {
|
||||
for (it = _pois.constBegin(); it != _pois.constEnd(); it++)
|
||||
it.value()->setScale(1.0/scale);
|
||||
it.value()->show();
|
||||
}
|
||||
|
||||
if (!_overlap)
|
||||
checkPOIOverlap();
|
||||
|
||||
_scale = scale;
|
||||
updatePOIVisibility();
|
||||
}
|
||||
|
||||
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++) {
|
||||
const Waypoint &w = waypoints.at(i);
|
||||
@ -246,43 +358,37 @@ void TrackView::addPOI(const QVector<Waypoint> &waypoints)
|
||||
WaypointItem *pi = new WaypointItem(w);
|
||||
pi->setScale(1.0/_scale);
|
||||
pi->setZValue(1);
|
||||
pi->showLabel(_showPOILabels);
|
||||
pi->setVisible(_showPOI);
|
||||
_scene->addItem(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)
|
||||
connect(_map, SIGNAL(loaded()), this, SLOT(redraw()),
|
||||
Qt::UniqueConnection);
|
||||
disconnect(_map, SIGNAL(loaded()), this, SLOT(redraw()));
|
||||
|
||||
_map = map;
|
||||
|
||||
if (_map)
|
||||
connect(_map, SIGNAL(loaded()), this, SLOT(redraw()));
|
||||
|
||||
resetCachedContent();
|
||||
}
|
||||
|
||||
void TrackView::setUnits(enum Units units)
|
||||
void PathView::setUnits(enum Units units)
|
||||
{
|
||||
_units = units;
|
||||
|
||||
_mapScale->setUnits(units);
|
||||
|
||||
for (int i = 0; i < _paths.count(); i++)
|
||||
_paths[i]->setUnits(units);
|
||||
|
||||
for (int i = 0; i < _tracks.count(); i++)
|
||||
_tracks[i]->setUnits(units);
|
||||
for (int i = 0; i < _routes.count(); i++)
|
||||
_routes[i]->setUnits(units);
|
||||
for (int i = 0; i < _waypoints.size(); i++)
|
||||
_waypoints.at(i)->setUnits(units);
|
||||
|
||||
@ -291,28 +397,31 @@ void TrackView::setUnits(enum Units units)
|
||||
it.value()->setUnits(units);
|
||||
}
|
||||
|
||||
void TrackView::redraw()
|
||||
void PathView::redraw()
|
||||
{
|
||||
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));
|
||||
_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;
|
||||
|
||||
qreal scale = _scale;
|
||||
_zoom = z;
|
||||
|
||||
rescale(mapScale(_zoom));
|
||||
QRectF br = trackBoundingRect() | waypointBoundingRect();
|
||||
QRectF br = trackBoundingRect() | routeBoundingRect()
|
||||
| waypointBoundingRect();
|
||||
QRectF ba = br.adjusted(-TILE_SIZE, -TILE_SIZE, TILE_SIZE, TILE_SIZE);
|
||||
_scene->setSceneRect(ba);
|
||||
|
||||
@ -327,9 +436,9 @@ void TrackView::zoom(int z, const QPointF &pos)
|
||||
resetCachedContent();
|
||||
}
|
||||
|
||||
void TrackView::wheelEvent(QWheelEvent *event)
|
||||
void PathView::wheelEvent(QWheelEvent *event)
|
||||
{
|
||||
if (_paths.isEmpty() && _waypoints.isEmpty())
|
||||
if (_tracks.isEmpty() && _routes.isEmpty() && _waypoints.isEmpty())
|
||||
return;
|
||||
|
||||
QPointF pos = mapToScene(event->pos());
|
||||
@ -339,7 +448,7 @@ void TrackView::wheelEvent(QWheelEvent *event)
|
||||
zoom(z, pos);
|
||||
}
|
||||
|
||||
void TrackView::keyPressEvent(QKeyEvent *event)
|
||||
void PathView::keyPressEvent(QKeyEvent *event)
|
||||
{
|
||||
int z = -1;
|
||||
|
||||
@ -354,7 +463,7 @@ void TrackView::keyPressEvent(QKeyEvent *event)
|
||||
QWidget::keyPressEvent(event);
|
||||
}
|
||||
|
||||
void TrackView::plot(QPainter *painter, const QRectF &target)
|
||||
void PathView::plot(QPainter *painter, const QRectF &target)
|
||||
{
|
||||
QRect orig, adj;
|
||||
qreal ratio, diff;
|
||||
@ -388,69 +497,100 @@ void TrackView::plot(QPainter *painter, const QRectF &target)
|
||||
setUpdatesEnabled(true);
|
||||
}
|
||||
|
||||
void TrackView::clearPOI()
|
||||
{
|
||||
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()
|
||||
void PathView::clear()
|
||||
{
|
||||
if (_mapScale->scene() == _scene)
|
||||
_scene->removeItem(_mapScale);
|
||||
|
||||
_pois.clear();
|
||||
_paths.clear();
|
||||
_tracks.clear();
|
||||
_routes.clear();
|
||||
_waypoints.clear();
|
||||
_markers.clear();
|
||||
_scene->clear();
|
||||
_palette.reset();
|
||||
|
||||
_maxPath = 0;
|
||||
_maxDistance = 0;
|
||||
_zoom = ZOOM_MAX;
|
||||
_scale = mapScale(_zoom);
|
||||
|
||||
_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++) {
|
||||
qreal f = _maxPath / _paths.at(i)->path().length();
|
||||
if (mp * f < 0 || mp * f > 1.0)
|
||||
_markers.at(i)->setVisible(false);
|
||||
else {
|
||||
QPointF pos = _paths.at(i)->path().pointAtPercent(mp * f);
|
||||
_markers.at(i)->setPos(pos);
|
||||
_markers.at(i)->setVisible(true);
|
||||
}
|
||||
}
|
||||
for (int i = 0; i < _tracks.count(); i++)
|
||||
_tracks.at(i)->setVisible(show);
|
||||
}
|
||||
|
||||
void TrackView::setPOIOverlap(bool overlap)
|
||||
void PathView::showRoutes(bool show)
|
||||
{
|
||||
_overlap = overlap;
|
||||
_showRoutes = show;
|
||||
|
||||
if (_overlap) {
|
||||
QHash<Waypoint, WaypointItem*>::const_iterator it;
|
||||
for (it = _pois.constBegin(); it != _pois.constEnd(); it++)
|
||||
it.value()->show();
|
||||
} else
|
||||
checkPOIOverlap();
|
||||
for (int i = 0; i < _routes.count(); i++)
|
||||
_routes.at(i)->setVisible(show);
|
||||
}
|
||||
|
||||
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);
|
||||
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;
|
||||
|
||||
rescale();
|
||||
|
||||
QRectF br = trackBoundingRect() | waypointBoundingRect();
|
||||
QRectF br = trackBoundingRect() | routeBoundingRect()
|
||||
| waypointBoundingRect();
|
||||
QRectF ba = br.adjusted(-TILE_SIZE, -TILE_SIZE, TILE_SIZE, TILE_SIZE);
|
||||
|
||||
if (ba.width() < e->size().width()) {
|
||||
@ -504,7 +645,7 @@ void TrackView::resizeEvent(QResizeEvent *e)
|
||||
resetCachedContent();
|
||||
}
|
||||
|
||||
void TrackView::paintEvent(QPaintEvent *e)
|
||||
void PathView::paintEvent(QPaintEvent *e)
|
||||
{
|
||||
QPointF scenePos = mapToScene(rect().bottomRight() + QPoint(
|
||||
-(SCALE_OFFSET + _mapScale->boundingRect().width()),
|
@ -13,52 +13,69 @@ class GPX;
|
||||
class POI;
|
||||
class Map;
|
||||
class Track;
|
||||
class Route;
|
||||
class TrackItem;
|
||||
class RouteItem;
|
||||
class WaypointItem;
|
||||
class MarkerItem;
|
||||
class ScaleItem;
|
||||
class PathItem;
|
||||
|
||||
class TrackView : public QGraphicsView
|
||||
class PathView : public QGraphicsView
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
TrackView(QWidget *parent = 0);
|
||||
~TrackView();
|
||||
PathView(QWidget *parent = 0);
|
||||
~PathView();
|
||||
|
||||
void loadGPX(const GPX &gpx);
|
||||
|
||||
void loadPOI(const POI &poi);
|
||||
void clearPOI();
|
||||
void clear();
|
||||
QList<PathItem*> loadGPX(const GPX &gpx);
|
||||
|
||||
void setPOI(POI *poi);
|
||||
void setMap(Map *map);
|
||||
void setUnits(enum Units units);
|
||||
void setPOIOverlap(bool overlap);
|
||||
|
||||
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();}
|
||||
|
||||
void clear();
|
||||
|
||||
public slots:
|
||||
void movePositionMarker(qreal val);
|
||||
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:
|
||||
void addTrack(const Track &track);
|
||||
PathItem *addTrack(const Track &track);
|
||||
PathItem *addRoute(const Route &route);
|
||||
void addWaypoints(const QList<Waypoint> &waypoints);
|
||||
void addPOI(const QVector<Waypoint> &waypoints);
|
||||
void loadPOI();
|
||||
void clearPOI();
|
||||
|
||||
QRectF trackBoundingRect() const;
|
||||
QRectF routeBoundingRect() const;
|
||||
QRectF waypointBoundingRect() const;
|
||||
qreal trackScale() const;
|
||||
qreal routeScale() const;
|
||||
qreal waypointScale() const;
|
||||
qreal mapScale(int zoom) const;
|
||||
void rescale(qreal scale);
|
||||
void rescale();
|
||||
void zoom(int z, const QPointF &pos);
|
||||
void checkPOIOverlap();
|
||||
void updatePOIVisibility();
|
||||
|
||||
void wheelEvent(QWheelEvent *event);
|
||||
void keyPressEvent(QKeyEvent *event);
|
||||
@ -67,22 +84,31 @@ private:
|
||||
void paintEvent(QPaintEvent *e);
|
||||
|
||||
QGraphicsScene *_scene;
|
||||
QList<TrackItem*> _paths;
|
||||
QList<MarkerItem*> _markers;
|
||||
ScaleItem *_mapScale;
|
||||
QList<TrackItem*> _tracks;
|
||||
QList<RouteItem*> _routes;
|
||||
QList<WaypointItem*> _waypoints;
|
||||
QHash<Waypoint, WaypointItem*> _pois;
|
||||
|
||||
Map *_map;
|
||||
ScaleItem *_mapScale;
|
||||
POI *_poi;
|
||||
|
||||
Palette _palette;
|
||||
qreal _maxPath, _maxDistance;
|
||||
|
||||
qreal _scale;
|
||||
int _zoom;
|
||||
|
||||
Units _units;
|
||||
bool _overlap;
|
||||
|
||||
bool _showTracks;
|
||||
bool _showRoutes;
|
||||
bool _showWaypoints;
|
||||
bool _showWaypointLabels;
|
||||
bool _showPOI;
|
||||
bool _showPOILabels;
|
||||
bool _overlapPOIs;
|
||||
bool _showRouteWaypoints;
|
||||
|
||||
bool _plot;
|
||||
};
|
||||
|
84
src/poi.cpp
84
src/poi.cpp
@ -1,13 +1,19 @@
|
||||
#include <QFile>
|
||||
#include <QSet>
|
||||
#include <QList>
|
||||
#include <QPainterPath>
|
||||
#include "pathitem.h"
|
||||
#include "waypointitem.h"
|
||||
#include "ll.h"
|
||||
#include "gpx.h"
|
||||
#include "poi.h"
|
||||
|
||||
|
||||
POI::POI(QObject *parent) : QObject(parent)
|
||||
{
|
||||
_errorLine = 0;
|
||||
_radius = 0.01;
|
||||
}
|
||||
|
||||
bool POI::loadFile(const QString &fileName)
|
||||
{
|
||||
QString error;
|
||||
@ -16,15 +22,17 @@ bool POI::loadFile(const QString &fileName)
|
||||
_error.clear();
|
||||
_errorLine = 0;
|
||||
|
||||
|
||||
if (loadCSVFile(fileName))
|
||||
if (loadCSVFile(fileName)) {
|
||||
emit pointsChanged();
|
||||
return true;
|
||||
else {
|
||||
} else {
|
||||
error = _error;
|
||||
errorLine = _errorLine;
|
||||
}
|
||||
if (loadGPXFile(fileName))
|
||||
if (loadGPXFile(fileName)) {
|
||||
emit pointsChanged();
|
||||
return true;
|
||||
}
|
||||
|
||||
fprintf(stderr, "Error loading POI file: %s:\n", qPrintable(fileName));
|
||||
fprintf(stderr, "CSV: line %d: %s\n", errorLine, qPrintable(error));
|
||||
@ -90,20 +98,20 @@ bool POI::loadCSVFile(const QString &fileName)
|
||||
QByteArray line = file.readLine();
|
||||
QList<QByteArray> list = line.split(',');
|
||||
if (list.size() < 3) {
|
||||
_error = "Parse error";
|
||||
_error = "Parse error.";
|
||||
_errorLine = ln;
|
||||
return false;
|
||||
}
|
||||
|
||||
qreal lat = list[0].trimmed().toDouble(&ret);
|
||||
if (!ret) {
|
||||
_error = "Invalid latitude";
|
||||
_error = "Invalid latitude.";
|
||||
_errorLine = ln;
|
||||
return false;
|
||||
}
|
||||
qreal lon = list[1].trimmed().toDouble(&ret);
|
||||
if (!ret) {
|
||||
_error = "Invalid longitude";
|
||||
_error = "Invalid longitude.";
|
||||
_errorLine = ln;
|
||||
return false;
|
||||
}
|
||||
@ -145,18 +153,19 @@ static bool cb(size_t data, void* context)
|
||||
return true;
|
||||
}
|
||||
|
||||
QVector<Waypoint> POI::points(const QPainterPath &path, qreal radius) const
|
||||
QVector<Waypoint> POI::points(const PathItem *path) const
|
||||
{
|
||||
QVector<Waypoint> ret;
|
||||
QSet<int> set;
|
||||
qreal min[2], max[2];
|
||||
const QPainterPath &pp = path->path();
|
||||
|
||||
for (int i = 0; i < path.elementCount(); i++) {
|
||||
QPointF p = mercator2ll(path.elementAt(i));
|
||||
min[0] = p.x() - radius;
|
||||
min[1] = -p.y() - radius;
|
||||
max[0] = p.x() + radius;
|
||||
max[1] = -p.y() + radius;
|
||||
for (int i = 0; i < pp.elementCount(); i++) {
|
||||
QPointF p = mercator2ll(pp.elementAt(i));
|
||||
min[0] = p.x() - _radius;
|
||||
min[1] = -p.y() - _radius;
|
||||
max[0] = p.x() + _radius;
|
||||
max[1] = -p.y() + _radius;
|
||||
_tree.Search(min, max, cb, &set);
|
||||
}
|
||||
|
||||
@ -169,7 +178,7 @@ QVector<Waypoint> POI::points(const QPainterPath &path, qreal radius) const
|
||||
return ret;
|
||||
}
|
||||
|
||||
QVector<Waypoint> POI::points(const QList<WaypointItem*> &list, qreal radius)
|
||||
QVector<Waypoint> POI::points(const QList<WaypointItem*> &list)
|
||||
const
|
||||
{
|
||||
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++) {
|
||||
const QPointF &p = list.at(i)->waypoint().coordinates();
|
||||
min[0] = p.x() - radius;
|
||||
min[1] = p.y() - radius;
|
||||
max[0] = p.x() + radius;
|
||||
max[1] = p.y() + radius;
|
||||
min[0] = p.x() - _radius;
|
||||
min[1] = p.y() - _radius;
|
||||
max[0] = p.x() + _radius;
|
||||
max[1] = p.y() + _radius;
|
||||
_tree.Search(min, max, cb, &set);
|
||||
}
|
||||
|
||||
QSet<int>::const_iterator i = set.constBegin();
|
||||
while (i != set.constEnd()) {
|
||||
ret.append(_data.at(*i));
|
||||
++i;
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
QVector<Waypoint> POI::points(const QList<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);
|
||||
}
|
||||
|
||||
@ -216,6 +249,8 @@ void POI::enableFile(const QString &fileName, bool enable)
|
||||
_tree.Insert(c, c, j);
|
||||
}
|
||||
}
|
||||
|
||||
emit pointsChanged();
|
||||
}
|
||||
|
||||
void POI::clear()
|
||||
@ -224,4 +259,13 @@ void POI::clear()
|
||||
_data.clear();
|
||||
_files.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 "rtree.h"
|
||||
|
||||
class QPainterPath;
|
||||
class PathItem;
|
||||
class WaypointItem;
|
||||
|
||||
#define POI_RADIUS 0.01
|
||||
|
||||
class POI
|
||||
class POI : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
POI() : _errorLine(0) {}
|
||||
POI(QObject *parent = 0);
|
||||
|
||||
bool loadFile(const QString &fileName);
|
||||
const QString &errorString() const {return _error;}
|
||||
int errorLine() const {return _errorLine;}
|
||||
|
||||
QVector<Waypoint> points(const QPainterPath &path,
|
||||
qreal radius = POI_RADIUS) const;
|
||||
QVector<Waypoint> points(const QList<WaypointItem*> &list,
|
||||
qreal radius = POI_RADIUS) const;
|
||||
qreal radius() const {return _radius;}
|
||||
void setRadius(qreal radius);
|
||||
|
||||
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;}
|
||||
void enableFile(const QString &fileName, bool enable);
|
||||
void clear();
|
||||
|
||||
signals:
|
||||
void pointsChanged();
|
||||
|
||||
private:
|
||||
typedef RTree<size_t, qreal, 2> POITree;
|
||||
typedef struct {
|
||||
@ -46,6 +52,8 @@ private:
|
||||
QStringList _files;
|
||||
QList<FileIndex> _indexes;
|
||||
|
||||
qreal _radius;
|
||||
|
||||
QString _error;
|
||||
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"
|
||||
|
||||
|
||||
#define BORDER_WIDTH 1
|
||||
#define SCALE_WIDTH 132
|
||||
#define SCALE_HEIGHT 5
|
||||
#define SEGMENTS 3
|
||||
@ -17,6 +18,10 @@ ScaleItem::ScaleItem(QGraphicsItem *parent) : QGraphicsItem(parent)
|
||||
_units = Metric;
|
||||
_zoom = ZOOM_MIN;
|
||||
_lat = 0;
|
||||
|
||||
#ifndef Q_OS_MAC
|
||||
setCacheMode(QGraphicsItem::DeviceCoordinateCache);
|
||||
#endif // Q_OS_MAC
|
||||
}
|
||||
|
||||
void ScaleItem::updateBoundingRect()
|
||||
@ -31,9 +36,9 @@ void ScaleItem::updateBoundingRect()
|
||||
es = fm.tightBoundingRect(QString::number(_length * SEGMENTS));
|
||||
us = fm.tightBoundingRect(units());
|
||||
|
||||
_boundingRect = QRectF(-ss.width()/2, 0,
|
||||
_width * SEGMENTS + ss.width()/2 + qMax(us.width() + PADDING, es.width()/2),
|
||||
SCALE_HEIGHT + PADDING + ss.height() + 2*fm.descent());
|
||||
_boundingRect = QRectF(-ss.width()/2, 0, _width * SEGMENTS + ss.width()/2
|
||||
+ qMax(us.width() + PADDING, es.width()/2) + 1, SCALE_HEIGHT + PADDING
|
||||
+ ss.height() + 2*fm.descent());
|
||||
}
|
||||
|
||||
void ScaleItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *option,
|
||||
@ -46,6 +51,7 @@ void ScaleItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *option,
|
||||
font.setFamily(FONT_FAMILY);
|
||||
QFontMetrics fm(font);
|
||||
QRect br;
|
||||
QPen pen = QPen(Qt::black, BORDER_WIDTH);
|
||||
bool aa;
|
||||
|
||||
|
||||
@ -53,6 +59,7 @@ void ScaleItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *option,
|
||||
painter->setRenderHint(QPainter::Antialiasing, false);
|
||||
|
||||
painter->setFont(font);
|
||||
painter->setPen(pen);
|
||||
|
||||
for (int i = 0; i <= SEGMENTS; 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)
|
||||
painter->fillRect(QRectF(i * _width, br.height() + PADDING, _width,
|
||||
SCALE_HEIGHT), Qt::black);
|
||||
|
||||
/*
|
||||
painter->setPen(Qt::red);
|
||||
painter->drawRect(boundingRect());
|
||||
*/
|
||||
|
||||
if (aa)
|
||||
painter->setRenderHint(QPainter::Antialiasing, true);
|
||||
}
|
||||
@ -78,9 +87,11 @@ void ScaleItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *option,
|
||||
QString ScaleItem::units() const
|
||||
{
|
||||
if (_units == Imperial)
|
||||
return _scale ? QObject::tr("mi") : QObject::tr("ft");
|
||||
return _scale ? qApp->translate("ScaleItem", "mi")
|
||||
: qApp->translate("ScaleItem", "ft");
|
||||
else
|
||||
return _scale ? QObject::tr("km") : QObject::tr("m");
|
||||
return _scale ? qApp->translate("ScaleItem", "km")
|
||||
: qApp->translate("ScaleItem", "m");
|
||||
}
|
||||
|
||||
void ScaleItem::computeScale()
|
||||
@ -110,12 +121,14 @@ void ScaleItem::computeScale()
|
||||
}
|
||||
}
|
||||
|
||||
void ScaleItem::setLatitude(qreal lat)
|
||||
void ScaleItem::setZoom(int z, qreal lat)
|
||||
{
|
||||
prepareGeometryChange();
|
||||
_zoom = z;
|
||||
_lat = lat;
|
||||
computeScale();
|
||||
updateBoundingRect();
|
||||
update();
|
||||
}
|
||||
|
||||
void ScaleItem::setZoom(int z)
|
||||
@ -124,6 +137,7 @@ void ScaleItem::setZoom(int z)
|
||||
_zoom = z;
|
||||
computeScale();
|
||||
updateBoundingRect();
|
||||
update();
|
||||
}
|
||||
|
||||
void ScaleItem::setUnits(enum Units units)
|
||||
@ -132,4 +146,5 @@ void ScaleItem::setUnits(enum Units units)
|
||||
_units = units;
|
||||
computeScale();
|
||||
updateBoundingRect();
|
||||
update();
|
||||
}
|
||||
|
@ -13,8 +13,8 @@ public:
|
||||
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option,
|
||||
QWidget *widget);
|
||||
|
||||
void setLatitude(qreal lat);
|
||||
void setZoom(int z);
|
||||
void setZoom(int z, qreal lat);
|
||||
void setUnits(enum Units units);
|
||||
|
||||
private:
|
||||
|
@ -3,21 +3,32 @@
|
||||
|
||||
#define WINDOW_SETTINGS_GROUP "Window"
|
||||
#define WINDOW_SIZE_SETTING "size"
|
||||
#define WINDOW_POS_SETTING "pos"
|
||||
#define WINDOW_POS_SETTING "pos"
|
||||
|
||||
#define SETTINGS_SETTINGS_GROUP "Settings"
|
||||
#define UNITS_SETTING "units"
|
||||
#define UNITS_SETTING "units"
|
||||
#define SHOW_TOOLBARS_SETTING "toolbar"
|
||||
#define SHOW_GRAPHS_SETTING "graphs"
|
||||
|
||||
#define GRAPH_SETTINGS_GROUP "Graph"
|
||||
#define SHOW_GRAPHS_SETTING "show"
|
||||
#define GRAPH_TYPE_SETTING "type"
|
||||
|
||||
#define MAP_SETTINGS_GROUP "Map"
|
||||
#define CURRENT_MAP_SETTING "map"
|
||||
#define CURRENT_MAP_SETTING "map"
|
||||
#define SHOW_MAP_SETTING "show"
|
||||
|
||||
#define POI_SETTINGS_GROUP "POI"
|
||||
#define POI_SETTINGS_GROUP "POI"
|
||||
#define OVERLAP_POI_SETTING "overlap"
|
||||
#define LABELS_POI_SETTING "labels"
|
||||
#define SHOW_POI_SETTING "show"
|
||||
#define DISABLED_POI_FILE_SETTINGS_PREFIX "disabled"
|
||||
#define DISABLED_POI_FILE_SETTING "file"
|
||||
|
||||
#define DATA_SETTINGS_GROUP "Data"
|
||||
#define SHOW_TRACKS_SETTING "tracks"
|
||||
#define SHOW_ROUTES_SETTING "routes"
|
||||
#define SHOW_WAYPOINTS_SETTING "waypoints"
|
||||
#define SHOW_ROUTE_WAYPOINTS_SETTING "routeWaypoints"
|
||||
#define SHOW_WAYPOINT_LABELS_SETTING "waypointLabels"
|
||||
|
||||
#endif // SETTINGS_H
|
||||
|
@ -4,7 +4,7 @@
|
||||
|
||||
#define SIZE 10
|
||||
|
||||
SliderItem::SliderItem(QGraphicsObject *parent) : QGraphicsObject(parent)
|
||||
SliderItem::SliderItem(QGraphicsItem *parent) : QGraphicsObject(parent)
|
||||
{
|
||||
setFlag(ItemIsMovable);
|
||||
setFlag(ItemSendsGeometryChanges);
|
||||
@ -24,7 +24,7 @@ void SliderItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *option
|
||||
painter->setPen(Qt::red);
|
||||
painter->drawLine(0, 0, 0, -_area.height());
|
||||
|
||||
//painter->drawRect(boundingRect());
|
||||
// painter->drawRect(boundingRect());
|
||||
}
|
||||
|
||||
QVariant SliderItem::itemChange(GraphicsItemChange change, const QVariant &value)
|
||||
|
@ -1,14 +1,14 @@
|
||||
#ifndef SLIDERITEM_H
|
||||
#define SLIDERITEM_H
|
||||
|
||||
#include <QGraphicsItem>
|
||||
#include <QGraphicsObject>
|
||||
|
||||
class SliderItem : public QGraphicsObject
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
SliderItem(QGraphicsObject *parent = 0);
|
||||
SliderItem(QGraphicsItem *parent = 0);
|
||||
|
||||
QRectF boundingRect() const;
|
||||
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option,
|
||||
|
@ -6,43 +6,46 @@
|
||||
SpeedGraph::SpeedGraph(QWidget *parent) : GraphTab(parent)
|
||||
{
|
||||
_units = Metric;
|
||||
_showTracks = true;
|
||||
|
||||
setYUnits();
|
||||
setXLabel(tr("Distance"));
|
||||
setYLabel(tr("Speed"));
|
||||
|
||||
setSliderPrecision(1);
|
||||
}
|
||||
|
||||
void SpeedGraph::addInfo()
|
||||
void SpeedGraph::setInfo()
|
||||
{
|
||||
GraphView::addInfo(tr("Average"), QString::number(avg() * yScale(), 'f', 1)
|
||||
+ UNIT_SPACE + yUnits());
|
||||
GraphView::addInfo(tr("Maximum"), QString::number(max() * yScale(), 'f', 1)
|
||||
+ UNIT_SPACE + yUnits());
|
||||
|
||||
redraw();
|
||||
if (_showTracks) {
|
||||
GraphView::addInfo(tr("Average"), QString::number(avg() * yScale(), 'f',
|
||||
1) + UNIT_SPACE + yUnits());
|
||||
GraphView::addInfo(tr("Maximum"), QString::number(max() * yScale(), 'f',
|
||||
1) + UNIT_SPACE + yUnits());
|
||||
} else
|
||||
clearInfo();
|
||||
}
|
||||
|
||||
void SpeedGraph::loadGPX(const GPX &gpx)
|
||||
void SpeedGraph::loadGPX(const GPX &gpx, const QList<PathItem *> &paths)
|
||||
{
|
||||
for (int i = 0; i < gpx.trackCount(); i++) {
|
||||
QVector<QPointF> data;
|
||||
|
||||
gpx.track(i).speedGraph(data);
|
||||
if (data.count() < 2) {
|
||||
for (int i = 0; i < gpx.tracks().count(); i++) {
|
||||
const Graph &graph = gpx.tracks().at(i)->speed();
|
||||
if (graph.size() < 2) {
|
||||
skipColor();
|
||||
continue;
|
||||
}
|
||||
|
||||
_avg.append(QPointF(gpx.track(i).distance(), gpx.track(i).distance()
|
||||
/ gpx.track(i).time()));
|
||||
_avg.append(QPointF(gpx.tracks().at(i)->distance(),
|
||||
gpx.tracks().at(i)->distance() / gpx.tracks().at(i)->time()));
|
||||
|
||||
loadData(data);
|
||||
GraphView::loadGraph(graph, paths.at(i));
|
||||
}
|
||||
|
||||
setXUnits();
|
||||
addInfo();
|
||||
for (int i = 0; i < gpx.routes().count(); i++)
|
||||
skipColor();
|
||||
|
||||
setInfo();
|
||||
|
||||
redraw();
|
||||
}
|
||||
|
||||
qreal SpeedGraph::avg() const
|
||||
@ -65,27 +68,6 @@ void SpeedGraph::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()
|
||||
{
|
||||
if (_units == Metric) {
|
||||
@ -100,9 +82,20 @@ void SpeedGraph::setYUnits()
|
||||
void SpeedGraph::setUnits(enum Units units)
|
||||
{
|
||||
_units = units;
|
||||
setXUnits();
|
||||
setYUnits();
|
||||
|
||||
clearInfo();
|
||||
addInfo();
|
||||
setYUnits();
|
||||
setInfo();
|
||||
GraphView::setUnits(units);
|
||||
|
||||
redraw();
|
||||
}
|
||||
|
||||
void SpeedGraph::showTracks(bool show)
|
||||
{
|
||||
_showTracks = show;
|
||||
|
||||
showGraph(show);
|
||||
setInfo();
|
||||
|
||||
redraw();
|
||||
}
|
||||
|
@ -4,8 +4,6 @@
|
||||
#include <QList>
|
||||
#include "graphtab.h"
|
||||
|
||||
class GPX;
|
||||
|
||||
class SpeedGraph : public GraphTab
|
||||
{
|
||||
Q_OBJECT
|
||||
@ -14,19 +12,22 @@ public:
|
||||
SpeedGraph(QWidget *parent = 0);
|
||||
|
||||
QString label() const {return tr("Speed");}
|
||||
void loadGPX(const GPX &gpx);
|
||||
void loadGPX(const GPX &gpx, const QList<PathItem *> &paths);
|
||||
void clear();
|
||||
void setUnits(enum Units units);
|
||||
void showTracks(bool show);
|
||||
void showRoutes(bool show) {Q_UNUSED(show);}
|
||||
|
||||
private:
|
||||
qreal avg() const;
|
||||
qreal max() const {return bounds().bottom();}
|
||||
void setXUnits();
|
||||
void setYUnits();
|
||||
void addInfo();
|
||||
void setInfo();
|
||||
|
||||
QList<QPointF> _avg;
|
||||
|
||||
enum Units _units;
|
||||
bool _showTracks;
|
||||
};
|
||||
|
||||
#endif // SPEEDGRAPH_H
|
||||
|
@ -5,49 +5,54 @@
|
||||
TemperatureGraph::TemperatureGraph(QWidget *parent) : GraphTab(parent)
|
||||
{
|
||||
_units = Metric;
|
||||
_showTracks = true;
|
||||
|
||||
setYUnits();
|
||||
setXLabel(tr("Distance"));
|
||||
setYLabel(tr("Temperature"));
|
||||
|
||||
setSliderPrecision(1);
|
||||
}
|
||||
|
||||
void TemperatureGraph::addInfo()
|
||||
void TemperatureGraph::setInfo()
|
||||
{
|
||||
GraphView::addInfo(tr("Average"), QString::number(avg() * yScale()
|
||||
+ yOffset(), 'f', 1) + UNIT_SPACE + yUnits());
|
||||
GraphView::addInfo(tr("Minimum"), QString::number(min() * yScale()
|
||||
+ yOffset(), 'f', 1) + UNIT_SPACE + yUnits());
|
||||
GraphView::addInfo(tr("Maximum"), QString::number(max() * yScale()
|
||||
+ yOffset(), 'f', 1) + UNIT_SPACE + yUnits());
|
||||
|
||||
redraw();
|
||||
if (_showTracks) {
|
||||
GraphView::addInfo(tr("Average"), QString::number(avg() * yScale()
|
||||
+ yOffset(), 'f', 1) + UNIT_SPACE + yUnits());
|
||||
GraphView::addInfo(tr("Minimum"), QString::number(min() * yScale()
|
||||
+ yOffset(), 'f', 1) + UNIT_SPACE + yUnits());
|
||||
GraphView::addInfo(tr("Maximum"), QString::number(max() * yScale()
|
||||
+ yOffset(), 'f', 1) + UNIT_SPACE + yUnits());
|
||||
} else
|
||||
clearInfo();
|
||||
}
|
||||
|
||||
void TemperatureGraph::loadGPX(const GPX &gpx)
|
||||
void TemperatureGraph::loadGPX(const GPX &gpx, const QList<PathItem *> &paths)
|
||||
{
|
||||
for (int i = 0; i < gpx.trackCount(); i++) {
|
||||
QVector<QPointF> data;
|
||||
for (int i = 0; i < gpx.tracks().count(); i++) {
|
||||
const Graph &graph = gpx.tracks().at(i)->temperature();
|
||||
qreal sum = 0, w = 0;
|
||||
|
||||
gpx.track(i).temperatureGraph(data);
|
||||
if (data.count() < 2) {
|
||||
if (graph.size() < 2) {
|
||||
skipColor();
|
||||
continue;
|
||||
}
|
||||
|
||||
for (int j = 1; j < data.size(); j++) {
|
||||
sum += data.at(j).y() * (data.at(j).x() - data.at(j-1).x());
|
||||
w += data.at(j).x() - data.at(j-1).x();
|
||||
for (int j = 1; j < graph.size(); j++) {
|
||||
qreal ds = graph.at(j).s() - graph.at(j-1).s();
|
||||
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();
|
||||
addInfo();
|
||||
for (int i = 0; i < gpx.routes().count(); i++)
|
||||
skipColor();
|
||||
|
||||
setInfo();
|
||||
|
||||
redraw();
|
||||
}
|
||||
|
||||
qreal TemperatureGraph::avg() const
|
||||
@ -70,27 +75,6 @@ void TemperatureGraph::clear()
|
||||
GraphView::clear();
|
||||
}
|
||||
|
||||
void TemperatureGraph::setXUnits()
|
||||
{
|
||||
if (_units == Metric) {
|
||||
if (bounds().width() < KMINM) {
|
||||
GraphView::setXUnits(tr("m"));
|
||||
setXScale(1);
|
||||
} else {
|
||||
GraphView::setXUnits(tr("km"));
|
||||
setXScale(M2KM);
|
||||
}
|
||||
} else {
|
||||
if (bounds().width() < MIINM) {
|
||||
GraphView::setXUnits(tr("ft"));
|
||||
setXScale(M2FT);
|
||||
} else {
|
||||
GraphView::setXUnits(tr("mi"));
|
||||
setXScale(M2MI);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void TemperatureGraph::setYUnits()
|
||||
{
|
||||
if (_units == Metric) {
|
||||
@ -107,9 +91,20 @@ void TemperatureGraph::setYUnits()
|
||||
void TemperatureGraph::setUnits(enum Units units)
|
||||
{
|
||||
_units = units;
|
||||
setXUnits();
|
||||
setYUnits();
|
||||
|
||||
clearInfo();
|
||||
addInfo();
|
||||
setYUnits();
|
||||
setInfo();
|
||||
GraphView::setUnits(units);
|
||||
|
||||
redraw();
|
||||
}
|
||||
|
||||
void TemperatureGraph::showTracks(bool show)
|
||||
{
|
||||
_showTracks = show;
|
||||
|
||||
showGraph(show);
|
||||
setInfo();
|
||||
|
||||
redraw();
|
||||
}
|
||||
|
@ -3,8 +3,6 @@
|
||||
|
||||
#include "graphtab.h"
|
||||
|
||||
class GPX;
|
||||
|
||||
class TemperatureGraph : public GraphTab
|
||||
{
|
||||
Q_OBJECT
|
||||
@ -13,20 +11,23 @@ public:
|
||||
TemperatureGraph(QWidget *parent = 0);
|
||||
|
||||
QString label() const {return tr("Temperature");}
|
||||
void loadGPX(const GPX &gpx);
|
||||
void loadGPX(const GPX &gpx, const QList<PathItem *> &paths);
|
||||
void clear();
|
||||
void setUnits(enum Units units);
|
||||
void showTracks(bool show);
|
||||
void showRoutes(bool show) {Q_UNUSED(show);}
|
||||
|
||||
private:
|
||||
qreal avg() const;
|
||||
qreal min() const {return bounds().top();}
|
||||
qreal max() const {return bounds().bottom();}
|
||||
void setXUnits();
|
||||
void setYUnits();
|
||||
void addInfo();
|
||||
void setInfo();
|
||||
|
||||
QList<QPointF> _avg;
|
||||
|
||||
enum Units _units;
|
||||
bool _showTracks;
|
||||
};
|
||||
|
||||
#endif // TEMPERATUREGRAPH_H
|
||||
|
116
src/track.cpp
116
src/track.cpp
@ -8,18 +8,19 @@
|
||||
#define WINDOW_HE 11
|
||||
#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);
|
||||
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++)
|
||||
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();
|
||||
}
|
||||
|
||||
static QVector<QPointF> eliminate(const QVector<QPointF> &v, int window)
|
||||
static QVector<GraphPoint> eliminate(const QVector<GraphPoint> &v, int window)
|
||||
{
|
||||
QList<int> rm;
|
||||
QVector<QPointF> ret;
|
||||
QVector<GraphPoint> ret;
|
||||
qreal m, M;
|
||||
|
||||
|
||||
if (v.size() < window)
|
||||
return QVector<QPointF>(v);
|
||||
return QVector<GraphPoint>(v);
|
||||
|
||||
for (int i = window/2; i < v.size() - window/2; i++) {
|
||||
m = median(v.mid(i - window/2, window));
|
||||
@ -55,26 +56,26 @@ static QVector<QPointF> eliminate(const QVector<QPointF> &v, int window)
|
||||
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;
|
||||
QVector<QPointF> ret;
|
||||
QVector<GraphPoint> ret;
|
||||
|
||||
if (v.size() < window)
|
||||
return QVector<QPointF>(v);
|
||||
return QVector<GraphPoint>(v);
|
||||
|
||||
for (int i = 0; i < window; i++)
|
||||
acc += v.at(i).y();
|
||||
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++) {
|
||||
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++)
|
||||
ret.append(QPointF(v.at(i).x(), acc/window));
|
||||
ret.append(GraphPoint(v.at(i).s(), v.at(i).t(), acc/window));
|
||||
|
||||
return ret;
|
||||
}
|
||||
@ -83,100 +84,101 @@ Track::Track(const QVector<Trackpoint> &data) : _data(data)
|
||||
{
|
||||
qreal dist = 0;
|
||||
|
||||
_dd.append(dist);
|
||||
for (int i = 1; i < _data.count(); i++) {
|
||||
dist += llDistance(_data.at(i).coordinates(),
|
||||
_data.at(i-1).coordinates());
|
||||
_dd.append(dist);
|
||||
_distance.append(0);
|
||||
_time.append(0);
|
||||
for (int i = 1; i < data.count(); i++) {
|
||||
dist += llDistance(data.at(i).coordinates(), data.at(i-1).coordinates());
|
||||
_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())
|
||||
return;
|
||||
return raw;
|
||||
|
||||
for (int i = 0; i < _data.size(); i++)
|
||||
if (_data.at(i).hasElevation())
|
||||
raw.append(QPointF(_dd.at(i), _data.at(i).elevation()
|
||||
- _data.at(i).geoidHeight()));
|
||||
raw.append(GraphPoint(_distance.at(i), _time.at(i),
|
||||
_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;
|
||||
qint64 dt;
|
||||
QVector<QPointF> raw;
|
||||
QVector<GraphPoint> raw;
|
||||
qreal v, ds, dt;
|
||||
|
||||
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++) {
|
||||
if (_data.at(i).hasSpeed())
|
||||
v = _data.at(i).speed();
|
||||
else if (_data.at(i).hasTimestamp()) {
|
||||
dt = _data.at(i-1).timestamp().msecsTo(_data.at(i).timestamp());
|
||||
else if (_data.at(i).hasTimestamp() && _data.at(i-1).hasTimestamp()) {
|
||||
dt = _time.at(i) - _time.at(i-1);
|
||||
if (!dt)
|
||||
continue;
|
||||
ds = _dd.at(i) - _dd.at(i-1);
|
||||
v = ds / ((qreal)dt / 1000.0);
|
||||
ds = _distance.at(i) - _distance.at(i-1);
|
||||
v = ds / dt;
|
||||
} else
|
||||
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())
|
||||
return;
|
||||
return raw;
|
||||
|
||||
for (int i = 0; i < _data.count(); i++)
|
||||
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())
|
||||
return;
|
||||
QVector<GraphPoint> raw;
|
||||
|
||||
for (int i = 0; i < _data.size(); i++)
|
||||
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++)
|
||||
track.append(_data.at(i).coordinates());
|
||||
return (_distance.isEmpty()) ? 0 : _distance.last();
|
||||
}
|
||||
|
||||
qreal Track::time() const
|
||||
{
|
||||
if (_data.size() < 2)
|
||||
return 0;
|
||||
|
||||
return (_data.first().timestamp().msecsTo(_data.last().timestamp())
|
||||
/ 1000.0);
|
||||
return (_data.size() < 2) ? 0 :
|
||||
(_data.first().timestamp().msecsTo(_data.last().timestamp()) / 1000.0);
|
||||
}
|
||||
|
||||
QDateTime Track::date() const
|
||||
{
|
||||
if (_data.size())
|
||||
return _data.first().timestamp();
|
||||
else
|
||||
return QDateTime();
|
||||
return (_data.size()) ? _data.first().timestamp() : QDateTime();
|
||||
}
|
||||
|
20
src/track.h
20
src/track.h
@ -4,27 +4,29 @@
|
||||
#include <QVector>
|
||||
#include <QDateTime>
|
||||
#include "trackpoint.h"
|
||||
#include "graph.h"
|
||||
|
||||
class Track
|
||||
{
|
||||
public:
|
||||
Track(const QVector<Trackpoint> &data);
|
||||
|
||||
void elevationGraph(QVector<QPointF> &graph) const;
|
||||
void speedGraph(QVector<QPointF> &graph) const;
|
||||
void heartRateGraph(QVector<QPointF> &graph) const;
|
||||
void temperatureGraph(QVector<QPointF> &graph) const;
|
||||
void track(QVector<QPointF> &track) const;
|
||||
qreal distance() const {return _dd.last();}
|
||||
const QVector<Trackpoint> &track() const {return _data;}
|
||||
Graph elevation() const;
|
||||
Graph speed() const;
|
||||
Graph heartRate() const;
|
||||
Graph temperature() const;
|
||||
|
||||
qreal distance() const;
|
||||
qreal time() const;
|
||||
QDateTime date() const;
|
||||
|
||||
bool isNull() const {return (_data.count() < 2) ? true : false;}
|
||||
bool isNull() const {return (_data.size() < 2);}
|
||||
|
||||
private:
|
||||
const QVector<Trackpoint> &_data;
|
||||
QVector<qreal> _dd;
|
||||
qreal _distance;
|
||||
QVector<qreal> _distance;
|
||||
QVector<qreal> _time;
|
||||
};
|
||||
|
||||
#endif // TRACK_H
|
||||
|
@ -1,14 +1,12 @@
|
||||
#include <QApplication>
|
||||
#include <QCursor>
|
||||
#include <QPen>
|
||||
#include <QPainter>
|
||||
#include "ll.h"
|
||||
#include "misc.h"
|
||||
#include "tooltip.h"
|
||||
#include "trackitem.h"
|
||||
|
||||
|
||||
#define TRACK_WIDTH 3
|
||||
|
||||
QString TrackItem::toolTip()
|
||||
{
|
||||
ToolTip tt;
|
||||
@ -24,64 +22,32 @@ QString TrackItem::toolTip()
|
||||
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)
|
||||
: QGraphicsPathItem(parent)
|
||||
: PathItem(parent)
|
||||
{
|
||||
QVector<QPointF> t;
|
||||
QPainterPath path;
|
||||
|
||||
track.track(t);
|
||||
const QVector<Trackpoint> &t = track.track();
|
||||
Q_ASSERT(t.count() >= 2);
|
||||
|
||||
const QPointF &p = t.at(0);
|
||||
path.moveTo(ll2mercator(QPointF(p.x(), -p.y())));
|
||||
const QPointF &p = t.at(0).coordinates();
|
||||
_path.moveTo(ll2mercator(QPointF(p.x(), -p.y())));
|
||||
for (int i = 1; i < t.size(); i++) {
|
||||
const QPointF &p = t.at(i);
|
||||
path.lineTo(ll2mercator(QPointF(p.x(), -p.y())));
|
||||
const QPointF &p = t.at(i).coordinates();
|
||||
_path.lineTo(ll2mercator(QPointF(p.x(), -p.y())));
|
||||
}
|
||||
|
||||
_units = Metric;
|
||||
updateShape();
|
||||
|
||||
_date = track.date();
|
||||
_distance = track.distance();
|
||||
_time = track.time();
|
||||
|
||||
setPath(path);
|
||||
_marker->setPos(_path.pointAtPercent(0));
|
||||
|
||||
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)
|
||||
{
|
||||
_units = units;
|
||||
PathItem::setUnits(units);
|
||||
setToolTip(toolTip());
|
||||
}
|
||||
|
@ -1,32 +1,26 @@
|
||||
#ifndef TRACKITEM_H
|
||||
#define TRACKITEM_H
|
||||
|
||||
#include <QGraphicsPathItem>
|
||||
#include <QDateTime>
|
||||
#include "units.h"
|
||||
#include <QPen>
|
||||
#include "track.h"
|
||||
#include "pathitem.h"
|
||||
|
||||
class TrackItem : public QGraphicsPathItem
|
||||
|
||||
class TrackItem : public PathItem
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
TrackItem(const Track &track, QGraphicsItem *parent = 0);
|
||||
|
||||
QPainterPath shape() const {return _shape;}
|
||||
void setScale(qreal scale);
|
||||
|
||||
void setUnits(enum Units units);
|
||||
void setColor(const QColor &color);
|
||||
|
||||
private:
|
||||
void updateShape();
|
||||
QString toolTip();
|
||||
|
||||
QPainterPath _shape;
|
||||
|
||||
Units _units;
|
||||
QDateTime _date;
|
||||
qreal _time;
|
||||
qreal _distance;
|
||||
};
|
||||
|
||||
#endif // TRACKITEM_H
|
||||
|
@ -13,10 +13,14 @@ enum Units {
|
||||
#define MS2MIH 2.236936290000 // m/s -> mi/h
|
||||
#define FT2MI 0.000189393939 // ft -> mi
|
||||
#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 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 C2FO 32 // Celsius to Farenheit - offset
|
||||
|
@ -31,6 +31,8 @@ public:
|
||||
void setElevation(qreal elevation) {_elevation = elevation;}
|
||||
void setGeoidHeight(qreal geoidHeight) {_geoidHeight = geoidHeight;}
|
||||
|
||||
bool hasElevation() const {return !std::isnan(_elevation);}
|
||||
|
||||
bool operator==(const Waypoint &other) const
|
||||
{return this->_name == other._name
|
||||
&& this->_coordinates == other._coordinates;}
|
||||
|
@ -7,12 +7,15 @@
|
||||
#include "waypointitem.h"
|
||||
|
||||
|
||||
#define POINT_SIZE 8
|
||||
#define POINT_SIZE 8
|
||||
#define HOVER_SIZE 10
|
||||
|
||||
QString WaypointItem::toolTip()
|
||||
{
|
||||
ToolTip tt;
|
||||
|
||||
if (!_waypoint.name().isEmpty() && !_showLabel)
|
||||
tt.insert(qApp->translate("WaypointItem", "Name"), _waypoint.name());
|
||||
tt.insert(qApp->translate("WaypointItem", "Coordinates"),
|
||||
::coordinates(_waypoint.coordinates()));
|
||||
if (!std::isnan(_waypoint.elevation()))
|
||||
@ -32,28 +35,42 @@ WaypointItem::WaypointItem(const Waypoint &waypoint, QGraphicsItem *parent)
|
||||
: QGraphicsItem(parent)
|
||||
{
|
||||
_units = Metric;
|
||||
_showLabel = true;
|
||||
_hover = false;
|
||||
|
||||
_waypoint = waypoint;
|
||||
_coordinates = ll2mercator(QPointF(waypoint.coordinates().x(),
|
||||
-waypoint.coordinates().y()));
|
||||
|
||||
updateBoundingRect();
|
||||
updateShape();
|
||||
|
||||
setPos(_coordinates);
|
||||
setToolTip(toolTip());
|
||||
setCursor(Qt::ArrowCursor);
|
||||
setAcceptHoverEvents(true);
|
||||
}
|
||||
|
||||
void WaypointItem::updateBoundingRect()
|
||||
void WaypointItem::updateShape()
|
||||
{
|
||||
QFont font;
|
||||
font.setPixelSize(FONT_SIZE);
|
||||
font.setFamily(FONT_FAMILY);
|
||||
QFontMetrics fm(font);
|
||||
QRect ts = fm.tightBoundingRect(_waypoint.name());
|
||||
QPainterPath p;
|
||||
qreal pointSize = _hover ? HOVER_SIZE : POINT_SIZE;
|
||||
|
||||
_boundingRect = QRectF(-POINT_SIZE/2, -POINT_SIZE/2, ts.width()
|
||||
+ POINT_SIZE, ts.height() + fm.descent() + POINT_SIZE);
|
||||
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());
|
||||
|
||||
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,
|
||||
@ -61,22 +78,30 @@ void WaypointItem::paint(QPainter *painter,
|
||||
{
|
||||
Q_UNUSED(option);
|
||||
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);
|
||||
painter->drawText(POINT_SIZE/2 - qMax(ts.x(), 0), POINT_SIZE/2 + ts.height(),
|
||||
_waypoint.name());
|
||||
qreal pointSize = _hover ? HOVER_SIZE : POINT_SIZE;
|
||||
|
||||
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->drawEllipse(-POINT_SIZE/2, -POINT_SIZE/2, POINT_SIZE, POINT_SIZE);
|
||||
painter->drawEllipse(-pointSize/2, -pointSize/2, pointSize, pointSize);
|
||||
|
||||
/*
|
||||
painter->setPen(Qt::red);
|
||||
painter->setBrush(Qt::NoBrush);
|
||||
painter->drawRect(boundingRect());
|
||||
painter->drawPath(_shape);
|
||||
*/
|
||||
}
|
||||
|
||||
@ -90,3 +115,31 @@ void WaypointItem::setUnits(enum Units units)
|
||||
_units = units;
|
||||
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 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,
|
||||
QWidget *widget);
|
||||
|
||||
private:
|
||||
void updateBoundingRect();
|
||||
void hoverEnterEvent(QGraphicsSceneHoverEvent *event);
|
||||
void hoverLeaveEvent(QGraphicsSceneHoverEvent *event);
|
||||
|
||||
void updateShape();
|
||||
QString toolTip();
|
||||
|
||||
QRectF _boundingRect;
|
||||
QPainterPath _shape;
|
||||
QPointF _coordinates;
|
||||
Waypoint _waypoint;
|
||||
Units _units;
|
||||
|
||||
bool _hover;
|
||||
bool _showLabel;
|
||||
};
|
||||
|
||||
#endif // WAYPOINTITEM_H
|
||||
|
Reference in New Issue
Block a user