1
0
mirror of https://github.com/tumic0/GPXSee.git synced 2025-07-06 15:42:51 +02:00

Compare commits

...

37 Commits
2.10 ... 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
50 changed files with 1340 additions and 477 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
@ -34,7 +35,11 @@ HEADERS += src/config.h \
src/trackpoint.h \ src/trackpoint.h \
src/waypointitem.h \ src/waypointitem.h \
src/palette.h \ src/palette.h \
src/heartrategraph.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 \
@ -59,8 +64,21 @@ SOURCES += src/main.cpp \
src/graphview.cpp \ src/graphview.cpp \
src/waypointitem.cpp \ src/waypointitem.cpp \
src/palette.cpp \ src/palette.cpp \
src/heartrategraph.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,6 +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>
</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="86"/>
<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="87"/> <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="24"/> <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="26"/> <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="30"/> <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="91"/> <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="92"/> <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="28"/> <location filename="../src/elevationgraph.cpp" line="26"/>
<source>Maximum</source> <source>Maximum</source>
<translation>Maximum</translation> <translation>Maximum</translation>
</message> </message>
@ -59,356 +59,375 @@
<context> <context>
<name>GUI</name> <name>GUI</name>
<message> <message>
<location filename="../src/gui.cpp" line="186"/> <location filename="../src/gui.cpp" line="448"/>
<source>About Qt</source>
<translation>O Qt</translation>
</message>
<message>
<location filename="../src/gui.cpp" line="406"/>
<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="465"/> <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="200"/> <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="532"/> <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="191"/> <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="174"/> <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="181"/> <location filename="../src/gui.cpp" line="189"/>
<location filename="../src/gui.cpp" line="422"/> <location filename="../src/gui.cpp" line="464"/>
<location filename="../src/gui.cpp" line="423"/> <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="195"/> <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="205"/> <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="210"/> <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="342"/> <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="287"/> <location filename="../src/gui.cpp" line="321"/>
<location filename="../src/gui.cpp" line="333"/> <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="179"/> <location filename="../src/gui.cpp" line="187"/>
<location filename="../src/gui.cpp" line="440"/> <location filename="../src/gui.cpp" line="487"/>
<location filename="../src/gui.cpp" line="441"/> <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="217"/> <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="220"/> <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="223"/> <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="230"/> <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="243"/> <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="249"/> <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="256"/> <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="262"/> <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="269"/> <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="272"/> <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="276"/> <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="279"/> <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="301"/> <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="306"/> <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="307"/> <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="315"/> <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="316"/> <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="323"/> <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="732"/> <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> <source>No GPX files loaded</source>
<translation>Nejsou načteny žádné GPX soubory</translation> <translation>Nejsou načteny žádné GPX soubory</translation>
</message> </message>
<message> <message>
<location filename="../src/gui.cpp" line="804"/> <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="805"/> <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="806"/> <location filename="../src/gui.cpp" line="924"/>
<source>Heart rate</source> <source>Heart rate</source>
<translation>Tep</translation> <translation>Tep</translation>
</message> </message>
<message> <message>
<location filename="../src/gui.cpp" line="425"/> <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="426"/> <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="428"/> <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="429"/> <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="430"/> <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="444"/> <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="447"/> <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="455"/> <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="466"/> <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="523"/> <location filename="../src/gui.cpp" line="574"/>
<location filename="../src/gui.cpp" line="549"/> <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="533"/> <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="614"/> <location filename="../src/gui.cpp" line="665"/>
<location filename="../src/gui.cpp" line="743"/> <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="617"/> <location filename="../src/gui.cpp" line="668"/>
<location filename="../src/gui.cpp" line="619"/> <location filename="../src/gui.cpp" line="670"/>
<location filename="../src/gui.cpp" line="621"/> <location filename="../src/gui.cpp" line="672"/>
<location filename="../src/gui.cpp" line="623"/> <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="620"/> <location filename="../src/gui.cpp" line="671"/>
<location filename="../src/gui.cpp" line="632"/> <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="622"/> <location filename="../src/gui.cpp" line="673"/>
<location filename="../src/gui.cpp" line="634"/> <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="184"/> <location filename="../src/gui.cpp" line="192"/>
<location filename="../src/gui.cpp" line="402"/> <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="349"/> <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="404"/> <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="443"/>
<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="454"/> <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="613"/> <location filename="../src/gui.cpp" line="664"/>
<location filename="../src/gui.cpp" line="625"/> <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="615"/> <location filename="../src/gui.cpp" line="666"/>
<location filename="../src/gui.cpp" line="627"/> <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="616"/> <location filename="../src/gui.cpp" line="667"/>
<location filename="../src/gui.cpp" line="628"/> <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="629"/> <location filename="../src/gui.cpp" line="680"/>
<location filename="../src/gui.cpp" line="631"/> <location filename="../src/gui.cpp" line="682"/>
<location filename="../src/gui.cpp" line="633"/> <location filename="../src/gui.cpp" line="684"/>
<location filename="../src/gui.cpp" line="635"/> <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="618"/> <location filename="../src/gui.cpp" line="669"/>
<location filename="../src/gui.cpp" line="630"/> <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="739"/> <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="626"/> <location filename="../src/gui.cpp" line="677"/>
<location filename="../src/gui.cpp" line="746"/> <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="525"/> <location filename="../src/gui.cpp" line="576"/>
<location filename="../src/gui.cpp" line="550"/> <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="520"/> <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="546"/> <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:
@ -418,38 +437,47 @@
<context> <context>
<name>HeartRateGraph</name> <name>HeartRateGraph</name>
<message> <message>
<location filename="../src/heartrategraph.cpp" line="9"/> <location filename="../src/heartrategraph.cpp" line="10"/>
<source>Distance</source> <source>Distance</source>
<translation>Vzdálenost</translation> <translation>Vzdálenost</translation>
</message> </message>
<message> <message>
<location filename="../src/heartrategraph.cpp" line="10"/> <location filename="../src/heartrategraph.cpp" line="11"/>
<source>Heart rate</source> <source>Heart rate</source>
<translation>Tep</translation> <translation>Tep</translation>
</message> </message>
<message> <message>
<location filename="../src/heartrategraph.cpp" line="11"/> <location filename="../src/heartrategraph.cpp" line="78"/>
<location filename="../src/heartrategraph.cpp" line="76"/>
<source>km</source> <source>km</source>
<translation>km</translation> <translation>km</translation>
</message> </message>
<message> <message>
<location filename="../src/heartrategraph.cpp" line="12"/> <location filename="../src/heartrategraph.cpp" line="9"/>
<source>1/min</source> <source>1/min</source>
<translation>1/min</translation> <translation>1/min</translation>
</message> </message>
<message> <message>
<location filename="../src/heartrategraph.cpp" line="19"/> <location filename="../src/heartrategraph.cpp" line="18"/>
<source>Average</source> <source>Average</source>
<translation>Průměr</translation> <translation>Průměr</translation>
</message> </message>
<message> <message>
<location filename="../src/heartrategraph.cpp" line="21"/> <location filename="../src/heartrategraph.cpp" line="20"/>
<source>Maximum</source> <source>Maximum</source>
<translation>Maximum</translation> <translation>Maximum</translation>
</message> </message>
<message> <message>
<location filename="../src/heartrategraph.cpp" line="79"/> <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> <source>mi</source>
<translation>mi</translation> <translation>mi</translation>
</message> </message>
@ -480,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"/>
<source>m</source>
<translation>m</translation>
</message>
<message>
<location filename="../src/speedgraph.cpp" line="75"/> <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="76"/> <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="80"/> <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="81"/> <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"
@ -65,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.10" 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
@ -79,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
@ -134,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);
@ -106,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;
@ -117,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);
} }
@ -134,18 +134,18 @@ 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; 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); 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);
@ -169,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);

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

