1
0
mirror of https://github.com/tumic0/GPXSee.git synced 2025-07-01 05:19:15 +02:00

Compare commits

...

83 Commits
2.9 ... 2.14

Author SHA1 Message Date
330b6547c4 Some more PDF export dialog polishing 2016-05-28 07:39:40 +02:00
498d33b77d PDF export dialog polishing 2016-05-27 22:45:58 +02:00
3592d9e68f Some more PDF info 2016-05-26 00:57:27 +02:00
7d38b55f60 Remove the PDF export dialog window superfluous "Help" button on Windows 2016-05-26 00:24:19 +02:00
82df1bec0e Improved PDF export dialog 2016-05-25 23:27:07 +02:00
82cbbbb52a Added basic PDF export settings 2016-05-24 03:01:22 +02:00
b8e404b789 Plots are now paper size agnostic 2016-05-22 15:47:23 +02:00
2ad94947d7 Make the file info and graph info having the same text size in plots. 2016-05-22 11:54:27 +02:00
b713da0012 Fixed QT4 compile issue 2016-05-21 16:18:48 +02:00
daf4ef894c Yet another bunch of print/PDF export improvements 2016-05-21 16:10:24 +02:00
eae8e23c6c Yet another print/pdf export fix 2016-05-21 00:28:06 +02:00
b9f7af33d7 Fixed graph shrinking on export/print 2016-05-20 23:47:37 +02:00
f334901db3 Print/pdf export related cosmetics 2016-05-20 22:44:03 +02:00
ffcba53b91 Added proper tile download for PDF exports/printing 2016-05-19 01:10:40 +02:00
f326c7e002 Added missing string localization
Code cleanup
2016-05-18 22:25:55 +02:00
15d4bd05f9 Keep the toolbar small 2016-05-17 00:45:49 +02:00
43bc7dd682 System defined toolbar style does't seem to be a that good idea... 2016-05-15 22:50:44 +02:00
a8cc02c1f9 Version++ 2016-05-15 22:40:49 +02:00
511deada2e Added printing support
"Save" is now "Export"
2016-05-15 22:38:15 +02:00
36937d8f2d Added support for maps in PDF export 2016-05-15 13:19:07 +02:00
969d87ec51 Improved toolbar style handling 2016-05-14 09:28:56 +02:00
07255aa8ae Some more code cleanup 2016-05-13 18:48:42 +02:00
e73f9448e9 Fixed plot region 2016-05-12 09:09:14 +02:00
ee9a8df51f Code cleanup 2016-05-12 09:03:05 +02:00
dcdd250858 Improved packaging scripts 2016-05-05 22:28:53 +02:00
6f73740da6 Program version (and some other stuff) now added by qmake. 2016-05-04 18:25:52 +02:00
6518fe3278 Added GPX file association 2016-05-03 10:18:51 +02:00
97e2215f0b File association stuff 2016-05-02 22:21:57 +02:00
21e7c00f66 Code cleanup 2016-04-30 10:54:07 +02:00
5daacc0a22 Program version now defined in the project file 2016-04-30 09:44:28 +02:00
1323f6ead8 Project structure refactoring 2016-04-29 22:49:37 +02:00
798f63aaff Fixed file open event handling on OS X
Installer files separation
2016-04-29 21:13:38 +02:00
b0abc976a5 Added remaining permanent settings 2016-04-28 08:49:06 +02:00
4c61e208ed More permanent settings 2016-04-26 20:55:29 +02:00
c997694e10 Merge branch 'master' of https://github.com/tumic0/GPXSee 2016-04-26 09:40:28 +02:00
a8d671556e Added permanent settings 2016-04-26 09:39:16 +02:00
2e4aeb57a8 Fixed broken file path handling on non-ASCII file systems. 2016-04-22 01:31:44 +02:00
e186a33340 Added screenshot + some more info 2016-04-20 09:27:57 +02:00
1b5bdc0f07 Better window title 2016-04-19 08:51:11 +02:00
5feec6ac0c Fixed broken registry handling in 64b uninstaller 2016-04-15 18:19:35 +02:00
5997ba21f2 Fixed OS X fullscreen shortcut (F11 collides with a system shortcut) 2016-04-13 22:04:14 +02:00
37d9bf1b9b Missing changes from previous commit
Yet another GUI polishing
2016-04-12 23:15:17 +02:00
2bf93f891a Redesigned about dialogs
64b Windows build stuff
2016-04-12 19:16:52 +02:00
11a9d75d8f Yet another graph tabs polishing
Code cleanup
2016-04-11 22:08:00 +02:00
23576cd52c Cosmetics 2016-04-09 09:14:10 +02:00
47bcd0cfaf Added map change shortcuts 2016-04-08 22:33:19 +02:00
043d1f49a6 Uh. That's hideous. 2016-04-05 19:45:30 +02:00
339144f7f8 Added fullscreen mode 2016-04-05 09:10:19 +02:00
27ff3a9ba8 version++ 2016-04-01 23:31:55 +02:00
8f4d31ac24 Fixed C++11 compile issues 2016-04-01 23:14:57 +02:00
34fcbfb60f Proper use of prepareGeometryChange() 2016-04-01 21:20:23 +02:00
803c4aecce Removed debug code 2016-04-01 19:35:57 +02:00
f247c2fa22 Added support for tiles cache clearing 2016-04-01 19:25:34 +02:00
9fa031ca4d Code cleanup 2016-04-01 19:20:55 +02:00
d3908f1561 Code cleanup 2016-04-01 09:41:52 +02:00
f41b13a5a2 Yet another small fix... 2016-03-30 23:07:54 +02:00
284f7d0a36 Fixed slider position handling 2016-03-30 20:50:51 +02:00
f469b4f600 Fixed slider info displaying on right graph border 2016-03-30 01:48:48 +02:00
eec797125b Fixed error handling 2016-03-29 20:58:33 +02:00
9dce08bce4 Added missing units init 2016-03-28 19:04:58 +02:00
06248457a0 Improved handlig of small-distance tracks 2016-03-27 15:04:58 +02:00
c9b5e0f2cb Code cleanup 2016-03-27 13:23:00 +02:00
b7f3a64577 Fixed broken elevation graph start value 2016-03-27 09:45:07 +02:00
e05069d653 Filter parameters adjustment 2016-03-25 13:11:26 +01:00
1928b579ab Replace global data sources with user data sources rather than merging them 2016-03-25 11:27:42 +01:00
501431207f Fixed graphs display configuration issue 2016-03-25 10:59:47 +01:00
0d41341086 Fixed broken file action group handling on file load error 2016-03-25 10:49:08 +01:00
13f383ab7a Yet another GUI polishing 2016-03-25 09:50:19 +01:00
5253698602 Yet another Graph tab display behaviour change 2016-03-24 20:50:11 +01:00
6bcb6ceb8d Now using a file on the filesystem for default maps rather than the executable 2016-03-24 19:34:46 +01:00
9da82a978c Fixed broken app close action 2016-03-24 19:16:26 +01:00
64a343dd2e Fixed tab logic 2016-03-23 20:56:39 +01:00
ac93ccba29 Fixed track color skew on empty tracks 2016-03-23 20:49:40 +01:00
7cd005873d Added missing size check 2016-03-23 20:48:22 +01:00
9c16c3498c Fixed redraw issue 2016-03-23 09:47:02 +01:00
a2eaacc017 Better graph tabs handling 2016-03-23 09:38:22 +01:00
58bed99d14 Fixed broken slider position setting
Refactoring
2016-03-23 09:22:26 +01:00
de71aa0d0c version++ 2016-03-22 19:49:48 +01:00
14290bf1f0 Enabled loading multiple POI files at once 2016-03-22 19:47:11 +01:00
e0fd77bbfd Fixed graph slider position computation 2016-03-22 19:19:59 +01:00
b1b8d68610 Fixed Y legend plotting issue 2016-03-22 06:48:49 +01:00
a0b64b4227 Added support for Garmin "TrackPointExtension" extension (heart rate) 2016-03-21 23:13:46 +01:00
93670d3026 Added heart rate graph
Improved graphs loading performance
Fixed various corner case behaviour bugs
2016-03-21 22:37:55 +01:00
67 changed files with 2798 additions and 911 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>@ICON@</string>
<key>CFBundlePackageType</key>
<string>APPL</string>
<key>CFBundleShortVersionString</key>
<string>@SHORT_VERSION@</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleExecutable</key>
<string>@EXECUTABLE@</string>
<key>CFBundleIdentifier</key>
<string>cz.wz.tumic.GPXSee</string>
<key>CFBundleDocumentTypes</key>
<array>
<dict>
<key>CFBundleTypeExtensions</key>
<array>
<string>gpx</string>
</array>
<key>CFBundleTypeMIMETypes</key>
<array>
<string>application/gpx+xml</string>
</array>
<key>CFBundleTypeIconFile</key>
<string>gpx.icns</string>
<key>CFBundleTypeName</key>
<string>GPS Exchange Format</string>
<key>CFBundleTypeRole</key>
<string>Viewer</string>
</dict>
</array>
<key>UTImportedTypeDeclarations</key>
<array>
<dict>
<key>UTTypeIdentifier</key>
<string>com.topografix.gpx</string>
<key>UTTypeReferenceURL</key>
<string>http://www.topografix.com/GPX/1/1</string>
<key>UTTypeDescription</key>
<string>GPS Exchange Format</string>
<key>UTTypeConformsTo</key>
<array>
<string>public.xml</string>
</array>
<key>UTTypeTagSpecification</key>
<dict>
<key>public.filename-extension</key>
<array>
<string>gpx</string>
</array>
<key>public.mime-type</key>
<string>application/gpx+xml</string>
</dict>
</dict>
</array>
</dict>
</plist>

View File

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

6
build/env.bat Normal file
View File

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

6
build/env64.bat Normal file
View File

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

View File

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

View File

@ -2,8 +2,8 @@
<qresource prefix="/">
<file>icons/dialog-close.png</file>
<file>icons/document-open.png</file>
<file>icons/document-save-as.png</file>
<file>icons/document-save.png</file>
<file>icons/document-print.png</file>
<file>icons/document-export.png</file>
<file>icons/flag.png</file>
<file>icons/gpxsee.png</file>
<file>icons/application-exit.png</file>
@ -13,7 +13,7 @@
<file>icons/arrow-right.png</file>
<file>icons/arrow-left-double.png</file>
<file>icons/arrow-right-double.png</file>
<file>icons/view-fullscreen.png</file>
<file>lang/gpxsee_cs.qm</file>
<file>maps.txt</file>
</qresource>
</RCC>

View File

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

BIN
icons/document-export.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 865 B

