mirror of
https://github.com/tumic0/GPXSee.git
synced 2025-07-01 05:19:15 +02:00
Compare commits
115 Commits
Author | SHA1 | Date | |
---|---|---|---|
0ce2f02178 | |||
1289762365 | |||
f0c3f9b8c8 | |||
31f6eeac26 | |||
40803d68c1 | |||
35dea229b4 | |||
330b6547c4 | |||
498d33b77d | |||
3592d9e68f | |||
7d38b55f60 | |||
82df1bec0e | |||
82cbbbb52a | |||
b8e404b789 | |||
2ad94947d7 | |||
b713da0012 | |||
daf4ef894c | |||
eae8e23c6c | |||
b9f7af33d7 | |||
f334901db3 | |||
ffcba53b91 | |||
f326c7e002 | |||
15d4bd05f9 | |||
43bc7dd682 | |||
a8cc02c1f9 | |||
511deada2e | |||
36937d8f2d | |||
969d87ec51 | |||
07255aa8ae | |||
e73f9448e9 | |||
ee9a8df51f | |||
dcdd250858 | |||
6f73740da6 | |||
6518fe3278 | |||
97e2215f0b | |||
21e7c00f66 | |||
5daacc0a22 | |||
1323f6ead8 | |||
798f63aaff | |||
b0abc976a5 | |||
4c61e208ed | |||
c997694e10 | |||
a8d671556e | |||
2e4aeb57a8 | |||
e186a33340 | |||
1b5bdc0f07 | |||
5feec6ac0c | |||
5997ba21f2 | |||
37d9bf1b9b | |||
2bf93f891a | |||
11a9d75d8f | |||
23576cd52c | |||
47bcd0cfaf | |||
043d1f49a6 | |||
339144f7f8 | |||
27ff3a9ba8 | |||
8f4d31ac24 | |||
34fcbfb60f | |||
803c4aecce | |||
f247c2fa22 | |||
9fa031ca4d | |||
d3908f1561 | |||
f41b13a5a2 | |||
284f7d0a36 | |||
f469b4f600 | |||
eec797125b | |||
9dce08bce4 | |||
06248457a0 | |||
c9b5e0f2cb | |||
b7f3a64577 | |||
e05069d653 | |||
1928b579ab | |||
501431207f | |||
0d41341086 | |||
13f383ab7a | |||
5253698602 | |||
6bcb6ceb8d | |||
9da82a978c | |||
64a343dd2e | |||
ac93ccba29 | |||
7cd005873d | |||
9c16c3498c | |||
a2eaacc017 | |||
58bed99d14 | |||
de71aa0d0c | |||
14290bf1f0 | |||
e0fd77bbfd | |||
b1b8d68610 | |||
a0b64b4227 | |||
93670d3026 | |||
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 |
66
Info.plist
Normal file
66
Info.plist
Normal file
@ -0,0 +1,66 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||||
<plist version="1.0">
|
||||
<dict>
|
||||
<key>NSPrincipalClass</key>
|
||||
<string>NSApplication</string>
|
||||
<key>CFBundleIconFile</key>
|
||||
<string>@ICON@</string>
|
||||
<key>CFBundlePackageType</key>
|
||||
<string>APPL</string>
|
||||
<key>CFBundleShortVersionString</key>
|
||||
<string>@SHORT_VERSION@</string>
|
||||
<key>CFBundleSignature</key>
|
||||
<string>????</string>
|
||||
<key>CFBundleExecutable</key>
|
||||
<string>@EXECUTABLE@</string>
|
||||
<key>CFBundleIdentifier</key>
|
||||
<string>cz.wz.tumic.GPXSee</string>
|
||||
|
||||
<key>CFBundleDocumentTypes</key>
|
||||
<array>
|
||||
<dict>
|
||||
<key>CFBundleTypeExtensions</key>
|
||||
<array>
|
||||
<string>gpx</string>
|
||||
</array>
|
||||
<key>CFBundleTypeMIMETypes</key>
|
||||
<array>
|
||||
<string>application/gpx+xml</string>
|
||||
</array>
|
||||
<key>CFBundleTypeIconFile</key>
|
||||
<string>gpx.icns</string>
|
||||
<key>CFBundleTypeName</key>
|
||||
<string>GPS Exchange Format</string>
|
||||
<key>CFBundleTypeRole</key>
|
||||
<string>Viewer</string>
|
||||
</dict>
|
||||
</array>
|
||||
|
||||
<key>UTImportedTypeDeclarations</key>
|
||||
<array>
|
||||
<dict>
|
||||
<key>UTTypeIdentifier</key>
|
||||
<string>com.topografix.gpx</string>
|
||||
<key>UTTypeReferenceURL</key>
|
||||
<string>http://www.topografix.com/GPX/1/1</string>
|
||||
<key>UTTypeDescription</key>
|
||||
<string>GPS Exchange Format</string>
|
||||
<key>UTTypeConformsTo</key>
|
||||
<array>
|
||||
<string>public.xml</string>
|
||||
</array>
|
||||
<key>UTTypeTagSpecification</key>
|
||||
<dict>
|
||||
<key>public.filename-extension</key>
|
||||
<array>
|
||||
<string>gpx</string>
|
||||
</array>
|
||||
<key>public.mime-type</key>
|
||||
<string>application/gpx+xml</string>
|
||||
</dict>
|
||||
</dict>
|
||||
</array>
|
||||
|
||||
</dict>
|
||||
</plist>
|
10
README.md
10
README.md
@ -2,12 +2,15 @@
|
||||
GPX viewer and analyzer.
|
||||
|
||||
* User-definable map sources.
|
||||
* Track and elevation/speed graphs.
|
||||
* Track and elevation/speed/heart rate graphs.
|
||||
* Support for multiple tracks in one view.
|
||||
* Support for POI files (Garmin CSV format).
|
||||
* Support for POI files.
|
||||
* Export to PDF.
|
||||
* Full-screen mode
|
||||
* Native GUI for Windows, Mac OS X and Linux.
|
||||
|
||||