@ -2,10 +2,12 @@
#define CONFIG_H #define CONFIG_H
#include <QtGlobal> #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.10"
#define FONT_FAMILY "Arial" #define FONT_FAMILY "Arial"
#define FONT_SIZE 12 #define FONT_SIZE 12

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,34 +7,35 @@ ElevationGraph::ElevationGraph(QWidget *parent) : GraphView(parent)
{ {
_ascent = 0; _ascent = 0;
_descent = 0; _descent = 0;
_max = -FLT_MAX;
_min = FLT_MAX;
_units = Metric;
setYUnits();
setXLabel(tr("Distance")); setXLabel(tr("Distance"));
setYLabel(tr("Elevation")); setYLabel(tr("Elevation"));
setXUnits(tr("km"));
setYUnits(tr("m")); setMinYRange(50.0);
setXScale(M2KM);
setMinRange(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.count() < 2) { if (data.count() < 2) {
@ -43,8 +43,6 @@ void ElevationGraph::loadGPX(const GPX &gpx)
continue; continue;
} }
min = max = data.at(0).y();
for (int j = 1; j < data.size(); j++) { for (int j = 1; j < data.size(); j++) {
qreal cur = data.at(j).y(); qreal cur = data.at(j).y();
qreal prev = data.at(j-1).y(); qreal prev = data.at(j-1).y();
@ -53,49 +51,64 @@ void ElevationGraph::loadGPX(const GPX &gpx)
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) {
setXUnits(tr("km")); if (bounds().width() < KMINM) {
setYUnits(tr("m")); GraphView::setXUnits(tr("m"));
setXScale(M2KM); setXScale(1);
} else {
GraphView::setXUnits(tr("km"));
setXScale(M2KM);
}
} else {
if (bounds().width() < MIINM) {
GraphView::setXUnits(tr("ft"));
setXScale(M2FT);
} else {
GraphView::setXUnits(tr("mi"));
setXScale(M2MI);
}
}
}
void ElevationGraph::setYUnits()
{
if (_units == Metric) {
GraphView::setYUnits(tr("m"));
setYScale(1); setYScale(1);
} else { } else {
setXUnits(tr("mi")); GraphView::setYUnits(tr("ft"));
setYUnits(tr("ft"));
setXScale(M2MI);
setYScale(M2FT); 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,11 +153,6 @@ 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()
@ -168,9 +165,9 @@ 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::redraw(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::redraw(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,17 +217,12 @@ void GraphView::redraw(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
@ -267,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();
@ -281,10 +270,8 @@ 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);
} }
@ -295,6 +282,9 @@ static qreal yAtX(const QPainterPath &path, qreal x)
int high = path.elementCount() - 1; int high = path.elementCount() - 1;
int mid = 0; int mid = 0;
Q_ASSERT(high > low);
Q_ASSERT(x >= path.elementAt(low).x && x <= path.elementAt(high).x);
while (low <= high) { while (low <= high) {
mid = low + ((high - low) / 2); mid = low + ((high - low) / 2);
const QPainterPath::Element &e = path.elementAt(mid); const QPainterPath::Element &e = path.elementAt(mid);
@ -307,59 +297,63 @@ static qreal yAtX(const QPainterPath &path, qreal x)
} }
QLineF l; QLineF l;
if (path.elementAt(mid).x < x) { if (path.elementAt(mid).x < x)
Q_ASSERT(mid >= 0 && mid+1 < path.elementCount());
l = QLineF(path.elementAt(mid).x, path.elementAt(mid).y, l = QLineF(path.elementAt(mid).x, path.elementAt(mid).y,
path.elementAt(mid+1).x, path.elementAt(mid+1).y); path.elementAt(mid+1).x, path.elementAt(mid+1).y);
} else { else
Q_ASSERT(mid-1 >= 0 && mid < path.elementCount());
l = QLineF(path.elementAt(mid-1).x, path.elementAt(mid-1).y, l = QLineF(path.elementAt(mid-1).x, path.elementAt(mid-1).y,
path.elementAt(mid).x, path.elementAt(mid).y); path.elementAt(mid).x, path.elementAt(mid).y);
}
return l.pointAt((x - l.p1().x()) / (l.p2().x() - l.p1().x())).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 * (_xMax - _xMin)); emit sliderPositionChanged(_sliderPos);
if (!_sliderInfo->isVisible()) updateSliderInfo();
return;
const QPainterPath &path = _graphs.at(0)->path();
QRectF br = path.boundingRect();
if (br.height() < _minRange)
br.adjust(0, -(_minRange/2 - br.height()/2), 0,
_minRange/2 - br.height()/2);
qreal y = yAtX(path, val * (_xMax - _xMin));
qreal r = (y - br.bottom()) / br.height();
_sliderInfo->setPos(QPointF(0, _slider->boundingRect().height() * r));
_sliderInfo->setText(QString::number(-y * _yScale, 'f', _precision));
}
qreal GraphView::sliderPosition() const
{
if (!_slider->isVisible())
return -1;
else
return (_slider->pos().x() / _slider->area().width()) * (_xMax - _xMin);
} }
void GraphView::setSliderPosition(qreal pos) void GraphView::setSliderPosition(qreal pos)
{ {
_sliderPos = pos;
if (_graphs.isEmpty()) if (_graphs.isEmpty())
return; return;
if (pos > (_xMax - _xMin)) if (pos > _bounds.right() || pos < _bounds.left())
_slider->setVisible(false); _slider->setVisible(false);
else { else {
_slider->setPos((pos / (_xMax - _xMin)) * _slider->area().width(), 0); _slider->setPos((pos / _bounds.width()) * _slider->area().width(), 0);
_slider->setVisible(true); _slider->setVisible(true);
} }
} }

View File

@ -35,39 +35,45 @@ 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 plot(QPainter *painter, const QRectF &target); void setSliderPrecision(int precision) {_precision = precision;}
void clear(); void setMinYRange(qreal range) {_minYRange = range;}
qreal sliderPosition() const; qreal sliderPosition() const {return _sliderPos;}
void setSliderPosition(qreal pos); void setSliderPosition(qreal pos);
int count() const {return _graphs.count();} void plot(QPainter *painter, const QRectF &target);
signals: signals:
void sliderPositionChanged(qreal); void sliderPositionChanged(qreal);
protected: protected:
const QRectF &bounds() const {return _bounds;}
void resizeEvent(QResizeEvent *); void resizeEvent(QResizeEvent *);
void redraw(); void redraw(const QSizeF &size);
void addInfo(const QString &key, const QString &value); void addInfo(const QString &key, const QString &value);
void clearInfo(); void clearInfo();
void skipColor() {_palette.color();} void skipColor() {_palette.color();}
qreal _xScale, _yScale;
QString _xUnits, _yUnits;
QString _xLabel, _yLabel;
int _precision;
qreal _minRange;
private slots: private slots:
void emitSliderPositionChanged(const QPointF &pos); void emitSliderPositionChanged(const QPointF &pos);
void newSliderPosition(const QPointF &pos); void newSliderPosition(const QPointF &pos);
@ -76,7 +82,14 @@ private:
void createXLabel(); void createXLabel();
void createYLabel(); void createYLabel();
void updateBounds(const QPointF &point); void updateBounds(const QPointF &point);
void redraw(const QSizeF &size); void updateSliderInfo();
qreal _xScale, _yScale;
QString _xUnits, _yUnits;
QString _xLabel, _yLabel;
int _precision;
qreal _minYRange;
qreal _sliderPos;
Scene *_scene; Scene *_scene;
@ -86,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,9 +14,11 @@
#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"
@ -26,6 +28,7 @@
#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"
@ -61,12 +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)), _track, connect(_heartRateGraph, SIGNAL(sliderPositionChanged(qreal)), this,
SLOT(movePositionMarker(qreal))); SLOT(sliderPositionChanged(qreal)));
_browser = new FileBrowser(this); _browser = new FileBrowser(this);
_browser->setFilter(QStringList("*.gpx")); _browser->setFilter(QStringList("*.gpx"));
@ -74,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);
@ -86,12 +94,12 @@ GUI::GUI(QWidget *parent) : QMainWindow(parent)
_time = 0; _time = 0;
_trackCount = 0; _trackCount = 0;
_lastGraph = 0; _sliderPos = 0;
_lastSliderPos = -1.0;
updateGraphTabs(); updateGraphTabs();
updateTrackView(); updateTrackView();
resize(600, 800); readSettings();
} }
void GUI::loadMaps() void GUI::loadMaps()
@ -136,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()
@ -156,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()));
@ -178,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);
@ -189,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(closeAll())); 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)),
@ -228,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);
@ -262,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);
@ -270,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);
@ -307,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"));
@ -325,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()
@ -365,16 +395,19 @@ 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 = new HeartRateGraph;
_heartRateGraph->setFrameShape(QFrame::NoFrame);
_trackGraphs = new QTabWidget; _trackGraphs = new QTabWidget;
connect(_trackGraphs, SIGNAL(currentChanged(int)), this, connect(_trackGraphs, SIGNAL(currentChanged(int)), this,
@ -383,6 +416,9 @@ void GUI::createTrackGraphs()
_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()
@ -406,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 "
@ -432,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();
} }
@ -489,12 +532,14 @@ bool GUI::openFile(const QString &fileName)
_fileActionGroup->setEnabled(true); _fileActionGroup->setEnabled(true);
_navigationActionGroup->setEnabled(true); _navigationActionGroup->setEnabled(true);
} else { } else {
_fileActionGroup->setEnabled(false); if (_files.isEmpty())
_fileActionGroup->setEnabled(false);
ret = false; ret = false;
} }
updateNavigationActions(); updateNavigationActions();
updateStatusBarInfo(); updateStatusBarInfo();
updateWindowTitle();
updateGraphTabs(); updateGraphTabs();
updateTrackView(); updateTrackView();
@ -514,6 +559,7 @@ bool GUI::loadFile(const QString &fileName)
_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();
@ -665,6 +711,7 @@ void GUI::reloadFile()
} }
updateStatusBarInfo(); updateStatusBarInfo();
updateWindowTitle();
updateGraphTabs(); updateGraphTabs();
updateTrackView(); updateTrackView();
if (_files.isEmpty()) if (_files.isEmpty())
@ -679,6 +726,8 @@ void GUI::closeFiles()
_time = 0; _time = 0;
_trackCount = 0; _trackCount = 0;
_sliderPos = 0;
_elevationGraph->clear(); _elevationGraph->clear();
_speedGraph->clear(); _speedGraph->clear();
_heartRateGraph->clear(); _heartRateGraph->clear();
@ -693,6 +742,7 @@ void GUI::closeAll()
_fileActionGroup->setEnabled(false); _fileActionGroup->setEnabled(false);
updateStatusBarInfo(); updateStatusBarInfo();
updateWindowTitle();
updateGraphTabs(); updateGraphTabs();
updateTrackView(); updateTrackView();
} }
@ -734,6 +784,40 @@ 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) {
@ -746,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()) {
_distanceLabel->setText(QString::number(_distance * M2MI, 'f', 1) if (_distance < MIINM)
+ UNIT_SPACE + tr("mi")); _distanceLabel->setText(QString::number(_distance * M2FT, 'f', 0)
else + UNIT_SPACE + tr("ft"));
_distanceLabel->setText(QString::number(_distance * M2KM, 'f', 1) else
+ UNIT_SPACE + tr("km")); _distanceLabel->setText(QString::number(_distance * M2MI, 'f', 1)
+ UNIT_SPACE + tr("mi"));
} else {
if (_distance < KMINM)
_distanceLabel->setText(QString::number(_distance, 'f', 0)
+ UNIT_SPACE + tr("m"));
else
_distanceLabel->setText(QString::number(_distance * M2KM, 'f', 1)
+ UNIT_SPACE + tr("km"));
}
_timeLabel->setText(timeSpan(_time)); _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);
@ -763,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),
@ -773,18 +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 (index < 0) if (index < 0)
return; return;
GraphView *tv = static_cast<GraphView*>(_trackGraphs->widget(index)); GraphView *gv = static_cast<GraphView*>(_trackGraphs->widget(index));
if (_lastGraph) { gv->setSliderPosition(_sliderPos);
if (_lastGraph->sliderPosition() >= 0)
_lastSliderPos = _lastGraph->sliderPosition();
tv->setSliderPosition(_lastSliderPos);
}
_lastGraph = tv;
} }
void GUI::updateNavigationActions() void GUI::updateNavigationActions()
@ -828,17 +949,14 @@ void GUI::updateGraphTabs()
_trackGraphs->insertTab(i, gv, tabs[i].label); _trackGraphs->insertTab(i, gv, tabs[i].label);
} }
for (int i = 0; i < (int)ARRAY_SIZE(tabs); i++) { if (_trackGraphs->count()) {
if (tabs[i].view->count()) { if (_showGraphsAction->isChecked())
if (_showGraphsAction->isChecked()) _trackGraphs->setHidden(false);
_trackGraphs->setHidden(false); _showGraphsAction->setEnabled(true);
_showGraphsAction->setEnabled(true); } else {
return; _trackGraphs->setHidden(true);
} _showGraphsAction->setEnabled(false);
} }
_trackGraphs->setHidden(true);
_showGraphsAction->setEnabled(false);
} }
void GUI::updateTrackView() void GUI::updateTrackView()
@ -921,6 +1039,13 @@ 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()) {
@ -929,3 +1054,114 @@ void GUI::keyPressEvent(QKeyEvent *event)
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

@ -45,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);
@ -58,6 +62,8 @@ private slots:
void setMetricUnits(); void setMetricUnits();
void setImperialUnits(); void setImperialUnits();
void sliderPositionChanged(qreal pos);
private: private:
void loadMaps(); void loadMaps();
void loadPOIs(); void loadPOIs();
@ -77,11 +83,17 @@ private:
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 updateGraphTabs();
void updateTrackView(); 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;
@ -112,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;
@ -120,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;
@ -146,8 +162,10 @@ private:
qreal _time; qreal _time;
int _trackCount; int _trackCount;
GraphView *_lastGraph; qreal _sliderPos;
qreal _lastSliderPos;
int _frameStyle;
bool _showGraphs;
}; };
#endif // GUI_H #endif // GUI_H