BIN
icons/document-print.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 880 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 798 B

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,391 +14,501 @@
<translation>Výška</translation>
</message>
<message>
<location filename="../src/elevationgraph.cpp" line="16"/>
<location filename="../src/elevationgraph.cpp" line="83"/>
<location filename="../src/elevationgraph.cpp" line="81"/>
<source>km</source>
<translation>km</translation>
</message>
<message>
<location filename="../src/elevationgraph.cpp" line="17"/>
<location filename="../src/elevationgraph.cpp" line="84"/>
<location filename="../src/elevationgraph.cpp" line="78"/>
<location filename="../src/elevationgraph.cpp" line="98"/>
<source>m</source>
<translation>m</translation>
</message>
<message>
<location filename="../src/elevationgraph.cpp" line="23"/>
<location filename="../src/elevationgraph.cpp" line="22"/>
<source>Ascent</source>
<translation>Stoupání</translation>
</message>
<message>
<location filename="../src/elevationgraph.cpp" line="25"/>
<location filename="../src/elevationgraph.cpp" line="24"/>
<source>Descent</source>
<translation>Klesání</translation>
</message>
<message>
<location filename="../src/elevationgraph.cpp" line="29"/>
<location filename="../src/elevationgraph.cpp" line="28"/>
<source>Minimum</source>
<translation>Minimum</translation>
</message>
<message>
<location filename="../src/elevationgraph.cpp" line="88"/>
<location filename="../src/elevationgraph.cpp" line="89"/>
<source>mi</source>
<translation>mi</translation>
</message>
<message>
<location filename="../src/elevationgraph.cpp" line="89"/>
<location filename="../src/elevationgraph.cpp" line="86"/>
<location filename="../src/elevationgraph.cpp" line="101"/>
<source>ft</source>
<translation>ft</translation>
</message>
<message>
<location filename="../src/elevationgraph.cpp" line="27"/>
<location filename="../src/elevationgraph.cpp" line="26"/>
<source>Maximum</source>
<translation>Maximum</translation>
</message>
</context>
<context>
<name>GUI</name>
<name>ExportDialog</name>
<message>
<location filename="../src/gui.cpp" line="161"/>
<source>About Qt</source>
<translation>O Qt</translation>
<location filename="../src/exportdialog.cpp" line="122"/>
<source>Export to PDF</source>
<translation>Exportovat do PDF</translation>
</message>
<message>
<location filename="../src/gui.cpp" line="380"/>
<source>GPXSee is distributed under the terms of the GNU General Public License version 3. For more info about GPXSee visit the project homepage at </source>
<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>
<location filename="../src/exportdialog.cpp" line="29"/>
<source>PDF files (*.pdf);;All files (*)</source>
<translation>Soubory PDF (*.pdf);;Všechny soubory (*)</translation>
</message>
<message>
<location filename="../src/gui.cpp" line="441"/>
<source>Open file</source>
<translation>Otevřít soubor</translation>
<location filename="../src/exportdialog.cpp" line="42"/>
<source>Portrait</source>
<translation>Na výšku</translation>
</message>
<message>
<location filename="../src/gui.cpp" line="175"/>
<source>Save as</source>
<translation>Uložit jako</translation>
<location filename="../src/exportdialog.cpp" line="43"/>
<source>Landscape</source>
<translation>Na šířku</translation>
</message>
<message>
<location filename="../src/gui.cpp" line="501"/>
<source>Open POI file</source>
<translation>Otevřít POI soubor</translation>
<location filename="../src/exportdialog.cpp" line="85"/>
<source>Page size:</source>
<translation>Velikost stránky:</translation>
</message>
<message>
<location filename="../src/gui.cpp" line="166"/>
<source>Open</source>
<translation>Otevřít</translation>
<location filename="../src/exportdialog.cpp" line="86"/>
<source>Orientation:</source>
<translation>Orientace:</translation>
</message>
<message>
<location filename="../src/gui.cpp" line="149"/>
<source>Quit</source>
<translation>Ukončit</translation>
<location filename="../src/exportdialog.cpp" line="82"/>
<source>Page Setup</source>
<translation>Nastavení stránky</translation>
</message>
<message>
<location filename="../src/gui.cpp" line="156"/>
<location filename="../src/gui.cpp" line="396"/>
<location filename="../src/gui.cpp" line="397"/>
<source>Keyboard controls</source>
<translation>Ovládací klávesy</translation>
<location filename="../src/exportdialog.cpp" line="55"/>
<source>in</source>
<translation>in</translation>
</message>
<message>
<location filename="../src/gui.cpp" line="170"/>
<source>Save</source>
<translation>Uložit</translation>
<location filename="../src/exportdialog.cpp" line="55"/>
<source>mm</source>
<translation>mm</translation>
</message>
<message>
<location filename="../src/gui.cpp" line="180"/>
<source>Close</source>
<translation>Zavřít</translation>
<location filename="../src/exportdialog.cpp" line="87"/>
<source>Margins:</source>
<translation>Okraje:</translation>
</message>
<message>
<location filename="../src/gui.cpp" line="185"/>
<source>Reload</source>
<translation>Znovu načíst</translation>
<location filename="../src/exportdialog.cpp" line="93"/>
<source>File:</source>
<translation>Soubor:</translation>
</message>
<message>
<location filename="../src/gui.cpp" line="317"/>
<source>Show</source>
<translation>Zobrazit</translation>
<location filename="../src/exportdialog.cpp" line="99"/>
<source>Output file</source>
<translation>Výstupní soubor</translation>
</message>
<message>
<location filename="../src/gui.cpp" line="262"/>
<location filename="../src/gui.cpp" line="308"/>
<source>File</source>
<translation>Soubor</translation>
<location filename="../src/exportdialog.cpp" line="106"/>
<source>Export</source>
<translation>Exportovat</translation>
</message>
<message>
<location filename="../src/gui.cpp" line="154"/>
<location filename="../src/gui.cpp" line="414"/>
<location filename="../src/gui.cpp" line="415"/>
<source>Data sources</source>
<translation>Zdroje dat</translation>
</message>
<message>
<location filename="../src/gui.cpp" line="192"/>
<source>Load POI file</source>
<translation>Nahrát POI soubor</translation>
</message>
<message>
<location filename="../src/gui.cpp" line="195"/>
<source>Close POI files</source>
<translation>Zavřit soubory POI</translation>
</message>
<message>
<location filename="../src/gui.cpp" line="198"/>
<source>Show POIs</source>
<translation>Zobrazit POI</translation>
</message>
<message>
<location filename="../src/gui.cpp" line="205"/>
<source>Show map</source>
<translation>Zobrazit mapu</translation>
</message>
<message>
<location filename="../src/gui.cpp" line="218"/>
<source>Show graphs</source>
<translation>Zobrazovat grafy</translation>
</message>
<message>
<location filename="../src/gui.cpp" line="224"/>
<source>Show toolbars</source>
<translation>Zobrazovat nástrojové lišty</translation>
</message>
<message>
<location filename="../src/gui.cpp" line="231"/>
<source>Metric</source>
<translation>Metrické</translation>
</message>
<message>
<location filename="../src/gui.cpp" line="237"/>
<source>Imperial</source>
<translation>Imperiální</translation>
</message>
<message>
<location filename="../src/gui.cpp" line="244"/>
<source>Next</source>
<translation>Následující</translation>
</message>
<message>
<location filename="../src/gui.cpp" line="247"/>
<source>Previous</source>
<translation>Předchozí</translation>
</message>
<message>
<location filename="../src/gui.cpp" line="251"/>
<source>Last</source>
<translation>Poslední</translation>
</message>
<message>
<location filename="../src/gui.cpp" line="254"/>
<source>First</source>
<translation>První</translation>
</message>
<message>
<location filename="../src/gui.cpp" line="276"/>
<source>Map</source>
<translation>Mapa</translation>
</message>
<message>
<location filename="../src/gui.cpp" line="281"/>
<source>POI</source>
<translation>POI</translation>
</message>
<message>
<location filename="../src/gui.cpp" line="282"/>
<source>POI files</source>
<translation>POI soubory</translation>
</message>
<message>
<location filename="../src/gui.cpp" line="290"/>
<source>Settings</source>
<translation>Nastavení</translation>
</message>
<message>
<location filename="../src/gui.cpp" line="291"/>
<source>Units</source>
<translation>Jednotky</translation>
</message>
<message>
<location filename="../src/gui.cpp" line="298"/>
<source>Help</source>
<translation>Nápověda</translation>
</message>
<message>
<location filename="../src/gui.cpp" line="348"/>
<source>Elevation</source>
<translation>Výška</translation>
</message>
<message>
<location filename="../src/gui.cpp" line="349"/>
<source>Speed</source>
<translation>Rychlost</translation>
</message>
<message>
<location filename="../src/gui.cpp" line="399"/>
<source>Next file</source>
<translation>Následující soubor</translation>
</message>
<message>
<location filename="../src/gui.cpp" line="400"/>
<source>Previous file</source>
<translation>Předchozí soubor</translation>
</message>
<message>
<location filename="../src/gui.cpp" line="402"/>
<source>First file</source>
<translation>První soubor</translation>
</message>
<message>
<location filename="../src/gui.cpp" line="403"/>
<source>Last file</source>
<translation>Poslední soubor</translation>
</message>
<message>
<location filename="../src/gui.cpp" line="404"/>
<source>Append modifier</source>
<translation>Modifikátor nahradit/přidat</translation>
</message>
<message>
<location filename="../src/gui.cpp" line="418"/>
<source>Map (tiles) source URLs are read on program startup from the following file:</source>
<translation>URL mapových zdrojů (dlaždic) jsou načteny při startu programu z následujícího souboru:</translation>
</message>
<message>
<location filename="../src/gui.cpp" line="422"/>
<source>The file format is one map entry per line, consisting of the map name and tiles URL delimited by a TAB character. The tile X and Y coordinates are replaced with $x and $y in the URL and the zoom level is replaced with $z. An example map file could look like:</source>
<translation>Formát souboru je jeden mapový záznam na řádku, kde mapový záznam sestává ze jména mapy a URL dlaždic navzájem oddělených tabulátorem. Souřadnice dlaždice jsou v URL nahrazeny řetězci $x a $y, úroven přiblížení (zoom) pak řetězcem $z. Příklad:</translation>
</message>
<message>
<location filename="../src/gui.cpp" line="430"/>
<source>To make GPXSee load a POI file automatically on startup, add the file to the following directory:</source>
<translation>POI soubory, které se mají automaticky nahrát při startu programu jsou načítány z následujícího adresáře:</translation>
</message>
<message>
<location filename="../src/gui.cpp" line="442"/>
<source>GPX files (*.gpx);;All files (*)</source>
<translation>soubory GPX (*.gpx);;všechny soubory (*)</translation>
</message>
<message>
<location filename="../src/gui.cpp" line="492"/>
<location filename="../src/gui.cpp" line="509"/>
<source>Line: %1</source>
<translation>Řádka: %1</translation>
</message>
<message>
<location filename="../src/gui.cpp" line="502"/>
<source>GPX files (*.gpx);;CSV files (*.csv);;All files (*)</source>
<translation>soubory GPX (*.gpx);;soubory CSV (*.csv);;všechny soubory (*)</translation>
</message>
<message>
<location filename="../src/gui.cpp" line="577"/>
<location filename="../src/gui.cpp" line="697"/>
<source>mi</source>
<translation>mi</translation>
</message>
<message>
<location filename="../src/gui.cpp" line="580"/>
<location filename="../src/gui.cpp" line="582"/>
<location filename="../src/gui.cpp" line="584"/>
<location filename="../src/gui.cpp" line="586"/>
<source>ft</source>
<translation>ft</translation>
</message>
<message>
<location filename="../src/gui.cpp" line="583"/>
<location filename="../src/gui.cpp" line="595"/>
<source>Maximum</source>
<translation>Maximum</translation>
</message>
<message>
<location filename="../src/gui.cpp" line="585"/>
<location filename="../src/gui.cpp" line="597"/>
<source>Minimum</source>
<translation>Minimum</translation>
</message>
<message>
<location filename="../src/gui.cpp" line="159"/>
<location filename="../src/gui.cpp" line="376"/>
<source>About GPXSee</source>
<translation>O aplikaci GPXSee</translation>
</message>
<message>
<location filename="../src/gui.cpp" line="324"/>
<source>Navigation</source>
<translation>Navigace</translation>
</message>
<message>
<location filename="../src/gui.cpp" line="378"/>
<source>GPX viewer and analyzer</source>
<translation>Prohlížeč a analyzátor GPX</translation>
</message>
<message>
<location filename="../src/gui.cpp" line="417"/>
<source>Map sources</source>
<translation>Mapové zdroje</translation>
</message>
<message>
<location filename="../src/gui.cpp" line="429"/>
<source>POIs</source>
<translation>POI body</translation>
</message>
<message>
<location filename="../src/gui.cpp" line="576"/>
<location filename="../src/gui.cpp" line="588"/>
<source>Distance</source>
<translation>Vzdálenost</translation>
</message>
<message>
<location filename="../src/gui.cpp" line="578"/>
<location filename="../src/gui.cpp" line="590"/>
<source>Time</source>
<translation>Čas</translation>
</message>
<message>
<location filename="../src/gui.cpp" line="579"/>
<location filename="../src/gui.cpp" line="591"/>
<source>Ascent</source>
<translation>Stoupání</translation>
</message>
<message>
<location filename="../src/gui.cpp" line="592"/>
<location filename="../src/gui.cpp" line="594"/>
<location filename="../src/gui.cpp" line="596"/>
<location filename="../src/gui.cpp" line="598"/>
<source>m</source>
<translation>m</translation>
</message>
<message>
<location filename="../src/gui.cpp" line="581"/>
<location filename="../src/gui.cpp" line="593"/>
<source>Descent</source>
<translation>Klesání</translation>
</message>
<message>
<location filename="../src/gui.cpp" line="693"/>
<source>%1 tracks</source>
<translation>Počet tras: %1</translation>
</message>
<message>
<location filename="../src/gui.cpp" line="589"/>
<location filename="../src/gui.cpp" line="700"/>
<source>km</source>
<translation>km</translation>
</message>
<message>
<location filename="../src/gui.cpp" line="494"/>
<location filename="../src/gui.cpp" line="510"/>
<location filename="../src/exportdialog.cpp" line="129"/>
<location filename="../src/exportdialog.cpp" line="139"/>
<location filename="../src/exportdialog.cpp" line="144"/>
<source>Error</source>
<translation>Chyba</translation>
</message>
<message>
<location filename="../src/gui.cpp" line="489"/>
<location filename="../src/exportdialog.cpp" line="129"/>
<source>No output file selected.</source>
<translation>Nebyl zvolen žádný výstupní soubor.</translation>
</message>
<message>
<location filename="../src/exportdialog.cpp" line="139"/>
<source>%1 is a directory.</source>
<translation>%1 je adresář.</translation>
</message>
<message>
<location filename="../src/exportdialog.cpp" line="144"/>
<source>%1 is not writable.</source>
<translation>%1 nelze zapsat.</translation>
</message>
</context>
<context>
<name>FileSelectWidget</name>
<message>
<location filename="../src/fileselectwidget.cpp" line="10"/>
<source>Browse...</source>
<translation>Procházet...</translation>
</message>
<message>
<location filename="../src/fileselectwidget.cpp" line="22"/>
<source>Select file</source>
<translation>Vybrat soubor</translation>
</message>
</context>
<context>
<name>GUI</name>
<message>
<location filename="../src/gui.cpp" line="458"/>
<source>GPXSee is distributed under the terms of the GNU General Public License version 3. For more info about GPXSee visit the project homepage at </source>
<translation>Program GPXSee je distribuován pod podmínkami licence GNU General Public License verze 3. Pro více informací navštivte stránky programu na adrese </translation>
</message>
<message>
<location filename="../src/gui.cpp" line="522"/>
<source>Open file</source>
<translation>Otevřít soubor</translation>
</message>
<message>
<location filename="../src/gui.cpp" line="599"/>
<source>Open POI file</source>
<translation>Otevřít POI soubor</translation>
</message>
<message>
<location filename="../src/gui.cpp" line="203"/>
<source>Open</source>
<translation>Otevřít</translation>
</message>
<message>
<location filename="../src/gui.cpp" line="187"/>
<source>Quit</source>
<translation>Ukončit</translation>
</message>
<message>
<location filename="../src/gui.cpp" line="195"/>
<location filename="../src/gui.cpp" line="474"/>
<location filename="../src/gui.cpp" line="475"/>
<source>Keyboard controls</source>
<translation>Ovládací klávesy</translation>
</message>
<message>
<location filename="../src/gui.cpp" line="219"/>
<source>Close</source>
<translation>Zavřít</translation>
</message>
<message>
<location filename="../src/gui.cpp" line="225"/>
<source>Reload</source>
<translation>Znovu načíst</translation>
</message>
<message>
<location filename="../src/gui.cpp" line="381"/>
<source>Show</source>
<translation>Zobrazit</translation>
</message>
<message>
<location filename="../src/gui.cpp" line="322"/>
<location filename="../src/gui.cpp" line="375"/>
<source>File</source>
<translation>Soubor</translation>
</message>
<message>
<location filename="../src/gui.cpp" line="193"/>
<location filename="../src/gui.cpp" line="497"/>
<location filename="../src/gui.cpp" line="498"/>
<source>Data sources</source>
<translation>Zdroje dat</translation>
</message>
<message>
<location filename="../src/gui.cpp" line="233"/>
<source>Load POI file</source>
<translation>Nahrát POI soubor</translation>
</message>
<message>
<location filename="../src/gui.cpp" line="236"/>
<source>Close POI files</source>
<translation>Zavřit POI soubory</translation>
</message>
<message>
<location filename="../src/gui.cpp" line="239"/>
<source>Show POIs</source>
<translation>Zobrazit POI</translation>
</message>
<message>
<location filename="../src/gui.cpp" line="247"/>
<source>Show map</source>
<translation>Zobrazit mapu</translation>
</message>
<message>
<location filename="../src/gui.cpp" line="253"/>
<source>Clear tile cache</source>
<translation>Vymazat mezipaměť dlaždic</translation>
</message>
<message>
<location filename="../src/gui.cpp" line="262"/>
<location filename="../src/gui.cpp" line="266"/>
<location filename="../src/gui.cpp" line="484"/>
<source>Next map</source>
<translation>Následující mapa</translation>
</message>
<message>
<location filename="../src/gui.cpp" line="273"/>
<source>Show graphs</source>
<translation>Zobrazovat grafy</translation>
</message>
<message>
<location filename="../src/gui.cpp" line="279"/>
<source>Show toolbars</source>
<translation>Zobrazovat nástrojové lišty</translation>
</message>
<message>
<location filename="../src/gui.cpp" line="285"/>
<source>Metric</source>
<translation>Metrické</translation>
</message>
<message>
<location filename="../src/gui.cpp" line="290"/>
<source>Imperial</source>
<translation>Imperiální</translation>
</message>
<message>
<location filename="../src/gui.cpp" line="296"/>
<source>Fullscreen mode</source>
<translation>Celoobrazovkový režim</translation>
</message>
<message>
<location filename="../src/gui.cpp" line="304"/>
<source>Next</source>
<translation>Následující</translation>
</message>
<message>
<location filename="../src/gui.cpp" line="307"/>
<source>Previous</source>
<translation>Předchozí</translation>
</message>
<message>
<location filename="../src/gui.cpp" line="311"/>
<source>Last</source>
<translation>Poslední</translation>
</message>
<message>
<location filename="../src/gui.cpp" line="314"/>
<source>First</source>
<translation>První</translation>
</message>
<message>
<location filename="../src/gui.cpp" line="336"/>
<source>Map</source>
<translation>Mapa</translation>
</message>
<message>
<location filename="../src/gui.cpp" line="343"/>
<source>POI</source>
<translation>POI</translation>
</message>
<message>
<location filename="../src/gui.cpp" line="344"/>
<source>POI files</source>
<translation>POI soubory</translation>
</message>
<message>
<location filename="../src/gui.cpp" line="352"/>
<source>Settings</source>
<translation>Nastavení</translation>
</message>
<message>
<location filename="../src/gui.cpp" line="353"/>
<source>Units</source>
<translation>Jednotky</translation>
</message>
<message>
<location filename="../src/gui.cpp" line="362"/>
<source>Help</source>
<translation>Nápověda</translation>
</message>
<message>
<location filename="../src/gui.cpp" line="486"/>
<source>Previous map</source>
<translation>Předchozí mapa</translation>
</message>
<message>
<location filename="../src/gui.cpp" line="684"/>
<location filename="../src/gui.cpp" line="687"/>
<source>Date</source>
<translation>Datum</translation>
</message>
<message>
<location filename="../src/gui.cpp" line="860"/>
<source>No GPX files loaded</source>
<translation>Nejsou načteny žádné GPX soubory</translation>
</message>
<message>
<location filename="../src/gui.cpp" line="420"/>
<source>Elevation</source>
<translation>Výška</translation>
</message>
<message>
<location filename="../src/gui.cpp" line="421"/>
<source>Speed</source>
<translation>Rychlost</translation>
</message>
<message>
<location filename="../src/gui.cpp" line="422"/>
<source>Heart rate</source>
<translation>Tep</translation>
</message>
<message>
<location filename="../src/gui.cpp" line="477"/>
<source>Next file</source>
<translation>Následující soubor</translation>
</message>
<message>
<location filename="../src/gui.cpp" line="454"/>
<source>Version </source>
<translation>Verze </translation>
</message>
<message>
<location filename="../src/gui.cpp" line="208"/>
<source>Print...</source>
<translation>Tisknout...</translation>
</message>
<message>
<location filename="../src/gui.cpp" line="213"/>
<source>Export to PDF...</source>
<translation>Exportovat do PDF...</translation>
</message>
<message>
<location filename="../src/gui.cpp" line="478"/>
<source>Previous file</source>
<translation>Předchozí soubor</translation>
</message>
<message>
<location filename="../src/gui.cpp" line="480"/>
<source>First file</source>
<translation>První soubor</translation>
</message>
<message>
<location filename="../src/gui.cpp" line="481"/>
<source>Last file</source>
<translation>Poslední soubor</translation>
</message>
<message>
<location filename="../src/gui.cpp" line="482"/>
<source>Append modifier</source>
<translation>Modifikátor nahradit/přidat</translation>
</message>
<message>
<location filename="../src/gui.cpp" line="501"/>
<source>Map (tiles) source URLs are read on program startup from the following file:</source>
<translation>URL mapových zdrojů (dlaždic) jsou načteny při startu programu z následujícího souboru:</translation>
</message>
<message>
<location filename="../src/gui.cpp" line="504"/>
<source>The file format is one map entry per line, consisting of the map name and tiles URL delimited by a TAB character. The tile X and Y coordinates are replaced with $x and $y in the URL and the zoom level is replaced with $z. An example map file could look like:</source>
<translation>Formát souboru je jeden mapový záznam na řádku, kde mapový záznam sestává ze jména mapy a URL dlaždic navzájem oddělených tabulátorem. Souřadnice dlaždice jsou v URL nahrazeny řetězci $x a $y, úroven přiblížení (zoom) pak řetězcem $z. Příklad:</translation>
</message>
<message>
<location filename="../src/gui.cpp" line="512"/>
<source>To make GPXSee load a POI file automatically on startup, add the file to the following directory:</source>
<translation>POI soubory, které se mají automaticky nahrát při startu programu jsou načítány z následujícího adresáře:</translation>
</message>
<message>
<location filename="../src/gui.cpp" line="523"/>
<source>GPX files (*.gpx);;All files (*)</source>
<translation>Soubory GPX (*.gpx);;Všechny soubory (*)</translation>
</message>
<message>
<location filename="../src/gui.cpp" line="590"/>
<location filename="../src/gui.cpp" line="616"/>
<source>Line: %1</source>
<translation>Řádka: %1</translation>
</message>
<message>
<location filename="../src/gui.cpp" line="600"/>
<source>GPX files (*.gpx);;CSV files (*.csv);;All files (*)</source>
<translation>Soubory GPX (*.gpx);;Soubory CSV (*.csv);;Všechny soubory (*)</translation>
</message>
<message>
<location filename="../src/gui.cpp" line="690"/>
<source>Tracks</source>
<translation>Počet tras</translation>
</message>
<message>
<location filename="../src/gui.cpp" line="696"/>
<location filename="../src/gui.cpp" line="875"/>
<source>mi</source>
<translation>mi</translation>
</message>
<message>
<location filename="../src/gui.cpp" line="872"/>
<source>ft</source>
<translation>ft</translation>
</message>
<message>
<location filename="../src/gui.cpp" line="198"/>
<location filename="../src/gui.cpp" line="452"/>
<source>About GPXSee</source>
<translation>O aplikaci GPXSee</translation>
</message>
<message>
<location filename="../src/gui.cpp" line="385"/>
<source>Navigation</source>
<translation>Navigace</translation>
</message>
<message>
<location filename="../src/gui.cpp" line="500"/>
<source>Map sources</source>
<translation>Mapové zdroje</translation>
</message>
<message>
<location filename="../src/gui.cpp" line="511"/>
<source>POIs</source>
<translation>POI body</translation>
</message>
<message>
<location filename="../src/gui.cpp" line="695"/>
<location filename="../src/gui.cpp" line="698"/>
<source>Distance</source>
<translation>Vzdálenost</translation>
</message>
<message>
<location filename="../src/gui.cpp" line="703"/>
<source>Time</source>
<translation>Čas</translation>
</message>
<message>
<location filename="../src/gui.cpp" line="879"/>
<source>m</source>
<translation>m</translation>
</message>
<message>
<location filename="../src/gui.cpp" line="867"/>
<source>%1 tracks</source>
<translation>Počet tras: %1</translation>
</message>
<message>
<location filename="../src/gui.cpp" line="699"/>
<location filename="../src/gui.cpp" line="882"/>
<source>km</source>
<translation>km</translation>
</message>
<message>
<location filename="../src/gui.cpp" line="592"/>
<location filename="../src/gui.cpp" line="617"/>
<source>Error</source>
<translation>Chyba</translation>
</message>
<message>
<location filename="../src/gui.cpp" line="587"/>
<source>Error loading GPX file:
%1</source>
<translation>Soubor GPX nelze otevřít:
%1</translation>
</message>
<message>
<location filename="../src/gui.cpp" line="506"/>
<location filename="../src/gui.cpp" line="613"/>
<source>Error loading POI file:
%1</source>
<translation>Soubor POI nelze otevřít:
@ -406,24 +516,72 @@
</message>
</context>
<context>
<name>QObject</name>
<name>HeartRateGraph</name>
<message>
<location filename="../src/scaleitem.cpp" line="83"/>
<source>mi</source>
<translation>mi</translation>
<location filename="../src/heartrategraph.cpp" line="10"/>
<source>Distance</source>
<translation>Vzdálenost</translation>
</message>
<message>
<location filename="../src/scaleitem.cpp" line="83"/>
<source>ft</source>
<translation>ft</translation>
<location filename="../src/heartrategraph.cpp" line="11"/>
<source>Heart rate</source>
<translation>Tep</translation>
</message>
<message>
<location filename="../src/scaleitem.cpp" line="85"/>
<location filename="../src/heartrategraph.cpp" line="78"/>
<source>km</source>
<translation>km</translation>
</message>
<message>
<location filename="../src/scaleitem.cpp" line="85"/>
<location filename="../src/heartrategraph.cpp" line="9"/>
<source>1/min</source>
<translation>1/min</translation>
</message>
<message>
<location filename="../src/heartrategraph.cpp" line="18"/>
<source>Average</source>
<translation>Průměr</translation>
</message>
<message>
<location filename="../src/heartrategraph.cpp" line="20"/>
<source>Maximum</source>
<translation>Maximum</translation>
</message>
<message>
<location filename="../src/heartrategraph.cpp" line="75"/>
<source>m</source>
<translation>m</translation>
</message>
<message>
<location filename="../src/heartrategraph.cpp" line="83"/>
<source>ft</source>
<translation>ft</translation>
</message>
<message>
<location filename="../src/heartrategraph.cpp" line="86"/>
<source>mi</source>
<translation>mi</translation>
</message>
</context>
<context>
<name>QObject</name>
<message>
<location filename="../src/scaleitem.cpp" line="81"/>
<source>mi</source>
<translation>mi</translation>
</message>
<message>
<location filename="../src/scaleitem.cpp" line="81"/>
<source>ft</source>
<translation>ft</translation>
</message>
<message>
<location filename="../src/scaleitem.cpp" line="83"/>
<source>km</source>
<translation>km</translation>
</message>
<message>
<location filename="../src/scaleitem.cpp" line="83"/>
<source>m</source>
<translation>m</translation>
</message>
@ -431,44 +589,52 @@
<context>
<name>SpeedGraph</name>
<message>
<location filename="../src/speedgraph.cpp" line="10"/>
<location filename="../src/speedgraph.cpp" line="11"/>
<source>Distance</source>
<translation>Vzdálenost</translation>
</message>
<message>
<location filename="../src/speedgraph.cpp" line="11"/>
<location filename="../src/speedgraph.cpp" line="12"/>
<source>Speed</source>
<translation>Rychlost</translation>
</message>
<message>
<location filename="../src/speedgraph.cpp" line="12"/>
<location filename="../src/speedgraph.cpp" line="73"/>
<location filename="../src/speedgraph.cpp" line="72"/>
<source>m</source>
<translation>m</translation>
</message>
<message>
<location filename="../src/speedgraph.cpp" line="75"/>
<source>km</source>
<translation></translation>
</message>
<message>
<location filename="../src/speedgraph.cpp" line="13"/>
<location filename="../src/speedgraph.cpp" line="74"/>
<location filename="../src/speedgraph.cpp" line="80"/>
<source>ft</source>
<translation>ft</translation>
</message>
<message>
<location filename="../src/speedgraph.cpp" line="92"/>
<source>km/h</source>
<translation>km/h</translation>
</message>
<message>
<location filename="../src/speedgraph.cpp" line="21"/>
<location filename="../src/speedgraph.cpp" line="19"/>
<source>Average</source>
<translation>Průměr</translation>
</message>
<message>
<location filename="../src/speedgraph.cpp" line="23"/>
<location filename="../src/speedgraph.cpp" line="21"/>
<source>Maximum</source>
<translation>Maximum</translation>
</message>
<message>
<location filename="../src/speedgraph.cpp" line="78"/>
<location filename="../src/speedgraph.cpp" line="83"/>
<source>mi</source>
<translation>mi</translation>
</message>
<message>
<location filename="../src/speedgraph.cpp" line="79"/>
<location filename="../src/speedgraph.cpp" line="95"/>
<source>mi/h</source>
<translation>mi/h</translation>
</message>

