1
0
mirror of https://github.com/tumic0/GPXSee.git synced 2025-07-01 13:29:16 +02:00

Compare commits

...

57 Commits
2.9 ... 2.13

Author SHA1 Message Date
6518fe3278 Added GPX file association 2016-05-03 10:18:51 +02:00
97e2215f0b File association stuff 2016-05-02 22:21:57 +02:00
21e7c00f66 Code cleanup 2016-04-30 10:54:07 +02:00
5daacc0a22 Program version now defined in the project file 2016-04-30 09:44:28 +02:00
1323f6ead8 Project structure refactoring 2016-04-29 22:49:37 +02:00
798f63aaff Fixed file open event handling on OS X
Installer files separation
2016-04-29 21:13:38 +02:00
b0abc976a5 Added remaining permanent settings 2016-04-28 08:49:06 +02:00
4c61e208ed More permanent settings 2016-04-26 20:55:29 +02:00
c997694e10 Merge branch 'master' of https://github.com/tumic0/GPXSee 2016-04-26 09:40:28 +02:00
a8d671556e Added permanent settings 2016-04-26 09:39:16 +02:00
2e4aeb57a8 Fixed broken file path handling on non-ASCII file systems. 2016-04-22 01:31:44 +02:00
e186a33340 Added screenshot + some more info 2016-04-20 09:27:57 +02:00
1b5bdc0f07 Better window title 2016-04-19 08:51:11 +02:00
5feec6ac0c Fixed broken registry handling in 64b uninstaller 2016-04-15 18:19:35 +02:00
5997ba21f2 Fixed OS X fullscreen shortcut (F11 collides with a system shortcut) 2016-04-13 22:04:14 +02:00
37d9bf1b9b Missing changes from previous commit
Yet another GUI polishing
2016-04-12 23:15:17 +02:00
2bf93f891a Redesigned about dialogs
64b Windows build stuff
2016-04-12 19:16:52 +02:00
11a9d75d8f Yet another graph tabs polishing
Code cleanup
2016-04-11 22:08:00 +02:00
23576cd52c Cosmetics 2016-04-09 09:14:10 +02:00
47bcd0cfaf Added map change shortcuts 2016-04-08 22:33:19 +02:00
043d1f49a6 Uh. That's hideous. 2016-04-05 19:45:30 +02:00
339144f7f8 Added fullscreen mode 2016-04-05 09:10:19 +02:00
27ff3a9ba8 version++ 2016-04-01 23:31:55 +02:00
8f4d31ac24 Fixed C++11 compile issues 2016-04-01 23:14:57 +02:00
34fcbfb60f Proper use of prepareGeometryChange() 2016-04-01 21:20:23 +02:00
803c4aecce Removed debug code 2016-04-01 19:35:57 +02:00
f247c2fa22 Added support for tiles cache clearing 2016-04-01 19:25:34 +02:00
9fa031ca4d Code cleanup 2016-04-01 19:20:55 +02:00
d3908f1561 Code cleanup 2016-04-01 09:41:52 +02:00
f41b13a5a2 Yet another small fix... 2016-03-30 23:07:54 +02:00
284f7d0a36 Fixed slider position handling 2016-03-30 20:50:51 +02:00
f469b4f600 Fixed slider info displaying on right graph border 2016-03-30 01:48:48 +02:00
eec797125b Fixed error handling 2016-03-29 20:58:33 +02:00
9dce08bce4 Added missing units init 2016-03-28 19:04:58 +02:00
06248457a0 Improved handlig of small-distance tracks 2016-03-27 15:04:58 +02:00
c9b5e0f2cb Code cleanup 2016-03-27 13:23:00 +02:00
b7f3a64577 Fixed broken elevation graph start value 2016-03-27 09:45:07 +02:00
e05069d653 Filter parameters adjustment 2016-03-25 13:11:26 +01:00
1928b579ab Replace global data sources with user data sources rather than merging them 2016-03-25 11:27:42 +01:00
501431207f Fixed graphs display configuration issue 2016-03-25 10:59:47 +01:00
0d41341086 Fixed broken file action group handling on file load error 2016-03-25 10:49:08 +01:00
13f383ab7a Yet another GUI polishing 2016-03-25 09:50:19 +01:00
5253698602 Yet another Graph tab display behaviour change 2016-03-24 20:50:11 +01:00
6bcb6ceb8d Now using a file on the filesystem for default maps rather than the executable 2016-03-24 19:34:46 +01:00
9da82a978c Fixed broken app close action 2016-03-24 19:16:26 +01:00
64a343dd2e Fixed tab logic 2016-03-23 20:56:39 +01:00
ac93ccba29 Fixed track color skew on empty tracks 2016-03-23 20:49:40 +01:00
7cd005873d Added missing size check 2016-03-23 20:48:22 +01:00
9c16c3498c Fixed redraw issue 2016-03-23 09:47:02 +01:00
a2eaacc017 Better graph tabs handling 2016-03-23 09:38:22 +01:00
58bed99d14 Fixed broken slider position setting
Refactoring
2016-03-23 09:22:26 +01:00
de71aa0d0c version++ 2016-03-22 19:49:48 +01:00
14290bf1f0 Enabled loading multiple POI files at once 2016-03-22 19:47:11 +01:00
e0fd77bbfd Fixed graph slider position computation 2016-03-22 19:19:59 +01:00
b1b8d68610 Fixed Y legend plotting issue 2016-03-22 06:48:49 +01:00
a0b64b4227 Added support for Garmin "TrackPointExtension" extension (heart rate) 2016-03-21 23:13:46 +01:00
93670d3026 Added heart rate graph
Improved graphs loading performance
Fixed various corner case behaviour bugs
2016-03-21 22:37:55 +01:00
53 changed files with 1811 additions and 514 deletions

66
Info.plist Normal file
View File

@ -0,0 +1,66 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>NSPrincipalClass</key>
<string>NSApplication</string>
<key>CFBundleIconFile</key>
<string>gpxsee.icns</string>
<key>CFBundlePackageType</key>
<string>APPL</string>
<key>CFBundleShortVersionString</key>
<string>2.13</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleExecutable</key>
<string>GPXSee</string>
<key>CFBundleIdentifier</key>
<string>cz.wz.tumic.GPXSee</string>
<key>CFBundleDocumentTypes</key>
<array>
<dict>
<key>CFBundleTypeExtensions</key>
<array>
<string>gpx</string>
</array>
<key>CFBundleTypeMIMETypes</key>
<array>
<string>application/gpx+xml</string>
</array>
<key>CFBundleTypeIconFile</key>
<string>gpx.icns</string>
<key>CFBundleTypeName</key>
<string>GPS Exchange Format</string>
<key>CFBundleTypeRole</key>
<string>Viewer</string>
</dict>
</array>
<key>UTImportedTypeDeclarations</key>
<array>
<dict>
<key>UTTypeIdentifier</key>
<string>com.topografix.gpx</string>
<key>UTTypeReferenceURL</key>
<string>http://www.topografix.com/GPX/1/1</string>
<key>UTTypeDescription</key>
<string>GPS Exchange Format</string>
<key>UTTypeConformsTo</key>
<array>
<string>public.xml</string>
</array>
<key>UTTypeTagSpecification</key>
<dict>
<key>public.filename-extension</key>
<array>
<string>gpx</string>
</array>
<key>public.mime-type</key>
<string>application/gpx+xml</string>
</dict>
</dict>
</array>
</dict>
</plist>

View File