View File

@ -4,29 +4,30 @@
HeartRateGraph::HeartRateGraph(QWidget *parent) : GraphView(parent) HeartRateGraph::HeartRateGraph(QWidget *parent) : GraphView(parent)
{ {
_max = 0; _units = Metric;
GraphView::setYUnits(tr("1/min"));
setXLabel(tr("Distance")); setXLabel(tr("Distance"));
setYLabel(tr("Heart rate")); setYLabel(tr("Heart rate"));
setXUnits(tr("km"));
setYUnits(tr("1/min")); setSliderPrecision(0);
setXScale(M2KM);
setPrecision(0);
} }
void HeartRateGraph::addInfo() void HeartRateGraph::addInfo()
{ {
GraphView::addInfo(tr("Average"), QString::number(avg() * _yScale, 'f', 0) GraphView::addInfo(tr("Average"), QString::number(avg() * yScale(), 'f', 0)
+ UNIT_SPACE + _yUnits); + 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());
redraw();
} }
void HeartRateGraph::loadGPX(const GPX &gpx) void HeartRateGraph::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, sum = 0, w = 0; qreal sum = 0, w = 0;
gpx.track(i).heartRateGraph(data); gpx.track(i).heartRateGraph(data);
if (data.count() < 2) { if (data.count() < 2) {
@ -40,13 +41,11 @@ void HeartRateGraph::loadGPX(const GPX &gpx)
} }
_avg.append(QPointF(gpx.track(i).distance(), sum/w)); _avg.append(QPointF(gpx.track(i).distance(), sum/w));
for (int j = 0; j < data.size(); j++)
max = qMax(max, data.at(j).y());
_max = qMax(_max, max);
addInfo();
loadData(data); loadData(data);
} }
setXUnits();
addInfo();
} }
qreal HeartRateGraph::avg() const qreal HeartRateGraph::avg() const
@ -64,24 +63,37 @@ qreal HeartRateGraph::avg() const
void HeartRateGraph::clear() void HeartRateGraph::clear()
{ {
_max = 0;
_avg.clear(); _avg.clear();
GraphView::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) void HeartRateGraph::setUnits(enum Units units)
{ {
if (units == Metric) { _units = units;
setXUnits(tr("km")); setXUnits();
setXScale(M2KM);
} else {
setXUnits(tr("mi"));
setXScale(M2MI);
}
clearInfo(); clearInfo();
addInfo(); addInfo();
redraw();
} }

View File

@ -18,13 +18,14 @@ 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 addInfo(); void addInfo();
qreal _max;
QList<QPointF> _avg; QList<QPointF> _avg;
enum Units _units;
}; };
#endif // HEARTRATEGRAPH_H #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
#define NEXT_KEY Qt::Key_Space #include <Qt>
#define PREV_KEY Qt::Key_Backspace #include <QKeySequence>
#define FIRST_KEY Qt::Key_Home
#define LAST_KEY Qt::Key_End #define NEXT_KEY Qt::Key_Space
#define MODIFIER Qt::ShiftModifier #define PREV_KEY Qt::Key_Backspace
#define FIRST_KEY Qt::Key_Home
#define LAST_KEY Qt::Key_End
#define MODIFIER Qt::ShiftModifier
#define QUIT_SHORTCUT QKeySequence::Quit
#define OPEN_SHORTCUT QKeySequence::Open
#define SAVE_SHORTCUT QKeySequence::Save
#define SAVE_AS_SHORTCUT QKeySequence::SaveAs
#define CLOSE_SHORTCUT QKeySequence::Close
#define RELOAD_SHORTCUT QKeySequence::Refresh
#define SHOW_POI_SHORTCUT QKeySequence(Qt::CTRL + Qt::Key_P)
#define SHOW_MAP_SHORTCUT QKeySequence(Qt::CTRL + Qt::Key_M)
#define NEXT_MAP_SHORTCUT QKeySequence::Forward
#define PREV_MAP_SHORTCUT QKeySequence::Back
#define SHOW_GRAPHS_SHORTCUT QKeySequence(Qt::CTRL + Qt::Key_G)
#ifdef Q_OS_MAC
#define FULLSCREEN_SHORTCUT QKeySequence(Qt::META + Qt::CTRL + Qt::Key_F)
#else // Q_OS_MAC
#define FULLSCREEN_SHORTCUT QKeySequence(Qt::Key_F11)
#endif // Q_OS_MAC
#endif // KEYS_H #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