|
||||
|
||||
## Build
|
||||
### Linux/OS X
|
||||
```shell
|
||||
@ -23,7 +26,8 @@ nmake release
|
||||
```
|
||||
|
||||
## 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
|
||||
GPXSee homepage: http://tumic.wz.cz/gpxsee
|
||||
|
6
build/env.bat
Normal file
6
build/env.bat
Normal file
@ -0,0 +1,6 @@
|
||||
CALL "C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\vcvarsall.bat"
|
||||
set PATH=C:\qt\qtbase\bin;%PATH%
|
||||
set PATH=C:\Program Files\Microsoft SDKs\Windows\v7.1\Bin;%PATH%
|
||||
set INCLUDE=C:\Program Files\Microsoft SDKs\Windows\v7.1\Include;%INCLUDE%
|
||||
set LIB=C:\Program Files\Microsoft SDKs\Windows\v7.1\Lib;%LIB%
|
||||
set CL=/D_USING_V110_SDK71_
|
6
build/env64.bat
Normal file
6
build/env64.bat
Normal file
@ -0,0 +1,6 @@
|
||||
CALL "C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\vcvarsall.bat" amd64
|
||||
set PATH=C:\qt64\qtbase\bin;%PATH%
|
||||
set PATH=C:\Program Files\Microsoft SDKs\Windows\v7.1\Bin;%PATH%
|
||||
set INCLUDE=C:\Program Files\Microsoft SDKs\Windows\v7.1\Include;%INCLUDE%
|
||||
set LIB=C:\Program Files\Microsoft SDKs\Windows\v7.1\Lib\x64;%LIB%
|
||||
set CL=/D_USING_V110_SDK71_
|
46
gpxsee.pro
46
gpxsee.pro
@ -1,4 +1,5 @@
|
||||
TARGET = GPXSee
|
||||
VERSION = 2.16
|
||||
QT += core \
|
||||
gui \
|
||||
network
|
||||
@ -13,8 +14,6 @@ HEADERS += src/config.h \
|
||||
src/rtree.h \
|
||||
src/ll.h \
|
||||
src/axisitem.h \
|
||||
src/poiitem.h \
|
||||
src/colorshop.h \
|
||||
src/keys.h \
|
||||
src/slideritem.h \
|
||||
src/markeritem.h \
|
||||
@ -33,7 +32,19 @@ HEADERS += src/config.h \
|
||||
src/trackview.h \
|
||||
src/track.h \
|
||||
src/graphview.h \
|
||||
src/trackpoint.h
|
||||
src/trackpoint.h \
|
||||
src/waypointitem.h \
|
||||
src/palette.h \
|
||||
src/heartrategraph.h \
|
||||
src/range.h \
|
||||
src/cpuarch.h \
|
||||
src/settings.h \
|
||||
src/app.h \
|
||||
src/trackinfo.h \
|
||||
src/exportdialog.h \
|
||||
src/fileselectwidget.h \
|
||||
src/margins.h \
|
||||
src/temperaturegraph.h
|
||||
SOURCES += src/main.cpp \
|
||||
src/gui.cpp \
|
||||
src/gpx.cpp \
|
||||
@ -41,8 +52,6 @@ SOURCES += src/main.cpp \
|
||||
src/poi.cpp \
|
||||
src/ll.cpp \
|
||||
src/axisitem.cpp \
|
||||
src/poiitem.cpp \
|
||||
src/colorshop.cpp \
|
||||
src/slideritem.cpp \
|
||||
src/markeritem.cpp \
|
||||
src/infoitem.cpp \
|
||||
@ -57,8 +66,29 @@ SOURCES += src/main.cpp \
|
||||
src/nicenum.cpp \
|
||||
src/trackview.cpp \
|
||||
src/track.cpp \
|
||||
src/graphview.cpp
|
||||
src/graphview.cpp \
|
||||
src/waypointitem.cpp \
|
||||
src/palette.cpp \
|
||||
src/heartrategraph.cpp \
|
||||
src/range.cpp \
|
||||
src/app.cpp \
|
||||
src/trackinfo.cpp \
|
||||
src/exportdialog.cpp \
|
||||
src/fileselectwidget.cpp \
|
||||
src/temperaturegraph.cpp \
|
||||
src/trackpoint.cpp
|
||||
RESOURCES += gpxsee.qrc
|
||||
TRANSLATIONS = lang/gpxsee_cs.ts
|
||||
macx:ICON = icons/gpxsee.icns
|
||||
win32:RC_FILE = gpxsee.rc
|
||||
macx {
|
||||
ICON = icons/gpxsee.icns
|
||||
QMAKE_INFO_PLIST = Info.plist
|
||||
APP_RESOURCES.files = icons/gpx.icns \
|
||||
pkg/maps.txt
|
||||
APP_RESOURCES.path = Contents/Resources
|
||||
QMAKE_BUNDLE_DATA += APP_RESOURCES
|
||||
}
|
||||
win32 {
|
||||
RC_ICONS = icons/gpxsee.ico \
|
||||
icons/gpx.ico
|
||||
}
|
||||
DEFINES += APP_VERSION=\\\"$$VERSION\\\"
|
||||
|
@ -2,8 +2,8 @@
|
||||
<qresource prefix="/">
|
||||
<file>icons/dialog-close.png</file>
|
||||
<file>icons/document-open.png</file>
|
||||
<file>icons/document-save-as.png</file>
|
||||
<file>icons/document-save.png</file>
|
||||
<file>icons/document-print.png</file>
|
||||
<file>icons/document-export.png</file>
|
||||
<file>icons/flag.png</file>
|
||||
<file>icons/gpxsee.png</file>
|
||||
<file>icons/application-exit.png</file>
|
||||
@ -13,7 +13,7 @@
|
||||
<file>icons/arrow-right.png</file>
|
||||
<file>icons/arrow-left-double.png</file>
|
||||
<file>icons/arrow-right-double.png</file>
|
||||
<file>icons/view-fullscreen.png</file>
|
||||
<file>lang/gpxsee_cs.qm</file>
|
||||
<file>maps.txt</file>
|
||||
</qresource>
|
||||
</RCC>
|
||||
|
BIN
icons/document-export.png
Normal file
BIN
icons/document-export.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 865 B |
BIN
icons/document-print.png
Normal file
BIN
icons/document-print.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 880 B |
Binary file not shown.
Before Width: | Height: | Size: 1.2 KiB |
Binary file not shown.
Before Width: | Height: | Size: 798 B |
BIN
icons/gpx.icns
Normal file
BIN
icons/gpx.icns
Normal file
Binary file not shown.
BIN
icons/gpx.ico
Normal file
BIN
icons/gpx.ico
Normal file
Binary file not shown.
After Width: | Height: | Size: 361 KiB |
BIN
icons/view-fullscreen.png
Normal file
BIN
icons/view-fullscreen.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 381 B |
File diff suppressed because it is too large
Load Diff
@ -3,9 +3,11 @@
|
||||
|
||||
; The name of the installer
|
||||
Name "GPXSee"
|
||||
; Program version
|
||||
!define VERSION "2.16"
|
||||
|
||||
; The file to write
|
||||
OutFile "install.exe"
|
||||
OutFile "GPXSee-${VERSION}.exe"
|
||||
|
||||
; Required execution level
|
||||
RequestExecutionLevel admin
|
||||
@ -18,7 +20,9 @@ InstallDir "$PROGRAMFILES\GPXSee"
|
||||
InstallDirRegKey HKLM "Software\GPXSee" "Install_Dir"
|
||||
|
||||
; Registry key for uninstaller
|
||||
!define REGENTRY "Software\Microsoft\Windows\CurrentVersion\Uninstall\GPXSee"
|
||||
!define REGENTRY "Software\Microsoft\Windows\CurrentVersion\Uninstall\GPXSee"
|
||||
; GPX file type registry entry
|
||||
!define REGGPX "GPXSee.gpx"
|
||||
|
||||
; Start menu page configuration
|
||||
!define MUI_STARTMENUPAGE_REGISTRY_ROOT "HKLM"
|
||||
@ -55,8 +59,9 @@ Section "GPXSee (required)" SEC_APP
|
||||
; Set output path to the installation directory.
|
||||
SetOutPath $INSTDIR
|
||||
|
||||
; Put file there
|
||||
; Put the files there
|
||||
File "gpxsee.exe"
|
||||
File "maps.txt"
|
||||
|
||||
; Write the installation path into the registry
|
||||
WriteRegStr HKLM SOFTWARE\GPXSee "Install_Dir" "$INSTDIR"
|
||||
@ -64,7 +69,7 @@ Section "GPXSee (required)" SEC_APP
|
||||
; Write the uninstall keys for Windows
|
||||
WriteRegStr HKLM "${REGENTRY}" "DisplayName" "GPXSee"
|
||||
WriteRegStr HKLM "${REGENTRY}" "Publisher" "Martin Tuma"
|
||||
WriteRegStr HKLM "${REGENTRY}" "DisplayVersion" "2.7"
|
||||
WriteRegStr HKLM "${REGENTRY}" "DisplayVersion" "${VERSION}"
|
||||
WriteRegStr HKLM "${REGENTRY}" "UninstallString" '"$INSTDIR\uninstall.exe"'
|
||||
WriteRegDWORD HKLM "${REGENTRY}" "NoModify" 1
|
||||
WriteRegDWORD HKLM "${REGENTRY}" "NoRepair" 1
|
||||
@ -78,6 +83,13 @@ Section "GPXSee (required)" SEC_APP
|
||||
CreateShortCut "$SMPROGRAMS\$StartMenuFolder\GPXSee.lnk" "$INSTDIR\gpxsee.exe"
|
||||
!insertmacro MUI_STARTMENU_WRITE_END
|
||||
|
||||
; Associate .gpx files
|
||||
WriteRegStr HKCR ".gpx" "" "${REGGPX}"
|
||||
WriteRegStr HKCR "${REGGPX}" "" "GPS Exchange Format"
|
||||
WriteRegStr HKCR "${REGGPX}\DefaultIcon" "" "$INSTDIR\GPXSee.exe,1"
|
||||
WriteRegStr HKCR "${REGGPX}\shell\open\command" "" "$\"$INSTDIR\GPXSee.exe$\" $\"%1$\""
|
||||
System::Call 'shell32.dll::SHChangeNotify(i, i, i, i) v (0x08000000, 0, 0, 0)'
|
||||
|
||||
SectionEnd
|
||||
|
||||
Section "QT libs" SEC_QT
|
||||
@ -90,6 +102,7 @@ Section "QT libs" SEC_QT
|
||||
File "libGLESv2.dll"
|
||||
File /r "platforms"
|
||||
File /r "imageformats"
|
||||
File /r "printsupport"
|
||||
|
||||
SectionEnd
|
||||
|
||||
@ -131,7 +144,12 @@ Section "Uninstall"
|
||||
SetShellVarContext all
|
||||
!insertmacro MUI_STARTMENU_GETFOLDER Application $StartMenuFolder
|
||||
Delete "$SMPROGRAMS\$StartMenuFolder\*.*"
|
||||
RMDir "$SMPROGRAMS\$StartMenuFolder"
|
||||
RMDir "$SMPROGRAMS\$StartMenuFolder"
|
||||
|
||||
; Remove GPX file association
|
||||
DeleteRegKey HKCR "${REGGPX}"
|
||||
DeleteRegKey HKCR ".gpx"
|
||||
System::Call 'shell32.dll::SHChangeNotify(i, i, i, i) v (0x08000000, 0, 0, 0)'
|
||||
|
||||
SectionEnd
|
||||
|
177
pkg/gpxsee64.nsi
Normal file
177
pkg/gpxsee64.nsi
Normal file
@ -0,0 +1,177 @@
|
||||
!include "MUI2.nsh"
|
||||
!include "x64.nsh"
|
||||
|
||||
; The name of the installer
|
||||
Name "GPXSee"
|
||||
; Program version
|
||||
!define VERSION "2.16"
|
||||
|
||||
; The file to write
|
||||
OutFile "GPXSee-${VERSION}_x64.exe"
|
||||
|
||||
; Required execution level
|
||||
RequestExecutionLevel admin
|
||||
|
||||
; The default installation directory
|
||||
InstallDir "$PROGRAMFILES64\GPXSee"
|
||||
|
||||
; Registry key to check for directory (so if you install again, it will
|
||||
; overwrite the old one automatically)
|
||||
InstallDirRegKey HKLM "Software\GPXSee" "Install_Dir"
|
||||
|
||||
; Registry key for uninstaller
|
||||
!define REGENTRY "Software\Microsoft\Windows\CurrentVersion\Uninstall\GPXSee"
|
||||
; GPX file type registry entry
|
||||
!define REGGPX "GPXSee.gpx"
|
||||
|
||||
; Start menu page configuration
|
||||
!define MUI_STARTMENUPAGE_REGISTRY_ROOT "HKLM"
|
||||
!define MUI_STARTMENUPAGE_REGISTRY_KEY "Software\GPXSee"
|
||||
!define MUI_STARTMENUPAGE_REGISTRY_VALUENAME "GPXSee"
|
||||
|
||||
Var StartMenuFolder
|
||||
|
||||
;--------------------------------
|
||||
|
||||
; Pages
|
||||
|
||||
!insertmacro MUI_PAGE_WELCOME
|
||||
!insertmacro MUI_PAGE_LICENSE "licence.txt"
|
||||
!insertmacro MUI_PAGE_COMPONENTS
|
||||
!insertmacro MUI_PAGE_DIRECTORY
|
||||
!insertmacro MUI_PAGE_STARTMENU Application $StartMenuFolder
|
||||
!insertmacro MUI_PAGE_INSTFILES
|
||||
|
||||
!insertmacro MUI_UNPAGE_CONFIRM
|
||||
!insertmacro MUI_UNPAGE_INSTFILES
|
||||
|
||||
;--------------------------------
|
||||
|
||||
; Languages
|
||||
!insertmacro MUI_LANGUAGE "English"
|
||||
|
||||
Function .onInit
|
||||
${If} ${RunningX64}
|
||||
SetRegView 64
|
||||
${Else}
|
||||
MessageBox MB_OK "The 64b version of GPXSee can not be run on 32b systems."
|
||||
Abort
|
||||
${EndIf}
|
||||
FunctionEnd
|
||||
|
||||
; The stuff to install
|
||||
Section "GPXSee (required)" SEC_APP
|
||||
|
||||
SectionIn RO
|
||||
|
||||
; Set output path to the installation directory.
|
||||
SetOutPath $INSTDIR
|
||||
|
||||
; Put the files there
|
||||
File "gpxsee.exe"
|
||||
File "maps.txt"
|
||||
|
||||
; Write the installation path into the registry
|
||||
WriteRegStr HKLM SOFTWARE\GPXSee "Install_Dir" "$INSTDIR"
|
||||
|
||||
; Write the uninstall keys for Windows
|
||||
WriteRegStr HKLM "${REGENTRY}" "DisplayName" "GPXSee"
|
||||
WriteRegStr HKLM "${REGENTRY}" "Publisher" "Martin Tuma"
|
||||
WriteRegStr HKLM "${REGENTRY}" "DisplayVersion" "${VERSION}"
|
||||
WriteRegStr HKLM "${REGENTRY}" "UninstallString" '"$INSTDIR\uninstall.exe"'
|
||||
WriteRegDWORD HKLM "${REGENTRY}" "NoModify" 1
|
||||
WriteRegDWORD HKLM "${REGENTRY}" "NoRepair" 1
|
||||
WriteUninstaller "$INSTDIR\uninstall.exe"
|
||||
|
||||
; Create start menu entry and add links
|
||||
SetShellVarContext all
|
||||
!insertmacro MUI_STARTMENU_WRITE_BEGIN Application
|
||||
CreateDirectory "$SMPROGRAMS\$StartMenuFolder"
|
||||
CreateShortCut "$SMPROGRAMS\$StartMenuFolder\Uninstall.lnk" "$INSTDIR\Uninstall.exe"
|
||||
CreateShortCut "$SMPROGRAMS\$StartMenuFolder\GPXSee.lnk" "$INSTDIR\gpxsee.exe"
|
||||
!insertmacro MUI_STARTMENU_WRITE_END
|
||||
|
||||
; Associate .gpx files
|
||||
WriteRegStr HKCR ".gpx" "" "${REGGPX}"
|
||||
WriteRegStr HKCR "${REGGPX}" "" "GPS Exchange Format"
|
||||
WriteRegStr HKCR "${REGGPX}\DefaultIcon" "" "$INSTDIR\GPXSee.exe,1"
|
||||
WriteRegStr HKCR "${REGGPX}\shell\open\command" "" "$\"$INSTDIR\GPXSee.exe$\" $\"%1$\""
|
||||
System::Call 'shell32.dll::SHChangeNotify(i, i, i, i) v (0x08000000, 0, 0, 0)'
|
||||
|
||||
SectionEnd
|
||||
|
||||
Section "QT libs" SEC_QT
|
||||
|
||||
File "Qt5Core.dll"
|
||||
File "Qt5Gui.dll"
|
||||
File "Qt5Widgets.dll"
|
||||
File "Qt5PrintSupport.dll"
|
||||
File "Qt5Network.dll"
|
||||
File "libGLESv2.dll"
|
||||
File /r "platforms"
|
||||
File /r "imageformats"
|
||||
File /r "printsupport"
|
||||
|
||||
SectionEnd
|
||||
|
||||
Section "MSVC runtime" SEC_MSVC
|
||||
|
||||
DetailPrint "Checking whether Visual C++ 2015 Redistributable is already installed..."
|
||||
ReadRegDword $R0 HKLM "SOFTWARE\Wow6432Node\Microsoft\VisualStudio\14.0\VC\Runtimes\x64" "Installed"
|
||||
StrCmp $R0 "1" 0 +3
|
||||
DetailPrint "Visual C++ 2015 Redistributable is already installed, skipping install."
|
||||
Goto done
|
||||
|
||||
DetailPrint "Installing Visual C++ 2015 Redistributable..."
|
||||
SetOutPath $TEMP
|
||||
File "VC_redist.x64.exe"
|
||||
ExecWait '"$TEMP/VC_redist.x64.exe" /install /quiet /norestart'
|
||||
|
||||
done:
|
||||
SectionEnd
|
||||
|
||||
;--------------------------------
|
||||
|
||||
; Uninstaller
|
||||
|
||||
Section "Uninstall"
|
||||
|
||||
; Remove registry keys
|
||||
SetRegView 64
|
||||
DeleteRegKey HKLM "${REGENTRY}"
|
||||
DeleteRegKey HKLM SOFTWARE\GPXSee
|
||||
|
||||
; Remove directories used
|
||||
RMDir /r "$INSTDIR"
|
||||
|
||||
; Remove Start menu entries
|
||||
SetShellVarContext all
|
||||
!insertmacro MUI_STARTMENU_GETFOLDER Application $StartMenuFolder
|
||||
Delete "$SMPROGRAMS\$StartMenuFolder\*.*"
|
||||
RMDir "$SMPROGRAMS\$StartMenuFolder"
|
||||
|
||||
; Remove GPX file association
|
||||
DeleteRegKey HKCR "${REGGPX}"
|
||||
DeleteRegKey HKCR ".gpx"
|
||||
System::Call 'shell32.dll::SHChangeNotify(i, i, i, i) v (0x08000000, 0, 0, 0)'
|
||||
|
||||
SectionEnd
|
||||
|
||||
;-------------------------------
|
||||
|
||||
;Descriptions
|
||||
|
||||
;Language strings
|
||||
LangString DESC_QT ${LANG_ENGLISH} \
|
||||
"QT Library. Unselct only if you have QT already installed!"
|
||||
LangString DESC_MSVC ${LANG_ENGLISH} \
|
||||
"Visual C++ 2015 runtime components. Unselct only if you have the runtime already installed!"
|
||||
LangString DESC_APP ${LANG_ENGLISH} \
|
||||
"GPXSee application"
|
||||
|
||||
;Assign language strings to sections
|
||||
!insertmacro MUI_FUNCTION_DESCRIPTION_BEGIN
|
||||
!insertmacro MUI_DESCRIPTION_TEXT ${SEC_QT} $(DESC_QT)
|
||||
!insertmacro MUI_DESCRIPTION_TEXT ${SEC_MSVC} $(DESC_MSVC)
|
||||
!insertmacro MUI_DESCRIPTION_TEXT ${SEC_APP} $(DESC_APP)
|
||||
!insertmacro MUI_FUNCTION_DESCRIPTION_END
|
48
src/app.cpp
Normal file
48
src/app.cpp
Normal file
@ -0,0 +1,48 @@
|
||||
#include <QtGlobal>
|
||||
#include <QTranslator>
|
||||
#include <QLocale>
|
||||
#include <QFileOpenEvent>
|
||||
#include "gui.h"
|
||||
#include "app.h"
|
||||
|
||||
|
||||
App::App(int &argc, char **argv) : QApplication(argc, argv),
|
||||
_argc(argc), _argv(argv)
|
||||
{
|
||||
_translator = new QTranslator();
|
||||
|
||||
QString locale = QLocale::system().name();
|
||||
_translator->load(QString(":/lang/gpxsee_") + locale);
|
||||
installTranslator(_translator);
|
||||
#ifdef Q_OS_MAC
|
||||
setAttribute(Qt::AA_DontShowIconsInMenus);
|
||||
#endif // Q_OS_MAC
|
||||
|
||||
_gui = new GUI();
|
||||
}
|
||||
|
||||
App::~App()
|
||||
{
|
||||
delete _gui;
|
||||
delete _translator;
|
||||
}
|
||||
|
||||
void App::run()
|
||||
{
|
||||
_gui->show();
|
||||
|
||||
for (int i = 1; i < _argc; i++)
|
||||
_gui->openFile(QString::fromLocal8Bit(_argv[i]));
|
||||
|
||||
exec();
|
||||
}
|
||||
|
||||
bool App::event(QEvent *event)
|
||||
{
|
||||
if (event->type() == QEvent::FileOpen) {
|
||||
QFileOpenEvent *e = static_cast<QFileOpenEvent *>(event);
|
||||
return _gui->openFile(e->file());
|
||||
}
|
||||
|
||||
return QApplication::event(event);
|
||||
}
|
28
src/app.h
Normal file
28
src/app.h
Normal file
@ -0,0 +1,28 @@
|
||||
#ifndef APP_H
|
||||
#define APP_H
|
||||
|
||||
#include <QApplication>
|
||||
|
||||
class GUI;
|
||||
class QTranslator;
|
||||
|
||||
class App : QApplication
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
App(int &argc, char **argv);
|
||||
~App();
|
||||
void run();
|
||||
|
||||
protected:
|
||||
bool event(QEvent *event);
|
||||
|
||||
private:
|
||||
int &_argc;
|
||||
char **_argv;
|
||||
GUI *_gui;
|
||||
QTranslator *_translator;
|
||||
};
|
||||
|
||||
#endif // APP_H
|
@ -36,25 +36,25 @@ AxisItem::AxisItem(Type type, QGraphicsItem *parent) : QGraphicsItem(parent)
|
||||
_size = 0;
|
||||
}
|
||||
|
||||
void AxisItem::setRange(const QPointF &range)
|
||||
void AxisItem::setRange(const RangeF &range)
|
||||
{
|
||||
prepareGeometryChange();
|
||||
_range = range;
|
||||
updateBoundingRect();
|
||||
prepareGeometryChange();
|
||||
}
|
||||
|
||||
void AxisItem::setSize(qreal size)
|
||||
{
|
||||
prepareGeometryChange();
|
||||
_size = size;
|
||||
updateBoundingRect();
|
||||
prepareGeometryChange();
|
||||
}
|
||||
|
||||
void AxisItem::setLabel(const QString& label)
|
||||
{
|
||||
prepareGeometryChange();
|
||||
_label = label;
|
||||
updateBoundingRect();
|
||||
prepareGeometryChange();
|
||||
}
|
||||
|
||||
void AxisItem::updateBoundingRect()
|
||||
@ -67,7 +67,7 @@ void AxisItem::updateBoundingRect()
|
||||
struct Label l;
|
||||
|
||||
|
||||
l = label(_range.x(), _range.y(), (_type == X) ? XTICKS : YTICKS);
|
||||
l = label(_range.min(), _range.max(), (_type == X) ? XTICKS : YTICKS);
|
||||
es = fm.tightBoundingRect(QString::number(l.max));
|
||||
ss = fm.tightBoundingRect(QString::number(l.min));
|
||||
ls = fm.tightBoundingRect(_label);
|
||||
@ -77,9 +77,20 @@ void AxisItem::updateBoundingRect()
|
||||
_size + es.width()/2 + ss.width()/2,
|
||||
ls.height() + es.height() - fm.descent() + TICK + 2*PADDING);
|
||||
} else {
|
||||
_boundingRect = QRectF(-(ls.height() + es.width() + 2*PADDING
|
||||
int mtw = 0;
|
||||
QRect ts;
|
||||
qreal val;
|
||||
|
||||
for (int i = 0; i < ((l.max - l.min) / l.d) + 1; i++) {
|
||||
val = l.min + i * l.d;
|
||||
QString str = QString::number(val);
|
||||
ts = fm.tightBoundingRect(str);
|
||||
mtw = qMax(ts.width(), mtw);
|
||||
}
|
||||
|
||||
_boundingRect = QRectF(-(ls.height() + mtw + 2*PADDING
|
||||
- fm.descent() + TICK/2), -(_size + es.height()/2
|
||||
+ fm.descent()), ls.height() -fm.descent() + es.width() + 2*PADDING
|
||||
+ fm.descent()), ls.height() -fm.descent() + mtw + 2*PADDING
|
||||
+ TICK, _size + es.height()/2 + fm.descent() + ss.height()/2);
|
||||
}
|
||||
}
|
||||
@ -95,7 +106,7 @@ void AxisItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *option,
|
||||
QFontMetrics fm(font);
|
||||
QRect ts, ls;
|
||||
struct Label l;
|
||||
qreal range = _range.y() - _range.x();
|
||||
qreal range = _range.size();
|
||||
qreal val;
|
||||
|
||||
|
||||
@ -106,15 +117,15 @@ void AxisItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *option,
|
||||
if (_type == X) {
|
||||
painter->drawLine(0, 0, _size, 0);
|
||||
|
||||
l = label(_range.x(), _range.y(), XTICKS);
|
||||
l = label(_range.min(), _range.max(), XTICKS);
|
||||
for (int i = 0; i < ((l.max - l.min) / l.d) + 1; i++) {
|
||||
val = l.min + i * l.d;
|
||||
QString str = QString::number(val);
|
||||
|
||||
painter->drawLine((_size/range) * (val - _range.x()), TICK/2,
|
||||
(_size/range) * (val - _range.x()), -TICK/2);
|
||||
painter->drawLine((_size/range) * (val - _range.min()), TICK/2,
|
||||
(_size/range) * (val - _range.min()), -TICK/2);
|
||||
ts = fm.tightBoundingRect(str);
|
||||
painter->drawText(((_size/range) * (val - _range.x()))
|
||||
painter->drawText(((_size/range) * (val - _range.min()))
|
||||
- (ts.width()/2), ts.height() + TICK/2 + PADDING, str);
|
||||
}
|
||||
|
||||
@ -123,21 +134,23 @@ void AxisItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *option,
|
||||
} else {
|
||||
painter->drawLine(0, 0, 0, -_size);
|
||||
|
||||
l = label(_range.x(), _range.y(), YTICKS);
|
||||
l = label(_range.min(), _range.max(), YTICKS);
|
||||
int mtw = 0;
|
||||
for (int i = 0; i < ((l.max - l.min) / l.d) + 1; i++) {
|
||||
val = l.min + i * l.d;
|
||||
QString str = QString::number(val);
|
||||
|
||||
painter->drawLine(TICK/2, -((_size/range) * (val - _range.x())),
|
||||
-TICK/2, -((_size/range) * (val - _range.x())));
|
||||
painter->drawLine(TICK/2, -((_size/range) * (val - _range.min())),
|
||||
-TICK/2, -((_size/range) * (val - _range.min())));
|
||||
ts = fm.tightBoundingRect(str);
|
||||
mtw = qMax(ts.width(), mtw);
|
||||
painter->drawText(-(ts.width() + PADDING + TICK/2), -((_size/range)
|
||||
* (val - _range.x())) + (ts.height()/2), str);
|
||||
* (val - _range.min())) + (ts.height()/2), str);
|
||||
}
|
||||
|
||||
painter->rotate(-90);
|
||||
painter->drawText(_size/2 - ls.width()/2, -(ts.width()
|
||||
+ 2*PADDING + TICK/2), _label);
|
||||
painter->drawText(_size/2 - ls.width()/2, -(mtw + 2*PADDING + TICK/2),
|
||||
_label);
|
||||
painter->rotate(90);
|
||||
}
|
||||
|
||||
@ -147,7 +160,7 @@ void AxisItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *option,
|
||||
*/
|
||||
}
|
||||
|
||||
QSizeF AxisItem::margin()
|
||||
QSizeF AxisItem::margin() const
|
||||
{
|
||||
QFont font;
|
||||
font.setPixelSize(FONT_SIZE);
|
||||
@ -156,7 +169,7 @@ QSizeF AxisItem::margin()
|
||||
struct Label l;
|
||||
|
||||
|
||||
l = label(_range.x(), _range.y(), (_type == X) ? XTICKS : YTICKS);
|
||||
l = label(_range.min(), _range.max(), (_type == X) ? XTICKS : YTICKS);
|
||||
es = fm.tightBoundingRect(QString::number(l.max));
|
||||
ss = fm.tightBoundingRect(QString::number(l.min));
|
||||
ls = fm.tightBoundingRect(_label);
|
||||
@ -165,7 +178,18 @@ QSizeF AxisItem::margin()
|
||||
return QSizeF(es.width()/2,
|
||||
ls.height() + es.height() - fm.descent() + TICK/2 + 2*PADDING);
|
||||
} else {
|
||||
return QSizeF(ls.height() -fm.descent() + es.width() + 2*PADDING
|
||||
int mtw = 0;
|
||||
QRect ts;
|
||||
qreal val;
|
||||
|
||||
for (int i = 0; i < ((l.max - l.min) / l.d) + 1; i++) {
|
||||
val = l.min + i * l.d;
|
||||
QString str = QString::number(val);
|
||||
ts = fm.tightBoundingRect(str);
|
||||
mtw = qMax(ts.width(), mtw);
|
||||
}
|
||||
|
||||
return QSizeF(ls.height() -fm.descent() + mtw + 2*PADDING
|
||||
+ TICK/2, es.height()/2 + fm.descent());
|
||||
}
|
||||
}
|
||||
|
@ -2,6 +2,7 @@
|
||||
#define AXISITEM_H
|
||||
|
||||
#include <QGraphicsItem>
|
||||
#include "range.h"
|
||||
|
||||
class AxisItem : public QGraphicsItem
|
||||
{
|
||||
@ -14,17 +15,17 @@ public:
|
||||
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option,
|
||||
QWidget *widget);
|
||||
|
||||
void setRange(const QPointF &range);
|
||||
void setRange(const RangeF &range);
|
||||
void setSize(qreal size);
|
||||
void setLabel(const QString& label);
|
||||
|
||||
QSizeF margin();
|
||||
QSizeF margin() const;
|
||||
|
||||
private:
|
||||
void updateBoundingRect();
|
||||
|
||||
Type _type;
|
||||
QPointF _range;
|
||||
RangeF _range;
|
||||
qreal _size;
|
||||
QString _label;
|
||||
QRectF _boundingRect;
|
||||
|
37
src/config.h
37
src/config.h
@ -1,20 +1,37 @@
|
||||
#ifndef CONFIG_H
|
||||
#define CONFIG_H
|
||||
|
||||
#define APP_NAME "GPXSee"
|
||||
#define APP_HOMEPAGE "http://tumic.wz.cz/gpxsee"
|
||||
#define APP_VERSION "2.7"
|
||||
#include <QtGlobal>
|
||||
#include <QDir>
|
||||
#include <QApplication>
|
||||
#include <QString>
|
||||
|
||||
#define FONT_FAMILY "Arial"
|
||||
#define FONT_SIZE 12
|
||||
#define APP_NAME "GPXSee"
|
||||
#define APP_HOMEPAGE "http://tumic.wz.cz/gpxsee"
|
||||
|
||||
#define FONT_FAMILY "Arial"
|
||||
#define FONT_SIZE 12
|
||||
#define SCREEN_DPI 96.0
|
||||
|
||||
#define MAP_FILE QString("maps.txt")
|
||||
#define POI_DIR QString("POI")
|
||||
|
||||
#if defined(Q_OS_WIN32)
|
||||
#define APP_DIR "GPXSee"
|
||||
#define USER_DIR QDir::homePath() + QString("/GPXSee")
|
||||
#define GLOBAL_DIR QApplication::applicationDirPath()
|
||||
#elif defined(Q_OS_MAC)
|
||||
#define USER_DIR QDir::homePath() + QString("/.gpxsee")
|
||||
#define GLOBAL_DIR QApplication::applicationDirPath() \
|
||||
+ QString("/../Resources")
|
||||
#else
|
||||
#define APP_DIR ".gpxsee"
|
||||
#define USER_DIR QDir::homePath() + QString("/.gpxsee")
|
||||
#define GLOBAL_DIR QString("/usr/share/gpxsee")
|
||||
#endif
|
||||
#define POI_DIR APP_DIR"/POI"
|
||||
#define TILES_DIR APP_DIR"/tiles"
|
||||
#define MAP_LIST_FILE APP_DIR"/maps.txt"
|
||||
|
||||
#define USER_MAP_FILE USER_DIR + QString("/") + MAP_FILE
|
||||
#define USER_POI_DIR USER_DIR + QString("/") + POI_DIR
|
||||
#define GLOBAL_MAP_FILE GLOBAL_DIR + QString("/") + MAP_FILE
|
||||
#define GLOBAL_POI_DIR GLOBAL_DIR + QString("/") + POI_DIR
|
||||
#define TILES_DIR USER_DIR + QString("/tiles")
|
||||
|
||||
#endif /* CONFIG_H */
|
||||
|
42
src/cpuarch.h
Normal file
42
src/cpuarch.h
Normal file
@ -0,0 +1,42 @@
|
||||
#ifndef CPUARCH_H
|
||||
#define CPUARCH_H
|
||||
|
||||
#include <QtGlobal>
|
||||
|
||||
#if QT_VERSION < QT_VERSION_CHECK(5, 4, 0)
|
||||
|
||||
#if defined(__arm64__)
|
||||
#define CPU_ARCH_STR "arm64"
|
||||
#elif defined(__arm__) || defined(__TARGET_ARCH_ARM) || defined(_M_ARM)
|
||||
#define CPU_ARCH_STR "arm"
|
||||
#elif defined(__x86_64) || defined(__x86_64__) || defined(__amd64) \
|
||||
|| defined(_M_X64)
|
||||
#define CPU_ARCH_STR "x86_64"
|
||||
#elif defined(__i386) || defined(__i386__) || defined(_M_IX86)
|
||||
#define CPU_ARCH_STR "i386"
|
||||
#elif defined(__ia64) || defined(__ia64__) || defined(_M_IA64)
|
||||
#define CPU_ARCH_STR "ia64"
|
||||
#elif defined(_MIPS_ARCH_MIPS64) || defined(__mips64)
|
||||
#define CPU_ARCH_STR "mips64"
|
||||
#elif defined(__mips) || defined(__mips__) || defined(_M_MRX000)
|
||||
#define CPU_ARCH_STR "mips"
|
||||
#elif defined(__ppc64__) || defined(__powerpc64__) || defined(__64BIT__)
|
||||
#define CPU_ARCH_STR "power64"
|
||||
#elif defined(__ppc__) || defined(__ppc) || defined(__powerpc__) \
|
||||
|| defined(_ARCH_COM) || defined(_ARCH_PWR) || defined(_ARCH_PPC) \
|
||||
|| defined(_M_MPPC) || defined(_M_PPC)
|
||||
#define CPU_ARCH_STR "power"
|
||||
#else
|
||||
#define CPU_ARCH_STR "unknown"
|
||||
#endif
|
||||
|
||||
#define CPU_ARCH QString(CPU_ARCH_STR)
|
||||
|
||||
#else // QT_VERSION < 5.4
|
||||
|
||||
#include <QSysInfo>
|
||||
#define CPU_ARCH QSysInfo::buildCpuArchitecture()
|
||||
|
||||
#endif // QT_VERSION < 5.4
|
||||
|
||||
#endif // CPUARCH_H
|
@ -14,7 +14,8 @@
|
||||
#define PLATFORM_STR "Unknown"
|
||||
#endif
|
||||
|
||||
#define USER_AGENT APP_NAME"/"APP_VERSION" ("PLATFORM_STR"; Qt "QT_VERSION_STR")"
|
||||
#define USER_AGENT \
|
||||
APP_NAME "/" APP_VERSION " (" PLATFORM_STR "; Qt " QT_VERSION_STR ")"
|
||||
|
||||
Downloader::Downloader()
|
||||
{
|
||||
@ -22,12 +23,12 @@ Downloader::Downloader()
|
||||
SLOT(downloadFinished(QNetworkReply*)));
|
||||
}
|
||||
|
||||
void Downloader::doDownload(const Download &dl)
|
||||
bool Downloader::doDownload(const Download &dl)
|
||||
{
|
||||
QUrl url(dl.url());
|
||||
|
||||
if (_errorDownloads.contains(url))
|
||||
return;
|
||||
return false;
|
||||
|
||||
QNetworkRequest request(url);
|
||||
request.setAttribute(QNetworkRequest::User, QVariant(dl.file()));
|
||||
@ -35,6 +36,8 @@ void Downloader::doDownload(const Download &dl)
|
||||
QNetworkReply *reply = _manager.get(request);
|
||||
|
||||
_currentDownloads.append(reply);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool Downloader::saveToDisk(const QString &filename, QIODevice *data)
|
||||
@ -61,9 +64,16 @@ void Downloader::downloadFinished(QNetworkReply *reply)
|
||||
fprintf(stderr, "Error downloading map tile: %s: %s\n",
|
||||
url.toEncoded().constData(), qPrintable(reply->errorString()));
|
||||
} else {
|
||||
QUrl redirect = reply->attribute(
|
||||
QNetworkRequest::RedirectionTargetAttribute).toUrl();
|
||||
QString filename = reply->request().attribute(QNetworkRequest::User)
|
||||
.toString();
|
||||
saveToDisk(filename, reply);
|
||||
|
||||
if (!redirect.isEmpty()) {
|
||||
Download dl(redirect, filename);
|
||||
doDownload(dl);
|
||||
} else
|
||||
saveToDisk(filename, reply);
|
||||
}
|
||||
|
||||
_currentDownloads.removeAll(reply);
|
||||
@ -73,8 +83,12 @@ void Downloader::downloadFinished(QNetworkReply *reply)
|
||||
emit finished();
|
||||
}
|
||||
|
||||
void Downloader::get(const QList<Download> &list)
|
||||
bool Downloader::get(const QList<Download> &list)
|
||||
{
|
||||
bool finishEmitted = false;
|
||||
|
||||
for (int i = 0; i < list.count(); i++)
|
||||
doDownload(list.at(i));
|
||||
finishEmitted |= doDownload(list.at(i));
|
||||
|
||||
return finishEmitted;
|
||||
}
|
||||
|
@ -12,13 +12,13 @@
|
||||
class Download
|
||||
{
|
||||
public:
|
||||
Download(const QString &url, const QString &file)
|
||||
Download(const QUrl &url, const QString &file)
|
||||
{_url = url; _file = file;}
|
||||
const QString& url() const {return _url;}
|
||||
const QUrl& url() const {return _url;}
|
||||
const QString& file() const {return _file;}
|
||||
|
||||
private:
|
||||
QString _url;
|
||||
QUrl _url;
|
||||
QString _file;
|
||||
};
|
||||
|
||||
@ -30,7 +30,7 @@ class Downloader : public QObject
|
||||
public:
|
||||
static Downloader& instance()
|
||||
{static Downloader i; return i;}
|
||||
void get(const QList<Download> &list);
|
||||
bool get(const QList<Download> &list);
|
||||
|
||||
signals:
|
||||
void finished();
|
||||
@ -43,7 +43,7 @@ private:
|
||||
Downloader(Downloader const&);
|
||||
void operator=(Downloader const&);
|
||||
|
||||
void doDownload(const Download &dl);
|
||||
bool doDownload(const Download &dl);
|
||||
bool saveToDisk(const QString &filename, QIODevice *data);
|
||||
|
||||
QNetworkAccessManager _manager;
|
||||
|
@ -1,4 +1,3 @@
|
||||
#include <float.h>
|
||||
#include "config.h"
|
||||
#include "gpx.h"
|
||||
#include "elevationgraph.h"
|
||||
@ -8,91 +7,108 @@ ElevationGraph::ElevationGraph(QWidget *parent) : GraphView(parent)
|
||||
{
|
||||
_ascent = 0;
|
||||
_descent = 0;
|
||||
_max = -FLT_MAX;
|
||||
_min = FLT_MAX;
|
||||
|
||||
GraphView::setXLabel(tr("Distance"));
|
||||
GraphView::setYLabel(tr("Elevation"));
|
||||
GraphView::setXUnits(tr("km"));
|
||||
GraphView::setYUnits(tr("m"));
|
||||
GraphView::setXScale(M2KM);
|
||||
_units = Metric;
|
||||
|
||||
setYUnits();
|
||||
setXLabel(tr("Distance"));
|
||||
setYLabel(tr("Elevation"));
|
||||
|
||||
setMinYRange(50.0);
|
||||
}
|
||||
|
||||
void ElevationGraph::addInfo()
|
||||
{
|
||||
GraphView::addInfo(tr("Ascent"), QString::number(_ascent * _yScale, 'f', 0)
|
||||
+ UNIT_SPACE + _yUnits);
|
||||
GraphView::addInfo(tr("Descent"), QString::number(_descent * _yScale, 'f', 0)
|
||||
+ UNIT_SPACE + _yUnits);
|
||||
GraphView::addInfo(tr("Maximum"), QString::number(_max * _yScale, 'f', 0)
|
||||
+ UNIT_SPACE + _yUnits);
|
||||
GraphView::addInfo(tr("Minimum"), QString::number(_min * _yScale, 'f', 0)
|
||||
+ UNIT_SPACE + _yUnits);
|
||||
GraphView::addInfo(tr("Ascent"), QString::number(_ascent * yScale(), 'f', 0)
|
||||
+ UNIT_SPACE + yUnits());
|
||||
GraphView::addInfo(tr("Descent"), QString::number(_descent * yScale(), 'f',
|
||||
0) + UNIT_SPACE + yUnits());
|
||||
GraphView::addInfo(tr("Maximum"), QString::number(max() * yScale(), 'f', 0)
|
||||
+ UNIT_SPACE + yUnits());
|
||||
GraphView::addInfo(tr("Minimum"), QString::number(min() * yScale(), 'f', 0)
|
||||
+ UNIT_SPACE + yUnits());
|
||||
|
||||
redraw();
|
||||
}
|
||||
|
||||
void ElevationGraph::loadGPX(const GPX &gpx)
|
||||
{
|
||||
for (int i = 0; i < gpx.trackCount(); i++) {
|
||||
QVector<QPointF> data;
|
||||
qreal min, max, ascent = 0, descent = 0;
|
||||
qreal ascent = 0, descent = 0;
|
||||
|
||||
gpx.track(i).elevationGraph(data);
|
||||
if (data.isEmpty())
|
||||
return;
|
||||
if (data.count() < 2) {
|
||||
skipColor();
|
||||
continue;
|
||||
}
|
||||
|
||||
min = max = data.at(0).y();
|
||||
|
||||
for (int i = 1; i < data.size(); i++) {
|
||||
qreal cur = data.at(i).y();
|
||||
qreal prev = data.at(i-1).y();
|
||||
for (int j = 1; j < data.size(); j++) {
|
||||
qreal cur = data.at(j).y();
|
||||
qreal prev = data.at(j-1).y();
|
||||
|
||||
if (cur > prev)
|
||||
ascent += cur - prev;
|
||||
if (cur < prev)
|
||||
descent += prev - cur;
|
||||
|
||||
if (cur > max)
|
||||
max = cur;
|
||||
if (cur < min)
|
||||
min = cur;
|
||||
}
|
||||
|
||||
_ascent += ascent;
|
||||
_descent += descent;
|
||||
_max = qMax(_max, max);
|
||||
_min = qMin(_min, min);
|
||||
|
||||
addInfo();
|
||||
loadData(data);
|
||||
}
|
||||
|
||||
setXUnits();
|
||||
addInfo();
|
||||
}
|
||||
|
||||
void ElevationGraph::clear()
|
||||
{
|
||||
_ascent = 0;
|
||||
_descent = 0;
|
||||
_max = -FLT_MAX;
|
||||
_min = FLT_MAX;
|
||||
|
||||
GraphView::clear();
|
||||
}
|
||||
|
||||
void ElevationGraph::setXUnits()
|
||||
{
|
||||
if (_units == Metric) {
|
||||
if (bounds().width() < KMINM) {
|
||||
GraphView::setXUnits(tr("m"));
|
||||
setXScale(1);
|
||||
} else {
|
||||
GraphView::setXUnits(tr("km"));
|
||||
setXScale(M2KM);
|
||||
}
|
||||
} else {
|
||||
if (bounds().width() < MIINM) {
|
||||
GraphView::setXUnits(tr("ft"));
|
||||
setXScale(M2FT);
|
||||
} else {
|
||||
GraphView::setXUnits(tr("mi"));
|
||||
setXScale(M2MI);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void ElevationGraph::setYUnits()
|
||||
{
|
||||
if (_units == Metric) {
|
||||
GraphView::setYUnits(tr("m"));
|
||||
setYScale(1);
|
||||
} else {
|
||||
GraphView::setYUnits(tr("ft"));
|
||||
setYScale(M2FT);
|
||||
}
|
||||
}
|
||||
|
||||
void ElevationGraph::setUnits(enum Units units)
|
||||
{
|
||||
if (units == Metric) {
|
||||
GraphView::setXUnits(tr("km"));
|
||||
GraphView::setYUnits(tr("m"));
|
||||
GraphView::setXScale(M2KM);
|
||||
GraphView::setYScale(1);
|
||||
} else {
|
||||
GraphView::setXUnits(tr("mi"));
|
||||
GraphView::setYUnits(tr("ft"));
|
||||
GraphView::setXScale(M2MI);
|
||||
GraphView::setYScale(M2FT);
|
||||
}
|
||||
_units = units;
|
||||
setXUnits();
|
||||
setYUnits();
|
||||
|
||||
clearInfo();
|
||||
addInfo();
|
||||
|
||||
redraw();
|
||||
}
|
||||
|
@ -19,14 +19,16 @@ public:
|
||||
|
||||
qreal ascent() const {return _ascent;}
|
||||
qreal descent() const {return _descent;}
|
||||
qreal max() const {return _max;}
|
||||
qreal min() const {return _min;}
|
||||
qreal max() const {return bounds().bottom();}
|
||||
qreal min() const {return bounds().top();}
|
||||
|
||||
private:
|
||||
void setXUnits();
|
||||
void setYUnits();
|
||||
void addInfo();
|
||||
|
||||
qreal _ascent, _descent;
|
||||
qreal _max, _min;
|
||||
enum Units _units;
|
||||
};
|
||||
|
||||
#endif // ELEVATIONGRAPH_H
|
||||
|
174
src/exportdialog.cpp
Normal file
174
src/exportdialog.cpp
Normal file
@ -0,0 +1,174 @@
|
||||
#include <QVBoxLayout>
|
||||
#include <QHBoxLayout>
|
||||
#include <QFormLayout>
|
||||
#include <QGridLayout>
|
||||
#include <QDialogButtonBox>
|
||||
#include <QGroupBox>
|
||||
#include <QComboBox>
|
||||
#include <QRadioButton>
|
||||
#include <QPushButton>
|
||||
#include <QFileInfo>
|
||||
#include <QMessageBox>
|
||||
#include <QTabWidget>
|
||||
#include <QDoubleSpinBox>
|
||||
#include <QLocale>
|
||||
#include "fileselectwidget.h"
|
||||
#include "units.h"
|
||||
#include "exportdialog.h"
|
||||
|
||||
|
||||
ExportDialog::ExportDialog(QPrinter *printer, QWidget *parent)
|
||||
: QDialog(parent), _printer(printer)
|
||||
{
|
||||
int index;
|
||||
|
||||
_units = (QLocale::system().measurementSystem()
|
||||
== QLocale::ImperialSystem) ? QPrinter::Inch : QPrinter::Millimeter;
|
||||
|
||||
_fileSelect = new FileSelectWidget();
|
||||
_fileSelect->setFilter(tr("PDF files (*.pdf);;All files (*)"));
|
||||
_fileSelect->setFile(_printer->outputFileName());
|
||||
|
||||
_paperSize = new QComboBox();
|
||||
_paperSize->addItem("A3", QPrinter::A3);
|
||||
_paperSize->addItem("A4", QPrinter::A4);
|
||||
_paperSize->addItem("A5", QPrinter::A5);
|
||||
_paperSize->addItem("Tabloid", QPrinter::Tabloid);
|
||||
_paperSize->addItem("Legal", QPrinter::Legal);
|
||||
_paperSize->addItem("Letter", QPrinter::Letter);
|
||||
if ((index = _paperSize->findData(_printer->paperSize())) >= 0)
|
||||
_paperSize->setCurrentIndex(index);
|
||||
|
||||
_portrait = new QRadioButton(tr("Portrait"));
|
||||
_landscape = new QRadioButton(tr("Landscape"));
|
||||
QHBoxLayout *orientationLayout = new QHBoxLayout();
|
||||
orientationLayout->addWidget(_portrait);
|
||||
orientationLayout->addWidget(_landscape);
|
||||
if (_printer->orientation() == QPrinter::Portrait)
|
||||
_portrait->setChecked(true);
|
||||
else
|
||||
_landscape->setChecked(true);
|
||||
|
||||
qreal top, bottom, left, right;
|
||||
|
||||
_printer->getPageMargins(&left, &top, &right, &bottom, _units);
|
||||
QString us = _units == QPrinter::Inch ? tr("in") : tr("mm");
|
||||
_topMargin = new QDoubleSpinBox();
|
||||
_bottomMargin = new QDoubleSpinBox();
|
||||
_leftMargin = new QDoubleSpinBox();
|
||||
_rightMargin = new QDoubleSpinBox();
|
||||
_topMargin->setValue(top);
|
||||
_topMargin->setSuffix(UNIT_SPACE + us);
|
||||
_bottomMargin->setValue(bottom);
|
||||
_bottomMargin->setSuffix(UNIT_SPACE + us);
|
||||
_leftMargin->setValue(left);
|
||||
_leftMargin->setSuffix(UNIT_SPACE + us);
|
||||
_rightMargin->setValue(right);
|
||||
_rightMargin->setSuffix(UNIT_SPACE + us);
|
||||
if (_units == QPrinter::Inch) {
|
||||
_topMargin->setSingleStep(0.1);
|
||||
_bottomMargin->setSingleStep(0.1);
|
||||
_leftMargin->setSingleStep(0.1);
|
||||
_rightMargin->setSingleStep(0.1);
|
||||
}
|
||||
|
||||
QGridLayout *marginsLayout = new QGridLayout();
|
||||
marginsLayout->addWidget(_topMargin, 0, 0, 1, 2, Qt::AlignCenter);
|
||||
marginsLayout->addWidget(_leftMargin, 1, 0, 1, 1, Qt::AlignRight);
|
||||
marginsLayout->addWidget(_rightMargin, 1, 1, 1, 1, Qt::AlignLeft);
|
||||
marginsLayout->addWidget(_bottomMargin, 2, 0, 1, 2, Qt::AlignCenter);
|
||||
|
||||
#ifndef Q_OS_MAC
|
||||
QGroupBox *pageSetupBox = new QGroupBox(tr("Page Setup"));
|
||||
#endif // Q_OS_MAC
|
||||
QFormLayout *pageSetupLayout = new QFormLayout;
|
||||
pageSetupLayout->addRow(tr("Page size:"), _paperSize);
|
||||
pageSetupLayout->addRow(tr("Orientation:"), orientationLayout);
|
||||
pageSetupLayout->addRow(tr("Margins:"), marginsLayout);
|
||||
#ifdef Q_OS_MAC
|
||||
QFrame *line = new QFrame();
|
||||
line->setFrameShape(QFrame::HLine);
|
||||
line->setFrameShadow(QFrame::Sunken);
|
||||
pageSetupLayout->addRow(line);
|
||||
pageSetupLayout->addRow(tr("File:"), _fileSelect);
|
||||
#else // Q_OS_MAC
|
||||
pageSetupBox->setLayout(pageSetupLayout);
|
||||
#endif // Q_OS_MAC
|
||||
|
||||
#ifndef Q_OS_MAC
|
||||
QGroupBox *outputFileBox = new QGroupBox(tr("Output file"));
|
||||
QHBoxLayout *outputFileLayout = new QHBoxLayout();
|
||||
outputFileLayout->addWidget(_fileSelect);
|
||||
outputFileBox->setLayout(outputFileLayout);
|
||||
#endif // Q_OS_MAC
|
||||
|
||||
QDialogButtonBox *buttonBox = new QDialogButtonBox();
|
||||
buttonBox->addButton(tr("Export"), QDialogButtonBox::AcceptRole);
|
||||
buttonBox->addButton(QDialogButtonBox::Cancel);
|
||||
connect(buttonBox, SIGNAL(accepted()), this, SLOT(accept()));
|
||||
connect(buttonBox, SIGNAL(rejected()), this, SLOT(reject()));
|
||||
|
||||
QVBoxLayout *layout = new QVBoxLayout;
|
||||
#ifdef Q_OS_MAC
|
||||
layout->addLayout(pageSetupLayout);
|
||||
#else // Q_OS_MAC
|
||||
layout->addWidget(pageSetupBox);
|
||||
layout->addWidget(outputFileBox);
|
||||
#endif // Q_OS_MAC
|
||||
layout->addWidget(buttonBox);
|
||||
setLayout(layout);
|
||||
|
||||
setWindowTitle(tr("Export to PDF"));
|
||||
setWindowFlags(windowFlags() & ~Qt::WindowContextHelpButtonHint);
|
||||
}
|
||||
|
||||
bool ExportDialog::checkFile()
|
||||
{
|
||||
if (_fileSelect->file().isEmpty()) {
|
||||
QMessageBox::warning(this, tr("Error"), tr("No output file selected."));
|
||||
return false;
|
||||
}
|
||||
|
||||
QFile file(_fileSelect->file());
|
||||
QFileInfo fi(file);
|
||||
bool exists = fi.exists();
|
||||
bool opened = false;
|
||||
|
||||
if (exists && fi.isDir()) {
|
||||
QMessageBox::warning(this, tr("Error"), tr("%1 is a directory.")
|
||||
.arg(file.fileName()));
|
||||
return false;
|
||||
} else if ((exists && !fi.isWritable())
|
||||
|| !(opened = file.open(QFile::Append))) {
|
||||
QMessageBox::warning(this, tr("Error"), tr("%1 is not writable.")
|
||||
.arg(file.fileName()));
|
||||
return false;
|
||||
}
|
||||
if (opened) {
|
||||
file.close();
|
||||
if (!exists)
|
||||
file.remove();
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void ExportDialog::accept()
|
||||
{
|
||||
if (!checkFile())
|
||||
return;
|
||||
|
||||
QPrinter::Orientation orientation = _portrait->isChecked()
|
||||
? QPrinter::Portrait : QPrinter::Landscape;
|
||||
QPrinter::PaperSize paperSize = static_cast<QPrinter::PaperSize>
|
||||
(_paperSize->itemData(_paperSize->currentIndex()).toInt());
|
||||
|
||||
_printer->setOutputFormat(QPrinter::PdfFormat);
|
||||
_printer->setOutputFileName(_fileSelect->file());
|
||||
_printer->setPaperSize(paperSize);
|
||||
_printer->setOrientation(orientation);
|
||||
_printer->setPageMargins(_leftMargin->value(), _topMargin->value(),
|
||||
_rightMargin->value(), _bottomMargin->value(), _units);
|
||||
|
||||
QDialog::accept();
|
||||
}
|
39
src/exportdialog.h
Normal file
39
src/exportdialog.h
Normal file
@ -0,0 +1,39 @@
|
||||
#ifndef EXPORTDIALOG_H
|
||||
#define EXPORTDIALOG_H
|
||||
|
||||
#include <QDialog>
|
||||
#include <QPrinter>
|
||||
|
||||
class QComboBox;
|
||||
class QRadioButton;
|
||||
class FileSelectWidget;
|
||||
class QDoubleSpinBox;
|
||||
|
||||
class ExportDialog : public QDialog
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
ExportDialog(QPrinter *printer, QWidget *parent = 0);
|
||||
|
||||
public slots:
|
||||
void accept();
|
||||
|
||||
private:
|
||||
bool checkFile();
|
||||
|
||||
QPrinter *_printer;
|
||||
|
||||
QPrinter::Unit _units;
|
||||
|
||||
FileSelectWidget *_fileSelect;
|
||||
QComboBox *_paperSize;
|
||||
QRadioButton *_portrait;
|
||||
QRadioButton *_landscape;
|
||||
QDoubleSpinBox *_topMargin;
|
||||
QDoubleSpinBox *_bottomMargin;
|
||||
QDoubleSpinBox *_leftMargin;
|
||||
QDoubleSpinBox *_rightMargin;
|
||||
};
|
||||
|
||||
#endif // EXPORTDIALOG_H
|
@ -41,12 +41,12 @@ void FileBrowser::setFilter(const QStringList &filter)
|
||||
reloadDirectory(_files.last().canonicalPath());
|
||||
}
|
||||
|
||||
bool FileBrowser::isLast()
|
||||
bool FileBrowser::isLast() const
|
||||
{
|
||||
return (_files.size() > 0 && _index == _files.size() - 1);
|
||||
}
|
||||
|
||||
bool FileBrowser::isFirst()
|
||||
bool FileBrowser::isFirst() const
|
||||
{
|
||||
return (_files.size() > 0 && _index == 0);
|
||||
}
|
||||
|
@ -23,8 +23,8 @@ public:
|
||||
QString last();
|
||||
QString first();
|
||||
|
||||
bool isLast();
|
||||
bool isFirst();
|
||||
bool isLast() const;
|
||||
bool isFirst() const;
|
||||
|
||||
private slots:
|
||||
void reloadDirectory(const QString &path);
|
||||
|
33
src/fileselectwidget.cpp
Normal file
33
src/fileselectwidget.cpp
Normal file
@ -0,0 +1,33 @@
|
||||
#include <QPushButton>
|
||||
#include <QFileDialog>
|
||||
#include <QHBoxLayout>
|
||||
#include <QFileInfo>
|
||||
#include <QApplication>
|
||||
#include <QFontMetrics>
|
||||
#include "fileselectwidget.h"
|
||||
|
||||
|
||||
FileSelectWidget::FileSelectWidget(QWidget *parent) : QWidget(parent)
|
||||
{
|
||||
QFontMetrics fm(QApplication::font());
|
||||
_edit = new QLineEdit();
|
||||
_edit->setMinimumWidth(fm.boundingRect(QDir::homePath()).width());
|
||||
_button = new QPushButton(tr("Browse..."));
|
||||
connect(_button, SIGNAL(clicked()), this, SLOT(browse()));
|
||||
|
||||
QHBoxLayout *layout = new QHBoxLayout();
|
||||
layout->setMargin(0);
|
||||
layout->addWidget(_edit);
|
||||
layout->addWidget(_button);
|
||||
setLayout(layout);
|
||||
}
|
||||
|
||||
void FileSelectWidget::browse()
|
||||
{
|
||||
QFileInfo fi(_edit->text());
|
||||
QString fileName = QFileDialog::getSaveFileName(this, tr("Select file"),
|
||||
fi.dir().absolutePath(), _filter);
|
||||
|
||||
if (!fileName.isEmpty())
|
||||
_edit->setText(fileName);
|
||||
}
|
30
src/fileselectwidget.h
Normal file
30
src/fileselectwidget.h
Normal file
@ -0,0 +1,30 @@
|
||||
#ifndef FILESELECTWIDGET_H
|
||||
#define FILESELECTWIDGET_H
|
||||
|
||||
#include <QWidget>
|
||||
#include <QLineEdit>
|
||||
|
||||
class QPushButton;
|
||||
|
||||
class FileSelectWidget : public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
FileSelectWidget(QWidget *parent = 0);
|
||||
|
||||
QString file() {return _edit->text();}
|
||||
void setFile(const QString &file) {_edit->setText(file);}
|
||||
void setFilter(const QString &filter) {_filter = filter;}
|
||||
|
||||
private slots:
|
||||
void browse();
|
||||
|
||||
private:
|
||||
QLineEdit *_edit;
|
||||
QPushButton *_button;
|
||||
|
||||
QString _filter;
|
||||
};
|
||||
|
||||
#endif // FILESELECTWIDGET_H
|
@ -12,22 +12,22 @@
|
||||
class GPX
|
||||
{
|
||||
public:
|
||||
GPX() : _parser(_tracks, _waypoints) {}
|
||||
GPX() : _parser(_tracks, _waypoints), _errorLine(0) {}
|
||||
bool loadFile(const QString &fileName);
|
||||
const QString &errorString() const {return _error;}
|
||||
int errorLine() const {return _errorLine;}
|
||||
|
||||
int trackCount() const {return _tracks.count();}
|
||||
Track track(int i) const {return Track(_tracks.at(i));}
|
||||
const QList<WayPoint> &waypoints() const {return _waypoints;}
|
||||
const QList<Waypoint> &waypoints() const {return _waypoints;}
|
||||
|
||||
private:
|
||||
Parser _parser;
|
||||
QString _error;
|
||||
int _errorLine;
|
||||
|
||||
QList<QVector<TrackPoint> > _tracks;
|
||||
QList<WayPoint> _waypoints;
|
||||
QList<QVector<Trackpoint> > _tracks;
|
||||
QList<Waypoint> _waypoints;
|
||||
};
|
||||
|
||||
#endif // GPX_H
|
||||
|
@ -1,8 +1,8 @@
|
||||
#include <float.h>
|
||||
#include <QGraphicsView>
|
||||
#include <QGraphicsSceneMouseEvent>
|
||||
#include <QEvent>
|
||||
#include <QGraphicsSimpleTextItem>
|
||||
#include <QPaintEngine>
|
||||
#include <QPaintDevice>
|
||||
#include "config.h"
|
||||
#include "axisitem.h"
|
||||
#include "slideritem.h"
|
||||
@ -28,6 +28,9 @@ GraphView::GraphView(QWidget *parent)
|
||||
_scene = new Scene(this);
|
||||
setScene(_scene);
|
||||
|
||||
setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
|
||||
setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
|
||||
|
||||
_xAxis = new AxisItem(AxisItem::X);
|
||||
_yAxis = new AxisItem(AxisItem::Y);
|
||||
|
||||
@ -44,15 +47,14 @@ GraphView::GraphView(QWidget *parent)
|
||||
_sliderInfo = new SliderInfoItem(_slider);
|
||||
_sliderInfo->setZValue(2.0);
|
||||
|
||||
_xMax = -FLT_MAX;
|
||||
_xMin = FLT_MAX;
|
||||
_yMax = -FLT_MAX;
|
||||
_yMin = FLT_MAX;
|
||||
|
||||
_xScale = 1;
|
||||
_yScale = 1;
|
||||
_yOffset = 0;
|
||||
|
||||
_precision = 0;
|
||||
_minYRange = 0.01;
|
||||
|
||||
_sliderPos = 0;
|
||||
}
|
||||
|
||||
GraphView::~GraphView()
|
||||
@ -67,20 +69,18 @@ GraphView::~GraphView()
|
||||
|
||||
if (_info->scene() != _scene)
|
||||
delete _info;
|
||||
|
||||
delete _scene;
|
||||
}
|
||||
|
||||
void GraphView::updateBounds(const QPointF &point)
|
||||
{
|
||||
if (point.x() < _xMin)
|
||||
_xMin = point.x();
|
||||
if (point.x() > _xMax)
|
||||
_xMax = point.x();
|
||||
if (point.y() < _yMin)
|
||||
_yMin = point.y();
|
||||
if (point.y() > _yMax)
|
||||
_yMax = point.y();
|
||||
if (point.x() < _bounds.left())
|
||||
_bounds.setLeft(point.x());
|
||||
if (point.x() > _bounds.right())
|
||||
_bounds.setRight(point.x());
|
||||
if (point.y() > _bounds.bottom())
|
||||
_bounds.setBottom(point.y());
|
||||
if (point.y() < _bounds.top())
|
||||
_bounds.setTop(point.y());
|
||||
}
|
||||
|
||||
void GraphView::createXLabel()
|
||||
@ -117,56 +117,45 @@ void GraphView::setYUnits(const QString &units)
|
||||
createYLabel();
|
||||
}
|
||||
|
||||
void GraphView::setXScale(qreal scale)
|
||||
{
|
||||
_xScale = scale;
|
||||
}
|
||||
|
||||
void GraphView::setYScale(qreal scale)
|
||||
{
|
||||
_yScale = scale;
|
||||
}
|
||||
|
||||
void GraphView::loadData(const QVector<QPointF> &data)
|
||||
{
|
||||
QPainterPath path;
|
||||
QGraphicsPathItem *pi;
|
||||
QColor color = _colorShop.color();
|
||||
|
||||
|
||||
if (data.size() < 2)
|
||||
return;
|
||||
|
||||
if (!_graphs.size())
|
||||
_bounds.moveTo(data.at(0));
|
||||
|
||||
updateBounds(data.at(0));
|
||||
path.moveTo(data.at(0).x(), -data.at(0).y());
|
||||
for (int i = 1; i < data.size(); i++) {
|
||||
path.lineTo(data.at(i).x(), -data.at(i).y());
|
||||
updateBounds(data.at(i));
|
||||
const QPointF &p = data.at(i);
|
||||
path.lineTo(p.x(), -p.y());
|
||||
updateBounds(p);
|
||||
}
|
||||
|
||||
pi = new QGraphicsPathItem(path);
|
||||
QBrush brush(color, Qt::SolidPattern);
|
||||
QBrush brush(_palette.color(), Qt::SolidPattern);
|
||||
QPen pen(brush, 0);
|
||||
pi->setPen(pen);
|
||||
_scene->addItem(pi);
|
||||
_graphs.append(pi);
|
||||
|
||||
if (_graphs.size() > 1)
|
||||
_sliderInfo->hide();
|
||||
|
||||
redraw();
|
||||
}
|
||||
|
||||
void GraphView::redraw()
|
||||
{
|
||||
if (!_graphs.isEmpty())
|
||||
resize(viewport()->size() - QSizeF(MARGIN, MARGIN));
|
||||
redraw(viewport()->size() - QSizeF(MARGIN, MARGIN));
|
||||
}
|
||||
|
||||
void GraphView::resize(const QSizeF &size)
|
||||
void GraphView::redraw(const QSizeF &size)
|
||||
{
|
||||
QRectF r;
|
||||
QSizeF mx, my;
|
||||
RangeF rx, ry;
|
||||
QTransform transform;
|
||||
qreal xs, ys;
|
||||
|
||||
@ -183,11 +172,22 @@ void GraphView::resize(const QSizeF &size)
|
||||
for (int i = 0; i < _graphs.size(); i++)
|
||||
_graphs.at(i)->resetTransform();
|
||||
|
||||
_xAxis->setRange(QPointF(_xMin * _xScale, _xMax * _xScale));
|
||||
_yAxis->setRange(QPointF(_yMin * _yScale, _yMax * _yScale));
|
||||
rx = RangeF(_bounds.left() * _xScale, _bounds.right() * _xScale);
|
||||
ry = RangeF(_bounds.top() * _yScale + _yOffset, _bounds.bottom() * _yScale
|
||||
+ _yOffset);
|
||||
if (ry.size() < _minYRange)
|
||||
ry.resize(_minYRange);
|
||||
|
||||
_xAxis->setRange(rx);
|
||||
_yAxis->setRange(ry);
|
||||
mx = _xAxis->margin();
|
||||
my = _yAxis->margin();
|
||||
|
||||
r = _scene->itemsBoundingRect();
|
||||
if (r.height() < _minYRange)
|
||||
r.adjust(0, -(_minYRange/2 - r.height()/2), 0,
|
||||
_minYRange/2 - r.height()/2);
|
||||
|
||||
xs = (size.width() - (my.width() + mx.width())) / r.width();
|
||||
ys = (size.height() - (mx.height() + my.height())
|
||||
- _info->boundingRect().height()) / r.height();
|
||||
@ -197,6 +197,10 @@ void GraphView::resize(const QSizeF &size)
|
||||
_graphs.at(i)->setTransform(transform);
|
||||
|
||||
r = _scene->itemsBoundingRect();
|
||||
if (r.height() < _minYRange * ys)
|
||||
r.adjust(0, -(_minYRange/2 * ys - r.height()/2), 0,
|
||||
(_minYRange/2) * ys - r.height()/2);
|
||||
|
||||
_xAxis->setSize(r.width());
|
||||
_yAxis->setSize(r.height());
|
||||
_xAxis->setPos(r.bottomLeft());
|
||||
@ -204,16 +208,14 @@ void GraphView::resize(const QSizeF &size)
|
||||
_scene->addItem(_xAxis);
|
||||
_scene->addItem(_yAxis);
|
||||
|
||||
qreal sp = (_slider->pos().x() == _slider->area().left())
|
||||
? 0 : (_slider->pos().x() - _slider->area().left())
|
||||
/ _slider->area().width();
|
||||
_slider->setArea(r);
|
||||
_slider->setPos(QPointF(sp * r.width(), r.bottom()));
|
||||
if (_sliderPos > _bounds.right() || _sliderPos < _bounds.left())
|
||||
_slider->setVisible(false);
|
||||
_slider->setPos((_sliderPos / _bounds.width()) * _slider->area().width(),
|
||||
r.bottom());
|
||||
_scene->addItem(_slider);
|
||||
|
||||
const QPainterPath &path = _graphs.at(0)->path();
|
||||
QPointF p = path.pointAtPercent(sp);
|
||||
_sliderInfo->setText(QString::number(-p.y() * _yScale, 'f', _precision));
|
||||
updateSliderInfo();
|
||||
|
||||
r = _scene->itemsBoundingRect();
|
||||
_info->setPos(r.topLeft() + QPointF(r.width()/2
|
||||
@ -231,17 +233,18 @@ void GraphView::resizeEvent(QResizeEvent *)
|
||||
|
||||
void GraphView::plot(QPainter *painter, const QRectF &target)
|
||||
{
|
||||
qreal ratio = target.width() / target.height();
|
||||
QSizeF orig = _scene->sceneRect().size();
|
||||
QSizeF canvas = QSizeF(orig.height() * ratio, orig.height());
|
||||
qreal ratio = painter->paintEngine()->paintDevice()->logicalDpiX()
|
||||
/ SCREEN_DPI;
|
||||
QSizeF canvas = QSizeF(target.width() / ratio, target.height() / ratio);
|
||||
|
||||
resize(canvas);
|
||||
_slider->hide();
|
||||
_info->hide();
|
||||
_scene->render(painter, target, QRectF());
|
||||
setUpdatesEnabled(false);
|
||||
redraw(canvas);
|
||||
if (_slider->pos().x() == _slider->area().left())
|
||||
_slider->hide();
|
||||
_scene->render(painter, target);
|
||||
_slider->show();
|
||||
_info->show();
|
||||
resize(orig);
|
||||
redraw();
|
||||
setUpdatesEnabled(true);
|
||||
}
|
||||
|
||||
void GraphView::clear()
|
||||
@ -250,58 +253,111 @@ void GraphView::clear()
|
||||
_scene->removeItem(_xAxis);
|
||||
if (_yAxis->scene() == _scene)
|
||||
_scene->removeItem(_yAxis);
|
||||
|
||||
if (_slider->scene() == _scene)
|
||||
_scene->removeItem(_slider);
|
||||
|
||||
if (_info->scene() == _scene)
|
||||
_scene->removeItem(_info);
|
||||
_sliderInfo->show();
|
||||
|
||||
_slider->clear();
|
||||
_info->clear();
|
||||
_scene->clear();
|
||||
_graphs.clear();
|
||||
_colorShop.reset();
|
||||
_palette.reset();
|
||||
|
||||
_xMax = -FLT_MAX;
|
||||
_xMin = FLT_MAX;
|
||||
_yMax = -FLT_MAX;
|
||||
_yMin = FLT_MAX;
|
||||
_bounds = QRectF();
|
||||
_sliderPos = 0;
|
||||
|
||||
_scene->setSceneRect(0, 0, 0, 0);
|
||||
}
|
||||
|
||||
static qreal yAtX(const QPainterPath &path, qreal x)
|
||||
{
|
||||
int low = 0;
|
||||
int high = path.elementCount() - 1;
|
||||
int mid = 0;
|
||||
|
||||
Q_ASSERT(high > low);
|
||||
Q_ASSERT(x >= path.elementAt(low).x && x <= path.elementAt(high).x);
|
||||
|
||||
while (low <= high) {
|
||||
mid = low + ((high - low) / 2);
|
||||
const QPainterPath::Element &e = path.elementAt(mid);
|
||||
if (e.x > x)
|
||||
high = mid - 1;
|
||||
else if (e.x < x)
|
||||
low = mid + 1;
|
||||
else
|
||||
return e.y;
|
||||
}
|
||||
|
||||
QLineF l;
|
||||
if (path.elementAt(mid).x < x)
|
||||
l = QLineF(path.elementAt(mid).x, path.elementAt(mid).y,
|
||||
path.elementAt(mid+1).x, path.elementAt(mid+1).y);
|
||||
else
|
||||
l = QLineF(path.elementAt(mid-1).x, path.elementAt(mid-1).y,
|
||||
path.elementAt(mid).x, path.elementAt(mid).y);
|
||||
|
||||
return l.pointAt((x - l.p1().x()) / (l.p2().x() - l.p1().x())).y();
|
||||
}
|
||||
|
||||
void GraphView::updateSliderInfo()
|
||||
{
|
||||
_sliderInfo->setVisible(_graphs.size() == 1);
|
||||
|
||||
if (!_slider->isVisible())
|
||||
return;
|
||||
|
||||
const QPainterPath &path = _graphs.at(0)->path();
|
||||
QRectF br = path.boundingRect();
|
||||
if (br.height() < _minYRange)
|
||||
br.adjust(0, -(_minYRange/2 - br.height()/2), 0,
|
||||
_minYRange/2 - br.height()/2);
|
||||
|
||||
qreal y = yAtX(path, _sliderPos);
|
||||
qreal r = (y - br.bottom()) / br.height();
|
||||
|
||||
qreal pos = (_sliderPos / _bounds.width()) * _slider->area().width();
|
||||
SliderInfoItem::Side s = (pos + _sliderInfo->boundingRect().width()
|
||||
> _slider->area().right()) ? SliderInfoItem::Left : SliderInfoItem::Right;
|
||||
|
||||
_sliderInfo->setSide(s);
|
||||
_sliderInfo->setPos(QPointF(0, _slider->boundingRect().height() * r));
|
||||
_sliderInfo->setText(QString::number(-y * _yScale + _yOffset, 'f',
|
||||
_precision));
|
||||
}
|
||||
|
||||
void GraphView::emitSliderPositionChanged(const QPointF &pos)
|
||||
{
|
||||
if (_graphs.isEmpty())
|
||||
return;
|
||||
|
||||
qreal val = pos.x() / _slider->area().width();
|
||||
emit sliderPositionChanged(val);
|
||||
_sliderPos = (pos.x() / _slider->area().width()) * _bounds.width();
|
||||
emit sliderPositionChanged(_sliderPos);
|
||||
|
||||
const QPainterPath &path = _graphs.at(0)->path();
|
||||
QPointF p = path.pointAtPercent(val);
|
||||
qreal r = (p.y() - path.boundingRect().bottom())
|
||||
/ path.boundingRect().height();
|
||||
_sliderInfo->setPos(QPointF(0, _slider->boundingRect().height() * r));
|
||||
_sliderInfo->setText(QString::number(-p.y() * _yScale, 'f', _precision));
|
||||
}
|
||||
|
||||
qreal GraphView::sliderPosition() const
|
||||
{
|
||||
return _slider->pos().x() / _slider->area().width();
|
||||
updateSliderInfo();
|
||||
}
|
||||
|
||||
void GraphView::setSliderPosition(qreal pos)
|
||||
{
|
||||
_slider->setPos(pos * _slider->area().width(), 0);
|
||||
_sliderPos = pos;
|
||||
|
||||
if (_graphs.isEmpty())
|
||||
return;
|
||||
|
||||
if (pos > _bounds.right() || pos < _bounds.left())
|
||||
_slider->setVisible(false);
|
||||
else {
|
||||
_slider->setPos((pos / _bounds.width()) * _slider->area().width(), 0);
|
||||
_slider->setVisible(true);
|
||||
}
|
||||
}
|
||||
|
||||
void GraphView::newSliderPosition(const QPointF &pos)
|
||||
{
|
||||
if (_slider->area().contains(pos)) {
|
||||
_slider->setPos(pos);
|
||||
_slider->setVisible(true);
|
||||
emitSliderPositionChanged(pos);
|
||||
}
|
||||
}
|
||||
|
@ -6,7 +6,7 @@
|
||||
#include <QVector>
|
||||
#include <QList>
|
||||
#include <QPointF>
|
||||
#include "colorshop.h"
|
||||
#include "palette.h"
|
||||
|
||||
|
||||
class AxisItem;
|
||||
@ -35,35 +35,46 @@ public:
|
||||
~GraphView();
|
||||
|
||||
void loadData(const QVector<QPointF> &data);
|
||||
|
||||
void redraw();
|
||||
void clear();
|
||||
|
||||
int count() const {return _graphs.count();}
|
||||
|
||||
const QString &xLabel() const {return _xLabel;}
|
||||
const QString &yLabel() const {return _yLabel;}
|
||||
const QString &xUnits() const {return _xUnits;}
|
||||
const QString &yUnits() const {return _yUnits;}
|
||||
qreal xScale() const {return _xScale;}
|
||||
qreal yScale() const {return _yScale;}
|
||||
qreal yOffset() const {return _yOffset;}
|
||||
|
||||
void setXLabel(const QString &label);
|
||||
void setYLabel(const QString &label);
|
||||
void setXUnits(const QString &units);
|
||||
void setYUnits(const QString &units);
|
||||
void setXScale(qreal scale);
|
||||
void setYScale(qreal scale);
|
||||
void setPrecision(int p) {_precision = p;}
|
||||
void setXScale(qreal scale) {_xScale = scale;}
|
||||
void setYScale(qreal scale) {_yScale = scale;}
|
||||
void setYOffset(qreal offset) {_yOffset = offset;}
|
||||
|
||||
void redraw();
|
||||
void setSliderPrecision(int precision) {_precision = precision;}
|
||||
void setMinYRange(qreal range) {_minYRange = range;}
|
||||
|
||||
void plot(QPainter *painter, const QRectF &target);
|
||||
void clear();
|
||||
|
||||
qreal sliderPosition() const;
|
||||
qreal sliderPosition() const {return _sliderPos;}
|
||||
void setSliderPosition(qreal pos);
|
||||
|
||||
void addInfo(const QString &key, const QString &value);
|
||||
void clearInfo();
|
||||
void plot(QPainter *painter, const QRectF &target);
|
||||
|
||||
signals:
|
||||
void sliderPositionChanged(qreal);
|
||||
|
||||
protected:
|
||||
const QRectF &bounds() const {return _bounds;}
|
||||
void resizeEvent(QResizeEvent *);
|
||||
|
||||
qreal _xScale, _yScale;
|
||||
QString _xUnits, _yUnits;
|
||||
QString _xLabel, _yLabel;
|
||||
int _precision;
|
||||
void redraw(const QSizeF &size);
|
||||
void addInfo(const QString &key, const QString &value);
|
||||
void clearInfo();
|
||||
void skipColor() {_palette.color();}
|
||||
|
||||
private slots:
|
||||
void emitSliderPositionChanged(const QPointF &pos);
|
||||
@ -73,7 +84,15 @@ private:
|
||||
void createXLabel();
|
||||
void createYLabel();
|
||||
void updateBounds(const QPointF &point);
|
||||
void resize(const QSizeF &size);
|
||||
void updateSliderInfo();
|
||||
|
||||
qreal _xScale, _yScale;
|
||||
qreal _yOffset;
|
||||
QString _xUnits, _yUnits;
|
||||
QString _xLabel, _yLabel;
|
||||
int _precision;
|
||||
qreal _minYRange;
|
||||
qreal _sliderPos;
|
||||
|
||||
Scene *_scene;
|
||||
|
||||
@ -83,8 +102,8 @@ private:
|
||||
InfoItem *_info;
|
||||
|
||||
QList<QGraphicsPathItem*> _graphs;
|
||||
qreal _xMin, _xMax, _yMin, _yMax;
|
||||
ColorShop _colorShop;
|
||||
QRectF _bounds;
|
||||
Palette _palette;
|
||||
};
|
||||
|
||||
#endif // GRAPHVIEW_H
|
||||
|
772
src/gui.cpp
772
src/gui.cpp
File diff suppressed because it is too large
Load Diff
94
src/gui.h
94
src/gui.h
@ -2,19 +2,27 @@
|
||||
#define GUI_H
|
||||
|
||||
#include <QMainWindow>
|
||||
#include <QMenu>
|
||||
#include <QToolBar>
|
||||
#include <QTabWidget>
|
||||
#include <QGraphicsView>
|
||||
#include <QActionGroup>
|
||||
#include <QAction>
|
||||
#include <QLabel>
|
||||
#include <QString>
|
||||
#include <QList>
|
||||
#include <QDate>
|
||||
#include <QPrinter>
|
||||
#include "poi.h"
|
||||
#include "margins.h"
|
||||
|
||||
|
||||
class QMenu;
|
||||
class QToolBar;
|
||||
class QTabWidget;
|
||||
class QActionGroup;
|
||||
class QAction;
|
||||
class QLabel;
|
||||
class QSignalMapper;
|
||||
class QPrinter;
|
||||
class FileBrowser;
|
||||
class GraphView;
|
||||
class ElevationGraph;
|
||||
class SpeedGraph;
|
||||
class HeartRateGraph;
|
||||
class TemperatureGraph;
|
||||
class TrackView;
|
||||
class Map;
|
||||
|
||||
@ -24,6 +32,7 @@ class GUI : public QMainWindow
|
||||
|
||||
public:
|
||||
GUI(QWidget *parent = 0);
|
||||
~GUI();
|
||||
|
||||
bool openFile(const QString &fileName);
|
||||
|
||||
@ -31,19 +40,25 @@ private slots:
|
||||
void about();
|
||||
void keys();
|
||||
void dataSources();
|
||||
void saveFile();
|
||||
void saveAs();
|
||||
void printFile();
|
||||
void exportFile();
|
||||
void openFile();
|
||||
void closeFile();
|
||||
void closeAll();
|
||||
void reloadFile();
|
||||
void openPOIFile();
|
||||
void closePOIFiles();
|
||||
void showPOI(bool checked);
|
||||
void showMap(bool checked);
|
||||
void showGraphs(bool checked);
|
||||
void showToolbars(bool checked);
|
||||
void showFullscreen(bool checked);
|
||||
void clearMapCache();
|
||||
void nextMap();
|
||||
void prevMap();
|
||||
|
||||
void mapChanged(int);
|
||||
void graphChanged(int);
|
||||
void poiFileChecked(int);
|
||||
|
||||
void next();
|
||||
void prev();
|
||||
@ -53,9 +68,19 @@ private slots:
|
||||
void setMetricUnits();
|
||||
void setImperialUnits();
|
||||
|
||||
private:
|
||||
void loadFiles();
|
||||
void sliderPositionChanged(qreal pos);
|
||||
|
||||
private:
|
||||
typedef QPair<GraphView *, QString> GraphTab;
|
||||
typedef QPair<QDate, QDate> DateRange;
|
||||
|
||||
void loadMaps();
|
||||
void loadPOIs();
|
||||
void closeFiles();
|
||||
void plot(QPrinter *printer);
|
||||
|
||||
QAction *createPOIFileAction(int index);
|
||||
void createPOIFilesActions();
|
||||
void createMapActions();
|
||||
void createActions();
|
||||
void createMenus();
|
||||
@ -64,12 +89,21 @@ private:
|
||||
void createTrackView();
|
||||
void createTrackGraphs();
|
||||
|
||||
bool openPOIFile(const QString &fileName);
|
||||
bool loadFile(const QString &fileName);
|
||||
void saveFile(const QString &fileName);
|
||||
void exportFile(const QString &fileName);
|
||||
void updateStatusBarInfo();
|
||||
void updateWindowTitle();
|
||||
void updateNavigationActions();
|
||||
void updateGraphTabs();
|
||||
void updateTrackView();
|
||||
|
||||
void keyPressEvent(QKeyEvent * event);
|
||||
void closeEvent(QCloseEvent *event);
|
||||
|
||||
int mapIndex(const QString &name);
|
||||
void readSettings();
|
||||
void writeSettings();
|
||||
|
||||
QMenu *_fileMenu;
|
||||
QMenu *_helpMenu;
|
||||
@ -77,6 +111,7 @@ private:
|
||||
QMenu *_mapMenu;
|
||||
QMenu *_settingsMenu;
|
||||
QMenu *_unitsMenu;
|
||||
QMenu *_poiFilesMenu;
|
||||
|
||||
QToolBar *_fileToolBar;
|
||||
QToolBar *_showToolBar;
|
||||
@ -90,14 +125,17 @@ private:
|
||||
QAction *_dataSourcesAction;
|
||||
QAction *_aboutAction;
|
||||
QAction *_aboutQtAction;
|
||||
QAction *_saveFileAction;
|
||||
QAction *_saveAsAction;
|
||||
QAction *_printFileAction;
|
||||
QAction *_exportFileAction;
|
||||
QAction *_openFileAction;
|
||||
QAction *_closeFileAction;
|
||||
QAction *_reloadFileAction;
|
||||
QAction *_openPOIAction;
|
||||
QAction *_closePOIAction;
|
||||
QAction *_showPOIAction;
|
||||
QAction *_showMapAction;
|
||||
QAction *_fullscreenAction;
|
||||
QAction *_clearMapCacheAction;
|
||||
QAction *_showGraphsAction;
|
||||
QAction *_showToolbarsAction;
|
||||
QAction *_nextAction;
|
||||
@ -106,27 +144,45 @@ private:
|
||||
QAction *_firstAction;
|
||||
QAction *_metricUnitsAction;
|
||||
QAction *_imperialUnitsAction;
|
||||
QAction *_nextMapAction;
|
||||
QAction *_prevMapAction;
|
||||
QList<QAction*> _mapActions;
|
||||
QList<QAction*> _poiFilesActions;
|
||||
|
||||
QSignalMapper *_poiFilesSM;
|
||||
|
||||
QLabel *_fileNameLabel;
|
||||
QLabel *_distanceLabel;
|
||||
QLabel *_timeLabel;
|
||||
|
||||
TrackView *_track;
|
||||
ElevationGraph *_elevationGraph;
|
||||
SpeedGraph *_speedGraph;
|
||||
TrackView *_track;
|
||||
HeartRateGraph *_heartRateGraph;
|
||||
TemperatureGraph *_temperatureGraph;
|
||||
QList<GraphTab> _tabs;
|
||||
|
||||
POI _poi;
|
||||
QList<Map*> _maps;
|
||||
|
||||
FileBrowser *_browser;
|
||||
QList<QString> _files;
|
||||
QString _saveFileName;
|
||||
Map *_currentMap;
|
||||
|
||||
int _trackCount;
|
||||
qreal _distance;
|
||||
qreal _time;
|
||||
int _trackCount;
|
||||
DateRange _dateRange;
|
||||
|
||||
qreal _sliderPos;
|
||||
|
||||
int _frameStyle;
|
||||
bool _showGraphs;
|
||||
|
||||
QString _exportFileName;
|
||||
QPrinter::PaperSize _exportPaperSize;
|
||||
QPrinter::Orientation _exportOrientation;
|
||||
MarginsF _exportMargins;
|
||||
};
|
||||
|
||||
#endif // GUI_H
|
||||
|
99
src/heartrategraph.cpp
Normal file
99
src/heartrategraph.cpp
Normal file
@ -0,0 +1,99 @@
|
||||
#include "gpx.h"
|
||||
#include "heartrategraph.h"
|
||||
|
||||
|
||||
HeartRateGraph::HeartRateGraph(QWidget *parent) : GraphView(parent)
|
||||
{
|
||||
_units = Metric;
|
||||
|
||||
GraphView::setYUnits(tr("1/min"));
|
||||
setXLabel(tr("Distance"));
|
||||
setYLabel(tr("Heart rate"));
|
||||
|
||||
setSliderPrecision(0);
|
||||
}
|
||||
|
||||
void HeartRateGraph::addInfo()
|
||||
{
|
||||
GraphView::addInfo(tr("Average"), QString::number(avg() * yScale(), 'f', 0)
|
||||
+ UNIT_SPACE + yUnits());
|
||||
GraphView::addInfo(tr("Maximum"), QString::number(max() * yScale(), 'f', 0)
|
||||
+ UNIT_SPACE + yUnits());
|
||||
|
||||
redraw();
|
||||
}
|
||||
|
||||
void HeartRateGraph::loadGPX(const GPX &gpx)
|
||||
{
|
||||
for (int i = 0; i < gpx.trackCount(); i++) {
|
||||
QVector<QPointF> data;
|
||||
qreal sum = 0, w = 0;
|
||||
|
||||
gpx.track(i).heartRateGraph(data);
|
||||
if (data.count() < 2) {
|
||||
skipColor();
|
||||
continue;
|
||||
}
|
||||
|
||||
for (int j = 1; j < data.size(); j++) {
|
||||
sum += data.at(j).y() * (data.at(j).x() - data.at(j-1).x());
|
||||
w += data.at(j).x() - data.at(j-1).x();
|
||||
}
|
||||
_avg.append(QPointF(gpx.track(i).distance(), sum/w));
|
||||
|
||||
loadData(data);
|
||||
}
|
||||
|
||||
setXUnits();
|
||||
addInfo();
|
||||
}
|
||||
|
||||
qreal HeartRateGraph::avg() const
|
||||
{
|
||||
qreal sum = 0, w = 0;
|
||||
QList<QPointF>::const_iterator it;
|
||||
|
||||
for (it = _avg.begin(); it != _avg.end(); it++) {
|
||||
sum += it->y() * it->x();
|
||||
w += it->x();
|
||||
}
|
||||
|
||||
return (sum / w);
|
||||
}
|
||||
|
||||
void HeartRateGraph::clear()
|
||||
{
|
||||
_avg.clear();
|
||||
|
||||
GraphView::clear();
|
||||
}
|
||||
|
||||
void HeartRateGraph::setXUnits()
|
||||
{
|
||||
if (_units == Metric) {
|
||||
if (bounds().width() < KMINM) {
|
||||
GraphView::setXUnits(tr("m"));
|
||||
setXScale(1);
|
||||
} else {
|
||||
GraphView::setXUnits(tr("km"));
|
||||
setXScale(M2KM);
|
||||
}
|
||||
} else {
|
||||
if (bounds().width() < MIINM) {
|
||||
GraphView::setXUnits(tr("ft"));
|
||||
setXScale(M2FT);
|
||||
} else {
|
||||
GraphView::setXUnits(tr("mi"));
|
||||
setXScale(M2MI);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void HeartRateGraph::setUnits(enum Units units)
|
||||
{
|
||||
_units = units;
|
||||
setXUnits();
|
||||
|
||||
clearInfo();
|
||||
addInfo();
|
||||
}
|
31
src/heartrategraph.h
Normal file
31
src/heartrategraph.h
Normal file
@ -0,0 +1,31 @@
|
||||
#ifndef HEARTRATEGRAPH_H
|
||||
#define HEARTRATEGRAPH_H
|
||||
|
||||
#include "graphview.h"
|
||||
#include "units.h"
|
||||
|
||||
class GPX;
|
||||
|
||||
class HeartRateGraph : public GraphView
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
HeartRateGraph(QWidget *parent = 0);
|
||||
|
||||
void loadGPX(const GPX &gpx);
|
||||
void clear();
|
||||
void setUnits(enum Units units);
|
||||
|
||||
qreal avg() const;
|
||||
qreal max() const {return bounds().bottom();}
|
||||
|
||||
private:
|
||||
void setXUnits();
|
||||
void addInfo();
|
||||
|
||||
QList<QPointF> _avg;
|
||||
enum Units _units;
|
||||
};
|
||||
|
||||
#endif // HEARTRATEGRAPH_H
|
13
src/icons.h
13
src/icons.h
@ -1,12 +1,10 @@
|
||||
#ifndef ICONS_H
|
||||
#define ICONS_H
|
||||
|
||||
#include <QtGlobal>
|
||||
|
||||
#define APP_ICON ":/icons/gpxsee.png"
|
||||
#define OPEN_FILE_ICON ":/icons/document-open.png"
|
||||
#define SAVE_FILE_ICON ":/icons/document-save.png"
|
||||
#define SAVE_AS_ICON ":/icons/document-save-as.png"
|
||||
#define EXPORT_FILE_ICON ":/icons/document-export.png"
|
||||
#define PRINT_FILE_ICON ":/icons/document-print.png"
|
||||
#define CLOSE_FILE_ICON ":/icons/dialog-close.png"
|
||||
#define SHOW_POI_ICON ":/icons/flag.png"
|
||||
#define SHOW_MAP_ICON ":/icons/applications-internet.png"
|
||||
@ -16,11 +14,6 @@
|
||||
#define PREV_FILE_ICON ":/icons/arrow-left.png"
|
||||
#define LAST_FILE_ICON ":/icons/arrow-right-double.png"
|
||||
#define FIRST_FILE_ICON ":/icons/arrow-left-double.png"
|
||||
|
||||
#if QT_VERSION < QT_VERSION_CHECK(5, 0, 0)
|
||||
#define QT_ICON ":/trolltech/qmessagebox/images/qtlogo-64.png"
|
||||
#else
|
||||
#define QT_ICON ":/qt-project.org/qmessagebox/images/qtlogo-64.png"
|
||||
#endif
|
||||
#define FULLSCREEN_ICON ":/icons/view-fullscreen.png"
|
||||
|
||||
#endif /* ICONS_H */
|
||||
|
@ -65,18 +65,19 @@ void InfoItem::insert(const QString &key, const QString &value)
|
||||
KV kv(key, value);
|
||||
int i;
|
||||
|
||||
prepareGeometryChange();
|
||||
|
||||
if ((i = _list.indexOf(kv)) < 0)
|
||||
_list.append(kv);
|
||||
else
|
||||
_list[i] = kv;
|
||||
|
||||
updateBoundingRect();
|
||||
prepareGeometryChange();
|
||||
}
|
||||
|
||||
void InfoItem::clear()
|
||||
{
|
||||
prepareGeometryChange();
|
||||
_list.clear();
|
||||
updateBoundingRect();
|
||||
prepareGeometryChange();
|
||||
}
|
||||
|
@ -15,6 +15,7 @@ public:
|
||||
|
||||
void insert(const QString &key, const QString &value);
|
||||
void clear();
|
||||
bool isEmpty() {return _list.isEmpty();}
|
||||
|
||||
private:
|
||||
void updateBoundingRect();
|
||||
|
29
src/keys.h
29
src/keys.h
@ -1,10 +1,29 @@
|
||||
#ifndef KEYS_H
|
||||
#define KEYS_H
|
||||
|
||||
#define NEXT_KEY Qt::Key_Space
|
||||
#define PREV_KEY Qt::Key_Backspace
|
||||
#define FIRST_KEY Qt::Key_Home
|
||||
#define LAST_KEY Qt::Key_End
|
||||
#define MODIFIER Qt::ShiftModifier
|
||||
#include <Qt>
|
||||
#include <QKeySequence>
|
||||
|
||||
#define NEXT_KEY Qt::Key_Space
|
||||
#define PREV_KEY Qt::Key_Backspace
|
||||
#define FIRST_KEY Qt::Key_Home
|
||||
#define LAST_KEY Qt::Key_End
|
||||
#define MODIFIER Qt::ShiftModifier
|
||||
|
||||
#define QUIT_SHORTCUT QKeySequence::Quit
|
||||
#define OPEN_SHORTCUT QKeySequence::Open
|
||||
#define CLOSE_SHORTCUT QKeySequence::Close
|
||||
#define RELOAD_SHORTCUT QKeySequence::Refresh
|
||||
#define EXPORT_SHORTCUT QKeySequence(Qt::CTRL + Qt::Key_E)
|
||||
#define SHOW_POI_SHORTCUT QKeySequence(Qt::CTRL + Qt::Key_P)
|
||||
#define SHOW_MAP_SHORTCUT QKeySequence(Qt::CTRL + Qt::Key_M)
|
||||
#define NEXT_MAP_SHORTCUT QKeySequence::Forward
|
||||
#define PREV_MAP_SHORTCUT QKeySequence::Back
|
||||
#define SHOW_GRAPHS_SHORTCUT QKeySequence(Qt::CTRL + Qt::Key_G)
|
||||
#ifdef Q_OS_MAC
|
||||
#define FULLSCREEN_SHORTCUT QKeySequence(Qt::META + Qt::CTRL + Qt::Key_F)
|
||||
#else // Q_OS_MAC
|
||||
#define FULLSCREEN_SHORTCUT QKeySequence(Qt::Key_F11)
|
||||
#endif // Q_OS_MAC
|
||||
|
||||
#endif // KEYS_H
|
||||
|
27
src/main.cpp
27
src/main.cpp
@ -1,28 +1,9 @@
|
||||
#include <QApplication>
|
||||
#include <QTranslator>
|
||||
#include <QLocale>
|
||||
#include "gui.h"
|
||||
#include "icons.h"
|
||||
|
||||
#include "app.h"
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
QApplication app(argc, argv);
|
||||
App app(argc, argv);
|
||||
app.run();
|
||||
|
||||
QString locale = QLocale::system().name();
|
||||
QTranslator translator;
|
||||
translator.load(QString(":/lang/gpxsee_") + locale);
|
||||
app.installTranslator(&translator);
|
||||
#ifdef Q_OS_MAC
|
||||
app.setAttribute(Qt::AA_DontShowIconsInMenus);
|
||||
#endif // Q_OS_MAC
|
||||
|
||||
GUI gui;
|
||||
gui.setWindowIcon(QIcon(QPixmap(APP_ICON)));
|
||||
gui.show();
|
||||
|
||||
for (int i = 1; i < argc; i++)
|
||||
gui.openFile(argv[i]);
|
||||
|
||||
return app.exec();
|
||||
return 0;
|
||||
}
|
||||
|
120
src/map.cpp
120
src/map.cpp
@ -15,8 +15,8 @@ Map::Map(QObject *parent, const QString &name, const QString &url)
|
||||
connect(&Downloader::instance(), SIGNAL(finished()), this,
|
||||
SLOT(emitLoaded()));
|
||||
|
||||
QString path = QString(TILES_DIR"/") + _name;
|
||||
if (!QDir::home().mkpath(path))
|
||||
QString path = TILES_DIR + QString("/") + _name;
|
||||
if (!QDir().mkpath(path))
|
||||
fprintf(stderr, "Error creating tiles dir: %s\n", qPrintable(path));
|
||||
}
|
||||
|
||||
@ -25,33 +25,111 @@ void Map::emitLoaded()
|
||||
emit loaded();
|
||||
}
|
||||
|
||||
void Map::loadTiles(QList<Tile> &list)
|
||||
void Map::loadTiles(QList<Tile> &list, bool block)
|
||||
{
|
||||
if (block)
|
||||
loadTilesSync(list);
|
||||
else
|
||||
loadTilesAsync(list);
|
||||
}
|
||||
|
||||
void Map::loadTilesAsync(QList<Tile> &list)
|
||||
{
|
||||
QList<Download> dl;
|
||||
|
||||
for (int i = 0; i < list.size(); ++i) {
|
||||
for (int i = 0; i < list.size(); i++) {
|
||||
Tile &t = list[i];
|
||||
QString file = QString("%1/" TILES_DIR "/%2/%3-%4-%5")
|
||||
.arg(QDir::homePath()).arg(_name).arg(t.zoom()).arg(t.xy().rx())
|
||||
.arg(t.xy().ry());
|
||||
QString file = tileFile(t);
|
||||
QFileInfo fi(file);
|
||||
|
||||
if (fi.exists()) {
|
||||
if (!t.pixmap().load(file))
|
||||
fprintf(stderr, "Error loading map tile: %s\n",
|
||||
qPrintable(file));
|
||||
} else {
|
||||
t.pixmap() = QPixmap(TILE_SIZE, TILE_SIZE);
|
||||
t.pixmap().fill();
|
||||
|
||||
QString url(_url);
|
||||
url.replace("$z", QString::number(t.zoom()));
|
||||
url.replace("$x", QString::number(t.xy().x()));
|
||||
url.replace("$y", QString::number(t.xy().y()));
|
||||
dl.append(Download(url, file));
|
||||
}
|
||||
if (!fi.exists()) {
|
||||
fillTile(t);
|
||||
dl.append(Download(tileUrl(t), file));
|
||||
} else
|
||||
loadTileFile(t, file);
|
||||
}
|
||||
|
||||
if (!dl.empty())
|
||||
Downloader::instance().get(dl);
|
||||
}
|
||||
|
||||
void Map::loadTilesSync(QList<Tile> &list)
|
||||
{
|
||||
QList<Download> dl;
|
||||
|
||||
for (int i = 0; i < list.size(); i++) {
|
||||
Tile &t = list[i];
|
||||
QString file = tileFile(t);
|
||||
QFileInfo fi(file);
|
||||
|
||||
if (!fi.exists())
|
||||
dl.append(Download(tileUrl(t), file));
|
||||
else
|
||||
loadTileFile(t, file);
|
||||
}
|
||||
|
||||
if (dl.empty())
|
||||
return;
|
||||
|
||||
QEventLoop wait;
|
||||
connect(&Downloader::instance(), SIGNAL(finished()), &wait, SLOT(quit()));
|
||||
if (Downloader::instance().get(dl))
|
||||
wait.exec();
|
||||
|
||||
for (int i = 0; i < list.size(); i++) {
|
||||
Tile &t = list[i];
|
||||
|
||||
if (t.pixmap().isNull()) {
|
||||
QString file = tileFile(t);
|
||||
QFileInfo fi(file);
|
||||
|
||||
if (!(fi.exists() && loadTileFile(t, file)))
|
||||
fillTile(t);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void Map::fillTile(Tile &tile)
|
||||
{
|
||||
tile.pixmap() = QPixmap(TILE_SIZE, TILE_SIZE);
|
||||
tile.pixmap().fill();
|
||||
}
|
||||
|
||||
bool Map::loadTileFile(Tile &tile, const QString &file)
|
||||
{
|
||||
if (!tile.pixmap().load(file)) {
|
||||
fprintf(stderr, "%s: error loading tile file\n", qPrintable(file));
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
QString Map::tileUrl(const Tile &tile)
|
||||
{
|
||||
QString url(_url);
|
||||
|
||||
url.replace("$z", QString::number(tile.zoom()));
|
||||
url.replace("$x", QString::number(tile.xy().x()));
|
||||
url.replace("$y", QString::number(tile.xy().y()));
|
||||
|
||||
return url;
|
||||
}
|
||||
|
||||
QString Map::tileFile(const Tile &tile)
|
||||
{
|
||||
QString file = TILES_DIR + QString("/%1/%2-%3-%4").arg(_name)
|
||||
.arg(tile.zoom()).arg(tile.xy().x()).arg(tile.xy().y());
|
||||
|
||||
return file;
|
||||
}
|
||||
|
||||
void Map::clearCache()
|
||||
{
|
||||
QString path = TILES_DIR + QString("/") + _name;
|
||||
QDir dir = QDir(path);
|
||||
QStringList list = dir.entryList();
|
||||
|
||||
for (int i = 0; i < list.count(); i++)
|
||||
dir.remove(list.at(i));
|
||||
}
|
||||
|
21
src/map.h
21
src/map.h
@ -9,8 +9,8 @@ public:
|
||||
Tile(const QPoint &xy, int zoom)
|
||||
{_xy = xy; _zoom = zoom;}
|
||||
|
||||
int zoom() {return _zoom;}
|
||||
QPoint& xy() {return _xy;}
|
||||
int zoom() const {return _zoom;}
|
||||
const QPoint& xy() const {return _xy;}
|
||||
QPixmap& pixmap() {return _pixmap;}
|
||||
|
||||
private:
|
||||
@ -24,20 +24,29 @@ class Map : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
signals:
|
||||
void loaded();
|
||||
|
||||
public:
|
||||
Map(QObject *parent = 0, const QString &name = QString(),
|
||||
const QString &url = QString());
|
||||
|
||||
const QString &name() const {return _name;}
|
||||
void loadTiles(QList<Tile> &list);
|
||||
void loadTiles(QList<Tile> &list, bool block);
|
||||
void clearCache();
|
||||
|
||||
signals:
|
||||
void loaded();
|
||||
|
||||
private slots:
|
||||
void emitLoaded();
|
||||
|
||||
private:
|
||||
QString tileUrl(const Tile &tile);
|
||||
QString tileFile(const Tile &tile);
|
||||
bool loadTileFile(Tile &tile, const QString &file);
|
||||
void fillTile(Tile &tile);
|
||||
|
||||
void loadTilesAsync(QList<Tile> &list);
|
||||
void loadTilesSync(QList<Tile> &list);
|
||||
|
||||
QString _name;
|
||||
QString _url;
|
||||
};
|
||||
|
9
src/margins.cpp
Normal file
9
src/margins.cpp
Normal file
@ -0,0 +1,9 @@
|
||||
#include "margins.h"
|
||||
|
||||
|
||||
QDebug operator<<(QDebug dbg, const MarginsF &margins)
|
||||
{
|
||||
dbg.nospace() << "MarginsF(" << margins.left() << ", " << margins.top()
|
||||
<< ", " << margins.right() << margins.bottom() << ")";
|
||||
return dbg.maybeSpace();
|
||||
}
|
30
src/margins.h
Normal file
30
src/margins.h
Normal file
@ -0,0 +1,30 @@
|
||||
#ifndef MARGINS_H
|
||||
#define MARGINS_H
|
||||
|
||||
#include <QtGlobal>
|
||||
#include <QDebug>
|
||||
|
||||
class MarginsF
|
||||
{
|
||||
public:
|
||||
MarginsF() {_left = 0; _top = 0; _right = 0; _bottom = 0;}
|
||||
MarginsF(qreal left, qreal top, qreal right, qreal bottom)
|
||||
{_left = left, _top = top; _right = right; _bottom = bottom;}
|
||||
|
||||
qreal left() const {return _left;}
|
||||
qreal top() const {return _top;}
|
||||
qreal right() const {return _right;}
|
||||
qreal bottom() const {return _bottom;}
|
||||
|
||||
qreal &rleft() {return _left;}
|
||||
qreal &rtop() {return _top;}
|
||||
qreal &rright() {return _right;}
|
||||
qreal &rbottom() {return _bottom;}
|
||||
|
||||
private:
|
||||
qreal _left, _top, _right, _bottom;
|
||||
};
|
||||
|
||||
QDebug operator<<(QDebug dbg, const MarginsF &margins);
|
||||
|
||||
#endif // MARGINS_H
|
@ -19,10 +19,18 @@ void MarkerItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *option
|
||||
{
|
||||
Q_UNUSED(option);
|
||||
Q_UNUSED(widget);
|
||||
bool aa;
|
||||
|
||||
|
||||
if ((aa = painter->testRenderHint(QPainter::Antialiasing)))
|
||||
painter->setRenderHint(QPainter::Antialiasing, false);
|
||||
|
||||
painter->setPen(Qt::red);
|
||||
painter->drawLine(-SIZE/2, 0, SIZE/2, 0);
|
||||
painter->drawLine(0, -SIZE/2, 0, SIZE/2);
|
||||
|
||||
if (aa)
|
||||
painter->setRenderHint(QPainter::Antialiasing, true);
|
||||
|
||||
// painter->drawRect(boundingRect());
|
||||
}
|
||||
|
@ -1,4 +1,4 @@
|
||||
#include "colorshop.h"
|
||||
#include "palette.h"
|
||||
|
||||
|
||||
#define HUE_INIT 0.1f
|
||||
@ -43,12 +43,12 @@ static unsigned hsv2rgb(float h, float s, float v)
|
||||
+ (unsigned)(b * 256);
|
||||
}
|
||||
|
||||
ColorShop::ColorShop()
|
||||
Palette::Palette()
|
||||
{
|
||||
_hueState = HUE_INIT;
|
||||
}
|
||||
|
||||
QColor ColorShop::color()
|
||||
QColor Palette::color()
|
||||
{
|
||||
_hueState += HUE_INCREMENT;
|
||||
_hueState -= (int) _hueState;
|
||||
@ -56,7 +56,7 @@ QColor ColorShop::color()
|
||||
return QColor(hsv2rgb(_hueState, SATURATION, VALUE));
|
||||
}
|
||||
|
||||
void ColorShop::reset()
|
||||
void Palette::reset()
|
||||
{
|
||||
_hueState = HUE_INIT;
|
||||
}
|
@ -1,12 +1,12 @@
|
||||
#ifndef COLORSHOP_H
|
||||
#define COLORSHOP_H
|
||||
#ifndef PALETTE_H
|
||||
#define PALETTE_H
|
||||
|
||||
#include <QColor>
|
||||
|
||||
class ColorShop
|
||||
class Palette
|
||||
{
|
||||
public:
|
||||
ColorShop();
|
||||
Palette();
|
||||
QColor color();
|
||||
void reset();
|
||||
|
||||
@ -14,4 +14,4 @@ private:
|
||||
float _hueState;
|
||||
};
|
||||
|
||||
#endif // COLORSHOP_H
|
||||
#endif // PALLETE_H
|
@ -5,16 +5,20 @@ void Parser::handleExtensionData(QStringRef element, const QString &value)
|
||||
{
|
||||
if (element == "speed")
|
||||
_track->last().speed = value.toDouble();
|
||||
else if (element == "hr" || element == "heartrate")
|
||||
_track->last().heartRate = value.toDouble();
|
||||
else if (element == "atemp" || element == "temp")
|
||||
_track->last().temperature = value.toDouble();
|
||||
}
|
||||
|
||||
void Parser::handleTrekPointData(QStringRef element, const QString &value)
|
||||
{
|
||||
if (element == "ele")
|
||||
_track->last().elevation = value.toLatin1().toDouble();
|
||||
if (element == "time")
|
||||
else if (element == "time")
|
||||
_track->last().timestamp = QDateTime::fromString(value.toLatin1(),
|
||||
Qt::ISODate);
|
||||
if (element == "geoidheight")
|
||||
else if (element == "geoidheight")
|
||||
_track->last().geoidheight = value.toLatin1().toDouble();
|
||||
}
|
||||
|
||||
@ -37,11 +41,24 @@ void Parser::handleWayPointAttributes(const QXmlStreamAttributes &attr)
|
||||
attr.value("lat").toLatin1().toDouble()));
|
||||
}
|
||||
|
||||
void Parser::tpExtension()
|
||||
{
|
||||
while (_reader.readNextStartElement()) {
|
||||
if (_reader.name() == "hr" || _reader.name() == "atemp")
|
||||
handleExtensionData(_reader.name(), _reader.readElementText());
|
||||
else
|
||||
_reader.skipCurrentElement();
|
||||
}
|
||||
}
|
||||
|
||||
void Parser::extensions()
|
||||
{
|
||||
while (_reader.readNextStartElement()) {
|
||||
if (_reader.name() == "speed")
|
||||
if (_reader.name() == "speed" || _reader.name() == "hr"
|
||||
|| _reader.name() == "heartrate" || _reader.name() == "temp")
|
||||
handleExtensionData(_reader.name(), _reader.readElementText());
|
||||
else if (_reader.name() == "TrackPointExtension")
|
||||
tpExtension();
|
||||
else
|
||||
_reader.skipCurrentElement();
|
||||
}
|
||||
@ -64,7 +81,7 @@ void Parser::trackPoints()
|
||||
{
|
||||
while (_reader.readNextStartElement()) {
|
||||
if (_reader.name() == "trkpt") {
|
||||
_track->append(TrackPoint());
|
||||
_track->append(Trackpoint());
|
||||
handleTrekPointAttributes(_reader.attributes());
|
||||
trackPointData();
|
||||
} else
|
||||
@ -96,11 +113,11 @@ void Parser::gpx()
|
||||
{
|
||||
while (_reader.readNextStartElement()) {
|
||||
if (_reader.name() == "trk") {
|
||||
_tracks.append(QVector<TrackPoint>());
|
||||
_tracks.append(QVector<Trackpoint>());
|
||||
_track = &_tracks.back();
|
||||
track();
|
||||
} else if (_reader.name() == "wpt") {
|
||||
_waypoints.append(WayPoint());
|
||||
_waypoints.append(Waypoint());
|
||||
handleWayPointAttributes(_reader.attributes());
|
||||
wayPointData();
|
||||
} else
|
||||
|
@ -11,7 +11,7 @@
|
||||
class Parser
|
||||
{
|
||||
public:
|
||||
Parser(QList<QVector<TrackPoint> > &tracks, QList<WayPoint> &waypoints)
|
||||
Parser(QList<QVector<Trackpoint> > &tracks, QList<Waypoint> &waypoints)
|
||||
: _tracks(tracks), _waypoints(waypoints) {_track = 0;}
|
||||
bool loadFile(QIODevice *device);
|
||||
QString errorString() const {return _reader.errorString();}
|
||||
@ -22,6 +22,7 @@ private:
|
||||
void gpx();
|
||||
void track();
|
||||
void trackPoints();
|
||||
void tpExtension();
|
||||
void extensions();
|
||||
void trackPointData();
|
||||
void wayPointData();
|
||||
@ -33,9 +34,9 @@ private:
|
||||
void handleExtensionData(QStringRef element, const QString &value);
|
||||
|
||||
QXmlStreamReader _reader;
|
||||
QList<QVector<TrackPoint> > &_tracks;
|
||||
QList<WayPoint> &_waypoints;
|
||||
QVector<TrackPoint> *_track;
|
||||
QList<QVector<Trackpoint> > &_tracks;
|
||||
QList<Waypoint> &_waypoints;
|
||||
QVector<Trackpoint> *_track;
|
||||
};
|
||||
|
||||
#endif // PARSER_H
|
||||
|
80
src/poi.cpp
80
src/poi.cpp
@ -6,8 +6,6 @@
|
||||
#include "poi.h"
|
||||
|
||||
|
||||
#define BOUNDING_RECT_SIZE 0.01
|
||||
|
||||
bool POI::loadFile(const QString &fileName)
|
||||
{
|
||||
QString error;
|
||||
@ -41,21 +39,27 @@ bool POI::loadFile(const QString &fileName)
|
||||
bool POI::loadGPXFile(const QString &fileName)
|
||||
{
|
||||
GPX gpx;
|
||||
int cnt = _data.size();
|
||||
FileIndex index;
|
||||
|
||||
index.enabled = true;
|
||||
index.start = _data.size();
|
||||
|
||||
if (gpx.loadFile(fileName)) {
|
||||
for (int i = 0; i < gpx.waypoints().size(); i++)
|
||||
_data.append(WayPoint(
|
||||
ll2mercator(gpx.waypoints().at(i).coordinates()),
|
||||
gpx.waypoints().at(i).description()));
|
||||
_data.append(gpx.waypoints().at(i));
|
||||
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];
|
||||
c[0] = _data.at(i).coordinates().x();
|
||||
c[1] = _data.at(i).coordinates().y();
|
||||
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();
|
||||
@ -68,8 +72,12 @@ bool POI::loadGPXFile(const QString &fileName)
|
||||
bool POI::loadCSVFile(const QString &fileName)
|
||||
{
|
||||
QFile file(fileName);
|
||||
FileIndex index;
|
||||
bool ret;
|
||||
int ln = 1, cnt = _data.size();
|
||||
int ln = 1;
|
||||
|
||||
index.enabled = true;
|
||||
index.start = _data.size();
|
||||
|
||||
if (!file.open(QFile::ReadOnly | QFile::Text)) {
|
||||
_error = qPrintable(file.errorString());
|
||||
@ -99,18 +107,23 @@ bool POI::loadCSVFile(const QString &fileName)
|
||||
}
|
||||
QByteArray ba = list[2].trimmed();
|
||||
|
||||
_data.append(WayPoint(ll2mercator(QPointF(lon, lat)),
|
||||
_data.append(Waypoint(QPointF(lon, lat),
|
||||
QString::fromUtf8(ba.data(), ba.size())));
|
||||
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];
|
||||
c[0] = _data.at(i).coordinates().x();
|
||||
c[1] = _data.at(i).coordinates().y();
|
||||
c[0] = p.x();
|
||||
c[1] = p.y();
|
||||
_tree.Insert(c, c, i);
|
||||
}
|
||||
|
||||
_files.append(fileName);
|
||||
_indexes.append(index);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -122,17 +135,18 @@ static bool cb(size_t data, void* context)
|
||||
return true;
|
||||
}
|
||||
|
||||
QVector<WayPoint> POI::points(const QVector<QPointF> &path) const
|
||||
QVector<Waypoint> POI::points(const QVector<QPointF> &path, qreal radius) const
|
||||
{
|
||||
QVector<WayPoint> ret;
|
||||
QVector<Waypoint> ret;
|
||||
QSet<int> set;
|
||||
qreal min[2], max[2];
|
||||
|
||||
for (int i = 0; i < path.count(); i++) {
|
||||
min[0] = path.at(i).x() - BOUNDING_RECT_SIZE;
|
||||
min[1] = path.at(i).y() - BOUNDING_RECT_SIZE;
|
||||
max[0] = path.at(i).x() + BOUNDING_RECT_SIZE;
|
||||
max[1] = path.at(i).y() + BOUNDING_RECT_SIZE;
|
||||
const QPointF &p = path.at(i);
|
||||
min[0] = p.x() - radius;
|
||||
min[1] = p.y() - radius;
|
||||
max[0] = p.x() + radius;
|
||||
max[1] = p.y() + radius;
|
||||
_tree.Search(min, max, cb, &set);
|
||||
}
|
||||
|
||||
@ -145,8 +159,34 @@ QVector<WayPoint> POI::points(const QVector<QPointF> &path) const
|
||||
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()
|
||||
{
|
||||
_tree.RemoveAll();
|
||||
_data.clear();
|
||||
_files.clear();
|
||||
_indexes.clear();
|
||||
}
|
||||
|
20
src/poi.h
20
src/poi.h
@ -4,6 +4,7 @@
|
||||
#include <QVector>
|
||||
#include <QPointF>
|
||||
#include <QString>
|
||||
#include <QStringList>
|
||||
#include "waypoint.h"
|
||||
#include "rtree.h"
|
||||
|
||||
@ -11,22 +12,33 @@
|
||||
class POI
|
||||
{
|
||||
public:
|
||||
POI() : _errorLine(0) {}
|
||||
bool loadFile(const QString &fileName);
|
||||
QString errorString() const {return _error;}
|
||||
const QString &errorString() const {return _error;}
|
||||
int errorLine() const {return _errorLine;}
|
||||
|
||||
QVector<WayPoint> 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();
|
||||
|
||||
private:
|
||||
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;
|
||||
QVector<WayPoint> _data;
|
||||
QVector<Waypoint> _data;
|
||||
QStringList _files;
|
||||
QList<FileIndex> _indexes;
|
||||
|
||||
QString _error;
|
||||
int _errorLine;
|
||||
};
|
||||
|
15
src/range.cpp
Normal file
15
src/range.cpp
Normal file
@ -0,0 +1,15 @@
|
||||
#include "range.h"
|
||||
|
||||
void RangeF::resize(qreal size)
|
||||
{
|
||||
qreal adj = (size/2 - this->size()/2);
|
||||
|
||||
_min -= adj;
|
||||
_max += adj;
|
||||
}
|
||||
|
||||
QDebug operator<<(QDebug dbg, const RangeF &range)
|
||||
{
|
||||
dbg.nospace() << "RangeF(" << range.min() << ", " << range.max() << ")";
|
||||
return dbg.maybeSpace();
|
||||
}
|
25
src/range.h
Normal file
25
src/range.h
Normal file
@ -0,0 +1,25 @@
|
||||
#ifndef RANGE_H
|
||||
#define RANGE_H
|
||||
|
||||
#include <QtGlobal>
|
||||
#include <QDebug>
|
||||
|
||||
class RangeF
|
||||
{
|
||||
public:
|
||||
RangeF() {_min = 0; _max = 0;}
|
||||
RangeF(qreal min, qreal max) {_min = min, _max = max;}
|
||||
|
||||
qreal min() const {return _min;}
|
||||
qreal max() const {return _max;}
|
||||
qreal size() const {return (_max - _min);}
|
||||
|
||||
void resize(qreal size);
|
||||
|
||||
private:
|
||||
qreal _min, _max;
|
||||
};
|
||||
|
||||
QDebug operator<<(QDebug dbg, const RangeF &range);
|
||||
|
||||
#endif // RANGE_H
|
@ -46,6 +46,11 @@ void ScaleItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *option,
|
||||
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);
|
||||
|
||||
@ -62,11 +67,12 @@ void ScaleItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *option,
|
||||
for (int i = 0; i < SEGMENTS; i += 2)
|
||||
painter->fillRect(QRectF(i * _width, br.height() + PADDING, _width,
|
||||
SCALE_HEIGHT), Qt::black);
|
||||
|
||||
/*
|
||||
painter->setPen(Qt::red);
|
||||
painter->drawRect(boundingRect());
|
||||
*/
|
||||
if (aa)
|
||||
painter->setRenderHint(QPainter::Antialiasing, true);
|
||||
}
|
||||
|
||||
QString ScaleItem::units() const
|
||||
@ -106,24 +112,24 @@ void ScaleItem::computeScale()
|
||||
|
||||
void ScaleItem::setLatitude(qreal lat)
|
||||
{
|
||||
prepareGeometryChange();
|
||||
_lat = lat;
|
||||
computeScale();
|
||||
updateBoundingRect();
|
||||
prepareGeometryChange();
|
||||
}
|
||||
|
||||
void ScaleItem::setZoom(int z)
|
||||
{
|
||||
prepareGeometryChange();
|
||||
_zoom = z;
|
||||
computeScale();
|
||||
updateBoundingRect();
|
||||
prepareGeometryChange();
|
||||
}
|
||||
|
||||
void ScaleItem::setUnits(enum Units units)
|
||||
{
|
||||
prepareGeometryChange();
|
||||
_units = units;
|
||||
computeScale();
|
||||
updateBoundingRect();
|
||||
prepareGeometryChange();
|
||||
}
|
||||
|
22
src/settings.h
Normal file
22
src/settings.h
Normal file
@ -0,0 +1,22 @@
|
||||
#ifndef SETTINGS_H
|
||||
#define SETTINGS_H
|
||||
|
||||
#define WINDOW_SETTINGS_GROUP "Window"
|
||||
#define WINDOW_SIZE_SETTING "size"
|
||||
#define WINDOW_POS_SETTING "pos"
|
||||
|
||||
#define SETTINGS_SETTINGS_GROUP "Settings"
|
||||
#define UNITS_SETTING "units"
|
||||
#define SHOW_TOOLBARS_SETTING "toolbar"
|
||||
#define SHOW_GRAPHS_SETTING "graphs"
|
||||
|
||||
#define MAP_SETTINGS_GROUP "Map"
|
||||
#define CURRENT_MAP_SETTING "map"
|
||||
#define SHOW_MAP_SETTING "show"
|
||||
|
||||
#define POI_SETTINGS_GROUP "POI"
|
||||
#define SHOW_POI_SETTING "show"
|
||||
#define DISABLED_POI_FILE_SETTINGS_PREFIX "disabled"
|
||||
#define DISABLED_POI_FILE_SETTING "file"
|
||||
|
||||
#endif // SETTINGS_H
|
@ -7,7 +7,7 @@
|
||||
|
||||
SliderInfoItem::SliderInfoItem(QGraphicsItem *parent) : QGraphicsItem(parent)
|
||||
{
|
||||
|
||||
_side = Right;
|
||||
}
|
||||
|
||||
void SliderInfoItem::updateBoundingRect()
|
||||
@ -17,7 +17,10 @@ void SliderInfoItem::updateBoundingRect()
|
||||
font.setFamily(FONT_FAMILY);
|
||||
QFontMetrics fm(font);
|
||||
|
||||
_boundingRect = QRectF(-SIZE/2, 0, fm.width(_text) + SIZE, fm.height());
|
||||
_boundingRect = (_side == Right)
|
||||
? QRectF(-SIZE/2, 0, fm.width(_text) + SIZE, fm.height())
|
||||
: QRectF(-(fm.width(_text) + SIZE/2), 0, fm.width(_text) + SIZE,
|
||||
fm.height());
|
||||
}
|
||||
|
||||
void SliderInfoItem::paint(QPainter *painter, const QStyleOptionGraphicsItem
|
||||
@ -32,7 +35,11 @@ void SliderInfoItem::paint(QPainter *painter, const QStyleOptionGraphicsItem
|
||||
painter->setFont(font);
|
||||
|
||||
painter->setPen(Qt::red);
|
||||
painter->drawText(SIZE, fm.height() - fm.descent(), _text);
|
||||
if (_side == Right)
|
||||
painter->drawText(SIZE, fm.height() - fm.descent(), _text);
|
||||
else
|
||||
painter->drawText(-(fm.width(_text) + SIZE/2),
|
||||
fm.height() - fm.descent(), _text);
|
||||
painter->drawLine(QPointF(-SIZE/2, 0), QPointF(SIZE/2, 0));
|
||||
|
||||
//painter->drawRect(boundingRect());
|
||||
@ -40,7 +47,17 @@ void SliderInfoItem::paint(QPainter *painter, const QStyleOptionGraphicsItem
|
||||
|
||||
void SliderInfoItem::setText(const QString &text)
|
||||
{
|
||||
prepareGeometryChange();
|
||||
_text = text;
|
||||
updateBoundingRect();
|
||||
prepareGeometryChange();
|
||||
}
|
||||
|
||||
void SliderInfoItem::setSide(Side side)
|
||||
{
|
||||
if (side == _side)
|
||||
return;
|
||||
|
||||
prepareGeometryChange();
|
||||
_side = side;
|
||||
updateBoundingRect();
|
||||
}
|
||||
|
@ -6,6 +6,8 @@
|
||||
class SliderInfoItem : public QGraphicsItem
|
||||
{
|
||||
public:
|
||||
enum Side {Left, Right};
|
||||
|
||||
SliderInfoItem(QGraphicsItem *parent = 0);
|
||||
|
||||
QRectF boundingRect() const {return _boundingRect;}
|
||||
@ -13,10 +15,12 @@ public:
|
||||
QWidget *widget);
|
||||
|
||||
void setText(const QString &text);
|
||||
void setSide(Side side);
|
||||
|
||||
private:
|
||||
void updateBoundingRect();
|
||||
|
||||
Side _side;
|
||||
QString _text;
|
||||
QRectF _boundingRect;
|
||||
};
|
||||
|
@ -41,7 +41,7 @@ QVariant SliderItem::itemChange(GraphicsItemChange change, const QVariant &value
|
||||
}
|
||||
}
|
||||
|
||||
if (change == ItemPositionHasChanged)
|
||||
if (change == ItemPositionHasChanged && scene())
|
||||
emit positionChanged(value.toPointF());
|
||||
|
||||
return QGraphicsItem::itemChange(change, value);
|
||||
@ -52,3 +52,9 @@ void SliderItem::clear()
|
||||
_area = QRectF();
|
||||
setPos(QPointF());
|
||||
}
|
||||
|
||||
void SliderItem::setArea(const QRectF &area)
|
||||
{
|
||||
prepareGeometryChange();
|
||||
_area = area;
|
||||
}
|
||||
|
@ -14,8 +14,8 @@ public:
|
||||
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option,
|
||||
QWidget *widget);
|
||||
|
||||
QRectF area() {return _area;}
|
||||
void setArea(const QRectF &area) {_area = area;}
|
||||
const QRectF &area() const {return _area;}
|
||||
void setArea(const QRectF &area);
|
||||
|
||||
void clear();
|
||||
|
||||
|
@ -5,45 +5,44 @@
|
||||
|
||||
SpeedGraph::SpeedGraph(QWidget *parent) : GraphView(parent)
|
||||
{
|
||||
_max = 0;
|
||||
_units = Metric;
|
||||
|
||||
GraphView::setXLabel(tr("Distance"));
|
||||
GraphView::setYLabel(tr("Speed"));
|
||||
GraphView::setXUnits(tr("km"));
|
||||
GraphView::setYUnits(tr("km/h"));
|
||||
GraphView::setXScale(M2KM);
|
||||
GraphView::setYScale(MS2KMH);
|
||||
GraphView::setPrecision(1);
|
||||
setYUnits();
|
||||
setXLabel(tr("Distance"));
|
||||
setYLabel(tr("Speed"));
|
||||
|
||||
setSliderPrecision(1);
|
||||
}
|
||||
|
||||
void SpeedGraph::addInfo()
|
||||
{
|
||||
GraphView::addInfo(tr("Average"), QString::number(avg() * _yScale, 'f', 1)
|
||||
+ UNIT_SPACE + _yUnits);
|
||||
GraphView::addInfo(tr("Maximum"), QString::number(_max * _yScale, 'f', 1)
|
||||
+ UNIT_SPACE + _yUnits);
|
||||
GraphView::addInfo(tr("Average"), QString::number(avg() * yScale(), 'f', 1)
|
||||
+ UNIT_SPACE + yUnits());
|
||||
GraphView::addInfo(tr("Maximum"), QString::number(max() * yScale(), 'f', 1)
|
||||
+ UNIT_SPACE + yUnits());
|
||||
|
||||
redraw();
|
||||
}
|
||||
|
||||
void SpeedGraph::loadGPX(const GPX &gpx)
|
||||
{
|
||||
for (int i = 0; i < gpx.trackCount(); i++) {
|
||||
QVector<QPointF> data;
|
||||
qreal max = 0;
|
||||
|
||||
gpx.track(i).speedGraph(data);
|
||||
if (data.isEmpty())
|
||||
return;
|
||||
if (data.count() < 2) {
|
||||
skipColor();
|
||||
continue;
|
||||
}
|
||||
|
||||
_avg.append(QPointF(gpx.track(i).distance(), gpx.track(i).distance()
|
||||
/ gpx.track(i).time()));
|
||||
|
||||
for (int i = 0; i < data.size(); i++)
|
||||
max = qMax(max, data.at(i).y());
|
||||
_max = qMax(_max, max);
|
||||
|
||||
addInfo();
|
||||
loadData(data);
|
||||
}
|
||||
|
||||
setXUnits();
|
||||
addInfo();
|
||||
}
|
||||
|
||||
qreal SpeedGraph::avg() const
|
||||
@ -61,28 +60,49 @@ qreal SpeedGraph::avg() const
|
||||
|
||||
void SpeedGraph::clear()
|
||||
{
|
||||
_max = 0;
|
||||
_avg.clear();
|
||||
|
||||
GraphView::clear();
|
||||
}
|
||||
|
||||
void SpeedGraph::setXUnits()
|
||||
{
|
||||
if (_units == Metric) {
|
||||
if (bounds().width() < KMINM) {
|
||||
GraphView::setXUnits(tr("m"));
|
||||
setXScale(1);
|
||||
} else {
|
||||
GraphView::setXUnits(tr("km"));
|
||||
setXScale(M2KM);
|
||||
}
|
||||
} else {
|
||||
if (bounds().width() < MIINM) {
|
||||
GraphView::setXUnits(tr("ft"));
|
||||
setXScale(M2FT);
|
||||
} else {
|
||||
GraphView::setXUnits(tr("mi"));
|
||||
setXScale(M2MI);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void SpeedGraph::setYUnits()
|
||||
{
|
||||
if (_units == Metric) {
|
||||
GraphView::setYUnits(tr("km/h"));
|
||||
setYScale(MS2KMH);
|
||||
} else {
|
||||
GraphView::setYUnits(tr("mi/h"));
|
||||
setYScale(MS2MIH);
|
||||
}
|
||||
}
|
||||
|
||||
void SpeedGraph::setUnits(enum Units units)
|
||||
{
|
||||
if (units == Metric) {
|
||||
GraphView::setXUnits(tr("km"));
|
||||
GraphView::setYUnits(tr("km/h"));
|
||||
GraphView::setXScale(M2KM);
|
||||
GraphView::setYScale(MS2KMH);
|
||||
} else {
|
||||
GraphView::setXUnits(tr("mi"));
|
||||
GraphView::setYUnits(tr("mi/h"));
|
||||
GraphView::setXScale(M2MI);
|
||||
GraphView::setYScale(MS2MIH);
|
||||
}
|
||||
_units = units;
|
||||
setXUnits();
|
||||
setYUnits();
|
||||
|
||||
clearInfo();
|
||||
addInfo();
|
||||
|
||||
redraw();
|
||||
}
|
||||
|
@ -19,13 +19,15 @@ public:
|
||||
void setUnits(enum Units units);
|
||||
|
||||
qreal avg() const;
|
||||
qreal max() const {return _max;}
|
||||
qreal max() const {return bounds().bottom();}
|
||||
|
||||
private:
|
||||
void setXUnits();
|
||||
void setYUnits();
|
||||
void addInfo();
|
||||
|
||||
qreal _max;
|
||||
QList<QPointF> _avg;
|
||||
enum Units _units;
|
||||
};
|
||||
|
||||
#endif // SPEEDGRAPH_H
|
||||
|
115
src/temperaturegraph.cpp
Normal file
115
src/temperaturegraph.cpp
Normal file
@ -0,0 +1,115 @@
|
||||
#include "gpx.h"
|
||||
#include "temperaturegraph.h"
|
||||
|
||||
|
||||
TemperatureGraph::TemperatureGraph(QWidget *parent) : GraphView(parent)
|
||||
{
|
||||
_units = Metric;
|
||||
|
||||
setYUnits();
|
||||
setXLabel(tr("Distance"));
|
||||
setYLabel(tr("Temperature"));
|
||||
|
||||
setSliderPrecision(1);
|
||||
}
|
||||
|
||||
void TemperatureGraph::addInfo()
|
||||
{
|
||||
GraphView::addInfo(tr("Average"), QString::number(avg() * yScale()
|
||||
+ yOffset(), 'f', 1) + UNIT_SPACE + yUnits());
|
||||
GraphView::addInfo(tr("Minimum"), QString::number(min() * yScale()
|
||||
+ yOffset(), 'f', 1) + UNIT_SPACE + yUnits());
|
||||
GraphView::addInfo(tr("Maximum"), QString::number(max() * yScale()
|
||||
+ yOffset(), 'f', 1) + UNIT_SPACE + yUnits());
|
||||
|
||||
redraw();
|
||||
}
|
||||
|
||||
void TemperatureGraph::loadGPX(const GPX &gpx)
|
||||
{
|
||||
for (int i = 0; i < gpx.trackCount(); i++) {
|
||||
QVector<QPointF> data;
|
||||
qreal sum = 0, w = 0;
|
||||
|
||||
gpx.track(i).temperatureGraph(data);
|
||||
if (data.count() < 2) {
|
||||
skipColor();
|
||||
continue;
|
||||
}
|
||||
|
||||
for (int j = 1; j < data.size(); j++) {
|
||||
sum += data.at(j).y() * (data.at(j).x() - data.at(j-1).x());
|
||||
w += data.at(j).x() - data.at(j-1).x();
|
||||
}
|
||||
_avg.append(QPointF(gpx.track(i).distance(), sum/w));
|
||||
|
||||
loadData(data);
|
||||
}
|
||||
|
||||
setXUnits();
|
||||
addInfo();
|
||||
}
|
||||
|
||||
qreal TemperatureGraph::avg() const
|
||||
{
|
||||
qreal sum = 0, w = 0;
|
||||
QList<QPointF>::const_iterator it;
|
||||
|
||||
for (it = _avg.begin(); it != _avg.end(); it++) {
|
||||
sum += it->y() * it->x();
|
||||
w += it->x();
|
||||
}
|
||||
|
||||
return (sum / w);
|
||||
}
|
||||
|
||||
void TemperatureGraph::clear()
|
||||
{
|
||||
_avg.clear();
|
||||
|
||||
GraphView::clear();
|
||||
}
|
||||
|
||||
void TemperatureGraph::setXUnits()
|
||||
{
|
||||
if (_units == Metric) {
|
||||
if (bounds().width() < KMINM) {
|
||||
GraphView::setXUnits(tr("m"));
|
||||
setXScale(1);
|
||||
} else {
|
||||
GraphView::setXUnits(tr("km"));
|
||||
setXScale(M2KM);
|
||||
}
|
||||
} else {
|
||||
if (bounds().width() < MIINM) {
|
||||
GraphView::setXUnits(tr("ft"));
|
||||
setXScale(M2FT);
|
||||
} else {
|
||||
GraphView::setXUnits(tr("mi"));
|
||||
setXScale(M2MI);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void TemperatureGraph::setYUnits()
|
||||
{
|
||||
if (_units == Metric) {
|
||||
GraphView::setYUnits(QString::fromUtf8("\xC2\xB0") + tr("C"));
|
||||
setYScale(1);
|
||||
setYOffset(0);
|
||||
} else {
|
||||
GraphView::setYUnits(QString::fromUtf8("\xC2\xB0") + tr("F"));
|
||||
setYScale(C2FS);
|
||||
setYOffset(C2FO);
|
||||
}
|
||||
}
|
||||
|
||||
void TemperatureGraph::setUnits(enum Units units)
|
||||
{
|
||||
_units = units;
|
||||
setXUnits();
|
||||
setYUnits();
|
||||
|
||||
clearInfo();
|
||||
addInfo();
|
||||
}
|
33
src/temperaturegraph.h
Normal file
33
src/temperaturegraph.h
Normal file
@ -0,0 +1,33 @@
|
||||
#ifndef TEMPERATUREGRAPH_H
|
||||
#define TEMPERATUREGRAPH_H
|
||||
|
||||
#include "units.h"
|
||||
#include "graphview.h"
|
||||
|
||||
class GPX;
|
||||
|
||||
class TemperatureGraph : public GraphView
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
TemperatureGraph(QWidget *parent = 0);
|
||||
|
||||
void loadGPX(const GPX &gpx);
|
||||
void clear();
|
||||
void setUnits(enum Units units);
|
||||
|
||||
qreal avg() const;
|
||||
qreal min() const {return bounds().top();}
|
||||
qreal max() const {return bounds().bottom();}
|
||||
|
||||
private:
|
||||
void setXUnits();
|
||||
void setYUnits();
|
||||
void addInfo();
|
||||
|
||||
QList<QPointF> _avg;
|
||||
enum Units _units;
|
||||
};
|
||||
|
||||
#endif // TEMPERATUREGRAPH_H
|
@ -1,9 +1,12 @@
|
||||
#include "ll.h"
|
||||
#include "track.h"
|
||||
|
||||
|
||||
#define WINDOW_EF 3
|
||||
#define WINDOW_SE 11
|
||||
#define WINDOW_SF 11
|
||||
#define WINDOW_SF 7
|
||||
#define WINDOW_HE 11
|
||||
#define WINDOW_HF 3
|
||||
|
||||
static bool lt(const QPointF &p1, const QPointF &p2)
|
||||
{
|
||||
@ -76,6 +79,18 @@ static QVector<QPointF> filter(const QVector<QPointF> &v, int window)
|
||||
return ret;
|
||||
}
|
||||
|
||||
Track::Track(const QVector<Trackpoint> &data) : _data(data)
|
||||
{
|
||||
_distance = 0;
|
||||
|
||||
for (int i = 1; i < _data.count(); i++)
|
||||
_dd.append(llDistance(_data.at(i).coordinates,
|
||||
_data.at(i-1).coordinates));
|
||||
|
||||
for (int i = 0; i < _dd.size(); i++)
|
||||
_distance += _dd.at(i);
|
||||
}
|
||||
|
||||
void Track::elevationGraph(QVector<QPointF> &graph) const
|
||||
{
|
||||
qreal dist = 0;
|
||||
@ -84,11 +99,13 @@ void Track::elevationGraph(QVector<QPointF> &graph) const
|
||||
if (!_data.size())
|
||||
return;
|
||||
|
||||
raw.append(QPointF(0, _data.at(0).elevation));
|
||||
if (_data.at(0).hasElevation())
|
||||
raw.append(QPointF(0, _data.at(0).elevation - _data.at(0).geoidheight));
|
||||
for (int i = 1; i < _data.size(); i++) {
|
||||
dist += llDistance(_data.at(i).coordinates, _data.at(i-1).coordinates);
|
||||
raw.append(QPointF(dist, _data.at(i).elevation
|
||||
- _data.at(i).geoidheight));
|
||||
dist += _dd.at(i-1);
|
||||
if (_data.at(i).hasElevation())
|
||||
raw.append(QPointF(dist, _data.at(i).elevation
|
||||
- _data.at(i).geoidheight));
|
||||
}
|
||||
|
||||
graph = filter(raw, WINDOW_EF);
|
||||
@ -104,16 +121,19 @@ void Track::speedGraph(QVector<QPointF> &graph) const
|
||||
|
||||
raw.append(QPointF(0, 0));
|
||||
for (int i = 1; i < _data.size(); i++) {
|
||||
ds = llDistance(_data.at(i).coordinates, _data.at(i-1).coordinates);
|
||||
dt = _data.at(i-1).timestamp.msecsTo(_data.at(i).timestamp) / 1000.0;
|
||||
ds = _dd.at(i-1);
|
||||
dist += ds;
|
||||
|
||||
if (_data.at(i).speed < 0) {
|
||||
if (_data.at(i).hasSpeed())
|
||||
v = _data.at(i).speed;
|
||||
else if (_data.at(i).hasTimestamp()) {
|
||||
dt = _data.at(i-1).timestamp.msecsTo(_data.at(i).timestamp)
|
||||
/ 1000.0;
|
||||
if (dt == 0)
|
||||
continue;
|
||||
v = ds / dt;
|
||||
} else
|
||||
v = _data.at(i).speed;
|
||||
continue;
|
||||
|
||||
raw.append(QPointF(dist, v));
|
||||
}
|
||||
@ -121,20 +141,45 @@ void Track::speedGraph(QVector<QPointF> &graph) const
|
||||
graph = filter(eliminate(raw, WINDOW_SE), WINDOW_SF);
|
||||
}
|
||||
|
||||
void Track::track(QVector<QPointF> &track) const
|
||||
void Track::heartRateGraph(QVector<QPointF> &graph) const
|
||||
{
|
||||
for (int i = 0; i < _data.size(); i++)
|
||||
track.append(ll2mercator(_data.at(i).coordinates));
|
||||
qreal dist = 0;
|
||||
QVector<QPointF> raw;
|
||||
|
||||
if (!_data.size())
|
||||
return;
|
||||
|
||||
if (_data.at(0).hasHeartRate())
|
||||
raw.append(QPointF(0, _data.at(0).heartRate));
|
||||
for (int i = 1; i < _data.count(); i++) {
|
||||
dist += _dd.at(i-1);
|
||||
if (_data.at(i).hasHeartRate())
|
||||
raw.append(QPointF(dist, _data.at(i).heartRate));
|
||||
}
|
||||
|
||||
graph = filter(eliminate(raw, WINDOW_HE), WINDOW_HF);
|
||||
}
|
||||
|
||||
qreal Track::distance() const
|
||||
void Track::temperatureGraph(QVector<QPointF> &graph) const
|
||||
{
|
||||
qreal dist = 0;
|
||||
|
||||
for (int i = 1; i < _data.size(); i++)
|
||||
dist += llDistance(_data.at(i).coordinates, _data.at(i-1).coordinates);
|
||||
if (!_data.size())
|
||||
return;
|
||||
|
||||
return dist;
|
||||
if (_data.at(0).hasTemperature())
|
||||
graph.append(QPointF(0, _data.at(0).temperature));
|
||||
for (int i = 1; i < _data.size(); i++) {
|
||||
dist += _dd.at(i-1);
|
||||
if (_data.at(i).hasTemperature())
|
||||
graph.append(QPointF(dist, _data.at(i).temperature));
|
||||
}
|
||||
}
|
||||
|
||||
void Track::track(QVector<QPointF> &track) const
|
||||
{
|
||||
for (int i = 0; i < _data.size(); i++)
|
||||
track.append(_data.at(i).coordinates);
|
||||
}
|
||||
|
||||
qreal Track::time() const
|
||||
|
10
src/track.h
10
src/track.h
@ -8,17 +8,21 @@
|
||||
class Track
|
||||
{
|
||||
public:
|
||||
Track(const QVector<TrackPoint> &data) : _data(data) {}
|
||||
Track(const QVector<Trackpoint> &data);
|
||||
|
||||
void elevationGraph(QVector<QPointF> &graph) const;
|
||||
void speedGraph(QVector<QPointF> &graph) const;
|
||||
void heartRateGraph(QVector<QPointF> &graph) const;
|
||||
void temperatureGraph(QVector<QPointF> &graph) const;
|
||||
void track(QVector<QPointF> &track) const;
|
||||
qreal distance() const;
|
||||
qreal distance() const {return _distance;}
|
||||
qreal time() const;
|
||||
QDateTime date() const;
|
||||
|
||||
private:
|
||||
const QVector<TrackPoint> &_data;
|
||||
const QVector<Trackpoint> &_data;
|
||||
QVector<qreal> _dd;
|
||||
qreal _distance;
|
||||
};
|
||||
|
||||
#endif // TRACK_H
|
||||
|
40
src/trackinfo.cpp
Normal file
40
src/trackinfo.cpp
Normal file
@ -0,0 +1,40 @@
|
||||
#include <QPaintEngine>
|
||||
#include <QPaintDevice>
|
||||
#include "config.h"
|
||||
#include "infoitem.h"
|
||||
#include "trackinfo.h"
|
||||
|
||||
|
||||
TrackInfo::TrackInfo(QObject *parent) : QGraphicsScene(parent)
|
||||
{
|
||||
_info = new InfoItem();
|
||||
addItem(_info);
|
||||
}
|
||||
|
||||
void TrackInfo::insert(const QString &key, const QString &value)
|
||||
{
|
||||
_info->insert(key, value);
|
||||
}
|
||||
|
||||
void TrackInfo::plot(QPainter *painter, const QRectF &target)
|
||||
{
|
||||
qreal ratio = painter->paintEngine()->paintDevice()->logicalDpiX()
|
||||
/ SCREEN_DPI;
|
||||
QSizeF canvas = QSizeF(target.width() / ratio, target.height() / ratio);
|
||||
QSizeF diff = QSizeF(qAbs(canvas.width() - sceneRect().width()),
|
||||
qAbs(canvas.height() - sceneRect().height()));
|
||||
QRectF adj = sceneRect().adjusted(0, -diff.height()/2, diff.width(),
|
||||
diff.height()/2);
|
||||
|
||||
render(painter, target, adj);
|
||||
}
|
||||
|
||||
bool TrackInfo::isEmpty() const
|
||||
{
|
||||
return _info->isEmpty();
|
||||
}
|
||||
|
||||
QSizeF TrackInfo::contentSize() const
|
||||
{
|
||||
return sceneRect().size();
|
||||
}
|
24
src/trackinfo.h
Normal file
24
src/trackinfo.h
Normal file
@ -0,0 +1,24 @@
|
||||
#ifndef TRACKINFO_H
|
||||
#define TRACKINFO_H
|
||||
|
||||
#include <QGraphicsScene>
|
||||
|
||||
class InfoItem;
|
||||
|
||||
class TrackInfo : public QGraphicsScene
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
TrackInfo(QObject *parent = 0);
|
||||
|
||||
void insert(const QString &key, const QString &value);
|
||||
void plot(QPainter *painter, const QRectF &target);
|
||||
bool isEmpty() const;
|
||||
QSizeF contentSize() const;
|
||||
|
||||
private:
|
||||
InfoItem *_info;
|
||||
};
|
||||
|
||||
#endif // TRACKINFO_H
|
11
src/trackpoint.cpp
Normal file
11
src/trackpoint.cpp
Normal file
@ -0,0 +1,11 @@
|
||||
#include "trackpoint.h"
|
||||
|
||||
QDebug operator<<(QDebug dbg, const Trackpoint &trackpoint)
|
||||
{
|
||||
dbg.nospace() << "Trackpoint(" << trackpoint.coordinates << ", "
|
||||
<< trackpoint.timestamp << ", " << trackpoint.elevation << ", "
|
||||
<< trackpoint.geoidheight << ", " << trackpoint.speed << ", "
|
||||
<< trackpoint.heartRate << ", " << trackpoint.temperature << ")";
|
||||
|
||||
return dbg.maybeSpace();
|
||||
}
|
@ -3,16 +3,35 @@
|
||||
|
||||
#include <QPointF>
|
||||
#include <QDateTime>
|
||||
#include <QDebug>
|
||||
#include <cmath>
|
||||
|
||||
struct TrackPoint
|
||||
class Trackpoint
|
||||
{
|
||||
public:
|
||||
Trackpoint() {
|
||||
elevation = NAN;
|
||||
geoidheight = 0;
|
||||
speed = NAN;
|
||||
heartRate = NAN;
|
||||
temperature = NAN;
|
||||
}
|
||||
|
||||
bool hasTimestamp() const {return !timestamp.isNull();}
|
||||
bool hasElevation() const {return !std::isnan(elevation);}
|
||||
bool hasSpeed() const {return !std::isnan(speed);}
|
||||
bool hasHeartRate() const {return !std::isnan(heartRate);}
|
||||
bool hasTemperature() const {return !std::isnan(temperature);}
|
||||
|
||||
QPointF coordinates;
|
||||
QDateTime timestamp;
|
||||
qreal elevation;
|
||||
qreal geoidheight;
|
||||
qreal speed;
|
||||
|
||||
TrackPoint() {elevation = 0; geoidheight = 0; speed = -1;}
|
||||
qreal heartRate;
|
||||
qreal temperature;
|
||||
};
|
||||
|
||||
QDebug operator<<(QDebug dbg, const Trackpoint &trackpoint);
|
||||
|
||||
#endif // TRACKPOINT_H
|
||||
|
@ -1,4 +1,3 @@
|
||||
#include <cmath>
|
||||
#include <QGraphicsView>
|
||||
#include <QGraphicsScene>
|
||||
#include <QPainterPath>
|
||||
@ -6,7 +5,7 @@
|
||||
#include "poi.h"
|
||||
#include "gpx.h"
|
||||
#include "map.h"
|
||||
#include "poiitem.h"
|
||||
#include "waypointitem.h"
|
||||
#include "markeritem.h"
|
||||
#include "scaleitem.h"
|
||||
#include "ll.h"
|
||||
@ -27,110 +26,187 @@ TrackView::TrackView(QWidget *parent)
|
||||
setViewportUpdateMode(QGraphicsView::FullViewportUpdate);
|
||||
setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
|
||||
setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
|
||||
setRenderHints(QPainter::Antialiasing);
|
||||
|
||||
_mapScale = new ScaleItem();
|
||||
_mapScale->setZValue(2.0);
|
||||
|
||||
_zoom = -1;
|
||||
_scale = 1.0;
|
||||
_zoom = ZOOM_MAX;
|
||||
_scale = mapScale(_zoom);
|
||||
_map = 0;
|
||||
_maxLen = 0;
|
||||
_maxPath = 0;
|
||||
_maxDistance = 0;
|
||||
|
||||
_plot = false;
|
||||
}
|
||||
|
||||
TrackView::~TrackView()
|
||||
{
|
||||
delete _scene;
|
||||
if (_mapScale->scene() != _scene)
|
||||
delete _mapScale;
|
||||
}
|
||||
|
||||
void TrackView::addTrack(const QVector<QPointF> &track)
|
||||
{
|
||||
QPainterPath path;
|
||||
QGraphicsPathItem *pi;
|
||||
MarkerItem *mi;
|
||||
|
||||
|
||||
if (track.size() < 2) {
|
||||
_palette.color();
|
||||
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())));
|
||||
}
|
||||
|
||||
_maxPath = qMax(path.length(), _maxPath);
|
||||
|
||||
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;
|
||||
QPainterPath path;
|
||||
QGraphicsPathItem *pi;
|
||||
MarkerItem *mi;
|
||||
QColor color = _colorShop.color();
|
||||
qreal prevScale = _scale;
|
||||
|
||||
|
||||
gpx.track(i).track(track);
|
||||
|
||||
if (track.size() < 2)
|
||||
continue;
|
||||
|
||||
_tracks.append(track);
|
||||
|
||||
path.moveTo(track.at(0).x(), -track.at(0).y());
|
||||
for (int i = 1; i < track.size(); i++)
|
||||
path.lineTo(track.at(i).x(), -track.at(i).y());
|
||||
|
||||
_maxLen = qMax(path.length(), _maxLen);
|
||||
|
||||
|
||||
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);
|
||||
|
||||
QRectF br = trackBoundingRect();
|
||||
QRectF ba = br.adjusted(-TILE_SIZE, -TILE_SIZE, TILE_SIZE, TILE_SIZE);
|
||||
_scene->setSceneRect(ba);
|
||||
centerOn(ba.center());
|
||||
|
||||
if (_mapScale->scene() != _scene)
|
||||
_scene->addItem(_mapScale);
|
||||
|
||||
_mapScale->setLatitude(track.at(track.size() / 2).y());
|
||||
_mapScale->setZoom(_zoom);
|
||||
addTrack(track);
|
||||
_maxDistance = qMax(gpx.track(i).distance(), _maxDistance);
|
||||
}
|
||||
|
||||
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;
|
||||
|
||||
bottom = _trackPaths.at(0)->sceneBoundingRect().bottom();
|
||||
top = _trackPaths.at(0)->sceneBoundingRect().top();
|
||||
left = _trackPaths.at(0)->sceneBoundingRect().left();
|
||||
right = _trackPaths.at(0)->sceneBoundingRect().right();
|
||||
if (_locations.empty())
|
||||
return QRectF();
|
||||
|
||||
for (int i = 1; i < _trackPaths.size(); i++) {
|
||||
bottom = qMax(bottom, _trackPaths.at(i)->sceneBoundingRect().bottom());
|
||||
top = qMin(top, _trackPaths.at(i)->sceneBoundingRect().top());
|
||||
right = qMax(right, _trackPaths.at(i)->sceneBoundingRect().right());
|
||||
left = qMin(left, _trackPaths.at(i)->sceneBoundingRect().left());
|
||||
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;
|
||||
|
||||
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();
|
||||
if (_locations.size() < 2)
|
||||
return mapScale(ZOOM_MAX);
|
||||
|
||||
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());
|
||||
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));
|
||||
@ -140,26 +216,29 @@ qreal TrackView::trackScale() const
|
||||
return qMax(sc.x(), sc.y());
|
||||
}
|
||||
|
||||
qreal TrackView::mapScale() const
|
||||
qreal TrackView::mapScale(int zoom) const
|
||||
{
|
||||
return ((360.0/(qreal)(1<<_zoom))/(qreal)TILE_SIZE);
|
||||
return ((360.0/(qreal)(1<<zoom))/(qreal)TILE_SIZE);
|
||||
}
|
||||
|
||||
void TrackView::rescale(qreal scale)
|
||||
{
|
||||
for (int i = 0; i < _trackPaths.size(); i++) {
|
||||
for (int i = 0; i < _paths.size(); i++) {
|
||||
_markers.at(i)->setScale(scale);
|
||||
_trackPaths.at(i)->setScale(1.0/scale);
|
||||
_paths.at(i)->setScale(1.0/scale);
|
||||
|
||||
QPen pen(_trackPaths.at(i)->pen());
|
||||
QPen pen(_paths.at(i)->pen());
|
||||
pen.setWidthF(TRACK_WIDTH * scale);
|
||||
_trackPaths.at(i)->setPen(pen);
|
||||
_paths.at(i)->setPen(pen);
|
||||
}
|
||||
|
||||
QHash<WayPoint, POIItem*>::const_iterator it, jt;
|
||||
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(QPointF(it.value()->entry().coordinates().x()
|
||||
* 1.0/scale, -it.value()->entry().coordinates().y() * 1.0/scale));
|
||||
it.value()->setPos(it.value()->entry().coordinates() * 1.0/scale);
|
||||
it.value()->show();
|
||||
}
|
||||
|
||||
@ -174,29 +253,36 @@ void TrackView::rescale(qreal scale)
|
||||
_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, POIItem*>::const_iterator it,jt;
|
||||
QHash<Waypoint, WaypointItem*>::const_iterator it,jt;
|
||||
|
||||
if (!_tracks.size())
|
||||
if (!_tracks.size() && !_waypoints.size())
|
||||
return;
|
||||
|
||||
for (int i = 0; i < _tracks.size(); i++) {
|
||||
QVector<WayPoint> p = poi.points(_tracks.at(i));
|
||||
|
||||
for (int i = 0; i < p.size(); i++) {
|
||||
if (_pois.contains(p.at(i)))
|
||||
continue;
|
||||
|
||||
POIItem *pi = new POIItem(p.at(i));
|
||||
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 (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++) {
|
||||
@ -211,7 +297,8 @@ void TrackView::setMap(Map *map)
|
||||
{
|
||||
_map = map;
|
||||
if (_map)
|
||||
connect(_map, SIGNAL(loaded()), this, SLOT(redraw()));
|
||||
connect(_map, SIGNAL(loaded()), this, SLOT(redraw()),
|
||||
Qt::UniqueConnection);
|
||||
resetCachedContent();
|
||||
}
|
||||
|
||||
@ -225,9 +312,16 @@ void TrackView::redraw()
|
||||
resetCachedContent();
|
||||
}
|
||||
|
||||
void TrackView::rescale()
|
||||
{
|
||||
_zoom = qMin(scale2zoom(trackScale()), scale2zoom(waypointScale()));
|
||||
rescale(mapScale(_zoom));
|
||||
_mapScale->setZoom(_zoom);
|
||||
}
|
||||
|
||||
void TrackView::wheelEvent(QWheelEvent *event)
|
||||
{
|
||||
if (_tracks.isEmpty())
|
||||
if (_paths.isEmpty() && _locations.isEmpty())
|
||||
return;
|
||||
|
||||
QPointF pos = mapToScene(event->pos());
|
||||
@ -236,8 +330,8 @@ void TrackView::wheelEvent(QWheelEvent *event)
|
||||
_zoom = (event->delta() > 0) ?
|
||||
qMin(_zoom + 1, ZOOM_MAX) : qMax(_zoom - 1, ZOOM_MIN);
|
||||
|
||||
rescale(mapScale());
|
||||
QRectF br = trackBoundingRect();
|
||||
rescale(mapScale(_zoom));
|
||||
QRectF br = trackBoundingRect() | waypointBoundingRect();
|
||||
QRectF ba = br.adjusted(-TILE_SIZE, -TILE_SIZE, TILE_SIZE, TILE_SIZE);
|
||||
_scene->setSceneRect(ba);
|
||||
|
||||
@ -252,53 +346,43 @@ void TrackView::wheelEvent(QWheelEvent *event)
|
||||
resetCachedContent();
|
||||
}
|
||||
|
||||
void TrackView::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 TrackView::plot(QPainter *painter, const QRectF &target)
|
||||
{
|
||||
QRectF orig, adj;
|
||||
QRect orig, adj;
|
||||
qreal ratio, diff;
|
||||
|
||||
_scene->removeItem(_mapScale);
|
||||
orig = _scene->itemsBoundingRect().adjusted(0, 0, 0,
|
||||
_mapScale->boundingRect().height());
|
||||
_scene->addItem(_mapScale);
|
||||
|
||||
if (target.width()/target.height() > orig.width()/orig.height()) {
|
||||
ratio = target.width()/target.height();
|
||||
diff = qAbs((orig.height() * ratio) - orig.width());
|
||||
adj = orig.adjusted(-diff/2, 0, diff/2, 0);
|
||||
} else {
|
||||
orig = viewport()->rect();
|
||||
|
||||
if (orig.height() * (target.width() / target.height()) - orig.width() < 0) {
|
||||
ratio = target.height()/target.width();
|
||||
diff = fabs((orig.width() * ratio) - orig.height());
|
||||
diff = (orig.width() * ratio) - orig.height();
|
||||
adj = orig.adjusted(0, -diff/2, 0, diff/2);
|
||||
} else {
|
||||
ratio = target.width() / target.height();
|
||||
diff = (orig.height() * ratio) - orig.width();
|
||||
adj = orig.adjusted(-diff/2, 0, diff/2, 0);
|
||||
}
|
||||
|
||||
_mapScale->setPos(adj.bottomRight()
|
||||
+ QPoint(-_mapScale->boundingRect().width(),
|
||||
-_mapScale->boundingRect().height()));
|
||||
setUpdatesEnabled(false);
|
||||
_plot = true;
|
||||
|
||||
setTrackLineWidth(0);
|
||||
_scene->render(painter, target, adj);
|
||||
setTrackLineWidth(TRACK_WIDTH * _scale);
|
||||
}
|
||||
QPointF pos = _mapScale->pos();
|
||||
_mapScale->setPos(mapToScene(QPoint(adj.bottomRight() + QPoint(
|
||||
-(SCALE_OFFSET + _mapScale->boundingRect().width()),
|
||||
-(SCALE_OFFSET + _mapScale->boundingRect().height())))));
|
||||
|
||||
enum QPrinter::Orientation TrackView::orientation() const
|
||||
{
|
||||
return (sceneRect().width() > sceneRect().height())
|
||||
? QPrinter::Landscape : QPrinter::Portrait;
|
||||
render(painter, target, adj);
|
||||
|
||||
_mapScale->setPos(pos);
|
||||
|
||||
_plot = false;
|
||||
setUpdatesEnabled(true);
|
||||
}
|
||||
|
||||
void TrackView::clearPOI()
|
||||
{
|
||||
QHash<WayPoint, POIItem*>::const_iterator it;
|
||||
QHash<Waypoint, WaypointItem*>::const_iterator it;
|
||||
|
||||
for (it = _pois.constBegin(); it != _pois.constEnd(); it++) {
|
||||
_scene->removeItem(it.value());
|
||||
@ -314,41 +398,52 @@ void TrackView::clear()
|
||||
_scene->removeItem(_mapScale);
|
||||
|
||||
_pois.clear();
|
||||
_tracks.clear();
|
||||
_trackPaths.clear();
|
||||
_paths.clear();
|
||||
_locations.clear();
|
||||
_markers.clear();
|
||||
_scene->clear();
|
||||
_colorShop.reset();
|
||||
_palette.reset();
|
||||
|
||||
_maxLen = 0;
|
||||
_tracks.clear();
|
||||
_waypoints.clear();
|
||||
|
||||
_scene->setSceneRect(0, 0, 0, 0);
|
||||
_maxPath = 0;
|
||||
_maxDistance = 0;
|
||||
_zoom = ZOOM_MAX;
|
||||
_scale = mapScale(_zoom);
|
||||
|
||||
_scene->setSceneRect(QRectF());
|
||||
}
|
||||
|
||||
void TrackView::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);
|
||||
qreal mp = val / _maxDistance;
|
||||
|
||||
for (int i = 0; i < _paths.size(); i++) {
|
||||
qreal f = _maxPath / _paths.at(i)->path().length();
|
||||
if (mp * f < 0 || mp * f > 1.0)
|
||||
_markers.at(i)->setVisible(false);
|
||||
else {
|
||||
QPointF pos = _paths.at(i)->path().pointAtPercent(mp * f);
|
||||
_markers.at(i)->setPos(pos);
|
||||
_markers.at(i)->setVisible(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void TrackView::drawBackground(QPainter *painter, const QRectF &rect)
|
||||
{
|
||||
if (_tracks.isEmpty() || !_map) {
|
||||
if ((_paths.isEmpty() && _locations.isEmpty()) || !_map) {
|
||||
painter->fillRect(rect, Qt::white);
|
||||
return;
|
||||
}
|
||||
|
||||
painter->setWorldMatrixEnabled(false);
|
||||
|
||||
QRectF rr(rect.topLeft() * _scale, rect.size());
|
||||
QPoint tile = mercator2tile(QPointF(rr.topLeft().x(), -rr.topLeft().y()),
|
||||
_zoom);
|
||||
QPointF tm = tile2mercator(tile, _zoom);
|
||||
QPoint tl = mapFromScene(QPointF(tm.x() / _scale, -tm.y() / _scale));
|
||||
QPoint tl = mapToScene(mapFromScene(QPointF(tm.x() / _scale,
|
||||
-tm.y() / _scale))).toPoint();
|
||||
|
||||
QList<Tile> tiles;
|
||||
for (int i = 0; i <= rr.size().width() / TILE_SIZE + 1; i++) {
|
||||
@ -357,22 +452,24 @@ void TrackView::drawBackground(QPainter *painter, const QRectF &rect)
|
||||
}
|
||||
}
|
||||
|
||||
_map->loadTiles(tiles);
|
||||
_map->loadTiles(tiles, _plot);
|
||||
|
||||
for (int i = 0; i < tiles.count(); i++) {
|
||||
Tile &t = tiles[i];
|
||||
QPoint tp(tl.x() + (t.xy().rx() - tile.rx()) * TILE_SIZE,
|
||||
tl.y() + (t.xy().ry() - tile.ry()) * TILE_SIZE);
|
||||
QPoint tp(tl.x() + (t.xy().x() - tile.x()) * TILE_SIZE,
|
||||
tl.y() + (t.xy().y() - tile.y()) * TILE_SIZE);
|
||||
painter->drawPixmap(tp, t.pixmap());
|
||||
}
|
||||
}
|
||||
|
||||
void TrackView::resizeEvent(QResizeEvent *e)
|
||||
{
|
||||
if (_tracks.isEmpty())
|
||||
if (_paths.isEmpty() && _locations.isEmpty())
|
||||
return;
|
||||
|
||||
QRectF br = trackBoundingRect();
|
||||
rescale();
|
||||
|
||||
QRectF br = trackBoundingRect() | waypointBoundingRect();
|
||||
QRectF ba = br.adjusted(-TILE_SIZE, -TILE_SIZE, TILE_SIZE, TILE_SIZE);
|
||||
|
||||
if (ba.width() < e->size().width()) {
|
||||
@ -392,9 +489,10 @@ void TrackView::resizeEvent(QResizeEvent *e)
|
||||
|
||||
void TrackView::paintEvent(QPaintEvent *e)
|
||||
{
|
||||
QPointF scenePos = mapToScene(rect().bottomLeft() + QPoint(SCALE_OFFSET,
|
||||
QPointF scenePos = mapToScene(rect().bottomRight() + QPoint(
|
||||
-(SCALE_OFFSET + _mapScale->boundingRect().width()),
|
||||
-(SCALE_OFFSET + _mapScale->boundingRect().height())));
|
||||
if (_mapScale->pos() != scenePos)
|
||||
if (_mapScale->pos() != scenePos && !_plot)
|
||||
_mapScale->setPos(scenePos);
|
||||
|
||||
QGraphicsView::paintEvent(e);
|
||||
|
@ -5,15 +5,14 @@
|
||||
#include <QVector>
|
||||
#include <QHash>
|
||||
#include <QList>
|
||||
#include <QPrinter>
|
||||
#include "units.h"
|
||||
#include "colorshop.h"
|
||||
#include "palette.h"
|
||||
#include "waypoint.h"
|
||||
|
||||
class GPX;
|
||||
class POI;
|
||||
class Map;
|
||||
class POIItem;
|
||||
class WaypointItem;
|
||||
class MarkerItem;
|
||||
class ScaleItem;
|
||||
|
||||
@ -35,22 +34,26 @@ public:
|
||||
void setUnits(enum Units units);
|
||||
|
||||
void plot(QPainter *painter, const QRectF &target);
|
||||
enum QPrinter::Orientation orientation() const;
|
||||
|
||||
int trackCount() const {return _paths.count();}
|
||||
int waypointCount() const {return _locations.count();}
|
||||
|
||||
public slots:
|
||||
void movePositionMarker(qreal val);
|
||||
|
||||
private slots:
|
||||
void redraw();
|
||||
|
||||
private:
|
||||
QRectF trackBoundingRect() const;
|
||||
qreal trackScale() const;
|
||||
qreal mapScale() const;
|
||||
void rescale(qreal scale);
|
||||
void addTrack(const QVector<QPointF> &track);
|
||||
void addWaypoints(const QList<Waypoint> &waypoints);
|
||||
void addPOI(const QVector<Waypoint> &waypoints);
|
||||
|
||||
void showMarkers(bool show);
|
||||
void setTrackLineWidth(qreal width);
|
||||
QRectF trackBoundingRect() const;
|
||||
QRectF waypointBoundingRect() const;
|
||||
qreal trackScale() const;
|
||||
qreal waypointScale() const;
|
||||
qreal mapScale(int zoom) const;
|
||||
void rescale(qreal scale);
|
||||
void rescale();
|
||||
|
||||
void wheelEvent(QWheelEvent *event);
|
||||
void drawBackground(QPainter *painter, const QRectF &rect);
|
||||
@ -58,18 +61,23 @@ private:
|
||||
void paintEvent(QPaintEvent *e);
|
||||
|
||||
QGraphicsScene *_scene;
|
||||
QList<QVector<QPointF> > _tracks;
|
||||
QList<QGraphicsPathItem*> _trackPaths;
|
||||
QList<QGraphicsPathItem*> _paths;
|
||||
QList<MarkerItem*> _markers;
|
||||
QHash<WayPoint, POIItem*> _pois;
|
||||
QList<WaypointItem*> _locations;
|
||||
QHash<Waypoint, WaypointItem*> _pois;
|
||||
QList<QVector<QPointF> > _tracks;
|
||||
QVector<QPointF> _waypoints;
|
||||
|
||||
Map *_map;
|
||||
ScaleItem *_mapScale;
|
||||
|
||||
ColorShop _colorShop;
|
||||
qreal _maxLen;
|
||||
Palette _palette;
|
||||
qreal _maxPath, _maxDistance;
|
||||
|
||||
qreal _scale;
|
||||
int _zoom;
|
||||
|
||||
bool _plot;
|
||||
};
|
||||
|
||||
#endif // TRACKVIEW_H
|
||||
|
11
src/units.h
11
src/units.h
@ -12,12 +12,17 @@ enum Units {
|
||||
#define MS2KMH 3.600000000000 // m/s -> km/h
|
||||
#define MS2MIH 2.236936290000 // m/s -> mi/h
|
||||
#define FT2MI 0.000189393939 // ft -> mi
|
||||
#define MM2IN 0.039370100000 // mm -> in
|
||||
|
||||
#define MIINFT 5280 // 1 mi in ft
|
||||
#define KMINM 1000 // 1 km in m
|
||||
#define KMINM 1000 // 1 km in m
|
||||
#define MIINFT 5280 // 1 mi in ft
|
||||
#define MIINM 1609.344 // 1mi in m
|
||||
|
||||
#define C2FS 1.8 // Celsius to Farenheit - scale
|
||||
#define C2FO 32 // Celsius to Farenheit - offset
|
||||
|
||||
#ifdef Q_OS_WIN32
|
||||
#define UNIT_SPACE " "
|
||||
#define UNIT_SPACE QString(" ")
|
||||
#else // Q_OS_WIN32
|
||||
#define UNIT_SPACE QString::fromUtf8("\xE2\x80\x89")
|
||||
#endif // Q_OS_WIN32
|
||||
|
@ -5,11 +5,11 @@
|
||||
#include <QString>
|
||||
#include <QHash>
|
||||
|
||||
class WayPoint
|
||||
class Waypoint
|
||||
{
|
||||
public:
|
||||
WayPoint() {}
|
||||
WayPoint(const QPointF &coordinates, const QString &description)
|
||||
Waypoint() {}
|
||||
Waypoint(const QPointF &coordinates, const QString &description)
|
||||
: _coordinates(coordinates), _description(description) {}
|
||||
|
||||
const QPointF &coordinates() const {return _coordinates;}
|
||||
@ -19,7 +19,7 @@ public:
|
||||
void setDescription(const QString &description)
|
||||
{_description = description;}
|
||||
|
||||
bool operator==(const WayPoint &other) const
|
||||
bool operator==(const Waypoint &other) const
|
||||
{return this->_description == other._description
|
||||
&& this->_coordinates == other._coordinates;}
|
||||
|
||||
@ -28,7 +28,7 @@ private:
|
||||
QString _description;
|
||||
};
|
||||
|
||||
inline uint qHash(const WayPoint &key)
|
||||
inline uint qHash(const Waypoint &key)
|
||||
{
|
||||
return ::qHash(key.description());
|
||||
}
|
||||
|
@ -1,18 +1,18 @@
|
||||
#include <QPainter>
|
||||
#include "config.h"
|
||||
#include "poiitem.h"
|
||||
#include "waypointitem.h"
|
||||
|
||||
|
||||
#define POINT_SIZE 8
|
||||
|
||||
POIItem::POIItem(const WayPoint &entry, QGraphicsItem *parent)
|
||||
WaypointItem::WaypointItem(const Waypoint &entry, QGraphicsItem *parent)
|
||||
: QGraphicsItem(parent)
|
||||
{
|
||||
_entry = entry;
|
||||
updateBoundingRect();
|
||||
}
|
||||
|
||||
void POIItem::updateBoundingRect()
|
||||
void WaypointItem::updateBoundingRect()
|
||||
{
|
||||
QFont font;
|
||||
font.setPixelSize(FONT_SIZE);
|
||||
@ -20,11 +20,11 @@ void POIItem::updateBoundingRect()
|
||||
QFontMetrics fm(font);
|
||||
QRect ts = fm.tightBoundingRect(_entry.description());
|
||||
|
||||
_boundingRect = QRectF(0, 0, ts.width() + POINT_SIZE,
|
||||
ts.height() + fm.descent() + POINT_SIZE);
|
||||
_boundingRect = QRectF(-POINT_SIZE/2, -POINT_SIZE/2, ts.width()
|
||||
+ POINT_SIZE, ts.height() + fm.descent() + POINT_SIZE);
|
||||
}
|
||||
|
||||
void POIItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *option,
|
||||
void WaypointItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *option,
|
||||
QWidget *widget)
|
||||
{
|
||||
Q_UNUSED(option);
|
||||
@ -36,10 +36,10 @@ void POIItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *option,
|
||||
QRect ts = fm.tightBoundingRect(_entry.description());
|
||||
|
||||
painter->setFont(font);
|
||||
painter->drawText(POINT_SIZE - qMax(ts.x(), 0), POINT_SIZE + ts.height(),
|
||||
painter->drawText(POINT_SIZE/2 - qMax(ts.x(), 0), POINT_SIZE/2 + ts.height(),
|
||||
_entry.description());
|
||||
painter->setBrush(Qt::SolidPattern);
|
||||
painter->drawEllipse(0, 0, POINT_SIZE, POINT_SIZE);
|
||||
painter->drawEllipse(-POINT_SIZE/2, -POINT_SIZE/2, POINT_SIZE, POINT_SIZE);
|
||||
|
||||
/*
|
||||
painter->setPen(Qt::red);
|
@ -1,14 +1,14 @@
|
||||
#ifndef POIITEM_H
|
||||
#define POIITEM_H
|
||||
#ifndef WAYPOINTITEM_H
|
||||
#define WAYPOINTITEM_H
|
||||
|
||||
#include <QGraphicsItem>
|
||||
#include "waypoint.h"
|
||||
|
||||
class POIItem : public QGraphicsItem
|
||||
class WaypointItem : public QGraphicsItem
|
||||
{
|
||||
public:
|
||||
POIItem(const WayPoint &entry, QGraphicsItem *parent = 0);
|
||||
const WayPoint &entry() const {return _entry;}
|
||||
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,
|
||||
@ -17,8 +17,8 @@ public:
|
||||
private:
|
||||
void updateBoundingRect();
|
||||
|
||||
WayPoint _entry;
|
||||
Waypoint _entry;
|
||||
QRectF _boundingRect;
|
||||
};
|
||||
|
||||
#endif // POIITEM_H
|
||||
#endif // WAYPOINTITEM_H
|
Reference in New Issue
Block a user