1
0
mirror of https://github.com/tumic0/GPXSee.git synced 2025-07-05 23:22:51 +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. GPX viewer and analyzer.
* User-definable map sources. * 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 multiple tracks in one view.
* Support for POI files. * Support for POI files.
* Export to PDF. * Export to PDF.
* Full-screen mode
* Native GUI for Windows, Mac OS X and Linux. * Native GUI for Windows, Mac OS X and Linux.
![GPXSee - Linux](https://a.fsdn.com/con/app/proj/gpxsee/screenshots/linux.png)
## Build ## Build
### Linux/OS X ### Linux/OS X
```shell ```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 TARGET = GPXSee
VERSION = 2.13
QT += core \ QT += core \
gui \ gui \
network network
@ -33,7 +34,12 @@ HEADERS += src/config.h \
src/graphview.h \ src/graphview.h \
src/trackpoint.h \ src/trackpoint.h \
src/waypointitem.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 \ SOURCES += src/main.cpp \
src/gui.cpp \ src/gui.cpp \
src/gpx.cpp \ src/gpx.cpp \
@ -57,8 +63,22 @@ SOURCES += src/main.cpp \
src/track.cpp \ src/track.cpp \
src/graphview.cpp \ src/graphview.cpp \
src/waypointitem.cpp \ src/waypointitem.cpp \
src/palette.cpp src/palette.cpp \
src/heartrategraph.cpp \
src/range.cpp \
src/app.cpp
RESOURCES += gpxsee.qrc RESOURCES += gpxsee.qrc
TRANSLATIONS = lang/gpxsee_cs.ts TRANSLATIONS = lang/gpxsee_cs.ts
macx:ICON = icons/gpxsee.icns macx {
win32:RC_FILE = gpxsee.rc 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-right.png</file>
<file>icons/arrow-left-double.png</file> <file>icons/arrow-left-double.png</file>
<file>icons/arrow-right-double.png</file> <file>icons/arrow-right-double.png</file>
<file>icons/view-fullscreen.png</file>
<file>lang/gpxsee_cs.qm</file> <file>lang/gpxsee_cs.qm</file>
<file>maps.txt</file>
</qresource> </qresource>
</RCC> </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> <translation>Výška</translation>
</message> </message>
<message> <message>
<location filename="../src/elevationgraph.cpp" line="16"/> <location filename="../src/elevationgraph.cpp" line="81"/>
<location filename="../src/elevationgraph.cpp" line="83"/>
<source>km</source> <source>km</source>
<translation>km</translation> <translation>km</translation>
</message> </message>
<message> <message>
<location filename="../src/elevationgraph.cpp" line="17"/> <location filename="../src/elevationgraph.cpp" line="78"/>
<location filename="../src/elevationgraph.cpp" line="84"/> <location filename="../src/elevationgraph.cpp" line="98"/>
<source>m</source> <source>m</source>
<translation>m</translation> <translation>m</translation>
</message> </message>
<message> <message>
<location filename="../src/elevationgraph.cpp" line="23"/> <location filename="../src/elevationgraph.cpp" line="22"/>
<source>Ascent</source> <source>Ascent</source>
<translation>Stoupání</translation> <translation>Stoupání</translation>
</message> </message>
<message> <message>
<location filename="../src/elevationgraph.cpp" line="25"/> <location filename="../src/elevationgraph.cpp" line="24"/>
<source>Descent</source> <source>Descent</source>
<translation>Klesání</translation> <translation>Klesání</translation>
</message> </message>
<message> <message>
<location filename="../src/elevationgraph.cpp" line="29"/> <location filename="../src/elevationgraph.cpp" line="28"/>
<source>Minimum</source> <source>Minimum</source>
<translation>Minimum</translation> <translation>Minimum</translation>
</message> </message>
<message> <message>
<location filename="../src/elevationgraph.cpp" line="88"/> <location filename="../src/elevationgraph.cpp" line="89"/>
<source>mi</source> <source>mi</source>
<translation>mi</translation> <translation>mi</translation>
</message> </message>
<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> <source>ft</source>
<translation>ft</translation> <translation>ft</translation>
</message> </message>
<message> <message>
<location filename="../src/elevationgraph.cpp" line="27"/> <location filename="../src/elevationgraph.cpp" line="26"/>
<source>Maximum</source> <source>Maximum</source>
<translation>Maximum</translation> <translation>Maximum</translation>
</message> </message>
@ -59,352 +59,429 @@
<context> <context>
<name>GUI</name> <name>GUI</name>
<message> <message>
<location filename="../src/gui.cpp" line="161"/> <location filename="../src/gui.cpp" line="448"/>
<source>About Qt</source>
<translation>O Qt</translation>
</message>
<message>
<location filename="../src/gui.cpp" line="380"/>
<source>GPXSee is distributed under the terms of the GNU General Public License version 3. For more info about GPXSee visit the project homepage at </source> <source>GPXSee is distributed under the terms of the GNU General Public License version 3. For more info about GPXSee visit the project homepage at </source>
<translation>Program GPXSee je distribuován pod podmínkami licence GNU General Public License verze 3. Pro více informací navštivte stránky programu na adrese </translation> <translation>Program GPXSee je distribuován pod podmínkami licence GNU General Public License verze 3. Pro více informací navštivte stránky programu na adrese </translation>
</message> </message>
<message> <message>
<location filename="../src/gui.cpp" line="441"/> <location filename="../src/gui.cpp" line="512"/>
<source>Open file</source> <source>Open file</source>
<translation>Otevřít soubor</translation> <translation>Otevřít soubor</translation>
</message> </message>
<message> <message>
<location filename="../src/gui.cpp" line="175"/> <location filename="../src/gui.cpp" line="208"/>
<source>Save as</source> <source>Save as</source>
<translation>Uložit jako</translation> <translation>Uložit jako</translation>
</message> </message>
<message> <message>
<location filename="../src/gui.cpp" line="501"/> <location filename="../src/gui.cpp" line="583"/>
<source>Open POI file</source> <source>Open POI file</source>
<translation>Otevřít POI soubor</translation> <translation>Otevřít POI soubor</translation>
</message> </message>
<message> <message>
<location filename="../src/gui.cpp" line="166"/> <location filename="../src/gui.cpp" line="197"/>
<source>Open</source> <source>Open</source>
<translation>Otevřít</translation> <translation>Otevřít</translation>
</message> </message>
<message> <message>
<location filename="../src/gui.cpp" line="149"/> <location filename="../src/gui.cpp" line="181"/>
<source>Quit</source> <source>Quit</source>
<translation>Ukončit</translation> <translation>Ukončit</translation>
</message> </message>
<message> <message>
<location filename="../src/gui.cpp" line="156"/> <location filename="../src/gui.cpp" line="189"/>
<location filename="../src/gui.cpp" line="396"/> <location filename="../src/gui.cpp" line="464"/>
<location filename="../src/gui.cpp" line="397"/> <location filename="../src/gui.cpp" line="465"/>
<source>Keyboard controls</source> <source>Keyboard controls</source>
<translation>Ovládací klávesy</translation> <translation>Ovládací klávesy</translation>
</message> </message>
<message> <message>
<location filename="../src/gui.cpp" line="170"/> <location filename="../src/gui.cpp" line="202"/>
<source>Save</source> <source>Save</source>
<translation>Uložit</translation> <translation>Uložit</translation>
</message> </message>
<message> <message>
<location filename="../src/gui.cpp" line="180"/> <location filename="../src/gui.cpp" line="214"/>
<source>Close</source> <source>Close</source>
<translation>Zavřít</translation> <translation>Zavřít</translation>
</message> </message>
<message> <message>
<location filename="../src/gui.cpp" line="185"/> <location filename="../src/gui.cpp" line="220"/>
<source>Reload</source> <source>Reload</source>
<translation>Znovu načíst</translation> <translation>Znovu načíst</translation>
</message> </message>
<message> <message>
<location filename="../src/gui.cpp" line="317"/> <location filename="../src/gui.cpp" line="379"/>
<source>Show</source> <source>Show</source>
<translation>Zobrazit</translation> <translation>Zobrazit</translation>
</message> </message>
<message> <message>
<location filename="../src/gui.cpp" line="262"/> <location filename="../src/gui.cpp" line="321"/>
<location filename="../src/gui.cpp" line="308"/> <location filename="../src/gui.cpp" line="370"/>
<source>File</source> <source>File</source>
<translation>Soubor</translation> <translation>Soubor</translation>
</message> </message>
<message> <message>
<location filename="../src/gui.cpp" line="154"/> <location filename="../src/gui.cpp" line="187"/>
<location filename="../src/gui.cpp" line="414"/> <location filename="../src/gui.cpp" line="487"/>
<location filename="../src/gui.cpp" line="415"/> <location filename="../src/gui.cpp" line="488"/>
<source>Data sources</source> <source>Data sources</source>
<translation>Zdroje dat</translation> <translation>Zdroje dat</translation>
</message> </message>
<message> <message>
<location filename="../src/gui.cpp" line="192"/> <location filename="../src/gui.cpp" line="228"/>
<source>Load POI file</source> <source>Load POI file</source>
<translation>Nahrát POI soubor</translation> <translation>Nahrát POI soubor</translation>
</message> </message>
<message> <message>
<location filename="../src/gui.cpp" line="195"/> <location filename="../src/gui.cpp" line="231"/>
<source>Close POI files</source> <source>Close POI files</source>
<translation>Zavřit soubory POI</translation> <translation>Zavřit POI soubory</translation>
</message> </message>
<message> <message>
<location filename="../src/gui.cpp" line="198"/> <location filename="../src/gui.cpp" line="234"/>
<source>Show POIs</source> <source>Show POIs</source>
<translation>Zobrazit POI</translation> <translation>Zobrazit POI</translation>
</message> </message>
<message> <message>
<location filename="../src/gui.cpp" line="205"/> <location filename="../src/gui.cpp" line="242"/>
<source>Show map</source> <source>Show map</source>
<translation>Zobrazit mapu</translation> <translation>Zobrazit mapu</translation>
</message> </message>
<message> <message>
<location filename="../src/gui.cpp" line="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> <source>Show graphs</source>
<translation>Zobrazovat grafy</translation> <translation>Zobrazovat grafy</translation>
</message> </message>
<message> <message>
<location filename="../src/gui.cpp" line="224"/> <location filename="../src/gui.cpp" line="276"/>
<source>Show toolbars</source> <source>Show toolbars</source>
<translation>Zobrazovat nástrojové lišty</translation> <translation>Zobrazovat nástrojové lišty</translation>
</message> </message>
<message> <message>
<location filename="../src/gui.cpp" line="231"/> <location filename="../src/gui.cpp" line="283"/>
<source>Metric</source> <source>Metric</source>
<translation>Metrické</translation> <translation>Metrické</translation>
</message> </message>
<message> <message>
<location filename="../src/gui.cpp" line="237"/> <location filename="../src/gui.cpp" line="289"/>
<source>Imperial</source> <source>Imperial</source>
<translation>Imperiální</translation> <translation>Imperiální</translation>
</message> </message>
<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> <source>Next</source>
<translation>Následující</translation> <translation>Následující</translation>
</message> </message>
<message> <message>
<location filename="../src/gui.cpp" line="247"/> <location filename="../src/gui.cpp" line="306"/>
<source>Previous</source> <source>Previous</source>
<translation>Předchozí</translation> <translation>Předchozí</translation>
</message> </message>
<message> <message>
<location filename="../src/gui.cpp" line="251"/> <location filename="../src/gui.cpp" line="310"/>
<source>Last</source> <source>Last</source>
<translation>Poslední</translation> <translation>Poslední</translation>
</message> </message>
<message> <message>
<location filename="../src/gui.cpp" line="254"/> <location filename="../src/gui.cpp" line="313"/>
<source>First</source> <source>First</source>
<translation>První</translation> <translation>První</translation>
</message> </message>
<message> <message>
<location filename="../src/gui.cpp" line="276"/> <location filename="../src/gui.cpp" line="335"/>
<source>Map</source> <source>Map</source>
<translation>Mapa</translation> <translation>Mapa</translation>
</message> </message>
<message> <message>
<location filename="../src/gui.cpp" line="281"/> <location filename="../src/gui.cpp" line="342"/>
<source>POI</source> <source>POI</source>
<translation>POI</translation> <translation>POI</translation>
</message> </message>
<message> <message>
<location filename="../src/gui.cpp" line="282"/> <location filename="../src/gui.cpp" line="343"/>
<source>POI files</source> <source>POI files</source>
<translation>POI soubory</translation> <translation>POI soubory</translation>
</message> </message>
<message> <message>
<location filename="../src/gui.cpp" line="290"/> <location filename="../src/gui.cpp" line="351"/>
<source>Settings</source> <source>Settings</source>
<translation>Nastavení</translation> <translation>Nastavení</translation>
</message> </message>
<message> <message>
<location filename="../src/gui.cpp" line="291"/> <location filename="../src/gui.cpp" line="352"/>
<source>Units</source> <source>Units</source>
<translation>Jednotky</translation> <translation>Jednotky</translation>
</message> </message>
<message> <message>
<location filename="../src/gui.cpp" line="298"/> <location filename="../src/gui.cpp" line="361"/>
<source>Help</source> <source>Help</source>
<translation>Nápověda</translation> <translation>Nápověda</translation>
</message> </message>
<message> <message>
<location filename="../src/gui.cpp" line="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> <source>Elevation</source>
<translation>Výška</translation> <translation>Výška</translation>
</message> </message>
<message> <message>
<location filename="../src/gui.cpp" line="349"/> <location filename="../src/gui.cpp" line="923"/>
<source>Speed</source> <source>Speed</source>
<translation>Rychlost</translation> <translation>Rychlost</translation>
</message> </message>
<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> <source>Next file</source>
<translation>Následující soubor</translation> <translation>Následující soubor</translation>
</message> </message>
<message> <message>
<location filename="../src/gui.cpp" line="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> <source>Previous file</source>
<translation>Předchozí soubor</translation> <translation>Předchozí soubor</translation>
</message> </message>
<message> <message>
<location filename="../src/gui.cpp" line="402"/> <location filename="../src/gui.cpp" line="470"/>
<source>First file</source> <source>First file</source>
<translation>První soubor</translation> <translation>První soubor</translation>
</message> </message>
<message> <message>
<location filename="../src/gui.cpp" line="403"/> <location filename="../src/gui.cpp" line="471"/>
<source>Last file</source> <source>Last file</source>
<translation>Poslední soubor</translation> <translation>Poslední soubor</translation>
</message> </message>
<message> <message>
<location filename="../src/gui.cpp" line="404"/> <location filename="../src/gui.cpp" line="472"/>
<source>Append modifier</source> <source>Append modifier</source>
<translation>Modifikátor nahradit/přidat</translation> <translation>Modifikátor nahradit/přidat</translation>
</message> </message>
<message> <message>
<location filename="../src/gui.cpp" line="418"/> <location filename="../src/gui.cpp" line="491"/>
<source>Map (tiles) source URLs are read on program startup from the following file:</source> <source>Map (tiles) source URLs are read on program startup from the following file:</source>
<translation>URL mapových zdrojů (dlaždic) jsou načteny při startu programu z následujícího souboru:</translation> <translation>URL mapových zdrojů (dlaždic) jsou načteny při startu programu z následujícího souboru:</translation>
</message> </message>
<message> <message>
<location filename="../src/gui.cpp" line="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> <source>The file format is one map entry per line, consisting of the map name and tiles URL delimited by a TAB character. The tile X and Y coordinates are replaced with $x and $y in the URL and the zoom level is replaced with $z. An example map file could look like:</source>
<translation>Formát souboru je jeden mapový záznam na řádku, kde mapový záznam sestává ze jména mapy a URL dlaždic navzájem oddělených tabulátorem. Souřadnice dlaždice jsou v URL nahrazeny řetězci $x a $y, úroven přiblížení (zoom) pak řetězcem $z. Příklad:</translation> <translation>Formát souboru je jeden mapový záznam na řádku, kde mapový záznam sestává ze jména mapy a URL dlaždic navzájem oddělených tabulátorem. Souřadnice dlaždice jsou v URL nahrazeny řetězci $x a $y, úroven přiblížení (zoom) pak řetězcem $z. Příklad:</translation>
</message> </message>
<message> <message>
<location filename="../src/gui.cpp" line="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> <source>To make GPXSee load a POI file automatically on startup, add the file to the following directory:</source>
<translation>POI soubory, které se mají automaticky nahrát při startu programu jsou načítány z následujícího adresáře:</translation> <translation>POI soubory, které se mají automaticky nahrát při startu programu jsou načítány z následujícího adresáře:</translation>
</message> </message>
<message> <message>
<location filename="../src/gui.cpp" line="442"/> <location filename="../src/gui.cpp" line="513"/>
<source>GPX files (*.gpx);;All files (*)</source> <source>GPX files (*.gpx);;All files (*)</source>
<translation>soubory GPX (*.gpx);;všechny soubory (*)</translation> <translation>soubory GPX (*.gpx);;všechny soubory (*)</translation>
</message> </message>
<message> <message>
<location filename="../src/gui.cpp" line="492"/> <location filename="../src/gui.cpp" line="574"/>
<location filename="../src/gui.cpp" line="509"/> <location filename="../src/gui.cpp" line="600"/>
<source>Line: %1</source> <source>Line: %1</source>
<translation>Řádka: %1</translation> <translation>Řádka: %1</translation>
</message> </message>
<message> <message>
<location filename="../src/gui.cpp" line="502"/> <location filename="../src/gui.cpp" line="584"/>
<source>GPX files (*.gpx);;CSV files (*.csv);;All files (*)</source> <source>GPX files (*.gpx);;CSV files (*.csv);;All files (*)</source>
<translation>soubory GPX (*.gpx);;soubory CSV (*.csv);;všechny soubory (*)</translation> <translation>soubory GPX (*.gpx);;soubory CSV (*.csv);;všechny soubory (*)</translation>
</message> </message>
<message> <message>
<location filename="../src/gui.cpp" line="577"/> <location filename="../src/gui.cpp" line="665"/>
<location filename="../src/gui.cpp" line="697"/> <location filename="../src/gui.cpp" line="837"/>
<source>mi</source> <source>mi</source>
<translation>mi</translation> <translation>mi</translation>
</message> </message>
<message> <message>
<location filename="../src/gui.cpp" line="580"/> <location filename="../src/gui.cpp" line="668"/>
<location filename="../src/gui.cpp" line="582"/> <location filename="../src/gui.cpp" line="670"/>
<location filename="../src/gui.cpp" line="584"/> <location filename="../src/gui.cpp" line="672"/>
<location filename="../src/gui.cpp" line="586"/> <location filename="../src/gui.cpp" line="674"/>
<location filename="../src/gui.cpp" line="834"/>
<source>ft</source> <source>ft</source>
<translation>ft</translation> <translation>ft</translation>
</message> </message>
<message> <message>
<location filename="../src/gui.cpp" line="583"/> <location filename="../src/gui.cpp" line="671"/>
<location filename="../src/gui.cpp" line="595"/> <location filename="../src/gui.cpp" line="683"/>
<source>Maximum</source> <source>Maximum</source>
<translation>Maximum</translation> <translation>Maximum</translation>
</message> </message>
<message> <message>
<location filename="../src/gui.cpp" line="585"/> <location filename="../src/gui.cpp" line="673"/>
<location filename="../src/gui.cpp" line="597"/> <location filename="../src/gui.cpp" line="685"/>
<source>Minimum</source> <source>Minimum</source>
<translation>Minimum</translation> <translation>Minimum</translation>
</message> </message>
<message> <message>
<location filename="../src/gui.cpp" line="159"/> <location filename="../src/gui.cpp" line="192"/>
<location filename="../src/gui.cpp" line="376"/> <location filename="../src/gui.cpp" line="442"/>
<source>About GPXSee</source> <source>About GPXSee</source>
<translation>O aplikaci GPXSee</translation> <translation>O aplikaci GPXSee</translation>
</message> </message>
<message> <message>
<location filename="../src/gui.cpp" line="324"/> <location filename="../src/gui.cpp" line="386"/>
<source>Navigation</source> <source>Navigation</source>
<translation>Navigace</translation> <translation>Navigace</translation>
</message> </message>
<message> <message>
<location filename="../src/gui.cpp" line="378"/> <location filename="../src/gui.cpp" line="490"/>
<source>GPX viewer and analyzer</source>
<translation>Prohlížeč a analyzátor GPX</translation>
</message>
<message>
<location filename="../src/gui.cpp" line="417"/>
<source>Map sources</source> <source>Map sources</source>
<translation>Mapové zdroje</translation> <translation>Mapové zdroje</translation>
</message> </message>
<message> <message>
<location filename="../src/gui.cpp" line="429"/> <location filename="../src/gui.cpp" line="501"/>
<source>POIs</source> <source>POIs</source>
<translation>POI body</translation> <translation>POI body</translation>
</message> </message>
<message> <message>
<location filename="../src/gui.cpp" line="576"/> <location filename="../src/gui.cpp" line="664"/>
<location filename="../src/gui.cpp" line="588"/> <location filename="../src/gui.cpp" line="676"/>
<source>Distance</source> <source>Distance</source>
<translation>Vzdálenost</translation> <translation>Vzdálenost</translation>
</message> </message>
<message> <message>
<location filename="../src/gui.cpp" line="578"/> <location filename="../src/gui.cpp" line="666"/>
<location filename="../src/gui.cpp" line="590"/> <location filename="../src/gui.cpp" line="678"/>
<source>Time</source> <source>Time</source>
<translation>Čas</translation> <translation>Čas</translation>
</message> </message>
<message> <message>
<location filename="../src/gui.cpp" line="579"/> <location filename="../src/gui.cpp" line="667"/>
<location filename="../src/gui.cpp" line="591"/> <location filename="../src/gui.cpp" line="679"/>
<source>Ascent</source> <source>Ascent</source>
<translation>Stoupání</translation> <translation>Stoupání</translation>
</message> </message>
<message> <message>
<location filename="../src/gui.cpp" line="592"/> <location filename="../src/gui.cpp" line="680"/>
<location filename="../src/gui.cpp" line="594"/> <location filename="../src/gui.cpp" line="682"/>
<location filename="../src/gui.cpp" line="596"/> <location filename="../src/gui.cpp" line="684"/>
<location filename="../src/gui.cpp" line="598"/> <location filename="../src/gui.cpp" line="686"/>
<location filename="../src/gui.cpp" line="841"/>
<source>m</source> <source>m</source>
<translation>m</translation> <translation>m</translation>
</message> </message>
<message> <message>
<location filename="../src/gui.cpp" line="581"/> <location filename="../src/gui.cpp" line="669"/>
<location filename="../src/gui.cpp" line="593"/> <location filename="../src/gui.cpp" line="681"/>
<source>Descent</source> <source>Descent</source>
<translation>Klesání</translation> <translation>Klesání</translation>
</message> </message>
<message> <message>
<location filename="../src/gui.cpp" line="693"/> <location filename="../src/gui.cpp" line="829"/>
<source>%1 tracks</source> <source>%1 tracks</source>
<translation>Počet tras: %1</translation> <translation>Počet tras: %1</translation>
</message> </message>
<message> <message>
<location filename="../src/gui.cpp" line="589"/> <location filename="../src/gui.cpp" line="677"/>
<location filename="../src/gui.cpp" line="700"/> <location filename="../src/gui.cpp" line="844"/>
<source>km</source> <source>km</source>
<translation>km</translation> <translation>km</translation>
</message> </message>
<message> <message>
<location filename="../src/gui.cpp" line="494"/> <location filename="../src/gui.cpp" line="576"/>
<location filename="../src/gui.cpp" line="510"/> <location filename="../src/gui.cpp" line="601"/>
<source>Error</source> <source>Error</source>
<translation>Chyba</translation> <translation>Chyba</translation>
</message> </message>
<message> <message>
<location filename="../src/gui.cpp" line="489"/> <location filename="../src/gui.cpp" line="571"/>
<source>Error loading GPX file: <source>Error loading GPX file:
%1</source> %1</source>
<translation>Soubor GPX nelze otevřít: <translation>Soubor GPX nelze otevřít:
%1</translation> %1</translation>
</message> </message>
<message> <message>
<location filename="../src/gui.cpp" line="506"/> <location filename="../src/gui.cpp" line="597"/>
<source>Error loading POI file: <source>Error loading POI file:
%1</source> %1</source>
<translation>Soubor POI nelze otevřít: <translation>Soubor POI nelze otevřít:
%1</translation> %1</translation>
</message> </message>
</context> </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> <context>
<name>QObject</name> <name>QObject</name>
<message> <message>
@ -431,44 +508,52 @@
<context> <context>
<name>SpeedGraph</name> <name>SpeedGraph</name>
<message> <message>
<location filename="../src/speedgraph.cpp" line="10"/> <location filename="../src/speedgraph.cpp" line="11"/>
<source>Distance</source> <source>Distance</source>
<translation>Vzdálenost</translation> <translation>Vzdálenost</translation>
</message> </message>
<message> <message>
<location filename="../src/speedgraph.cpp" line="11"/> <location filename="../src/speedgraph.cpp" line="12"/>
<source>Speed</source> <source>Speed</source>
<translation>Rychlost</translation> <translation>Rychlost</translation>
</message> </message>
<message> <message>
<location filename="../src/speedgraph.cpp" line="12"/> <location filename="../src/speedgraph.cpp" line="72"/>
<location filename="../src/speedgraph.cpp" line="73"/> <source>m</source>
<translation>m</translation>
</message>
<message>
<location filename="../src/speedgraph.cpp" line="75"/>
<source>km</source> <source>km</source>
<translation></translation> <translation></translation>
</message> </message>
<message> <message>
<location filename="../src/speedgraph.cpp" line="13"/> <location filename="../src/speedgraph.cpp" line="80"/>
<location filename="../src/speedgraph.cpp" line="74"/> <source>ft</source>
<translation>ft</translation>
</message>
<message>
<location filename="../src/speedgraph.cpp" line="92"/>
<source>km/h</source> <source>km/h</source>
<translation>km/h</translation> <translation>km/h</translation>
</message> </message>
<message> <message>
<location filename="../src/speedgraph.cpp" line="21"/> <location filename="../src/speedgraph.cpp" line="19"/>
<source>Average</source> <source>Average</source>
<translation>Průměr</translation> <translation>Průměr</translation>
</message> </message>
<message> <message>
<location filename="../src/speedgraph.cpp" line="23"/> <location filename="../src/speedgraph.cpp" line="21"/>
<source>Maximum</source> <source>Maximum</source>
<translation>Maximum</translation> <translation>Maximum</translation>
</message> </message>
<message> <message>
<location filename="../src/speedgraph.cpp" line="78"/> <location filename="../src/speedgraph.cpp" line="83"/>
<source>mi</source> <source>mi</source>
<translation>mi</translation> <translation>mi</translation>
</message> </message>
<message> <message>
<location filename="../src/speedgraph.cpp" line="79"/> <location filename="../src/speedgraph.cpp" line="95"/>
<source>mi/h</source> <source>mi/h</source>
<translation>mi/h</translation> <translation>mi/h</translation>
</message> </message>

View File

@ -19,6 +19,8 @@ InstallDirRegKey HKLM "Software\GPXSee" "Install_Dir"
; Registry key for uninstaller ; 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 ; Start menu page configuration
!define MUI_STARTMENUPAGE_REGISTRY_ROOT "HKLM" !define MUI_STARTMENUPAGE_REGISTRY_ROOT "HKLM"
@ -55,8 +57,9 @@ Section "GPXSee (required)" SEC_APP
; Set output path to the installation directory. ; Set output path to the installation directory.
SetOutPath $INSTDIR SetOutPath $INSTDIR
; Put file there ; Put the files there
File "gpxsee.exe" File "gpxsee.exe"
File "maps.txt"
; Write the installation path into the registry ; Write the installation path into the registry
WriteRegStr HKLM SOFTWARE\GPXSee "Install_Dir" "$INSTDIR" WriteRegStr HKLM SOFTWARE\GPXSee "Install_Dir" "$INSTDIR"
@ -64,7 +67,7 @@ Section "GPXSee (required)" SEC_APP
; Write the uninstall keys for Windows ; Write the uninstall keys for Windows
WriteRegStr HKLM "${REGENTRY}" "DisplayName" "GPXSee" WriteRegStr HKLM "${REGENTRY}" "DisplayName" "GPXSee"
WriteRegStr HKLM "${REGENTRY}" "Publisher" "Martin Tuma" 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"' WriteRegStr HKLM "${REGENTRY}" "UninstallString" '"$INSTDIR\uninstall.exe"'
WriteRegDWORD HKLM "${REGENTRY}" "NoModify" 1 WriteRegDWORD HKLM "${REGENTRY}" "NoModify" 1
WriteRegDWORD HKLM "${REGENTRY}" "NoRepair" 1 WriteRegDWORD HKLM "${REGENTRY}" "NoRepair" 1
@ -78,6 +81,13 @@ Section "GPXSee (required)" SEC_APP
CreateShortCut "$SMPROGRAMS\$StartMenuFolder\GPXSee.lnk" "$INSTDIR\gpxsee.exe" CreateShortCut "$SMPROGRAMS\$StartMenuFolder\GPXSee.lnk" "$INSTDIR\gpxsee.exe"
!insertmacro MUI_STARTMENU_WRITE_END !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 SectionEnd
Section "QT libs" SEC_QT Section "QT libs" SEC_QT
@ -133,6 +143,11 @@ Section "Uninstall"
Delete "$SMPROGRAMS\$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 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; _size = 0;
} }
void AxisItem::setRange(const QPointF &range) void AxisItem::setRange(const RangeF &range)
{ {
prepareGeometryChange();
_range = range; _range = range;
updateBoundingRect(); updateBoundingRect();
prepareGeometryChange();
} }
void AxisItem::setSize(qreal size) void AxisItem::setSize(qreal size)
{ {
prepareGeometryChange();
_size = size; _size = size;
updateBoundingRect(); updateBoundingRect();
prepareGeometryChange();
} }
void AxisItem::setLabel(const QString& label) void AxisItem::setLabel(const QString& label)
{ {
prepareGeometryChange();
_label = label; _label = label;
updateBoundingRect(); updateBoundingRect();
prepareGeometryChange();
} }
void AxisItem::updateBoundingRect() void AxisItem::updateBoundingRect()
@ -67,7 +67,7 @@ void AxisItem::updateBoundingRect()
struct Label l; 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)); es = fm.tightBoundingRect(QString::number(l.max));
ss = fm.tightBoundingRect(QString::number(l.min)); ss = fm.tightBoundingRect(QString::number(l.min));
ls = fm.tightBoundingRect(_label); ls = fm.tightBoundingRect(_label);
@ -77,9 +77,20 @@ void AxisItem::updateBoundingRect()
_size + es.width()/2 + ss.width()/2, _size + es.width()/2 + ss.width()/2,
ls.height() + es.height() - fm.descent() + TICK + 2*PADDING); ls.height() + es.height() - fm.descent() + TICK + 2*PADDING);
} else { } 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() + 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); + 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); QFontMetrics fm(font);
QRect ts, ls; QRect ts, ls;
struct Label l; struct Label l;
qreal range = _range.y() - _range.x(); qreal range = _range.size();
qreal val; qreal val;
@ -106,15 +117,15 @@ void AxisItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *option,
if (_type == X) { if (_type == X) {
painter->drawLine(0, 0, _size, 0); 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++) { for (int i = 0; i < ((l.max - l.min) / l.d) + 1; i++) {
val = l.min + i * l.d; val = l.min + i * l.d;
QString str = QString::number(val); QString str = QString::number(val);
painter->drawLine((_size/range) * (val - _range.x()), TICK/2, painter->drawLine((_size/range) * (val - _range.min()), TICK/2,
(_size/range) * (val - _range.x()), -TICK/2); (_size/range) * (val - _range.min()), -TICK/2);
ts = fm.tightBoundingRect(str); 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); - (ts.width()/2), ts.height() + TICK/2 + PADDING, str);
} }
@ -123,21 +134,23 @@ void AxisItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *option,
} else { } else {
painter->drawLine(0, 0, 0, -_size); 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++) { for (int i = 0; i < ((l.max - l.min) / l.d) + 1; i++) {
val = l.min + i * l.d; val = l.min + i * l.d;
QString str = QString::number(val); QString str = QString::number(val);
painter->drawLine(TICK/2, -((_size/range) * (val - _range.x())), painter->drawLine(TICK/2, -((_size/range) * (val - _range.min())),
-TICK/2, -((_size/range) * (val - _range.x()))); -TICK/2, -((_size/range) * (val - _range.min())));
ts = fm.tightBoundingRect(str); ts = fm.tightBoundingRect(str);
mtw = qMax(ts.width(), mtw);
painter->drawText(-(ts.width() + PADDING + TICK/2), -((_size/range) 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->rotate(-90);
painter->drawText(_size/2 - ls.width()/2, -(ts.width() painter->drawText(_size/2 - ls.width()/2, -(mtw + 2*PADDING + TICK/2),
+ 2*PADDING + TICK/2), _label); _label);
painter->rotate(90); painter->rotate(90);
} }
@ -156,7 +169,7 @@ QSizeF AxisItem::margin() const
struct Label l; 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)); es = fm.tightBoundingRect(QString::number(l.max));
ss = fm.tightBoundingRect(QString::number(l.min)); ss = fm.tightBoundingRect(QString::number(l.min));
ls = fm.tightBoundingRect(_label); ls = fm.tightBoundingRect(_label);
@ -165,7 +178,18 @@ QSizeF AxisItem::margin() const
return QSizeF(es.width()/2, return QSizeF(es.width()/2,
ls.height() + es.height() - fm.descent() + TICK/2 + 2*PADDING); ls.height() + es.height() - fm.descent() + TICK/2 + 2*PADDING);
} else { } 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()); + TICK/2, es.height()/2 + fm.descent());
} }
} }