View File

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

176
pkg/gpxsee64.nsi Normal file
View File

@ -0,0 +1,176 @@
!include "MUI2.nsh"
!include "x64.nsh"
; The name of the installer
Name "GPXSee"
; Program version
!define VERSION "2.14"
; The file to write
OutFile "GPXSee-${VERSION}_x64.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" "${VERSION}"
WriteRegStr HKLM "${REGENTRY}" "UninstallString" '"$INSTDIR\uninstall.exe"'
WriteRegDWORD HKLM "${REGENTRY}" "NoModify" 1
WriteRegDWORD HKLM "${REGENTRY}" "NoRepair" 1
WriteUninstaller "$INSTDIR\uninstall.exe"
; Create start menu entry and add links
SetShellVarContext all
!insertmacro MUI_STARTMENU_WRITE_BEGIN Application
CreateDirectory "$SMPROGRAMS\$StartMenuFolder"
CreateShortCut "$SMPROGRAMS\$StartMenuFolder\Uninstall.lnk" "$INSTDIR\Uninstall.exe"
CreateShortCut "$SMPROGRAMS\$StartMenuFolder\GPXSee.lnk" "$INSTDIR\gpxsee.exe"
!insertmacro MUI_STARTMENU_WRITE_END
; Associate .gpx files
WriteRegStr HKCR ".gpx" "" "${REGGPX}"
WriteRegStr HKCR "${REGGPX}" "" "GPS Exchange Format"
WriteRegStr HKCR "${REGGPX}\DefaultIcon" "" "$INSTDIR\GPXSee.exe,1"
WriteRegStr HKCR "${REGGPX}\shell\open\command" "" "$\"$INSTDIR\GPXSee.exe$\" $\"%1$\""
System::Call 'shell32.dll::SHChangeNotify(i, i, i, i) v (0x08000000, 0, 0, 0)'
SectionEnd
Section "QT libs" SEC_QT
File "Qt5Core.dll"
File "Qt5Gui.dll"
File "Qt5Widgets.dll"
File "Qt5PrintSupport.dll"
File "Qt5Network.dll"
File "libGLESv2.dll"
File /r "platforms"
File /r "imageformats"
SectionEnd
Section "MSVC runtime" SEC_MSVC
DetailPrint "Checking whether Visual C++ 2015 Redistributable is already installed..."
ReadRegDword $R0 HKLM "SOFTWARE\Wow6432Node\Microsoft\VisualStudio\14.0\VC\Runtimes\x64" "Installed"
StrCmp $R0 "1" 0 +3
DetailPrint "Visual C++ 2015 Redistributable is already installed, skipping install."
Goto done
DetailPrint "Installing Visual C++ 2015 Redistributable..."
SetOutPath $TEMP
File "VC_redist.x64.exe"
ExecWait '"$TEMP/VC_redist.x64.exe" /install /quiet /norestart'
done:
SectionEnd
;--------------------------------
; Uninstaller
Section "Uninstall"
; Remove registry keys
SetRegView 64
DeleteRegKey HKLM "${REGENTRY}"
DeleteRegKey HKLM SOFTWARE\GPXSee
; Remove directories used
RMDir /r "$INSTDIR"
; Remove Start menu entries
SetShellVarContext all
!insertmacro MUI_STARTMENU_GETFOLDER Application $StartMenuFolder
Delete "$SMPROGRAMS\$StartMenuFolder\*.*"
RMDir "$SMPROGRAMS\$StartMenuFolder"
; Remove GPX file association
DeleteRegKey HKCR "${REGGPX}"
DeleteRegKey HKCR ".gpx"
System::Call 'shell32.dll::SHChangeNotify(i, i, i, i) v (0x08000000, 0, 0, 0)'
SectionEnd
;-------------------------------
;Descriptions
;Language strings
LangString DESC_QT ${LANG_ENGLISH} \
"QT Library. Unselct only if you have QT already installed!"
LangString DESC_MSVC ${LANG_ENGLISH} \
"Visual C++ 2015 runtime components. Unselct only if you have the runtime already installed!"
LangString DESC_APP ${LANG_ENGLISH} \
"GPXSee application"
;Assign language strings to sections
!insertmacro MUI_FUNCTION_DESCRIPTION_BEGIN
!insertmacro MUI_DESCRIPTION_TEXT ${SEC_QT} $(DESC_QT)
!insertmacro MUI_DESCRIPTION_TEXT ${SEC_MSVC} $(DESC_MSVC)
!insertmacro MUI_DESCRIPTION_TEXT ${SEC_APP} $(DESC_APP)
!insertmacro MUI_FUNCTION_DESCRIPTION_END