@ -16,7 +16,7 @@ Map::Map(QObject *parent, const QString &name, const QString &url)
SLOT(emitLoaded())); SLOT(emitLoaded()));
QString path = TILES_DIR + QString("/") + _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));
} }
@ -54,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();

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);
painter->drawText(SIZE, fm.height() - fm.descent(), _text); if (_side == Right)
painter->drawText(SIZE, fm.height() - fm.descent(), _text);
else
painter->drawText(-(fm.width(_text) + SIZE/2),
fm.height() - fm.descent(), _text);
painter->drawLine(QPointF(-SIZE/2, 0), QPointF(SIZE/2, 0)); painter->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,30 +5,29 @@
SpeedGraph::SpeedGraph(QWidget *parent) : GraphView(parent) SpeedGraph::SpeedGraph(QWidget *parent) : GraphView(parent)
{ {
_max = 0; _units = Metric;
setYUnits();
setXLabel(tr("Distance")); setXLabel(tr("Distance"));
setYLabel(tr("Speed")); setYLabel(tr("Speed"));
setXUnits(tr("km"));
setYUnits(tr("km/h")); setSliderPrecision(1);
setXScale(M2KM);
setYScale(MS2KMH);
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.count() < 2) { if (data.count() < 2) {
@ -39,13 +38,11 @@ void SpeedGraph::loadGPX(const GPX &gpx)
_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 j = 0; j < data.size(); j++)
max = qMax(max, data.at(j).y());
_max = qMax(_max, max);
addInfo();
loadData(data); loadData(data);
} }
setXUnits();
addInfo();
} }
qreal SpeedGraph::avg() const qreal SpeedGraph::avg() const
@ -63,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) {
setXUnits(tr("km")); if (bounds().width() < KMINM) {
setYUnits(tr("km/h")); GraphView::setXUnits(tr("m"));
setXScale(M2KM); setXScale(1);
} else {
GraphView::setXUnits(tr("km"));
setXScale(M2KM);
}
} else {
if (bounds().width() < MIINM) {
GraphView::setXUnits(tr("ft"));
setXScale(M2FT);
} else {
GraphView::setXUnits(tr("mi"));
setXScale(M2MI);
}
}
}
void SpeedGraph::setYUnits()
{
if (_units == Metric) {
GraphView::setYUnits(tr("km/h"));
setYScale(MS2KMH); setYScale(MS2KMH);
} else { } else {
setXUnits(tr("mi")); GraphView::setYUnits(tr("mi/h"));
setYUnits(tr("mi/h"));
setXScale(M2MI);
setYScale(MS2MIH); 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,4 +1,3 @@
#include <cmath>
#include "ll.h" #include "ll.h"
#include "track.h" #include "track.h"
@ -100,12 +99,12 @@ void Track::elevationGraph(QVector<QPointF> &graph) const
if (!_data.size()) if (!_data.size())
return; return;
if (std::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 += _dd.at(i-1); dist += _dd.at(i-1);
if (std::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));
@ -128,7 +127,7 @@ void Track::speedGraph(QVector<QPointF> &graph) const
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 (std::isnan(_data.at(i).speed)) { if (!_data.at(i).hasSpeed()) {
if (dt == 0) if (dt == 0)
continue; continue;
v = ds / dt; v = ds / dt;
@ -149,11 +148,11 @@ void Track::heartRateGraph(QVector<QPointF> &graph) const
if (!_data.size()) if (!_data.size())
return; return;
if (std::isnan(_data.at(0).heartRate)) if (!_data.at(0).hasHeartRate())
return; return;
raw.append(QPointF(0, _data.at(0).heartRate)); raw.append(QPointF(0, _data.at(0).heartRate));
for (int i = 1; i < _data.count(); i++) { for (int i = 1; i < _data.count(); i++) {
if (std::isnan(_data.at(i).heartRate)) if (!_data.at(i).hasHeartRate())
return; return;
dist += _dd.at(i-1); dist += _dd.at(i-1);
raw.append(QPointF(dist, _data.at(i).heartRate)); raw.append(QPointF(dist, _data.at(i).heartRate));

View File

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

View File

@ -308,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())
@ -420,7 +427,7 @@ void TrackView::movePositionMarker(qreal val)
for (int i = 0; i < _paths.size(); i++) { for (int i = 0; i < _paths.size(); i++) {
qreal f = _maxPath / _paths.at(i)->path().length(); qreal f = _maxPath / _paths.at(i)->path().length();
if (mp * f > 1.0) if (mp * f < 0 || mp * f > 1.0)
_markers.at(i)->setVisible(false); _markers.at(i)->setVisible(false);
else { else {
QPointF pos = _paths.at(i)->path().pointAtPercent(mp * f); QPointF pos = _paths.at(i)->path().pointAtPercent(mp * f);
@ -467,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

@ -42,8 +42,6 @@ public:
public slots: public slots:
void movePositionMarker(qreal val); void movePositionMarker(qreal val);
private slots:
void redraw(); void redraw();
private: private:
@ -57,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);

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 " "