@ -2,12 +2,15 @@
GPX viewer and analyzer.
* User-definable map sources.
* Track and elevation/speed graphs.
* Track and elevation/speed/heart rate graphs.
* Support for multiple tracks in one view.
* Support for POI files.
* Export to PDF.
* Full-screen mode
* Native GUI for Windows, Mac OS X and Linux.
![GPXSee - Linux](https://a.fsdn.com/con/app/proj/gpxsee/screenshots/linux.png)
## Build
### Linux/OS X
```shell

6
build/env.bat Normal file
View File

@ -0,0 +1,6 @@
CALL "C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\vcvarsall.bat"
set PATH=C:\qt\qtbase\bin;%PATH%
set PATH=C:\Program Files\Microsoft SDKs\Windows\v7.1\Bin;%PATH%
set INCLUDE=C:\Program Files\Microsoft SDKs\Windows\v7.1\Include;%INCLUDE%
set LIB=C:\Program Files\Microsoft SDKs\Windows\v7.1\Lib;%LIB%
set CL=/D_USING_V110_SDK71_

6
build/env64.bat Normal file
View File

@ -0,0 +1,6 @@
CALL "C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\vcvarsall.bat" amd64
set PATH=C:\qt64\qtbase\bin;%PATH%
set PATH=C:\Program Files\Microsoft SDKs\Windows\v7.1\Bin;%PATH%
set INCLUDE=C:\Program Files\Microsoft SDKs\Windows\v7.1\Include;%INCLUDE%
set LIB=C:\Program Files\Microsoft SDKs\Windows\v7.1\Lib\x64;%LIB%
set CL=/D_USING_V110_SDK71_

View File

@ -1,4 +1,5 @@
TARGET = GPXSee
VERSION = 2.13
QT += core \
gui \
network
@ -33,7 +34,12 @@ HEADERS += src/config.h \
src/graphview.h \
src/trackpoint.h \
src/waypointitem.h \
src/palette.h
src/palette.h \
src/heartrategraph.h \
src/range.h \
src/cpuarch.h \
src/settings.h \
src/app.h
SOURCES += src/main.cpp \
src/gui.cpp \
src/gpx.cpp \
@ -57,8 +63,22 @@ SOURCES += src/main.cpp \
src/track.cpp \
src/graphview.cpp \
src/waypointitem.cpp \
src/palette.cpp
src/palette.cpp \
src/heartrategraph.cpp \
src/range.cpp \
src/app.cpp
RESOURCES += gpxsee.qrc
TRANSLATIONS = lang/gpxsee_cs.ts
macx:ICON = icons/gpxsee.icns
win32:RC_FILE = gpxsee.rc
macx {
ICON = icons/gpxsee.icns
QMAKE_INFO_PLIST = Info.plist
APP_RESOURCES.files = icons/gpx.icns \
pkg/maps.txt
APP_RESOURCES.path = Contents/Resources
QMAKE_BUNDLE_DATA += APP_RESOURCES
}
win32 {
RC_ICONS = icons/gpxsee.ico \
icons/gpx.ico
}
DEFINES += APP_VERSION=\\\"$$VERSION\\\"

View File

@ -13,7 +13,7 @@
<file>icons/arrow-right.png</file>
<file>icons/arrow-left-double.png</file>
<file>icons/arrow-right-double.png</file>
<file>icons/view-fullscreen.png</file>
<file>lang/gpxsee_cs.qm</file>
<file>maps.txt</file>
</qresource>
</RCC>

View File

@ -1 +0,0 @@
IDI_ICON1 ICON DISCARDABLE "icons/gpxsee.ico"

BIN
icons/gpx.icns Normal file

Binary file not shown.

BIN
icons/gpx.ico Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 361 KiB

BIN
icons/view-fullscreen.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 381 B

View File

@ -14,44 +14,44 @@
<translation>Výška</translation>
</message>
<message>
<location filename="../src/elevationgraph.cpp" line="16"/>
<location filename="../src/elevationgraph.cpp" line="83"/>
<location filename="../src/elevationgraph.cpp" line="81"/>
<source>km</source>
<translation>km</translation>
</message>
<message>
<location filename="../src/elevationgraph.cpp" line="17"/>
<location filename="../src/elevationgraph.cpp" line="84"/>
<location filename="../src/elevationgraph.cpp" line="78"/>
<location filename="../src/elevationgraph.cpp" line="98"/>
<source>m</source>
<translation>m</translation>
</message>
<message>
<location filename="../src/elevationgraph.cpp" line="23"/>
<location filename="../src/elevationgraph.cpp" line="22"/>
<source>Ascent</source>
<translation>Stoupání</translation>
</message>
<message>
<location filename="../src/elevationgraph.cpp" line="25"/>
<location filename="../src/elevationgraph.cpp" line="24"/>
<source>Descent</source>
<translation>Klesání</translation>
</message>
<message>
<location filename="../src/elevationgraph.cpp" line="29"/>
<location filename="../src/elevationgraph.cpp" line="28"/>
<source>Minimum</source>
<translation>Minimum</translation>
</message>
<message>
<location filename="../src/elevationgraph.cpp" line="88"/>
<location filename="../src/elevationgraph.cpp" line="89"/>
<source>mi</source>
<translation>mi</translation>
</message>
<message>
<location filename="../src/elevationgraph.cpp" line="89"/>
<location filename="../src/elevationgraph.cpp" line="86"/>
<location filename="../src/elevationgraph.cpp" line="101"/>
<source>ft</source>
<translation>ft</translation>
</message>
<message>
<location filename="../src/elevationgraph.cpp" line="27"/>
<location filename="../src/elevationgraph.cpp" line="26"/>
<source>Maximum</source>
<translation>Maximum</translation>
</message>
@ -59,352 +59,429 @@
<context>
<name>GUI</name>
<message>
<location filename="../src/gui.cpp" line="161"/>
<source>About Qt</source>
<translation>O Qt</translation>
</message>
<message>
<location filename="../src/gui.cpp" line="380"/>
<location filename="../src/gui.cpp" line="448"/>
<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="441"/>
<location filename="../src/gui.cpp" line="512"/>
<source>Open file</source>
<translation>Otevřít soubor</translation>
</message>
<message>
<location filename="../src/gui.cpp" line="175"/>
<location filename="../src/gui.cpp" line="208"/>
<source>Save as</source>
<translation>Uložit jako</translation>
</message>
<message>
<location filename="../src/gui.cpp" line="501"/>
<location filename="../src/gui.cpp" line="583"/>
<source>Open POI file</source>
<translation>Otevřít POI soubor</translation>
</message>
<message>
<location filename="../src/gui.cpp" line="166"/>
<location filename="../src/gui.cpp" line="197"/>
<source>Open</source>
<translation>Otevřít</translation>
</message>
<message>
<location filename="../src/gui.cpp" line="149"/>
<location filename="../src/gui.cpp" line="181"/>
<source>Quit</source>
<translation>Ukončit</translation>
</message>
<message>
<location filename="../src/gui.cpp" line="156"/>
<location filename="../src/gui.cpp" line="396"/>
<location filename="../src/gui.cpp" line="397"/>
<location filename="../src/gui.cpp" line="189"/>
<location filename="../src/gui.cpp" line="464"/>
<location filename="../src/gui.cpp" line="465"/>
<source>Keyboard controls</source>
<translation>Ovládací klávesy</translation>
</message>
<message>
<location filename="../src/gui.cpp" line="170"/>
<location filename="../src/gui.cpp" line="202"/>
<source>Save</source>
<translation>Uložit</translation>
</message>
<message>
<location filename="../src/gui.cpp" line="180"/>
<location filename="../src/gui.cpp" line="214"/>
<source>Close</source>
<translation>Zavřít</translation>
</message>
<message>
<location filename="../src/gui.cpp" line="185"/>
<location filename="../src/gui.cpp" line="220"/>
<source>Reload</source>
<translation>Znovu načíst</translation>
</message>
<message>
<location filename="../src/gui.cpp" line="317"/>
<location filename="../src/gui.cpp" line="379"/>
<source>Show</source>
<translation>Zobrazit</translation>
</message>
<message>
<location filename="../src/gui.cpp" line="262"/>
<location filename="../src/gui.cpp" line="308"/>
<location filename="../src/gui.cpp" line="321"/>
<location filename="../src/gui.cpp" line="370"/>
<source>File</source>
<translation>Soubor</translation>
</message>
<message>
<location filename="../src/gui.cpp" line="154"/>
<location filename="../src/gui.cpp" line="414"/>
<location filename="../src/gui.cpp" line="415"/>
<location filename="../src/gui.cpp" line="187"/>
<location filename="../src/gui.cpp" line="487"/>
<location filename="../src/gui.cpp" line="488"/>
<source>Data sources</source>
<translation>Zdroje dat</translation>
</message>
<message>
<location filename="../src/gui.cpp" line="192"/>
<location filename="../src/gui.cpp" line="228"/>
<source>Load POI file</source>
<translation>Nahrát POI soubor</translation>
</message>
<message>
<location filename="../src/gui.cpp" line="195"/>
<location filename="../src/gui.cpp" line="231"/>
<source>Close POI files</source>
<translation>Zavřit soubory POI</translation>
<translation>Zavřit POI soubory</translation>
</message>
<message>
<location filename="../src/gui.cpp" line="198"/>
<location filename="../src/gui.cpp" line="234"/>
<source>Show POIs</source>
<translation>Zobrazit POI</translation>
</message>
<message>
<location filename="../src/gui.cpp" line="205"/>
<location filename="../src/gui.cpp" line="242"/>
<source>Show map</source>
<translation>Zobrazit mapu</translation>
</message>
<message>
<location filename="../src/gui.cpp" line="218"/>
<location filename="../src/gui.cpp" line="248"/>
<source>Clear tile cache</source>
<translation>Vymazat mezipaměť dlaždic</translation>
</message>
<message>
<location filename="../src/gui.cpp" line="258"/>
<location filename="../src/gui.cpp" line="262"/>
<location filename="../src/gui.cpp" line="474"/>
<source>Next map</source>
<translation>Následující mapa</translation>
</message>
<message>
<location filename="../src/gui.cpp" line="269"/>
<source>Show graphs</source>
<translation>Zobrazovat grafy</translation>
</message>
<message>
<location filename="../src/gui.cpp" line="224"/>
<location filename="../src/gui.cpp" line="276"/>
<source>Show toolbars</source>
<translation>Zobrazovat nástrojové lišty</translation>
</message>
<message>
<location filename="../src/gui.cpp" line="231"/>
<location filename="../src/gui.cpp" line="283"/>
<source>Metric</source>
<translation>Metrické</translation>
</message>
<message>
<location filename="../src/gui.cpp" line="237"/>
<location filename="../src/gui.cpp" line="289"/>
<source>Imperial</source>
<translation>Imperiální</translation>
</message>
<message>
<location filename="../src/gui.cpp" line="244"/>
<location filename="../src/gui.cpp" line="295"/>
<source>Fullscreen mode</source>
<translation>Celoobrazovkový režim</translation>
</message>
<message>
<location filename="../src/gui.cpp" line="303"/>
<source>Next</source>
<translation>Následující</translation>
</message>
<message>
<location filename="../src/gui.cpp" line="247"/>
<location filename="../src/gui.cpp" line="306"/>
<source>Previous</source>
<translation>Předchozí</translation>
</message>
<message>
<location filename="../src/gui.cpp" line="251"/>
<location filename="../src/gui.cpp" line="310"/>
<source>Last</source>
<translation>Poslední</translation>
</message>
<message>
<location filename="../src/gui.cpp" line="254"/>
<location filename="../src/gui.cpp" line="313"/>
<source>First</source>
<translation>První</translation>
</message>
<message>
<location filename="../src/gui.cpp" line="276"/>
<location filename="../src/gui.cpp" line="335"/>
<source>Map</source>
<translation>Mapa</translation>
</message>
<message>
<location filename="../src/gui.cpp" line="281"/>
<location filename="../src/gui.cpp" line="342"/>
<source>POI</source>
<translation>POI</translation>
</message>
<message>
<location filename="../src/gui.cpp" line="282"/>
<location filename="../src/gui.cpp" line="343"/>
<source>POI files</source>
<translation>POI soubory</translation>
</message>
<message>
<location filename="../src/gui.cpp" line="290"/>
<location filename="../src/gui.cpp" line="351"/>
<source>Settings</source>
<translation>Nastavení</translation>
</message>
<message>
<location filename="../src/gui.cpp" line="291"/>
<location filename="../src/gui.cpp" line="352"/>
<source>Units</source>
<translation>Jednotky</translation>
</message>
<message>
<location filename="../src/gui.cpp" line="298"/>
<location filename="../src/gui.cpp" line="361"/>
<source>Help</source>
<translation>Nápověda</translation>
</message>
<message>
<location filename="../src/gui.cpp" line="348"/>
<location filename="../src/gui.cpp" line="476"/>
<source>Previous map</source>
<translation>Předchozí mapa</translation>
</message>
<message>
<location filename="../src/gui.cpp" line="822"/>
<source>No GPX files loaded</source>
<translation>Nejsou načteny žádné GPX soubory</translation>
</message>
<message>
<location filename="../src/gui.cpp" line="922"/>
<source>Elevation</source>
<translation>Výška</translation>
</message>
<message>
<location filename="../src/gui.cpp" line="349"/>
<location filename="../src/gui.cpp" line="923"/>
<source>Speed</source>
<translation>Rychlost</translation>
</message>
<message>
<location filename="../src/gui.cpp" line="399"/>
<location filename="../src/gui.cpp" line="924"/>
<source>Heart rate</source>
<translation>Tep</translation>
</message>
<message>
<location filename="../src/gui.cpp" line="467"/>
<source>Next file</source>
<translation>Následující soubor</translation>
</message>
<message>
<location filename="../src/gui.cpp" line="400"/>
<location filename="../src/gui.cpp" line="444"/>
<source>Version </source>
<translation>Verze </translation>
</message>
<message>
<location filename="../src/gui.cpp" line="468"/>
<source>Previous file</source>
<translation>Předchozí soubor</translation>
</message>
<message>
<location filename="../src/gui.cpp" line="402"/>
<location filename="../src/gui.cpp" line="470"/>
<source>First file</source>
<translation>První soubor</translation>
</message>
<message>
<location filename="../src/gui.cpp" line="403"/>
<location filename="../src/gui.cpp" line="471"/>
<source>Last file</source>
<translation>Poslední soubor</translation>
</message>
<message>
<location filename="../src/gui.cpp" line="404"/>
<location filename="../src/gui.cpp" line="472"/>
<source>Append modifier</source>
<translation>Modifikátor nahradit/přidat</translation>
</message>
<message>
<location filename="../src/gui.cpp" line="418"/>
<location filename="../src/gui.cpp" line="491"/>
<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="422"/>
<location filename="../src/gui.cpp" line="494"/>
<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="430"/>
<location filename="../src/gui.cpp" line="502"/>
<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="442"/>
<location filename="../src/gui.cpp" line="513"/>
<source>GPX files (*.gpx);;All files (*)</source>
<translation>soubory GPX (*.gpx);;všechny soubory (*)</translation>
</message>
<message>
<location filename="../src/gui.cpp" line="492"/>
<location filename="../src/gui.cpp" line="509"/>
<location filename="../src/gui.cpp" line="574"/>
<location filename="../src/gui.cpp" line="600"/>
<source>Line: %1</source>
<translation>Řádka: %1</translation>
</message>
<message>
<location filename="../src/gui.cpp" line="502"/>
<location filename="../src/gui.cpp" line="584"/>
<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="577"/>
<location filename="../src/gui.cpp" line="697"/>
<location filename="../src/gui.cpp" line="665"/>
<location filename="../src/gui.cpp" line="837"/>
<source>mi</source>
<translation>mi</translation>
</message>
<message>
<location filename="../src/gui.cpp" line="580"/>
<location filename="../src/gui.cpp" line="582"/>
<location filename="../src/gui.cpp" line="584"/>
<location filename="../src/gui.cpp" line="586"/>
<location filename="../src/gui.cpp" line="668"/>
<location filename="../src/gui.cpp" line="670"/>
<location filename="../src/gui.cpp" line="672"/>
<location filename="../src/gui.cpp" line="674"/>
<location filename="../src/gui.cpp" line="834"/>
<source>ft</source>
<translation>ft</translation>
</message>
<message>
<location filename="../src/gui.cpp" line="583"/>
<location filename="../src/gui.cpp" line="595"/>
<location filename="../src/gui.cpp" line="671"/>
<location filename="../src/gui.cpp" line="683"/>
<source>Maximum</source>
<translation>Maximum</translation>
</message>
<message>
<location filename="../src/gui.cpp" line="585"/>
<location filename="../src/gui.cpp" line="597"/>
<location filename="../src/gui.cpp" line="673"/>
<location filename="../src/gui.cpp" line="685"/>
<source>Minimum</source>
<translation>Minimum</translation>
</message>
<message>
<location filename="../src/gui.cpp" line="159"/>
<location filename="../src/gui.cpp" line="376"/>
<location filename="../src/gui.cpp" line="192"/>
<location filename="../src/gui.cpp" line="442"/>
<source>About GPXSee</source>
<translation>O aplikaci GPXSee</translation>
</message>
<message>
<location filename="../src/gui.cpp" line="324"/>
<location filename="../src/gui.cpp" line="386"/>
<source>Navigation</source>
<translation>Navigace</translation>
</message>
<message>
<location filename="../src/gui.cpp" line="378"/>
<source>GPX viewer and analyzer</source>
<translation>Prohlížeč a analyzátor GPX</translation>
</message>
<message>
<location filename="../src/gui.cpp" line="417"/>
<location filename="../src/gui.cpp" line="490"/>
<source>Map sources</source>
<translation>Mapové zdroje</translation>
</message>
<message>
<location filename="../src/gui.cpp" line="429"/>
<location filename="../src/gui.cpp" line="501"/>
<source>POIs</source>
<translation>POI body</translation>
</message>
<message>
<location filename="../src/gui.cpp" line="576"/>
<location filename="../src/gui.cpp" line="588"/>
<location filename="../src/gui.cpp" line="664"/>
<location filename="../src/gui.cpp" line="676"/>
<source>Distance</source>
<translation>Vzdálenost</translation>
</message>
<message>
<location filename="../src/gui.cpp" line="578"/>
<location filename="../src/gui.cpp" line="590"/>
<location filename="../src/gui.cpp" line="666"/>
<location filename="../src/gui.cpp" line="678"/>
<source>Time</source>
<translation>Čas</translation>
</message>
<message>
<location filename="../src/gui.cpp" line="579"/>
<location filename="../src/gui.cpp" line="591"/>
<location filename="../src/gui.cpp" line="667"/>
<location filename="../src/gui.cpp" line="679"/>
<source>Ascent</source>
<translation>Stoupání</translation>
</message>
<message>
<location filename="../src/gui.cpp" line="592"/>
<location filename="../src/gui.cpp" line="594"/>
<location filename="../src/gui.cpp" line="596"/>
<location filename="../src/gui.cpp" line="598"/>
<location filename="../src/gui.cpp" line="680"/>
<location filename="../src/gui.cpp" line="682"/>
<location filename="../src/gui.cpp" line="684"/>
<location filename="../src/gui.cpp" line="686"/>
<location filename="../src/gui.cpp" line="841"/>
<source>m</source>
<translation>m</translation>
</message>
<message>
<location filename="../src/gui.cpp" line="581"/>
<location filename="../src/gui.cpp" line="593"/>
<location filename="../src/gui.cpp" line="669"/>
<location filename="../src/gui.cpp" line="681"/>
<source>Descent</source>
<translation>Klesání</translation>
</message>
<message>
<location filename="../src/gui.cpp" line="693"/>
<location filename="../src/gui.cpp" line="829"/>
<source>%1 tracks</source>
<translation>Počet tras: %1</translation>
</message>
<message>
<location filename="../src/gui.cpp" line="589"/>
<location filename="../src/gui.cpp" line="700"/>
<location filename="../src/gui.cpp" line="677"/>
<location filename="../src/gui.cpp" line="844"/>
<source>km</source>
<translation>km</translation>
</message>
<message>
<location filename="../src/gui.cpp" line="494"/>
<location filename="../src/gui.cpp" line="510"/>
<location filename="../src/gui.cpp" line="576"/>
<location filename="../src/gui.cpp" line="601"/>
<source>Error</source>
<translation>Chyba</translation>
</message>
<message>
<location filename="../src/gui.cpp" line="489"/>
<location filename="../src/gui.cpp" line="571"/>
<source>Error loading GPX file:
%1</source>
<translation>Soubor GPX nelze otevřít:
%1</translation>
</message>
<message>
<location filename="../src/gui.cpp" line="506"/>
<location filename="../src/gui.cpp" line="597"/>
<source>Error loading POI file:
%1</source>
<translation>Soubor POI nelze otevřít:
%1</translation>
</message>
</context>
<context>
<name>HeartRateGraph</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"/>
<source>Heart rate</source>
<translation>Tep</translation>
</message>
<message>
<location filename="../src/heartrategraph.cpp" line="78"/>
<source>km</source>
<translation>km</translation>
</message>
<message>
<location filename="../src/heartrategraph.cpp" line="9"/>
<source>1/min</source>
<translation>1/min</translation>
</message>
<message>
<location filename="../src/heartrategraph.cpp" line="18"/>
<source>Average</source>
<translation>Průměr</translation>
</message>
<message>
<location filename="../src/heartrategraph.cpp" line="20"/>
<source>Maximum</source>
<translation>Maximum</translation>
</message>
<message>
<location filename="../src/heartrategraph.cpp" line="75"/>
<source>m</source>
<translation>m</translation>
</message>
<message>
<location filename="../src/heartrategraph.cpp" line="83"/>
<source>ft</source>
<translation>ft</translation>
</message>
<message>
<location filename="../src/heartrategraph.cpp" line="86"/>
<source>mi</source>
<translation>mi</translation>
</message>
</context>
<context>
<name>QObject</name>
<message>
@ -431,44 +508,52 @@
<context>
<name>SpeedGraph</name>
<message>
<location filename="../src/speedgraph.cpp" line="10"/>
<location filename="../src/speedgraph.cpp" line="11"/>
<source>Distance</source>
<translation>Vzdálenost</translation>
</message>
<message>
<location filename="../src/speedgraph.cpp" line="11"/>
<location filename="../src/speedgraph.cpp" line="12"/>
<source>Speed</source>
<translation>Rychlost</translation>
</message>
<message>
<location filename="../src/speedgraph.cpp" line="12"/>
<location filename="../src/speedgraph.cpp" line="73"/>
<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="13"/>
<location filename="../src/speedgraph.cpp" line="74"/>
<location filename="../src/speedgraph.cpp" line="80"/>
<source>ft</source>
<translation>ft</translation>
</message>
<message>
<location filename="../src/speedgraph.cpp" line="92"/>
<source>km/h</source>
<translation>km/h</translation>
</message>
<message>
<location filename="../src/speedgraph.cpp" line="21"/>
<location filename="../src/speedgraph.cpp" line="19"/>
<source>Average</source>
<translation>Průměr</translation>
</message>
<message>
<location filename="../src/speedgraph.cpp" line="23"/>
<location filename="../src/speedgraph.cpp" line="21"/>
<source>Maximum</source>
<translation>Maximum</translation>
</message>
<message>
<location filename="../src/speedgraph.cpp" line="78"/>
<location filename="../src/speedgraph.cpp" line="83"/>
<source>mi</source>
<translation>mi</translation>
</message>
<message>
<location filename="../src/speedgraph.cpp" line="79"/>
<location filename="../src/speedgraph.cpp" line="95"/>
<source>mi/h</source>
<translation>mi/h</translation>
</message>

View File

@ -18,7 +18,9 @@ InstallDir "$PROGRAMFILES\GPXSee"
InstallDirRegKey HKLM "Software\GPXSee" "Install_Dir"
; Registry key for uninstaller
!define REGENTRY "Software\Microsoft\Windows\CurrentVersion\Uninstall\GPXSee"
!define REGENTRY "Software\Microsoft\Windows\CurrentVersion\Uninstall\GPXSee"
; GPX file type registry entry
!define REGGPX "GPXSee.gpx"
; Start menu page configuration
!define MUI_STARTMENUPAGE_REGISTRY_ROOT "HKLM"
@ -55,8 +57,9 @@ Section "GPXSee (required)" SEC_APP
; Set output path to the installation directory.
SetOutPath $INSTDIR
; Put file there
; Put the files there
File "gpxsee.exe"
File "maps.txt"
; Write the installation path into the registry
WriteRegStr HKLM SOFTWARE\GPXSee "Install_Dir" "$INSTDIR"
@ -64,7 +67,7 @@ Section "GPXSee (required)" SEC_APP
; Write the uninstall keys for Windows
WriteRegStr HKLM "${REGENTRY}" "DisplayName" "GPXSee"
WriteRegStr HKLM "${REGENTRY}" "Publisher" "Martin Tuma"
WriteRegStr HKLM "${REGENTRY}" "DisplayVersion" "2.9"
WriteRegStr HKLM "${REGENTRY}" "DisplayVersion" "2.13"
WriteRegStr HKLM "${REGENTRY}" "UninstallString" '"$INSTDIR\uninstall.exe"'
WriteRegDWORD HKLM "${REGENTRY}" "NoModify" 1
WriteRegDWORD HKLM "${REGENTRY}" "NoRepair" 1
@ -78,6 +81,13 @@ Section "GPXSee (required)" SEC_APP
CreateShortCut "$SMPROGRAMS\$StartMenuFolder\GPXSee.lnk" "$INSTDIR\gpxsee.exe"
!insertmacro MUI_STARTMENU_WRITE_END
; Associate .gpx files
WriteRegStr HKCR ".gpx" "" "${REGGPX}"
WriteRegStr HKCR "${REGGPX}" "" "GPS Exchange Format"
WriteRegStr HKCR "${REGGPX}\DefaultIcon" "" "$INSTDIR\GPXSee.exe,1"
WriteRegStr HKCR "${REGGPX}\shell\open\command" "" "$\"$INSTDIR\GPXSee.exe$\" $\"%1$\""
System::Call 'shell32.dll::SHChangeNotify(i, i, i, i) v (0x08000000, 0, 0, 0)'
SectionEnd
Section "QT libs" SEC_QT
@ -131,7 +141,12 @@ Section "Uninstall"
SetShellVarContext all
!insertmacro MUI_STARTMENU_GETFOLDER Application $StartMenuFolder
Delete "$SMPROGRAMS\$StartMenuFolder\*.*"
RMDir "$SMPROGRAMS\$StartMenuFolder"
RMDir "$SMPROGRAMS\$StartMenuFolder"
; Remove GPX file association
DeleteRegKey HKCR "${REGGPX}"
DeleteRegKey HKCR ".gpx"
System::Call 'shell32.dll::SHChangeNotify(i, i, i, i) v (0x08000000, 0, 0, 0)'
SectionEnd

174
pkg/gpxsee64.nsi Normal file
View File

@ -0,0 +1,174 @@
!include "MUI2.nsh"
!include "x64.nsh"
; The name of the installer
Name "GPXSee"
; The file to write
OutFile "install.exe"
; Required execution level
RequestExecutionLevel admin
; The default installation directory
InstallDir "$PROGRAMFILES64\GPXSee"
; Registry key to check for directory (so if you install again, it will
; overwrite the old one automatically)
InstallDirRegKey HKLM "Software\GPXSee" "Install_Dir"
; Registry key for uninstaller
!define REGENTRY "Software\Microsoft\Windows\CurrentVersion\Uninstall\GPXSee"
; GPX file type registry entry
!define REGGPX "GPXSee.gpx"
; Start menu page configuration
!define MUI_STARTMENUPAGE_REGISTRY_ROOT "HKLM"
!define MUI_STARTMENUPAGE_REGISTRY_KEY "Software\GPXSee"
!define MUI_STARTMENUPAGE_REGISTRY_VALUENAME "GPXSee"
Var StartMenuFolder
;--------------------------------
; Pages
!insertmacro MUI_PAGE_WELCOME
!insertmacro MUI_PAGE_LICENSE "licence.txt"
!insertmacro MUI_PAGE_COMPONENTS
!insertmacro MUI_PAGE_DIRECTORY
!insertmacro MUI_PAGE_STARTMENU Application $StartMenuFolder
!insertmacro MUI_PAGE_INSTFILES
!insertmacro MUI_UNPAGE_CONFIRM
!insertmacro MUI_UNPAGE_INSTFILES
;--------------------------------
; Languages
!insertmacro MUI_LANGUAGE "English"
Function .onInit
${If} ${RunningX64}
SetRegView 64
${Else}
MessageBox MB_OK "The 64b version of GPXSee can not be run on 32b systems."
Abort
${EndIf}
FunctionEnd
; The stuff to install
Section "GPXSee (required)" SEC_APP
SectionIn RO
; Set output path to the installation directory.
SetOutPath $INSTDIR
; Put the files there
File "gpxsee.exe"
File "maps.txt"
; Write the installation path into the registry
WriteRegStr HKLM SOFTWARE\GPXSee "Install_Dir" "$INSTDIR"
; Write the uninstall keys for Windows
WriteRegStr HKLM "${REGENTRY}" "DisplayName" "GPXSee"
WriteRegStr HKLM "${REGENTRY}" "Publisher" "Martin Tuma"
WriteRegStr HKLM "${REGENTRY}" "DisplayVersion" "2.13"
WriteRegStr HKLM "${REGENTRY}" "UninstallString" '"$INSTDIR\uninstall.exe"'
WriteRegDWORD HKLM "${REGENTRY}" "NoModify" 1
WriteRegDWORD HKLM "${REGENTRY}" "NoRepair" 1
WriteUninstaller "$INSTDIR\uninstall.exe"
; Create start menu entry and add links
SetShellVarContext all
!insertmacro MUI_STARTMENU_WRITE_BEGIN Application
CreateDirectory "$SMPROGRAMS\$StartMenuFolder"
CreateShortCut "$SMPROGRAMS\$StartMenuFolder\Uninstall.lnk" "$INSTDIR\Uninstall.exe"
CreateShortCut "$SMPROGRAMS\$StartMenuFolder\GPXSee.lnk" "$INSTDIR\gpxsee.exe"
!insertmacro MUI_STARTMENU_WRITE_END
; Associate .gpx files
WriteRegStr HKCR ".gpx" "" "${REGGPX}"
WriteRegStr HKCR "${REGGPX}" "" "GPS Exchange Format"
WriteRegStr HKCR "${REGGPX}\DefaultIcon" "" "$INSTDIR\GPXSee.exe,1"
WriteRegStr HKCR "${REGGPX}\shell\open\command" "" "$\"$INSTDIR\GPXSee.exe$\" $\"%1$\""
System::Call 'shell32.dll::SHChangeNotify(i, i, i, i) v (0x08000000, 0, 0, 0)'
SectionEnd
Section "QT libs" SEC_QT
File "Qt5Core.dll"
File "Qt5Gui.dll"
File "Qt5Widgets.dll"
File "Qt5PrintSupport.dll"
File "Qt5Network.dll"
File "libGLESv2.dll"
File /r "platforms"
File /r "imageformats"
SectionEnd
Section "MSVC runtime" SEC_MSVC
DetailPrint "Checking whether Visual C++ 2015 Redistributable is already installed..."
ReadRegDword $R0 HKLM "SOFTWARE\Wow6432Node\Microsoft\VisualStudio\14.0\VC\Runtimes\x64" "Installed"
StrCmp $R0 "1" 0 +3
DetailPrint "Visual C++ 2015 Redistributable is already installed, skipping install."
Goto done
DetailPrint "Installing Visual C++ 2015 Redistributable..."
SetOutPath $TEMP
File "VC_redist.x64.exe"
ExecWait '"$TEMP/VC_redist.x64.exe" /install /quiet /norestart'
done:
SectionEnd
;--------------------------------
; Uninstaller
Section "Uninstall"
; Remove registry keys
SetRegView 64
DeleteRegKey HKLM "${REGENTRY}"
DeleteRegKey HKLM SOFTWARE\GPXSee
; Remove directories used
RMDir /r "$INSTDIR"
; Remove Start menu entries
SetShellVarContext all
!insertmacro MUI_STARTMENU_GETFOLDER Application $StartMenuFolder
Delete "$SMPROGRAMS\$StartMenuFolder\*.*"
RMDir "$SMPROGRAMS\$StartMenuFolder"
; Remove GPX file association
DeleteRegKey HKCR "${REGGPX}"
DeleteRegKey HKCR ".gpx"
System::Call 'shell32.dll::SHChangeNotify(i, i, i, i) v (0x08000000, 0, 0, 0)'
SectionEnd
;-------------------------------
;Descriptions
;Language strings
LangString DESC_QT ${LANG_ENGLISH} \
"QT Library. Unselct only if you have QT already installed!"
LangString DESC_MSVC ${LANG_ENGLISH} \
"Visual C++ 2015 runtime components. Unselct only if you have the runtime already installed!"
LangString DESC_APP ${LANG_ENGLISH} \
"GPXSee application"
;Assign language strings to sections
!insertmacro MUI_FUNCTION_DESCRIPTION_BEGIN
!insertmacro MUI_DESCRIPTION_TEXT ${SEC_QT} $(DESC_QT)
!insertmacro MUI_DESCRIPTION_TEXT ${SEC_MSVC} $(DESC_MSVC)
!insertmacro MUI_DESCRIPTION_TEXT ${SEC_APP} $(DESC_APP)
!insertmacro MUI_FUNCTION_DESCRIPTION_END

48
src/app.cpp Normal file
View File

@ -0,0 +1,48 @@
#include <QtGlobal>
#include <QTranslator>
#include <QLocale>
#include <QFileOpenEvent>
#include "gui.h"
#include "app.h"
App::App(int &argc, char **argv) : QApplication(argc, argv),
_argc(argc), _argv(argv)
{
_translator = new QTranslator();
QString locale = QLocale::system().name();
_translator->load(QString(":/lang/gpxsee_") + locale);
installTranslator(_translator);
#ifdef Q_OS_MAC
setAttribute(Qt::AA_DontShowIconsInMenus);
#endif // Q_OS_MAC
_gui = new GUI();
}
App::~App()
{
delete _gui;
delete _translator;
}
void App::run()
{
_gui->show();
for (int i = 1; i < _argc; i++)
_gui->openFile(QString::fromLocal8Bit(_argv[i]));
exec();
}
bool App::event(QEvent *event)
{
if (event->type() == QEvent::FileOpen) {
QFileOpenEvent *e = static_cast<QFileOpenEvent *>(event);
return _gui->openFile(e->file());
}
return QApplication::event(event);
}

28
src/app.h Normal file
View File

@ -0,0 +1,28 @@
#ifndef APP_H
#define APP_H
#include <QApplication>
class GUI;
class QTranslator;
class App : QApplication
{
Q_OBJECT
public:
App(int &argc, char **argv);
~App();
void run();
protected:
bool event(QEvent *event);
private:
int &_argc;
char **_argv;
GUI *_gui;
QTranslator *_translator;
};
#endif // APP_H

View File

@ -36,25 +36,25 @@ AxisItem::AxisItem(Type type, QGraphicsItem *parent) : QGraphicsItem(parent)
_size = 0;
}
void AxisItem::setRange(const QPointF &range)
void AxisItem::setRange(const RangeF &range)
{
prepareGeometryChange();
_range = range;
updateBoundingRect();
prepareGeometryChange();
}
void AxisItem::setSize(qreal size)
{
prepareGeometryChange();
_size = size;
updateBoundingRect();
prepareGeometryChange();
}
void AxisItem::setLabel(const QString& label)
{
prepareGeometryChange();
_label = label;
updateBoundingRect();
prepareGeometryChange();
}
void AxisItem::updateBoundingRect()
@ -67,7 +67,7 @@ void AxisItem::updateBoundingRect()
struct Label l;
l = label(_range.x(), _range.y(), (_type == X) ? XTICKS : YTICKS);
l = label(_range.min(), _range.max(), (_type == X) ? XTICKS : YTICKS);
es = fm.tightBoundingRect(QString::number(l.max));
ss = fm.tightBoundingRect(QString::number(l.min));
ls = fm.tightBoundingRect(_label);
@ -77,9 +77,20 @@ void AxisItem::updateBoundingRect()
_size + es.width()/2 + ss.width()/2,
ls.height() + es.height() - fm.descent() + TICK + 2*PADDING);
} else {
_boundingRect = QRectF(-(ls.height() + es.width() + 2*PADDING
int mtw = 0;
QRect ts;
qreal val;
for (int i = 0; i < ((l.max - l.min) / l.d) + 1; i++) {
val = l.min + i * l.d;
QString str = QString::number(val);
ts = fm.tightBoundingRect(str);
mtw = qMax(ts.width(), mtw);
}
_boundingRect = QRectF(-(ls.height() + mtw + 2*PADDING
- fm.descent() + TICK/2), -(_size + es.height()/2
+ fm.descent()), ls.height() -fm.descent() + es.width() + 2*PADDING
+ fm.descent()), ls.height() -fm.descent() + mtw + 2*PADDING
+ TICK, _size + es.height()/2 + fm.descent() + ss.height()/2);
}
}
@ -95,7 +106,7 @@ void AxisItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *option,
QFontMetrics fm(font);
QRect ts, ls;
struct Label l;
qreal range = _range.y() - _range.x();
qreal range = _range.size();
qreal val;
@ -106,15 +117,15 @@ void AxisItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *option,
if (_type == X) {
painter->drawLine(0, 0, _size, 0);
l = label(_range.x(), _range.y(), XTICKS);
l = label(_range.min(), _range.max(), XTICKS);
for (int i = 0; i < ((l.max - l.min) / l.d) + 1; i++) {
val = l.min + i * l.d;
QString str = QString::number(val);
painter->drawLine((_size/range) * (val - _range.x()), TICK/2,
(_size/range) * (val - _range.x()), -TICK/2);
painter->drawLine((_size/range) * (val - _range.min()), TICK/2,
(_size/range) * (val - _range.min()), -TICK/2);
ts = fm.tightBoundingRect(str);
painter->drawText(((_size/range) * (val - _range.x()))
painter->drawText(((_size/range) * (val - _range.min()))
- (ts.width()/2), ts.height() + TICK/2 + PADDING, str);
}
@ -123,21 +134,23 @@ void AxisItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *option,
} else {
painter->drawLine(0, 0, 0, -_size);
l = label(_range.x(), _range.y(), YTICKS);
l = label(_range.min(), _range.max(), YTICKS);
int mtw = 0;
for (int i = 0; i < ((l.max - l.min) / l.d) + 1; i++) {
val = l.min + i * l.d;
QString str = QString::number(val);
painter->drawLine(TICK/2, -((_size/range) * (val - _range.x())),
-TICK/2, -((_size/range) * (val - _range.x())));
painter->drawLine(TICK/2, -((_size/range) * (val - _range.min())),
-TICK/2, -((_size/range) * (val - _range.min())));
ts = fm.tightBoundingRect(str);
mtw = qMax(ts.width(), mtw);
painter->drawText(-(ts.width() + PADDING + TICK/2), -((_size/range)
* (val - _range.x())) + (ts.height()/2), str);
* (val - _range.min())) + (ts.height()/2), str);
}
painter->rotate(-90);
painter->drawText(_size/2 - ls.width()/2, -(ts.width()
+ 2*PADDING + TICK/2), _label);
painter->drawText(_size/2 - ls.width()/2, -(mtw + 2*PADDING + TICK/2),
_label);
painter->rotate(90);
}
@ -156,7 +169,7 @@ QSizeF AxisItem::margin() const
struct Label l;
l = label(_range.x(), _range.y(), (_type == X) ? XTICKS : YTICKS);
l = label(_range.min(), _range.max(), (_type == X) ? XTICKS : YTICKS);
es = fm.tightBoundingRect(QString::number(l.max));
ss = fm.tightBoundingRect(QString::number(l.min));
ls = fm.tightBoundingRect(_label);
@ -165,7 +178,18 @@ QSizeF AxisItem::margin() const
return QSizeF(es.width()/2,
ls.height() + es.height() - fm.descent() + TICK/2 + 2*PADDING);
} else {
return QSizeF(ls.height() -fm.descent() + es.width() + 2*PADDING
int mtw = 0;
QRect ts;
qreal val;
for (int i = 0; i < ((l.max - l.min) / l.d) + 1; i++) {
val = l.min + i * l.d;
QString str = QString::number(val);
ts = fm.tightBoundingRect(str);
mtw = qMax(ts.width(), mtw);
}
return QSizeF(ls.height() -fm.descent() + mtw + 2*PADDING
+ TICK/2, es.height()/2 + fm.descent());
}
}

View File

@ -2,6 +2,7 @@
#define AXISITEM_H
#include <QGraphicsItem>
#include "range.h"
class AxisItem : public QGraphicsItem
{
@ -14,7 +15,7 @@ public:
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option,
QWidget *widget);
void setRange(const QPointF &range);
void setRange(const RangeF &range);
void setSize(qreal size);
void setLabel(const QString& label);
@ -24,7 +25,7 @@ private:
void updateBoundingRect();
Type _type;
QPointF _range;
RangeF _range;
qreal _size;
QString _label;
QRectF _boundingRect;

View File

@ -1,20 +1,36 @@
#ifndef CONFIG_H
#define CONFIG_H
#define APP_NAME "GPXSee"
#define APP_HOMEPAGE "http://tumic.wz.cz/gpxsee"
#define APP_VERSION "2.9"
#include <QtGlobal>
#include <QDir>
#include <QApplication>
#include <QString>
#define FONT_FAMILY "Arial"
#define FONT_SIZE 12
#define APP_NAME "GPXSee"
#define APP_HOMEPAGE "http://tumic.wz.cz/gpxsee"
#define FONT_FAMILY "Arial"
#define FONT_SIZE 12
#define MAP_FILE QString("maps.txt")
#define POI_DIR QString("POI")
#if defined(Q_OS_WIN32)
#define APP_DIR "GPXSee"
#define USER_DIR QDir::homePath() + QString("/GPXSee")
#define GLOBAL_DIR QApplication::applicationDirPath()
#elif defined(Q_OS_MAC)
#define USER_DIR QDir::homePath() + QString("/.gpxsee")
#define GLOBAL_DIR QApplication::applicationDirPath() \
+ QString("/../Resources")
#else
#define APP_DIR ".gpxsee"
#define USER_DIR QDir::homePath() + QString("/.gpxsee")
#define GLOBAL_DIR QString("/usr/share/gpxsee")
#endif
#define POI_DIR APP_DIR"/POI"
#define TILES_DIR APP_DIR"/tiles"
#define MAP_LIST_FILE APP_DIR"/maps.txt"
#define USER_MAP_FILE USER_DIR + QString("/") + MAP_FILE
#define USER_POI_DIR USER_DIR + QString("/") + POI_DIR
#define GLOBAL_MAP_FILE GLOBAL_DIR + QString("/") + MAP_FILE
#define GLOBAL_POI_DIR GLOBAL_DIR + QString("/") + POI_DIR
#define TILES_DIR USER_DIR + QString("/tiles")
#endif /* CONFIG_H */

42
src/cpuarch.h Normal file
View File

@ -0,0 +1,42 @@
#ifndef CPUARCH_H
#define CPUARCH_H
#include <QtGlobal>
#if QT_VERSION < QT_VERSION_CHECK(5, 4, 0)
#if defined(__arm64__)
#define CPU_ARCH_STR "arm64"
#elif defined(__arm__) || defined(__TARGET_ARCH_ARM) || defined(_M_ARM)
#define CPU_ARCH_STR "arm"
#elif defined(__x86_64) || defined(__x86_64__) || defined(__amd64) \
|| defined(_M_X64)
#define CPU_ARCH_STR "x86_64"
#elif defined(__i386) || defined(__i386__) || defined(_M_IX86)
#define CPU_ARCH_STR "i386"
#elif defined(__ia64) || defined(__ia64__) || defined(_M_IA64)
#define CPU_ARCH_STR "ia64"
#elif defined(_MIPS_ARCH_MIPS64) || defined(__mips64)
#define CPU_ARCH_STR "mips64"
#elif defined(__mips) || defined(__mips__) || defined(_M_MRX000)
#define CPU_ARCH_STR "mips"
#elif defined(__ppc64__) || defined(__powerpc64__) || defined(__64BIT__)
#define CPU_ARCH_STR "power64"
#elif defined(__ppc__) || defined(__ppc) || defined(__powerpc__) \
|| defined(_ARCH_COM) || defined(_ARCH_PWR) || defined(_ARCH_PPC) \
|| defined(_M_MPPC) || defined(_M_PPC)
#define CPU_ARCH_STR "power"
#else
#define CPU_ARCH_STR "unknown"
#endif
#define CPU_ARCH QString(CPU_ARCH_STR)
#else // QT_VERSION < 5.4
#include <QSysInfo>
#define CPU_ARCH QSysInfo::buildCpuArchitecture()
#endif // QT_VERSION < 5.4
#endif // CPUARCH_H

View File

@ -14,7 +14,8 @@
#define PLATFORM_STR "Unknown"
#endif
#define USER_AGENT APP_NAME"/"APP_VERSION" ("PLATFORM_STR"; Qt "QT_VERSION_STR")"
#define USER_AGENT \
APP_NAME "/" APP_VERSION " (" PLATFORM_STR "; Qt " QT_VERSION_STR ")"
Downloader::Downloader()
{

View File

@ -1,4 +1,3 @@
#include <float.h>
#include "config.h"
#include "gpx.h"
#include "elevationgraph.h"
@ -8,92 +7,108 @@ ElevationGraph::ElevationGraph(QWidget *parent) : GraphView(parent)
{
_ascent = 0;
_descent = 0;
_max = -FLT_MAX;
_min = FLT_MAX;
GraphView::setXLabel(tr("Distance"));
GraphView::setYLabel(tr("Elevation"));
GraphView::setXUnits(tr("km"));
GraphView::setYUnits(tr("m"));
GraphView::setXScale(M2KM);
GraphView::setMinRange(50.0);
_units = Metric;
setYUnits();
setXLabel(tr("Distance"));
setYLabel(tr("Elevation"));
setMinYRange(50.0);
}
void ElevationGraph::addInfo()
{
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);
GraphView::addInfo(tr("Ascent"), QString::number(_ascent * yScale(), 'f', 0)
+ UNIT_SPACE + yUnits());
GraphView::addInfo(tr("Descent"), QString::number(_descent * yScale(), 'f',
0) + UNIT_SPACE + yUnits());
GraphView::addInfo(tr("Maximum"), QString::number(max() * yScale(), 'f', 0)
+ UNIT_SPACE + yUnits());
GraphView::addInfo(tr("Minimum"), QString::number(min() * yScale(), 'f', 0)
+ UNIT_SPACE + yUnits());
redraw();
}
void ElevationGraph::loadGPX(const GPX &gpx)
{
for (int i = 0; i < gpx.trackCount(); i++) {
QVector<QPointF> data;
qreal min, max, ascent = 0, descent = 0;
qreal ascent = 0, descent = 0;
gpx.track(i).elevationGraph(data);
if (data.isEmpty())
if (data.count() < 2) {
skipColor();
continue;
}
min = max = data.at(0).y();
for (int i = 1; i < data.size(); i++) {
qreal cur = data.at(i).y();
qreal prev = data.at(i-1).y();
for (int j = 1; j < data.size(); j++) {
qreal cur = data.at(j).y();
qreal prev = data.at(j-1).y();
if (cur > prev)
ascent += cur - prev;
if (cur < prev)
descent += prev - cur;
if (cur > max)
max = cur;
if (cur < min)
min = cur;
}
_ascent += ascent;
_descent += descent;
_max = qMax(_max, max);
_min = qMin(_min, min);
addInfo();
loadData(data);
}
setXUnits();
addInfo();
}
void ElevationGraph::clear()
{
_ascent = 0;
_descent = 0;
_max = -FLT_MAX;
_min = FLT_MAX;
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) {
GraphView::setYUnits(tr("m"));
setYScale(1);
} else {
GraphView::setYUnits(tr("ft"));
setYScale(M2FT);
}
}
void ElevationGraph::setUnits(enum Units units)
{
if (units == Metric) {
GraphView::setXUnits(tr("km"));
GraphView::setYUnits(tr("m"));
GraphView::setXScale(M2KM);
GraphView::setYScale(1);
} else {
GraphView::setXUnits(tr("mi"));
GraphView::setYUnits(tr("ft"));
GraphView::setXScale(M2MI);
GraphView::setYScale(M2FT);
}
_units = units;
setXUnits();
setYUnits();
clearInfo();
addInfo();
redraw();
}

View File

@ -19,14 +19,16 @@ public:
qreal ascent() const {return _ascent;}
qreal descent() const {return _descent;}
qreal max() const {return _max;}
qreal min() const {return _min;}
qreal max() const {return bounds().bottom();}
qreal min() const {return bounds().top();}
private:
void setXUnits();
void setYUnits();
void addInfo();
qreal _ascent, _descent;
qreal _max, _min;
enum Units _units;
};
#endif // ELEVATIONGRAPH_H

View File

@ -1,4 +1,3 @@
#include <float.h>
#include <QGraphicsView>
#include <QGraphicsSceneMouseEvent>
#include <QEvent>
@ -28,6 +27,9 @@ GraphView::GraphView(QWidget *parent)
_scene = new Scene(this);
setScene(_scene);
setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
_xAxis = new AxisItem(AxisItem::X);
_yAxis = new AxisItem(AxisItem::Y);
@ -44,16 +46,13 @@ GraphView::GraphView(QWidget *parent)
_sliderInfo = new SliderInfoItem(_slider);
_sliderInfo->setZValue(2.0);
_xMax = -FLT_MAX;
_xMin = FLT_MAX;
_yMax = -FLT_MAX;
_yMin = FLT_MAX;
_xScale = 1;
_yScale = 1;
_precision = 0;
_minRange = 0.01;
_minYRange = 0.01;
_sliderPos = 0;
}
GraphView::~GraphView()
@ -74,14 +73,14 @@ GraphView::~GraphView()
void GraphView::updateBounds(const QPointF &point)
{
if (point.x() < _xMin)
_xMin = point.x();
if (point.x() > _xMax)
_xMax = point.x();
if (point.y() < _yMin)
_yMin = point.y();
if (point.y() > _yMax)
_yMax = point.y();
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());
}
void GraphView::createXLabel()
@ -137,6 +136,9 @@ void GraphView::loadData(const QVector<QPointF> &data)
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++) {
@ -151,26 +153,21 @@ void GraphView::loadData(const QVector<QPointF> &data)
pi->setPen(pen);
_scene->addItem(pi);
_graphs.append(pi);
if (_graphs.size() > 1)
_sliderInfo->hide();
redraw();
}
void GraphView::redraw()
{
if (!_graphs.isEmpty())
resize(viewport()->size() - QSizeF(MARGIN, MARGIN));
redraw(viewport()->size() - QSizeF(MARGIN, MARGIN));
}
void GraphView::resize(const QSizeF &size)
void GraphView::redraw(const QSizeF &size)
{
QRectF r;
QSizeF mx, my;
QPointF rx, ry;
RangeF rx, ry;
QTransform transform;
qreal xs, ys, diff;
qreal xs, ys;
if (_xAxis->scene() == _scene)
@ -185,20 +182,20 @@ void GraphView::resize(const QSizeF &size)
for (int i = 0; i < _graphs.size(); i++)
_graphs.at(i)->resetTransform();
rx = QPointF(_xMin * _xScale, _xMax * _xScale);
ry = QPointF(_yMin * _yScale, _yMax * _yScale);
if ((diff = ry.y() - ry.x()) < _minRange)
ry = QPointF(ry.x() - (_minRange/2 - diff/2),
ry.y() + (_minRange/2 - diff/2));
rx = RangeF(_bounds.left() * _xScale, _bounds.right() * _xScale);
ry = RangeF(_bounds.top() * _yScale, _bounds.bottom() * _yScale);
if (ry.size() < _minYRange)
ry.resize(_minYRange);
_xAxis->setRange(rx);
_yAxis->setRange(ry);
mx = _xAxis->margin();
my = _yAxis->margin();
r = _scene->itemsBoundingRect();
if (r.height() < _minRange)
r.adjust(0, -(_minRange/2 - r.height()/2), 0,
_minRange/2 - r.height()/2);
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())
@ -209,9 +206,9 @@ void GraphView::resize(const QSizeF &size)
_graphs.at(i)->setTransform(transform);
r = _scene->itemsBoundingRect();
if (r.height() < _minRange * ys)
r.adjust(0, -(_minRange/2 * ys - r.height()/2), 0,
(_minRange/2) * ys - r.height()/2);
if (r.height() < _minYRange * ys)
r.adjust(0, -(_minYRange/2 * ys - r.height()/2), 0,
(_minYRange/2) * ys - r.height()/2);
_xAxis->setSize(r.width());
_yAxis->setSize(r.height());
@ -220,16 +217,12 @@ void GraphView::resize(const QSizeF &size)
_scene->addItem(_xAxis);
_scene->addItem(_yAxis);
qreal sp = (_slider->pos().x() == _slider->area().left())
? 0 : (_slider->pos().x() - _slider->area().left())
/ _slider->area().width();
_slider->setArea(r);
_slider->setPos(QPointF(sp * r.width(), r.bottom()));
_slider->setPos((_sliderPos / _bounds.width()) * _slider->area().width(),
r.bottom());
_scene->addItem(_slider);
const QPainterPath &path = _graphs.at(0)->path();
QPointF p = path.pointAtPercent(sp);
_sliderInfo->setText(QString::number(-p.y() * _yScale, 'f', _precision));
updateSliderInfo();
r = _scene->itemsBoundingRect();
_info->setPos(r.topLeft() + QPointF(r.width()/2
@ -251,13 +244,13 @@ void GraphView::plot(QPainter *painter, const QRectF &target)
QSizeF orig = _scene->sceneRect().size();
QSizeF canvas = QSizeF(orig.height() * ratio, orig.height());
resize(canvas);
redraw(canvas);
_slider->hide();
_info->hide();
_scene->render(painter, target, QRectF());
_slider->show();
_info->show();
resize(orig);
redraw(orig);
}
void GraphView::clear()
@ -266,13 +259,10 @@ void GraphView::clear()
_scene->removeItem(_xAxis);
if (_yAxis->scene() == _scene)
_scene->removeItem(_yAxis);
if (_slider->scene() == _scene)
_scene->removeItem(_slider);
if (_info->scene() == _scene)
_scene->removeItem(_info);
_sliderInfo->show();
_slider->clear();
_info->clear();
@ -280,47 +270,99 @@ void GraphView::clear()
_graphs.clear();
_palette.reset();
_xMax = -FLT_MAX;
_xMin = FLT_MAX;
_yMax = -FLT_MAX;
_yMin = FLT_MAX;
_bounds = QRectF();
_sliderPos = 0;
_scene->setSceneRect(0, 0, 0, 0);
}
static qreal yAtX(const QPainterPath &path, qreal x)
{
int low = 0;
int high = path.elementCount() - 1;
int mid = 0;
Q_ASSERT(high > low);
Q_ASSERT(x >= path.elementAt(low).x && x <= path.elementAt(high).x);
while (low <= high) {
mid = low + ((high - low) / 2);
const QPainterPath::Element &e = path.elementAt(mid);
if (e.x > x)
high = mid - 1;
else if (e.x < x)
low = mid + 1;
else
return e.y;
}
QLineF l;
if (path.elementAt(mid).x < x)
l = QLineF(path.elementAt(mid).x, path.elementAt(mid).y,
path.elementAt(mid+1).x, path.elementAt(mid+1).y);
else
l = QLineF(path.elementAt(mid-1).x, path.elementAt(mid-1).y,
path.elementAt(mid).x, path.elementAt(mid).y);
return l.pointAt((x - l.p1().x()) / (l.p2().x() - l.p1().x())).y();
}
void GraphView::updateSliderInfo()
{
_sliderInfo->setVisible(_graphs.size() == 1);
if (_graphs.size() != 1)
return;
const QPainterPath &path = _graphs.at(0)->path();
QRectF br = path.boundingRect();
if (br.height() < _minYRange)
br.adjust(0, -(_minYRange/2 - br.height()/2), 0,
_minYRange/2 - br.height()/2);
qreal y = yAtX(path, _sliderPos);
qreal r = (y - br.bottom()) / br.height();
qreal pos = (_sliderPos / _bounds.width()) * _slider->area().width();
SliderInfoItem::Side s = (pos + _sliderInfo->boundingRect().width()
> _slider->area().right()) ? SliderInfoItem::Left : SliderInfoItem::Right;
_sliderInfo->setSide(s);
_sliderInfo->setPos(QPointF(0, _slider->boundingRect().height() * r));
_sliderInfo->setText(QString::number(-y * _yScale, 'f', _precision));
}
void GraphView::emitSliderPositionChanged(const QPointF &pos)
{
if (_graphs.isEmpty())
return;
qreal val = pos.x() / _slider->area().width();
emit sliderPositionChanged(val);
_sliderPos = (pos.x() / _slider->area().width()) * _bounds.width();
emit sliderPositionChanged(_sliderPos);
const QPainterPath &path = _graphs.at(0)->path();
QRectF br = path.boundingRect();
if (br.height() < _minRange)
br.adjust(0, -(_minRange/2 - br.height()/2), 0,
_minRange/2 - br.height()/2);
QPointF p = path.pointAtPercent(val);
qreal r = (p.y() - br.bottom()) / br.height();
_sliderInfo->setPos(QPointF(0, _slider->boundingRect().height() * r));
_sliderInfo->setText(QString::number(-p.y() * _yScale, 'f', _precision));
}
qreal GraphView::sliderPosition() const
{
return _slider->pos().x() / _slider->area().width();
updateSliderInfo();
}
void GraphView::setSliderPosition(qreal pos)
{
_slider->setPos(pos * _slider->area().width(), 0);
_sliderPos = pos;
if (_graphs.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);
}
}
void GraphView::newSliderPosition(const QPointF &pos)
{
if (_slider->area().contains(pos)) {
_slider->setPos(pos);
_slider->setVisible(true);
emitSliderPositionChanged(pos);
}
}

View File

@ -35,37 +35,44 @@ public:
~GraphView();
void loadData(const QVector<QPointF> &data);
void redraw();
void clear();
int count() const {return _graphs.count();}
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;}
void setXLabel(const QString &label);
void setYLabel(const QString &label);
void setXUnits(const QString &units);
void setYUnits(const QString &units);
void setXScale(qreal scale);
void setYScale(qreal scale);
void setPrecision(int precision) {_precision = precision;}
void setMinRange(qreal range) {_minRange = range;}
void redraw();
void setSliderPrecision(int precision) {_precision = precision;}
void setMinYRange(qreal range) {_minYRange = range;}
void plot(QPainter *painter, const QRectF &target);
void clear();
qreal sliderPosition() const;
qreal sliderPosition() const {return _sliderPos;}
void setSliderPosition(qreal pos);
void addInfo(const QString &key, const QString &value);
void clearInfo();
void plot(QPainter *painter, const QRectF &target);
signals:
void sliderPositionChanged(qreal);
protected:
const QRectF &bounds() const {return _bounds;}
void resizeEvent(QResizeEvent *);
qreal _xScale, _yScale;
QString _xUnits, _yUnits;
QString _xLabel, _yLabel;
int _precision;
qreal _minRange;
void redraw(const QSizeF &size);
void addInfo(const QString &key, const QString &value);
void clearInfo();
void skipColor() {_palette.color();}
private slots:
void emitSliderPositionChanged(const QPointF &pos);
@ -75,7 +82,14 @@ private:
void createXLabel();
void createYLabel();
void updateBounds(const QPointF &point);
void resize(const QSizeF &size);
void updateSliderInfo();
qreal _xScale, _yScale;
QString _xUnits, _yUnits;
QString _xLabel, _yLabel;
int _precision;
qreal _minYRange;
qreal _sliderPos;
Scene *_scene;
@ -85,7 +99,7 @@ private:
InfoItem *_info;
QList<QGraphicsPathItem*> _graphs;
qreal _xMin, _xMax, _yMin, _yMax;
QRectF _bounds;
Palette _palette;
};

View File

@ -14,20 +14,31 @@
#include <QActionGroup>
#include <QAction>
#include <QLabel>
#include <QSettings>
#include "config.h"
#include "icons.h"
#include "keys.h"
#include "settings.h"
#include "gpx.h"
#include "map.h"
#include "maplist.h"
#include "elevationgraph.h"
#include "speedgraph.h"
#include "heartrategraph.h"
#include "trackview.h"
#include "infoitem.h"
#include "filebrowser.h"
#include "cpuarch.h"
#include "gui.h"
#define ARRAY_SIZE(a) (sizeof(a)/sizeof(a[0]))
struct GraphTab {
GraphView *view;
QString label;
};
static QString timeSpan(qreal time)
{
unsigned h, m, s;
@ -43,7 +54,8 @@ static QString timeSpan(qreal time)
GUI::GUI(QWidget *parent) : QMainWindow(parent)
{
loadFiles();
loadMaps();
loadPOIs();
createActions();
createMenus();
@ -52,10 +64,12 @@ GUI::GUI(QWidget *parent) : QMainWindow(parent)
createTrackGraphs();
createStatusBar();
connect(_elevationGraph, SIGNAL(sliderPositionChanged(qreal)), _track,
SLOT(movePositionMarker(qreal)));
connect(_speedGraph, SIGNAL(sliderPositionChanged(qreal)), _track,
SLOT(movePositionMarker(qreal)));
connect(_elevationGraph, SIGNAL(sliderPositionChanged(qreal)), this,
SLOT(sliderPositionChanged(qreal)));
connect(_speedGraph, SIGNAL(sliderPositionChanged(qreal)), this,
SLOT(sliderPositionChanged(qreal)));
connect(_heartRateGraph, SIGNAL(sliderPositionChanged(qreal)), this,
SLOT(sliderPositionChanged(qreal)));
_browser = new FileBrowser(this);
_browser->setFilter(QStringList("*.gpx"));
@ -63,11 +77,16 @@ GUI::GUI(QWidget *parent) : QMainWindow(parent)
QVBoxLayout *layout = new QVBoxLayout;
layout->addWidget(_track);
layout->addWidget(_trackGraphs);
layout->setContentsMargins(0, 0, 0, 0);
#ifdef Q_OS_WIN32
layout->setSpacing(0);
#endif // Q_OS_WIN32
QWidget *widget = new QWidget;
widget->setLayout(layout);
setCentralWidget(widget);
setWindowIcon(QIcon(QPixmap(APP_ICON)));
setWindowTitle(APP_NAME);
setUnifiedTitleAndToolBarOnMac(true);
@ -75,19 +94,33 @@ GUI::GUI(QWidget *parent) : QMainWindow(parent)
_time = 0;
_trackCount = 0;
resize(600, 800);
_sliderPos = 0;
updateGraphTabs();
updateTrackView();
readSettings();
}
void GUI::loadFiles()
void GUI::loadMaps()
{
// Maps
_maps = MapList::load(this, QString("%1/" MAP_LIST_FILE)
.arg(QDir::homePath()));
_maps += MapList::load(this, ":/maps.txt");
if (QFile::exists(USER_MAP_FILE))
_maps = MapList::load(this, USER_MAP_FILE);
else
_maps = MapList::load(this, GLOBAL_MAP_FILE);
}
void GUI::loadPOIs()
{
QFileInfoList list;
QDir userDir(USER_POI_DIR);
QDir globalDir(GLOBAL_POI_DIR);
if (userDir.exists())
list = userDir.entryInfoList(QStringList(), QDir::Files);
else
list = globalDir.entryInfoList(QStringList(), QDir::Files);
// POI files
QDir dir(QString("%1/" POI_DIR).arg(QDir::homePath()));
QFileInfoList list = dir.entryInfoList(QStringList(), QDir::Files);
for (int i = 0; i < list.size(); ++i)
_poi.loadFile(list.at(i).absoluteFilePath());
}
@ -111,9 +144,6 @@ void GUI::createMapActions()
}
connect(sm, SIGNAL(mapped(int)), this, SLOT(mapChanged(int)));
_mapActions.at(0)->setChecked(true);
_currentMap = _maps.at(0);
}
void GUI::createPOIFilesActions()
@ -131,7 +161,6 @@ QAction *GUI::createPOIFileAction(int index)
QAction *a = new QAction(QFileInfo(_poi.files().at(index)).fileName(),
this);
a->setCheckable(true);
a->setChecked(true);
_poiFilesSM->setMapping(a, index);
connect(a, SIGNAL(triggered()), _poiFilesSM, SLOT(map()));
@ -153,8 +182,9 @@ void GUI::createActions()
// General actions
_exitAction = new QAction(QIcon(QPixmap(QUIT_ICON)), tr("Quit"), this);
_exitAction->setShortcut(QKeySequence::Quit);
_exitAction->setShortcut(QUIT_SHORTCUT);
connect(_exitAction, SIGNAL(triggered()), this, SLOT(close()));
addAction(_exitAction);
// Help & About
_dataSourcesAction = new QAction(tr("Data sources"), this);
@ -164,34 +194,37 @@ void GUI::createActions()
_aboutAction = new QAction(QIcon(QPixmap(APP_ICON)),
tr("About GPXSee"), this);
connect(_aboutAction, SIGNAL(triggered()), this, SLOT(about()));
_aboutQtAction = new QAction(QIcon(QPixmap(QT_ICON)), tr("About Qt"), this);
connect(_aboutQtAction, SIGNAL(triggered()), qApp, SLOT(aboutQt()));
// File related actions
_openFileAction = new QAction(QIcon(QPixmap(OPEN_FILE_ICON)),
tr("Open"), this);
_openFileAction->setShortcut(QKeySequence::Open);
_openFileAction->setShortcut(OPEN_SHORTCUT);
connect(_openFileAction, SIGNAL(triggered()), this, SLOT(openFile()));
addAction(_openFileAction);
_saveFileAction = new QAction(QIcon(QPixmap(SAVE_FILE_ICON)),
tr("Save"), this);
_saveFileAction->setShortcut(QKeySequence::Save);
_saveFileAction->setShortcut(SAVE_SHORTCUT);
_saveFileAction->setActionGroup(_fileActionGroup);
connect(_saveFileAction, SIGNAL(triggered()), this, SLOT(saveFile()));
addAction(_saveFileAction);
_saveAsAction = new QAction(QIcon(QPixmap(SAVE_AS_ICON)),
tr("Save as"), this);
_saveAsAction->setShortcut(QKeySequence::SaveAs);
_saveAsAction->setShortcut(SAVE_AS_SHORTCUT);
_saveAsAction->setActionGroup(_fileActionGroup);
connect(_saveAsAction, SIGNAL(triggered()), this, SLOT(saveAs()));
addAction(_saveAsAction);
_closeFileAction = new QAction(QIcon(QPixmap(CLOSE_FILE_ICON)),
tr("Close"), this);
_closeFileAction->setShortcut(QKeySequence::Close);
_closeFileAction->setShortcut(CLOSE_SHORTCUT);
_closeFileAction->setActionGroup(_fileActionGroup);
connect(_closeFileAction, SIGNAL(triggered()), this, SLOT(closeFile()));
connect(_closeFileAction, SIGNAL(triggered()), this, SLOT(closeAll()));
addAction(_closeFileAction);
_reloadFileAction = new QAction(QIcon(QPixmap(RELOAD_FILE_ICON)),
tr("Reload"), this);
_reloadFileAction->setShortcut(QKeySequence::Refresh);
_reloadFileAction->setShortcut(RELOAD_SHORTCUT);
_reloadFileAction->setActionGroup(_fileActionGroup);
connect(_reloadFileAction, SIGNAL(triggered()), this, SLOT(reloadFile()));
addAction(_reloadFileAction);
// POI actions
_openPOIAction = new QAction(QIcon(QPixmap(OPEN_FILE_ICON)),
@ -203,33 +236,46 @@ void GUI::createActions()
_showPOIAction = new QAction(QIcon(QPixmap(SHOW_POI_ICON)),
tr("Show POIs"), this);
_showPOIAction->setCheckable(true);
_showPOIAction->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_P));
_showPOIAction->setShortcut(SHOW_POI_SHORTCUT);
connect(_showPOIAction, SIGNAL(triggered(bool)), this, SLOT(showPOI(bool)));
addAction(_showPOIAction);
createPOIFilesActions();
// Map actions
_showMapAction = new QAction(QIcon(QPixmap(SHOW_MAP_ICON)), tr("Show map"),
this);
_showMapAction->setCheckable(true);
_showMapAction->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_M));
_showMapAction->setShortcut(SHOW_MAP_SHORTCUT);
connect(_showMapAction, SIGNAL(triggered(bool)), this, SLOT(showMap(bool)));
if (_maps.empty())
addAction(_showMapAction);
_clearMapCacheAction = new QAction(tr("Clear tile cache"), this);
connect(_clearMapCacheAction, SIGNAL(triggered()), this,
SLOT(clearMapCache()));
if (_maps.empty()) {
_showMapAction->setEnabled(false);
else {
_clearMapCacheAction->setEnabled(false);
} else {
createMapActions();
_showMapAction->setChecked(true);
_nextMapAction = new QAction(tr("Next map"), this);
_nextMapAction->setShortcut(NEXT_MAP_SHORTCUT);
connect(_nextMapAction, SIGNAL(triggered()), this, SLOT(nextMap()));
addAction(_nextMapAction);
_prevMapAction = new QAction(tr("Next map"), this);
_prevMapAction->setShortcut(PREV_MAP_SHORTCUT);
connect(_prevMapAction, SIGNAL(triggered()), this, SLOT(prevMap()));
addAction(_prevMapAction);
}
// Settings actions
_showGraphsAction = new QAction(tr("Show graphs"), this);
_showGraphsAction->setCheckable(true);
_showGraphsAction->setChecked(true);
_showGraphsAction->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_G));
_showGraphsAction->setShortcut(SHOW_GRAPHS_SHORTCUT);
connect(_showGraphsAction, SIGNAL(triggered(bool)), this,
SLOT(showGraphs(bool)));
addAction(_showGraphsAction);
_showToolbarsAction = new QAction(tr("Show toolbars"), this);
_showToolbarsAction->setCheckable(true);
_showToolbarsAction->setChecked(true);
connect(_showToolbarsAction, SIGNAL(triggered(bool)), this,
SLOT(showToolbars(bool)));
QActionGroup *ag = new QActionGroup(this);
@ -237,7 +283,6 @@ void GUI::createActions()
_metricUnitsAction = new QAction(tr("Metric"), this);
_metricUnitsAction->setCheckable(true);
_metricUnitsAction->setActionGroup(ag);
_metricUnitsAction->setChecked(true);
connect(_metricUnitsAction, SIGNAL(triggered()), this,
SLOT(setMetricUnits()));
_imperialUnitsAction = new QAction(tr("Imperial"), this);
@ -245,6 +290,13 @@ void GUI::createActions()
_imperialUnitsAction->setActionGroup(ag);
connect(_imperialUnitsAction, SIGNAL(triggered()), this,
SLOT(setImperialUnits()));
_fullscreenAction = new QAction(QIcon(QPixmap(FULLSCREEN_ICON)),
tr("Fullscreen mode"), this);
_fullscreenAction->setCheckable(true);
_fullscreenAction->setShortcut(FULLSCREEN_SHORTCUT);
connect(_fullscreenAction, SIGNAL(triggered(bool)), this,
SLOT(showFullscreen(bool)));
addAction(_fullscreenAction);
// Navigation actions
_nextAction = new QAction(QIcon(QPixmap(NEXT_FILE_ICON)), tr("Next"), this);
@ -282,6 +334,8 @@ void GUI::createMenus()
_mapMenu = menuBar()->addMenu(tr("Map"));
_mapMenu->addActions(_mapActions);
_mapMenu->addSeparator();
_mapMenu->addAction(_clearMapCacheAction);
_mapMenu->addSeparator();
_mapMenu->addAction(_showMapAction);
_poiMenu = menuBar()->addMenu(tr("POI"));
@ -300,13 +354,14 @@ void GUI::createMenus()
_settingsMenu->addSeparator();
_settingsMenu->addAction(_showToolbarsAction);
_settingsMenu->addAction(_showGraphsAction);
_settingsMenu->addSeparator();
_settingsMenu->addAction(_fullscreenAction);
_helpMenu = menuBar()->addMenu(tr("Help"));
_helpMenu->addAction(_dataSourcesAction);
_helpMenu->addAction(_keysAction);
_helpMenu->addSeparator();
_helpMenu->addAction(_aboutAction);
_helpMenu->addAction(_aboutQtAction);
}
void GUI::createToolBars()
@ -340,25 +395,30 @@ void GUI::createToolBars()
void GUI::createTrackView()
{
_track = new TrackView(this);
if (_showMapAction->isChecked())
_track->setMap(_currentMap);
#ifdef Q_OS_WIN32
_track->setFrameShape(QFrame::NoFrame);
#endif // Q_OS_WIN32
}
void GUI::createTrackGraphs()
{
_elevationGraph = new ElevationGraph;
_elevationGraph->setFrameShape(QFrame::NoFrame);
_speedGraph = new SpeedGraph;
_speedGraph->setFrameShape(QFrame::NoFrame);
_heartRateGraph = new HeartRateGraph;
_heartRateGraph->setFrameShape(QFrame::NoFrame);
_trackGraphs = new QTabWidget;
_trackGraphs->addTab(_elevationGraph, tr("Elevation"));
_trackGraphs->addTab(_speedGraph, tr("Speed"));
connect(_trackGraphs, SIGNAL(currentChanged(int)), this,
SLOT(graphChanged(int)));
_trackGraphs->setFixedHeight(200);
_trackGraphs->setSizePolicy(
QSizePolicy(QSizePolicy::Ignored, QSizePolicy::Fixed));
#ifdef Q_OS_WIN32
_trackGraphs->setDocumentMode(true);
#endif // Q_OS_WIN32
}
void GUI::createStatusBar()
@ -373,6 +433,8 @@ void GUI::createStatusBar()
statusBar()->addPermanentWidget(_distanceLabel, 1);
statusBar()->addPermanentWidget(_timeLabel, 1);
statusBar()->setSizeGripEnabled(false);
updateStatusBarInfo();
}
void GUI::about()
@ -380,8 +442,10 @@ void GUI::about()
QMessageBox msgBox(this);
msgBox.setWindowTitle(tr("About GPXSee"));
msgBox.setText(QString("<h3>") + QString(APP_NAME " " APP_VERSION)
+ QString("</h3><p>") + tr("GPX viewer and analyzer") + QString("<p/>"));
msgBox.setText(QString("<h2>") + QString(APP_NAME) + QString("</h2><p>")
+ QString("<p>") + tr("Version ") + APP_VERSION + QString(" (")
+ CPU_ARCH + QString(", Qt ") + QString(QT_VERSION_STR)
+ QString(")</p>"));
msgBox.setInformativeText(QString("<table width=\"300\"><tr><td>")
+ tr("GPXSee is distributed under the terms of the GNU General Public "
"License version 3. For more info about GPXSee visit the project "
@ -406,9 +470,14 @@ void GUI::keys()
+ QString("</td><td><i>SPACE</i></td></tr><tr><td>") + tr("Previous file")
+ QString("</td><td><i>BACKSPACE</i></td></tr><tr><td>")
+ tr("First file") + QString("</td><td><i>HOME</i></td></tr><tr><td>")
+ tr("Last file") + QString("</td><td><i>END</i></td></tr><tr><td></td>"
"<td></td></tr><tr><td>") + tr("Append modifier")
+ QString("</td><td><i>SHIFT</i></td></tr></table></div>"));
+ tr("Last file") + QString("</td><td><i>END</i></td></tr><tr><td>")
+ tr("Append modifier") + QString("</td><td><i>SHIFT</i></td></tr>"
"<tr><td></td><td></td></tr><tr><td>")
+ tr("Next map") + QString("</td><td><i>")
+ _nextMapAction->shortcut().toString() + QString("</i></td></tr><tr><td>")
+ tr("Previous map") + QString("</td><td><i>")
+ _prevMapAction->shortcut().toString() + QString("</i></td></tr>"
"</table></div>"));
msgBox.exec();
}
@ -423,8 +492,7 @@ void GUI::dataSources()
QString("<h4>") + tr("Map sources") + QString("</h4><p>")
+ tr("Map (tiles) source URLs are read on program startup from the "
"following file:")
+ QString("</p><p><code>") + QDir::homePath()
+ QString("/" MAP_LIST_FILE "</code></p><p>")
+ QString("</p><p><code>") + USER_MAP_FILE + QString("</code></p><p>")
+ tr("The file format is one map entry per line, consisting of the map "
"name and tiles URL delimited by a TAB character. The tile X and Y "
"coordinates are replaced with $x and $y in the URL and the zoom "
@ -435,8 +503,7 @@ void GUI::dataSources()
+ QString("<h4>") + tr("POIs") + QString("</h4><p>")
+ tr("To make GPXSee load a POI file automatically on startup, add "
"the file to the following directory:")
+ QString("</p><p><code>") + QDir::homePath()
+ QString("/" POI_DIR "</code></p>")
+ QString("</p><p><code>") + USER_POI_DIR + QString("</code></p>")
);
msgBox.exec();
@ -454,21 +521,29 @@ void GUI::openFile()
bool GUI::openFile(const QString &fileName)
{
bool ret = true;
if (fileName.isEmpty() || _files.contains(fileName))
return false;
if (loadFile(fileName)) {
_files.append(fileName);
_browser->setCurrent(fileName);
updateStatusBarInfo();
_fileActionGroup->setEnabled(true);
_navigationActionGroup->setEnabled(true);
updateNavigationActions();
return true;
} else {
updateNavigationActions();
return false;
if (_files.isEmpty())
_fileActionGroup->setEnabled(false);
ret = false;
}
updateNavigationActions();
updateStatusBarInfo();
updateWindowTitle();
updateGraphTabs();
updateTrackView();
return ret;
}
bool GUI::loadFile(const QString &fileName)
@ -478,9 +553,13 @@ bool GUI::loadFile(const QString &fileName)
if (gpx.loadFile(fileName)) {
_elevationGraph->loadGPX(gpx);
_speedGraph->loadGPX(gpx);
_heartRateGraph->loadGPX(gpx);
updateGraphTabs();
_track->setHidden(false);
_track->loadGPX(gpx);
if (_showPOIAction->isChecked())
_track->loadPOI(_poi);
_track->movePositionMarker(_sliderPos);
for (int i = 0; i < gpx.trackCount(); i++) {
_distance += gpx.track(i).distance();
@ -504,22 +583,34 @@ bool GUI::loadFile(const QString &fileName)
void GUI::openPOIFile()
{
QString fileName = QFileDialog::getOpenFileName(this, tr("Open POI file"),
QStringList files = QFileDialog::getOpenFileNames(this, tr("Open POI file"),
QString(), tr("GPX files (*.gpx);;CSV files (*.csv);;All files (*)"));
QStringList list = files;
if (!fileName.isEmpty()) {
if (!_poi.loadFile(fileName)) {
QString error = tr("Error loading POI file:\n%1")
.arg(_poi.errorString()) + QString("\n");
if (_poi.errorLine())
error.append(tr("Line: %1").arg(_poi.errorLine()));
QMessageBox::critical(this, tr("Error"), error);
} else {
_showPOIAction->setChecked(true);
_track->loadPOI(_poi);
_poiFilesMenu->addAction(createPOIFileAction(
_poi.files().indexOf(fileName)));
}
for (QStringList::Iterator it = list.begin(); it != list.end(); it++)
openPOIFile(*it);
}
bool GUI::openPOIFile(const QString &fileName)
{
if (fileName.isEmpty())
return false;
if (!_poi.loadFile(fileName)) {
QString error = tr("Error loading POI file:\n%1")
.arg(_poi.errorString()) + QString("\n");
if (_poi.errorLine())
error.append(tr("Line: %1").arg(_poi.errorLine()));
QMessageBox::critical(this, tr("Error"), error);
return false;
} else {
_showPOIAction->setChecked(true);
_track->loadPOI(_poi);
_poiFilesMenu->addAction(createPOIFileAction(
_poi.files().indexOf(fileName)));
return true;
}
}
@ -599,8 +690,6 @@ void GUI::saveFile(const QString &fileName)
}
scene.addItem(&info);
scene.render(&p, QRectF(0, 0, printer.width(), 200));
p.end();
}
void GUI::reloadFile()
@ -611,6 +700,7 @@ void GUI::reloadFile()
_elevationGraph->clear();
_speedGraph->clear();
_heartRateGraph->clear();
_track->clear();
for (int i = 0; i < _files.size(); i++) {
@ -621,26 +711,40 @@ void GUI::reloadFile()
}
updateStatusBarInfo();
updateWindowTitle();
updateGraphTabs();
updateTrackView();
if (_files.isEmpty())
_fileActionGroup->setEnabled(false);
else
_browser->setCurrent(_files.last());
}
void GUI::closeFile()
void GUI::closeFiles()
{
_distance = 0;
_time = 0;
_trackCount = 0;
_sliderPos = 0;
_elevationGraph->clear();
_speedGraph->clear();
_heartRateGraph->clear();
_track->clear();
_files.clear();
}
void GUI::closeAll()
{
closeFiles();
_fileActionGroup->setEnabled(false);
updateStatusBarInfo();
updateWindowTitle();
updateGraphTabs();
updateTrackView();
}
void GUI::showPOI(bool checked)
@ -680,10 +784,44 @@ void GUI::showToolbars(bool checked)
}
}
void GUI::showFullscreen(bool checked)
{
if (checked) {
_frameStyle = _track->frameStyle();
_showGraphs = _showGraphsAction->isChecked();
statusBar()->hide();
menuBar()->hide();
showToolbars(false);
showGraphs(false);
_showGraphsAction->setChecked(false);
_track->setFrameStyle(QFrame::NoFrame);
showFullScreen();
} else {
statusBar()->show();
menuBar()->show();
if (_showToolbarsAction->isChecked())
showToolbars(true);
_showGraphsAction->setChecked(_showGraphs);
if (_showGraphsAction->isEnabled())
showGraphs(_showGraphs);
_track->setFrameStyle(_frameStyle);
showNormal();
}
}
void GUI::clearMapCache()
{
_currentMap->clearCache();
_track->redraw();
}
void GUI::updateStatusBarInfo()
{
if (_files.count() == 0) {
_fileNameLabel->clear();
_fileNameLabel->setText(tr("No GPX files loaded"));
_distanceLabel->clear();
_timeLabel->clear();
return;
@ -692,15 +830,33 @@ void GUI::updateStatusBarInfo()
else
_fileNameLabel->setText(tr("%1 tracks").arg(_trackCount));
if (_imperialUnitsAction->isChecked())
_distanceLabel->setText(QString::number(_distance * M2MI, 'f', 1)
+ UNIT_SPACE + tr("mi"));
else
_distanceLabel->setText(QString::number(_distance * M2KM, 'f', 1)
+ UNIT_SPACE + tr("km"));
if (_imperialUnitsAction->isChecked()) {
if (_distance < MIINM)
_distanceLabel->setText(QString::number(_distance * M2FT, 'f', 0)
+ UNIT_SPACE + tr("ft"));
else
_distanceLabel->setText(QString::number(_distance * M2MI, 'f', 1)
+ UNIT_SPACE + tr("mi"));
} else {
if (_distance < KMINM)
_distanceLabel->setText(QString::number(_distance, 'f', 0)
+ UNIT_SPACE + tr("m"));
else
_distanceLabel->setText(QString::number(_distance * M2KM, 'f', 1)
+ UNIT_SPACE + tr("km"));
}
_timeLabel->setText(timeSpan(_time));
}
void GUI::updateWindowTitle()
{
if (_files.count() == 1)
setWindowTitle(QFileInfo(_files.at(0)).fileName()
+ QString(" - " APP_NAME));
else
setWindowTitle(APP_NAME);
}
void GUI::mapChanged(int index)
{
_currentMap = _maps.at(index);
@ -709,6 +865,24 @@ void GUI::mapChanged(int index)
_track->setMap(_currentMap);
}
void GUI::nextMap()
{
if (_maps.count() < 2)
return;
int next = (_maps.indexOf(_currentMap) + 1) % _maps.count();
_mapActions.at(next)->setChecked(true);
mapChanged(next);
}
void GUI::prevMap()
{
if (_maps.count() < 2)
return;
int prev = (_maps.indexOf(_currentMap) + _maps.count() - 1) % _maps.count();
_mapActions.at(prev)->setChecked(true);
mapChanged(prev);
}
void GUI::poiFileChecked(int index)
{
_poi.enableFile(_poi.files().at(index),
@ -719,12 +893,19 @@ void GUI::poiFileChecked(int index)
_track->loadPOI(_poi);
}
void GUI::sliderPositionChanged(qreal pos)
{
_sliderPos = pos;
_track->movePositionMarker(_sliderPos);
}
void GUI::graphChanged(int index)
{
if (_trackGraphs->widget(index) == _elevationGraph)
_elevationGraph->setSliderPosition(_speedGraph->sliderPosition());
else if (_trackGraphs->widget(index) == _speedGraph)
_speedGraph->setSliderPosition(_elevationGraph->sliderPosition());
if (index < 0)
return;
GraphView *gv = static_cast<GraphView*>(_trackGraphs->widget(index));
gv->setSliderPosition(_sliderPos);
}
void GUI::updateNavigationActions()
@ -746,11 +927,49 @@ void GUI::updateNavigationActions()
}
}
void GUI::updateGraphTabs()
{
struct GraphTab tabs[] = {
{_elevationGraph, tr("Elevation")},
{_speedGraph, tr("Speed")},
{_heartRateGraph, tr("Heart rate")}
};
int index;
GraphView *gv;
for (int i = 0; i < (int)ARRAY_SIZE(tabs); i++) {
gv = tabs[i].view;
if (!gv->count() && (index = _trackGraphs->indexOf(gv)) >= 0)
_trackGraphs->removeTab(index);
}
for (int i = 0; i < (int)ARRAY_SIZE(tabs); i++) {
gv = tabs[i].view;
if (gv->count() && _trackGraphs->indexOf(gv) < 0)
_trackGraphs->insertTab(i, gv, tabs[i].label);
}
if (_trackGraphs->count()) {
if (_showGraphsAction->isChecked())
_trackGraphs->setHidden(false);
_showGraphsAction->setEnabled(true);
} else {
_trackGraphs->setHidden(true);
_showGraphsAction->setEnabled(false);
}
}
void GUI::updateTrackView()
{
_track->setHidden(!(_track->trackCount() + _track->waypointCount()));
}
void GUI::setMetricUnits()
{
_track->setUnits(Metric);
_elevationGraph->setUnits(Metric);
_speedGraph->setUnits(Metric);
_heartRateGraph->setUnits(Metric);
updateStatusBarInfo();
}
@ -759,6 +978,7 @@ void GUI::setImperialUnits()
_track->setUnits(Imperial);
_elevationGraph->setUnits(Imperial);
_speedGraph->setUnits(Imperial);
_heartRateGraph->setUnits(Imperial);
updateStatusBarInfo();
}
@ -768,7 +988,7 @@ void GUI::next()
if (file.isNull())
return;
closeFile();
closeFiles();
openFile(file);
}
@ -778,7 +998,7 @@ void GUI::prev()
if (file.isNull())
return;
closeFile();
closeFiles();
openFile(file);
}
@ -788,7 +1008,7 @@ void GUI::last()
if (file.isNull())
return;
closeFile();
closeFiles();
openFile(file);
}
@ -798,7 +1018,7 @@ void GUI::first()
if (file.isNull())
return;
closeFile();
closeFiles();
openFile(file);
}
@ -819,11 +1039,129 @@ void GUI::keyPressEvent(QKeyEvent *event)
case LAST_KEY:
file = _browser->last();
break;
case Qt::Key_Escape:
if (_fullscreenAction->isChecked()) {
_fullscreenAction->setChecked(false);
showFullscreen(false);
}
break;
}
if (!file.isNull()) {
if (!(event->modifiers() & MODIFIER))
closeFile();
closeFiles();
openFile(file);
}
}
void GUI::closeEvent(QCloseEvent *event)
{
writeSettings();
event->accept();
}
void GUI::writeSettings()
{
QSettings settings(APP_NAME, APP_NAME);
settings.beginGroup(WINDOW_SETTINGS_GROUP);
settings.setValue(WINDOW_SIZE_SETTING, size());
settings.setValue(WINDOW_POS_SETTING, pos());
settings.endGroup();
settings.beginGroup(SETTINGS_SETTINGS_GROUP);
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);
if (_currentMap)
settings.setValue(CURRENT_MAP_SETTING, _currentMap->name());
settings.setValue(SHOW_MAP_SETTING, _showMapAction->isChecked());
settings.endGroup();
settings.beginGroup(POI_SETTINGS_GROUP);
settings.setValue(SHOW_POI_SETTING, _showPOIAction->isChecked());
settings.remove(DISABLED_POI_FILE_SETTINGS_PREFIX);
settings.beginWriteArray(DISABLED_POI_FILE_SETTINGS_PREFIX);
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.endArray();
settings.endGroup();
}
void GUI::readSettings()
{
QSettings settings(APP_NAME, APP_NAME);
settings.beginGroup(WINDOW_SETTINGS_GROUP);
resize(settings.value(WINDOW_SIZE_SETTING, QSize(600, 800)).toSize());
move(settings.value(WINDOW_POS_SETTING, QPoint(10, 10)).toPoint());
settings.endGroup();
settings.beginGroup(SETTINGS_SETTINGS_GROUP);
if (settings.value(UNITS_SETTING, Metric).toInt() == Imperial) {
setImperialUnits();
_imperialUnitsAction->setChecked(true);
} else
_metricUnitsAction->setChecked(true);
if (settings.value(SHOW_TOOLBARS_SETTING, true).toBool() == false) {
showToolbars(false);
_showToolbarsAction->setChecked(false);
} 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);
if (settings.value(SHOW_MAP_SETTING, true).toBool() == true)
_showMapAction->setChecked(true);
if (_maps.count()) {
int index = mapIndex(settings.value(CURRENT_MAP_SETTING).toString());
_mapActions.at(index)->setChecked(true);
_currentMap = _maps.at(index);
if (_showMapAction->isChecked())
_track->setMap(_currentMap);
} else
_currentMap = 0;
settings.endGroup();
settings.beginGroup(POI_SETTINGS_GROUP);
if (settings.value(SHOW_POI_SETTING, false).toBool() == true)
_showPOIAction->setChecked(true);
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(
DISABLED_POI_FILE_SETTING).toString());
if (index >= 0) {
_poi.enableFile(_poi.files().at(index), false);
_poiFilesActions.at(index)->setChecked(false);
}
}
settings.endArray();
settings.endGroup();
}
int GUI::mapIndex(const QString &name)
{
for (int i = 0; i < _maps.count(); i++)
if (_maps.at(i)->name() == name)
return i;
return 0;
}

View File

@ -14,8 +14,10 @@ class QAction;
class QLabel;
class QSignalMapper;
class FileBrowser;
class GraphView;
class ElevationGraph;
class SpeedGraph;
class HeartRateGraph;
class TrackView;
class Map;
@ -35,7 +37,7 @@ private slots:
void saveFile();
void saveAs();
void openFile();
void closeFile();
void closeAll();
void reloadFile();
void openPOIFile();
void closePOIFiles();
@ -43,6 +45,10 @@ private slots:
void showMap(bool checked);
void showGraphs(bool checked);
void showToolbars(bool checked);
void showFullscreen(bool checked);
void clearMapCache();
void nextMap();
void prevMap();
void mapChanged(int);
void graphChanged(int);
@ -56,8 +62,12 @@ private slots:
void setMetricUnits();
void setImperialUnits();
void sliderPositionChanged(qreal pos);
private:
void loadFiles();
void loadMaps();
void loadPOIs();
void closeFiles();
QAction *createPOIFileAction(int index);
void createPOIFilesActions();
@ -69,12 +79,21 @@ private:
void createTrackView();
void createTrackGraphs();
bool openPOIFile(const QString &fileName);
bool loadFile(const QString &fileName);
void saveFile(const QString &fileName);
void updateStatusBarInfo();
void updateWindowTitle();
void updateNavigationActions();
void updateGraphTabs();
void updateTrackView();
void keyPressEvent(QKeyEvent * event);
void closeEvent(QCloseEvent *event);
int mapIndex(const QString &name);
void readSettings();
void writeSettings();
QMenu *_fileMenu;
QMenu *_helpMenu;
@ -105,6 +124,8 @@ private:
QAction *_closePOIAction;
QAction *_showPOIAction;
QAction *_showMapAction;
QAction *_fullscreenAction;
QAction *_clearMapCacheAction;
QAction *_showGraphsAction;
QAction *_showToolbarsAction;
QAction *_nextAction;
@ -113,6 +134,8 @@ private:
QAction *_firstAction;
QAction *_metricUnitsAction;
QAction *_imperialUnitsAction;
QAction *_nextMapAction;
QAction *_prevMapAction;
QList<QAction*> _mapActions;
QList<QAction*> _poiFilesActions;
@ -124,6 +147,7 @@ private:
ElevationGraph *_elevationGraph;
SpeedGraph *_speedGraph;
HeartRateGraph *_heartRateGraph;
TrackView *_track;
POI _poi;
@ -137,6 +161,11 @@ private:
qreal _distance;
qreal _time;
int _trackCount;
qreal _sliderPos;
int _frameStyle;
bool _showGraphs;
};
#endif // GUI_H

99
src/heartrategraph.cpp Normal file
View File

@ -0,0 +1,99 @@
#include "gpx.h"
#include "heartrategraph.h"
HeartRateGraph::HeartRateGraph(QWidget *parent) : GraphView(parent)
{
_units = Metric;
GraphView::setYUnits(tr("1/min"));
setXLabel(tr("Distance"));
setYLabel(tr("Heart rate"));
setSliderPrecision(0);
}
void HeartRateGraph::addInfo()
{
GraphView::addInfo(tr("Average"), QString::number(avg() * yScale(), 'f', 0)
+ UNIT_SPACE + yUnits());
GraphView::addInfo(tr("Maximum"), QString::number(max() * yScale(), 'f', 0)
+ UNIT_SPACE + yUnits());
redraw();
}
void HeartRateGraph::loadGPX(const GPX &gpx)
{
for (int i = 0; i < gpx.trackCount(); i++) {
QVector<QPointF> data;
qreal sum = 0, w = 0;
gpx.track(i).heartRateGraph(data);
if (data.count() < 2) {
skipColor();
continue;
}
for (int j = 1; j < data.size(); j++) {
sum += data.at(j).y() * (data.at(j).x() - data.at(j-1).x());
w += data.at(j).x() - data.at(j-1).x();
}
_avg.append(QPointF(gpx.track(i).distance(), sum/w));
loadData(data);
}
setXUnits();
addInfo();
}
qreal HeartRateGraph::avg() const
{
qreal sum = 0, w = 0;
QList<QPointF>::const_iterator it;
for (it = _avg.begin(); it != _avg.end(); it++) {
sum += it->y() * it->x();
w += it->x();
}
return (sum / w);
}
void HeartRateGraph::clear()
{
_avg.clear();
GraphView::clear();
}
void HeartRateGraph::setXUnits()
{
if (_units == Metric) {
if (bounds().width() < KMINM) {
GraphView::setXUnits(tr("m"));
setXScale(1);
} else {
GraphView::setXUnits(tr("km"));
setXScale(M2KM);
}
} else {
if (bounds().width() < MIINM) {
GraphView::setXUnits(tr("ft"));
setXScale(M2FT);
} else {
GraphView::setXUnits(tr("mi"));
setXScale(M2MI);
}
}
}
void HeartRateGraph::setUnits(enum Units units)
{
_units = units;
setXUnits();
clearInfo();
addInfo();
}

31
src/heartrategraph.h Normal file
View File

@ -0,0 +1,31 @@
#ifndef HEARTRATEGRAPH_H
#define HEARTRATEGRAPH_H
#include "graphview.h"
#include "units.h"
class GPX;
class HeartRateGraph : public GraphView
{
Q_OBJECT
public:
HeartRateGraph(QWidget *parent = 0);
void loadGPX(const GPX &gpx);
void clear();
void setUnits(enum Units units);
qreal avg() const;
qreal max() const {return bounds().bottom();}
private:
void setXUnits();
void addInfo();
QList<QPointF> _avg;
enum Units _units;
};
#endif // HEARTRATEGRAPH_H

View File

@ -1,8 +1,6 @@
#ifndef ICONS_H
#define ICONS_H
#include <QtGlobal>
#define APP_ICON ":/icons/gpxsee.png"
#define OPEN_FILE_ICON ":/icons/document-open.png"
#define SAVE_FILE_ICON ":/icons/document-save.png"
@ -16,11 +14,6 @@
#define PREV_FILE_ICON ":/icons/arrow-left.png"
#define LAST_FILE_ICON ":/icons/arrow-right-double.png"
#define FIRST_FILE_ICON ":/icons/arrow-left-double.png"
#if QT_VERSION < QT_VERSION_CHECK(5, 0, 0)
#define QT_ICON ":/trolltech/qmessagebox/images/qtlogo-64.png"
#else
#define QT_ICON ":/qt-project.org/qmessagebox/images/qtlogo-64.png"
#endif
#define FULLSCREEN_ICON ":/icons/view-fullscreen.png"
#endif /* ICONS_H */

View File

@ -65,18 +65,19 @@ void InfoItem::insert(const QString &key, const QString &value)
KV kv(key, value);
int i;
prepareGeometryChange();
if ((i = _list.indexOf(kv)) < 0)
_list.append(kv);
else
_list[i] = kv;
updateBoundingRect();
prepareGeometryChange();
}
void InfoItem::clear()
{
prepareGeometryChange();
_list.clear();
updateBoundingRect();
prepareGeometryChange();
}

View File

@ -1,10 +1,30 @@
#ifndef KEYS_H
#define KEYS_H
#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
#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 QUIT_SHORTCUT QKeySequence::Quit
#define OPEN_SHORTCUT QKeySequence::Open
#define SAVE_SHORTCUT QKeySequence::Save
#define SAVE_AS_SHORTCUT QKeySequence::SaveAs
#define CLOSE_SHORTCUT QKeySequence::Close
#define RELOAD_SHORTCUT QKeySequence::Refresh
#define 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)
#ifdef Q_OS_MAC
#define FULLSCREEN_SHORTCUT QKeySequence(Qt::META + Qt::CTRL + Qt::Key_F)
#else // Q_OS_MAC
#define FULLSCREEN_SHORTCUT QKeySequence(Qt::Key_F11)
#endif // Q_OS_MAC
#endif // KEYS_H

View File

@ -1,28 +1,9 @@
#include <QApplication>
#include <QTranslator>
#include <QLocale>
#include "gui.h"
#include "icons.h"
#include "app.h"
int main(int argc, char *argv[])
{
QApplication app(argc, argv);
App app(argc, argv);
app.run();
QString locale = QLocale::system().name();
QTranslator translator;
translator.load(QString(":/lang/gpxsee_") + locale);
app.installTranslator(&translator);
#ifdef Q_OS_MAC
app.setAttribute(Qt::AA_DontShowIconsInMenus);
#endif // Q_OS_MAC
GUI gui;
gui.setWindowIcon(QIcon(QPixmap(APP_ICON)));
gui.show();
for (int i = 1; i < argc; i++)
gui.openFile(argv[i]);
return app.exec();
return 0;
}

View File

@ -15,8 +15,8 @@ Map::Map(QObject *parent, const QString &name, const QString &url)
connect(&Downloader::instance(), SIGNAL(finished()), this,
SLOT(emitLoaded()));
QString path = QString(TILES_DIR"/") + _name;
if (!QDir::home().mkpath(path))
QString path = TILES_DIR + QString("/") + _name;
if (!QDir().mkpath(path))
fprintf(stderr, "Error creating tiles dir: %s\n", qPrintable(path));
}
@ -31,9 +31,8 @@ void Map::loadTiles(QList<Tile> &list)
for (int i = 0; i < list.size(); ++i) {
Tile &t = list[i];
QString file = QString("%1/" TILES_DIR "/%2/%3-%4-%5")
.arg(QDir::homePath()).arg(_name).arg(t.zoom()).arg(t.xy().rx())
.arg(t.xy().ry());
QString file = TILES_DIR + QString("/%1/%2-%3-%4")
.arg(_name).arg(t.zoom()).arg(t.xy().rx()).arg(t.xy().ry());
QFileInfo fi(file);
if (fi.exists()) {
@ -55,3 +54,13 @@ void Map::loadTiles(QList<Tile> &list)
if (!dl.empty())
Downloader::instance().get(dl);
}
void Map::clearCache()
{
QString path = TILES_DIR + QString("/") + _name;
QDir dir = QDir(path);
QStringList list = dir.entryList();
for (int i = 0; i < list.count(); i++)
dir.remove(list.at(i));
}

View File

@ -24,15 +24,16 @@ class Map : public QObject
{
Q_OBJECT
signals:
void loaded();
public:
Map(QObject *parent = 0, const QString &name = QString(),
const QString &url = QString());
const QString &name() const {return _name;}
void loadTiles(QList<Tile> &list);
void clearCache();
signals:
void loaded();
private slots:
void emitLoaded();

View File

@ -5,16 +5,18 @@ void Parser::handleExtensionData(QStringRef element, const QString &value)
{
if (element == "speed")
_track->last().speed = value.toDouble();
else if (element == "hr" || element == "heartrate")
_track->last().heartRate = value.toDouble();
}
void Parser::handleTrekPointData(QStringRef element, const QString &value)
{
if (element == "ele")
_track->last().elevation = value.toLatin1().toDouble();
if (element == "time")
else if (element == "time")
_track->last().timestamp = QDateTime::fromString(value.toLatin1(),
Qt::ISODate);
if (element == "geoidheight")
else if (element == "geoidheight")
_track->last().geoidheight = value.toLatin1().toDouble();
}
@ -37,11 +39,24 @@ void Parser::handleWayPointAttributes(const QXmlStreamAttributes &attr)
attr.value("lat").toLatin1().toDouble()));
}
void Parser::tpExtension()
{
while (_reader.readNextStartElement()) {
if (_reader.name() == "hr")
handleExtensionData(_reader.name(), _reader.readElementText());
else
_reader.skipCurrentElement();
}
}
void Parser::extensions()
{
while (_reader.readNextStartElement()) {
if (_reader.name() == "speed")
if (_reader.name() == "speed" || _reader.name() == "hr"
|| _reader.name() == "heartrate")
handleExtensionData(_reader.name(), _reader.readElementText());
else if (_reader.name() == "TrackPointExtension")
tpExtension();
else
_reader.skipCurrentElement();
}

View File

@ -22,6 +22,7 @@ private:
void gpx();
void track();
void trackPoints();
void tpExtension();
void extensions();
void trackPointData();
void wayPointData();

15
src/range.cpp Normal file
View File

@ -0,0 +1,15 @@
#include "range.h"
void RangeF::resize(qreal size)
{
qreal adj = (size/2 - this->size()/2);
_min -= adj;
_max += adj;
}
QDebug operator<<(QDebug dbg, const RangeF &range)
{
dbg.nospace() << "RangeF(" << range.min() << ", " << range.max() << ")";
return dbg.maybeSpace();
}

25
src/range.h Normal file
View File

@ -0,0 +1,25 @@
#ifndef RANGE_H
#define RANGE_H
#include <QtGlobal>
#include <QDebug>
class RangeF
{
public:
RangeF() {_min = 0; _max = 0;}
RangeF(qreal min, qreal max) {_min = min, _max = max;}
qreal min() const {return _min;}
qreal max() const {return _max;}
qreal size() const {return (_max - _min);}
void resize(qreal size);
private:
qreal _min, _max;
};
QDebug operator<<(QDebug dbg, const RangeF &range);
#endif // RANGE_H

View File

@ -114,24 +114,24 @@ void ScaleItem::computeScale()
void ScaleItem::setLatitude(qreal lat)
{
prepareGeometryChange();
_lat = lat;
computeScale();
updateBoundingRect();
prepareGeometryChange();
}
void ScaleItem::setZoom(int z)
{
prepareGeometryChange();
_zoom = z;
computeScale();
updateBoundingRect();
prepareGeometryChange();
}
void ScaleItem::setUnits(enum Units units)
{
prepareGeometryChange();
_units = units;
computeScale();
updateBoundingRect();
prepareGeometryChange();
}

22
src/settings.h Normal file
View File

@ -0,0 +1,22 @@
#ifndef SETTINGS_H
#define SETTINGS_H
#define WINDOW_SETTINGS_GROUP "Window"
#define WINDOW_SIZE_SETTING "size"
#define WINDOW_POS_SETTING "pos"
#define SETTINGS_SETTINGS_GROUP "Settings"
#define UNITS_SETTING "units"
#define SHOW_TOOLBARS_SETTING "toolbar"
#define SHOW_GRAPHS_SETTING "graphs"
#define MAP_SETTINGS_GROUP "Map"
#define CURRENT_MAP_SETTING "map"
#define SHOW_MAP_SETTING "show"
#define POI_SETTINGS_GROUP "POI"
#define SHOW_POI_SETTING "show"
#define DISABLED_POI_FILE_SETTINGS_PREFIX "disabled"
#define DISABLED_POI_FILE_SETTING "file"
#endif // SETTINGS_H

View File

@ -7,6 +7,7 @@
SliderInfoItem::SliderInfoItem(QGraphicsItem *parent) : QGraphicsItem(parent)
{
_side = Right;
}
void SliderInfoItem::updateBoundingRect()
@ -16,7 +17,10 @@ void SliderInfoItem::updateBoundingRect()
font.setFamily(FONT_FAMILY);
QFontMetrics fm(font);
_boundingRect = QRectF(-SIZE/2, 0, fm.width(_text) + SIZE, fm.height());
_boundingRect = (_side == Right)
? QRectF(-SIZE/2, 0, fm.width(_text) + SIZE, fm.height())
: QRectF(-(fm.width(_text) + SIZE/2), 0, fm.width(_text) + SIZE,
fm.height());
}
void SliderInfoItem::paint(QPainter *painter, const QStyleOptionGraphicsItem
@ -31,7 +35,11 @@ void SliderInfoItem::paint(QPainter *painter, const QStyleOptionGraphicsItem
painter->setFont(font);
painter->setPen(Qt::red);
painter->drawText(SIZE, fm.height() - fm.descent(), _text);
if (_side == Right)
painter->drawText(SIZE, fm.height() - fm.descent(), _text);
else
painter->drawText(-(fm.width(_text) + SIZE/2),
fm.height() - fm.descent(), _text);
painter->drawLine(QPointF(-SIZE/2, 0), QPointF(SIZE/2, 0));
//painter->drawRect(boundingRect());
@ -39,7 +47,17 @@ void SliderInfoItem::paint(QPainter *painter, const QStyleOptionGraphicsItem
void SliderInfoItem::setText(const QString &text)
{
prepareGeometryChange();
_text = text;
updateBoundingRect();
prepareGeometryChange();
}
void SliderInfoItem::setSide(Side side)
{
if (side == _side)
return;
prepareGeometryChange();
_side = side;
updateBoundingRect();
}

View File

@ -6,6 +6,8 @@
class SliderInfoItem : public QGraphicsItem
{
public:
enum Side {Left, Right};
SliderInfoItem(QGraphicsItem *parent = 0);
QRectF boundingRect() const {return _boundingRect;}
@ -13,10 +15,12 @@ public:
QWidget *widget);
void setText(const QString &text);
void setSide(Side side);
private:
void updateBoundingRect();
Side _side;
QString _text;
QRectF _boundingRect;
};

View File

@ -41,7 +41,7 @@ QVariant SliderItem::itemChange(GraphicsItemChange change, const QVariant &value
}
}
if (change == ItemPositionHasChanged)
if (change == ItemPositionHasChanged && scene())
emit positionChanged(value.toPointF());
return QGraphicsItem::itemChange(change, value);
@ -52,3 +52,9 @@ void SliderItem::clear()
_area = QRectF();
setPos(QPointF());
}
void SliderItem::setArea(const QRectF &area)
{
prepareGeometryChange();
_area = area;
}

View File

@ -15,7 +15,7 @@ public:
QWidget *widget);
const QRectF &area() const {return _area;}
void setArea(const QRectF &area) {_area = area;}
void setArea(const QRectF &area);
void clear();

View File

@ -5,45 +5,44 @@
SpeedGraph::SpeedGraph(QWidget *parent) : GraphView(parent)
{
_max = 0;
_units = Metric;
GraphView::setXLabel(tr("Distance"));
GraphView::setYLabel(tr("Speed"));
GraphView::setXUnits(tr("km"));
GraphView::setYUnits(tr("km/h"));
GraphView::setXScale(M2KM);
GraphView::setYScale(MS2KMH);
GraphView::setPrecision(1);
setYUnits();
setXLabel(tr("Distance"));
setYLabel(tr("Speed"));
setSliderPrecision(1);
}
void SpeedGraph::addInfo()
{
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);
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();
}
void SpeedGraph::loadGPX(const GPX &gpx)
{
for (int i = 0; i < gpx.trackCount(); i++) {
QVector<QPointF> data;
qreal max = 0;
gpx.track(i).speedGraph(data);
if (data.isEmpty())
if (data.count() < 2) {
skipColor();
continue;
}
_avg.append(QPointF(gpx.track(i).distance(), gpx.track(i).distance()
/ gpx.track(i).time()));
for (int i = 0; i < data.size(); i++)
max = qMax(max, data.at(i).y());
_max = qMax(_max, max);
addInfo();
loadData(data);
}
setXUnits();
addInfo();
}
qreal SpeedGraph::avg() const
@ -61,28 +60,49 @@ qreal SpeedGraph::avg() const
void SpeedGraph::clear()
{
_max = 0;
_avg.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) {
GraphView::setYUnits(tr("km/h"));
setYScale(MS2KMH);
} else {
GraphView::setYUnits(tr("mi/h"));
setYScale(MS2MIH);
}
}
void SpeedGraph::setUnits(enum Units units)
{
if (units == Metric) {
GraphView::setXUnits(tr("km"));
GraphView::setYUnits(tr("km/h"));
GraphView::setXScale(M2KM);
GraphView::setYScale(MS2KMH);
} else {
GraphView::setXUnits(tr("mi"));
GraphView::setYUnits(tr("mi/h"));
GraphView::setXScale(M2MI);
GraphView::setYScale(MS2MIH);
}
_units = units;
setXUnits();
setYUnits();
clearInfo();
addInfo();
redraw();
}

View File

@ -19,13 +19,15 @@ public:
void setUnits(enum Units units);
qreal avg() const;
qreal max() const {return _max;}
qreal max() const {return bounds().bottom();}
private:
void setXUnits();
void setYUnits();
void addInfo();
qreal _max;
QList<QPointF> _avg;
enum Units _units;
};
#endif // SPEEDGRAPH_H

View File

@ -1,11 +1,12 @@
#include <cmath>
#include "ll.h"
#include "track.h"
#define WINDOW_EF 3
#define WINDOW_SE 11
#define WINDOW_SF 11
#define WINDOW_SF 7
#define WINDOW_HE 11
#define WINDOW_HF 3
static bool lt(const QPointF &p1, const QPointF &p2)
{
@ -78,6 +79,18 @@ static QVector<QPointF> filter(const QVector<QPointF> &v, int window)
return ret;
}
Track::Track(const QVector<Trackpoint> &data) : _data(data)
{
_distance = 0;
for (int i = 1; i < _data.count(); i++)
_dd.append(llDistance(_data.at(i).coordinates,
_data.at(i-1).coordinates));
for (int i = 0; i < _dd.size(); i++)
_distance += _dd.at(i);
}
void Track::elevationGraph(QVector<QPointF> &graph) const
{
qreal dist = 0;
@ -86,12 +99,12 @@ void Track::elevationGraph(QVector<QPointF> &graph) const
if (!_data.size())
return;
if (isnan(_data.at(0).elevation))
if (!_data.at(0).hasElevation())
return;
raw.append(QPointF(0, _data.at(0).elevation));
raw.append(QPointF(0, _data.at(0).elevation - _data.at(0).geoidheight));
for (int i = 1; i < _data.size(); i++) {
dist += llDistance(_data.at(i).coordinates, _data.at(i-1).coordinates);
if (isnan(_data.at(i).elevation))
dist += _dd.at(i-1);
if (!_data.at(i).hasElevation())
return;
raw.append(QPointF(dist, _data.at(i).elevation
- _data.at(i).geoidheight));
@ -110,11 +123,11 @@ void Track::speedGraph(QVector<QPointF> &graph) const
raw.append(QPointF(0, 0));
for (int i = 1; i < _data.size(); i++) {
ds = llDistance(_data.at(i).coordinates, _data.at(i-1).coordinates);
ds = _dd.at(i-1);
dt = _data.at(i-1).timestamp.msecsTo(_data.at(i).timestamp) / 1000.0;
dist += ds;
if (isnan(_data.at(i).speed)) {
if (!_data.at(i).hasSpeed()) {
if (dt == 0)
continue;
v = ds / dt;
@ -127,22 +140,33 @@ void Track::speedGraph(QVector<QPointF> &graph) const
graph = filter(eliminate(raw, WINDOW_SE), WINDOW_SF);
}
void Track::heartRateGraph(QVector<QPointF> &graph) const
{
qreal dist = 0;
QVector<QPointF> raw;
if (!_data.size())
return;
if (!_data.at(0).hasHeartRate())
return;
raw.append(QPointF(0, _data.at(0).heartRate));
for (int i = 1; i < _data.count(); i++) {
if (!_data.at(i).hasHeartRate())
return;
dist += _dd.at(i-1);
raw.append(QPointF(dist, _data.at(i).heartRate));
}
graph = filter(eliminate(raw, WINDOW_HE), WINDOW_HF);
}
void Track::track(QVector<QPointF> &track) const
{
for (int i = 0; i < _data.size(); i++)
track.append(_data.at(i).coordinates);
}
qreal Track::distance() const
{
qreal dist = 0;
for (int i = 1; i < _data.size(); i++)
dist += llDistance(_data.at(i).coordinates, _data.at(i-1).coordinates);
return dist;
}
qreal Track::time() const
{
if (_data.size() < 2)

View File

@ -8,17 +8,20 @@
class Track
{
public:
Track(const QVector<Trackpoint> &data) : _data(data) {}
Track(const QVector<Trackpoint> &data);
void elevationGraph(QVector<QPointF> &graph) const;
void speedGraph(QVector<QPointF> &graph) const;
void heartRateGraph(QVector<QPointF> &graph) const;
void track(QVector<QPointF> &track) const;
qreal distance() const;
qreal distance() const {return _distance;}
qreal time() const;
QDateTime date() const;
private:
const QVector<Trackpoint> &_data;
QVector<qreal> _dd;
qreal _distance;
};
#endif // TRACK_H

View File

@ -5,15 +5,26 @@
#include <QDateTime>
#include <cmath>
struct Trackpoint
class Trackpoint
{
public:
Trackpoint() {
elevation = NAN;
geoidheight = 0;
speed = NAN;
heartRate = NAN;
}
bool hasElevation() const {return !std::isnan(elevation);}
bool hasSpeed() const {return !std::isnan(speed);}
bool hasHeartRate() const {return !std::isnan(heartRate);}
QPointF coordinates;
QDateTime timestamp;
qreal elevation;
qreal geoidheight;
qreal speed;
Trackpoint() {elevation = NAN; geoidheight = 0; speed = NAN;}
qreal heartRate;
};
#endif // TRACKPOINT_H

View File

@ -34,7 +34,8 @@ TrackView::TrackView(QWidget *parent)
_zoom = ZOOM_MAX;
_scale = mapScale(_zoom);
_map = 0;
_maxLen = 0;
_maxPath = 0;
_maxDistance = 0;
}
TrackView::~TrackView()
@ -49,8 +50,10 @@ void TrackView::addTrack(const QVector<QPointF> &track)
MarkerItem *mi;
if (track.size() < 2)
if (track.size() < 2) {
_palette.color();
return;
}
_tracks.append(track);
@ -61,8 +64,7 @@ void TrackView::addTrack(const QVector<QPointF> &track)
path.lineTo(ll2mercator(QPointF(p.x(), -p.y())));
}
_maxLen = qMax(path.length(), _maxLen);
_maxPath = qMax(path.length(), _maxPath);
pi = new QGraphicsPathItem(path);
_paths.append(pi);
@ -108,6 +110,7 @@ void TrackView::loadGPX(const GPX &gpx)
QVector<QPointF> track;
gpx.track(i).track(track);
addTrack(track);
_maxDistance = qMax(gpx.track(i).distance(), _maxDistance);
}
addWaypoints(gpx.waypoints());
@ -305,6 +308,13 @@ void TrackView::redraw()
resetCachedContent();
}
void TrackView::rescale()
{
_zoom = qMin(scale2zoom(trackScale()), scale2zoom(waypointScale()));
rescale(mapScale(_zoom));
_mapScale->setZoom(_zoom);
}
void TrackView::wheelEvent(QWheelEvent *event)
{
if (_paths.isEmpty() && _locations.isEmpty())
@ -403,7 +413,8 @@ void TrackView::clear()
_tracks.clear();
_waypoints.clear();
_maxLen = 0;
_maxPath = 0;
_maxDistance = 0;
_zoom = ZOOM_MAX;
_scale = mapScale(_zoom);
@ -412,11 +423,17 @@ void TrackView::clear()
void TrackView::movePositionMarker(qreal val)
{
qreal mp = val / _maxDistance;
for (int i = 0; i < _paths.size(); i++) {
qreal f = _maxLen / _paths.at(i)->path().length();
QPointF pos = _paths.at(i)->path().pointAtPercent(qMin(val * f,
1.0));
_markers.at(i)->setPos(pos);
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);
}
}
}
@ -457,6 +474,8 @@ void TrackView::resizeEvent(QResizeEvent *e)
if (_paths.isEmpty() && _locations.isEmpty())
return;
rescale();
QRectF br = trackBoundingRect() | waypointBoundingRect();
QRectF ba = br.adjusted(-TILE_SIZE, -TILE_SIZE, TILE_SIZE, TILE_SIZE);

View File

@ -37,10 +37,11 @@ public:
void plot(QPainter *painter, const QRectF &target);
enum QPrinter::Orientation orientation() const;
int trackCount() const {return _paths.count();}
int waypointCount() const {return _locations.count();}
public slots:
void movePositionMarker(qreal val);
private slots:
void redraw();
private:
@ -54,6 +55,7 @@ private:
qreal waypointScale() const;
qreal mapScale(int zoom) const;
void rescale(qreal scale);
void rescale();
void showMarkers(bool show);
void setTrackLineWidth(qreal width);
@ -75,7 +77,7 @@ private:
ScaleItem *_mapScale;
Palette _palette;
qreal _maxLen;
qreal _maxPath, _maxDistance;
qreal _scale;
int _zoom;

View File

@ -13,8 +13,9 @@ enum Units {
#define MS2MIH 2.236936290000 // m/s -> mi/h
#define FT2MI 0.000189393939 // ft -> mi
#define MIINFT 5280 // 1 mi in ft
#define KMINM 1000 // 1 km in m
#define KMINM 1000 // 1 km in m
#define MIINFT 5280 // 1 mi in ft
#define MIINM 1609.344 // 1mi in m
#ifdef Q_OS_WIN32
#define UNIT_SPACE " "