48
src/app.cpp Normal file
View File

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

28
src/app.h Normal file
View File

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

View File

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

View File

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

View File

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

42
src/cpuarch.h Normal file
View File

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

View File

@ -14,7 +14,8 @@
#define PLATFORM_STR "Unknown"
#endif
#define USER_AGENT APP_NAME"/"APP_VERSION" ("PLATFORM_STR"; Qt "QT_VERSION_STR")"
#define USER_AGENT \
APP_NAME "/" APP_VERSION " (" PLATFORM_STR "; Qt " QT_VERSION_STR ")"
Downloader::Downloader()
{
@ -22,12 +23,12 @@ Downloader::Downloader()
SLOT(downloadFinished(QNetworkReply*)));
}
void Downloader::doDownload(const Download &dl)
bool Downloader::doDownload(const Download &dl)
{
QUrl url(dl.url());
if (_errorDownloads.contains(url))
return;
return false;
QNetworkRequest request(url);
request.setAttribute(QNetworkRequest::User, QVariant(dl.file()));
@ -35,6 +36,8 @@ void Downloader::doDownload(const Download &dl)
QNetworkReply *reply = _manager.get(request);
_currentDownloads.append(reply);
return true;
}
bool Downloader::saveToDisk(const QString &filename, QIODevice *data)
@ -73,8 +76,12 @@ void Downloader::downloadFinished(QNetworkReply *reply)
emit finished();
}
void Downloader::get(const QList<Download> &list)
bool Downloader::get(const QList<Download> &list)
{
bool finishEmitted = false;
for (int i = 0; i < list.count(); i++)
doDownload(list.at(i));
finishEmitted |= doDownload(list.at(i));
return finishEmitted;
}