View File

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

View File

@ -1,20 +1,36 @@
#ifndef CONFIG_H #ifndef CONFIG_H
#define CONFIG_H #define CONFIG_H
#include <QtGlobal>
#include <QDir>
#include <QApplication>
#include <QString>
#define APP_NAME "GPXSee" #define APP_NAME "GPXSee"
#define APP_HOMEPAGE "http://tumic.wz.cz/gpxsee" #define APP_HOMEPAGE "http://tumic.wz.cz/gpxsee"
#define APP_VERSION "2.9"
#define FONT_FAMILY "Arial" #define FONT_FAMILY "Arial"
#define FONT_SIZE 12 #define FONT_SIZE 12
#define MAP_FILE QString("maps.txt")
#define POI_DIR QString("POI")
#if defined(Q_OS_WIN32) #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 #else
#define APP_DIR ".gpxsee" #define USER_DIR QDir::homePath() + QString("/.gpxsee")
#define GLOBAL_DIR QString("/usr/share/gpxsee")
#endif #endif
#define POI_DIR APP_DIR"/POI"
#define TILES_DIR APP_DIR"/tiles" #define USER_MAP_FILE USER_DIR + QString("/") + MAP_FILE
#define MAP_LIST_FILE APP_DIR"/maps.txt" #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 */ #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" #define PLATFORM_STR "Unknown"
#endif #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() Downloader::Downloader()
{ {

View File

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

View File

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

View File

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

View File

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

View File

@ -14,20 +14,31 @@
#include <QActionGroup> #include <QActionGroup>
#include <QAction> #include <QAction>
#include <QLabel> #include <QLabel>
#include <QSettings>
#include "config.h" #include "config.h"
#include "icons.h" #include "icons.h"
#include "keys.h" #include "keys.h"
#include "settings.h"
#include "gpx.h" #include "gpx.h"
#include "map.h" #include "map.h"
#include "maplist.h" #include "maplist.h"
#include "elevationgraph.h" #include "elevationgraph.h"
#include "speedgraph.h" #include "speedgraph.h"
#include "heartrategraph.h"
#include "trackview.h" #include "trackview.h"
#include "infoitem.h" #include "infoitem.h"
#include "filebrowser.h" #include "filebrowser.h"
#include "cpuarch.h"
#include "gui.h" #include "gui.h"
#define ARRAY_SIZE(a) (sizeof(a)/sizeof(a[0]))
struct GraphTab {
GraphView *view;
QString label;
};
static QString timeSpan(qreal time) static QString timeSpan(qreal time)
{ {
unsigned h, m, s; unsigned h, m, s;
@ -43,7 +54,8 @@ static QString timeSpan(qreal time)
GUI::GUI(QWidget *parent) : QMainWindow(parent) GUI::GUI(QWidget *parent) : QMainWindow(parent)
{ {
loadFiles(); loadMaps();
loadPOIs();
createActions(); createActions();
createMenus(); createMenus();
@ -52,10 +64,12 @@ GUI::GUI(QWidget *parent) : QMainWindow(parent)
createTrackGraphs(); createTrackGraphs();
createStatusBar(); createStatusBar();
connect(_elevationGraph, SIGNAL(sliderPositionChanged(qreal)), _track, connect(_elevationGraph, SIGNAL(sliderPositionChanged(qreal)), this,
SLOT(movePositionMarker(qreal))); SLOT(sliderPositionChanged(qreal)));
connect(_speedGraph, SIGNAL(sliderPositionChanged(qreal)), _track, connect(_speedGraph, SIGNAL(sliderPositionChanged(qreal)), this,
SLOT(movePositionMarker(qreal))); SLOT(sliderPositionChanged(qreal)));
connect(_heartRateGraph, SIGNAL(sliderPositionChanged(qreal)), this,
SLOT(sliderPositionChanged(qreal)));
_browser = new FileBrowser(this); _browser = new FileBrowser(this);
_browser->setFilter(QStringList("*.gpx")); _browser->setFilter(QStringList("*.gpx"));
@ -63,11 +77,16 @@ GUI::GUI(QWidget *parent) : QMainWindow(parent)
QVBoxLayout *layout = new QVBoxLayout; QVBoxLayout *layout = new QVBoxLayout;
layout->addWidget(_track); layout->addWidget(_track);
layout->addWidget(_trackGraphs); layout->addWidget(_trackGraphs);
layout->setContentsMargins(0, 0, 0, 0);
#ifdef Q_OS_WIN32
layout->setSpacing(0);
#endif // Q_OS_WIN32
QWidget *widget = new QWidget; QWidget *widget = new QWidget;
widget->setLayout(layout); widget->setLayout(layout);
setCentralWidget(widget); setCentralWidget(widget);
setWindowIcon(QIcon(QPixmap(APP_ICON)));
setWindowTitle(APP_NAME); setWindowTitle(APP_NAME);
setUnifiedTitleAndToolBarOnMac(true); setUnifiedTitleAndToolBarOnMac(true);
@ -75,19 +94,33 @@ GUI::GUI(QWidget *parent) : QMainWindow(parent)
_time = 0; _time = 0;
_trackCount = 0; _trackCount = 0;
resize(600, 800); _sliderPos = 0;
updateGraphTabs();
updateTrackView();
readSettings();
} }
void GUI::loadFiles() void GUI::loadMaps()
{ {
// Maps if (QFile::exists(USER_MAP_FILE))
_maps = MapList::load(this, QString("%1/" MAP_LIST_FILE) _maps = MapList::load(this, USER_MAP_FILE);
.arg(QDir::homePath())); else
_maps += MapList::load(this, ":/maps.txt"); _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) for (int i = 0; i < list.size(); ++i)
_poi.loadFile(list.at(i).absoluteFilePath()); _poi.loadFile(list.at(i).absoluteFilePath());
} }
@ -111,9 +144,6 @@ void GUI::createMapActions()
} }
connect(sm, SIGNAL(mapped(int)), this, SLOT(mapChanged(int))); connect(sm, SIGNAL(mapped(int)), this, SLOT(mapChanged(int)));
_mapActions.at(0)->setChecked(true);
_currentMap = _maps.at(0);
} }
void GUI::createPOIFilesActions() void GUI::createPOIFilesActions()
@ -131,7 +161,6 @@ QAction *GUI::createPOIFileAction(int index)
QAction *a = new QAction(QFileInfo(_poi.files().at(index)).fileName(), QAction *a = new QAction(QFileInfo(_poi.files().at(index)).fileName(),
this); this);
a->setCheckable(true); a->setCheckable(true);
a->setChecked(true);
_poiFilesSM->setMapping(a, index); _poiFilesSM->setMapping(a, index);
connect(a, SIGNAL(triggered()), _poiFilesSM, SLOT(map())); connect(a, SIGNAL(triggered()), _poiFilesSM, SLOT(map()));
@ -153,8 +182,9 @@ void GUI::createActions()
// General actions // General actions
_exitAction = new QAction(QIcon(QPixmap(QUIT_ICON)), tr("Quit"), this); _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())); connect(_exitAction, SIGNAL(triggered()), this, SLOT(close()));
addAction(_exitAction);
// Help & About // Help & About
_dataSourcesAction = new QAction(tr("Data sources"), this); _dataSourcesAction = new QAction(tr("Data sources"), this);
@ -164,34 +194,37 @@ void GUI::createActions()
_aboutAction = new QAction(QIcon(QPixmap(APP_ICON)), _aboutAction = new QAction(QIcon(QPixmap(APP_ICON)),
tr("About GPXSee"), this); tr("About GPXSee"), this);
connect(_aboutAction, SIGNAL(triggered()), this, SLOT(about())); 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 // File related actions
_openFileAction = new QAction(QIcon(QPixmap(OPEN_FILE_ICON)), _openFileAction = new QAction(QIcon(QPixmap(OPEN_FILE_ICON)),
tr("Open"), this); tr("Open"), this);
_openFileAction->setShortcut(QKeySequence::Open); _openFileAction->setShortcut(OPEN_SHORTCUT);
connect(_openFileAction, SIGNAL(triggered()), this, SLOT(openFile())); connect(_openFileAction, SIGNAL(triggered()), this, SLOT(openFile()));
addAction(_openFileAction);
_saveFileAction = new QAction(QIcon(QPixmap(SAVE_FILE_ICON)), _saveFileAction = new QAction(QIcon(QPixmap(SAVE_FILE_ICON)),
tr("Save"), this); tr("Save"), this);
_saveFileAction->setShortcut(QKeySequence::Save); _saveFileAction->setShortcut(SAVE_SHORTCUT);
_saveFileAction->setActionGroup(_fileActionGroup); _saveFileAction->setActionGroup(_fileActionGroup);
connect(_saveFileAction, SIGNAL(triggered()), this, SLOT(saveFile())); connect(_saveFileAction, SIGNAL(triggered()), this, SLOT(saveFile()));
addAction(_saveFileAction);
_saveAsAction = new QAction(QIcon(QPixmap(SAVE_AS_ICON)), _saveAsAction = new QAction(QIcon(QPixmap(SAVE_AS_ICON)),
tr("Save as"), this); tr("Save as"), this);
_saveAsAction->setShortcut(QKeySequence::SaveAs); _saveAsAction->setShortcut(SAVE_AS_SHORTCUT);
_saveAsAction->setActionGroup(_fileActionGroup); _saveAsAction->setActionGroup(_fileActionGroup);
connect(_saveAsAction, SIGNAL(triggered()), this, SLOT(saveAs())); connect(_saveAsAction, SIGNAL(triggered()), this, SLOT(saveAs()));
addAction(_saveAsAction);
_closeFileAction = new QAction(QIcon(QPixmap(CLOSE_FILE_ICON)), _closeFileAction = new QAction(QIcon(QPixmap(CLOSE_FILE_ICON)),
tr("Close"), this); tr("Close"), this);
_closeFileAction->setShortcut(QKeySequence::Close); _closeFileAction->setShortcut(CLOSE_SHORTCUT);
_closeFileAction->setActionGroup(_fileActionGroup); _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)), _reloadFileAction = new QAction(QIcon(QPixmap(RELOAD_FILE_ICON)),
tr("Reload"), this); tr("Reload"), this);
_reloadFileAction->setShortcut(QKeySequence::Refresh); _reloadFileAction->setShortcut(RELOAD_SHORTCUT);
_reloadFileAction->setActionGroup(_fileActionGroup); _reloadFileAction->setActionGroup(_fileActionGroup);
connect(_reloadFileAction, SIGNAL(triggered()), this, SLOT(reloadFile())); connect(_reloadFileAction, SIGNAL(triggered()), this, SLOT(reloadFile()));
addAction(_reloadFileAction);
// POI actions // POI actions
_openPOIAction = new QAction(QIcon(QPixmap(OPEN_FILE_ICON)), _openPOIAction = new QAction(QIcon(QPixmap(OPEN_FILE_ICON)),
@ -203,33 +236,46 @@ void GUI::createActions()
_showPOIAction = new QAction(QIcon(QPixmap(SHOW_POI_ICON)), _showPOIAction = new QAction(QIcon(QPixmap(SHOW_POI_ICON)),
tr("Show POIs"), this); tr("Show POIs"), this);
_showPOIAction->setCheckable(true); _showPOIAction->setCheckable(true);
_showPOIAction->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_P)); _showPOIAction->setShortcut(SHOW_POI_SHORTCUT);
connect(_showPOIAction, SIGNAL(triggered(bool)), this, SLOT(showPOI(bool))); connect(_showPOIAction, SIGNAL(triggered(bool)), this, SLOT(showPOI(bool)));
addAction(_showPOIAction);
createPOIFilesActions(); createPOIFilesActions();
// Map actions // Map actions
_showMapAction = new QAction(QIcon(QPixmap(SHOW_MAP_ICON)), tr("Show map"), _showMapAction = new QAction(QIcon(QPixmap(SHOW_MAP_ICON)), tr("Show map"),
this); this);
_showMapAction->setCheckable(true); _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))); 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); _showMapAction->setEnabled(false);
else { _clearMapCacheAction->setEnabled(false);
} else {
createMapActions(); 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 // Settings actions
_showGraphsAction = new QAction(tr("Show graphs"), this); _showGraphsAction = new QAction(tr("Show graphs"), this);
_showGraphsAction->setCheckable(true); _showGraphsAction->setCheckable(true);
_showGraphsAction->setChecked(true); _showGraphsAction->setShortcut(SHOW_GRAPHS_SHORTCUT);
_showGraphsAction->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_G));
connect(_showGraphsAction, SIGNAL(triggered(bool)), this, connect(_showGraphsAction, SIGNAL(triggered(bool)), this,
SLOT(showGraphs(bool))); SLOT(showGraphs(bool)));
addAction(_showGraphsAction);
_showToolbarsAction = new QAction(tr("Show toolbars"), this); _showToolbarsAction = new QAction(tr("Show toolbars"), this);
_showToolbarsAction->setCheckable(true); _showToolbarsAction->setCheckable(true);
_showToolbarsAction->setChecked(true);
connect(_showToolbarsAction, SIGNAL(triggered(bool)), this, connect(_showToolbarsAction, SIGNAL(triggered(bool)), this,
SLOT(showToolbars(bool))); SLOT(showToolbars(bool)));
QActionGroup *ag = new QActionGroup(this); QActionGroup *ag = new QActionGroup(this);
@ -237,7 +283,6 @@ void GUI::createActions()
_metricUnitsAction = new QAction(tr("Metric"), this); _metricUnitsAction = new QAction(tr("Metric"), this);
_metricUnitsAction->setCheckable(true); _metricUnitsAction->setCheckable(true);
_metricUnitsAction->setActionGroup(ag); _metricUnitsAction->setActionGroup(ag);
_metricUnitsAction->setChecked(true);
connect(_metricUnitsAction, SIGNAL(triggered()), this, connect(_metricUnitsAction, SIGNAL(triggered()), this,
SLOT(setMetricUnits())); SLOT(setMetricUnits()));
_imperialUnitsAction = new QAction(tr("Imperial"), this); _imperialUnitsAction = new QAction(tr("Imperial"), this);
@ -245,6 +290,13 @@ void GUI::createActions()
_imperialUnitsAction->setActionGroup(ag); _imperialUnitsAction->setActionGroup(ag);
connect(_imperialUnitsAction, SIGNAL(triggered()), this, connect(_imperialUnitsAction, SIGNAL(triggered()), this,
SLOT(setImperialUnits())); 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 // Navigation actions
_nextAction = new QAction(QIcon(QPixmap(NEXT_FILE_ICON)), tr("Next"), this); _nextAction = new QAction(QIcon(QPixmap(NEXT_FILE_ICON)), tr("Next"), this);
@ -282,6 +334,8 @@ void GUI::createMenus()
_mapMenu = menuBar()->addMenu(tr("Map")); _mapMenu = menuBar()->addMenu(tr("Map"));
_mapMenu->addActions(_mapActions); _mapMenu->addActions(_mapActions);
_mapMenu->addSeparator(); _mapMenu->addSeparator();
_mapMenu->addAction(_clearMapCacheAction);
_mapMenu->addSeparator();
_mapMenu->addAction(_showMapAction); _mapMenu->addAction(_showMapAction);
_poiMenu = menuBar()->addMenu(tr("POI")); _poiMenu = menuBar()->addMenu(tr("POI"));
@ -300,13 +354,14 @@ void GUI::createMenus()
_settingsMenu->addSeparator(); _settingsMenu->addSeparator();
_settingsMenu->addAction(_showToolbarsAction); _settingsMenu->addAction(_showToolbarsAction);
_settingsMenu->addAction(_showGraphsAction); _settingsMenu->addAction(_showGraphsAction);
_settingsMenu->addSeparator();
_settingsMenu->addAction(_fullscreenAction);
_helpMenu = menuBar()->addMenu(tr("Help")); _helpMenu = menuBar()->addMenu(tr("Help"));
_helpMenu->addAction(_dataSourcesAction); _helpMenu->addAction(_dataSourcesAction);
_helpMenu->addAction(_keysAction); _helpMenu->addAction(_keysAction);
_helpMenu->addSeparator(); _helpMenu->addSeparator();
_helpMenu->addAction(_aboutAction); _helpMenu->addAction(_aboutAction);
_helpMenu->addAction(_aboutQtAction);
} }
void GUI::createToolBars() void GUI::createToolBars()
@ -340,25 +395,30 @@ void GUI::createToolBars()
void GUI::createTrackView() void GUI::createTrackView()
{ {
_track = new TrackView(this); _track = new TrackView(this);
#ifdef Q_OS_WIN32
if (_showMapAction->isChecked()) _track->setFrameShape(QFrame::NoFrame);
_track->setMap(_currentMap); #endif // Q_OS_WIN32
} }
void GUI::createTrackGraphs() void GUI::createTrackGraphs()
{ {
_elevationGraph = new ElevationGraph; _elevationGraph = new ElevationGraph;
_elevationGraph->setFrameShape(QFrame::NoFrame);
_speedGraph = new SpeedGraph; _speedGraph = new SpeedGraph;
_speedGraph->setFrameShape(QFrame::NoFrame);
_heartRateGraph = new HeartRateGraph;
_heartRateGraph->setFrameShape(QFrame::NoFrame);
_trackGraphs = new QTabWidget; _trackGraphs = new QTabWidget;
_trackGraphs->addTab(_elevationGraph, tr("Elevation"));
_trackGraphs->addTab(_speedGraph, tr("Speed"));
connect(_trackGraphs, SIGNAL(currentChanged(int)), this, connect(_trackGraphs, SIGNAL(currentChanged(int)), this,
SLOT(graphChanged(int))); SLOT(graphChanged(int)));
_trackGraphs->setFixedHeight(200); _trackGraphs->setFixedHeight(200);
_trackGraphs->setSizePolicy( _trackGraphs->setSizePolicy(
QSizePolicy(QSizePolicy::Ignored, QSizePolicy::Fixed)); QSizePolicy(QSizePolicy::Ignored, QSizePolicy::Fixed));
#ifdef Q_OS_WIN32
_trackGraphs->setDocumentMode(true);
#endif // Q_OS_WIN32
} }
void GUI::createStatusBar() void GUI::createStatusBar()
@ -373,6 +433,8 @@ void GUI::createStatusBar()
statusBar()->addPermanentWidget(_distanceLabel, 1); statusBar()->addPermanentWidget(_distanceLabel, 1);
statusBar()->addPermanentWidget(_timeLabel, 1); statusBar()->addPermanentWidget(_timeLabel, 1);
statusBar()->setSizeGripEnabled(false); statusBar()->setSizeGripEnabled(false);
updateStatusBarInfo();
} }
void GUI::about() void GUI::about()
@ -380,8 +442,10 @@ void GUI::about()
QMessageBox msgBox(this); QMessageBox msgBox(this);
msgBox.setWindowTitle(tr("About GPXSee")); msgBox.setWindowTitle(tr("About GPXSee"));
msgBox.setText(QString("<h3>") + QString(APP_NAME " " APP_VERSION) msgBox.setText(QString("<h2>") + QString(APP_NAME) + QString("</h2><p>")
+ QString("</h3><p>") + tr("GPX viewer and analyzer") + QString("<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>") msgBox.setInformativeText(QString("<table width=\"300\"><tr><td>")
+ tr("GPXSee is distributed under the terms of the GNU General Public " + tr("GPXSee is distributed under the terms of the GNU General Public "
"License version 3. For more info about GPXSee visit the project " "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>SPACE</i></td></tr><tr><td>") + tr("Previous file")
+ QString("</td><td><i>BACKSPACE</i></td></tr><tr><td>") + QString("</td><td><i>BACKSPACE</i></td></tr><tr><td>")
+ tr("First file") + QString("</td><td><i>HOME</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>" + tr("Last file") + QString("</td><td><i>END</i></td></tr><tr><td>")
"<td></td></tr><tr><td>") + tr("Append modifier") + tr("Append modifier") + QString("</td><td><i>SHIFT</i></td></tr>"
+ QString("</td><td><i>SHIFT</i></td></tr></table></div>")); "<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(); msgBox.exec();
} }
@ -423,8 +492,7 @@ void GUI::dataSources()
QString("<h4>") + tr("Map sources") + QString("</h4><p>") QString("<h4>") + tr("Map sources") + QString("</h4><p>")
+ tr("Map (tiles) source URLs are read on program startup from the " + tr("Map (tiles) source URLs are read on program startup from the "
"following file:") "following file:")
+ QString("</p><p><code>") + QDir::homePath() + QString("</p><p><code>") + USER_MAP_FILE + QString("</code></p><p>")
+ QString("/" MAP_LIST_FILE "</code></p><p>")
+ tr("The file format is one map entry per line, consisting of the map " + 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 " "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 " "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>") + QString("<h4>") + tr("POIs") + QString("</h4><p>")
+ tr("To make GPXSee load a POI file automatically on startup, add " + tr("To make GPXSee load a POI file automatically on startup, add "
"the file to the following directory:") "the file to the following directory:")
+ QString("</p><p><code>") + QDir::homePath() + QString("</p><p><code>") + USER_POI_DIR + QString("</code></p>")
+ QString("/" POI_DIR "</code></p>")
); );
msgBox.exec(); msgBox.exec();
@ -454,21 +521,29 @@ void GUI::openFile()
bool GUI::openFile(const QString &fileName) bool GUI::openFile(const QString &fileName)
{ {
bool ret = true;
if (fileName.isEmpty() || _files.contains(fileName)) if (fileName.isEmpty() || _files.contains(fileName))
return false; return false;
if (loadFile(fileName)) { if (loadFile(fileName)) {
_files.append(fileName); _files.append(fileName);
_browser->setCurrent(fileName); _browser->setCurrent(fileName);
updateStatusBarInfo();
_fileActionGroup->setEnabled(true); _fileActionGroup->setEnabled(true);
_navigationActionGroup->setEnabled(true); _navigationActionGroup->setEnabled(true);
updateNavigationActions();
return true;
} else { } else {
updateNavigationActions(); if (_files.isEmpty())
return false; _fileActionGroup->setEnabled(false);
ret = false;
} }
updateNavigationActions();
updateStatusBarInfo();
updateWindowTitle();
updateGraphTabs();
updateTrackView();
return ret;
} }
bool GUI::loadFile(const QString &fileName) bool GUI::loadFile(const QString &fileName)
@ -478,9 +553,13 @@ bool GUI::loadFile(const QString &fileName)
if (gpx.loadFile(fileName)) { if (gpx.loadFile(fileName)) {
_elevationGraph->loadGPX(gpx); _elevationGraph->loadGPX(gpx);
_speedGraph->loadGPX(gpx); _speedGraph->loadGPX(gpx);
_heartRateGraph->loadGPX(gpx);
updateGraphTabs();
_track->setHidden(false);
_track->loadGPX(gpx); _track->loadGPX(gpx);
if (_showPOIAction->isChecked()) if (_showPOIAction->isChecked())
_track->loadPOI(_poi); _track->loadPOI(_poi);
_track->movePositionMarker(_sliderPos);
for (int i = 0; i < gpx.trackCount(); i++) { for (int i = 0; i < gpx.trackCount(); i++) {
_distance += gpx.track(i).distance(); _distance += gpx.track(i).distance();
@ -504,22 +583,34 @@ bool GUI::loadFile(const QString &fileName)
void GUI::openPOIFile() 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 (*)")); QString(), tr("GPX files (*.gpx);;CSV files (*.csv);;All files (*)"));
QStringList list = files;
for (QStringList::Iterator it = list.begin(); it != list.end(); it++)
openPOIFile(*it);
}
bool GUI::openPOIFile(const QString &fileName)
{
if (fileName.isEmpty())
return false;
if (!fileName.isEmpty()) {
if (!_poi.loadFile(fileName)) { if (!_poi.loadFile(fileName)) {
QString error = tr("Error loading POI file:\n%1") QString error = tr("Error loading POI file:\n%1")
.arg(_poi.errorString()) + QString("\n"); .arg(_poi.errorString()) + QString("\n");
if (_poi.errorLine()) if (_poi.errorLine())
error.append(tr("Line: %1").arg(_poi.errorLine())); error.append(tr("Line: %1").arg(_poi.errorLine()));
QMessageBox::critical(this, tr("Error"), error); QMessageBox::critical(this, tr("Error"), error);
return false;
} else { } else {
_showPOIAction->setChecked(true); _showPOIAction->setChecked(true);
_track->loadPOI(_poi); _track->loadPOI(_poi);
_poiFilesMenu->addAction(createPOIFileAction( _poiFilesMenu->addAction(createPOIFileAction(
_poi.files().indexOf(fileName))); _poi.files().indexOf(fileName)));
}
return true;
} }
} }
@ -599,8 +690,6 @@ void GUI::saveFile(const QString &fileName)
} }
scene.addItem(&info); scene.addItem(&info);
scene.render(&p, QRectF(0, 0, printer.width(), 200)); scene.render(&p, QRectF(0, 0, printer.width(), 200));
p.end();
} }
void GUI::reloadFile() void GUI::reloadFile()
@ -611,6 +700,7 @@ void GUI::reloadFile()
_elevationGraph->clear(); _elevationGraph->clear();
_speedGraph->clear(); _speedGraph->clear();
_heartRateGraph->clear();
_track->clear(); _track->clear();
for (int i = 0; i < _files.size(); i++) { for (int i = 0; i < _files.size(); i++) {
@ -621,26 +711,40 @@ void GUI::reloadFile()
} }
updateStatusBarInfo(); updateStatusBarInfo();
updateWindowTitle();
updateGraphTabs();
updateTrackView();
if (_files.isEmpty()) if (_files.isEmpty())
_fileActionGroup->setEnabled(false); _fileActionGroup->setEnabled(false);
else else
_browser->setCurrent(_files.last()); _browser->setCurrent(_files.last());
} }
void GUI::closeFile() void GUI::closeFiles()
{ {
_distance = 0; _distance = 0;
_time = 0; _time = 0;
_trackCount = 0; _trackCount = 0;
_sliderPos = 0;
_elevationGraph->clear(); _elevationGraph->clear();
_speedGraph->clear(); _speedGraph->clear();
_heartRateGraph->clear();
_track->clear(); _track->clear();
_files.clear(); _files.clear();
}
void GUI::closeAll()
{
closeFiles();
_fileActionGroup->setEnabled(false); _fileActionGroup->setEnabled(false);
updateStatusBarInfo(); updateStatusBarInfo();
updateWindowTitle();
updateGraphTabs();
updateTrackView();
} }
void GUI::showPOI(bool checked) 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() void GUI::updateStatusBarInfo()
{ {
if (_files.count() == 0) { if (_files.count() == 0) {
_fileNameLabel->clear(); _fileNameLabel->setText(tr("No GPX files loaded"));
_distanceLabel->clear(); _distanceLabel->clear();
_timeLabel->clear(); _timeLabel->clear();
return; return;
@ -692,15 +830,33 @@ void GUI::updateStatusBarInfo()
else else
_fileNameLabel->setText(tr("%1 tracks").arg(_trackCount)); _fileNameLabel->setText(tr("%1 tracks").arg(_trackCount));
if (_imperialUnitsAction->isChecked()) 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) _distanceLabel->setText(QString::number(_distance * M2MI, 'f', 1)
+ UNIT_SPACE + tr("mi")); + UNIT_SPACE + tr("mi"));
} else {
if (_distance < KMINM)
_distanceLabel->setText(QString::number(_distance, 'f', 0)
+ UNIT_SPACE + tr("m"));
else else
_distanceLabel->setText(QString::number(_distance * M2KM, 'f', 1) _distanceLabel->setText(QString::number(_distance * M2KM, 'f', 1)
+ UNIT_SPACE + tr("km")); + UNIT_SPACE + tr("km"));
}
_timeLabel->setText(timeSpan(_time)); _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) void GUI::mapChanged(int index)
{ {
_currentMap = _maps.at(index); _currentMap = _maps.at(index);
@ -709,6 +865,24 @@ void GUI::mapChanged(int index)
_track->setMap(_currentMap); _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) void GUI::poiFileChecked(int index)
{ {
_poi.enableFile(_poi.files().at(index), _poi.enableFile(_poi.files().at(index),
@ -719,12 +893,19 @@ void GUI::poiFileChecked(int index)
_track->loadPOI(_poi); _track->loadPOI(_poi);
} }
void GUI::sliderPositionChanged(qreal pos)
{
_sliderPos = pos;
_track->movePositionMarker(_sliderPos);
}
void GUI::graphChanged(int index) void GUI::graphChanged(int index)
{ {
if (_trackGraphs->widget(index) == _elevationGraph) if (index < 0)
_elevationGraph->setSliderPosition(_speedGraph->sliderPosition()); return;
else if (_trackGraphs->widget(index) == _speedGraph)
_speedGraph->setSliderPosition(_elevationGraph->sliderPosition()); GraphView *gv = static_cast<GraphView*>(_trackGraphs->widget(index));
gv->setSliderPosition(_sliderPos);
} }
void GUI::updateNavigationActions() 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() void GUI::setMetricUnits()
{ {
_track->setUnits(Metric); _track->setUnits(Metric);
_elevationGraph->setUnits(Metric); _elevationGraph->setUnits(Metric);
_speedGraph->setUnits(Metric); _speedGraph->setUnits(Metric);
_heartRateGraph->setUnits(Metric);
updateStatusBarInfo(); updateStatusBarInfo();
} }
@ -759,6 +978,7 @@ void GUI::setImperialUnits()
_track->setUnits(Imperial); _track->setUnits(Imperial);
_elevationGraph->setUnits(Imperial); _elevationGraph->setUnits(Imperial);
_speedGraph->setUnits(Imperial); _speedGraph->setUnits(Imperial);
_heartRateGraph->setUnits(Imperial);
updateStatusBarInfo(); updateStatusBarInfo();
} }
@ -768,7 +988,7 @@ void GUI::next()
if (file.isNull()) if (file.isNull())
return; return;
closeFile(); closeFiles();
openFile(file); openFile(file);
} }
@ -778,7 +998,7 @@ void GUI::prev()
if (file.isNull()) if (file.isNull())
return; return;
closeFile(); closeFiles();
openFile(file); openFile(file);
} }
@ -788,7 +1008,7 @@ void GUI::last()
if (file.isNull()) if (file.isNull())
return; return;
closeFile(); closeFiles();
openFile(file); openFile(file);
} }
@ -798,7 +1018,7 @@ void GUI::first()
if (file.isNull()) if (file.isNull())
return; return;
closeFile(); closeFiles();
openFile(file); openFile(file);
} }
@ -819,11 +1039,129 @@ void GUI::keyPressEvent(QKeyEvent *event)
case LAST_KEY: case LAST_KEY:
file = _browser->last(); file = _browser->last();
break; break;
case Qt::Key_Escape:
if (_fullscreenAction->isChecked()) {
_fullscreenAction->setChecked(false);
showFullscreen(false);
}
break;
} }
if (!file.isNull()) { if (!file.isNull()) {
if (!(event->modifiers() & MODIFIER)) if (!(event->modifiers() & MODIFIER))
closeFile(); closeFiles();
openFile(file); 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 QLabel;
class QSignalMapper; class QSignalMapper;
class FileBrowser; class FileBrowser;
class GraphView;
class ElevationGraph; class ElevationGraph;
class SpeedGraph; class SpeedGraph;
class HeartRateGraph;
class TrackView; class TrackView;
class Map; class Map;
@ -35,7 +37,7 @@ private slots:
void saveFile(); void saveFile();
void saveAs(); void saveAs();
void openFile(); void openFile();
void closeFile(); void closeAll();
void reloadFile(); void reloadFile();
void openPOIFile(); void openPOIFile();
void closePOIFiles(); void closePOIFiles();
@ -43,6 +45,10 @@ private slots:
void showMap(bool checked); void showMap(bool checked);
void showGraphs(bool checked); void showGraphs(bool checked);
void showToolbars(bool checked); void showToolbars(bool checked);
void showFullscreen(bool checked);
void clearMapCache();
void nextMap();
void prevMap();
void mapChanged(int); void mapChanged(int);
void graphChanged(int); void graphChanged(int);
@ -56,8 +62,12 @@ private slots:
void setMetricUnits(); void setMetricUnits();
void setImperialUnits(); void setImperialUnits();
void sliderPositionChanged(qreal pos);
private: private:
void loadFiles(); void loadMaps();
void loadPOIs();
void closeFiles();
QAction *createPOIFileAction(int index); QAction *createPOIFileAction(int index);
void createPOIFilesActions(); void createPOIFilesActions();
@ -69,12 +79,21 @@ private:
void createTrackView(); void createTrackView();
void createTrackGraphs(); void createTrackGraphs();
bool openPOIFile(const QString &fileName);
bool loadFile(const QString &fileName); bool loadFile(const QString &fileName);
void saveFile(const QString &fileName); void saveFile(const QString &fileName);
void updateStatusBarInfo(); void updateStatusBarInfo();
void updateWindowTitle();
void updateNavigationActions(); void updateNavigationActions();
void updateGraphTabs();
void updateTrackView();
void keyPressEvent(QKeyEvent * event); void keyPressEvent(QKeyEvent * event);
void closeEvent(QCloseEvent *event);
int mapIndex(const QString &name);
void readSettings();
void writeSettings();
QMenu *_fileMenu; QMenu *_fileMenu;
QMenu *_helpMenu; QMenu *_helpMenu;
@ -105,6 +124,8 @@ private:
QAction *_closePOIAction; QAction *_closePOIAction;
QAction *_showPOIAction; QAction *_showPOIAction;
QAction *_showMapAction; QAction *_showMapAction;
QAction *_fullscreenAction;
QAction *_clearMapCacheAction;
QAction *_showGraphsAction; QAction *_showGraphsAction;
QAction *_showToolbarsAction; QAction *_showToolbarsAction;
QAction *_nextAction; QAction *_nextAction;
@ -113,6 +134,8 @@ private:
QAction *_firstAction; QAction *_firstAction;
QAction *_metricUnitsAction; QAction *_metricUnitsAction;
QAction *_imperialUnitsAction; QAction *_imperialUnitsAction;
QAction *_nextMapAction;
QAction *_prevMapAction;
QList<QAction*> _mapActions; QList<QAction*> _mapActions;
QList<QAction*> _poiFilesActions; QList<QAction*> _poiFilesActions;
@ -124,6 +147,7 @@ private:
ElevationGraph *_elevationGraph; ElevationGraph *_elevationGraph;
SpeedGraph *_speedGraph; SpeedGraph *_speedGraph;
HeartRateGraph *_heartRateGraph;
TrackView *_track; TrackView *_track;
POI _poi; POI _poi;
@ -137,6 +161,11 @@ private:
qreal _distance; qreal _distance;
qreal _time; qreal _time;
int _trackCount; int _trackCount;
qreal _sliderPos;
int _frameStyle;
bool _showGraphs;
}; };
#endif // GUI_H #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 #ifndef ICONS_H
#define ICONS_H #define ICONS_H
#include <QtGlobal>
#define APP_ICON ":/icons/gpxsee.png" #define APP_ICON ":/icons/gpxsee.png"
#define OPEN_FILE_ICON ":/icons/document-open.png" #define OPEN_FILE_ICON ":/icons/document-open.png"
#define SAVE_FILE_ICON ":/icons/document-save.png" #define SAVE_FILE_ICON ":/icons/document-save.png"
@ -16,11 +14,6 @@
#define PREV_FILE_ICON ":/icons/arrow-left.png" #define PREV_FILE_ICON ":/icons/arrow-left.png"
#define LAST_FILE_ICON ":/icons/arrow-right-double.png" #define LAST_FILE_ICON ":/icons/arrow-right-double.png"
#define FIRST_FILE_ICON ":/icons/arrow-left-double.png" #define FIRST_FILE_ICON ":/icons/arrow-left-double.png"
#define FULLSCREEN_ICON ":/icons/view-fullscreen.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
#endif /* ICONS_H */ #endif /* ICONS_H */

