mirror of
https://github.com/tumic0/GPXSee.git
synced 2025-07-02 22:09:16 +02:00
Compare commits
67 Commits
Author | SHA1 | Date | |
---|---|---|---|
b212ccf594 | |||
a80de92691 | |||
17ab241a6d | |||
816e1d1768 | |||
50c768e12d | |||
72dda5fdd6 | |||
ee3a6adf2b | |||
56f15da550 | |||
61c82a0836 | |||
201b3f6dae | |||
04f2a08b78 | |||
a736e3204f | |||
08f503249d | |||
f05e6ce29f | |||
209f58412a | |||
919d53ade9 | |||
4cba2ddefd | |||
e52a163529 | |||
70238062f2 | |||
7d749dfe5b | |||
64e65679fe | |||
7a6e60b83d | |||
a1ac09f615 | |||
236d045492 | |||
ba4ac9fe51 | |||
59d8b3cc77 | |||
2f80e612b5 | |||
047801685a | |||
973298f36e | |||
932f817496 | |||
580289e533 | |||
30891482a1 | |||
47a753610a | |||
e06a1bc148 | |||
635293ec1b | |||
2a987abec3 | |||
aac3de5707 | |||
923a00479a | |||
82660caccb | |||
ddebaaa62c | |||
7723392c01 | |||
30e78591c5 | |||
a26b1257b2 | |||
97a9dadd39 | |||
6acbf0d89f | |||
9941faa218 | |||
e7edd5c3c3 | |||
16cce5abd0 | |||
c2391929d3 | |||
5bd4999205 | |||
d8068ad994 | |||
6659e2ffa7 | |||
141226b509 | |||
4a2c7b19fb | |||
3bba3d6cd7 | |||
0374e59bce | |||
69c62ffdc3 | |||
b195993164 | |||
b2672a982a | |||
4d10a8d5d5 | |||
22b84cc6cd | |||
ba9319d7f6 | |||
7ac94588c8 | |||
1b358bde3c | |||
9b2ca4ccb7 | |||
2d9677096d | |||
f3eb136187 |
@ -4,7 +4,7 @@ GPX viewer and analyzer.
|
|||||||
* User-definable map sources.
|
* User-definable map sources.
|
||||||
* Track and elevation/speed graphs.
|
* Track and elevation/speed graphs.
|
||||||
* Support for multiple tracks in one view.
|
* Support for multiple tracks in one view.
|
||||||
* Support for POI files (Garmin CSV format).
|
* Support for POI files.
|
||||||
* Export to PDF.
|
* Export to PDF.
|
||||||
* Native GUI for Windows, Mac OS X and Linux.
|
* Native GUI for Windows, Mac OS X and Linux.
|
||||||
|
|
||||||
@ -23,7 +23,8 @@ nmake release
|
|||||||
```
|
```
|
||||||
|
|
||||||
## Binaries
|
## Binaries
|
||||||
Available at Sourceforge: http://sourceforge.net/projects/gpxsee
|
* Windows & OS X builds: http://sourceforge.net/projects/gpxsee
|
||||||
|
* Linux packages: https://build.opensuse.org/project/repositories/home:tumic:GPXSee
|
||||||
|
|
||||||
## Homepage
|
## Homepage
|
||||||
GPXSee homepage: http://tumic.wz.cz/gpxsee
|
GPXSee homepage: http://tumic.wz.cz/gpxsee
|
||||||
|
51
gpxsee.nsi
51
gpxsee.nsi
@ -1,5 +1,5 @@
|
|||||||
;Include Modern UI
|
|
||||||
!include "MUI2.nsh"
|
!include "MUI2.nsh"
|
||||||
|
!include "x64.nsh"
|
||||||
|
|
||||||
; The name of the installer
|
; The name of the installer
|
||||||
Name "GPXSee"
|
Name "GPXSee"
|
||||||
@ -7,20 +7,21 @@ Name "GPXSee"
|
|||||||
; The file to write
|
; The file to write
|
||||||
OutFile "install.exe"
|
OutFile "install.exe"
|
||||||
|
|
||||||
RequestExecutionLevel user
|
; Required execution level
|
||||||
|
RequestExecutionLevel admin
|
||||||
|
|
||||||
; The default installation directory
|
; The default installation directory
|
||||||
InstallDir "$LOCALAPPDATA\GPXSee"
|
InstallDir "$PROGRAMFILES\GPXSee"
|
||||||
|
|
||||||
; Registry key to check for directory (so if you install again, it will
|
; Registry key to check for directory (so if you install again, it will
|
||||||
; overwrite the old one automatically)
|
; overwrite the old one automatically)
|
||||||
InstallDirRegKey HKCU "Software\GPXSee" "Install_Dir"
|
InstallDirRegKey HKLM "Software\GPXSee" "Install_Dir"
|
||||||
|
|
||||||
; Registry key for uninstaller
|
; Registry key for uninstaller
|
||||||
!define REGENTRY "Software\Microsoft\Windows\CurrentVersion\Uninstall\GPXSee"
|
!define REGENTRY "Software\Microsoft\Windows\CurrentVersion\Uninstall\GPXSee"
|
||||||
|
|
||||||
; Start menu page configuration
|
; Start menu page configuration
|
||||||
!define MUI_STARTMENUPAGE_REGISTRY_ROOT "HKCU"
|
!define MUI_STARTMENUPAGE_REGISTRY_ROOT "HKLM"
|
||||||
!define MUI_STARTMENUPAGE_REGISTRY_KEY "Software\GPXSee"
|
!define MUI_STARTMENUPAGE_REGISTRY_KEY "Software\GPXSee"
|
||||||
!define MUI_STARTMENUPAGE_REGISTRY_VALUENAME "GPXSee"
|
!define MUI_STARTMENUPAGE_REGISTRY_VALUENAME "GPXSee"
|
||||||
|
|
||||||
@ -58,18 +59,19 @@ Section "GPXSee (required)" SEC_APP
|
|||||||
File "gpxsee.exe"
|
File "gpxsee.exe"
|
||||||
|
|
||||||
; Write the installation path into the registry
|
; Write the installation path into the registry
|
||||||
WriteRegStr HKCU SOFTWARE\GPXSee "Install_Dir" "$INSTDIR"
|
WriteRegStr HKLM SOFTWARE\GPXSee "Install_Dir" "$INSTDIR"
|
||||||
|
|
||||||
; Write the uninstall keys for Windows
|
; Write the uninstall keys for Windows
|
||||||
WriteRegStr HKCU "${REGENTRY}" "DisplayName" "GPXSee"
|
WriteRegStr HKLM "${REGENTRY}" "DisplayName" "GPXSee"
|
||||||
WriteRegStr HKCU "${REGENTRY}" "Publisher" "Martin Tuma"
|
WriteRegStr HKLM "${REGENTRY}" "Publisher" "Martin Tuma"
|
||||||
WriteRegStr HKCU "${REGENTRY}" "DisplayVersion" "2.1"
|
WriteRegStr HKLM "${REGENTRY}" "DisplayVersion" "2.9"
|
||||||
WriteRegStr HKCU "${REGENTRY}" "UninstallString" '"$INSTDIR\uninstall.exe"'
|
WriteRegStr HKLM "${REGENTRY}" "UninstallString" '"$INSTDIR\uninstall.exe"'
|
||||||
WriteRegDWORD HKCU "${REGENTRY}" "NoModify" 1
|
WriteRegDWORD HKLM "${REGENTRY}" "NoModify" 1
|
||||||
WriteRegDWORD HKCU "${REGENTRY}" "NoRepair" 1
|
WriteRegDWORD HKLM "${REGENTRY}" "NoRepair" 1
|
||||||
WriteUninstaller "$INSTDIR\uninstall.exe"
|
WriteUninstaller "$INSTDIR\uninstall.exe"
|
||||||
|
|
||||||
; Create start menu entry and add links
|
; Create start menu entry and add links
|
||||||
|
SetShellVarContext all
|
||||||
!insertmacro MUI_STARTMENU_WRITE_BEGIN Application
|
!insertmacro MUI_STARTMENU_WRITE_BEGIN Application
|
||||||
CreateDirectory "$SMPROGRAMS\$StartMenuFolder"
|
CreateDirectory "$SMPROGRAMS\$StartMenuFolder"
|
||||||
CreateShortCut "$SMPROGRAMS\$StartMenuFolder\Uninstall.lnk" "$INSTDIR\Uninstall.exe"
|
CreateShortCut "$SMPROGRAMS\$StartMenuFolder\Uninstall.lnk" "$INSTDIR\Uninstall.exe"
|
||||||
@ -93,9 +95,23 @@ SectionEnd
|
|||||||
|
|
||||||
Section "MSVC runtime" SEC_MSVC
|
Section "MSVC runtime" SEC_MSVC
|
||||||
|
|
||||||
File "msvcr100.dll"
|
DetailPrint "Checking whether Visual C++ 2015 Redistributable is already installed..."
|
||||||
File "msvcp100.dll"
|
${If} ${RunningX64}
|
||||||
|
ReadRegDword $R0 HKLM "SOFTWARE\Wow6432Node\Microsoft\VisualStudio\14.0\VC\Runtimes\x86" "Installed"
|
||||||
|
${Else}
|
||||||
|
ReadRegDword $R0 HKLM "SOFTWARE\Microsoft\VisualStudio\14.0\VC\Runtimes\x86" "Installed"
|
||||||
|
${EndIf}
|
||||||
|
|
||||||
|
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.x86.exe"
|
||||||
|
ExecWait '"$TEMP/VC_redist.x86.exe" /install /quiet /norestart'
|
||||||
|
|
||||||
|
done:
|
||||||
SectionEnd
|
SectionEnd
|
||||||
|
|
||||||
;--------------------------------
|
;--------------------------------
|
||||||
@ -105,13 +121,14 @@ SectionEnd
|
|||||||
Section "Uninstall"
|
Section "Uninstall"
|
||||||
|
|
||||||
; Remove registry keys
|
; Remove registry keys
|
||||||
DeleteRegKey HKCU "${REGENTRY}"
|
DeleteRegKey HKLM "${REGENTRY}"
|
||||||
DeleteRegKey HKCU SOFTWARE\GPXSee
|
DeleteRegKey HKLM SOFTWARE\GPXSee
|
||||||
|
|
||||||
; Remove directories used
|
; Remove directories used
|
||||||
RMDir /r "$INSTDIR"
|
RMDir /r "$INSTDIR"
|
||||||
|
|
||||||
; Remove Start menu entries
|
; Remove Start menu entries
|
||||||
|
SetShellVarContext all
|
||||||
!insertmacro MUI_STARTMENU_GETFOLDER Application $StartMenuFolder
|
!insertmacro MUI_STARTMENU_GETFOLDER Application $StartMenuFolder
|
||||||
Delete "$SMPROGRAMS\$StartMenuFolder\*.*"
|
Delete "$SMPROGRAMS\$StartMenuFolder\*.*"
|
||||||
RMDir "$SMPROGRAMS\$StartMenuFolder"
|
RMDir "$SMPROGRAMS\$StartMenuFolder"
|
||||||
@ -126,7 +143,7 @@ SectionEnd
|
|||||||
LangString DESC_QT ${LANG_ENGLISH} \
|
LangString DESC_QT ${LANG_ENGLISH} \
|
||||||
"QT Library. Unselct only if you have QT already installed!"
|
"QT Library. Unselct only if you have QT already installed!"
|
||||||
LangString DESC_MSVC ${LANG_ENGLISH} \
|
LangString DESC_MSVC ${LANG_ENGLISH} \
|
||||||
"Visual C++ 2010 runtime components. Unselct only if you have the runtime already installed!"
|
"Visual C++ 2015 runtime components. Unselct only if you have the runtime already installed!"
|
||||||
LangString DESC_APP ${LANG_ENGLISH} \
|
LangString DESC_APP ${LANG_ENGLISH} \
|
||||||
"GPXSee application"
|
"GPXSee application"
|
||||||
|
|
||||||
|
29
gpxsee.pro
29
gpxsee.pro
@ -8,15 +8,11 @@ HEADERS += src/config.h \
|
|||||||
src/icons.h \
|
src/icons.h \
|
||||||
src/gui.h \
|
src/gui.h \
|
||||||
src/gpx.h \
|
src/gpx.h \
|
||||||
src/graph.h \
|
|
||||||
src/track.h \
|
|
||||||
src/parser.h \
|
src/parser.h \
|
||||||
src/poi.h \
|
src/poi.h \
|
||||||
src/rtree.h \
|
src/rtree.h \
|
||||||
src/ll.h \
|
src/ll.h \
|
||||||
src/axisitem.h \
|
src/axisitem.h \
|
||||||
src/poiitem.h \
|
|
||||||
src/colorshop.h \
|
|
||||||
src/keys.h \
|
src/keys.h \
|
||||||
src/slideritem.h \
|
src/slideritem.h \
|
||||||
src/markeritem.h \
|
src/markeritem.h \
|
||||||
@ -27,18 +23,24 @@ HEADERS += src/config.h \
|
|||||||
src/filebrowser.h \
|
src/filebrowser.h \
|
||||||
src/map.h \
|
src/map.h \
|
||||||
src/maplist.h \
|
src/maplist.h \
|
||||||
src/downloader.h
|
src/downloader.h \
|
||||||
|
src/units.h \
|
||||||
|
src/scaleitem.h \
|
||||||
|
src/nicenum.h \
|
||||||
|
src/waypoint.h \
|
||||||
|
src/trackview.h \
|
||||||
|
src/track.h \
|
||||||
|
src/graphview.h \
|
||||||
|
src/trackpoint.h \
|
||||||
|
src/waypointitem.h \
|
||||||
|
src/palette.h
|
||||||
SOURCES += src/main.cpp \
|
SOURCES += src/main.cpp \
|
||||||
src/gui.cpp \
|
src/gui.cpp \
|
||||||
src/gpx.cpp \
|
src/gpx.cpp \
|
||||||
src/graph.cpp \
|
|
||||||
src/track.cpp \
|
|
||||||
src/parser.cpp \
|
src/parser.cpp \
|
||||||
src/poi.cpp \
|
src/poi.cpp \
|
||||||
src/ll.cpp \
|
src/ll.cpp \
|
||||||
src/axisitem.cpp \
|
src/axisitem.cpp \
|
||||||
src/poiitem.cpp \
|
|
||||||
src/colorshop.cpp \
|
|
||||||
src/slideritem.cpp \
|
src/slideritem.cpp \
|
||||||
src/markeritem.cpp \
|
src/markeritem.cpp \
|
||||||
src/infoitem.cpp \
|
src/infoitem.cpp \
|
||||||
@ -48,7 +50,14 @@ SOURCES += src/main.cpp \
|
|||||||
src/filebrowser.cpp \
|
src/filebrowser.cpp \
|
||||||
src/map.cpp \
|
src/map.cpp \
|
||||||
src/maplist.cpp \
|
src/maplist.cpp \
|
||||||
src/downloader.cpp
|
src/downloader.cpp \
|
||||||
|
src/scaleitem.cpp \
|
||||||
|
src/nicenum.cpp \
|
||||||
|
src/trackview.cpp \
|
||||||
|
src/track.cpp \
|
||||||
|
src/graphview.cpp \
|
||||||
|
src/waypointitem.cpp \
|
||||||
|
src/palette.cpp
|
||||||
RESOURCES += gpxsee.qrc
|
RESOURCES += gpxsee.qrc
|
||||||
TRANSLATIONS = lang/gpxsee_cs.ts
|
TRANSLATIONS = lang/gpxsee_cs.ts
|
||||||
macx:ICON = icons/gpxsee.icns
|
macx:ICON = icons/gpxsee.icns
|
||||||
|
@ -9,6 +9,11 @@
|
|||||||
<file>icons/application-exit.png</file>
|
<file>icons/application-exit.png</file>
|
||||||
<file>icons/applications-internet.png</file>
|
<file>icons/applications-internet.png</file>
|
||||||
<file>icons/view-refresh.png</file>
|
<file>icons/view-refresh.png</file>
|
||||||
|
<file>icons/arrow-left.png</file>
|
||||||
|
<file>icons/arrow-right.png</file>
|
||||||
|
<file>icons/arrow-left-double.png</file>
|
||||||
|
<file>icons/arrow-right-double.png</file>
|
||||||
<file>lang/gpxsee_cs.qm</file>
|
<file>lang/gpxsee_cs.qm</file>
|
||||||
|
<file>maps.txt</file>
|
||||||
</qresource>
|
</qresource>
|
||||||
</RCC>
|
</RCC>
|
||||||
|
BIN
icons/arrow-left-double.png
Normal file
BIN
icons/arrow-left-double.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 926 B |
BIN
icons/arrow-left.png
Normal file
BIN
icons/arrow-left.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 707 B |
BIN
icons/arrow-right-double.png
Normal file
BIN
icons/arrow-right-double.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 924 B |
BIN
icons/arrow-right.png
Normal file
BIN
icons/arrow-right.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 682 B |
@ -4,42 +4,54 @@
|
|||||||
<context>
|
<context>
|
||||||
<name>ElevationGraph</name>
|
<name>ElevationGraph</name>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../src/elevationgraph.cpp" line="13"/>
|
<location filename="../src/elevationgraph.cpp" line="14"/>
|
||||||
<source>Distance</source>
|
<source>Distance</source>
|
||||||
<translation>Vzdálenost</translation>
|
<translation>Vzdálenost</translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../src/elevationgraph.cpp" line="14"/>
|
<location filename="../src/elevationgraph.cpp" line="15"/>
|
||||||
<source>Elevation</source>
|
<source>Elevation</source>
|
||||||
<translation>Výška</translation>
|
<translation>Výška</translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../src/elevationgraph.cpp" line="15"/>
|
<location filename="../src/elevationgraph.cpp" line="16"/>
|
||||||
|
<location filename="../src/elevationgraph.cpp" line="83"/>
|
||||||
<source>km</source>
|
<source>km</source>
|
||||||
<translation>km</translation>
|
<translation>km</translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../src/elevationgraph.cpp" line="16"/>
|
<location filename="../src/elevationgraph.cpp" line="17"/>
|
||||||
|
<location filename="../src/elevationgraph.cpp" line="84"/>
|
||||||
<source>m</source>
|
<source>m</source>
|
||||||
<translation>m</translation>
|
<translation>m</translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../src/elevationgraph.cpp" line="52"/>
|
<location filename="../src/elevationgraph.cpp" line="23"/>
|
||||||
<source>Ascent</source>
|
<source>Ascent</source>
|
||||||
<translation>Stoupání</translation>
|
<translation>Stoupání</translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../src/elevationgraph.cpp" line="54"/>
|
<location filename="../src/elevationgraph.cpp" line="25"/>
|
||||||
<source>Descent</source>
|
<source>Descent</source>
|
||||||
<translation>Klesání</translation>
|
<translation>Klesání</translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../src/elevationgraph.cpp" line="58"/>
|
<location filename="../src/elevationgraph.cpp" line="29"/>
|
||||||
<source>Minimum</source>
|
<source>Minimum</source>
|
||||||
<translation>Minimum</translation>
|
<translation>Minimum</translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../src/elevationgraph.cpp" line="56"/>
|
<location filename="../src/elevationgraph.cpp" line="88"/>
|
||||||
|
<source>mi</source>
|
||||||
|
<translation>mi</translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<location filename="../src/elevationgraph.cpp" line="89"/>
|
||||||
|
<source>ft</source>
|
||||||
|
<translation>ft</translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<location filename="../src/elevationgraph.cpp" line="27"/>
|
||||||
<source>Maximum</source>
|
<source>Maximum</source>
|
||||||
<translation>Maximum</translation>
|
<translation>Maximum</translation>
|
||||||
</message>
|
</message>
|
||||||
@ -47,293 +59,418 @@
|
|||||||
<context>
|
<context>
|
||||||
<name>GUI</name>
|
<name>GUI</name>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../src/gui.cpp" line="135"/>
|
<location filename="../src/gui.cpp" line="161"/>
|
||||||
<source>About Qt</source>
|
<source>About Qt</source>
|
||||||
<translation>O Qt</translation>
|
<translation>O Qt</translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../src/gui.cpp" line="295"/>
|
<location filename="../src/gui.cpp" line="380"/>
|
||||||
<source>GPXSee is distributed under the terms of the GNU General Public License version 3. For more info about GPXSee visit the project homepage at </source>
|
<source>GPXSee is distributed under the terms of the GNU General Public License version 3. For more info about GPXSee visit the project homepage at </source>
|
||||||
<translation>Program GPXSee je distribuován pod podmínkami licence GNU General Public License verze 3. Pro více informací navštivte stránky programu na adrese </translation>
|
<translation>Program GPXSee je distribuován pod podmínkami licence GNU General Public License verze 3. Pro více informací navštivte stránky programu na adrese </translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../src/gui.cpp" line="354"/>
|
<location filename="../src/gui.cpp" line="441"/>
|
||||||
<source>Open file</source>
|
<source>Open file</source>
|
||||||
<translation>Otevřít soubor</translation>
|
<translation>Otevřít soubor</translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../src/gui.cpp" line="149"/>
|
<location filename="../src/gui.cpp" line="175"/>
|
||||||
<source>Save as</source>
|
<source>Save as</source>
|
||||||
<translation>Uložit jako</translation>
|
<translation>Uložit jako</translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../src/gui.cpp" line="405"/>
|
<location filename="../src/gui.cpp" line="501"/>
|
||||||
<source>Open POI file</source>
|
<source>Open POI file</source>
|
||||||
<translation>Otevřít POI soubor</translation>
|
<translation>Otevřít POI soubor</translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../src/gui.cpp" line="140"/>
|
<location filename="../src/gui.cpp" line="166"/>
|
||||||
<source>Open</source>
|
<source>Open</source>
|
||||||
<translation>Otevřít</translation>
|
<translation>Otevřít</translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../src/gui.cpp" line="123"/>
|
<location filename="../src/gui.cpp" line="149"/>
|
||||||
<source>Quit</source>
|
<source>Quit</source>
|
||||||
<translation>Ukončit</translation>
|
<translation>Ukončit</translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../src/gui.cpp" line="130"/>
|
<location filename="../src/gui.cpp" line="156"/>
|
||||||
<location filename="../src/gui.cpp" line="311"/>
|
<location filename="../src/gui.cpp" line="396"/>
|
||||||
<location filename="../src/gui.cpp" line="312"/>
|
<location filename="../src/gui.cpp" line="397"/>
|
||||||
<source>Keyboard controls</source>
|
<source>Keyboard controls</source>
|
||||||
<translation>Ovládací klávesy</translation>
|
<translation>Ovládací klávesy</translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../src/gui.cpp" line="144"/>
|
<location filename="../src/gui.cpp" line="170"/>
|
||||||
<source>Save</source>
|
<source>Save</source>
|
||||||
<translation>Uložit</translation>
|
<translation>Uložit</translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../src/gui.cpp" line="154"/>
|
<location filename="../src/gui.cpp" line="180"/>
|
||||||
<source>Close</source>
|
<source>Close</source>
|
||||||
<translation>Zavřít</translation>
|
<translation>Zavřít</translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../src/gui.cpp" line="159"/>
|
<location filename="../src/gui.cpp" line="185"/>
|
||||||
<source>Reload</source>
|
<source>Reload</source>
|
||||||
<translation>Znovu načíst</translation>
|
<translation>Znovu načíst</translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../src/gui.cpp" line="244"/>
|
<location filename="../src/gui.cpp" line="317"/>
|
||||||
<source>Show</source>
|
<source>Show</source>
|
||||||
<translation>Zobrazit</translation>
|
<translation>Zobrazit</translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../src/gui.cpp" line="198"/>
|
<location filename="../src/gui.cpp" line="262"/>
|
||||||
<location filename="../src/gui.cpp" line="235"/>
|
<location filename="../src/gui.cpp" line="308"/>
|
||||||
<source>File</source>
|
<source>File</source>
|
||||||
<translation>Soubor</translation>
|
<translation>Soubor</translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../src/gui.cpp" line="128"/>
|
<location filename="../src/gui.cpp" line="154"/>
|
||||||
<location filename="../src/gui.cpp" line="327"/>
|
<location filename="../src/gui.cpp" line="414"/>
|
||||||
<location filename="../src/gui.cpp" line="328"/>
|
<location filename="../src/gui.cpp" line="415"/>
|
||||||
<source>Data sources</source>
|
<source>Data sources</source>
|
||||||
<translation>Zdroje dat</translation>
|
<translation>Zdroje dat</translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../src/gui.cpp" line="166"/>
|
<location filename="../src/gui.cpp" line="192"/>
|
||||||
<source>Load POI file</source>
|
<source>Load POI file</source>
|
||||||
<translation>Nahrát POI soubor</translation>
|
<translation>Nahrát POI soubor</translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../src/gui.cpp" line="169"/>
|
<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>
|
<source>Show POIs</source>
|
||||||
<translation>Zobrazit POI</translation>
|
<translation>Zobrazit POI</translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../src/gui.cpp" line="174"/>
|
<location filename="../src/gui.cpp" line="205"/>
|
||||||
<source>Show map</source>
|
<source>Show map</source>
|
||||||
<translation>Zobrazit mapu</translation>
|
<translation>Zobrazit mapu</translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../src/gui.cpp" line="184"/>
|
<location filename="../src/gui.cpp" line="218"/>
|
||||||
<source>Show graphs</source>
|
<source>Show graphs</source>
|
||||||
<translation>Zobrazovat grafy</translation>
|
<translation>Zobrazovat grafy</translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../src/gui.cpp" line="189"/>
|
<location filename="../src/gui.cpp" line="224"/>
|
||||||
<source>Show toolbars</source>
|
<source>Show toolbars</source>
|
||||||
<translation>Zobrazovat nástrojové lišty</translation>
|
<translation>Zobrazovat nástrojové lišty</translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../src/gui.cpp" line="212"/>
|
<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>
|
<source>Map</source>
|
||||||
<translation>Mapa</translation>
|
<translation>Mapa</translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../src/gui.cpp" line="217"/>
|
<location filename="../src/gui.cpp" line="281"/>
|
||||||
<source>POI</source>
|
<source>POI</source>
|
||||||
<translation>POI</translation>
|
<translation>POI</translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../src/gui.cpp" line="221"/>
|
<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>
|
<source>Settings</source>
|
||||||
<translation>Nastavení</translation>
|
<translation>Nastavení</translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../src/gui.cpp" line="225"/>
|
<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>
|
<source>Help</source>
|
||||||
<translation>Nápověda</translation>
|
<translation>Nápověda</translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../src/gui.cpp" line="263"/>
|
<location filename="../src/gui.cpp" line="348"/>
|
||||||
<source>Elevation</source>
|
<source>Elevation</source>
|
||||||
<translation>Výška</translation>
|
<translation>Výška</translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../src/gui.cpp" line="264"/>
|
<location filename="../src/gui.cpp" line="349"/>
|
||||||
<source>Speed</source>
|
<source>Speed</source>
|
||||||
<translation>Rychlost</translation>
|
<translation>Rychlost</translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../src/gui.cpp" line="314"/>
|
<location filename="../src/gui.cpp" line="399"/>
|
||||||
<source>Next file</source>
|
<source>Next file</source>
|
||||||
<translation>Následující soubor</translation>
|
<translation>Následující soubor</translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../src/gui.cpp" line="315"/>
|
<location filename="../src/gui.cpp" line="400"/>
|
||||||
<source>Previous file</source>
|
<source>Previous file</source>
|
||||||
<translation>Předchozí soubor</translation>
|
<translation>Předchozí soubor</translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../src/gui.cpp" line="317"/>
|
<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>
|
<source>Append modifier</source>
|
||||||
<translation>Modifikátor nahradit/přidat</translation>
|
<translation>Modifikátor nahradit/přidat</translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../src/gui.cpp" line="331"/>
|
<location filename="../src/gui.cpp" line="418"/>
|
||||||
<source>Map (tiles) source URLs are read on program startup from the following file:</source>
|
<source>Map (tiles) source URLs are read on program startup from the following file:</source>
|
||||||
<translation>URL mapových zdrojů (dlaždic) jsou načteny při startu programu z následujícího souboru:</translation>
|
<translation>URL mapových zdrojů (dlaždic) jsou načteny při startu programu z následujícího souboru:</translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../src/gui.cpp" line="335"/>
|
<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>
|
<source>The file format is one map entry per line, consisting of the map name and tiles URL delimited by a TAB character. The tile X and Y coordinates are replaced with $x and $y in the URL and the zoom level is replaced with $z. An example map file could look like:</source>
|
||||||
<translation>Formát souboru je jeden mapový záznam na řádku, kde mapový záznam sestává ze jména mapy a URL dlaždic navzájem oddělených tabulátorem. Souřadnice dlaždice jsou v URL nahrazeny řetězci $x a $y, úroven přiblížení (zoom) pak řetězcem $z. Příklad:</translation>
|
<translation>Formát souboru je jeden mapový záznam na řádku, kde mapový záznam sestává ze jména mapy a URL dlaždic navzájem oddělených tabulátorem. Souřadnice dlaždice jsou v URL nahrazeny řetězci $x a $y, úroven přiblížení (zoom) pak řetězcem $z. Příklad:</translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../src/gui.cpp" line="343"/>
|
<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>
|
<source>To make GPXSee load a POI file automatically on startup, add the file to the following directory:</source>
|
||||||
<translation>POI soubory, které se mají automaticky nahrát při startu programu jsou načítány z následujícího adresáře:</translation>
|
<translation>POI soubory, které se mají automaticky nahrát při startu programu jsou načítány z následujícího adresáře:</translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../src/gui.cpp" line="396"/>
|
<location filename="../src/gui.cpp" line="442"/>
|
||||||
<location filename="../src/gui.cpp" line="412"/>
|
<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>
|
<source>Line: %1</source>
|
||||||
<translation>Řádka: %1</translation>
|
<translation>Řádka: %1</translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../src/gui.cpp" line="464"/>
|
<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>
|
<source>Maximum</source>
|
||||||
<translation>Maximum</translation>
|
<translation>Maximum</translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../src/gui.cpp" line="466"/>
|
<location filename="../src/gui.cpp" line="585"/>
|
||||||
|
<location filename="../src/gui.cpp" line="597"/>
|
||||||
<source>Minimum</source>
|
<source>Minimum</source>
|
||||||
<translation>Minimum</translation>
|
<translation>Minimum</translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../src/gui.cpp" line="133"/>
|
<location filename="../src/gui.cpp" line="159"/>
|
||||||
<location filename="../src/gui.cpp" line="291"/>
|
<location filename="../src/gui.cpp" line="376"/>
|
||||||
<source>About GPXSee</source>
|
<source>About GPXSee</source>
|
||||||
<translation>O aplikaci GPXSee</translation>
|
<translation>O aplikaci GPXSee</translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../src/gui.cpp" line="293"/>
|
<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>
|
<source>GPX viewer and analyzer</source>
|
||||||
<translation>Prohlížeč a analyzátor GPX</translation>
|
<translation>Prohlížeč a analyzátor GPX</translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../src/gui.cpp" line="330"/>
|
<location filename="../src/gui.cpp" line="417"/>
|
||||||
<source>Map sources</source>
|
<source>Map sources</source>
|
||||||
<translation>Mapové zdroje</translation>
|
<translation>Mapové zdroje</translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../src/gui.cpp" line="342"/>
|
<location filename="../src/gui.cpp" line="429"/>
|
||||||
<source>POIs</source>
|
<source>POIs</source>
|
||||||
<translation>POI body</translation>
|
<translation>POI body</translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../src/gui.cpp" line="457"/>
|
<location filename="../src/gui.cpp" line="576"/>
|
||||||
|
<location filename="../src/gui.cpp" line="588"/>
|
||||||
<source>Distance</source>
|
<source>Distance</source>
|
||||||
<translation>Vzdálenost</translation>
|
<translation>Vzdálenost</translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../src/gui.cpp" line="459"/>
|
<location filename="../src/gui.cpp" line="578"/>
|
||||||
|
<location filename="../src/gui.cpp" line="590"/>
|
||||||
<source>Time</source>
|
<source>Time</source>
|
||||||
<translation>Čas</translation>
|
<translation>Čas</translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../src/gui.cpp" line="460"/>
|
<location filename="../src/gui.cpp" line="579"/>
|
||||||
|
<location filename="../src/gui.cpp" line="591"/>
|
||||||
<source>Ascent</source>
|
<source>Ascent</source>
|
||||||
<translation>Stoupání</translation>
|
<translation>Stoupání</translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../src/gui.cpp" line="461"/>
|
<location filename="../src/gui.cpp" line="592"/>
|
||||||
<location filename="../src/gui.cpp" line="463"/>
|
<location filename="../src/gui.cpp" line="594"/>
|
||||||
<location filename="../src/gui.cpp" line="465"/>
|
<location filename="../src/gui.cpp" line="596"/>
|
||||||
<location filename="../src/gui.cpp" line="467"/>
|
<location filename="../src/gui.cpp" line="598"/>
|
||||||
<source>m</source>
|
<source>m</source>
|
||||||
<translation>m</translation>
|
<translation>m</translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../src/gui.cpp" line="462"/>
|
<location filename="../src/gui.cpp" line="581"/>
|
||||||
|
<location filename="../src/gui.cpp" line="593"/>
|
||||||
<source>Descent</source>
|
<source>Descent</source>
|
||||||
<translation>Klesání</translation>
|
<translation>Klesání</translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../src/gui.cpp" line="558"/>
|
<location filename="../src/gui.cpp" line="693"/>
|
||||||
<source>%1 tracks</source>
|
<source>%1 tracks</source>
|
||||||
<translation>Počet tras: %1</translation>
|
<translation>Počet tras: %1</translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../src/gui.cpp" line="458"/>
|
<location filename="../src/gui.cpp" line="589"/>
|
||||||
<location filename="../src/gui.cpp" line="561"/>
|
<location filename="../src/gui.cpp" line="700"/>
|
||||||
<source>km</source>
|
<source>km</source>
|
||||||
<translation>km</translation>
|
<translation>km</translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../src/gui.cpp" line="398"/>
|
<location filename="../src/gui.cpp" line="494"/>
|
||||||
<location filename="../src/gui.cpp" line="413"/>
|
<location filename="../src/gui.cpp" line="510"/>
|
||||||
<source>Error</source>
|
<source>Error</source>
|
||||||
<translation>Chyba</translation>
|
<translation>Chyba</translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../src/gui.cpp" line="393"/>
|
<location filename="../src/gui.cpp" line="489"/>
|
||||||
<source>Error loading GPX file:
|
<source>Error loading GPX file:
|
||||||
%1</source>
|
%1</source>
|
||||||
<translation>Soubor GPX nelze otevřít:
|
<translation>Soubor GPX nelze otevřít:
|
||||||
%1</translation>
|
%1</translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../src/gui.cpp" line="409"/>
|
<location filename="../src/gui.cpp" line="506"/>
|
||||||
<source>Error loading POI file:
|
<source>Error loading POI file:
|
||||||
%1</source>
|
%1</source>
|
||||||
<translation>Soubor POI nelze otevřít:
|
<translation>Soubor POI nelze otevřít:
|
||||||
%1</translation>
|
%1</translation>
|
||||||
</message>
|
</message>
|
||||||
</context>
|
</context>
|
||||||
|
<context>
|
||||||
|
<name>QObject</name>
|
||||||
|
<message>
|
||||||
|
<location filename="../src/scaleitem.cpp" line="83"/>
|
||||||
|
<source>mi</source>
|
||||||
|
<translation>mi</translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<location filename="../src/scaleitem.cpp" line="83"/>
|
||||||
|
<source>ft</source>
|
||||||
|
<translation>ft</translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<location filename="../src/scaleitem.cpp" line="85"/>
|
||||||
|
<source>km</source>
|
||||||
|
<translation>km</translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<location filename="../src/scaleitem.cpp" line="85"/>
|
||||||
|
<source>m</source>
|
||||||
|
<translation>m</translation>
|
||||||
|
</message>
|
||||||
|
</context>
|
||||||
<context>
|
<context>
|
||||||
<name>SpeedGraph</name>
|
<name>SpeedGraph</name>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../src/speedgraph.cpp" line="9"/>
|
<location filename="../src/speedgraph.cpp" line="10"/>
|
||||||
<source>Distance</source>
|
<source>Distance</source>
|
||||||
<translation>Vzdálenost</translation>
|
<translation>Vzdálenost</translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../src/speedgraph.cpp" line="10"/>
|
<location filename="../src/speedgraph.cpp" line="11"/>
|
||||||
<source>Speed</source>
|
<source>Speed</source>
|
||||||
<translation>Rychlost</translation>
|
<translation>Rychlost</translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../src/speedgraph.cpp" line="11"/>
|
<location filename="../src/speedgraph.cpp" line="12"/>
|
||||||
|
<location filename="../src/speedgraph.cpp" line="73"/>
|
||||||
<source>km</source>
|
<source>km</source>
|
||||||
<translation></translation>
|
<translation></translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../src/speedgraph.cpp" line="12"/>
|
<location filename="../src/speedgraph.cpp" line="13"/>
|
||||||
|
<location filename="../src/speedgraph.cpp" line="74"/>
|
||||||
<source>km/h</source>
|
<source>km/h</source>
|
||||||
<translation>km/h</translation>
|
<translation>km/h</translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../src/speedgraph.cpp" line="35"/>
|
<location filename="../src/speedgraph.cpp" line="21"/>
|
||||||
<source>Average</source>
|
<source>Average</source>
|
||||||
<translation>Průměr</translation>
|
<translation>Průměr</translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../src/speedgraph.cpp" line="37"/>
|
<location filename="../src/speedgraph.cpp" line="23"/>
|
||||||
<source>Maximum</source>
|
<source>Maximum</source>
|
||||||
<translation>Maximum</translation>
|
<translation>Maximum</translation>
|
||||||
</message>
|
</message>
|
||||||
|
<message>
|
||||||
|
<location filename="../src/speedgraph.cpp" line="78"/>
|
||||||
|
<source>mi</source>
|
||||||
|
<translation>mi</translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<location filename="../src/speedgraph.cpp" line="79"/>
|
||||||
|
<source>mi/h</source>
|
||||||
|
<translation>mi/h</translation>
|
||||||
|
</message>
|
||||||
</context>
|
</context>
|
||||||
</TS>
|
</TS>
|
||||||
|
2
maps.txt
Normal file
2
maps.txt
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
Thunderforest http://tile.thunderforest.com/outdoors/$z/$x/$y.png
|
||||||
|
Open Street Map http://tile.openstreetmap.org/$z/$x/$y.png
|
@ -1,6 +1,7 @@
|
|||||||
#include <cmath>
|
#include <cmath>
|
||||||
#include <QPainter>
|
#include <QPainter>
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
|
#include "nicenum.h"
|
||||||
#include "axisitem.h"
|
#include "axisitem.h"
|
||||||
|
|
||||||
|
|
||||||
@ -15,38 +16,6 @@ struct Label {
|
|||||||
double d;
|
double d;
|
||||||
};
|
};
|
||||||
|
|
||||||
static double niceNum(double x, int round)
|
|
||||||
{
|
|
||||||
int expv;
|
|
||||||
double f;
|
|
||||||
double nf;
|
|
||||||
|
|
||||||
expv = floor(log10(x));
|
|
||||||
f = x / pow(10.0, expv);
|
|
||||||
|
|
||||||
if (round) {
|
|
||||||
if (f < 1.5)
|
|
||||||
nf = 1.0;
|
|
||||||
else if (f < 3.0)
|
|
||||||
nf = 2.0;
|
|
||||||
else if (f < 7.0)
|
|
||||||
nf = 5.0;
|
|
||||||
else
|
|
||||||
nf = 10.0;
|
|
||||||
} else {
|
|
||||||
if (f <= 1.0)
|
|
||||||
nf = 1.;
|
|
||||||
else if (f <= 2.0)
|
|
||||||
nf = 2.0;
|
|
||||||
else if (f <= 5.0)
|
|
||||||
nf = 5.0;
|
|
||||||
else
|
|
||||||
nf = 10.0;
|
|
||||||
}
|
|
||||||
|
|
||||||
return nf * pow(10.0, expv);
|
|
||||||
}
|
|
||||||
|
|
||||||
static struct Label label(double min, double max, int ticks)
|
static struct Label label(double min, double max, int ticks)
|
||||||
{
|
{
|
||||||
double range;
|
double range;
|
||||||
@ -123,7 +92,6 @@ void AxisItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *option,
|
|||||||
QFont font;
|
QFont font;
|
||||||
font.setPixelSize(FONT_SIZE);
|
font.setPixelSize(FONT_SIZE);
|
||||||
font.setFamily(FONT_FAMILY);
|
font.setFamily(FONT_FAMILY);
|
||||||
painter->setFont(font);
|
|
||||||
QFontMetrics fm(font);
|
QFontMetrics fm(font);
|
||||||
QRect ts, ls;
|
QRect ts, ls;
|
||||||
struct Label l;
|
struct Label l;
|
||||||
@ -131,6 +99,8 @@ void AxisItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *option,
|
|||||||
qreal val;
|
qreal val;
|
||||||
|
|
||||||
|
|
||||||
|
painter->setFont(font);
|
||||||
|
|
||||||
ls = fm.tightBoundingRect(_label);
|
ls = fm.tightBoundingRect(_label);
|
||||||
|
|
||||||
if (_type == X) {
|
if (_type == X) {
|
||||||
@ -177,7 +147,7 @@ void AxisItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *option,
|
|||||||
*/
|
*/
|
||||||
}
|
}
|
||||||
|
|
||||||
QSizeF AxisItem::margin()
|
QSizeF AxisItem::margin() const
|
||||||
{
|
{
|
||||||
QFont font;
|
QFont font;
|
||||||
font.setPixelSize(FONT_SIZE);
|
font.setPixelSize(FONT_SIZE);
|
||||||
|
@ -18,7 +18,7 @@ public:
|
|||||||
void setSize(qreal size);
|
void setSize(qreal size);
|
||||||
void setLabel(const QString& label);
|
void setLabel(const QString& label);
|
||||||
|
|
||||||
QSizeF margin();
|
QSizeF margin() const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void updateBoundingRect();
|
void updateBoundingRect();
|
||||||
|
@ -3,7 +3,7 @@
|
|||||||
|
|
||||||
#define APP_NAME "GPXSee"
|
#define APP_NAME "GPXSee"
|
||||||
#define APP_HOMEPAGE "http://tumic.wz.cz/gpxsee"
|
#define APP_HOMEPAGE "http://tumic.wz.cz/gpxsee"
|
||||||
#define APP_VERSION "2.1"
|
#define APP_VERSION "2.9"
|
||||||
|
|
||||||
#define FONT_FAMILY "Arial"
|
#define FONT_FAMILY "Arial"
|
||||||
#define FONT_SIZE 12
|
#define FONT_SIZE 12
|
||||||
|
@ -18,19 +18,23 @@
|
|||||||
|
|
||||||
Downloader::Downloader()
|
Downloader::Downloader()
|
||||||
{
|
{
|
||||||
connect(&manager, SIGNAL(finished(QNetworkReply*)),
|
connect(&_manager, SIGNAL(finished(QNetworkReply*)),
|
||||||
SLOT(downloadFinished(QNetworkReply*)));
|
SLOT(downloadFinished(QNetworkReply*)));
|
||||||
}
|
}
|
||||||
|
|
||||||
void Downloader::doDownload(const Download &dl)
|
void Downloader::doDownload(const Download &dl)
|
||||||
{
|
{
|
||||||
QUrl url(dl.url());
|
QUrl url(dl.url());
|
||||||
|
|
||||||
|
if (_errorDownloads.contains(url))
|
||||||
|
return;
|
||||||
|
|
||||||
QNetworkRequest request(url);
|
QNetworkRequest request(url);
|
||||||
request.setAttribute(QNetworkRequest::User, QVariant(dl.file()));
|
request.setAttribute(QNetworkRequest::User, QVariant(dl.file()));
|
||||||
request.setRawHeader("User-Agent", USER_AGENT);
|
request.setRawHeader("User-Agent", USER_AGENT);
|
||||||
QNetworkReply *reply = manager.get(request);
|
QNetworkReply *reply = _manager.get(request);
|
||||||
|
|
||||||
currentDownloads.append(reply);
|
_currentDownloads.append(reply);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Downloader::saveToDisk(const QString &filename, QIODevice *data)
|
bool Downloader::saveToDisk(const QString &filename, QIODevice *data)
|
||||||
@ -53,6 +57,7 @@ void Downloader::downloadFinished(QNetworkReply *reply)
|
|||||||
{
|
{
|
||||||
QUrl url = reply->url();
|
QUrl url = reply->url();
|
||||||
if (reply->error()) {
|
if (reply->error()) {
|
||||||
|
_errorDownloads.insert(url);
|
||||||
fprintf(stderr, "Error downloading map tile: %s: %s\n",
|
fprintf(stderr, "Error downloading map tile: %s: %s\n",
|
||||||
url.toEncoded().constData(), qPrintable(reply->errorString()));
|
url.toEncoded().constData(), qPrintable(reply->errorString()));
|
||||||
} else {
|
} else {
|
||||||
@ -61,10 +66,10 @@ void Downloader::downloadFinished(QNetworkReply *reply)
|
|||||||
saveToDisk(filename, reply);
|
saveToDisk(filename, reply);
|
||||||
}
|
}
|
||||||
|
|
||||||
currentDownloads.removeAll(reply);
|
_currentDownloads.removeAll(reply);
|
||||||
reply->deleteLater();
|
reply->deleteLater();
|
||||||
|
|
||||||
if (currentDownloads.isEmpty())
|
if (_currentDownloads.isEmpty())
|
||||||
emit finished();
|
emit finished();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -6,6 +6,7 @@
|
|||||||
#include <QNetworkReply>
|
#include <QNetworkReply>
|
||||||
#include <QUrl>
|
#include <QUrl>
|
||||||
#include <QList>
|
#include <QList>
|
||||||
|
#include <QSet>
|
||||||
|
|
||||||
|
|
||||||
class Download
|
class Download
|
||||||
@ -45,8 +46,9 @@ private:
|
|||||||
void doDownload(const Download &dl);
|
void doDownload(const Download &dl);
|
||||||
bool saveToDisk(const QString &filename, QIODevice *data);
|
bool saveToDisk(const QString &filename, QIODevice *data);
|
||||||
|
|
||||||
QNetworkAccessManager manager;
|
QNetworkAccessManager _manager;
|
||||||
QList<QNetworkReply *> currentDownloads;
|
QList<QNetworkReply *> _currentDownloads;
|
||||||
|
QSet<QUrl> _errorDownloads;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // DOWNLOADER_H
|
#endif // DOWNLOADER_H
|
||||||
|
@ -1,64 +1,71 @@
|
|||||||
#include <float.h>
|
#include <float.h>
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
|
#include "gpx.h"
|
||||||
#include "elevationgraph.h"
|
#include "elevationgraph.h"
|
||||||
|
|
||||||
|
|
||||||
ElevationGraph::ElevationGraph(QWidget *parent) : Graph(parent)
|
ElevationGraph::ElevationGraph(QWidget *parent) : GraphView(parent)
|
||||||
{
|
{
|
||||||
_ascent = 0;
|
_ascent = 0;
|
||||||
_descent = 0;
|
_descent = 0;
|
||||||
_max = -FLT_MAX;
|
_max = -FLT_MAX;
|
||||||
_min = FLT_MAX;
|
_min = FLT_MAX;
|
||||||
|
|
||||||
Graph::setXLabel(tr("Distance"));
|
GraphView::setXLabel(tr("Distance"));
|
||||||
Graph::setYLabel(tr("Elevation"));
|
GraphView::setYLabel(tr("Elevation"));
|
||||||
Graph::setXUnits(tr("km"));
|
GraphView::setXUnits(tr("km"));
|
||||||
Graph::setYUnits(tr("m"));
|
GraphView::setYUnits(tr("m"));
|
||||||
Graph::setXScale(0.001);
|
GraphView::setXScale(M2KM);
|
||||||
|
GraphView::setMinRange(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);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ElevationGraph::loadGPX(const GPX &gpx)
|
void ElevationGraph::loadGPX(const GPX &gpx)
|
||||||
{
|
{
|
||||||
QVector<QPointF> data;
|
for (int i = 0; i < gpx.trackCount(); i++) {
|
||||||
qreal min, max, ascent = 0, descent = 0;
|
QVector<QPointF> data;
|
||||||
|
qreal min, max, ascent = 0, descent = 0;
|
||||||
|
|
||||||
|
gpx.track(i).elevationGraph(data);
|
||||||
|
if (data.isEmpty())
|
||||||
|
continue;
|
||||||
|
|
||||||
gpx.elevationGraph(data);
|
min = max = data.at(0).y();
|
||||||
if (data.isEmpty())
|
|
||||||
return;
|
|
||||||
|
|
||||||
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 i = 1; i < data.size(); i++) {
|
if (cur > prev)
|
||||||
qreal cur = data.at(i).y();
|
ascent += cur - prev;
|
||||||
qreal prev = data.at(i-1).y();
|
if (cur < prev)
|
||||||
|
descent += prev - cur;
|
||||||
|
|
||||||
if (cur > prev)
|
if (cur > max)
|
||||||
ascent += cur - prev;
|
max = cur;
|
||||||
if (cur < prev)
|
if (cur < min)
|
||||||
descent += prev - cur;
|
min = cur;
|
||||||
|
}
|
||||||
|
|
||||||
if (cur > max)
|
_ascent += ascent;
|
||||||
max = cur;
|
_descent += descent;
|
||||||
if (cur < min)
|
_max = qMax(_max, max);
|
||||||
min = cur;
|
_min = qMin(_min, min);
|
||||||
|
|
||||||
|
addInfo();
|
||||||
|
loadData(data);
|
||||||
}
|
}
|
||||||
|
|
||||||
_ascent += ascent;
|
|
||||||
_descent += descent;
|
|
||||||
_max = qMax(_max, max);
|
|
||||||
_min = qMin(_min, min);
|
|
||||||
|
|
||||||
addInfo(tr("Ascent"), QString::number(_ascent, 'f', 0)
|
|
||||||
+ THIN_SPACE + _yUnits);
|
|
||||||
addInfo(tr("Descent"), QString::number(_descent, 'f', 0)
|
|
||||||
+ THIN_SPACE + _yUnits);
|
|
||||||
addInfo(tr("Maximum"), QString::number(_max, 'f', 0)
|
|
||||||
+ THIN_SPACE + _yUnits);
|
|
||||||
addInfo(tr("Minimum"), QString::number(_min, 'f', 0)
|
|
||||||
+ THIN_SPACE + _yUnits);
|
|
||||||
|
|
||||||
Graph::loadData(data);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void ElevationGraph::clear()
|
void ElevationGraph::clear()
|
||||||
@ -68,5 +75,25 @@ void ElevationGraph::clear()
|
|||||||
_max = -FLT_MAX;
|
_max = -FLT_MAX;
|
||||||
_min = FLT_MAX;
|
_min = FLT_MAX;
|
||||||
|
|
||||||
Graph::clear();
|
GraphView::clear();
|
||||||
|
}
|
||||||
|
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
|
||||||
|
clearInfo();
|
||||||
|
addInfo();
|
||||||
|
|
||||||
|
redraw();
|
||||||
}
|
}
|
||||||
|
@ -1,10 +1,12 @@
|
|||||||
#ifndef ELEVATIONGRAPH_H
|
#ifndef ELEVATIONGRAPH_H
|
||||||
#define ELEVATIONGRAPH_H
|
#define ELEVATIONGRAPH_H
|
||||||
|
|
||||||
#include "graph.h"
|
#include "graphview.h"
|
||||||
#include "gpx.h"
|
#include "units.h"
|
||||||
|
|
||||||
class ElevationGraph : public Graph
|
class GPX;
|
||||||
|
|
||||||
|
class ElevationGraph : public GraphView
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
@ -13,6 +15,7 @@ public:
|
|||||||
|
|
||||||
void loadGPX(const GPX &gpx);
|
void loadGPX(const GPX &gpx);
|
||||||
void clear();
|
void clear();
|
||||||
|
void setUnits(enum Units units);
|
||||||
|
|
||||||
qreal ascent() const {return _ascent;}
|
qreal ascent() const {return _ascent;}
|
||||||
qreal descent() const {return _descent;}
|
qreal descent() const {return _descent;}
|
||||||
@ -20,6 +23,8 @@ public:
|
|||||||
qreal min() const {return _min;}
|
qreal min() const {return _min;}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
void addInfo();
|
||||||
|
|
||||||
qreal _ascent, _descent;
|
qreal _ascent, _descent;
|
||||||
qreal _max, _min;
|
qreal _max, _min;
|
||||||
};
|
};
|
||||||
|
@ -41,6 +41,16 @@ void FileBrowser::setFilter(const QStringList &filter)
|
|||||||
reloadDirectory(_files.last().canonicalPath());
|
reloadDirectory(_files.last().canonicalPath());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool FileBrowser::isLast() const
|
||||||
|
{
|
||||||
|
return (_files.size() > 0 && _index == _files.size() - 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool FileBrowser::isFirst() const
|
||||||
|
{
|
||||||
|
return (_files.size() > 0 && _index == 0);
|
||||||
|
}
|
||||||
|
|
||||||
QString FileBrowser::next()
|
QString FileBrowser::next()
|
||||||
{
|
{
|
||||||
if (_index < 0 || _index == _files.size() - 1)
|
if (_index < 0 || _index == _files.size() - 1)
|
||||||
@ -57,6 +67,24 @@ QString FileBrowser::prev()
|
|||||||
return _files.at(--_index).absoluteFilePath();
|
return _files.at(--_index).absoluteFilePath();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QString FileBrowser::last()
|
||||||
|
{
|
||||||
|
if (_files.empty())
|
||||||
|
return QString();
|
||||||
|
|
||||||
|
_index = _files.size() - 1;
|
||||||
|
return _files.last().absoluteFilePath();
|
||||||
|
}
|
||||||
|
|
||||||
|
QString FileBrowser::first()
|
||||||
|
{
|
||||||
|
if (_files.empty())
|
||||||
|
return QString();
|
||||||
|
|
||||||
|
_index = 0;
|
||||||
|
return _files.first().absoluteFilePath();
|
||||||
|
}
|
||||||
|
|
||||||
void FileBrowser::reloadDirectory(const QString &path)
|
void FileBrowser::reloadDirectory(const QString &path)
|
||||||
{
|
{
|
||||||
QDir dir(path);
|
QDir dir(path);
|
||||||
|
@ -20,6 +20,11 @@ public:
|
|||||||
|
|
||||||
QString next();
|
QString next();
|
||||||
QString prev();
|
QString prev();
|
||||||
|
QString last();
|
||||||
|
QString first();
|
||||||
|
|
||||||
|
bool isLast() const;
|
||||||
|
bool isFirst() const;
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void reloadDirectory(const QString &path);
|
void reloadDirectory(const QString &path);
|
||||||
|
158
src/gpx.cpp
158
src/gpx.cpp
@ -4,88 +4,12 @@
|
|||||||
#include "gpx.h"
|
#include "gpx.h"
|
||||||
|
|
||||||
|
|
||||||
#define WINDOW_EF 3
|
|
||||||
#define WINDOW_SE 11
|
|
||||||
#define WINDOW_SF 11
|
|
||||||
|
|
||||||
static bool lt(const QPointF &p1, const QPointF &p2)
|
|
||||||
{
|
|
||||||
return p1.y() < p2.y();
|
|
||||||
}
|
|
||||||
|
|
||||||
static qreal median(QVector<QPointF> v)
|
|
||||||
{
|
|
||||||
qSort(v.begin(), v.end(), lt);
|
|
||||||
return v.at(v.size() / 2).y();
|
|
||||||
}
|
|
||||||
|
|
||||||
static qreal MAD(QVector<QPointF> v, qreal m)
|
|
||||||
{
|
|
||||||
for (int i = 0; i < v.size(); i++)
|
|
||||||
v[i].setY(qAbs(v.at(i).y() - m));
|
|
||||||
qSort(v.begin(), v.end(), lt);
|
|
||||||
return v.at(v.size() / 2).y();
|
|
||||||
}
|
|
||||||
|
|
||||||
static QVector<QPointF> eliminate(const QVector<QPointF> &v, int window)
|
|
||||||
{
|
|
||||||
QList<int> rm;
|
|
||||||
QVector<QPointF> ret;
|
|
||||||
qreal m, M;
|
|
||||||
|
|
||||||
|
|
||||||
if (v.size() < window)
|
|
||||||
return QVector<QPointF>(v);
|
|
||||||
|
|
||||||
for (int i = window/2; i < v.size() - window/2; i++) {
|
|
||||||
m = median(v.mid(i - window/2, window));
|
|
||||||
M = MAD(v.mid(i - window/2, window), m);
|
|
||||||
if (qAbs((0.6745 * (v.at(i).y() - m)) / M) > 3.5)
|
|
||||||
rm.append(i);
|
|
||||||
}
|
|
||||||
|
|
||||||
QList<int>::const_iterator it = rm.begin();
|
|
||||||
for (int i = 0; i < v.size(); i++) {
|
|
||||||
if (it == rm.end() || *it != i)
|
|
||||||
ret.append(v.at(i));
|
|
||||||
else
|
|
||||||
it++;
|
|
||||||
}
|
|
||||||
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
static QVector<QPointF> filter(const QVector<QPointF> &v, int window)
|
|
||||||
{
|
|
||||||
qreal acc = 0;
|
|
||||||
QVector<QPointF> ret;
|
|
||||||
|
|
||||||
if (v.size() < window)
|
|
||||||
return QVector<QPointF>(v);
|
|
||||||
|
|
||||||
for (int i = 0; i < window; i++)
|
|
||||||
acc += v.at(i).y();
|
|
||||||
for (int i = 0; i <= window/2; i++)
|
|
||||||
ret.append(QPointF(v.at(i).x(), acc/window));
|
|
||||||
|
|
||||||
for (int i = window/2 + 1; i < v.size() - window/2; i++) {
|
|
||||||
acc += v.at(i + window/2).y() - v.at(i - (window/2 + 1)).y();
|
|
||||||
ret.append(QPointF(v.at(i).x(), acc/window));
|
|
||||||
}
|
|
||||||
|
|
||||||
for (int i = v.size() - window/2; i < v.size(); i++)
|
|
||||||
ret.append(QPointF(v.at(i).x(), acc/window));
|
|
||||||
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
bool GPX::loadFile(const QString &fileName)
|
bool GPX::loadFile(const QString &fileName)
|
||||||
{
|
{
|
||||||
QFile file(fileName);
|
QFile file(fileName);
|
||||||
bool ret;
|
bool ret;
|
||||||
|
|
||||||
_data.clear();
|
_tracks.clear();
|
||||||
_error.clear();
|
_error.clear();
|
||||||
_errorLine = 0;
|
_errorLine = 0;
|
||||||
|
|
||||||
@ -94,7 +18,7 @@ bool GPX::loadFile(const QString &fileName)
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!(ret = _parser.loadFile(&file, _data))) {
|
if (!(ret = _parser.loadFile(&file))) {
|
||||||
_error = _parser.errorString();
|
_error = _parser.errorString();
|
||||||
_errorLine = _parser.errorLine();
|
_errorLine = _parser.errorLine();
|
||||||
}
|
}
|
||||||
@ -102,81 +26,3 @@ bool GPX::loadFile(const QString &fileName)
|
|||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
void GPX::elevationGraph(QVector<QPointF> &graph) const
|
|
||||||
{
|
|
||||||
qreal dist = 0;
|
|
||||||
QVector<QPointF> raw;
|
|
||||||
|
|
||||||
if (!_data.size())
|
|
||||||
return;
|
|
||||||
|
|
||||||
raw.append(QPointF(0, _data.at(0).elevation));
|
|
||||||
for (int i = 1; i < _data.size(); i++) {
|
|
||||||
dist += llDistance(_data.at(i).coordinates, _data.at(i-1).coordinates);
|
|
||||||
raw.append(QPointF(dist, _data.at(i).elevation
|
|
||||||
- _data.at(i).geoidheight));
|
|
||||||
}
|
|
||||||
|
|
||||||
graph = filter(raw, WINDOW_EF);
|
|
||||||
}
|
|
||||||
|
|
||||||
void GPX::speedGraph(QVector<QPointF> &graph) const
|
|
||||||
{
|
|
||||||
qreal dist = 0, v, ds, dt;
|
|
||||||
QVector<QPointF> raw;
|
|
||||||
|
|
||||||
if (!_data.size())
|
|
||||||
return;
|
|
||||||
|
|
||||||
raw.append(QPointF(0, 0));
|
|
||||||
for (int i = 1; i < _data.size(); i++) {
|
|
||||||
ds = llDistance(_data.at(i).coordinates, _data.at(i-1).coordinates);
|
|
||||||
dt = _data.at(i-1).timestamp.msecsTo(_data.at(i).timestamp) / 1000.0;
|
|
||||||
dist += ds;
|
|
||||||
|
|
||||||
if (_data.at(i).speed < 0) {
|
|
||||||
if (dt == 0)
|
|
||||||
continue;
|
|
||||||
v = ds / dt;
|
|
||||||
} else
|
|
||||||
v = _data.at(i).speed;
|
|
||||||
|
|
||||||
raw.append(QPointF(dist, v));
|
|
||||||
}
|
|
||||||
|
|
||||||
graph = filter(eliminate(raw, WINDOW_SE), WINDOW_SF);
|
|
||||||
}
|
|
||||||
|
|
||||||
void GPX::track(QVector<QPointF> &track) const
|
|
||||||
{
|
|
||||||
for (int i = 0; i < _data.size(); i++)
|
|
||||||
track.append(ll2mercator(_data.at(i).coordinates));
|
|
||||||
}
|
|
||||||
|
|
||||||
qreal GPX::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 GPX::time() const
|
|
||||||
{
|
|
||||||
if (_data.size() < 2)
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
return (_data.at(0).timestamp.msecsTo(_data.at(_data.size() - 1).timestamp)
|
|
||||||
/ 1000.0);
|
|
||||||
}
|
|
||||||
|
|
||||||
QDateTime GPX::date() const
|
|
||||||
{
|
|
||||||
if (_data.size())
|
|
||||||
return _data.at(0).timestamp;
|
|
||||||
else
|
|
||||||
return QDateTime();
|
|
||||||
}
|
|
||||||
|
17
src/gpx.h
17
src/gpx.h
@ -2,29 +2,32 @@
|
|||||||
#define GPX_H
|
#define GPX_H
|
||||||
|
|
||||||
#include <QVector>
|
#include <QVector>
|
||||||
|
#include <QList>
|
||||||
#include <QPointF>
|
#include <QPointF>
|
||||||
#include <QString>
|
#include <QString>
|
||||||
|
#include "waypoint.h"
|
||||||
|
#include "track.h"
|
||||||
#include "parser.h"
|
#include "parser.h"
|
||||||
|
|
||||||
class GPX
|
class GPX
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
GPX() : _parser(_tracks, _waypoints), _errorLine(0) {}
|
||||||
bool loadFile(const QString &fileName);
|
bool loadFile(const QString &fileName);
|
||||||
const QString &errorString() const {return _error;}
|
const QString &errorString() const {return _error;}
|
||||||
int errorLine() const {return _errorLine;}
|
int errorLine() const {return _errorLine;}
|
||||||
|
|
||||||
void elevationGraph(QVector<QPointF> &graph) const;
|
int trackCount() const {return _tracks.count();}
|
||||||
void speedGraph(QVector<QPointF> &graph) const;
|
Track track(int i) const {return Track(_tracks.at(i));}
|
||||||
void track(QVector<QPointF> &track) const;
|
const QList<Waypoint> &waypoints() const {return _waypoints;}
|
||||||
qreal distance() const;
|
|
||||||
qreal time() const;
|
|
||||||
QDateTime date() const;
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Parser _parser;
|
Parser _parser;
|
||||||
QVector<TrackPoint> _data;
|
|
||||||
QString _error;
|
QString _error;
|
||||||
int _errorLine;
|
int _errorLine;
|
||||||
|
|
||||||
|
QList<QVector<Trackpoint> > _tracks;
|
||||||
|
QList<Waypoint> _waypoints;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // GPX_H
|
#endif // GPX_H
|
||||||
|
@ -3,11 +3,12 @@
|
|||||||
#include <QGraphicsSceneMouseEvent>
|
#include <QGraphicsSceneMouseEvent>
|
||||||
#include <QEvent>
|
#include <QEvent>
|
||||||
#include <QGraphicsSimpleTextItem>
|
#include <QGraphicsSimpleTextItem>
|
||||||
|
#include "config.h"
|
||||||
|
#include "axisitem.h"
|
||||||
#include "slideritem.h"
|
#include "slideritem.h"
|
||||||
#include "sliderinfoitem.h"
|
#include "sliderinfoitem.h"
|
||||||
#include "infoitem.h"
|
#include "infoitem.h"
|
||||||
#include "config.h"
|
#include "graphview.h"
|
||||||
#include "graph.h"
|
|
||||||
|
|
||||||
|
|
||||||
#define MARGIN 10.0
|
#define MARGIN 10.0
|
||||||
@ -21,7 +22,7 @@ void Scene::mousePressEvent(QGraphicsSceneMouseEvent *e)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
Graph::Graph(QWidget *parent)
|
GraphView::GraphView(QWidget *parent)
|
||||||
: QGraphicsView(parent)
|
: QGraphicsView(parent)
|
||||||
{
|
{
|
||||||
_scene = new Scene(this);
|
_scene = new Scene(this);
|
||||||
@ -52,9 +53,10 @@ Graph::Graph(QWidget *parent)
|
|||||||
_yScale = 1;
|
_yScale = 1;
|
||||||
|
|
||||||
_precision = 0;
|
_precision = 0;
|
||||||
|
_minRange = 0.01;
|
||||||
}
|
}
|
||||||
|
|
||||||
Graph::~Graph()
|
GraphView::~GraphView()
|
||||||
{
|
{
|
||||||
if (_xAxis->scene() != _scene)
|
if (_xAxis->scene() != _scene)
|
||||||
delete _xAxis;
|
delete _xAxis;
|
||||||
@ -70,7 +72,7 @@ Graph::~Graph()
|
|||||||
delete _scene;
|
delete _scene;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Graph::updateBounds(const QPointF &point)
|
void GraphView::updateBounds(const QPointF &point)
|
||||||
{
|
{
|
||||||
if (point.x() < _xMin)
|
if (point.x() < _xMin)
|
||||||
_xMin = point.x();
|
_xMin = point.x();
|
||||||
@ -82,45 +84,54 @@ void Graph::updateBounds(const QPointF &point)
|
|||||||
_yMax = point.y();
|
_yMax = point.y();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Graph::createXLabel()
|
void GraphView::createXLabel()
|
||||||
{
|
{
|
||||||
_xAxis->setLabel(QString("%1 [%2]").arg(_xLabel).arg(_xUnits));
|
_xAxis->setLabel(QString("%1 [%2]").arg(_xLabel).arg(_xUnits));
|
||||||
}
|
}
|
||||||
|
|
||||||
void Graph::createYLabel()
|
void GraphView::createYLabel()
|
||||||
{
|
{
|
||||||
_yAxis->setLabel(QString("%1 [%2]").arg(_yLabel).arg(_yUnits));
|
_yAxis->setLabel(QString("%1 [%2]").arg(_yLabel).arg(_yUnits));
|
||||||
}
|
}
|
||||||
|
|
||||||
void Graph::setXLabel(const QString &label)
|
void GraphView::setXLabel(const QString &label)
|
||||||
{
|
{
|
||||||
_xLabel = label;
|
_xLabel = label;
|
||||||
createXLabel();
|
createXLabel();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Graph::setYLabel(const QString &label)
|
void GraphView::setYLabel(const QString &label)
|
||||||
{
|
{
|
||||||
_yLabel = label;
|
_yLabel = label;
|
||||||
createYLabel();
|
createYLabel();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Graph::setXUnits(const QString &units)
|
void GraphView::setXUnits(const QString &units)
|
||||||
{
|
{
|
||||||
_xUnits = units;
|
_xUnits = units;
|
||||||
createXLabel();
|
createXLabel();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Graph::setYUnits(const QString &units)
|
void GraphView::setYUnits(const QString &units)
|
||||||
{
|
{
|
||||||
_yUnits = units;
|
_yUnits = units;
|
||||||
createYLabel();
|
createYLabel();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Graph::loadData(const QVector<QPointF> &data)
|
void GraphView::setXScale(qreal scale)
|
||||||
|
{
|
||||||
|
_xScale = scale;
|
||||||
|
}
|
||||||
|
|
||||||
|
void GraphView::setYScale(qreal scale)
|
||||||
|
{
|
||||||
|
_yScale = scale;
|
||||||
|
}
|
||||||
|
|
||||||
|
void GraphView::loadData(const QVector<QPointF> &data)
|
||||||
{
|
{
|
||||||
QPainterPath path;
|
QPainterPath path;
|
||||||
QGraphicsPathItem *pi;
|
QGraphicsPathItem *pi;
|
||||||
QColor color = _colorShop.color();
|
|
||||||
|
|
||||||
|
|
||||||
if (data.size() < 2)
|
if (data.size() < 2)
|
||||||
@ -129,12 +140,13 @@ void Graph::loadData(const QVector<QPointF> &data)
|
|||||||
updateBounds(data.at(0));
|
updateBounds(data.at(0));
|
||||||
path.moveTo(data.at(0).x(), -data.at(0).y());
|
path.moveTo(data.at(0).x(), -data.at(0).y());
|
||||||
for (int i = 1; i < data.size(); i++) {
|
for (int i = 1; i < data.size(); i++) {
|
||||||
path.lineTo(data.at(i).x(), -data.at(i).y());
|
const QPointF &p = data.at(i);
|
||||||
updateBounds(data.at(i));
|
path.lineTo(p.x(), -p.y());
|
||||||
|
updateBounds(p);
|
||||||
}
|
}
|
||||||
|
|
||||||
pi = new QGraphicsPathItem(path);
|
pi = new QGraphicsPathItem(path);
|
||||||
QBrush brush(color, Qt::SolidPattern);
|
QBrush brush(_palette.color(), Qt::SolidPattern);
|
||||||
QPen pen(brush, 0);
|
QPen pen(brush, 0);
|
||||||
pi->setPen(pen);
|
pi->setPen(pen);
|
||||||
_scene->addItem(pi);
|
_scene->addItem(pi);
|
||||||
@ -143,15 +155,22 @@ void Graph::loadData(const QVector<QPointF> &data)
|
|||||||
if (_graphs.size() > 1)
|
if (_graphs.size() > 1)
|
||||||
_sliderInfo->hide();
|
_sliderInfo->hide();
|
||||||
|
|
||||||
resize(viewport()->size() - QSizeF(MARGIN, MARGIN));
|
redraw();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Graph::resize(const QSizeF &size)
|
void GraphView::redraw()
|
||||||
|
{
|
||||||
|
if (!_graphs.isEmpty())
|
||||||
|
resize(viewport()->size() - QSizeF(MARGIN, MARGIN));
|
||||||
|
}
|
||||||
|
|
||||||
|
void GraphView::resize(const QSizeF &size)
|
||||||
{
|
{
|
||||||
QRectF r;
|
QRectF r;
|
||||||
QSizeF mx, my;
|
QSizeF mx, my;
|
||||||
|
QPointF rx, ry;
|
||||||
QTransform transform;
|
QTransform transform;
|
||||||
qreal xs, ys;
|
qreal xs, ys, diff;
|
||||||
|
|
||||||
|
|
||||||
if (_xAxis->scene() == _scene)
|
if (_xAxis->scene() == _scene)
|
||||||
@ -166,11 +185,21 @@ void Graph::resize(const QSizeF &size)
|
|||||||
for (int i = 0; i < _graphs.size(); i++)
|
for (int i = 0; i < _graphs.size(); i++)
|
||||||
_graphs.at(i)->resetTransform();
|
_graphs.at(i)->resetTransform();
|
||||||
|
|
||||||
_xAxis->setRange(QPointF(_xMin * _xScale, _xMax * _xScale));
|
rx = QPointF(_xMin * _xScale, _xMax * _xScale);
|
||||||
_yAxis->setRange(QPointF(_yMin * _yScale, _yMax * _yScale));
|
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));
|
||||||
|
_xAxis->setRange(rx);
|
||||||
|
_yAxis->setRange(ry);
|
||||||
mx = _xAxis->margin();
|
mx = _xAxis->margin();
|
||||||
my = _yAxis->margin();
|
my = _yAxis->margin();
|
||||||
|
|
||||||
r = _scene->itemsBoundingRect();
|
r = _scene->itemsBoundingRect();
|
||||||
|
if (r.height() < _minRange)
|
||||||
|
r.adjust(0, -(_minRange/2 - r.height()/2), 0,
|
||||||
|
_minRange/2 - r.height()/2);
|
||||||
|
|
||||||
xs = (size.width() - (my.width() + mx.width())) / r.width();
|
xs = (size.width() - (my.width() + mx.width())) / r.width();
|
||||||
ys = (size.height() - (mx.height() + my.height())
|
ys = (size.height() - (mx.height() + my.height())
|
||||||
- _info->boundingRect().height()) / r.height();
|
- _info->boundingRect().height()) / r.height();
|
||||||
@ -180,6 +209,10 @@ void Graph::resize(const QSizeF &size)
|
|||||||
_graphs.at(i)->setTransform(transform);
|
_graphs.at(i)->setTransform(transform);
|
||||||
|
|
||||||
r = _scene->itemsBoundingRect();
|
r = _scene->itemsBoundingRect();
|
||||||
|
if (r.height() < _minRange * ys)
|
||||||
|
r.adjust(0, -(_minRange/2 * ys - r.height()/2), 0,
|
||||||
|
(_minRange/2) * ys - r.height()/2);
|
||||||
|
|
||||||
_xAxis->setSize(r.width());
|
_xAxis->setSize(r.width());
|
||||||
_yAxis->setSize(r.height());
|
_yAxis->setSize(r.height());
|
||||||
_xAxis->setPos(r.bottomLeft());
|
_xAxis->setPos(r.bottomLeft());
|
||||||
@ -187,10 +220,17 @@ void Graph::resize(const QSizeF &size)
|
|||||||
_scene->addItem(_xAxis);
|
_scene->addItem(_xAxis);
|
||||||
_scene->addItem(_yAxis);
|
_scene->addItem(_yAxis);
|
||||||
|
|
||||||
|
qreal sp = (_slider->pos().x() == _slider->area().left())
|
||||||
|
? 0 : (_slider->pos().x() - _slider->area().left())
|
||||||
|
/ _slider->area().width();
|
||||||
_slider->setArea(r);
|
_slider->setArea(r);
|
||||||
_slider->setPos(r.bottomLeft());
|
_slider->setPos(QPointF(sp * r.width(), r.bottom()));
|
||||||
_scene->addItem(_slider);
|
_scene->addItem(_slider);
|
||||||
|
|
||||||
|
const QPainterPath &path = _graphs.at(0)->path();
|
||||||
|
QPointF p = path.pointAtPercent(sp);
|
||||||
|
_sliderInfo->setText(QString::number(-p.y() * _yScale, 'f', _precision));
|
||||||
|
|
||||||
r = _scene->itemsBoundingRect();
|
r = _scene->itemsBoundingRect();
|
||||||
_info->setPos(r.topLeft() + QPointF(r.width()/2
|
_info->setPos(r.topLeft() + QPointF(r.width()/2
|
||||||
- _info->boundingRect().width()/2, -_info->boundingRect().height()));
|
- _info->boundingRect().width()/2, -_info->boundingRect().height()));
|
||||||
@ -199,13 +239,13 @@ void Graph::resize(const QSizeF &size)
|
|||||||
_scene->setSceneRect(_scene->itemsBoundingRect());
|
_scene->setSceneRect(_scene->itemsBoundingRect());
|
||||||
}
|
}
|
||||||
|
|
||||||
void Graph::resizeEvent(QResizeEvent *)
|
void GraphView::resizeEvent(QResizeEvent *)
|
||||||
{
|
{
|
||||||
if (!_graphs.empty())
|
if (!_graphs.empty())
|
||||||
resize(viewport()->size() - QSizeF(MARGIN, MARGIN));
|
redraw();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Graph::plot(QPainter *painter, const QRectF &target)
|
void GraphView::plot(QPainter *painter, const QRectF &target)
|
||||||
{
|
{
|
||||||
qreal ratio = target.width() / target.height();
|
qreal ratio = target.width() / target.height();
|
||||||
QSizeF orig = _scene->sceneRect().size();
|
QSizeF orig = _scene->sceneRect().size();
|
||||||
@ -214,13 +254,13 @@ void Graph::plot(QPainter *painter, const QRectF &target)
|
|||||||
resize(canvas);
|
resize(canvas);
|
||||||
_slider->hide();
|
_slider->hide();
|
||||||
_info->hide();
|
_info->hide();
|
||||||
_scene->render(painter, target, QRectF(), Qt::KeepAspectRatioByExpanding);
|
_scene->render(painter, target, QRectF());
|
||||||
_slider->show();
|
_slider->show();
|
||||||
_info->show();
|
_info->show();
|
||||||
resize(orig);
|
resize(orig);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Graph::clear()
|
void GraphView::clear()
|
||||||
{
|
{
|
||||||
if (_xAxis->scene() == _scene)
|
if (_xAxis->scene() == _scene)
|
||||||
_scene->removeItem(_xAxis);
|
_scene->removeItem(_xAxis);
|
||||||
@ -234,10 +274,11 @@ void Graph::clear()
|
|||||||
_scene->removeItem(_info);
|
_scene->removeItem(_info);
|
||||||
_sliderInfo->show();
|
_sliderInfo->show();
|
||||||
|
|
||||||
|
_slider->clear();
|
||||||
_info->clear();
|
_info->clear();
|
||||||
_scene->clear();
|
_scene->clear();
|
||||||
_graphs.clear();
|
_graphs.clear();
|
||||||
_colorShop.reset();
|
_palette.reset();
|
||||||
|
|
||||||
_xMax = -FLT_MAX;
|
_xMax = -FLT_MAX;
|
||||||
_xMin = FLT_MAX;
|
_xMin = FLT_MAX;
|
||||||
@ -247,7 +288,7 @@ void Graph::clear()
|
|||||||
_scene->setSceneRect(0, 0, 0, 0);
|
_scene->setSceneRect(0, 0, 0, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Graph::emitSliderPositionChanged(const QPointF &pos)
|
void GraphView::emitSliderPositionChanged(const QPointF &pos)
|
||||||
{
|
{
|
||||||
if (_graphs.isEmpty())
|
if (_graphs.isEmpty())
|
||||||
return;
|
return;
|
||||||
@ -256,24 +297,27 @@ void Graph::emitSliderPositionChanged(const QPointF &pos)
|
|||||||
emit sliderPositionChanged(val);
|
emit sliderPositionChanged(val);
|
||||||
|
|
||||||
const QPainterPath &path = _graphs.at(0)->path();
|
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);
|
QPointF p = path.pointAtPercent(val);
|
||||||
qreal r = (p.y() - path.boundingRect().bottom())
|
qreal r = (p.y() - br.bottom()) / br.height();
|
||||||
/ path.boundingRect().height();
|
|
||||||
_sliderInfo->setPos(QPointF(0, _slider->boundingRect().height() * r));
|
_sliderInfo->setPos(QPointF(0, _slider->boundingRect().height() * r));
|
||||||
_sliderInfo->setText(QString::number(-p.y() * _yScale, 'f', _precision));
|
_sliderInfo->setText(QString::number(-p.y() * _yScale, 'f', _precision));
|
||||||
}
|
}
|
||||||
|
|
||||||
qreal Graph::sliderPosition() const
|
qreal GraphView::sliderPosition() const
|
||||||
{
|
{
|
||||||
return _slider->pos().x() / _slider->area().width();
|
return _slider->pos().x() / _slider->area().width();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Graph::setSliderPosition(qreal pos)
|
void GraphView::setSliderPosition(qreal pos)
|
||||||
{
|
{
|
||||||
_slider->setPos(pos * _slider->area().width(), 0);
|
_slider->setPos(pos * _slider->area().width(), 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Graph::newSliderPosition(const QPointF &pos)
|
void GraphView::newSliderPosition(const QPointF &pos)
|
||||||
{
|
{
|
||||||
if (_slider->area().contains(pos)) {
|
if (_slider->area().contains(pos)) {
|
||||||
_slider->setPos(pos);
|
_slider->setPos(pos);
|
||||||
@ -281,7 +325,12 @@ void Graph::newSliderPosition(const QPointF &pos)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Graph::addInfo(const QString &key, const QString &value)
|
void GraphView::addInfo(const QString &key, const QString &value)
|
||||||
{
|
{
|
||||||
_info->insert(key, value);
|
_info->insert(key, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void GraphView::clearInfo()
|
||||||
|
{
|
||||||
|
_info->clear();
|
||||||
|
}
|
@ -1,17 +1,15 @@
|
|||||||
#ifndef GRAPH_H
|
#ifndef GRAPHVIEW_H
|
||||||
#define GRAPH_H
|
#define GRAPHVIEW_H
|
||||||
|
|
||||||
#include <QGraphicsView>
|
#include <QGraphicsView>
|
||||||
#include <QGraphicsScene>
|
#include <QGraphicsScene>
|
||||||
#include <QVector>
|
#include <QVector>
|
||||||
#include <QList>
|
#include <QList>
|
||||||
#include <QPointF>
|
#include <QPointF>
|
||||||
#include "axisitem.h"
|
#include "palette.h"
|
||||||
#include "colorshop.h"
|
|
||||||
|
|
||||||
|
|
||||||
#define THIN_SPACE QString::fromUtf8("\xE2\x80\x89")
|
class AxisItem;
|
||||||
|
|
||||||
class SliderItem;
|
class SliderItem;
|
||||||
class SliderInfoItem;
|
class SliderInfoItem;
|
||||||
class InfoItem;
|
class InfoItem;
|
||||||
@ -28,22 +26,25 @@ signals:
|
|||||||
void mouseClicked(const QPointF &pos);
|
void mouseClicked(const QPointF &pos);
|
||||||
};
|
};
|
||||||
|
|
||||||
class Graph : public QGraphicsView
|
class GraphView : public QGraphicsView
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
Graph(QWidget *parent = 0);
|
GraphView(QWidget *parent = 0);
|
||||||
~Graph();
|
~GraphView();
|
||||||
|
|
||||||
void loadData(const QVector<QPointF> &data);
|
void loadData(const QVector<QPointF> &data);
|
||||||
void setXLabel(const QString &label);
|
void setXLabel(const QString &label);
|
||||||
void setYLabel(const QString &label);
|
void setYLabel(const QString &label);
|
||||||
void setXUnits(const QString &units);
|
void setXUnits(const QString &units);
|
||||||
void setYUnits(const QString &units);
|
void setYUnits(const QString &units);
|
||||||
void setXScale(qreal scale) {_xScale = scale;}
|
void setXScale(qreal scale);
|
||||||
void setYScale(qreal scale) {_yScale = scale;}
|
void setYScale(qreal scale);
|
||||||
void setPrecision(int p) {_precision = p;}
|
void setPrecision(int precision) {_precision = precision;}
|
||||||
|
void setMinRange(qreal range) {_minRange = range;}
|
||||||
|
|
||||||
|
void redraw();
|
||||||
|
|
||||||
void plot(QPainter *painter, const QRectF &target);
|
void plot(QPainter *painter, const QRectF &target);
|
||||||
void clear();
|
void clear();
|
||||||
@ -52,6 +53,7 @@ public:
|
|||||||
void setSliderPosition(qreal pos);
|
void setSliderPosition(qreal pos);
|
||||||
|
|
||||||
void addInfo(const QString &key, const QString &value);
|
void addInfo(const QString &key, const QString &value);
|
||||||
|
void clearInfo();
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void sliderPositionChanged(qreal);
|
void sliderPositionChanged(qreal);
|
||||||
@ -63,6 +65,7 @@ protected:
|
|||||||
QString _xUnits, _yUnits;
|
QString _xUnits, _yUnits;
|
||||||
QString _xLabel, _yLabel;
|
QString _xLabel, _yLabel;
|
||||||
int _precision;
|
int _precision;
|
||||||
|
qreal _minRange;
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void emitSliderPositionChanged(const QPointF &pos);
|
void emitSliderPositionChanged(const QPointF &pos);
|
||||||
@ -83,7 +86,7 @@ private:
|
|||||||
|
|
||||||
QList<QGraphicsPathItem*> _graphs;
|
QList<QGraphicsPathItem*> _graphs;
|
||||||
qreal _xMin, _xMax, _yMin, _yMax;
|
qreal _xMin, _xMax, _yMin, _yMax;
|
||||||
ColorShop _colorShop;
|
Palette _palette;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // GRAPH_H
|
#endif // GRAPHVIEW_H
|
326
src/gui.cpp
326
src/gui.cpp
@ -8,6 +8,12 @@
|
|||||||
#include <QPainter>
|
#include <QPainter>
|
||||||
#include <QKeyEvent>
|
#include <QKeyEvent>
|
||||||
#include <QSignalMapper>
|
#include <QSignalMapper>
|
||||||
|
#include <QMenu>
|
||||||
|
#include <QToolBar>
|
||||||
|
#include <QTabWidget>
|
||||||
|
#include <QActionGroup>
|
||||||
|
#include <QAction>
|
||||||
|
#include <QLabel>
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
#include "icons.h"
|
#include "icons.h"
|
||||||
#include "keys.h"
|
#include "keys.h"
|
||||||
@ -16,7 +22,7 @@
|
|||||||
#include "maplist.h"
|
#include "maplist.h"
|
||||||
#include "elevationgraph.h"
|
#include "elevationgraph.h"
|
||||||
#include "speedgraph.h"
|
#include "speedgraph.h"
|
||||||
#include "track.h"
|
#include "trackview.h"
|
||||||
#include "infoitem.h"
|
#include "infoitem.h"
|
||||||
#include "filebrowser.h"
|
#include "filebrowser.h"
|
||||||
#include "gui.h"
|
#include "gui.h"
|
||||||
@ -31,11 +37,11 @@ static QString timeSpan(qreal time)
|
|||||||
s = time - (h * 3600) - (m * 60);
|
s = time - (h * 3600) - (m * 60);
|
||||||
|
|
||||||
return QString("%1:%2:%3").arg(h).arg(m, 2, 10, QChar('0'))
|
return QString("%1:%2:%3").arg(h).arg(m, 2, 10, QChar('0'))
|
||||||
.arg(s,2, 10, QChar('0'));
|
.arg(s, 2, 10, QChar('0'));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
GUI::GUI()
|
GUI::GUI(QWidget *parent) : QMainWindow(parent)
|
||||||
{
|
{
|
||||||
loadFiles();
|
loadFiles();
|
||||||
|
|
||||||
@ -67,6 +73,7 @@ GUI::GUI()
|
|||||||
|
|
||||||
_distance = 0;
|
_distance = 0;
|
||||||
_time = 0;
|
_time = 0;
|
||||||
|
_trackCount = 0;
|
||||||
|
|
||||||
resize(600, 800);
|
resize(600, 800);
|
||||||
}
|
}
|
||||||
@ -74,17 +81,15 @@ GUI::GUI()
|
|||||||
void GUI::loadFiles()
|
void GUI::loadFiles()
|
||||||
{
|
{
|
||||||
// Maps
|
// Maps
|
||||||
_maps = MapList::load(QString("%1/"MAP_LIST_FILE).arg(QDir::homePath()));
|
_maps = MapList::load(this, QString("%1/" MAP_LIST_FILE)
|
||||||
|
.arg(QDir::homePath()));
|
||||||
|
_maps += MapList::load(this, ":/maps.txt");
|
||||||
|
|
||||||
// POI files
|
// POI files
|
||||||
QDir dir(QString("%1/"POI_DIR).arg(QDir::homePath()));
|
QDir dir(QString("%1/" POI_DIR).arg(QDir::homePath()));
|
||||||
QFileInfoList list = dir.entryInfoList(QStringList(), QDir::Files);
|
QFileInfoList list = dir.entryInfoList(QStringList(), QDir::Files);
|
||||||
for (int i = 0; i < list.size(); ++i) {
|
for (int i = 0; i < list.size(); ++i)
|
||||||
if (!_poi.loadFile(list.at(i).absoluteFilePath()))
|
_poi.loadFile(list.at(i).absoluteFilePath());
|
||||||
fprintf(stderr, "Error loading POI file: %s: %s",
|
|
||||||
qPrintable(list.at(i).absoluteFilePath()),
|
|
||||||
qPrintable(_poi.errorString()));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void GUI::createMapActions()
|
void GUI::createMapActions()
|
||||||
@ -111,6 +116,31 @@ void GUI::createMapActions()
|
|||||||
_currentMap = _maps.at(0);
|
_currentMap = _maps.at(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void GUI::createPOIFilesActions()
|
||||||
|
{
|
||||||
|
_poiFilesSM = new QSignalMapper(this);
|
||||||
|
|
||||||
|
for (int i = 0; i < _poi.files().count(); i++)
|
||||||
|
createPOIFileAction(i);
|
||||||
|
|
||||||
|
connect(_poiFilesSM, SIGNAL(mapped(int)), this, SLOT(poiFileChecked(int)));
|
||||||
|
}
|
||||||
|
|
||||||
|
QAction *GUI::createPOIFileAction(int index)
|
||||||
|
{
|
||||||
|
QAction *a = new QAction(QFileInfo(_poi.files().at(index)).fileName(),
|
||||||
|
this);
|
||||||
|
a->setCheckable(true);
|
||||||
|
a->setChecked(true);
|
||||||
|
|
||||||
|
_poiFilesSM->setMapping(a, index);
|
||||||
|
connect(a, SIGNAL(triggered()), _poiFilesSM, SLOT(map()));
|
||||||
|
|
||||||
|
_poiFilesActions.append(a);
|
||||||
|
|
||||||
|
return a;
|
||||||
|
}
|
||||||
|
|
||||||
void GUI::createActions()
|
void GUI::createActions()
|
||||||
{
|
{
|
||||||
// Action Groups
|
// Action Groups
|
||||||
@ -118,6 +148,8 @@ void GUI::createActions()
|
|||||||
_fileActionGroup->setExclusive(false);
|
_fileActionGroup->setExclusive(false);
|
||||||
_fileActionGroup->setEnabled(false);
|
_fileActionGroup->setEnabled(false);
|
||||||
|
|
||||||
|
_navigationActionGroup = new QActionGroup(this);
|
||||||
|
_navigationActionGroup->setEnabled(false);
|
||||||
|
|
||||||
// General actions
|
// General actions
|
||||||
_exitAction = new QAction(QIcon(QPixmap(QUIT_ICON)), tr("Quit"), this);
|
_exitAction = new QAction(QIcon(QPixmap(QUIT_ICON)), tr("Quit"), this);
|
||||||
@ -165,25 +197,34 @@ void GUI::createActions()
|
|||||||
_openPOIAction = new QAction(QIcon(QPixmap(OPEN_FILE_ICON)),
|
_openPOIAction = new QAction(QIcon(QPixmap(OPEN_FILE_ICON)),
|
||||||
tr("Load POI file"), this);
|
tr("Load POI file"), this);
|
||||||
connect(_openPOIAction, SIGNAL(triggered()), this, SLOT(openPOIFile()));
|
connect(_openPOIAction, SIGNAL(triggered()), this, SLOT(openPOIFile()));
|
||||||
|
_closePOIAction = new QAction(QIcon(QPixmap(CLOSE_FILE_ICON)),
|
||||||
|
tr("Close POI files"), this);
|
||||||
|
connect(_closePOIAction, SIGNAL(triggered()), this, SLOT(closePOIFiles()));
|
||||||
_showPOIAction = new QAction(QIcon(QPixmap(SHOW_POI_ICON)),
|
_showPOIAction = new QAction(QIcon(QPixmap(SHOW_POI_ICON)),
|
||||||
tr("Show POIs"), this);
|
tr("Show POIs"), this);
|
||||||
_showPOIAction->setCheckable(true);
|
_showPOIAction->setCheckable(true);
|
||||||
|
_showPOIAction->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_P));
|
||||||
connect(_showPOIAction, SIGNAL(triggered(bool)), this, SLOT(showPOI(bool)));
|
connect(_showPOIAction, SIGNAL(triggered(bool)), this, SLOT(showPOI(bool)));
|
||||||
|
createPOIFilesActions();
|
||||||
|
|
||||||
// Map actions
|
// Map actions
|
||||||
_showMapAction = new QAction(QIcon(QPixmap(SHOW_MAP_ICON)), tr("Show map"),
|
_showMapAction = new QAction(QIcon(QPixmap(SHOW_MAP_ICON)), tr("Show map"),
|
||||||
this);
|
this);
|
||||||
_showMapAction->setCheckable(true);
|
_showMapAction->setCheckable(true);
|
||||||
|
_showMapAction->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_M));
|
||||||
connect(_showMapAction, SIGNAL(triggered(bool)), this, SLOT(showMap(bool)));
|
connect(_showMapAction, SIGNAL(triggered(bool)), this, SLOT(showMap(bool)));
|
||||||
if (_maps.empty())
|
if (_maps.empty())
|
||||||
_showMapAction->setEnabled(false);
|
_showMapAction->setEnabled(false);
|
||||||
else
|
else {
|
||||||
createMapActions();
|
createMapActions();
|
||||||
|
_showMapAction->setChecked(true);
|
||||||
|
}
|
||||||
|
|
||||||
// Settings actions
|
// Settings actions
|
||||||
_showGraphsAction = new QAction(tr("Show graphs"), this);
|
_showGraphsAction = new QAction(tr("Show graphs"), this);
|
||||||
_showGraphsAction->setCheckable(true);
|
_showGraphsAction->setCheckable(true);
|
||||||
_showGraphsAction->setChecked(true);
|
_showGraphsAction->setChecked(true);
|
||||||
|
_showGraphsAction->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_G));
|
||||||
connect(_showGraphsAction, SIGNAL(triggered(bool)), this,
|
connect(_showGraphsAction, SIGNAL(triggered(bool)), this,
|
||||||
SLOT(showGraphs(bool)));
|
SLOT(showGraphs(bool)));
|
||||||
_showToolbarsAction = new QAction(tr("Show toolbars"), this);
|
_showToolbarsAction = new QAction(tr("Show toolbars"), this);
|
||||||
@ -191,6 +232,35 @@ void GUI::createActions()
|
|||||||
_showToolbarsAction->setChecked(true);
|
_showToolbarsAction->setChecked(true);
|
||||||
connect(_showToolbarsAction, SIGNAL(triggered(bool)), this,
|
connect(_showToolbarsAction, SIGNAL(triggered(bool)), this,
|
||||||
SLOT(showToolbars(bool)));
|
SLOT(showToolbars(bool)));
|
||||||
|
QActionGroup *ag = new QActionGroup(this);
|
||||||
|
ag->setExclusive(true);
|
||||||
|
_metricUnitsAction = new QAction(tr("Metric"), this);
|
||||||
|
_metricUnitsAction->setCheckable(true);
|
||||||
|
_metricUnitsAction->setActionGroup(ag);
|
||||||
|
_metricUnitsAction->setChecked(true);
|
||||||
|
connect(_metricUnitsAction, SIGNAL(triggered()), this,
|
||||||
|
SLOT(setMetricUnits()));
|
||||||
|
_imperialUnitsAction = new QAction(tr("Imperial"), this);
|
||||||
|
_imperialUnitsAction->setCheckable(true);
|
||||||
|
_imperialUnitsAction->setActionGroup(ag);
|
||||||
|
connect(_imperialUnitsAction, SIGNAL(triggered()), this,
|
||||||
|
SLOT(setImperialUnits()));
|
||||||
|
|
||||||
|
// Navigation actions
|
||||||
|
_nextAction = new QAction(QIcon(QPixmap(NEXT_FILE_ICON)), tr("Next"), this);
|
||||||
|
_nextAction->setActionGroup(_navigationActionGroup);
|
||||||
|
connect(_nextAction, SIGNAL(triggered()), this, SLOT(next()));
|
||||||
|
_prevAction = new QAction(QIcon(QPixmap(PREV_FILE_ICON)), tr("Previous"),
|
||||||
|
this);
|
||||||
|
_prevAction->setActionGroup(_navigationActionGroup);
|
||||||
|
connect(_prevAction, SIGNAL(triggered()), this, SLOT(prev()));
|
||||||
|
_lastAction = new QAction(QIcon(QPixmap(LAST_FILE_ICON)), tr("Last"), this);
|
||||||
|
_lastAction->setActionGroup(_navigationActionGroup);
|
||||||
|
connect(_lastAction, SIGNAL(triggered()), this, SLOT(last()));
|
||||||
|
_firstAction = new QAction(QIcon(QPixmap(FIRST_FILE_ICON)), tr("First"),
|
||||||
|
this);
|
||||||
|
_firstAction->setActionGroup(_navigationActionGroup);
|
||||||
|
connect(_firstAction, SIGNAL(triggered()), this, SLOT(first()));
|
||||||
}
|
}
|
||||||
|
|
||||||
void GUI::createMenus()
|
void GUI::createMenus()
|
||||||
@ -215,10 +285,19 @@ void GUI::createMenus()
|
|||||||
_mapMenu->addAction(_showMapAction);
|
_mapMenu->addAction(_showMapAction);
|
||||||
|
|
||||||
_poiMenu = menuBar()->addMenu(tr("POI"));
|
_poiMenu = menuBar()->addMenu(tr("POI"));
|
||||||
|
_poiFilesMenu = _poiMenu->addMenu(tr("POI files"));
|
||||||
|
_poiFilesMenu->addActions(_poiFilesActions);
|
||||||
|
_poiMenu->addSeparator();
|
||||||
_poiMenu->addAction(_openPOIAction);
|
_poiMenu->addAction(_openPOIAction);
|
||||||
|
_poiMenu->addAction(_closePOIAction);
|
||||||
|
_poiMenu->addSeparator();
|
||||||
_poiMenu->addAction(_showPOIAction);
|
_poiMenu->addAction(_showPOIAction);
|
||||||
|
|
||||||
_settingsMenu = menuBar()->addMenu(tr("Settings"));
|
_settingsMenu = menuBar()->addMenu(tr("Settings"));
|
||||||
|
_unitsMenu = _settingsMenu->addMenu(tr("Units"));
|
||||||
|
_unitsMenu->addAction(_metricUnitsAction);
|
||||||
|
_unitsMenu->addAction(_imperialUnitsAction);
|
||||||
|
_settingsMenu->addSeparator();
|
||||||
_settingsMenu->addAction(_showToolbarsAction);
|
_settingsMenu->addAction(_showToolbarsAction);
|
||||||
_settingsMenu->addAction(_showGraphsAction);
|
_settingsMenu->addAction(_showGraphsAction);
|
||||||
|
|
||||||
@ -247,11 +326,23 @@ void GUI::createToolBars()
|
|||||||
#ifdef Q_OS_MAC
|
#ifdef Q_OS_MAC
|
||||||
_showToolBar->setToolButtonStyle(Qt::ToolButtonTextUnderIcon);
|
_showToolBar->setToolButtonStyle(Qt::ToolButtonTextUnderIcon);
|
||||||
#endif // Q_OS_MAC
|
#endif // Q_OS_MAC
|
||||||
|
|
||||||
|
_navigationToolBar = addToolBar(tr("Navigation"));
|
||||||
|
_navigationToolBar->addAction(_firstAction);
|
||||||
|
_navigationToolBar->addAction(_prevAction);
|
||||||
|
_navigationToolBar->addAction(_nextAction);
|
||||||
|
_navigationToolBar->addAction(_lastAction);
|
||||||
|
#ifdef Q_OS_MAC
|
||||||
|
_navigationToolBar->setToolButtonStyle(Qt::ToolButtonTextUnderIcon);
|
||||||
|
#endif // Q_OS_MAC
|
||||||
}
|
}
|
||||||
|
|
||||||
void GUI::createTrackView()
|
void GUI::createTrackView()
|
||||||
{
|
{
|
||||||
_track = new Track(this);
|
_track = new TrackView(this);
|
||||||
|
|
||||||
|
if (_showMapAction->isChecked())
|
||||||
|
_track->setMap(_currentMap);
|
||||||
}
|
}
|
||||||
|
|
||||||
void GUI::createTrackGraphs()
|
void GUI::createTrackGraphs()
|
||||||
@ -289,12 +380,12 @@ void GUI::about()
|
|||||||
QMessageBox msgBox(this);
|
QMessageBox msgBox(this);
|
||||||
|
|
||||||
msgBox.setWindowTitle(tr("About GPXSee"));
|
msgBox.setWindowTitle(tr("About GPXSee"));
|
||||||
msgBox.setText(QString("<h3>") + QString(APP_NAME" "APP_VERSION)
|
msgBox.setText(QString("<h3>") + QString(APP_NAME " " APP_VERSION)
|
||||||
+ QString("</h3><p>") + tr("GPX viewer and analyzer") + QString("<p/>"));
|
+ QString("</h3><p>") + tr("GPX viewer and analyzer") + QString("<p/>"));
|
||||||
msgBox.setInformativeText(QString("<table width=\"300\"><tr><td>")
|
msgBox.setInformativeText(QString("<table width=\"300\"><tr><td>")
|
||||||
+ tr("GPXSee is distributed under the terms of the GNU General Public "
|
+ tr("GPXSee is distributed under the terms of the GNU General Public "
|
||||||
"License version 3. For more info about GPXSee visit the project "
|
"License version 3. For more info about GPXSee visit the project "
|
||||||
"homepage at ") + QString("<a href=\""APP_HOMEPAGE"\">"APP_HOMEPAGE
|
"homepage at ") + QString("<a href=\"" APP_HOMEPAGE "\">" APP_HOMEPAGE
|
||||||
"</a>.</td></tr></table>"));
|
"</a>.</td></tr></table>"));
|
||||||
|
|
||||||
QIcon icon = msgBox.windowIcon();
|
QIcon icon = msgBox.windowIcon();
|
||||||
@ -314,8 +405,10 @@ void GUI::keys()
|
|||||||
QString("<div><table width=\"300\"><tr><td>") + tr("Next file")
|
QString("<div><table width=\"300\"><tr><td>") + tr("Next file")
|
||||||
+ QString("</td><td><i>SPACE</i></td></tr><tr><td>") + tr("Previous file")
|
+ QString("</td><td><i>SPACE</i></td></tr><tr><td>") + tr("Previous file")
|
||||||
+ QString("</td><td><i>BACKSPACE</i></td></tr><tr><td>")
|
+ QString("</td><td><i>BACKSPACE</i></td></tr><tr><td>")
|
||||||
+ tr("Append modifier") + QString("</td><td><i>SHIFT</i></td></tr>"
|
+ tr("First file") + QString("</td><td><i>HOME</i></td></tr><tr><td>")
|
||||||
"</table></div>"));
|
+ tr("Last file") + QString("</td><td><i>END</i></td></tr><tr><td></td>"
|
||||||
|
"<td></td></tr><tr><td>") + tr("Append modifier")
|
||||||
|
+ QString("</td><td><i>SHIFT</i></td></tr></table></div>"));
|
||||||
|
|
||||||
msgBox.exec();
|
msgBox.exec();
|
||||||
}
|
}
|
||||||
@ -331,7 +424,7 @@ void GUI::dataSources()
|
|||||||
+ tr("Map (tiles) source URLs are read on program startup from the "
|
+ tr("Map (tiles) source URLs are read on program startup from the "
|
||||||
"following file:")
|
"following file:")
|
||||||
+ QString("</p><p><code>") + QDir::homePath()
|
+ QString("</p><p><code>") + QDir::homePath()
|
||||||
+ QString("/"MAP_LIST_FILE"</code></p><p>")
|
+ QString("/" MAP_LIST_FILE "</code></p><p>")
|
||||||
+ tr("The file format is one map entry per line, consisting of the map "
|
+ tr("The file format is one map entry per line, consisting of the map "
|
||||||
"name and tiles URL delimited by a TAB character. The tile X and Y "
|
"name and tiles URL delimited by a TAB character. The tile X and Y "
|
||||||
"coordinates are replaced with $x and $y in the URL and the zoom "
|
"coordinates are replaced with $x and $y in the URL and the zoom "
|
||||||
@ -343,7 +436,7 @@ void GUI::dataSources()
|
|||||||
+ tr("To make GPXSee load a POI file automatically on startup, add "
|
+ tr("To make GPXSee load a POI file automatically on startup, add "
|
||||||
"the file to the following directory:")
|
"the file to the following directory:")
|
||||||
+ QString("</p><p><code>") + QDir::homePath()
|
+ QString("</p><p><code>") + QDir::homePath()
|
||||||
+ QString("/"POI_DIR"</code></p>")
|
+ QString("/" POI_DIR "</code></p>")
|
||||||
);
|
);
|
||||||
|
|
||||||
msgBox.exec();
|
msgBox.exec();
|
||||||
@ -351,7 +444,8 @@ void GUI::dataSources()
|
|||||||
|
|
||||||
void GUI::openFile()
|
void GUI::openFile()
|
||||||
{
|
{
|
||||||
QStringList files = QFileDialog::getOpenFileNames(this, tr("Open file"));
|
QStringList files = QFileDialog::getOpenFileNames(this, tr("Open file"),
|
||||||
|
QString(), tr("GPX files (*.gpx);;All files (*)"));
|
||||||
QStringList list = files;
|
QStringList list = files;
|
||||||
|
|
||||||
for (QStringList::Iterator it = list.begin(); it != list.end(); it++)
|
for (QStringList::Iterator it = list.begin(); it != list.end(); it++)
|
||||||
@ -368,9 +462,13 @@ bool GUI::openFile(const QString &fileName)
|
|||||||
_browser->setCurrent(fileName);
|
_browser->setCurrent(fileName);
|
||||||
updateStatusBarInfo();
|
updateStatusBarInfo();
|
||||||
_fileActionGroup->setEnabled(true);
|
_fileActionGroup->setEnabled(true);
|
||||||
|
_navigationActionGroup->setEnabled(true);
|
||||||
|
updateNavigationActions();
|
||||||
return true;
|
return true;
|
||||||
} else
|
} else {
|
||||||
|
updateNavigationActions();
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool GUI::loadFile(const QString &fileName)
|
bool GUI::loadFile(const QString &fileName)
|
||||||
@ -384,8 +482,12 @@ bool GUI::loadFile(const QString &fileName)
|
|||||||
if (_showPOIAction->isChecked())
|
if (_showPOIAction->isChecked())
|
||||||
_track->loadPOI(_poi);
|
_track->loadPOI(_poi);
|
||||||
|
|
||||||
_distance += gpx.distance();
|
for (int i = 0; i < gpx.trackCount(); i++) {
|
||||||
_time += gpx.time();
|
_distance += gpx.track(i).distance();
|
||||||
|
_time += gpx.track(i).time();
|
||||||
|
}
|
||||||
|
|
||||||
|
_trackCount += gpx.trackCount();
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
} else {
|
} else {
|
||||||
@ -402,7 +504,8 @@ bool GUI::loadFile(const QString &fileName)
|
|||||||
|
|
||||||
void GUI::openPOIFile()
|
void GUI::openPOIFile()
|
||||||
{
|
{
|
||||||
QString fileName = QFileDialog::getOpenFileName(this, tr("Open POI file"));
|
QString fileName = QFileDialog::getOpenFileName(this, tr("Open POI file"),
|
||||||
|
QString(), tr("GPX files (*.gpx);;CSV files (*.csv);;All files (*)"));
|
||||||
|
|
||||||
if (!fileName.isEmpty()) {
|
if (!fileName.isEmpty()) {
|
||||||
if (!_poi.loadFile(fileName)) {
|
if (!_poi.loadFile(fileName)) {
|
||||||
@ -414,10 +517,25 @@ void GUI::openPOIFile()
|
|||||||
} else {
|
} else {
|
||||||
_showPOIAction->setChecked(true);
|
_showPOIAction->setChecked(true);
|
||||||
_track->loadPOI(_poi);
|
_track->loadPOI(_poi);
|
||||||
|
_poiFilesMenu->addAction(createPOIFileAction(
|
||||||
|
_poi.files().indexOf(fileName)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void GUI::closePOIFiles()
|
||||||
|
{
|
||||||
|
_poiFilesMenu->clear();
|
||||||
|
|
||||||
|
for (int i = 0; i < _poiFilesActions.count(); i++)
|
||||||
|
delete _poiFilesActions[i];
|
||||||
|
_poiFilesActions.clear();
|
||||||
|
|
||||||
|
_track->clearPOI();
|
||||||
|
|
||||||
|
_poi.clear();
|
||||||
|
}
|
||||||
|
|
||||||
void GUI::saveAs()
|
void GUI::saveAs()
|
||||||
{
|
{
|
||||||
QString fileName = QFileDialog::getSaveFileName(this, "Export to PDF",
|
QString fileName = QFileDialog::getSaveFileName(this, "Export to PDF",
|
||||||
@ -454,17 +572,31 @@ void GUI::saveFile(const QString &fileName)
|
|||||||
|
|
||||||
QGraphicsScene scene;
|
QGraphicsScene scene;
|
||||||
InfoItem info;
|
InfoItem info;
|
||||||
info.insert(tr("Distance"), QString::number(_distance / 1000, 'f', 1)
|
if (_imperialUnitsAction->isChecked()) {
|
||||||
+ THIN_SPACE + tr("km"));
|
info.insert(tr("Distance"), QString::number(_distance * M2MI, 'f', 1)
|
||||||
info.insert(tr("Time"), timeSpan(_time));
|
+ UNIT_SPACE + tr("mi"));
|
||||||
info.insert(tr("Ascent"), QString::number(_elevationGraph->ascent(), 'f', 0)
|
info.insert(tr("Time"), timeSpan(_time));
|
||||||
+ THIN_SPACE + tr("m"));
|
info.insert(tr("Ascent"), QString::number(_elevationGraph->ascent()
|
||||||
info.insert(tr("Descent"), QString::number(_elevationGraph->descent(), 'f',
|
* M2FT, 'f', 0) + UNIT_SPACE + tr("ft"));
|
||||||
0) + THIN_SPACE + tr("m"));
|
info.insert(tr("Descent"), QString::number(_elevationGraph->descent()
|
||||||
info.insert(tr("Maximum"), QString::number(_elevationGraph->max(), 'f', 0)
|
* M2FT, 'f', 0) + UNIT_SPACE + tr("ft"));
|
||||||
+ THIN_SPACE + tr("m"));
|
info.insert(tr("Maximum"), QString::number(_elevationGraph->max()
|
||||||
info.insert(tr("Minimum"), QString::number(_elevationGraph->min(), 'f', 0)
|
* M2FT, 'f', 0) + UNIT_SPACE + tr("ft"));
|
||||||
+ THIN_SPACE + tr("m"));
|
info.insert(tr("Minimum"), QString::number(_elevationGraph->min()
|
||||||
|
* M2FT, 'f', 0) + UNIT_SPACE + tr("ft"));
|
||||||
|
} else {
|
||||||
|
info.insert(tr("Distance"), QString::number(_distance * M2KM, 'f', 1)
|
||||||
|
+ UNIT_SPACE + tr("km"));
|
||||||
|
info.insert(tr("Time"), timeSpan(_time));
|
||||||
|
info.insert(tr("Ascent"), QString::number(_elevationGraph->ascent(),
|
||||||
|
'f', 0) + UNIT_SPACE + tr("m"));
|
||||||
|
info.insert(tr("Descent"), QString::number(_elevationGraph->descent(),
|
||||||
|
'f', 0) + UNIT_SPACE + tr("m"));
|
||||||
|
info.insert(tr("Maximum"), QString::number(_elevationGraph->max(), 'f',
|
||||||
|
0) + UNIT_SPACE + tr("m"));
|
||||||
|
info.insert(tr("Minimum"), QString::number(_elevationGraph->min(), 'f',
|
||||||
|
0) + UNIT_SPACE + tr("m"));
|
||||||
|
}
|
||||||
scene.addItem(&info);
|
scene.addItem(&info);
|
||||||
scene.render(&p, QRectF(0, 0, printer.width(), 200));
|
scene.render(&p, QRectF(0, 0, printer.width(), 200));
|
||||||
|
|
||||||
@ -475,6 +607,7 @@ void GUI::reloadFile()
|
|||||||
{
|
{
|
||||||
_distance = 0;
|
_distance = 0;
|
||||||
_time = 0;
|
_time = 0;
|
||||||
|
_trackCount = 0;
|
||||||
|
|
||||||
_elevationGraph->clear();
|
_elevationGraph->clear();
|
||||||
_speedGraph->clear();
|
_speedGraph->clear();
|
||||||
@ -498,6 +631,7 @@ void GUI::closeFile()
|
|||||||
{
|
{
|
||||||
_distance = 0;
|
_distance = 0;
|
||||||
_time = 0;
|
_time = 0;
|
||||||
|
_trackCount = 0;
|
||||||
|
|
||||||
_elevationGraph->clear();
|
_elevationGraph->clear();
|
||||||
_speedGraph->clear();
|
_speedGraph->clear();
|
||||||
@ -535,30 +669,35 @@ void GUI::showToolbars(bool checked)
|
|||||||
if (checked) {
|
if (checked) {
|
||||||
addToolBar(_fileToolBar);
|
addToolBar(_fileToolBar);
|
||||||
addToolBar(_showToolBar);
|
addToolBar(_showToolBar);
|
||||||
|
addToolBar(_navigationToolBar);
|
||||||
_fileToolBar->show();
|
_fileToolBar->show();
|
||||||
_showToolBar->show();
|
_showToolBar->show();
|
||||||
|
_navigationToolBar->show();
|
||||||
} else {
|
} else {
|
||||||
removeToolBar(_fileToolBar);
|
removeToolBar(_fileToolBar);
|
||||||
removeToolBar(_showToolBar);
|
removeToolBar(_showToolBar);
|
||||||
|
removeToolBar(_navigationToolBar);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void GUI::updateStatusBarInfo()
|
void GUI::updateStatusBarInfo()
|
||||||
{
|
{
|
||||||
int files = _files.size();
|
if (_files.count() == 0) {
|
||||||
|
|
||||||
if (files == 0) {
|
|
||||||
_fileNameLabel->clear();
|
_fileNameLabel->clear();
|
||||||
_distanceLabel->clear();
|
_distanceLabel->clear();
|
||||||
_timeLabel->clear();
|
_timeLabel->clear();
|
||||||
return;
|
return;
|
||||||
} else if (files == 1)
|
} else if (_files.count() == 1)
|
||||||
_fileNameLabel->setText(_files.at(0));
|
_fileNameLabel->setText(_files.at(0));
|
||||||
else
|
else
|
||||||
_fileNameLabel->setText(tr("%1 tracks").arg(_files.size()));
|
_fileNameLabel->setText(tr("%1 tracks").arg(_trackCount));
|
||||||
|
|
||||||
_distanceLabel->setText(QString::number(_distance / 1000, 'f', 1)
|
if (_imperialUnitsAction->isChecked())
|
||||||
+ " " + tr("km"));
|
_distanceLabel->setText(QString::number(_distance * M2MI, 'f', 1)
|
||||||
|
+ UNIT_SPACE + tr("mi"));
|
||||||
|
else
|
||||||
|
_distanceLabel->setText(QString::number(_distance * M2KM, 'f', 1)
|
||||||
|
+ UNIT_SPACE + tr("km"));
|
||||||
_timeLabel->setText(timeSpan(_time));
|
_timeLabel->setText(timeSpan(_time));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -570,6 +709,16 @@ void GUI::mapChanged(int index)
|
|||||||
_track->setMap(_currentMap);
|
_track->setMap(_currentMap);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void GUI::poiFileChecked(int index)
|
||||||
|
{
|
||||||
|
_poi.enableFile(_poi.files().at(index),
|
||||||
|
_poiFilesActions.at(index)->isChecked());
|
||||||
|
|
||||||
|
_track->clearPOI();
|
||||||
|
if (_showPOIAction->isChecked())
|
||||||
|
_track->loadPOI(_poi);
|
||||||
|
}
|
||||||
|
|
||||||
void GUI::graphChanged(int index)
|
void GUI::graphChanged(int index)
|
||||||
{
|
{
|
||||||
if (_trackGraphs->widget(index) == _elevationGraph)
|
if (_trackGraphs->widget(index) == _elevationGraph)
|
||||||
@ -578,14 +727,99 @@ void GUI::graphChanged(int index)
|
|||||||
_speedGraph->setSliderPosition(_elevationGraph->sliderPosition());
|
_speedGraph->setSliderPosition(_elevationGraph->sliderPosition());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void GUI::updateNavigationActions()
|
||||||
|
{
|
||||||
|
if (_browser->isLast()) {
|
||||||
|
_nextAction->setEnabled(false);
|
||||||
|
_lastAction->setEnabled(false);
|
||||||
|
} else {
|
||||||
|
_nextAction->setEnabled(true);
|
||||||
|
_lastAction->setEnabled(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (_browser->isFirst()) {
|
||||||
|
_prevAction->setEnabled(false);
|
||||||
|
_firstAction->setEnabled(false);
|
||||||
|
} else {
|
||||||
|
_prevAction->setEnabled(true);
|
||||||
|
_firstAction->setEnabled(true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void GUI::setMetricUnits()
|
||||||
|
{
|
||||||
|
_track->setUnits(Metric);
|
||||||
|
_elevationGraph->setUnits(Metric);
|
||||||
|
_speedGraph->setUnits(Metric);
|
||||||
|
updateStatusBarInfo();
|
||||||
|
}
|
||||||
|
|
||||||
|
void GUI::setImperialUnits()
|
||||||
|
{
|
||||||
|
_track->setUnits(Imperial);
|
||||||
|
_elevationGraph->setUnits(Imperial);
|
||||||
|
_speedGraph->setUnits(Imperial);
|
||||||
|
updateStatusBarInfo();
|
||||||
|
}
|
||||||
|
|
||||||
|
void GUI::next()
|
||||||
|
{
|
||||||
|
QString file = _browser->next();
|
||||||
|
if (file.isNull())
|
||||||
|
return;
|
||||||
|
|
||||||
|
closeFile();
|
||||||
|
openFile(file);
|
||||||
|
}
|
||||||
|
|
||||||
|
void GUI::prev()
|
||||||
|
{
|
||||||
|
QString file = _browser->prev();
|
||||||
|
if (file.isNull())
|
||||||
|
return;
|
||||||
|
|
||||||
|
closeFile();
|
||||||
|
openFile(file);
|
||||||
|
}
|
||||||
|
|
||||||
|
void GUI::last()
|
||||||
|
{
|
||||||
|
QString file = _browser->last();
|
||||||
|
if (file.isNull())
|
||||||
|
return;
|
||||||
|
|
||||||
|
closeFile();
|
||||||
|
openFile(file);
|
||||||
|
}
|
||||||
|
|
||||||
|
void GUI::first()
|
||||||
|
{
|
||||||
|
QString file = _browser->first();
|
||||||
|
if (file.isNull())
|
||||||
|
return;
|
||||||
|
|
||||||
|
closeFile();
|
||||||
|
openFile(file);
|
||||||
|
}
|
||||||
|
|
||||||
void GUI::keyPressEvent(QKeyEvent *event)
|
void GUI::keyPressEvent(QKeyEvent *event)
|
||||||
{
|
{
|
||||||
QString file;
|
QString file;
|
||||||
|
|
||||||
if (event->key() == PREV_KEY)
|
switch (event->key()) {
|
||||||
file = _browser->prev();
|
case PREV_KEY:
|
||||||
if (event->key() == NEXT_KEY)
|
file = _browser->prev();
|
||||||
file = _browser->next();
|
break;
|
||||||
|
case NEXT_KEY:
|
||||||
|
file = _browser->next();
|
||||||
|
break;
|
||||||
|
case FIRST_KEY:
|
||||||
|
file = _browser->first();
|
||||||
|
break;
|
||||||
|
case LAST_KEY:
|
||||||
|
file = _browser->last();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
if (!file.isNull()) {
|
if (!file.isNull()) {
|
||||||
if (!(event->modifiers() & MODIFIER))
|
if (!(event->modifiers() & MODIFIER))
|
||||||
|
51
src/gui.h
51
src/gui.h
@ -2,20 +2,21 @@
|
|||||||
#define GUI_H
|
#define GUI_H
|
||||||
|
|
||||||
#include <QMainWindow>
|
#include <QMainWindow>
|
||||||
#include <QMenu>
|
#include <QString>
|
||||||
#include <QToolBar>
|
#include <QList>
|
||||||
#include <QTabWidget>
|
|
||||||
#include <QGraphicsView>
|
|
||||||
#include <QActionGroup>
|
|
||||||
#include <QAction>
|
|
||||||
#include <QLabel>
|
|
||||||
#include "poi.h"
|
#include "poi.h"
|
||||||
|
|
||||||
|
class QMenu;
|
||||||
|
class QToolBar;
|
||||||
|
class QTabWidget;
|
||||||
|
class QActionGroup;
|
||||||
|
class QAction;
|
||||||
|
class QLabel;
|
||||||
|
class QSignalMapper;
|
||||||
class FileBrowser;
|
class FileBrowser;
|
||||||
class ElevationGraph;
|
class ElevationGraph;
|
||||||
class SpeedGraph;
|
class SpeedGraph;
|
||||||
class Track;
|
class TrackView;
|
||||||
class Map;
|
class Map;
|
||||||
|
|
||||||
class GUI : public QMainWindow
|
class GUI : public QMainWindow
|
||||||
@ -23,7 +24,7 @@ class GUI : public QMainWindow
|
|||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
GUI();
|
GUI(QWidget *parent = 0);
|
||||||
|
|
||||||
bool openFile(const QString &fileName);
|
bool openFile(const QString &fileName);
|
||||||
|
|
||||||
@ -37,6 +38,7 @@ private slots:
|
|||||||
void closeFile();
|
void closeFile();
|
||||||
void reloadFile();
|
void reloadFile();
|
||||||
void openPOIFile();
|
void openPOIFile();
|
||||||
|
void closePOIFiles();
|
||||||
void showPOI(bool checked);
|
void showPOI(bool checked);
|
||||||
void showMap(bool checked);
|
void showMap(bool checked);
|
||||||
void showGraphs(bool checked);
|
void showGraphs(bool checked);
|
||||||
@ -44,10 +46,21 @@ private slots:
|
|||||||
|
|
||||||
void mapChanged(int);
|
void mapChanged(int);
|
||||||
void graphChanged(int);
|
void graphChanged(int);
|
||||||
|
void poiFileChecked(int);
|
||||||
|
|
||||||
|
void next();
|
||||||
|
void prev();
|
||||||
|
void last();
|
||||||
|
void first();
|
||||||
|
|
||||||
|
void setMetricUnits();
|
||||||
|
void setImperialUnits();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void loadFiles();
|
void loadFiles();
|
||||||
|
|
||||||
|
QAction *createPOIFileAction(int index);
|
||||||
|
void createPOIFilesActions();
|
||||||
void createMapActions();
|
void createMapActions();
|
||||||
void createActions();
|
void createActions();
|
||||||
void createMenus();
|
void createMenus();
|
||||||
@ -59,6 +72,7 @@ private:
|
|||||||
bool loadFile(const QString &fileName);
|
bool loadFile(const QString &fileName);
|
||||||
void saveFile(const QString &fileName);
|
void saveFile(const QString &fileName);
|
||||||
void updateStatusBarInfo();
|
void updateStatusBarInfo();
|
||||||
|
void updateNavigationActions();
|
||||||
|
|
||||||
void keyPressEvent(QKeyEvent * event);
|
void keyPressEvent(QKeyEvent * event);
|
||||||
|
|
||||||
@ -67,11 +81,15 @@ private:
|
|||||||
QMenu *_poiMenu;
|
QMenu *_poiMenu;
|
||||||
QMenu *_mapMenu;
|
QMenu *_mapMenu;
|
||||||
QMenu *_settingsMenu;
|
QMenu *_settingsMenu;
|
||||||
|
QMenu *_unitsMenu;
|
||||||
|
QMenu *_poiFilesMenu;
|
||||||
|
|
||||||
QToolBar *_fileToolBar;
|
QToolBar *_fileToolBar;
|
||||||
QToolBar *_showToolBar;
|
QToolBar *_showToolBar;
|
||||||
|
QToolBar *_navigationToolBar;
|
||||||
QTabWidget *_trackGraphs;
|
QTabWidget *_trackGraphs;
|
||||||
QActionGroup *_fileActionGroup;
|
QActionGroup *_fileActionGroup;
|
||||||
|
QActionGroup *_navigationActionGroup;
|
||||||
|
|
||||||
QAction *_exitAction;
|
QAction *_exitAction;
|
||||||
QAction *_keysAction;
|
QAction *_keysAction;
|
||||||
@ -84,11 +102,21 @@ private:
|
|||||||
QAction *_closeFileAction;
|
QAction *_closeFileAction;
|
||||||
QAction *_reloadFileAction;
|
QAction *_reloadFileAction;
|
||||||
QAction *_openPOIAction;
|
QAction *_openPOIAction;
|
||||||
|
QAction *_closePOIAction;
|
||||||
QAction *_showPOIAction;
|
QAction *_showPOIAction;
|
||||||
QAction *_showMapAction;
|
QAction *_showMapAction;
|
||||||
QAction *_showGraphsAction;
|
QAction *_showGraphsAction;
|
||||||
QAction *_showToolbarsAction;
|
QAction *_showToolbarsAction;
|
||||||
|
QAction *_nextAction;
|
||||||
|
QAction *_prevAction;
|
||||||
|
QAction *_lastAction;
|
||||||
|
QAction *_firstAction;
|
||||||
|
QAction *_metricUnitsAction;
|
||||||
|
QAction *_imperialUnitsAction;
|
||||||
QList<QAction*> _mapActions;
|
QList<QAction*> _mapActions;
|
||||||
|
QList<QAction*> _poiFilesActions;
|
||||||
|
|
||||||
|
QSignalMapper *_poiFilesSM;
|
||||||
|
|
||||||
QLabel *_fileNameLabel;
|
QLabel *_fileNameLabel;
|
||||||
QLabel *_distanceLabel;
|
QLabel *_distanceLabel;
|
||||||
@ -96,7 +124,7 @@ private:
|
|||||||
|
|
||||||
ElevationGraph *_elevationGraph;
|
ElevationGraph *_elevationGraph;
|
||||||
SpeedGraph *_speedGraph;
|
SpeedGraph *_speedGraph;
|
||||||
Track *_track;
|
TrackView *_track;
|
||||||
|
|
||||||
POI _poi;
|
POI _poi;
|
||||||
QList<Map*> _maps;
|
QList<Map*> _maps;
|
||||||
@ -108,6 +136,7 @@ private:
|
|||||||
|
|
||||||
qreal _distance;
|
qreal _distance;
|
||||||
qreal _time;
|
qreal _time;
|
||||||
|
int _trackCount;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // GUI_H
|
#endif // GUI_H
|
||||||
|
@ -12,6 +12,10 @@
|
|||||||
#define SHOW_MAP_ICON ":/icons/applications-internet.png"
|
#define SHOW_MAP_ICON ":/icons/applications-internet.png"
|
||||||
#define QUIT_ICON ":/icons/application-exit.png"
|
#define QUIT_ICON ":/icons/application-exit.png"
|
||||||
#define RELOAD_FILE_ICON ":/icons/view-refresh.png"
|
#define RELOAD_FILE_ICON ":/icons/view-refresh.png"
|
||||||
|
#define NEXT_FILE_ICON ":/icons/arrow-right.png"
|
||||||
|
#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)
|
#if QT_VERSION < QT_VERSION_CHECK(5, 0, 0)
|
||||||
#define QT_ICON ":/trolltech/qmessagebox/images/qtlogo-64.png"
|
#define QT_ICON ":/trolltech/qmessagebox/images/qtlogo-64.png"
|
||||||
|
@ -3,7 +3,6 @@
|
|||||||
#include "config.h"
|
#include "config.h"
|
||||||
#include "infoitem.h"
|
#include "infoitem.h"
|
||||||
|
|
||||||
|
|
||||||
#define PADDING 10
|
#define PADDING 10
|
||||||
|
|
||||||
InfoItem::InfoItem(QGraphicsItem *parent) : QGraphicsItem(parent)
|
InfoItem::InfoItem(QGraphicsItem *parent) : QGraphicsItem(parent)
|
||||||
@ -11,24 +10,21 @@ InfoItem::InfoItem(QGraphicsItem *parent) : QGraphicsItem(parent)
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
QRectF InfoItem::boundingRect() const
|
void InfoItem::updateBoundingRect()
|
||||||
{
|
{
|
||||||
QFont font;
|
QFont font;
|
||||||
font.setPixelSize(FONT_SIZE);
|
font.setPixelSize(FONT_SIZE);
|
||||||
font.setFamily(FONT_FAMILY);
|
font.setFamily(FONT_FAMILY);
|
||||||
QFontMetrics fm(font);
|
QFontMetrics fm(font);
|
||||||
QList<KV>::const_iterator i;
|
QList<KV>::const_iterator i;
|
||||||
int width = 0;
|
qreal width = 0;
|
||||||
|
|
||||||
if (_list.isEmpty())
|
|
||||||
return QRectF();
|
|
||||||
|
|
||||||
for (i = _list.constBegin(); i != _list.constEnd(); i++) {
|
for (i = _list.constBegin(); i != _list.constEnd(); i++) {
|
||||||
width += fm.width(i->key + ": ");
|
width += fm.width(i->key + ": ");
|
||||||
width += fm.width(i->value) + ((i == _list.end() - 1) ? 0 : PADDING);
|
width += fm.width(i->value) + ((i == _list.end() - 1) ? 0 : PADDING);
|
||||||
}
|
}
|
||||||
|
|
||||||
return QRectF(0, 0, width, fm.height());
|
_boundingRect = QRectF(0, 0, width, _list.isEmpty() ? 0 : fm.height());
|
||||||
}
|
}
|
||||||
|
|
||||||
void InfoItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *option,
|
void InfoItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *option,
|
||||||
@ -74,5 +70,13 @@ void InfoItem::insert(const QString &key, const QString &value)
|
|||||||
else
|
else
|
||||||
_list[i] = kv;
|
_list[i] = kv;
|
||||||
|
|
||||||
|
updateBoundingRect();
|
||||||
|
prepareGeometryChange();
|
||||||
|
}
|
||||||
|
|
||||||
|
void InfoItem::clear()
|
||||||
|
{
|
||||||
|
_list.clear();
|
||||||
|
updateBoundingRect();
|
||||||
prepareGeometryChange();
|
prepareGeometryChange();
|
||||||
}
|
}
|
||||||
|
@ -9,14 +9,16 @@ class InfoItem : public QGraphicsItem
|
|||||||
public:
|
public:
|
||||||
InfoItem(QGraphicsItem *parent = 0);
|
InfoItem(QGraphicsItem *parent = 0);
|
||||||
|
|
||||||
QRectF boundingRect() const;
|
QRectF boundingRect() const {return _boundingRect;}
|
||||||
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option,
|
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option,
|
||||||
QWidget *widget);
|
QWidget *widget);
|
||||||
|
|
||||||
void insert(const QString &key, const QString &value);
|
void insert(const QString &key, const QString &value);
|
||||||
void clear() {_list.clear();}
|
void clear();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
void updateBoundingRect();
|
||||||
|
|
||||||
class KV {
|
class KV {
|
||||||
public:
|
public:
|
||||||
QString key;
|
QString key;
|
||||||
@ -29,6 +31,7 @@ private:
|
|||||||
};
|
};
|
||||||
|
|
||||||
QList<KV> _list;
|
QList<KV> _list;
|
||||||
|
QRectF _boundingRect;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // INFOITEM_H
|
#endif // INFOITEM_H
|
||||||
|
@ -3,6 +3,8 @@
|
|||||||
|
|
||||||
#define NEXT_KEY Qt::Key_Space
|
#define NEXT_KEY Qt::Key_Space
|
||||||
#define PREV_KEY Qt::Key_Backspace
|
#define PREV_KEY Qt::Key_Backspace
|
||||||
|
#define FIRST_KEY Qt::Key_Home
|
||||||
|
#define LAST_KEY Qt::Key_End
|
||||||
#define MODIFIER Qt::ShiftModifier
|
#define MODIFIER Qt::ShiftModifier
|
||||||
|
|
||||||
#endif // KEYS_H
|
#endif // KEYS_H
|
||||||
|
@ -68,3 +68,9 @@ int scale2zoom(qreal scale)
|
|||||||
return ZOOM_MAX;
|
return ZOOM_MAX;
|
||||||
return zoom;
|
return zoom;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
qreal zoom2resolution(int zoom, qreal y)
|
||||||
|
{
|
||||||
|
return (WGS84_RADIUS * 2 * M_PI / 256 * cos(2 * atan(exp(deg2rad(y)))
|
||||||
|
- M_PI/2)) / pow(2.0, zoom);
|
||||||
|
}
|
||||||
|
1
src/ll.h
1
src/ll.h
@ -12,5 +12,6 @@ qreal llDistance(const QPointF &p1, const QPointF &p2);
|
|||||||
QPoint mercator2tile(const QPointF &m, int zoom);
|
QPoint mercator2tile(const QPointF &m, int zoom);
|
||||||
QPointF tile2mercator(const QPoint &tile, int zoom);
|
QPointF tile2mercator(const QPoint &tile, int zoom);
|
||||||
int scale2zoom(qreal scale);
|
int scale2zoom(qreal scale);
|
||||||
|
qreal zoom2resolution(int zoom, qreal y);
|
||||||
|
|
||||||
#endif // LL_H
|
#endif // LL_H
|
||||||
|
12
src/map.cpp
12
src/map.cpp
@ -6,7 +6,8 @@
|
|||||||
#include "map.h"
|
#include "map.h"
|
||||||
|
|
||||||
|
|
||||||
Map::Map(const QString &name, const QString &url)
|
Map::Map(QObject *parent, const QString &name, const QString &url)
|
||||||
|
: QObject(parent)
|
||||||
{
|
{
|
||||||
_name = name;
|
_name = name;
|
||||||
_url = url;
|
_url = url;
|
||||||
@ -14,10 +15,9 @@ Map::Map(const QString &name, const QString &url)
|
|||||||
connect(&Downloader::instance(), SIGNAL(finished()), this,
|
connect(&Downloader::instance(), SIGNAL(finished()), this,
|
||||||
SLOT(emitLoaded()));
|
SLOT(emitLoaded()));
|
||||||
|
|
||||||
if (!QDir::home().mkpath(QString(TILES_DIR"/%1").arg(_name)))
|
QString path = QString(TILES_DIR"/") + _name;
|
||||||
fprintf(stderr, "Error creating tiles dir: %s\n",
|
if (!QDir::home().mkpath(path))
|
||||||
qPrintable(QDir::home().absolutePath() + QString("/"TILES_DIR"/%1")
|
fprintf(stderr, "Error creating tiles dir: %s\n", qPrintable(path));
|
||||||
.arg(_name)));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Map::emitLoaded()
|
void Map::emitLoaded()
|
||||||
@ -31,7 +31,7 @@ void Map::loadTiles(QList<Tile> &list)
|
|||||||
|
|
||||||
for (int i = 0; i < list.size(); ++i) {
|
for (int i = 0; i < list.size(); ++i) {
|
||||||
Tile &t = list[i];
|
Tile &t = list[i];
|
||||||
QString file = QString("%1/"TILES_DIR"/%2/%3-%4-%5")
|
QString file = QString("%1/" TILES_DIR "/%2/%3-%4-%5")
|
||||||
.arg(QDir::homePath()).arg(_name).arg(t.zoom()).arg(t.xy().rx())
|
.arg(QDir::homePath()).arg(_name).arg(t.zoom()).arg(t.xy().rx())
|
||||||
.arg(t.xy().ry());
|
.arg(t.xy().ry());
|
||||||
QFileInfo fi(file);
|
QFileInfo fi(file);
|
||||||
|
@ -2,8 +2,6 @@
|
|||||||
#define MAP_H
|
#define MAP_H
|
||||||
|
|
||||||
#include <QPixmap>
|
#include <QPixmap>
|
||||||
#include "downloader.h"
|
|
||||||
|
|
||||||
|
|
||||||
class Tile
|
class Tile
|
||||||
{
|
{
|
||||||
@ -11,7 +9,7 @@ public:
|
|||||||
Tile(const QPoint &xy, int zoom)
|
Tile(const QPoint &xy, int zoom)
|
||||||
{_xy = xy; _zoom = zoom;}
|
{_xy = xy; _zoom = zoom;}
|
||||||
|
|
||||||
int zoom() {return _zoom;}
|
int zoom() const {return _zoom;}
|
||||||
QPoint& xy() {return _xy;}
|
QPoint& xy() {return _xy;}
|
||||||
QPixmap& pixmap() {return _pixmap;}
|
QPixmap& pixmap() {return _pixmap;}
|
||||||
|
|
||||||
@ -30,9 +28,10 @@ signals:
|
|||||||
void loaded();
|
void loaded();
|
||||||
|
|
||||||
public:
|
public:
|
||||||
Map(const QString &name, const QString &url);
|
Map(QObject *parent = 0, const QString &name = QString(),
|
||||||
|
const QString &url = QString());
|
||||||
|
|
||||||
const QString &name() {return _name;}
|
const QString &name() const {return _name;}
|
||||||
void loadTiles(QList<Tile> &list);
|
void loadTiles(QList<Tile> &list);
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
|
@ -1,9 +1,10 @@
|
|||||||
#include <QFile>
|
#include <QFile>
|
||||||
#include <QFileInfo>
|
#include <QFileInfo>
|
||||||
|
#include "map.h"
|
||||||
#include "maplist.h"
|
#include "maplist.h"
|
||||||
|
|
||||||
|
|
||||||
QList<Map*> MapList::load(const QString &fileName)
|
QList<Map*> MapList::load(QObject *parent, const QString &fileName)
|
||||||
{
|
{
|
||||||
QList<Map*> mapList;
|
QList<Map*> mapList;
|
||||||
QFileInfo fi(fileName);
|
QFileInfo fi(fileName);
|
||||||
@ -32,7 +33,7 @@ QList<Map*> MapList::load(const QString &fileName)
|
|||||||
QByteArray ba1 = list[0].trimmed();
|
QByteArray ba1 = list[0].trimmed();
|
||||||
QByteArray ba2 = list[1].trimmed();
|
QByteArray ba2 = list[1].trimmed();
|
||||||
|
|
||||||
mapList.append(new Map(QString::fromUtf8(ba1.data(), ba1.size()),
|
mapList.append(new Map(parent, QString::fromUtf8(ba1.data(), ba1.size()),
|
||||||
QString::fromLatin1(ba2.data(), ba2.size())));
|
QString::fromLatin1(ba2.data(), ba2.size())));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2,13 +2,16 @@
|
|||||||
#define MAPLIST_H
|
#define MAPLIST_H
|
||||||
|
|
||||||
#include <QList>
|
#include <QList>
|
||||||
#include "map.h"
|
#include <QString>
|
||||||
|
#include <QObject>
|
||||||
|
|
||||||
|
class Map;
|
||||||
|
|
||||||
class MapList
|
class MapList
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
static QList<Map*> load(const QString &fileName);
|
static QList<Map*> load(QObject *parent = 0,
|
||||||
|
const QString &fileName = QString());
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // MAPLIST_H
|
#endif // MAPLIST_H
|
||||||
|
@ -19,10 +19,18 @@ void MarkerItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *option
|
|||||||
{
|
{
|
||||||
Q_UNUSED(option);
|
Q_UNUSED(option);
|
||||||
Q_UNUSED(widget);
|
Q_UNUSED(widget);
|
||||||
|
bool aa;
|
||||||
|
|
||||||
|
|
||||||
|
if ((aa = painter->testRenderHint(QPainter::Antialiasing)))
|
||||||
|
painter->setRenderHint(QPainter::Antialiasing, false);
|
||||||
|
|
||||||
painter->setPen(Qt::red);
|
painter->setPen(Qt::red);
|
||||||
painter->drawLine(-SIZE/2, 0, SIZE/2, 0);
|
painter->drawLine(-SIZE/2, 0, SIZE/2, 0);
|
||||||
painter->drawLine(0, -SIZE/2, 0, SIZE/2);
|
painter->drawLine(0, -SIZE/2, 0, SIZE/2);
|
||||||
|
|
||||||
|
if (aa)
|
||||||
|
painter->setRenderHint(QPainter::Antialiasing, true);
|
||||||
|
|
||||||
// painter->drawRect(boundingRect());
|
// painter->drawRect(boundingRect());
|
||||||
}
|
}
|
||||||
|
34
src/nicenum.cpp
Normal file
34
src/nicenum.cpp
Normal file
@ -0,0 +1,34 @@
|
|||||||
|
#include <cmath>
|
||||||
|
#include "nicenum.h"
|
||||||
|
|
||||||
|
double niceNum(double x, int round)
|
||||||
|
{
|
||||||
|
int expv;
|
||||||
|
double f;
|
||||||
|
double nf;
|
||||||
|
|
||||||
|
expv = (int)floor(log10(x));
|
||||||
|
f = x / pow(10.0, expv);
|
||||||
|
|
||||||
|
if (round) {
|
||||||
|
if (f < 1.5)
|
||||||
|
nf = 1.0;
|
||||||
|
else if (f < 3.0)
|
||||||
|
nf = 2.0;
|
||||||
|
else if (f < 7.0)
|
||||||
|
nf = 5.0;
|
||||||
|
else
|
||||||
|
nf = 10.0;
|
||||||
|
} else {
|
||||||
|
if (f <= 1.0)
|
||||||
|
nf = 1.0;
|
||||||
|
else if (f <= 2.0)
|
||||||
|
nf = 2.0;
|
||||||
|
else if (f <= 5.0)
|
||||||
|
nf = 5.0;
|
||||||
|
else
|
||||||
|
nf = 10.0;
|
||||||
|
}
|
||||||
|
|
||||||
|
return nf * pow(10.0, expv);
|
||||||
|
}
|
6
src/nicenum.h
Normal file
6
src/nicenum.h
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
#ifndef NICENUM_H
|
||||||
|
#define NICENUM_H
|
||||||
|
|
||||||
|
double niceNum(double x, int round);
|
||||||
|
|
||||||
|
#endif // NICENUM_H
|
@ -1,4 +1,4 @@
|
|||||||
#include "colorshop.h"
|
#include "palette.h"
|
||||||
|
|
||||||
|
|
||||||
#define HUE_INIT 0.1f
|
#define HUE_INIT 0.1f
|
||||||
@ -43,12 +43,12 @@ static unsigned hsv2rgb(float h, float s, float v)
|
|||||||
+ (unsigned)(b * 256);
|
+ (unsigned)(b * 256);
|
||||||
}
|
}
|
||||||
|
|
||||||
ColorShop::ColorShop()
|
Palette::Palette()
|
||||||
{
|
{
|
||||||
_hueState = HUE_INIT;
|
_hueState = HUE_INIT;
|
||||||
}
|
}
|
||||||
|
|
||||||
QColor ColorShop::color()
|
QColor Palette::color()
|
||||||
{
|
{
|
||||||
_hueState += HUE_INCREMENT;
|
_hueState += HUE_INCREMENT;
|
||||||
_hueState -= (int) _hueState;
|
_hueState -= (int) _hueState;
|
||||||
@ -56,7 +56,7 @@ QColor ColorShop::color()
|
|||||||
return QColor(hsv2rgb(_hueState, SATURATION, VALUE));
|
return QColor(hsv2rgb(_hueState, SATURATION, VALUE));
|
||||||
}
|
}
|
||||||
|
|
||||||
void ColorShop::reset()
|
void Palette::reset()
|
||||||
{
|
{
|
||||||
_hueState = HUE_INIT;
|
_hueState = HUE_INIT;
|
||||||
}
|
}
|
@ -1,12 +1,12 @@
|
|||||||
#ifndef COLORSHOP_H
|
#ifndef PALETTE_H
|
||||||
#define COLORSHOP_H
|
#define PALETTE_H
|
||||||
|
|
||||||
#include <QColor>
|
#include <QColor>
|
||||||
|
|
||||||
class ColorShop
|
class Palette
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
ColorShop();
|
Palette();
|
||||||
QColor color();
|
QColor color();
|
||||||
void reset();
|
void reset();
|
||||||
|
|
||||||
@ -14,4 +14,4 @@ private:
|
|||||||
float _hueState;
|
float _hueState;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // COLORSHOP_H
|
#endif // PALLETE_H
|
@ -1,96 +1,118 @@
|
|||||||
#include "parser.h"
|
#include "parser.h"
|
||||||
|
|
||||||
|
|
||||||
void Parser::handleExtensionData(QVector<TrackPoint> &data,
|
void Parser::handleExtensionData(QStringRef element, const QString &value)
|
||||||
QStringRef element, const QString &value)
|
|
||||||
{
|
{
|
||||||
if (element == "speed")
|
if (element == "speed")
|
||||||
data.last().speed = value.toDouble();
|
_track->last().speed = value.toDouble();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Parser::handleTrekPointData(QVector<TrackPoint> &data,
|
void Parser::handleTrekPointData(QStringRef element, const QString &value)
|
||||||
QStringRef element, const QString &value)
|
|
||||||
{
|
{
|
||||||
if (element == "ele")
|
if (element == "ele")
|
||||||
data.last().elevation = value.toLatin1().toDouble();
|
_track->last().elevation = value.toLatin1().toDouble();
|
||||||
if (element == "time")
|
if (element == "time")
|
||||||
data.last().timestamp = QDateTime::fromString(value.toLatin1(),
|
_track->last().timestamp = QDateTime::fromString(value.toLatin1(),
|
||||||
Qt::ISODate);
|
Qt::ISODate);
|
||||||
if (element == "geoidheight")
|
if (element == "geoidheight")
|
||||||
data.last().geoidheight = value.toLatin1().toDouble();
|
_track->last().geoidheight = value.toLatin1().toDouble();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Parser::handleTrekPointAttributes(QVector<TrackPoint> &data,
|
void Parser::handleWayPointData(QStringRef element, const QString &value)
|
||||||
const QXmlStreamAttributes &attr)
|
|
||||||
{
|
{
|
||||||
data.last().coordinates.setY(attr.value("lat").toLatin1().toDouble());
|
if (element == "name")
|
||||||
data.last().coordinates.setX(attr.value("lon").toLatin1().toDouble());
|
_waypoints.last().setDescription(value);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Parser::handleTrekPointAttributes(const QXmlStreamAttributes &attr)
|
||||||
|
{
|
||||||
|
_track->last().coordinates.setY(attr.value("lat").toLatin1().toDouble());
|
||||||
|
_track->last().coordinates.setX(attr.value("lon").toLatin1().toDouble());
|
||||||
|
}
|
||||||
|
|
||||||
void Parser::extensions(QVector<TrackPoint> &data)
|
void Parser::handleWayPointAttributes(const QXmlStreamAttributes &attr)
|
||||||
|
{
|
||||||
|
_waypoints.last().setCoordinates(QPointF(
|
||||||
|
attr.value("lon").toLatin1().toDouble(),
|
||||||
|
attr.value("lat").toLatin1().toDouble()));
|
||||||
|
}
|
||||||
|
|
||||||
|
void Parser::extensions()
|
||||||
{
|
{
|
||||||
while (_reader.readNextStartElement()) {
|
while (_reader.readNextStartElement()) {
|
||||||
if (_reader.name() == "speed")
|
if (_reader.name() == "speed")
|
||||||
handleExtensionData(data, _reader.name(), _reader.readElementText());
|
handleExtensionData(_reader.name(), _reader.readElementText());
|
||||||
else
|
else
|
||||||
_reader.skipCurrentElement();
|
_reader.skipCurrentElement();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Parser::trekPointData(QVector<TrackPoint> &data)
|
void Parser::trackPointData()
|
||||||
{
|
{
|
||||||
while (_reader.readNextStartElement()) {
|
while (_reader.readNextStartElement()) {
|
||||||
if (_reader.name() == "ele" || _reader.name() == "time"
|
if (_reader.name() == "ele" || _reader.name() == "time"
|
||||||
|| _reader.name() == "geoidheight")
|
|| _reader.name() == "geoidheight")
|
||||||
handleTrekPointData(data, _reader.name(), _reader.readElementText());
|
handleTrekPointData(_reader.name(), _reader.readElementText());
|
||||||
else if (_reader.name() == "extensions")
|
else if (_reader.name() == "extensions")
|
||||||
extensions(data);
|
extensions();
|
||||||
else
|
else
|
||||||
_reader.skipCurrentElement();
|
_reader.skipCurrentElement();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Parser::trekPoints(QVector<TrackPoint> &data)
|
void Parser::trackPoints()
|
||||||
{
|
{
|
||||||
QXmlStreamAttributes attr;
|
|
||||||
|
|
||||||
while (_reader.readNextStartElement()) {
|
while (_reader.readNextStartElement()) {
|
||||||
if (_reader.name() == "trkpt") {
|
if (_reader.name() == "trkpt") {
|
||||||
attr = _reader.attributes();
|
_track->append(Trackpoint());
|
||||||
data.append(TrackPoint());
|
handleTrekPointAttributes(_reader.attributes());
|
||||||
handleTrekPointAttributes(data, attr);
|
trackPointData();
|
||||||
trekPointData(data);
|
|
||||||
} else
|
} else
|
||||||
_reader.skipCurrentElement();
|
_reader.skipCurrentElement();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Parser::trek(QVector<TrackPoint> &data)
|
void Parser::track()
|
||||||
{
|
{
|
||||||
while (_reader.readNextStartElement()) {
|
while (_reader.readNextStartElement()) {
|
||||||
if (_reader.name() == "trkseg") {
|
if (_reader.name() == "trkseg") {
|
||||||
trekPoints(data);
|
trackPoints();
|
||||||
} else
|
} else
|
||||||
_reader.skipCurrentElement();
|
_reader.skipCurrentElement();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Parser::gpx(QVector<TrackPoint> &data)
|
void Parser::wayPointData()
|
||||||
{
|
{
|
||||||
while (_reader.readNextStartElement()) {
|
while (_reader.readNextStartElement()) {
|
||||||
if (_reader.name() == "trk")
|
if (_reader.name() == "name")
|
||||||
trek(data);
|
handleWayPointData(_reader.name(), _reader.readElementText());
|
||||||
else
|
else
|
||||||
_reader.skipCurrentElement();
|
_reader.skipCurrentElement();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Parser::parse(QVector<TrackPoint> &data)
|
void Parser::gpx()
|
||||||
|
{
|
||||||
|
while (_reader.readNextStartElement()) {
|
||||||
|
if (_reader.name() == "trk") {
|
||||||
|
_tracks.append(QVector<Trackpoint>());
|
||||||
|
_track = &_tracks.back();
|
||||||
|
track();
|
||||||
|
} else if (_reader.name() == "wpt") {
|
||||||
|
_waypoints.append(Waypoint());
|
||||||
|
handleWayPointAttributes(_reader.attributes());
|
||||||
|
wayPointData();
|
||||||
|
} else
|
||||||
|
_reader.skipCurrentElement();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
bool Parser::parse()
|
||||||
{
|
{
|
||||||
if (_reader.readNextStartElement()) {
|
if (_reader.readNextStartElement()) {
|
||||||
if (_reader.name() == "gpx")
|
if (_reader.name() == "gpx")
|
||||||
gpx(data);
|
gpx();
|
||||||
else
|
else
|
||||||
_reader.raiseError("Not a GPX file.");
|
_reader.raiseError("Not a GPX file.");
|
||||||
}
|
}
|
||||||
@ -98,10 +120,10 @@ bool Parser::parse(QVector<TrackPoint> &data)
|
|||||||
return !_reader.error();
|
return !_reader.error();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Parser::loadFile(QIODevice *device, QVector<TrackPoint> &data)
|
bool Parser::loadFile(QIODevice *device)
|
||||||
{
|
{
|
||||||
_reader.clear();
|
_reader.clear();
|
||||||
_reader.setDevice(device);
|
_reader.setDevice(device);
|
||||||
|
|
||||||
return parse(data);
|
return parse();
|
||||||
}
|
}
|
||||||
|
47
src/parser.h
47
src/parser.h
@ -2,43 +2,40 @@
|
|||||||
#define PARSER_H
|
#define PARSER_H
|
||||||
|
|
||||||
#include <QXmlStreamReader>
|
#include <QXmlStreamReader>
|
||||||
#include <QDateTime>
|
#include <QVector>
|
||||||
#include <QPointF>
|
#include <QList>
|
||||||
|
#include "trackpoint.h"
|
||||||
|
#include "waypoint.h"
|
||||||
|
|
||||||
struct TrackPoint
|
|
||||||
{
|
|
||||||
QPointF coordinates;
|
|
||||||
QDateTime timestamp;
|
|
||||||
qreal elevation;
|
|
||||||
qreal geoidheight;
|
|
||||||
qreal speed;
|
|
||||||
|
|
||||||
TrackPoint() {elevation = 0; geoidheight = 0; speed = -1;}
|
|
||||||
};
|
|
||||||
|
|
||||||
class Parser
|
class Parser
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
bool loadFile(QIODevice *device, QVector<TrackPoint> &data);
|
Parser(QList<QVector<Trackpoint> > &tracks, QList<Waypoint> &waypoints)
|
||||||
|
: _tracks(tracks), _waypoints(waypoints) {_track = 0;}
|
||||||
|
bool loadFile(QIODevice *device);
|
||||||
QString errorString() const {return _reader.errorString();}
|
QString errorString() const {return _reader.errorString();}
|
||||||
int errorLine() const {return _reader.lineNumber();}
|
int errorLine() const {return _reader.lineNumber();}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
bool parse(QVector<TrackPoint> &data);
|
bool parse();
|
||||||
void gpx(QVector<TrackPoint> &data);
|
void gpx();
|
||||||
void trek(QVector<TrackPoint> &data);
|
void track();
|
||||||
void trekPoints(QVector<TrackPoint> &data);
|
void trackPoints();
|
||||||
void extensions(QVector<TrackPoint> &data);
|
void extensions();
|
||||||
void trekPointData(QVector<TrackPoint> &data);
|
void trackPointData();
|
||||||
|
void wayPointData();
|
||||||
|
|
||||||
void handleTrekPointAttributes(QVector<TrackPoint> &data,
|
void handleWayPointAttributes(const QXmlStreamAttributes &attr);
|
||||||
const QXmlStreamAttributes &attr);
|
void handleWayPointData(QStringRef element, const QString &value);
|
||||||
void handleTrekPointData(QVector<TrackPoint> &data, QStringRef element,
|
void handleTrekPointAttributes(const QXmlStreamAttributes &attr);
|
||||||
const QString &value);
|
void handleTrekPointData(QStringRef element, const QString &value);
|
||||||
void handleExtensionData(QVector<TrackPoint> &data, QStringRef element,
|
void handleExtensionData(QStringRef element, const QString &value);
|
||||||
const QString &value);
|
|
||||||
|
|
||||||
QXmlStreamReader _reader;
|
QXmlStreamReader _reader;
|
||||||
|
QList<QVector<Trackpoint> > &_tracks;
|
||||||
|
QList<Waypoint> &_waypoints;
|
||||||
|
QVector<Trackpoint> *_track;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // PARSER_H
|
#endif // PARSER_H
|
||||||
|
130
src/poi.cpp
130
src/poi.cpp
@ -2,20 +2,83 @@
|
|||||||
#include <QSet>
|
#include <QSet>
|
||||||
#include <QList>
|
#include <QList>
|
||||||
#include "ll.h"
|
#include "ll.h"
|
||||||
|
#include "gpx.h"
|
||||||
#include "poi.h"
|
#include "poi.h"
|
||||||
|
|
||||||
|
|
||||||
#define BOUNDING_RECT_SIZE 0.01
|
|
||||||
|
|
||||||
bool POI::loadFile(const QString &fileName)
|
bool POI::loadFile(const QString &fileName)
|
||||||
{
|
{
|
||||||
QFile file(fileName);
|
QString error;
|
||||||
bool ret;
|
int errorLine;
|
||||||
int ln = 1, cnt = _data.size();
|
|
||||||
|
|
||||||
_error.clear();
|
_error.clear();
|
||||||
_errorLine = 0;
|
_errorLine = 0;
|
||||||
|
|
||||||
|
|
||||||
|
if (loadCSVFile(fileName))
|
||||||
|
return true;
|
||||||
|
else {
|
||||||
|
error = _error;
|
||||||
|
errorLine = _errorLine;
|
||||||
|
}
|
||||||
|
if (loadGPXFile(fileName))
|
||||||
|
return true;
|
||||||
|
|
||||||
|
fprintf(stderr, "Error loading POI file: %s:\n", qPrintable(fileName));
|
||||||
|
fprintf(stderr, "CSV: line %d: %s\n", errorLine, qPrintable(error));
|
||||||
|
fprintf(stderr, "GPX: line %d: %s\n", _errorLine, qPrintable(_error));
|
||||||
|
|
||||||
|
if (errorLine > _errorLine) {
|
||||||
|
_errorLine = errorLine;
|
||||||
|
_error = error;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool POI::loadGPXFile(const QString &fileName)
|
||||||
|
{
|
||||||
|
GPX gpx;
|
||||||
|
FileIndex index;
|
||||||
|
|
||||||
|
index.enabled = true;
|
||||||
|
index.start = _data.size();
|
||||||
|
|
||||||
|
if (gpx.loadFile(fileName)) {
|
||||||
|
for (int i = 0; i < gpx.waypoints().size(); i++)
|
||||||
|
_data.append(gpx.waypoints().at(i));
|
||||||
|
index.end = _data.size() - 1;
|
||||||
|
|
||||||
|
for (int i = index.start; i <= index.end; i++) {
|
||||||
|
const QPointF &p = _data.at(i).coordinates();
|
||||||
|
qreal c[2];
|
||||||
|
c[0] = p.x();
|
||||||
|
c[1] = p.y();
|
||||||
|
_tree.Insert(c, c, i);
|
||||||
|
}
|
||||||
|
|
||||||
|
_files.append(fileName);
|
||||||
|
_indexes.append(index);
|
||||||
|
|
||||||
|
return true;
|
||||||
|
} else {
|
||||||
|
_error = gpx.errorString();
|
||||||
|
_errorLine = gpx.errorLine();
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool POI::loadCSVFile(const QString &fileName)
|
||||||
|
{
|
||||||
|
QFile file(fileName);
|
||||||
|
FileIndex index;
|
||||||
|
bool ret;
|
||||||
|
int ln = 1;
|
||||||
|
|
||||||
|
index.enabled = true;
|
||||||
|
index.start = _data.size();
|
||||||
|
|
||||||
if (!file.open(QFile::ReadOnly | QFile::Text)) {
|
if (!file.open(QFile::ReadOnly | QFile::Text)) {
|
||||||
_error = qPrintable(file.errorString());
|
_error = qPrintable(file.errorString());
|
||||||
return false;
|
return false;
|
||||||
@ -44,21 +107,23 @@ bool POI::loadFile(const QString &fileName)
|
|||||||
}
|
}
|
||||||
QByteArray ba = list[2].trimmed();
|
QByteArray ba = list[2].trimmed();
|
||||||
|
|
||||||
Entry entry;
|
_data.append(Waypoint(QPointF(lon, lat),
|
||||||
entry.description = QString::fromUtf8(ba.data(), ba.size());
|
QString::fromUtf8(ba.data(), ba.size())));
|
||||||
entry.coordinates = ll2mercator(QPointF(lon, lat));
|
|
||||||
|
|
||||||
_data.append(entry);
|
|
||||||
ln++;
|
ln++;
|
||||||
}
|
}
|
||||||
|
index.end = _data.size() - 1;
|
||||||
|
|
||||||
for (int i = cnt; i < _data.size(); ++i) {
|
for (int i = index.start; i <= index.end; i++) {
|
||||||
|
const QPointF &p = _data.at(i).coordinates();
|
||||||
qreal c[2];
|
qreal c[2];
|
||||||
c[0] = _data.at(i).coordinates.x();
|
c[0] = p.x();
|
||||||
c[1] = _data.at(i).coordinates.y();
|
c[1] = p.y();
|
||||||
_tree.Insert(c, c, i);
|
_tree.Insert(c, c, i);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
_files.append(fileName);
|
||||||
|
_indexes.append(index);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -70,17 +135,18 @@ static bool cb(size_t data, void* context)
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
QVector<Entry> POI::points(const QVector<QPointF> &path) const
|
QVector<Waypoint> POI::points(const QVector<QPointF> &path, qreal radius) const
|
||||||
{
|
{
|
||||||
QVector<Entry> ret;
|
QVector<Waypoint> ret;
|
||||||
QSet<int> set;
|
QSet<int> set;
|
||||||
qreal min[2], max[2];
|
qreal min[2], max[2];
|
||||||
|
|
||||||
for (int i = 0; i < path.count(); i++) {
|
for (int i = 0; i < path.count(); i++) {
|
||||||
min[0] = path.at(i).x() - BOUNDING_RECT_SIZE;
|
const QPointF &p = path.at(i);
|
||||||
min[1] = path.at(i).y() - BOUNDING_RECT_SIZE;
|
min[0] = p.x() - radius;
|
||||||
max[0] = path.at(i).x() + BOUNDING_RECT_SIZE;
|
min[1] = p.y() - radius;
|
||||||
max[1] = path.at(i).y() + BOUNDING_RECT_SIZE;
|
max[0] = p.x() + radius;
|
||||||
|
max[1] = p.y() + radius;
|
||||||
_tree.Search(min, max, cb, &set);
|
_tree.Search(min, max, cb, &set);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -93,8 +159,34 @@ QVector<Entry> POI::points(const QVector<QPointF> &path) const
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void POI::enableFile(const QString &fileName, bool enable)
|
||||||
|
{
|
||||||
|
int i;
|
||||||
|
|
||||||
|
i = _files.indexOf(fileName);
|
||||||
|
Q_ASSERT(i >= 0);
|
||||||
|
_indexes[i].enabled = enable;
|
||||||
|
|
||||||
|
_tree.RemoveAll();
|
||||||
|
for (int i = 0; i < _indexes.count(); i++) {
|
||||||
|
FileIndex idx = _indexes.at(i);
|
||||||
|
if (!idx.enabled)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
for (int j = idx.start; j <= idx.end; j++) {
|
||||||
|
const QPointF &p = _data.at(j).coordinates();
|
||||||
|
qreal c[2];
|
||||||
|
c[0] = p.x();
|
||||||
|
c[1] = p.y();
|
||||||
|
_tree.Insert(c, c, j);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void POI::clear()
|
void POI::clear()
|
||||||
{
|
{
|
||||||
_tree.RemoveAll();
|
_tree.RemoveAll();
|
||||||
_data.clear();
|
_data.clear();
|
||||||
|
_files.clear();
|
||||||
|
_indexes.clear();
|
||||||
}
|
}
|
||||||
|
40
src/poi.h
40
src/poi.h
@ -4,41 +4,41 @@
|
|||||||
#include <QVector>
|
#include <QVector>
|
||||||
#include <QPointF>
|
#include <QPointF>
|
||||||
#include <QString>
|
#include <QString>
|
||||||
|
#include <QStringList>
|
||||||
|
#include "waypoint.h"
|
||||||
#include "rtree.h"
|
#include "rtree.h"
|
||||||
|
|
||||||
class Entry
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
QPointF coordinates;
|
|
||||||
QString description;
|
|
||||||
|
|
||||||
bool operator==(const Entry &other) const
|
|
||||||
{return this->description == other.description
|
|
||||||
&& this->coordinates == other.coordinates;}
|
|
||||||
};
|
|
||||||
|
|
||||||
inline uint qHash(const Entry &key)
|
|
||||||
{
|
|
||||||
return ::qHash(key.description);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
class POI
|
class POI
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
POI() : _errorLine(0) {}
|
||||||
bool loadFile(const QString &fileName);
|
bool loadFile(const QString &fileName);
|
||||||
QString errorString() const {return _error;}
|
const QString &errorString() const {return _error;}
|
||||||
int errorLine() const {return _errorLine;}
|
int errorLine() const {return _errorLine;}
|
||||||
|
|
||||||
QVector<Entry> points(const QVector<QPointF> &path) const;
|
QVector<Waypoint> points(const QVector<QPointF> &path,
|
||||||
|
qreal radius = 0.01) const;
|
||||||
|
const QStringList &files() const {return _files;}
|
||||||
|
void enableFile(const QString &fileName, bool enable);
|
||||||
void clear();
|
void clear();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
typedef RTree<size_t, qreal, 2> POITree;
|
typedef RTree<size_t, qreal, 2> POITree;
|
||||||
|
typedef struct {
|
||||||
|
int start;
|
||||||
|
int end;
|
||||||
|
bool enabled;
|
||||||
|
} FileIndex;
|
||||||
|
|
||||||
|
bool loadCSVFile(const QString &fileName);
|
||||||
|
bool loadGPXFile(const QString &fileName);
|
||||||
|
|
||||||
POITree _tree;
|
POITree _tree;
|
||||||
QVector<Entry> _data;
|
QVector<Waypoint> _data;
|
||||||
|
QStringList _files;
|
||||||
|
QList<FileIndex> _indexes;
|
||||||
|
|
||||||
QString _error;
|
QString _error;
|
||||||
int _errorLine;
|
int _errorLine;
|
||||||
};
|
};
|
||||||
|
@ -1,49 +0,0 @@
|
|||||||
#include <QPainter>
|
|
||||||
#include "config.h"
|
|
||||||
#include "poiitem.h"
|
|
||||||
|
|
||||||
|
|
||||||
#define POINT_SIZE 8
|
|
||||||
|
|
||||||
POIItem::POIItem(const Entry &entry, QGraphicsItem *parent)
|
|
||||||
: QGraphicsItem(parent)
|
|
||||||
{
|
|
||||||
_entry = entry;
|
|
||||||
updateBoundingRect();
|
|
||||||
}
|
|
||||||
|
|
||||||
void POIItem::updateBoundingRect()
|
|
||||||
{
|
|
||||||
QFont font;
|
|
||||||
font.setPixelSize(FONT_SIZE);
|
|
||||||
font.setFamily(FONT_FAMILY);
|
|
||||||
QFontMetrics fm(font);
|
|
||||||
QRect ts = fm.tightBoundingRect(_entry.description);
|
|
||||||
|
|
||||||
_boundingRect = QRectF(0, 0, ts.width() + POINT_SIZE,
|
|
||||||
ts.height() + fm.descent() + POINT_SIZE);
|
|
||||||
}
|
|
||||||
|
|
||||||
void POIItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *option,
|
|
||||||
QWidget *widget)
|
|
||||||
{
|
|
||||||
Q_UNUSED(option);
|
|
||||||
Q_UNUSED(widget);
|
|
||||||
QFont font;
|
|
||||||
font.setPixelSize(FONT_SIZE);
|
|
||||||
font.setFamily(FONT_FAMILY);
|
|
||||||
QFontMetrics fm(font);
|
|
||||||
QRect ts = fm.tightBoundingRect(_entry.description);
|
|
||||||
|
|
||||||
painter->setFont(font);
|
|
||||||
painter->drawText(POINT_SIZE - qMax(ts.x(), 0), POINT_SIZE + ts.height(),
|
|
||||||
_entry.description);
|
|
||||||
painter->setBrush(Qt::SolidPattern);
|
|
||||||
painter->drawEllipse(0, 0, POINT_SIZE, POINT_SIZE);
|
|
||||||
|
|
||||||
/*
|
|
||||||
painter->setPen(Qt::red);
|
|
||||||
painter->setBrush(Qt::NoBrush);
|
|
||||||
painter->drawRect(boundingRect());
|
|
||||||
*/
|
|
||||||
}
|
|
@ -1,24 +0,0 @@
|
|||||||
#ifndef POIITEM_H
|
|
||||||
#define POIITEM_H
|
|
||||||
|
|
||||||
#include <QGraphicsItem>
|
|
||||||
#include "poi.h"
|
|
||||||
|
|
||||||
class POIItem : public QGraphicsItem
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
POIItem(const Entry &entry, QGraphicsItem *parent = 0);
|
|
||||||
const Entry &entry() const {return _entry;}
|
|
||||||
|
|
||||||
QRectF boundingRect() const {return _boundingRect;}
|
|
||||||
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option,
|
|
||||||
QWidget *widget);
|
|
||||||
|
|
||||||
private:
|
|
||||||
void updateBoundingRect();
|
|
||||||
|
|
||||||
Entry _entry;
|
|
||||||
QRectF _boundingRect;
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif // POIITEM_H
|
|
813
src/rtree.h
813
src/rtree.h
File diff suppressed because it is too large
Load Diff
137
src/scaleitem.cpp
Normal file
137
src/scaleitem.cpp
Normal file
@ -0,0 +1,137 @@
|
|||||||
|
#include <QPainter>
|
||||||
|
#include "config.h"
|
||||||
|
#include "ll.h"
|
||||||
|
#include "nicenum.h"
|
||||||
|
#include "scaleitem.h"
|
||||||
|
|
||||||
|
|
||||||
|
#define SCALE_WIDTH 132
|
||||||
|
#define SCALE_HEIGHT 5
|
||||||
|
#define SEGMENTS 3
|
||||||
|
|
||||||
|
#define PADDING 4
|
||||||
|
|
||||||
|
|
||||||
|
ScaleItem::ScaleItem(QGraphicsItem *parent) : QGraphicsItem(parent)
|
||||||
|
{
|
||||||
|
_units = Metric;
|
||||||
|
_zoom = ZOOM_MIN;
|
||||||
|
_lat = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
void ScaleItem::updateBoundingRect()
|
||||||
|
{
|
||||||
|
QFont font;
|
||||||
|
font.setPixelSize(FONT_SIZE);
|
||||||
|
font.setFamily(FONT_FAMILY);
|
||||||
|
QFontMetrics fm(font);
|
||||||
|
QRect ss, es, us;
|
||||||
|
|
||||||
|
ss = fm.tightBoundingRect(QString::number(0));
|
||||||
|
es = fm.tightBoundingRect(QString::number(_length * SEGMENTS));
|
||||||
|
us = fm.tightBoundingRect(units());
|
||||||
|
|
||||||
|
_boundingRect = QRectF(-ss.width()/2, 0,
|
||||||
|
_width * SEGMENTS + ss.width()/2 + qMax(us.width() + PADDING, es.width()/2),
|
||||||
|
SCALE_HEIGHT + PADDING + ss.height() + 2*fm.descent());
|
||||||
|
}
|
||||||
|
|
||||||
|
void ScaleItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *option,
|
||||||
|
QWidget *widget)
|
||||||
|
{
|
||||||
|
Q_UNUSED(option);
|
||||||
|
Q_UNUSED(widget);
|
||||||
|
QFont font;
|
||||||
|
font.setPixelSize(FONT_SIZE);
|
||||||
|
font.setFamily(FONT_FAMILY);
|
||||||
|
QFontMetrics fm(font);
|
||||||
|
QRect br;
|
||||||
|
bool aa;
|
||||||
|
|
||||||
|
|
||||||
|
if ((aa = painter->testRenderHint(QPainter::Antialiasing)))
|
||||||
|
painter->setRenderHint(QPainter::Antialiasing, false);
|
||||||
|
|
||||||
|
painter->setFont(font);
|
||||||
|
|
||||||
|
for (int i = 0; i <= SEGMENTS; i++) {
|
||||||
|
QString label = QString::number(_length * i);
|
||||||
|
br = fm.tightBoundingRect(label);
|
||||||
|
painter->drawText(_width * i - br.width()/2, br.height(), label);
|
||||||
|
}
|
||||||
|
painter->drawText(_width * SEGMENTS + PADDING, SCALE_HEIGHT + PADDING
|
||||||
|
+ br.height() + fm.descent(), units());
|
||||||
|
|
||||||
|
painter->drawRect(QRectF(0, br.height() + PADDING, SEGMENTS * _width,
|
||||||
|
SCALE_HEIGHT));
|
||||||
|
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());
|
||||||
|
*/
|
||||||
|
}
|
||||||
|
|
||||||
|
QString ScaleItem::units() const
|
||||||
|
{
|
||||||
|
if (_units == Imperial)
|
||||||
|
return _scale ? QObject::tr("mi") : QObject::tr("ft");
|
||||||
|
else
|
||||||
|
return _scale ? QObject::tr("km") : QObject::tr("m");
|
||||||
|
}
|
||||||
|
|
||||||
|
void ScaleItem::computeScale()
|
||||||
|
{
|
||||||
|
qreal res = zoom2resolution(_zoom, _lat);
|
||||||
|
|
||||||
|
if (_units == Imperial) {
|
||||||
|
_length = niceNum((res * M2FT * SCALE_WIDTH) / SEGMENTS, 1);
|
||||||
|
if (_length >= MIINFT) {
|
||||||
|
_length = niceNum((res * M2FT * FT2MI * SCALE_WIDTH) / SEGMENTS, 1);
|
||||||
|
_width = (_length / (res * M2FT * FT2MI));
|
||||||
|
_scale = true;
|
||||||
|
} else {
|
||||||
|
_width = (_length / (res * M2FT));
|
||||||
|
_scale = false;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
_length = niceNum((res * SCALE_WIDTH) / SEGMENTS, 1);
|
||||||
|
if (_length >= KMINM) {
|
||||||
|
_length *= M2KM;
|
||||||
|
_width = (_length / (res * M2KM));
|
||||||
|
_scale = true;
|
||||||
|
} else {
|
||||||
|
_width = (_length / res);
|
||||||
|
_scale = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void ScaleItem::setLatitude(qreal lat)
|
||||||
|
{
|
||||||
|
_lat = lat;
|
||||||
|
computeScale();
|
||||||
|
updateBoundingRect();
|
||||||
|
prepareGeometryChange();
|
||||||
|
}
|
||||||
|
|
||||||
|
void ScaleItem::setZoom(int z)
|
||||||
|
{
|
||||||
|
_zoom = z;
|
||||||
|
computeScale();
|
||||||
|
updateBoundingRect();
|
||||||
|
prepareGeometryChange();
|
||||||
|
}
|
||||||
|
|
||||||
|
void ScaleItem::setUnits(enum Units units)
|
||||||
|
{
|
||||||
|
_units = units;
|
||||||
|
computeScale();
|
||||||
|
updateBoundingRect();
|
||||||
|
prepareGeometryChange();
|
||||||
|
}
|
35
src/scaleitem.h
Normal file
35
src/scaleitem.h
Normal file
@ -0,0 +1,35 @@
|
|||||||
|
#ifndef SCALEITEM_H
|
||||||
|
#define SCALEITEM_H
|
||||||
|
|
||||||
|
#include <QGraphicsItem>
|
||||||
|
#include "units.h"
|
||||||
|
|
||||||
|
class ScaleItem : public QGraphicsItem
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
ScaleItem(QGraphicsItem *parent = 0);
|
||||||
|
|
||||||
|
QRectF boundingRect() const {return _boundingRect;}
|
||||||
|
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option,
|
||||||
|
QWidget *widget);
|
||||||
|
|
||||||
|
void setLatitude(qreal lat);
|
||||||
|
void setZoom(int z);
|
||||||
|
void setUnits(enum Units units);
|
||||||
|
|
||||||
|
private:
|
||||||
|
void updateBoundingRect();
|
||||||
|
void computeScale();
|
||||||
|
QString units() const;
|
||||||
|
|
||||||
|
int _zoom;
|
||||||
|
qreal _lat;
|
||||||
|
qreal _width;
|
||||||
|
qreal _length;
|
||||||
|
Units _units;
|
||||||
|
bool _scale;
|
||||||
|
|
||||||
|
QRectF _boundingRect;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // SCALEITEM_H
|
@ -7,7 +7,6 @@
|
|||||||
|
|
||||||
SliderInfoItem::SliderInfoItem(QGraphicsItem *parent) : QGraphicsItem(parent)
|
SliderInfoItem::SliderInfoItem(QGraphicsItem *parent) : QGraphicsItem(parent)
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void SliderInfoItem::updateBoundingRect()
|
void SliderInfoItem::updateBoundingRect()
|
||||||
|
@ -46,3 +46,9 @@ QVariant SliderItem::itemChange(GraphicsItemChange change, const QVariant &value
|
|||||||
|
|
||||||
return QGraphicsItem::itemChange(change, value);
|
return QGraphicsItem::itemChange(change, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void SliderItem::clear()
|
||||||
|
{
|
||||||
|
_area = QRectF();
|
||||||
|
setPos(QPointF());
|
||||||
|
}
|
||||||
|
@ -14,9 +14,11 @@ public:
|
|||||||
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option,
|
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option,
|
||||||
QWidget *widget);
|
QWidget *widget);
|
||||||
|
|
||||||
QRectF area() {return _area;}
|
const QRectF &area() const {return _area;}
|
||||||
void setArea(const QRectF &area) {_area = area;}
|
void setArea(const QRectF &area) {_area = area;}
|
||||||
|
|
||||||
|
void clear();
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void positionChanged(const QPointF&);
|
void positionChanged(const QPointF&);
|
||||||
|
|
||||||
|
@ -1,43 +1,49 @@
|
|||||||
#include "config.h"
|
#include "config.h"
|
||||||
|
#include "gpx.h"
|
||||||
#include "speedgraph.h"
|
#include "speedgraph.h"
|
||||||
|
|
||||||
|
|
||||||
SpeedGraph::SpeedGraph(QWidget *parent) : Graph(parent)
|
SpeedGraph::SpeedGraph(QWidget *parent) : GraphView(parent)
|
||||||
{
|
{
|
||||||
_max = 0;
|
_max = 0;
|
||||||
|
|
||||||
Graph::setXLabel(tr("Distance"));
|
GraphView::setXLabel(tr("Distance"));
|
||||||
Graph::setYLabel(tr("Speed"));
|
GraphView::setYLabel(tr("Speed"));
|
||||||
Graph::setXUnits(tr("km"));
|
GraphView::setXUnits(tr("km"));
|
||||||
Graph::setYUnits(tr("km/h"));
|
GraphView::setYUnits(tr("km/h"));
|
||||||
Graph::setXScale(0.001);
|
GraphView::setXScale(M2KM);
|
||||||
Graph::setYScale(3.6);
|
GraphView::setYScale(MS2KMH);
|
||||||
Graph::setPrecision(1);
|
GraphView::setPrecision(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);
|
||||||
}
|
}
|
||||||
|
|
||||||
void SpeedGraph::loadGPX(const GPX &gpx)
|
void SpeedGraph::loadGPX(const GPX &gpx)
|
||||||
{
|
{
|
||||||
QVector<QPointF> data;
|
for (int i = 0; i < gpx.trackCount(); i++) {
|
||||||
qreal max = 0;
|
QVector<QPointF> data;
|
||||||
|
qreal max = 0;
|
||||||
|
|
||||||
|
gpx.track(i).speedGraph(data);
|
||||||
|
if (data.isEmpty())
|
||||||
|
continue;
|
||||||
|
|
||||||
gpx.speedGraph(data);
|
_avg.append(QPointF(gpx.track(i).distance(), gpx.track(i).distance()
|
||||||
if (data.isEmpty())
|
/ gpx.track(i).time()));
|
||||||
return;
|
|
||||||
|
|
||||||
_avg.append(QPointF(gpx.distance(), gpx.distance() / gpx.time()));
|
for (int i = 0; i < data.size(); i++)
|
||||||
|
max = qMax(max, data.at(i).y());
|
||||||
|
_max = qMax(_max, max);
|
||||||
|
|
||||||
for (int i = 0; i < data.size(); i++)
|
addInfo();
|
||||||
max = qMax(max, data.at(i).y());
|
loadData(data);
|
||||||
_max = qMax(_max, max);
|
}
|
||||||
|
|
||||||
|
|
||||||
addInfo(tr("Average"), QString::number(avg() * _yScale, 'f', 1)
|
|
||||||
+ THIN_SPACE + _yUnits);
|
|
||||||
addInfo(tr("Maximum"), QString::number(_max * _yScale, 'f', 1)
|
|
||||||
+ THIN_SPACE + _yUnits);
|
|
||||||
|
|
||||||
Graph::loadData(data);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
qreal SpeedGraph::avg() const
|
qreal SpeedGraph::avg() const
|
||||||
@ -58,5 +64,25 @@ void SpeedGraph::clear()
|
|||||||
_max = 0;
|
_max = 0;
|
||||||
_avg.clear();
|
_avg.clear();
|
||||||
|
|
||||||
Graph::clear();
|
GraphView::clear();
|
||||||
|
}
|
||||||
|
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
|
||||||
|
clearInfo();
|
||||||
|
addInfo();
|
||||||
|
|
||||||
|
redraw();
|
||||||
}
|
}
|
||||||
|
@ -2,10 +2,12 @@
|
|||||||
#define SPEEDGRAPH_H
|
#define SPEEDGRAPH_H
|
||||||
|
|
||||||
#include <QList>
|
#include <QList>
|
||||||
#include "graph.h"
|
#include "graphview.h"
|
||||||
#include "gpx.h"
|
#include "units.h"
|
||||||
|
|
||||||
class SpeedGraph : public Graph
|
class GPX;
|
||||||
|
|
||||||
|
class SpeedGraph : public GraphView
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
@ -14,11 +16,14 @@ public:
|
|||||||
|
|
||||||
void loadGPX(const GPX &gpx);
|
void loadGPX(const GPX &gpx);
|
||||||
void clear();
|
void clear();
|
||||||
|
void setUnits(enum Units units);
|
||||||
|
|
||||||
qreal avg() const;
|
qreal avg() const;
|
||||||
qreal max() const {return _max;}
|
qreal max() const {return _max;}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
void addInfo();
|
||||||
|
|
||||||
qreal _max;
|
qreal _max;
|
||||||
QList<QPointF> _avg;
|
QList<QPointF> _avg;
|
||||||
};
|
};
|
||||||
|
379
src/track.cpp
379
src/track.cpp
@ -1,306 +1,161 @@
|
|||||||
#include <cmath>
|
#include <cmath>
|
||||||
#include <QGraphicsView>
|
|
||||||
#include <QGraphicsScene>
|
|
||||||
#include <QPainterPath>
|
|
||||||
#include <QWheelEvent>
|
|
||||||
#include "poiitem.h"
|
|
||||||
#include "markeritem.h"
|
|
||||||
#include "ll.h"
|
#include "ll.h"
|
||||||
#include "track.h"
|
#include "track.h"
|
||||||
|
|
||||||
|
|
||||||
#define MARGIN 10.0
|
#define WINDOW_EF 3
|
||||||
#define TRACK_WIDTH 3
|
#define WINDOW_SE 11
|
||||||
|
#define WINDOW_SF 11
|
||||||
|
|
||||||
Track::Track(QWidget *parent)
|
static bool lt(const QPointF &p1, const QPointF &p2)
|
||||||
: QGraphicsView(parent)
|
|
||||||
{
|
{
|
||||||
_scene = new QGraphicsScene(this);
|
return p1.y() < p2.y();
|
||||||
setScene(_scene);
|
|
||||||
setCacheMode(QGraphicsView::CacheBackground);
|
|
||||||
setDragMode(QGraphicsView::ScrollHandDrag);
|
|
||||||
setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
|
|
||||||
setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
|
|
||||||
|
|
||||||
_zoom = -1;
|
|
||||||
_scale = 1.0;
|
|
||||||
_map = 0;
|
|
||||||
_maxLen = 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Track::~Track()
|
static qreal median(QVector<QPointF> v)
|
||||||
{
|
{
|
||||||
delete _scene;
|
qSort(v.begin(), v.end(), lt);
|
||||||
|
return v.at(v.size() / 2).y();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Track::loadGPX(const GPX &gpx)
|
static qreal MAD(QVector<QPointF> v, qreal m)
|
||||||
{
|
{
|
||||||
QVector<QPointF> track;
|
for (int i = 0; i < v.size(); i++)
|
||||||
QPainterPath path;
|
v[i].setY(qAbs(v.at(i).y() - m));
|
||||||
QGraphicsPathItem *pi;
|
qSort(v.begin(), v.end(), lt);
|
||||||
MarkerItem *mi;
|
return v.at(v.size() / 2).y();
|
||||||
QColor color = _colorShop.color();
|
}
|
||||||
qreal prevScale = _scale;
|
|
||||||
|
static QVector<QPointF> eliminate(const QVector<QPointF> &v, int window)
|
||||||
|
{
|
||||||
|
QList<int> rm;
|
||||||
|
QVector<QPointF> ret;
|
||||||
|
qreal m, M;
|
||||||
|
|
||||||
|
|
||||||
gpx.track(track);
|
if (v.size() < window)
|
||||||
|
return QVector<QPointF>(v);
|
||||||
|
|
||||||
if (track.size() < 2)
|
for (int i = window/2; i < v.size() - window/2; i++) {
|
||||||
|
m = median(v.mid(i - window/2, window));
|
||||||
|
M = MAD(v.mid(i - window/2, window), m);
|
||||||
|
if (qAbs((0.6745 * (v.at(i).y() - m)) / M) > 3.5)
|
||||||
|
rm.append(i);
|
||||||
|
}
|
||||||
|
|
||||||
|
QList<int>::const_iterator it = rm.begin();
|
||||||
|
for (int i = 0; i < v.size(); i++) {
|
||||||
|
if (it == rm.end() || *it != i)
|
||||||
|
ret.append(v.at(i));
|
||||||
|
else
|
||||||
|
it++;
|
||||||
|
}
|
||||||
|
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
static QVector<QPointF> filter(const QVector<QPointF> &v, int window)
|
||||||
|
{
|
||||||
|
qreal acc = 0;
|
||||||
|
QVector<QPointF> ret;
|
||||||
|
|
||||||
|
if (v.size() < window)
|
||||||
|
return QVector<QPointF>(v);
|
||||||
|
|
||||||
|
for (int i = 0; i < window; i++)
|
||||||
|
acc += v.at(i).y();
|
||||||
|
for (int i = 0; i <= window/2; i++)
|
||||||
|
ret.append(QPointF(v.at(i).x(), acc/window));
|
||||||
|
|
||||||
|
for (int i = window/2 + 1; i < v.size() - window/2; i++) {
|
||||||
|
acc += v.at(i + window/2).y() - v.at(i - (window/2 + 1)).y();
|
||||||
|
ret.append(QPointF(v.at(i).x(), acc/window));
|
||||||
|
}
|
||||||
|
|
||||||
|
for (int i = v.size() - window/2; i < v.size(); i++)
|
||||||
|
ret.append(QPointF(v.at(i).x(), acc/window));
|
||||||
|
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
void Track::elevationGraph(QVector<QPointF> &graph) const
|
||||||
|
{
|
||||||
|
qreal dist = 0;
|
||||||
|
QVector<QPointF> raw;
|
||||||
|
|
||||||
|
if (!_data.size())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
_tracks.append(track);
|
if (isnan(_data.at(0).elevation))
|
||||||
|
return;
|
||||||
path.moveTo(track.at(0).x(), -track.at(0).y());
|
raw.append(QPointF(0, _data.at(0).elevation));
|
||||||
for (int i = 1; i < track.size(); i++)
|
for (int i = 1; i < _data.size(); i++) {
|
||||||
path.lineTo(track.at(i).x(), -track.at(i).y());
|
dist += llDistance(_data.at(i).coordinates, _data.at(i-1).coordinates);
|
||||||
|
if (isnan(_data.at(i).elevation))
|
||||||
_maxLen = qMax(path.length(), _maxLen);
|
return;
|
||||||
|
raw.append(QPointF(dist, _data.at(i).elevation
|
||||||
|
- _data.at(i).geoidheight));
|
||||||
pi = new QGraphicsPathItem(path);
|
|
||||||
_trackPaths.append(pi);
|
|
||||||
_zoom = scale2zoom(trackScale());
|
|
||||||
_scale = mapScale();
|
|
||||||
QBrush brush(color, Qt::SolidPattern);
|
|
||||||
QPen pen(brush, TRACK_WIDTH * _scale);
|
|
||||||
pi->setPen(pen);
|
|
||||||
pi->setScale(1.0/_scale);
|
|
||||||
_scene->addItem(pi);
|
|
||||||
|
|
||||||
mi = new MarkerItem(pi);
|
|
||||||
_markers.append(mi);
|
|
||||||
mi->setPos(pi->path().pointAtPercent(0));
|
|
||||||
mi->setScale(_scale);
|
|
||||||
|
|
||||||
if (_trackPaths.size() > 1 && prevScale != _scale)
|
|
||||||
rescale(_scale);
|
|
||||||
_scene->setSceneRect(_scene->itemsBoundingRect());
|
|
||||||
}
|
|
||||||
|
|
||||||
qreal Track::trackScale() const
|
|
||||||
{
|
|
||||||
qreal bottom, top, left, right;
|
|
||||||
|
|
||||||
bottom = _trackPaths.at(0)->path().boundingRect().bottom();
|
|
||||||
top = _trackPaths.at(0)->path().boundingRect().top();
|
|
||||||
left = _trackPaths.at(0)->path().boundingRect().left();
|
|
||||||
right = _trackPaths.at(0)->path().boundingRect().right();
|
|
||||||
|
|
||||||
for (int i = 1; i < _trackPaths.size(); i++) {
|
|
||||||
bottom = qMax(bottom, _trackPaths.at(i)->path().boundingRect().bottom());
|
|
||||||
top = qMin(top, _trackPaths.at(i)->path().boundingRect().top());
|
|
||||||
right = qMax(right, _trackPaths.at(i)->path().boundingRect().right());
|
|
||||||
left = qMin(left, _trackPaths.at(i)->path().boundingRect().left());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
QRectF br(QPointF(left, top), QPointF(right, bottom));
|
graph = filter(raw, WINDOW_EF);
|
||||||
QPointF sc(br.width() / (viewport()->width() - MARGIN/2),
|
|
||||||
br.height() / (viewport()->height() - MARGIN/2));
|
|
||||||
|
|
||||||
return qMax(sc.x(), sc.y());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
qreal Track::mapScale() const
|
void Track::speedGraph(QVector<QPointF> &graph) const
|
||||||
{
|
{
|
||||||
return ((360.0/(qreal)(1<<_zoom))/(qreal)TILE_SIZE);
|
qreal dist = 0, v, ds, dt;
|
||||||
}
|
QVector<QPointF> raw;
|
||||||
|
|
||||||
void Track::rescale(qreal scale)
|
if (!_data.size())
|
||||||
{
|
return;
|
||||||
for (int i = 0; i < _trackPaths.size(); i++) {
|
|
||||||
_markers.at(i)->setScale(scale);
|
|
||||||
_trackPaths.at(i)->setScale(1.0/scale);
|
|
||||||
|
|
||||||
QPen pen(_trackPaths.at(i)->pen());
|
raw.append(QPointF(0, 0));
|
||||||
pen.setWidthF(TRACK_WIDTH * scale);
|
for (int i = 1; i < _data.size(); i++) {
|
||||||
_trackPaths.at(i)->setPen(pen);
|
ds = llDistance(_data.at(i).coordinates, _data.at(i-1).coordinates);
|
||||||
}
|
dt = _data.at(i-1).timestamp.msecsTo(_data.at(i).timestamp) / 1000.0;
|
||||||
|
dist += ds;
|
||||||
|
|
||||||
QHash<Entry, POIItem*>::const_iterator it, jt;
|
if (isnan(_data.at(i).speed)) {
|
||||||
for (it = _pois.constBegin(); it != _pois.constEnd(); it++) {
|
if (dt == 0)
|
||||||
it.value()->setPos(QPointF(it.value()->entry().coordinates.x()
|
|
||||||
* 1.0/scale, -it.value()->entry().coordinates.y() * 1.0/scale));
|
|
||||||
it.value()->show();
|
|
||||||
}
|
|
||||||
|
|
||||||
for (it = _pois.constBegin(); it != _pois.constEnd(); it++) {
|
|
||||||
for (jt = _pois.constBegin(); jt != _pois.constEnd(); jt++) {
|
|
||||||
if (it != jt && it.value()->isVisible() && jt.value()->isVisible()
|
|
||||||
&& it.value()->collidesWithItem(jt.value()))
|
|
||||||
jt.value()->hide();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
_scale = scale;
|
|
||||||
}
|
|
||||||
|
|
||||||
void Track::loadPOI(const POI &poi)
|
|
||||||
{
|
|
||||||
QHash<Entry, POIItem*>::const_iterator it,jt;
|
|
||||||
|
|
||||||
for (int i = 0; i < _tracks.size(); i++) {
|
|
||||||
QVector<Entry> p = poi.points(_tracks.at(i));
|
|
||||||
|
|
||||||
for (int i = 0; i < p.size(); i++) {
|
|
||||||
if (_pois.contains(p.at(i)))
|
|
||||||
continue;
|
continue;
|
||||||
|
v = ds / dt;
|
||||||
|
} else
|
||||||
|
v = _data.at(i).speed;
|
||||||
|
|
||||||
POIItem *pi = new POIItem(p.at(i));
|
raw.append(QPointF(dist, v));
|
||||||
pi->setPos(p.at(i).coordinates.x() * 1.0/_scale,
|
|
||||||
-p.at(i).coordinates.y() * 1.0/_scale);
|
|
||||||
pi->setZValue(1);
|
|
||||||
_scene->addItem(pi);
|
|
||||||
|
|
||||||
_pois.insert(p.at(i), pi);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
for (it = _pois.constBegin(); it != _pois.constEnd(); it++) {
|
graph = filter(eliminate(raw, WINDOW_SE), WINDOW_SF);
|
||||||
for (jt = _pois.constBegin(); jt != _pois.constEnd(); jt++) {
|
|
||||||
if (it != jt && it.value()->isVisible() && jt.value()->isVisible()
|
|
||||||
&& it.value()->collidesWithItem(jt.value()))
|
|
||||||
jt.value()->hide();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
_scene->setSceneRect(_scene->itemsBoundingRect());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Track::setMap(Map *map)
|
void Track::track(QVector<QPointF> &track) const
|
||||||
{
|
{
|
||||||
_map = map;
|
for (int i = 0; i < _data.size(); i++)
|
||||||
if (_map)
|
track.append(_data.at(i).coordinates);
|
||||||
connect(_map, SIGNAL(loaded()), this, SLOT(redraw()));
|
|
||||||
resetCachedContent();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Track::redraw()
|
qreal Track::distance() const
|
||||||
{
|
{
|
||||||
resetCachedContent();
|
qreal dist = 0;
|
||||||
|
|
||||||
|
for (int i = 1; i < _data.size(); i++)
|
||||||
|
dist += llDistance(_data.at(i).coordinates, _data.at(i-1).coordinates);
|
||||||
|
|
||||||
|
return dist;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Track::wheelEvent(QWheelEvent *event)
|
qreal Track::time() const
|
||||||
{
|
{
|
||||||
QPointF pos = mapToScene(event->pos());
|
if (_data.size() < 2)
|
||||||
qreal scale = _scale;
|
return 0;
|
||||||
|
|
||||||
_zoom = (event->delta() > 0) ?
|
return (_data.at(0).timestamp.msecsTo(_data.at(_data.size() - 1).timestamp)
|
||||||
qMin(_zoom + 1, ZOOM_MAX) : qMax(_zoom - 1, ZOOM_MIN);
|
/ 1000.0);
|
||||||
|
|
||||||
rescale(mapScale());
|
|
||||||
_scene->setSceneRect(_scene->itemsBoundingRect());
|
|
||||||
centerOn(pos * scale/_scale);
|
|
||||||
resetCachedContent();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Track::showMarkers(bool show)
|
QDateTime Track::date() const
|
||||||
{
|
{
|
||||||
for (int i = 0; i < _markers.size(); i++)
|
if (_data.size())
|
||||||
_markers.at(i)->setVisible(show);
|
return _data.at(0).timestamp;
|
||||||
}
|
else
|
||||||
|
return QDateTime();
|
||||||
void Track::setTrackLineWidth(qreal width)
|
|
||||||
{
|
|
||||||
for (int i = 0; i < _trackPaths.size(); i++) {
|
|
||||||
QPen pen(_trackPaths.at(i)->pen());
|
|
||||||
pen.setWidthF(width);
|
|
||||||
_trackPaths.at(i)->setPen(pen);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void Track::plot(QPainter *painter, const QRectF &target)
|
|
||||||
{
|
|
||||||
QRectF orig = sceneRect();
|
|
||||||
QRectF adj;
|
|
||||||
qreal ratio, diff;
|
|
||||||
|
|
||||||
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 {
|
|
||||||
ratio = target.height()/target.width();
|
|
||||||
diff = fabs((orig.width() * ratio) - orig.height());
|
|
||||||
adj = orig.adjusted(0, -diff/2, 0, diff/2);
|
|
||||||
}
|
|
||||||
|
|
||||||
showMarkers(false);
|
|
||||||
setTrackLineWidth(0);
|
|
||||||
_scene->render(painter, target, adj, Qt::KeepAspectRatioByExpanding);
|
|
||||||
setTrackLineWidth(TRACK_WIDTH * _scale);
|
|
||||||
showMarkers(true);
|
|
||||||
}
|
|
||||||
|
|
||||||
enum QPrinter::Orientation Track::orientation() const
|
|
||||||
{
|
|
||||||
return (sceneRect().width() > sceneRect().height())
|
|
||||||
? QPrinter::Landscape : QPrinter::Portrait;
|
|
||||||
}
|
|
||||||
|
|
||||||
void Track::clearPOI()
|
|
||||||
{
|
|
||||||
QHash<Entry, POIItem*>::const_iterator it;
|
|
||||||
|
|
||||||
for (it = _pois.constBegin(); it != _pois.constEnd(); it++) {
|
|
||||||
_scene->removeItem(it.value());
|
|
||||||
delete it.value();
|
|
||||||
}
|
|
||||||
|
|
||||||
_pois.clear();
|
|
||||||
}
|
|
||||||
|
|
||||||
void Track::clear()
|
|
||||||
{
|
|
||||||
_pois.clear();
|
|
||||||
_tracks.clear();
|
|
||||||
_trackPaths.clear();
|
|
||||||
_markers.clear();
|
|
||||||
_scene->clear();
|
|
||||||
_colorShop.reset();
|
|
||||||
|
|
||||||
_maxLen = 0;
|
|
||||||
|
|
||||||
_scene->setSceneRect(0, 0, 0, 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
void Track::movePositionMarker(qreal val)
|
|
||||||
{
|
|
||||||
for (int i = 0; i < _trackPaths.size(); i++) {
|
|
||||||
qreal f = _maxLen / _trackPaths.at(i)->path().length();
|
|
||||||
QPointF pos = _trackPaths.at(i)->path().pointAtPercent(qMin(val * f,
|
|
||||||
1.0));
|
|
||||||
_markers.at(i)->setPos(pos);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void Track::drawBackground(QPainter *painter, const QRectF &rect)
|
|
||||||
{
|
|
||||||
if (_tracks.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));
|
|
||||||
|
|
||||||
QList<Tile> tiles;
|
|
||||||
for (int i = 0; i <= rr.size().width() / TILE_SIZE + 1; i++) {
|
|
||||||
for (int j = 0; j <= rr.size().height() / TILE_SIZE + 1; j++) {
|
|
||||||
tiles.append(Tile(QPoint(tile.x() + i, tile.y() + j), _zoom));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
_map->loadTiles(tiles);
|
|
||||||
|
|
||||||
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);
|
|
||||||
painter->drawPixmap(tp, t.pixmap());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
66
src/track.h
66
src/track.h
@ -1,68 +1,24 @@
|
|||||||
#ifndef TRACK_H
|
#ifndef TRACK_H
|
||||||
#define TRACK_H
|
#define TRACK_H
|
||||||
|
|
||||||
#include <QGraphicsView>
|
|
||||||
#include <QVector>
|
#include <QVector>
|
||||||
#include <QHash>
|
#include <QDateTime>
|
||||||
#include <QList>
|
#include "trackpoint.h"
|
||||||
#include <QPrinter>
|
|
||||||
#include "poi.h"
|
|
||||||
#include "gpx.h"
|
|
||||||
#include "map.h"
|
|
||||||
#include "colorshop.h"
|
|
||||||
|
|
||||||
|
class Track
|
||||||
class POIItem;
|
|
||||||
class MarkerItem;
|
|
||||||
|
|
||||||
class Track : public QGraphicsView
|
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
Track(QWidget *parent = 0);
|
Track(const QVector<Trackpoint> &data) : _data(data) {}
|
||||||
~Track();
|
|
||||||
|
|
||||||
void loadGPX(const GPX &gpx);
|
void elevationGraph(QVector<QPointF> &graph) const;
|
||||||
|
void speedGraph(QVector<QPointF> &graph) const;
|
||||||
void loadPOI(const POI &poi);
|
void track(QVector<QPointF> &track) const;
|
||||||
void clearPOI();
|
qreal distance() const;
|
||||||
void clear();
|
qreal time() const;
|
||||||
|
QDateTime date() const;
|
||||||
void setMap(Map *map);
|
|
||||||
|
|
||||||
void plot(QPainter *painter, const QRectF &target);
|
|
||||||
enum QPrinter::Orientation orientation() const;
|
|
||||||
|
|
||||||
public slots:
|
|
||||||
void movePositionMarker(qreal val);
|
|
||||||
|
|
||||||
private slots:
|
|
||||||
void redraw();
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
qreal trackScale() const;
|
const QVector<Trackpoint> &_data;
|
||||||
qreal mapScale() const;
|
|
||||||
void rescale(qreal scale);
|
|
||||||
|
|
||||||
void showMarkers(bool show);
|
|
||||||
void setTrackLineWidth(qreal width);
|
|
||||||
|
|
||||||
void wheelEvent(QWheelEvent *event);
|
|
||||||
void drawBackground(QPainter *painter, const QRectF &rect);
|
|
||||||
|
|
||||||
QGraphicsScene *_scene;
|
|
||||||
QList<QVector<QPointF> > _tracks;
|
|
||||||
QList<QGraphicsPathItem*> _trackPaths;
|
|
||||||
QList<MarkerItem*> _markers;
|
|
||||||
QHash<Entry, POIItem*> _pois;
|
|
||||||
Map *_map;
|
|
||||||
|
|
||||||
ColorShop _colorShop;
|
|
||||||
qreal _maxLen;
|
|
||||||
|
|
||||||
qreal _scale;
|
|
||||||
int _zoom;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // TRACK_H
|
#endif // TRACK_H
|
||||||
|
19
src/trackpoint.h
Normal file
19
src/trackpoint.h
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
#ifndef TRACKPOINT_H
|
||||||
|
#define TRACKPOINT_H
|
||||||
|
|
||||||
|
#include <QPointF>
|
||||||
|
#include <QDateTime>
|
||||||
|
#include <cmath>
|
||||||
|
|
||||||
|
struct Trackpoint
|
||||||
|
{
|
||||||
|
QPointF coordinates;
|
||||||
|
QDateTime timestamp;
|
||||||
|
qreal elevation;
|
||||||
|
qreal geoidheight;
|
||||||
|
qreal speed;
|
||||||
|
|
||||||
|
Trackpoint() {elevation = NAN; geoidheight = 0; speed = NAN;}
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // TRACKPOINT_H
|
486
src/trackview.cpp
Normal file
486
src/trackview.cpp
Normal file
@ -0,0 +1,486 @@
|
|||||||
|
#include <QGraphicsView>
|
||||||
|
#include <QGraphicsScene>
|
||||||
|
#include <QPainterPath>
|
||||||
|
#include <QWheelEvent>
|
||||||
|
#include "poi.h"
|
||||||
|
#include "gpx.h"
|
||||||
|
#include "map.h"
|
||||||
|
#include "waypointitem.h"
|
||||||
|
#include "markeritem.h"
|
||||||
|
#include "scaleitem.h"
|
||||||
|
#include "ll.h"
|
||||||
|
#include "trackview.h"
|
||||||
|
|
||||||
|
|
||||||
|
#define MARGIN 10.0
|
||||||
|
#define TRACK_WIDTH 3
|
||||||
|
#define SCALE_OFFSET 7
|
||||||
|
|
||||||
|
TrackView::TrackView(QWidget *parent)
|
||||||
|
: QGraphicsView(parent)
|
||||||
|
{
|
||||||
|
_scene = new QGraphicsScene(this);
|
||||||
|
setScene(_scene);
|
||||||
|
setCacheMode(QGraphicsView::CacheBackground);
|
||||||
|
setDragMode(QGraphicsView::ScrollHandDrag);
|
||||||
|
setViewportUpdateMode(QGraphicsView::FullViewportUpdate);
|
||||||
|
setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
|
||||||
|
setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
|
||||||
|
setRenderHints(QPainter::Antialiasing);
|
||||||
|
|
||||||
|
_mapScale = new ScaleItem();
|
||||||
|
_mapScale->setZValue(2.0);
|
||||||
|
|
||||||
|
_zoom = ZOOM_MAX;
|
||||||
|
_scale = mapScale(_zoom);
|
||||||
|
_map = 0;
|
||||||
|
_maxLen = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
TrackView::~TrackView()
|
||||||
|
{
|
||||||
|
delete _scene;
|
||||||
|
}
|
||||||
|
|
||||||
|
void TrackView::addTrack(const QVector<QPointF> &track)
|
||||||
|
{
|
||||||
|
QPainterPath path;
|
||||||
|
QGraphicsPathItem *pi;
|
||||||
|
MarkerItem *mi;
|
||||||
|
|
||||||
|
|
||||||
|
if (track.size() < 2)
|
||||||
|
return;
|
||||||
|
|
||||||
|
_tracks.append(track);
|
||||||
|
|
||||||
|
const QPointF &p = track.at(0);
|
||||||
|
path.moveTo(ll2mercator(QPointF(p.x(), -p.y())));
|
||||||
|
for (int i = 1; i < track.size(); i++) {
|
||||||
|
const QPointF &p = track.at(i);
|
||||||
|
path.lineTo(ll2mercator(QPointF(p.x(), -p.y())));
|
||||||
|
}
|
||||||
|
|
||||||
|
_maxLen = qMax(path.length(), _maxLen);
|
||||||
|
|
||||||
|
|
||||||
|
pi = new QGraphicsPathItem(path);
|
||||||
|
_paths.append(pi);
|
||||||
|
_zoom = qMin(_zoom, scale2zoom(trackScale()));
|
||||||
|
_scale = mapScale(_zoom);
|
||||||
|
QBrush brush(_palette.color(), Qt::SolidPattern);
|
||||||
|
QPen pen(brush, TRACK_WIDTH * _scale);
|
||||||
|
pi->setPen(pen);
|
||||||
|
pi->setScale(1.0/_scale);
|
||||||
|
_scene->addItem(pi);
|
||||||
|
|
||||||
|
mi = new MarkerItem(pi);
|
||||||
|
_markers.append(mi);
|
||||||
|
mi->setPos(pi->path().pointAtPercent(0));
|
||||||
|
mi->setScale(_scale);
|
||||||
|
}
|
||||||
|
|
||||||
|
void TrackView::addWaypoints(const QList<Waypoint> &waypoints)
|
||||||
|
{
|
||||||
|
for (int i = 0; i < waypoints.count(); i++) {
|
||||||
|
const Waypoint &w = waypoints.at(i);
|
||||||
|
WaypointItem *wi = new WaypointItem(
|
||||||
|
Waypoint(ll2mercator(QPointF(w.coordinates().x(),
|
||||||
|
-w.coordinates().y())), w.description()));
|
||||||
|
|
||||||
|
wi->setPos(wi->entry().coordinates() * 1.0/_scale);
|
||||||
|
wi->setZValue(1);
|
||||||
|
_scene->addItem(wi);
|
||||||
|
|
||||||
|
_locations.append(wi);
|
||||||
|
_waypoints.append(w.coordinates());
|
||||||
|
}
|
||||||
|
|
||||||
|
_zoom = qMin(_zoom, scale2zoom(waypointScale()));
|
||||||
|
_scale = mapScale(_zoom);
|
||||||
|
}
|
||||||
|
|
||||||
|
void TrackView::loadGPX(const GPX &gpx)
|
||||||
|
{
|
||||||
|
int zoom = _zoom;
|
||||||
|
|
||||||
|
for (int i = 0; i < gpx.trackCount(); i++) {
|
||||||
|
QVector<QPointF> track;
|
||||||
|
gpx.track(i).track(track);
|
||||||
|
addTrack(track);
|
||||||
|
}
|
||||||
|
|
||||||
|
addWaypoints(gpx.waypoints());
|
||||||
|
|
||||||
|
if (_paths.empty() && _locations.empty())
|
||||||
|
return;
|
||||||
|
|
||||||
|
if ((_paths.size() > 1 && _zoom < zoom)
|
||||||
|
|| (_locations.size() && _zoom < zoom))
|
||||||
|
rescale(_scale);
|
||||||
|
|
||||||
|
QRectF br = trackBoundingRect() | waypointBoundingRect();
|
||||||
|
QRectF ba = br.adjusted(-TILE_SIZE, -TILE_SIZE, TILE_SIZE, TILE_SIZE);
|
||||||
|
_scene->setSceneRect(ba);
|
||||||
|
centerOn(ba.center());
|
||||||
|
|
||||||
|
_mapScale->setLatitude(-(br.center().ry() * _scale));
|
||||||
|
_mapScale->setZoom(_zoom);
|
||||||
|
if (_mapScale->scene() != _scene)
|
||||||
|
_scene->addItem(_mapScale);
|
||||||
|
}
|
||||||
|
|
||||||
|
QRectF TrackView::trackBoundingRect() const
|
||||||
|
{
|
||||||
|
if (_paths.empty())
|
||||||
|
return QRectF();
|
||||||
|
|
||||||
|
QRectF br = _paths.at(0)->sceneBoundingRect();
|
||||||
|
for (int i = 1; i < _paths.size(); i++)
|
||||||
|
br |= _paths.at(i)->sceneBoundingRect();
|
||||||
|
|
||||||
|
return br;
|
||||||
|
}
|
||||||
|
|
||||||
|
QRectF TrackView::waypointBoundingRect() const
|
||||||
|
{
|
||||||
|
qreal bottom, top, left, right;
|
||||||
|
|
||||||
|
if (_locations.empty())
|
||||||
|
return QRectF();
|
||||||
|
|
||||||
|
const QPointF &p = _locations.at(0)->pos();
|
||||||
|
bottom = p.y();
|
||||||
|
top = p.y();
|
||||||
|
left = p.x();
|
||||||
|
right = p.x();
|
||||||
|
|
||||||
|
for (int i = 1; i < _locations.size(); i++) {
|
||||||
|
const QPointF &p = _locations.at(i)->pos();
|
||||||
|
bottom = qMax(bottom, p.y());
|
||||||
|
top = qMin(top, p.y());
|
||||||
|
right = qMax(right, p.x());
|
||||||
|
left = qMin(left, p.x());
|
||||||
|
}
|
||||||
|
|
||||||
|
return QRectF(QPointF(left, top), QPointF(right, bottom));
|
||||||
|
}
|
||||||
|
|
||||||
|
qreal TrackView::trackScale() const
|
||||||
|
{
|
||||||
|
if (_paths.empty())
|
||||||
|
return mapScale(ZOOM_MAX);
|
||||||
|
|
||||||
|
QRectF br = _paths.at(0)->path().boundingRect();
|
||||||
|
|
||||||
|
for (int i = 1; i < _paths.size(); i++)
|
||||||
|
br |= _paths.at(i)->path().boundingRect();
|
||||||
|
|
||||||
|
QPointF sc(br.width() / (viewport()->width() - MARGIN/2),
|
||||||
|
br.height() / (viewport()->height() - MARGIN/2));
|
||||||
|
|
||||||
|
return qMax(sc.x(), sc.y());
|
||||||
|
}
|
||||||
|
|
||||||
|
qreal TrackView::waypointScale() const
|
||||||
|
{
|
||||||
|
qreal bottom, top, left, right;
|
||||||
|
|
||||||
|
if (_locations.size() < 2)
|
||||||
|
return mapScale(ZOOM_MAX);
|
||||||
|
|
||||||
|
const QPointF &p = _locations.at(0)->entry().coordinates();
|
||||||
|
bottom = p.y();
|
||||||
|
top = p.y();
|
||||||
|
left = p.x();
|
||||||
|
right = p.x();
|
||||||
|
|
||||||
|
for (int i = 1; i < _locations.size(); i++) {
|
||||||
|
const QPointF &p = _locations.at(i)->entry().coordinates();
|
||||||
|
bottom = qMax(bottom, p.y());
|
||||||
|
top = qMin(top, p.y());
|
||||||
|
right = qMax(right, p.x());
|
||||||
|
left = qMin(left, p.x());
|
||||||
|
}
|
||||||
|
|
||||||
|
QRectF br(QPointF(left, top), QPointF(right, bottom));
|
||||||
|
QPointF sc(br.width() / (viewport()->width() - MARGIN/2),
|
||||||
|
br.height() / (viewport()->height() - MARGIN/2));
|
||||||
|
|
||||||
|
return qMax(sc.x(), sc.y());
|
||||||
|
}
|
||||||
|
|
||||||
|
qreal TrackView::mapScale(int zoom) const
|
||||||
|
{
|
||||||
|
return ((360.0/(qreal)(1<<zoom))/(qreal)TILE_SIZE);
|
||||||
|
}
|
||||||
|
|
||||||
|
void TrackView::rescale(qreal scale)
|
||||||
|
{
|
||||||
|
for (int i = 0; i < _paths.size(); i++) {
|
||||||
|
_markers.at(i)->setScale(scale);
|
||||||
|
_paths.at(i)->setScale(1.0/scale);
|
||||||
|
|
||||||
|
QPen pen(_paths.at(i)->pen());
|
||||||
|
pen.setWidthF(TRACK_WIDTH * scale);
|
||||||
|
_paths.at(i)->setPen(pen);
|
||||||
|
}
|
||||||
|
|
||||||
|
for (int i = 0; i < _locations.size(); i++)
|
||||||
|
_locations.at(i)->setPos(_locations.at(i)->entry().coordinates()
|
||||||
|
* 1.0/scale);
|
||||||
|
|
||||||
|
QHash<Waypoint, WaypointItem*>::const_iterator it, jt;
|
||||||
|
for (it = _pois.constBegin(); it != _pois.constEnd(); it++) {
|
||||||
|
it.value()->setPos(it.value()->entry().coordinates() * 1.0/scale);
|
||||||
|
it.value()->show();
|
||||||
|
}
|
||||||
|
|
||||||
|
for (it = _pois.constBegin(); it != _pois.constEnd(); it++) {
|
||||||
|
for (jt = _pois.constBegin(); jt != _pois.constEnd(); jt++) {
|
||||||
|
if (it != jt && it.value()->isVisible() && jt.value()->isVisible()
|
||||||
|
&& it.value()->collidesWithItem(jt.value()))
|
||||||
|
jt.value()->hide();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
_scale = scale;
|
||||||
|
}
|
||||||
|
|
||||||
|
void TrackView::addPOI(const QVector<Waypoint> &waypoints)
|
||||||
|
{
|
||||||
|
for (int i = 0; i < waypoints.size(); i++) {
|
||||||
|
const Waypoint &w = waypoints.at(i);
|
||||||
|
|
||||||
|
if (_pois.contains(w))
|
||||||
|
continue;
|
||||||
|
|
||||||
|
WaypointItem *pi = new WaypointItem(
|
||||||
|
Waypoint(ll2mercator(QPointF(w.coordinates().x(),
|
||||||
|
-w.coordinates().y())), w.description()));
|
||||||
|
|
||||||
|
pi->setPos(pi->entry().coordinates() * 1.0/_scale);
|
||||||
|
pi->setZValue(1);
|
||||||
|
_scene->addItem(pi);
|
||||||
|
|
||||||
|
_pois.insert(w, pi);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void TrackView::loadPOI(const POI &poi)
|
||||||
|
{
|
||||||
|
QHash<Waypoint, WaypointItem*>::const_iterator it,jt;
|
||||||
|
|
||||||
|
if (!_tracks.size() && !_waypoints.size())
|
||||||
|
return;
|
||||||
|
|
||||||
|
for (int i = 0; i < _tracks.size(); i++)
|
||||||
|
addPOI(poi.points(_tracks.at(i)));
|
||||||
|
addPOI(poi.points(_waypoints));
|
||||||
|
|
||||||
|
for (it = _pois.constBegin(); it != _pois.constEnd(); it++) {
|
||||||
|
for (jt = _pois.constBegin(); jt != _pois.constEnd(); jt++) {
|
||||||
|
if (it != jt && it.value()->isVisible() && jt.value()->isVisible()
|
||||||
|
&& it.value()->collidesWithItem(jt.value()))
|
||||||
|
jt.value()->hide();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void TrackView::setMap(Map *map)
|
||||||
|
{
|
||||||
|
_map = map;
|
||||||
|
if (_map)
|
||||||
|
connect(_map, SIGNAL(loaded()), this, SLOT(redraw()));
|
||||||
|
resetCachedContent();
|
||||||
|
}
|
||||||
|
|
||||||
|
void TrackView::setUnits(enum Units units)
|
||||||
|
{
|
||||||
|
_mapScale->setUnits(units);
|
||||||
|
}
|
||||||
|
|
||||||
|
void TrackView::redraw()
|
||||||
|
{
|
||||||
|
resetCachedContent();
|
||||||
|
}
|
||||||
|
|
||||||
|
void TrackView::wheelEvent(QWheelEvent *event)
|
||||||
|
{
|
||||||
|
if (_paths.isEmpty() && _locations.isEmpty())
|
||||||
|
return;
|
||||||
|
|
||||||
|
QPointF pos = mapToScene(event->pos());
|
||||||
|
qreal scale = _scale;
|
||||||
|
|
||||||
|
_zoom = (event->delta() > 0) ?
|
||||||
|
qMin(_zoom + 1, ZOOM_MAX) : qMax(_zoom - 1, ZOOM_MIN);
|
||||||
|
|
||||||
|
rescale(mapScale(_zoom));
|
||||||
|
QRectF br = trackBoundingRect() | waypointBoundingRect();
|
||||||
|
QRectF ba = br.adjusted(-TILE_SIZE, -TILE_SIZE, TILE_SIZE, TILE_SIZE);
|
||||||
|
_scene->setSceneRect(ba);
|
||||||
|
|
||||||
|
if (br.width() < viewport()->size().width()
|
||||||
|
&& br.height() < viewport()->size().height())
|
||||||
|
centerOn(br.center());
|
||||||
|
else
|
||||||
|
centerOn(pos * scale/_scale);
|
||||||
|
|
||||||
|
_mapScale->setZoom(_zoom);
|
||||||
|
|
||||||
|
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;
|
||||||
|
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 {
|
||||||
|
ratio = target.height()/target.width();
|
||||||
|
diff = fabs((orig.width() * ratio) - orig.height());
|
||||||
|
adj = orig.adjusted(0, -diff/2, 0, diff/2);
|
||||||
|
}
|
||||||
|
|
||||||
|
_mapScale->setPos(adj.bottomRight()
|
||||||
|
+ QPoint(-_mapScale->boundingRect().width(),
|
||||||
|
-_mapScale->boundingRect().height()));
|
||||||
|
|
||||||
|
setTrackLineWidth(0);
|
||||||
|
_scene->render(painter, target, adj);
|
||||||
|
setTrackLineWidth(TRACK_WIDTH * _scale);
|
||||||
|
}
|
||||||
|
|
||||||
|
enum QPrinter::Orientation TrackView::orientation() const
|
||||||
|
{
|
||||||
|
return (sceneRect().width() > sceneRect().height())
|
||||||
|
? QPrinter::Landscape : QPrinter::Portrait;
|
||||||
|
}
|
||||||
|
|
||||||
|
void TrackView::clearPOI()
|
||||||
|
{
|
||||||
|
QHash<Waypoint, WaypointItem*>::const_iterator it;
|
||||||
|
|
||||||
|
for (it = _pois.constBegin(); it != _pois.constEnd(); it++) {
|
||||||
|
_scene->removeItem(it.value());
|
||||||
|
delete it.value();
|
||||||
|
}
|
||||||
|
|
||||||
|
_pois.clear();
|
||||||
|
}
|
||||||
|
|
||||||
|
void TrackView::clear()
|
||||||
|
{
|
||||||
|
if (_mapScale->scene() == _scene)
|
||||||
|
_scene->removeItem(_mapScale);
|
||||||
|
|
||||||
|
_pois.clear();
|
||||||
|
_paths.clear();
|
||||||
|
_locations.clear();
|
||||||
|
_markers.clear();
|
||||||
|
_scene->clear();
|
||||||
|
_palette.reset();
|
||||||
|
|
||||||
|
_tracks.clear();
|
||||||
|
_waypoints.clear();
|
||||||
|
|
||||||
|
_maxLen = 0;
|
||||||
|
_zoom = ZOOM_MAX;
|
||||||
|
_scale = mapScale(_zoom);
|
||||||
|
|
||||||
|
_scene->setSceneRect(QRectF());
|
||||||
|
}
|
||||||
|
|
||||||
|
void TrackView::movePositionMarker(qreal val)
|
||||||
|
{
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void TrackView::drawBackground(QPainter *painter, const QRectF &rect)
|
||||||
|
{
|
||||||
|
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));
|
||||||
|
|
||||||
|
QList<Tile> tiles;
|
||||||
|
for (int i = 0; i <= rr.size().width() / TILE_SIZE + 1; i++) {
|
||||||
|
for (int j = 0; j <= rr.size().height() / TILE_SIZE + 1; j++) {
|
||||||
|
tiles.append(Tile(QPoint(tile.x() + i, tile.y() + j), _zoom));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
_map->loadTiles(tiles);
|
||||||
|
|
||||||
|
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);
|
||||||
|
painter->drawPixmap(tp, t.pixmap());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void TrackView::resizeEvent(QResizeEvent *e)
|
||||||
|
{
|
||||||
|
if (_paths.isEmpty() && _locations.isEmpty())
|
||||||
|
return;
|
||||||
|
|
||||||
|
QRectF br = trackBoundingRect() | waypointBoundingRect();
|
||||||
|
QRectF ba = br.adjusted(-TILE_SIZE, -TILE_SIZE, TILE_SIZE, TILE_SIZE);
|
||||||
|
|
||||||
|
if (ba.width() < e->size().width()) {
|
||||||
|
qreal diff = e->size().width() - ba.width();
|
||||||
|
ba.adjust(-diff/2, 0, diff/2, 0);
|
||||||
|
}
|
||||||
|
if (ba.height() < e->size().height()) {
|
||||||
|
qreal diff = e->size().height() - ba.height();
|
||||||
|
ba.adjust(0, -diff/2, 0, diff/2);
|
||||||
|
}
|
||||||
|
|
||||||
|
_scene->setSceneRect(ba);
|
||||||
|
|
||||||
|
centerOn(br.center());
|
||||||
|
resetCachedContent();
|
||||||
|
}
|
||||||
|
|
||||||
|
void TrackView::paintEvent(QPaintEvent *e)
|
||||||
|
{
|
||||||
|
QPointF scenePos = mapToScene(rect().bottomLeft() + QPoint(SCALE_OFFSET,
|
||||||
|
-(SCALE_OFFSET + _mapScale->boundingRect().height())));
|
||||||
|
if (_mapScale->pos() != scenePos)
|
||||||
|
_mapScale->setPos(scenePos);
|
||||||
|
|
||||||
|
QGraphicsView::paintEvent(e);
|
||||||
|
}
|
84
src/trackview.h
Normal file
84
src/trackview.h
Normal file
@ -0,0 +1,84 @@
|
|||||||
|
#ifndef TRACKVIEW_H
|
||||||
|
#define TRACKVIEW_H
|
||||||
|
|
||||||
|
#include <QGraphicsView>
|
||||||
|
#include <QVector>
|
||||||
|
#include <QHash>
|
||||||
|
#include <QList>
|
||||||
|
#include <QPrinter>
|
||||||
|
#include "units.h"
|
||||||
|
#include "palette.h"
|
||||||
|
#include "waypoint.h"
|
||||||
|
|
||||||
|
class GPX;
|
||||||
|
class POI;
|
||||||
|
class Map;
|
||||||
|
class WaypointItem;
|
||||||
|
class MarkerItem;
|
||||||
|
class ScaleItem;
|
||||||
|
|
||||||
|
class TrackView : public QGraphicsView
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
|
||||||
|
public:
|
||||||
|
TrackView(QWidget *parent = 0);
|
||||||
|
~TrackView();
|
||||||
|
|
||||||
|
void loadGPX(const GPX &gpx);
|
||||||
|
|
||||||
|
void loadPOI(const POI &poi);
|
||||||
|
void clearPOI();
|
||||||
|
void clear();
|
||||||
|
|
||||||
|
void setMap(Map *map);
|
||||||
|
void setUnits(enum Units units);
|
||||||
|
|
||||||
|
void plot(QPainter *painter, const QRectF &target);
|
||||||
|
enum QPrinter::Orientation orientation() const;
|
||||||
|
|
||||||
|
public slots:
|
||||||
|
void movePositionMarker(qreal val);
|
||||||
|
|
||||||
|
private slots:
|
||||||
|
void redraw();
|
||||||
|
|
||||||
|
private:
|
||||||
|
void addTrack(const QVector<QPointF> &track);
|
||||||
|
void addWaypoints(const QList<Waypoint> &waypoints);
|
||||||
|
void addPOI(const QVector<Waypoint> &waypoints);
|
||||||
|
|
||||||
|
QRectF trackBoundingRect() const;
|
||||||
|
QRectF waypointBoundingRect() const;
|
||||||
|
qreal trackScale() const;
|
||||||
|
qreal waypointScale() const;
|
||||||
|
qreal mapScale(int zoom) const;
|
||||||
|
void rescale(qreal scale);
|
||||||
|
|
||||||
|
void showMarkers(bool show);
|
||||||
|
void setTrackLineWidth(qreal width);
|
||||||
|
|
||||||
|
void wheelEvent(QWheelEvent *event);
|
||||||
|
void drawBackground(QPainter *painter, const QRectF &rect);
|
||||||
|
void resizeEvent(QResizeEvent *e);
|
||||||
|
void paintEvent(QPaintEvent *e);
|
||||||
|
|
||||||
|
QGraphicsScene *_scene;
|
||||||
|
QList<QGraphicsPathItem*> _paths;
|
||||||
|
QList<MarkerItem*> _markers;
|
||||||
|
QList<WaypointItem*> _locations;
|
||||||
|
QHash<Waypoint, WaypointItem*> _pois;
|
||||||
|
QList<QVector<QPointF> > _tracks;
|
||||||
|
QVector<QPointF> _waypoints;
|
||||||
|
|
||||||
|
Map *_map;
|
||||||
|
ScaleItem *_mapScale;
|
||||||
|
|
||||||
|
Palette _palette;
|
||||||
|
qreal _maxLen;
|
||||||
|
|
||||||
|
qreal _scale;
|
||||||
|
int _zoom;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // TRACKVIEW_H
|
25
src/units.h
Normal file
25
src/units.h
Normal file
@ -0,0 +1,25 @@
|
|||||||
|
#ifndef UNITS_H
|
||||||
|
#define UNITS_H
|
||||||
|
|
||||||
|
enum Units {
|
||||||
|
Metric,
|
||||||
|
Imperial
|
||||||
|
};
|
||||||
|
|
||||||
|
#define M2KM 0.001000000000 // m -> km
|
||||||
|
#define M2MI 0.000621371192 // m -> mi
|
||||||
|
#define M2FT 3.280839900000 // m -> ft
|
||||||
|
#define MS2KMH 3.600000000000 // m/s -> km/h
|
||||||
|
#define MS2MIH 2.236936290000 // m/s -> mi/h
|
||||||
|
#define FT2MI 0.000189393939 // ft -> mi
|
||||||
|
|
||||||
|
#define MIINFT 5280 // 1 mi in ft
|
||||||
|
#define KMINM 1000 // 1 km in m
|
||||||
|
|
||||||
|
#ifdef Q_OS_WIN32
|
||||||
|
#define UNIT_SPACE " "
|
||||||
|
#else // Q_OS_WIN32
|
||||||
|
#define UNIT_SPACE QString::fromUtf8("\xE2\x80\x89")
|
||||||
|
#endif // Q_OS_WIN32
|
||||||
|
|
||||||
|
#endif // UNITS_H
|
36
src/waypoint.h
Normal file
36
src/waypoint.h
Normal file
@ -0,0 +1,36 @@
|
|||||||
|
#ifndef WAYPOINT_H
|
||||||
|
#define WAYPOINT_H
|
||||||
|
|
||||||
|
#include <QPointF>
|
||||||
|
#include <QString>
|
||||||
|
#include <QHash>
|
||||||
|
|
||||||
|
class Waypoint
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
Waypoint() {}
|
||||||
|
Waypoint(const QPointF &coordinates, const QString &description)
|
||||||
|
: _coordinates(coordinates), _description(description) {}
|
||||||
|
|
||||||
|
const QPointF &coordinates() const {return _coordinates;}
|
||||||
|
const QString &description() const {return _description;}
|
||||||
|
void setCoordinates(const QPointF &coordinates)
|
||||||
|
{_coordinates = coordinates;}
|
||||||
|
void setDescription(const QString &description)
|
||||||
|
{_description = description;}
|
||||||
|
|
||||||
|
bool operator==(const Waypoint &other) const
|
||||||
|
{return this->_description == other._description
|
||||||
|
&& this->_coordinates == other._coordinates;}
|
||||||
|
|
||||||
|
private:
|
||||||
|
QPointF _coordinates;
|
||||||
|
QString _description;
|
||||||
|
};
|
||||||
|
|
||||||
|
inline uint qHash(const Waypoint &key)
|
||||||
|
{
|
||||||
|
return ::qHash(key.description());
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif // WAYPOINT_H
|
49
src/waypointitem.cpp
Normal file
49
src/waypointitem.cpp
Normal file
@ -0,0 +1,49 @@
|
|||||||
|
#include <QPainter>
|
||||||
|
#include "config.h"
|
||||||
|
#include "waypointitem.h"
|
||||||
|
|
||||||
|
|
||||||
|
#define POINT_SIZE 8
|
||||||
|
|
||||||
|
WaypointItem::WaypointItem(const Waypoint &entry, QGraphicsItem *parent)
|
||||||
|
: QGraphicsItem(parent)
|
||||||
|
{
|
||||||
|
_entry = entry;
|
||||||
|
updateBoundingRect();
|
||||||
|
}
|
||||||
|
|
||||||
|
void WaypointItem::updateBoundingRect()
|
||||||
|
{
|
||||||
|
QFont font;
|
||||||
|
font.setPixelSize(FONT_SIZE);
|
||||||
|
font.setFamily(FONT_FAMILY);
|
||||||
|
QFontMetrics fm(font);
|
||||||
|
QRect ts = fm.tightBoundingRect(_entry.description());
|
||||||
|
|
||||||
|
_boundingRect = QRectF(-POINT_SIZE/2, -POINT_SIZE/2, ts.width()
|
||||||
|
+ POINT_SIZE, ts.height() + fm.descent() + POINT_SIZE);
|
||||||
|
}
|
||||||
|
|
||||||
|
void WaypointItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *option,
|
||||||
|
QWidget *widget)
|
||||||
|
{
|
||||||
|
Q_UNUSED(option);
|
||||||
|
Q_UNUSED(widget);
|
||||||
|
QFont font;
|
||||||
|
font.setPixelSize(FONT_SIZE);
|
||||||
|
font.setFamily(FONT_FAMILY);
|
||||||
|
QFontMetrics fm(font);
|
||||||
|
QRect ts = fm.tightBoundingRect(_entry.description());
|
||||||
|
|
||||||
|
painter->setFont(font);
|
||||||
|
painter->drawText(POINT_SIZE/2 - qMax(ts.x(), 0), POINT_SIZE/2 + ts.height(),
|
||||||
|
_entry.description());
|
||||||
|
painter->setBrush(Qt::SolidPattern);
|
||||||
|
painter->drawEllipse(-POINT_SIZE/2, -POINT_SIZE/2, POINT_SIZE, POINT_SIZE);
|
||||||
|
|
||||||
|
/*
|
||||||
|
painter->setPen(Qt::red);
|
||||||
|
painter->setBrush(Qt::NoBrush);
|
||||||
|
painter->drawRect(boundingRect());
|
||||||
|
*/
|
||||||
|
}
|
24
src/waypointitem.h
Normal file
24
src/waypointitem.h
Normal file
@ -0,0 +1,24 @@
|
|||||||
|
#ifndef WAYPOINTITEM_H
|
||||||
|
#define WAYPOINTITEM_H
|
||||||
|
|
||||||
|
#include <QGraphicsItem>
|
||||||
|
#include "waypoint.h"
|
||||||
|
|
||||||
|
class WaypointItem : public QGraphicsItem
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
WaypointItem(const Waypoint &entry, QGraphicsItem *parent = 0);
|
||||||
|
const Waypoint &entry() const {return _entry;}
|
||||||
|
|
||||||
|
QRectF boundingRect() const {return _boundingRect;}
|
||||||
|
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option,
|
||||||
|
QWidget *widget);
|
||||||
|
|
||||||
|
private:
|
||||||
|
void updateBoundingRect();
|
||||||
|
|
||||||
|
Waypoint _entry;
|
||||||
|
QRectF _boundingRect;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // WAYPOINTITEM_H
|
Reference in New Issue
Block a user