View File

@ -30,7 +30,7 @@ class Downloader : public QObject
public:
static Downloader& instance()
{static Downloader i; return i;}
void get(const QList<Download> &list);
bool get(const QList<Download> &list);
signals:
void finished();
@ -43,7 +43,7 @@ private:
Downloader(Downloader const&);
void operator=(Downloader const&);
void doDownload(const Download &dl);
bool doDownload(const Download &dl);
bool saveToDisk(const QString &filename, QIODevice *data);
QNetworkAccessManager _manager;

View File

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

View File

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

174
src/exportdialog.cpp Normal file
View File

@ -0,0 +1,174 @@
#include <QVBoxLayout>
#include <QHBoxLayout>
#include <QFormLayout>
#include <QGridLayout>
#include <QDialogButtonBox>
#include <QGroupBox>
#include <QComboBox>
#include <QRadioButton>
#include <QPushButton>
#include <QFileInfo>
#include <QMessageBox>
#include <QTabWidget>
#include <QDoubleSpinBox>
#include <QLocale>
#include "fileselectwidget.h"
#include "units.h"
#include "exportdialog.h"
ExportDialog::ExportDialog(QPrinter *printer, QWidget *parent)
: QDialog(parent), _printer(printer)
{
int index;
_units = (QLocale::system().measurementSystem()
== QLocale::ImperialSystem) ? QPrinter::Inch : QPrinter::Millimeter;
_fileSelect = new FileSelectWidget();
_fileSelect->setFilter(tr("PDF files (*.pdf);;All files (*)"));
_fileSelect->setFile(_printer->outputFileName());
_paperSize = new QComboBox();
_paperSize->addItem("A3", QPrinter::A3);
_paperSize->addItem("A4", QPrinter::A4);
_paperSize->addItem("A5", QPrinter::A5);
_paperSize->addItem("Tabloid", QPrinter::Tabloid);
_paperSize->addItem("Legal", QPrinter::Legal);
_paperSize->addItem("Letter", QPrinter::Letter);
if ((index = _paperSize->findData(_printer->paperSize())) >= 0)
_paperSize->setCurrentIndex(index);
_portrait = new QRadioButton(tr("Portrait"));
_landscape = new QRadioButton(tr("Landscape"));
QHBoxLayout *orientationLayout = new QHBoxLayout();
orientationLayout->addWidget(_portrait);
orientationLayout->addWidget(_landscape);
if (_printer->orientation() == QPrinter::Portrait)
_portrait->setChecked(true);
else
_landscape->setChecked(true);
qreal top, bottom, left, right;
_printer->getPageMargins(&left, &top, &right, &bottom, _units);
QString us = _units == QPrinter::Inch ? tr("in") : tr("mm");
_topMargin = new QDoubleSpinBox();
_bottomMargin = new QDoubleSpinBox();
_leftMargin = new QDoubleSpinBox();
_rightMargin = new QDoubleSpinBox();
_topMargin->setValue(top);
_topMargin->setSuffix(UNIT_SPACE + us);
_bottomMargin->setValue(bottom);
_bottomMargin->setSuffix(UNIT_SPACE + us);
_leftMargin->setValue(left);
_leftMargin->setSuffix(UNIT_SPACE + us);
_rightMargin->setValue(right);
_rightMargin->setSuffix(UNIT_SPACE + us);
if (_units == QPrinter::Inch) {
_topMargin->setSingleStep(0.1);
_bottomMargin->setSingleStep(0.1);
_leftMargin->setSingleStep(0.1);
_rightMargin->setSingleStep(0.1);
}
QGridLayout *marginsLayout = new QGridLayout();
marginsLayout->addWidget(_topMargin, 0, 0, 1, 2, Qt::AlignCenter);
marginsLayout->addWidget(_leftMargin, 1, 0, 1, 1, Qt::AlignRight);
marginsLayout->addWidget(_rightMargin, 1, 1, 1, 1, Qt::AlignLeft);
marginsLayout->addWidget(_bottomMargin, 2, 0, 1, 2, Qt::AlignCenter);
#ifndef Q_OS_MAC
QGroupBox *pageSetupBox = new QGroupBox(tr("Page Setup"));
#endif // Q_OS_MAC
QFormLayout *pageSetupLayout = new QFormLayout;
pageSetupLayout->addRow(tr("Page size:"), _paperSize);
pageSetupLayout->addRow(tr("Orientation:"), orientationLayout);
pageSetupLayout->addRow(tr("Margins:"), marginsLayout);
#ifdef Q_OS_MAC
QFrame *line = new QFrame();
line->setFrameShape(QFrame::HLine);
line->setFrameShadow(QFrame::Sunken);
pageSetupLayout->addRow(line);
pageSetupLayout->addRow(tr("File:"), _fileSelect);
#else // Q_OS_MAC
pageSetupBox->setLayout(pageSetupLayout);
#endif // Q_OS_MAC
#ifndef Q_OS_MAC
QGroupBox *outputFileBox = new QGroupBox(tr("Output file"));
QHBoxLayout *outputFileLayout = new QHBoxLayout();
outputFileLayout->addWidget(_fileSelect);
outputFileBox->setLayout(outputFileLayout);
#endif // Q_OS_MAC
QDialogButtonBox *buttonBox = new QDialogButtonBox();
buttonBox->addButton(tr("Export"), QDialogButtonBox::AcceptRole);
buttonBox->addButton(QDialogButtonBox::Cancel);
connect(buttonBox, SIGNAL(accepted()), this, SLOT(accept()));
connect(buttonBox, SIGNAL(rejected()), this, SLOT(reject()));
QVBoxLayout *layout = new QVBoxLayout;
#ifdef Q_OS_MAC
layout->addLayout(pageSetupLayout);
#else // Q_OS_MAC
layout->addWidget(pageSetupBox);
layout->addWidget(outputFileBox);
#endif // Q_OS_MAC
layout->addWidget(buttonBox);
setLayout(layout);
setWindowTitle(tr("Export to PDF"));
setWindowFlags(windowFlags() & ~Qt::WindowContextHelpButtonHint);
}
bool ExportDialog::checkFile()
{
if (_fileSelect->file().isEmpty()) {
QMessageBox::warning(this, tr("Error"), tr("No output file selected."));
return false;
}
QFile file(_fileSelect->file());
QFileInfo fi(file);
bool exists = fi.exists();
bool opened = false;
if (exists && fi.isDir()) {
QMessageBox::warning(this, tr("Error"), tr("%1 is a directory.")
.arg(file.fileName()));
return false;
} else if ((exists && !fi.isWritable())
|| !(opened = file.open(QFile::Append))) {
QMessageBox::warning(this, tr("Error"), tr("%1 is not writable.")
.arg(file.fileName()));
return false;
}
if (opened) {
file.close();
if (!exists)
file.remove();
}
return true;
}
void ExportDialog::accept()
{
if (!checkFile())
return;
QPrinter::Orientation orientation = _portrait->isChecked()
? QPrinter::Portrait : QPrinter::Landscape;
QPrinter::PaperSize paperSize = static_cast<QPrinter::PaperSize>
(_paperSize->itemData(_paperSize->currentIndex()).toInt());
_printer->setOutputFormat(QPrinter::PdfFormat);
_printer->setOutputFileName(_fileSelect->file());
_printer->setPaperSize(paperSize);
_printer->setOrientation(orientation);
_printer->setPageMargins(_leftMargin->value(), _topMargin->value(),
_rightMargin->value(), _bottomMargin->value(), _units);
QDialog::accept();
}