View File

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

View File

@ -1,10 +1,30 @@
#ifndef KEYS_H #ifndef KEYS_H
#define KEYS_H #define KEYS_H
#include <Qt>
#include <QKeySequence>
#define NEXT_KEY Qt::Key_Space #define NEXT_KEY Qt::Key_Space
#define PREV_KEY Qt::Key_Backspace #define PREV_KEY Qt::Key_Backspace
#define FIRST_KEY Qt::Key_Home #define FIRST_KEY Qt::Key_Home
#define LAST_KEY Qt::Key_End #define LAST_KEY Qt::Key_End
#define MODIFIER Qt::ShiftModifier #define MODIFIER Qt::ShiftModifier
#define QUIT_SHORTCUT QKeySequence::Quit
#define 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 #endif // KEYS_H

View File

@ -1,28 +1,9 @@
#include <QApplication> #include "app.h"
#include <QTranslator>
#include <QLocale>
#include "gui.h"
#include "icons.h"
int main(int argc, char *argv[]) int main(int argc, char *argv[])
{ {
QApplication app(argc, argv); App app(argc, argv);
app.run();
QString locale = QLocale::system().name(); return 0;
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();
} }

View File

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

View File

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

View File

@ -22,6 +22,7 @@ private:
void gpx(); void gpx();
void track(); void track();
void trackPoints(); void trackPoints();
void tpExtension();
void extensions(); void extensions();
void trackPointData(); void trackPointData();
void wayPointData(); 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) void ScaleItem::setLatitude(qreal lat)
{ {
prepareGeometryChange();
_lat = lat; _lat = lat;
computeScale(); computeScale();
updateBoundingRect(); updateBoundingRect();
prepareGeometryChange();
} }
void ScaleItem::setZoom(int z) void ScaleItem::setZoom(int z)
{ {
prepareGeometryChange();
_zoom = z; _zoom = z;
computeScale(); computeScale();
updateBoundingRect(); updateBoundingRect();
prepareGeometryChange();
} }
void ScaleItem::setUnits(enum Units units) void ScaleItem::setUnits(enum Units units)
{ {
prepareGeometryChange();
_units = units; _units = units;
computeScale(); computeScale();
updateBoundingRect(); 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) SliderInfoItem::SliderInfoItem(QGraphicsItem *parent) : QGraphicsItem(parent)
{ {
_side = Right;
} }
void SliderInfoItem::updateBoundingRect() void SliderInfoItem::updateBoundingRect()
@ -16,7 +17,10 @@ void SliderInfoItem::updateBoundingRect()
font.setFamily(FONT_FAMILY); font.setFamily(FONT_FAMILY);
QFontMetrics fm(font); 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 void SliderInfoItem::paint(QPainter *painter, const QStyleOptionGraphicsItem
@ -31,7 +35,11 @@ void SliderInfoItem::paint(QPainter *painter, const QStyleOptionGraphicsItem
painter->setFont(font); painter->setFont(font);
painter->setPen(Qt::red); painter->setPen(Qt::red);
if (_side == Right)
painter->drawText(SIZE, fm.height() - fm.descent(), _text); 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->drawLine(QPointF(-SIZE/2, 0), QPointF(SIZE/2, 0));
//painter->drawRect(boundingRect()); //painter->drawRect(boundingRect());
@ -39,7 +47,17 @@ void SliderInfoItem::paint(QPainter *painter, const QStyleOptionGraphicsItem
void SliderInfoItem::setText(const QString &text) void SliderInfoItem::setText(const QString &text)
{ {
prepareGeometryChange();
_text = text; _text = text;
updateBoundingRect(); 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 class SliderInfoItem : public QGraphicsItem
{ {
public: public:
enum Side {Left, Right};
SliderInfoItem(QGraphicsItem *parent = 0); SliderInfoItem(QGraphicsItem *parent = 0);
QRectF boundingRect() const {return _boundingRect;} QRectF boundingRect() const {return _boundingRect;}
@ -13,10 +15,12 @@ public:
QWidget *widget); QWidget *widget);
void setText(const QString &text); void setText(const QString &text);
void setSide(Side side);
private: private:
void updateBoundingRect(); void updateBoundingRect();
Side _side;
QString _text; QString _text;
QRectF _boundingRect; 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()); emit positionChanged(value.toPointF());
return QGraphicsItem::itemChange(change, value); return QGraphicsItem::itemChange(change, value);
@ -52,3 +52,9 @@ void SliderItem::clear()
_area = QRectF(); _area = QRectF();
setPos(QPointF()); setPos(QPointF());
} }
void SliderItem::setArea(const QRectF &area)
{
prepareGeometryChange();
_area = area;
}

View File

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

View File

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

View File

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

View File

@ -1,11 +1,12 @@
#include <cmath>
#include "ll.h" #include "ll.h"
#include "track.h" #include "track.h"
#define WINDOW_EF 3 #define WINDOW_EF 3
#define WINDOW_SE 11 #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) 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; 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 void Track::elevationGraph(QVector<QPointF> &graph) const
{ {
qreal dist = 0; qreal dist = 0;
@ -86,12 +99,12 @@ void Track::elevationGraph(QVector<QPointF> &graph) const
if (!_data.size()) if (!_data.size())
return; return;
if (isnan(_data.at(0).elevation)) if (!_data.at(0).hasElevation())
return; 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++) { for (int i = 1; i < _data.size(); i++) {
dist += llDistance(_data.at(i).coordinates, _data.at(i-1).coordinates); dist += _dd.at(i-1);
if (isnan(_data.at(i).elevation)) if (!_data.at(i).hasElevation())
return; return;
raw.append(QPointF(dist, _data.at(i).elevation raw.append(QPointF(dist, _data.at(i).elevation
- _data.at(i).geoidheight)); - _data.at(i).geoidheight));
@ -110,11 +123,11 @@ void Track::speedGraph(QVector<QPointF> &graph) const
raw.append(QPointF(0, 0)); raw.append(QPointF(0, 0));
for (int i = 1; i < _data.size(); i++) { 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; dt = _data.at(i-1).timestamp.msecsTo(_data.at(i).timestamp) / 1000.0;
dist += ds; dist += ds;
if (isnan(_data.at(i).speed)) { if (!_data.at(i).hasSpeed()) {
if (dt == 0) if (dt == 0)
continue; continue;
v = ds / dt; v = ds / dt;
@ -127,22 +140,33 @@ void Track::speedGraph(QVector<QPointF> &graph) const
graph = filter(eliminate(raw, WINDOW_SE), WINDOW_SF); 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 void Track::track(QVector<QPointF> &track) const
{ {
for (int i = 0; i < _data.size(); i++) for (int i = 0; i < _data.size(); i++)
track.append(_data.at(i).coordinates); 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 qreal Track::time() const
{ {
if (_data.size() < 2) if (_data.size() < 2)

View File

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

View File

@ -5,15 +5,26 @@
#include <QDateTime> #include <QDateTime>
#include <cmath> #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; QPointF coordinates;
QDateTime timestamp; QDateTime timestamp;
qreal elevation; qreal elevation;
qreal geoidheight; qreal geoidheight;
qreal speed; qreal speed;
qreal heartRate;
Trackpoint() {elevation = NAN; geoidheight = 0; speed = NAN;}
}; };
#endif // TRACKPOINT_H #endif // TRACKPOINT_H

View File

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

View File

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

View File

@ -13,8 +13,9 @@ enum Units {
#define MS2MIH 2.236936290000 // m/s -> mi/h #define MS2MIH 2.236936290000 // m/s -> mi/h
#define FT2MI 0.000189393939 // ft -> mi #define FT2MI 0.000189393939 // ft -> mi
#define 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 #ifdef Q_OS_WIN32
#define UNIT_SPACE " " #define UNIT_SPACE " "