39
src/exportdialog.h Normal file
View File

@ -0,0 +1,39 @@
#ifndef EXPORTDIALOG_H
#define EXPORTDIALOG_H
#include <QDialog>
#include <QPrinter>
class QComboBox;
class QRadioButton;
class FileSelectWidget;
class QDoubleSpinBox;
class ExportDialog : public QDialog
{
Q_OBJECT
public:
ExportDialog(QPrinter *printer, QWidget *parent = 0);
public slots:
void accept();
private:
bool checkFile();
QPrinter *_printer;
QPrinter::Unit _units;
FileSelectWidget *_fileSelect;
QComboBox *_paperSize;
QRadioButton *_portrait;
QRadioButton *_landscape;
QDoubleSpinBox *_topMargin;
QDoubleSpinBox *_bottomMargin;
QDoubleSpinBox *_leftMargin;
QDoubleSpinBox *_rightMargin;
};
#endif // EXPORTDIALOG_H

33
src/fileselectwidget.cpp Normal file
View File

@ -0,0 +1,33 @@
#include <QPushButton>
#include <QFileDialog>
#include <QHBoxLayout>
#include <QFileInfo>
#include <QApplication>
#include <QFontMetrics>
#include "fileselectwidget.h"
FileSelectWidget::FileSelectWidget(QWidget *parent) : QWidget(parent)
{
QFontMetrics fm(QApplication::font());
_edit = new QLineEdit();
_edit->setMinimumWidth(fm.boundingRect(QDir::homePath()).width());
_button = new QPushButton(tr("Browse..."));
connect(_button, SIGNAL(clicked()), this, SLOT(browse()));
QHBoxLayout *layout = new QHBoxLayout();
layout->setMargin(0);
layout->addWidget(_edit);
layout->addWidget(_button);
setLayout(layout);
}
void FileSelectWidget::browse()
{
QFileInfo fi(_edit->text());
QString fileName = QFileDialog::getSaveFileName(this, tr("Select file"),
fi.dir().absolutePath(), _filter);
if (!fileName.isEmpty())
_edit->setText(fileName);
}

30
src/fileselectwidget.h Normal file
View File

@ -0,0 +1,30 @@
#ifndef FILESELECTWIDGET_H
#define FILESELECTWIDGET_H
#include <QWidget>
#include <QLineEdit>
class QPushButton;
class FileSelectWidget : public QWidget
{
Q_OBJECT
public:
FileSelectWidget(QWidget *parent = 0);
QString file() {return _edit->text();}
void setFile(const QString &file) {_edit->setText(file);}
void setFilter(const QString &filter) {_filter = filter;}
private slots:
void browse();
private:
QLineEdit *_edit;
QPushButton *_button;
QString _filter;
};
#endif // FILESELECTWIDGET_H

View File

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

View File

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

File diff suppressed because it is too large Load Diff

View File

@ -4,7 +4,10 @@
#include <QMainWindow>
#include <QString>
#include <QList>
#include <QDate>
#include <QPrinter>
#include "poi.h"
#include "margins.h"
class QMenu;
class QToolBar;
@ -13,9 +16,12 @@ class QActionGroup;
class QAction;
class QLabel;
class QSignalMapper;
class QPrinter;
class FileBrowser;
class GraphView;
class ElevationGraph;
class SpeedGraph;
class HeartRateGraph;
class TrackView;
class Map;
@ -25,6 +31,7 @@ class GUI : public QMainWindow
public:
GUI(QWidget *parent = 0);
~GUI();
bool openFile(const QString &fileName);
@ -32,10 +39,10 @@ private slots:
void about();
void keys();
void dataSources();
void saveFile();
void saveAs();
void printFile();
void exportFile();
void openFile();
void closeFile();
void closeAll();
void reloadFile();
void openPOIFile();
void closePOIFiles();
@ -43,6 +50,10 @@ private slots:
void showMap(bool checked);
void showGraphs(bool checked);
void showToolbars(bool checked);
void showFullscreen(bool checked);
void clearMapCache();
void nextMap();
void prevMap();
void mapChanged(int);
void graphChanged(int);
@ -56,8 +67,16 @@ private slots:
void setMetricUnits();
void setImperialUnits();
void sliderPositionChanged(qreal pos);
private:
void loadFiles();
typedef QPair<GraphView *, QString> GraphTab;
typedef QPair<QDate, QDate> DateRange;
void loadMaps();
void loadPOIs();
void closeFiles();
void plot(QPrinter *printer);
QAction *createPOIFileAction(int index);
void createPOIFilesActions();
@ -69,12 +88,21 @@ private:
void createTrackView();
void createTrackGraphs();
bool openPOIFile(const QString &fileName);
bool loadFile(const QString &fileName);
void saveFile(const QString &fileName);
void exportFile(const QString &fileName);
void updateStatusBarInfo();
void updateWindowTitle();
void updateNavigationActions();
void updateGraphTabs();
void updateTrackView();
void keyPressEvent(QKeyEvent * event);
void closeEvent(QCloseEvent *event);
int mapIndex(const QString &name);
void readSettings();
void writeSettings();
QMenu *_fileMenu;
QMenu *_helpMenu;
@ -96,8 +124,8 @@ private:
QAction *_dataSourcesAction;
QAction *_aboutAction;
QAction *_aboutQtAction;
QAction *_saveFileAction;
QAction *_saveAsAction;
QAction *_printFileAction;
QAction *_exportFileAction;
QAction *_openFileAction;
QAction *_closeFileAction;
QAction *_reloadFileAction;
@ -105,6 +133,8 @@ private:
QAction *_closePOIAction;
QAction *_showPOIAction;
QAction *_showMapAction;
QAction *_fullscreenAction;
QAction *_clearMapCacheAction;
QAction *_showGraphsAction;
QAction *_showToolbarsAction;
QAction *_nextAction;
@ -113,6 +143,8 @@ private:
QAction *_firstAction;
QAction *_metricUnitsAction;
QAction *_imperialUnitsAction;
QAction *_nextMapAction;
QAction *_prevMapAction;
QList<QAction*> _mapActions;
QList<QAction*> _poiFilesActions;
@ -122,21 +154,33 @@ private:
QLabel *_distanceLabel;
QLabel *_timeLabel;
TrackView *_track;
ElevationGraph *_elevationGraph;
SpeedGraph *_speedGraph;
TrackView *_track;
HeartRateGraph *_heartRateGraph;
QList<GraphTab> _tabs;
POI _poi;
QList<Map*> _maps;
FileBrowser *_browser;
QList<QString> _files;
QString _saveFileName;
Map *_currentMap;
int _trackCount;
qreal _distance;
qreal _time;
int _trackCount;
DateRange _dateRange;
qreal _sliderPos;
int _frameStyle;
bool _showGraphs;
QString _exportFileName;
QPrinter::PaperSize _exportPaperSize;
QPrinter::Orientation _exportOrientation;
MarginsF _exportMargins;
};
#endif // GUI_H

99
src/heartrategraph.cpp Normal file
View File

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

31
src/heartrategraph.h Normal file
View File

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

View File

@ -1,12 +1,10 @@
#ifndef ICONS_H
#define ICONS_H
#include <QtGlobal>
#define APP_ICON ":/icons/gpxsee.png"
#define OPEN_FILE_ICON ":/icons/document-open.png"
#define SAVE_FILE_ICON ":/icons/document-save.png"
#define SAVE_AS_ICON ":/icons/document-save-as.png"
#define EXPORT_FILE_ICON ":/icons/document-export.png"
#define PRINT_FILE_ICON ":/icons/document-print.png"
#define CLOSE_FILE_ICON ":/icons/dialog-close.png"
#define SHOW_POI_ICON ":/icons/flag.png"
#define SHOW_MAP_ICON ":/icons/applications-internet.png"
@ -16,11 +14,6 @@
#define PREV_FILE_ICON ":/icons/arrow-left.png"
#define LAST_FILE_ICON ":/icons/arrow-right-double.png"
#define FIRST_FILE_ICON ":/icons/arrow-left-double.png"
#if QT_VERSION < QT_VERSION_CHECK(5, 0, 0)
#define QT_ICON ":/trolltech/qmessagebox/images/qtlogo-64.png"
#else
#define QT_ICON ":/qt-project.org/qmessagebox/images/qtlogo-64.png"
#endif
#define FULLSCREEN_ICON ":/icons/view-fullscreen.png"
#endif /* ICONS_H */

View File

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

View File

@ -15,6 +15,7 @@ public:
void insert(const QString &key, const QString &value);
void clear();
bool isEmpty() {return _list.isEmpty();}
private:
void updateBoundingRect();

View File

@ -1,10 +1,29 @@
#ifndef KEYS_H
#define KEYS_H
#define NEXT_KEY Qt::Key_Space
#define PREV_KEY Qt::Key_Backspace
#define FIRST_KEY Qt::Key_Home
#define LAST_KEY Qt::Key_End
#define MODIFIER Qt::ShiftModifier
#include <Qt>
#include <QKeySequence>
#define NEXT_KEY Qt::Key_Space
#define PREV_KEY Qt::Key_Backspace
#define FIRST_KEY Qt::Key_Home
#define LAST_KEY Qt::Key_End
#define MODIFIER Qt::ShiftModifier
#define QUIT_SHORTCUT QKeySequence::Quit
#define OPEN_SHORTCUT QKeySequence::Open
#define CLOSE_SHORTCUT QKeySequence::Close
#define RELOAD_SHORTCUT QKeySequence::Refresh
#define EXPORT_SHORTCUT QKeySequence(Qt::CTRL + Qt::Key_E)
#define SHOW_POI_SHORTCUT QKeySequence(Qt::CTRL + Qt::Key_P)
#define SHOW_MAP_SHORTCUT QKeySequence(Qt::CTRL + Qt::Key_M)
#define NEXT_MAP_SHORTCUT QKeySequence::Forward
#define PREV_MAP_SHORTCUT QKeySequence::Back
#define SHOW_GRAPHS_SHORTCUT QKeySequence(Qt::CTRL + Qt::Key_G)
#ifdef Q_OS_MAC
#define FULLSCREEN_SHORTCUT QKeySequence(Qt::META + Qt::CTRL + Qt::Key_F)
#else // Q_OS_MAC
#define FULLSCREEN_SHORTCUT QKeySequence(Qt::Key_F11)
#endif // Q_OS_MAC
#endif // KEYS_H

View File

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

View File

@ -15,8 +15,8 @@ Map::Map(QObject *parent, const QString &name, const QString &url)
connect(&Downloader::instance(), SIGNAL(finished()), this,
SLOT(emitLoaded()));
QString path = QString(TILES_DIR"/") + _name;
if (!QDir::home().mkpath(path))
QString path = TILES_DIR + QString("/") + _name;
if (!QDir().mkpath(path))
fprintf(stderr, "Error creating tiles dir: %s\n", qPrintable(path));
}
@ -25,33 +25,108 @@ void Map::emitLoaded()
emit loaded();
}
void Map::loadTiles(QList<Tile> &list)
void Map::loadTiles(QList<Tile> &list, bool block)
{
if (block)
loadTilesSync(list);
else
loadTilesAsync(list);
}
void Map::loadTilesAsync(QList<Tile> &list)
{
QList<Download> dl;
for (int i = 0; i < list.size(); ++i) {
for (int i = 0; i < list.size(); i++) {
Tile &t = list[i];
QString file = QString("%1/" TILES_DIR "/%2/%3-%4-%5")
.arg(QDir::homePath()).arg(_name).arg(t.zoom()).arg(t.xy().rx())
.arg(t.xy().ry());
QString file = tileFile(t);
QFileInfo fi(file);
if (fi.exists()) {
if (!t.pixmap().load(file))
fprintf(stderr, "Error loading map tile: %s\n",
qPrintable(file));
} else {
t.pixmap() = QPixmap(TILE_SIZE, TILE_SIZE);
t.pixmap().fill();
QString url(_url);
url.replace("$z", QString::number(t.zoom()));
url.replace("$x", QString::number(t.xy().x()));
url.replace("$y", QString::number(t.xy().y()));
dl.append(Download(url, file));
if (!(fi.exists() && loadTileFile(t, file))) {
fillTile(t);
dl.append(Download(tileUrl(t), file));
}
}
if (!dl.empty())
Downloader::instance().get(dl);
}
void Map::loadTilesSync(QList<Tile> &list)
{
QList<Download> dl;
for (int i = 0; i < list.size(); i++) {
Tile &t = list[i];
QString file = tileFile(t);
QFileInfo fi(file);
if (!(fi.exists() && loadTileFile(t, file)))
dl.append(Download(tileUrl(t), file));
}
if (dl.empty())
return;
QEventLoop wait;
connect(&Downloader::instance(), SIGNAL(finished()), &wait, SLOT(quit()));
if (Downloader::instance().get(dl))
wait.exec();
for (int i = 0; i < list.size(); i++) {
Tile &t = list[i];
if (t.pixmap().isNull()) {
QString file = tileFile(t);
QFileInfo fi(file);
if (!(fi.exists() && loadTileFile(t, file)))
fillTile(t);
}
}
}
void Map::fillTile(Tile &tile)
{
tile.pixmap() = QPixmap(TILE_SIZE, TILE_SIZE);
tile.pixmap().fill();
}
bool Map::loadTileFile(Tile &tile, const QString &file)
{
if (!tile.pixmap().load(file)) {
fprintf(stderr, "%s: error loading tile file\n", qPrintable(file));
return false;
}
return true;
}
QString Map::tileUrl(const Tile &tile)
{
QString url(_url);
url.replace("$z", QString::number(tile.zoom()));
url.replace("$x", QString::number(tile.xy().x()));
url.replace("$y", QString::number(tile.xy().y()));
return url;
}
QString Map::tileFile(const Tile &tile)
{
QString file = TILES_DIR + QString("/%1/%2-%3-%4").arg(_name)
.arg(tile.zoom()).arg(tile.xy().x()).arg(tile.xy().y());
return file;
}
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

@ -10,7 +10,7 @@ public:
{_xy = xy; _zoom = zoom;}
int zoom() const {return _zoom;}
QPoint& xy() {return _xy;}
const QPoint& xy() const {return _xy;}
QPixmap& pixmap() {return _pixmap;}
private:
@ -24,20 +24,29 @@ class Map : public QObject
{
Q_OBJECT
signals:
void loaded();
public:
Map(QObject *parent = 0, const QString &name = QString(),
const QString &url = QString());
const QString &name() const {return _name;}
void loadTiles(QList<Tile> &list);
void loadTiles(QList<Tile> &list, bool block);
void clearCache();
signals:
void loaded();
private slots:
void emitLoaded();
private:
QString tileUrl(const Tile &tile);
QString tileFile(const Tile &tile);
bool loadTileFile(Tile &tile, const QString &file);
void fillTile(Tile &tile);
void loadTilesAsync(QList<Tile> &list);
void loadTilesSync(QList<Tile> &list);
QString _name;
QString _url;
};

9
src/margins.cpp Normal file
View File

@ -0,0 +1,9 @@
#include "margins.h"
QDebug operator<<(QDebug dbg, const MarginsF &margins)
{
dbg.nospace() << "MarginsF(" << margins.left() << ", " << margins.top()
<< ", " << margins.right() << margins.bottom() << ")";
return dbg.maybeSpace();
}

30
src/margins.h Normal file
View File

@ -0,0 +1,30 @@
#ifndef MARGINS_H
#define MARGINS_H
#include <QtGlobal>
#include <QDebug>
class MarginsF
{
public:
MarginsF() {_left = 0; _top = 0; _right = 0; _bottom = 0;}
MarginsF(qreal left, qreal top, qreal right, qreal bottom)
{_left = left, _top = top; _right = right; _bottom = bottom;}
qreal left() const {return _left;}
qreal top() const {return _top;}
qreal right() const {return _right;}
qreal bottom() const {return _bottom;}
qreal &rleft() {return _left;}
qreal &rtop() {return _top;}
qreal &rright() {return _right;}
qreal &rbottom() {return _bottom;}
private:
qreal _left, _top, _right, _bottom;
};
QDebug operator<<(QDebug dbg, const MarginsF &margins);
#endif // MARGINS_H

View File

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

View File

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

15
src/range.cpp Normal file
View File

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

25
src/range.h Normal file
View File

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

View File

@ -67,14 +67,12 @@ void ScaleItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *option,
for (int i = 0; i < SEGMENTS; i += 2)
painter->fillRect(QRectF(i * _width, br.height() + PADDING, _width,
SCALE_HEIGHT), Qt::black);
if (aa)
painter->setRenderHint(QPainter::Antialiasing, true);
/*
painter->setPen(Qt::red);
painter->drawRect(boundingRect());
*/
if (aa)
painter->setRenderHint(QPainter::Antialiasing, true);
}
QString ScaleItem::units() const
@ -114,24 +112,24 @@ void ScaleItem::computeScale()
void ScaleItem::setLatitude(qreal lat)
{
prepareGeometryChange();
_lat = lat;
computeScale();
updateBoundingRect();
prepareGeometryChange();
}
void ScaleItem::setZoom(int z)
{
prepareGeometryChange();
_zoom = z;
computeScale();
updateBoundingRect();
prepareGeometryChange();
}
void ScaleItem::setUnits(enum Units units)
{
prepareGeometryChange();
_units = units;
computeScale();
updateBoundingRect();
prepareGeometryChange();
}

22
src/settings.h Normal file
View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

40
src/trackinfo.cpp Normal file
View File

@ -0,0 +1,40 @@
#include <QPaintEngine>
#include <QPaintDevice>
#include "config.h"
#include "infoitem.h"
#include "trackinfo.h"
TrackInfo::TrackInfo(QObject *parent) : QGraphicsScene(parent)
{
_info = new InfoItem();
addItem(_info);
}
void TrackInfo::insert(const QString &key, const QString &value)
{
_info->insert(key, value);
}
void TrackInfo::plot(QPainter *painter, const QRectF &target)
{
qreal ratio = painter->paintEngine()->paintDevice()->logicalDpiX()
/ SCREEN_DPI;
QSizeF canvas = QSizeF(target.width() / ratio, target.height() / ratio);
QSizeF diff = QSizeF(qAbs(canvas.width() - sceneRect().width()),
qAbs(canvas.height() - sceneRect().height()));
QRectF adj = sceneRect().adjusted(0, -diff.height()/2, diff.width(),
diff.height()/2);
render(painter, target, adj);
}
bool TrackInfo::isEmpty() const
{
return _info->isEmpty();
}
QSizeF TrackInfo::contentSize() const
{
return sceneRect().size();
}

24
src/trackinfo.h Normal file
View File

@ -0,0 +1,24 @@
#ifndef TRACKINFO_H
#define TRACKINFO_H
#include <QGraphicsScene>
class InfoItem;
class TrackInfo : public QGraphicsScene
{
Q_OBJECT
public:
TrackInfo(QObject *parent = 0);
void insert(const QString &key, const QString &value);
void plot(QPainter *painter, const QRectF &target);
bool isEmpty() const;
QSizeF contentSize() const;
private:
InfoItem *_info;
};
#endif // TRACKINFO_H

View File

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

View File

@ -34,12 +34,16 @@ TrackView::TrackView(QWidget *parent)
_zoom = ZOOM_MAX;
_scale = mapScale(_zoom);
_map = 0;
_maxLen = 0;
_maxPath = 0;
_maxDistance = 0;
_plot = false;
}
TrackView::~TrackView()
{
delete _scene;
if (_mapScale->scene() != _scene)
delete _mapScale;
}
void TrackView::addTrack(const QVector<QPointF> &track)
@ -49,8 +53,10 @@ void TrackView::addTrack(const QVector<QPointF> &track)
MarkerItem *mi;
if (track.size() < 2)
if (track.size() < 2) {
_palette.color();
return;
}
_tracks.append(track);
@ -61,8 +67,7 @@ void TrackView::addTrack(const QVector<QPointF> &track)
path.lineTo(ll2mercator(QPointF(p.x(), -p.y())));
}
_maxLen = qMax(path.length(), _maxLen);
_maxPath = qMax(path.length(), _maxPath);
pi = new QGraphicsPathItem(path);
_paths.append(pi);
@ -108,6 +113,7 @@ void TrackView::loadGPX(const GPX &gpx)
QVector<QPointF> track;
gpx.track(i).track(track);
addTrack(track);
_maxDistance = qMax(gpx.track(i).distance(), _maxDistance);
}
addWaypoints(gpx.waypoints());
@ -291,7 +297,8 @@ void TrackView::setMap(Map *map)
{
_map = map;
if (_map)
connect(_map, SIGNAL(loaded()), this, SLOT(redraw()));
connect(_map, SIGNAL(loaded()), this, SLOT(redraw()),
Qt::UniqueConnection);
resetCachedContent();
}
@ -305,6 +312,13 @@ void TrackView::redraw()
resetCachedContent();
}
void TrackView::rescale()
{
_zoom = qMin(scale2zoom(trackScale()), scale2zoom(waypointScale()));
rescale(mapScale(_zoom));
_mapScale->setZoom(_zoom);
}
void TrackView::wheelEvent(QWheelEvent *event)
{
if (_paths.isEmpty() && _locations.isEmpty())
@ -332,48 +346,38 @@ void TrackView::wheelEvent(QWheelEvent *event)
resetCachedContent();
}
void TrackView::setTrackLineWidth(qreal width)
{
for (int i = 0; i < _paths.size(); i++) {
QPen pen(_paths.at(i)->pen());
pen.setWidthF(width);
_paths.at(i)->setPen(pen);
}
}
void TrackView::plot(QPainter *painter, const QRectF &target)
{
QRectF orig, adj;
QRect orig, adj;
qreal ratio, diff;
_scene->removeItem(_mapScale);
orig = _scene->itemsBoundingRect().adjusted(0, 0, 0,
_mapScale->boundingRect().height());
_scene->addItem(_mapScale);
if (target.width()/target.height() > orig.width()/orig.height()) {
ratio = target.width()/target.height();
diff = qAbs((orig.height() * ratio) - orig.width());
adj = orig.adjusted(-diff/2, 0, diff/2, 0);
} else {
orig = viewport()->rect();
if (orig.height() * (target.width() / target.height()) - orig.width() < 0) {
ratio = target.height()/target.width();
diff = fabs((orig.width() * ratio) - orig.height());
diff = (orig.width() * ratio) - orig.height();
adj = orig.adjusted(0, -diff/2, 0, diff/2);
} else {
ratio = target.width() / target.height();
diff = (orig.height() * ratio) - orig.width();
adj = orig.adjusted(-diff/2, 0, diff/2, 0);
}
_mapScale->setPos(adj.bottomRight()
+ QPoint(-_mapScale->boundingRect().width(),
-_mapScale->boundingRect().height()));
setUpdatesEnabled(false);
_plot = true;
setTrackLineWidth(0);
_scene->render(painter, target, adj);
setTrackLineWidth(TRACK_WIDTH * _scale);
}
QPointF pos = _mapScale->pos();
_mapScale->setPos(mapToScene(QPoint(adj.bottomRight() + QPoint(
-(SCALE_OFFSET + _mapScale->boundingRect().width()),
-(SCALE_OFFSET + _mapScale->boundingRect().height())))));
enum QPrinter::Orientation TrackView::orientation() const
{
return (sceneRect().width() > sceneRect().height())
? QPrinter::Landscape : QPrinter::Portrait;
render(painter, target, adj);
_mapScale->setPos(pos);
_plot = false;
setUpdatesEnabled(true);
}
void TrackView::clearPOI()
@ -403,7 +407,8 @@ void TrackView::clear()
_tracks.clear();
_waypoints.clear();
_maxLen = 0;
_maxPath = 0;
_maxDistance = 0;
_zoom = ZOOM_MAX;
_scale = mapScale(_zoom);
@ -412,28 +417,33 @@ void TrackView::clear()
void TrackView::movePositionMarker(qreal val)
{
qreal mp = val / _maxDistance;
for (int i = 0; i < _paths.size(); i++) {
qreal f = _maxLen / _paths.at(i)->path().length();
QPointF pos = _paths.at(i)->path().pointAtPercent(qMin(val * f,
1.0));
_markers.at(i)->setPos(pos);
qreal f = _maxPath / _paths.at(i)->path().length();
if (mp * f < 0 || mp * f > 1.0)
_markers.at(i)->setVisible(false);
else {
QPointF pos = _paths.at(i)->path().pointAtPercent(mp * f);
_markers.at(i)->setPos(pos);
_markers.at(i)->setVisible(true);
}
}
}
void TrackView::drawBackground(QPainter *painter, const QRectF &rect)
{
if ((_paths.isEmpty() && _locations.isEmpty())|| !_map) {
if ((_paths.isEmpty() && _locations.isEmpty()) || !_map) {
painter->fillRect(rect, Qt::white);
return;
}
painter->setWorldMatrixEnabled(false);
QRectF rr(rect.topLeft() * _scale, rect.size());
QPoint tile = mercator2tile(QPointF(rr.topLeft().x(), -rr.topLeft().y()),
_zoom);
QPointF tm = tile2mercator(tile, _zoom);
QPoint tl = mapFromScene(QPointF(tm.x() / _scale, -tm.y() / _scale));
QPoint tl = mapToScene(mapFromScene(QPointF(tm.x() / _scale,
-tm.y() / _scale))).toPoint();
QList<Tile> tiles;
for (int i = 0; i <= rr.size().width() / TILE_SIZE + 1; i++) {
@ -442,12 +452,12 @@ void TrackView::drawBackground(QPainter *painter, const QRectF &rect)
}
}
_map->loadTiles(tiles);
_map->loadTiles(tiles, _plot);
for (int i = 0; i < tiles.count(); i++) {
Tile &t = tiles[i];
QPoint tp(tl.x() + (t.xy().rx() - tile.rx()) * TILE_SIZE,
tl.y() + (t.xy().ry() - tile.ry()) * TILE_SIZE);
QPoint tp(tl.x() + (t.xy().x() - tile.x()) * TILE_SIZE,
tl.y() + (t.xy().y() - tile.y()) * TILE_SIZE);
painter->drawPixmap(tp, t.pixmap());
}
}
@ -457,6 +467,8 @@ void TrackView::resizeEvent(QResizeEvent *e)
if (_paths.isEmpty() && _locations.isEmpty())
return;
rescale();
QRectF br = trackBoundingRect() | waypointBoundingRect();
QRectF ba = br.adjusted(-TILE_SIZE, -TILE_SIZE, TILE_SIZE, TILE_SIZE);
@ -477,9 +489,10 @@ void TrackView::resizeEvent(QResizeEvent *e)
void TrackView::paintEvent(QPaintEvent *e)
{
QPointF scenePos = mapToScene(rect().bottomLeft() + QPoint(SCALE_OFFSET,
QPointF scenePos = mapToScene(rect().bottomRight() + QPoint(
-(SCALE_OFFSET + _mapScale->boundingRect().width()),
-(SCALE_OFFSET + _mapScale->boundingRect().height())));
if (_mapScale->pos() != scenePos)
if (_mapScale->pos() != scenePos && !_plot)
_mapScale->setPos(scenePos);
QGraphicsView::paintEvent(e);

View File

@ -5,7 +5,6 @@
#include <QVector>
#include <QHash>
#include <QList>
#include <QPrinter>
#include "units.h"
#include "palette.h"
#include "waypoint.h"
@ -35,12 +34,12 @@ public:
void setUnits(enum Units units);
void plot(QPainter *painter, const QRectF &target);
enum QPrinter::Orientation orientation() const;
int trackCount() const {return _paths.count();}
int waypointCount() const {return _locations.count();}
public slots:
void movePositionMarker(qreal val);
private slots:
void redraw();
private:
@ -54,9 +53,7 @@ private:
qreal waypointScale() const;
qreal mapScale(int zoom) const;
void rescale(qreal scale);
void showMarkers(bool show);
void setTrackLineWidth(qreal width);
void rescale();
void wheelEvent(QWheelEvent *event);
void drawBackground(QPainter *painter, const QRectF &rect);
@ -75,10 +72,12 @@ private:
ScaleItem *_mapScale;
Palette _palette;
qreal _maxLen;
qreal _maxPath, _maxDistance;
qreal _scale;
int _zoom;
bool _plot;
};
#endif // TRACKVIEW_H

View File

@ -12,12 +12,14 @@ enum Units {
#define MS2KMH 3.600000000000 // m/s -> km/h
#define MS2MIH 2.236936290000 // m/s -> mi/h
#define FT2MI 0.000189393939 // ft -> mi
#define MM2IN 0.039370100000 // mm -> in
#define MIINFT 5280 // 1 mi in ft
#define KMINM 1000 // 1 km in m
#define KMINM 1000 // 1 km in m
#define MIINFT 5280 // 1 mi in ft
#define MIINM 1609.344 // 1mi in m
#ifdef Q_OS_WIN32
#define UNIT_SPACE " "
#define UNIT_SPACE QString(" ")
#else // Q_OS_WIN32
#define UNIT_SPACE QString::fromUtf8("\xE2\x80\x89")
#endif // Q_OS_WIN32