Compare commits
132 Commits
Author | SHA1 | Date | |
---|---|---|---|
b2a49eaa23 | |||
8ff8d4bf16 | |||
46598a85fc | |||
32cbd33c91 | |||
0e356d0222 | |||
1a29ab6304 | |||
5581cff55b | |||
a458b82e37 | |||
bd946fb477 | |||
7e6ed0933c | |||
1586a5e912 | |||
3e340ab941 | |||
ea178d1acb | |||
f61488fcfa | |||
b68ca92add | |||
0448ae5eea | |||
2bc112c7b4 | |||
ccd92edb8d | |||
0cbf79870b | |||
7e8530555d | |||
2fd16e5e31 | |||
a5033c8b19 | |||
b0c6176ddd | |||
6edd7a8c61 | |||
8a299be65b | |||
cde4c65c53 | |||
b24136a580 | |||
da1b2bb90a | |||
30e198cf46 | |||
0f2deca4fa | |||
1055c4fd98 | |||
18c501b610 | |||
71310116e3 | |||
34e48199b2 | |||
4cf027df58 | |||
a9668ca86e | |||
181f60ed40 | |||
307405d661 | |||
1242423ca8 | |||
2bdab0f449 | |||
4e23df3a66 | |||
23f5a317d0 | |||
80bc9f1f01 | |||
dec3f10df3 | |||
296d4c6c9d | |||
668558cf2e | |||
a6053a4d7b | |||
535361dada | |||
e9e7660beb | |||
eb5692a0ab | |||
367427b26a | |||
371fa13bc6 | |||
5a8250ed63 | |||
c8a39a607b | |||
215cf03b68 | |||
9cadb8d0a5 | |||
20c82deda7 | |||
7c9768e83a | |||
736566b12c | |||
540339bf22 | |||
81a9743064 | |||
818fa11fd3 | |||
dd80d34e58 | |||
17c791d753 | |||
9f06b042ca | |||
d201101587 | |||
da842bd21d | |||
8a90a736d2 | |||
aac9bf024b | |||
585ded6b1c | |||
b9098c0dc5 | |||
584245785e | |||
66ce91c237 | |||
d134938ff8 | |||
9e583a9dab | |||
62ff4bb7c4 | |||
4b66aaa78b | |||
c97aa9c25d | |||
f1c6db0b46 | |||
9bd70ec96e | |||
984d3bb6c5 | |||
87a4398131 | |||
324ac2e0f4 | |||
8591d3f34c | |||
1a53968bd3 | |||
82cf7b49ca | |||
9789982626 | |||
eb03fe6ead | |||
0d1b416c4f | |||
c89f8dbb47 | |||
e4d777bace | |||
640829d89d | |||
78fb5c1547 | |||
6a25ad6379 | |||
5693375a3f | |||
10b903c129 | |||
9a0d304e8d | |||
0e5eb7287d | |||
7827509a4a | |||
974290ce8b | |||
09c097cc68 | |||
7f12c0ca95 | |||
a773921da0 | |||
b67428065f | |||
5bbf117f64 | |||
1744764025 | |||
c425b3868d | |||
84e61c657e | |||
721ee2aaa9 | |||
6cc22afcdc | |||
b99def1b30 | |||
1c5a19a33a | |||
27194d3d36 | |||
375ef20592 | |||
e86c19635e | |||
d7fd40d9d2 | |||
94fc5e17d0 | |||
425c75416a | |||
1160c6d385 | |||
a6b2a477a1 | |||
0ca264b176 | |||
be3c101c07 | |||
cb52ad8bc5 | |||
12d5dcc78c | |||
afd87c6fa2 | |||
c7d68f924f | |||
89304c0d5c | |||
c57a0f4061 | |||
f02ff1fa01 | |||
434df521fb | |||
9d90b97ba3 | |||
09631de5a2 |
185
Info.plist
@ -35,6 +35,86 @@
|
|||||||
<key>CFBundleTypeRole</key>
|
<key>CFBundleTypeRole</key>
|
||||||
<string>Viewer</string>
|
<string>Viewer</string>
|
||||||
</dict>
|
</dict>
|
||||||
|
<dict>
|
||||||
|
<key>CFBundleTypeExtensions</key>
|
||||||
|
<array>
|
||||||
|
<string>tcx</string>
|
||||||
|
</array>
|
||||||
|
<key>CFBundleTypeMIMETypes</key>
|
||||||
|
<array>
|
||||||
|
<string>application/tcx+xml</string>
|
||||||
|
</array>
|
||||||
|
<key>CFBundleTypeIconFile</key>
|
||||||
|
<string>tcx.icns</string>
|
||||||
|
<key>CFBundleTypeName</key>
|
||||||
|
<string>Training Center XML</string>
|
||||||
|
<key>CFBundleTypeRole</key>
|
||||||
|
<string>Viewer</string>
|
||||||
|
</dict>
|
||||||
|
<dict>
|
||||||
|
<key>CFBundleTypeExtensions</key>
|
||||||
|
<array>
|
||||||
|
<string>kml</string>
|
||||||
|
</array>
|
||||||
|
<key>CFBundleTypeMIMETypes</key>
|
||||||
|
<array>
|
||||||
|
<string>application/vnd.google-earth.kml+xml</string>
|
||||||
|
</array>
|
||||||
|
<key>CFBundleTypeIconFile</key>
|
||||||
|
<string>kml.icns</string>
|
||||||
|
<key>CFBundleTypeName</key>
|
||||||
|
<string>Keyhole Markup Language</string>
|
||||||
|
<key>CFBundleTypeRole</key>
|
||||||
|
<string>Viewer</string>
|
||||||
|
</dict>
|
||||||
|
<dict>
|
||||||
|
<key>CFBundleTypeExtensions</key>
|
||||||
|
<array>
|
||||||
|
<string>fit</string>
|
||||||
|
</array>
|
||||||
|
<key>CFBundleTypeMIMETypes</key>
|
||||||
|
<array>
|
||||||
|
<string>application/vnd.ant.fit</string>
|
||||||
|
</array>
|
||||||
|
<key>CFBundleTypeIconFile</key>
|
||||||
|
<string>fit.icns</string>
|
||||||
|
<key>CFBundleTypeName</key>
|
||||||
|
<string>Flexible and Interoperable Data Transfer</string>
|
||||||
|
<key>CFBundleTypeRole</key>
|
||||||
|
<string>Viewer</string>
|
||||||
|
</dict>
|
||||||
|
<dict>
|
||||||
|
<key>CFBundleTypeExtensions</key>
|
||||||
|
<array>
|
||||||
|
<string>igc</string>
|
||||||
|
</array>
|
||||||
|
<key>CFBundleTypeMIMETypes</key>
|
||||||
|
<array>
|
||||||
|
<string>application/vnd.fai.igc</string>
|
||||||
|
</array>
|
||||||
|
<key>CFBundleTypeIconFile</key>
|
||||||
|
<string>igc.icns</string>
|
||||||
|
<key>CFBundleTypeName</key>
|
||||||
|
<string>Flight Recorder Data Format</string>
|
||||||
|
<key>CFBundleTypeRole</key>
|
||||||
|
<string>Viewer</string>
|
||||||
|
</dict>
|
||||||
|
<dict>
|
||||||
|
<key>CFBundleTypeExtensions</key>
|
||||||
|
<array>
|
||||||
|
<string>nmea</string>
|
||||||
|
</array>
|
||||||
|
<key>CFBundleTypeMIMETypes</key>
|
||||||
|
<array>
|
||||||
|
<string>application/vnd.nmea.nmea</string>
|
||||||
|
</array>
|
||||||
|
<key>CFBundleTypeIconFile</key>
|
||||||
|
<string>nmea.icns</string>
|
||||||
|
<key>CFBundleTypeName</key>
|
||||||
|
<string>NMEA 0183 data</string>
|
||||||
|
<key>CFBundleTypeRole</key>
|
||||||
|
<string>Viewer</string>
|
||||||
|
</dict>
|
||||||
</array>
|
</array>
|
||||||
|
|
||||||
<key>UTImportedTypeDeclarations</key>
|
<key>UTImportedTypeDeclarations</key>
|
||||||
@ -60,6 +140,111 @@
|
|||||||
<string>application/gpx+xml</string>
|
<string>application/gpx+xml</string>
|
||||||
</dict>
|
</dict>
|
||||||
</dict>
|
</dict>
|
||||||
|
<dict>
|
||||||
|
<key>UTTypeIdentifier</key>
|
||||||
|
<string>com.garmin.tcx</string>
|
||||||
|
<key>UTTypeReferenceURL</key>
|
||||||
|
<string>http://www8.garmin.com/xmlschemas/TrainingCenterDatabasev2.xsd</string>
|
||||||
|
<key>UTTypeDescription</key>
|
||||||
|
<string>Training Center XML</string>
|
||||||
|
<key>UTTypeConformsTo</key>
|
||||||
|
<array>
|
||||||
|
<string>public.xml</string>
|
||||||
|
</array>
|
||||||
|
<key>UTTypeTagSpecification</key>
|
||||||
|
<dict>
|
||||||
|
<key>public.filename-extension</key>
|
||||||
|
<array>
|
||||||
|
<string>tcx</string>
|
||||||
|
</array>
|
||||||
|
<key>public.mime-type</key>
|
||||||
|
<string>application/tcx+xml</string>
|
||||||
|
</dict>
|
||||||
|
</dict>
|
||||||
|
<dict>
|
||||||
|
<key>UTTypeIdentifier</key>
|
||||||
|
<string>com.google.kml</string>
|
||||||
|
<key>UTTypeReferenceURL</key>
|
||||||
|
<string>https://developers.google.com/kml/documentation/kmlreference</string>
|
||||||
|
<key>UTTypeDescription</key>
|
||||||
|
<string>Keyhole Markup Language</string>
|
||||||
|
<key>UTTypeConformsTo</key>
|
||||||
|
<array>
|
||||||
|
<string>public.xml</string>
|
||||||
|
</array>
|
||||||
|
<key>UTTypeTagSpecification</key>
|
||||||
|
<dict>
|
||||||
|
<key>public.filename-extension</key>
|
||||||
|
<array>
|
||||||
|
<string>kml</string>
|
||||||
|
</array>
|
||||||
|
<key>public.mime-type</key>
|
||||||
|
<string>application/vnd.google-earth.kml+xml</string>
|
||||||
|
</dict>
|
||||||
|
</dict>
|
||||||
|
<dict>
|
||||||
|
<key>UTTypeIdentifier</key>
|
||||||
|
<string>com.thisisant.fit</string>
|
||||||
|
<key>UTTypeReferenceURL</key>
|
||||||
|
<string>https://www.thisisant.com/resources/fit</string>
|
||||||
|
<key>UTTypeDescription</key>
|
||||||
|
<string>Flexible and Interoperable Data Transfer</string>
|
||||||
|
<key>UTTypeConformsTo</key>
|
||||||
|
<array>
|
||||||
|
<string>public.data</string>
|
||||||
|
</array>
|
||||||
|
<key>UTTypeTagSpecification</key>
|
||||||
|
<dict>
|
||||||
|
<key>public.filename-extension</key>
|
||||||
|
<array>
|
||||||
|
<string>fit</string>
|
||||||
|
</array>
|
||||||
|
<key>public.mime-type</key>
|
||||||
|
<string>application/vnd.ant.fit</string>
|
||||||
|
</dict>
|
||||||
|
</dict>
|
||||||
|
<dict>
|
||||||
|
<key>UTTypeIdentifier</key>
|
||||||
|
<string>org.fai.igc</string>
|
||||||
|
<key>UTTypeReferenceURL</key>
|
||||||
|
<string>http://www.fai.org/gnss-recording-devices/igc-approved-flight-recorders</string>
|
||||||
|
<key>UTTypeDescription</key>
|
||||||
|
<string>Flight Recorder Data Format</string>
|
||||||
|
<key>UTTypeConformsTo</key>
|
||||||
|
<array>
|
||||||
|
<string>public.data</string>
|
||||||
|
</array>
|
||||||
|
<key>UTTypeTagSpecification</key>
|
||||||
|
<dict>
|
||||||
|
<key>public.filename-extension</key>
|
||||||
|
<array>
|
||||||
|
<string>igc</string>
|
||||||
|
</array>
|
||||||
|
<key>public.mime-type</key>
|
||||||
|
<string>application/vnd.fai.igc</string>
|
||||||
|
</dict>
|
||||||
|
</dict>
|
||||||
|
<dict>
|
||||||
|
<key>UTTypeIdentifier</key>
|
||||||
|
<string>org.nmea.nmea</string>
|
||||||
|
<key>UTTypeReferenceURL</key>
|
||||||
|
<string>http://www.nmea.org/content/nmea_standards/nmea_0183_v_410.asp</string>
|
||||||
|
<key>UTTypeDescription</key>
|
||||||
|
<string>NMEA 0183 data</string>
|
||||||
|
<key>UTTypeConformsTo</key>
|
||||||
|
<array>
|
||||||
|
<string>public.data</string>
|
||||||
|
</array>
|
||||||
|
<key>UTTypeTagSpecification</key>
|
||||||
|
<dict>
|
||||||
|
<key>public.filename-extension</key>
|
||||||
|
<array>
|
||||||
|
<string>nmea</string>
|
||||||
|
</array>
|
||||||
|
<key>public.mime-type</key>
|
||||||
|
<string>application/vnd.nmea.nmea</string>
|
||||||
|
</dict>
|
||||||
|
</dict>
|
||||||
</array>
|
</array>
|
||||||
|
|
||||||
</dict>
|
</dict>
|
||||||
|
11
README.md
@ -1,13 +1,16 @@
|
|||||||
# GPXSee
|
# GPXSee
|
||||||
GPX viewer and analyzer.
|
GPXSee is a Qt-based GPS log file viewer and analyzer that supports GPX, TCX,
|
||||||
|
KML, FIT, IGC and NMEA files.
|
||||||
|
|
||||||
|
## Features
|
||||||
* User-definable map sources.
|
* User-definable map sources.
|
||||||
* Track and elevation/speed/heart rate graphs.
|
* Elevation, speed, heart rate, cadence, power and temperature graphs.
|
||||||
* Support for multiple tracks in one view.
|
* Support for multiple tracks in one view.
|
||||||
* Support for POI files.
|
* Support for POI files.
|
||||||
* Export to PDF.
|
* Print/export to PDF.
|
||||||
* Full-screen mode
|
* Full-screen mode.
|
||||||
* Native GUI for Windows, Mac OS X and Linux.
|
* Native GUI for Windows, Mac OS X and Linux.
|
||||||
|
* Opens GPX, TCX, FIT, KML, IGC, NMEA and Garmin CSV files.
|
||||||
|
|
||||||

|

|
||||||
|
|
||||||
|
69
gpxsee.pro
@ -1,18 +1,17 @@
|
|||||||
TARGET = GPXSee
|
TARGET = GPXSee
|
||||||
VERSION = 2.19
|
VERSION = 3.6
|
||||||
QT += core \
|
QT += core \
|
||||||
gui \
|
gui \
|
||||||
network
|
network
|
||||||
greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
|
greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
|
||||||
greaterThan(QT_MAJOR_VERSION, 4): QT += printsupport
|
greaterThan(QT_MAJOR_VERSION, 4): QT += printsupport
|
||||||
|
lessThan(QT_VERSION, 5.4): QT += opengl
|
||||||
|
macx: QT += opengl
|
||||||
HEADERS += src/config.h \
|
HEADERS += src/config.h \
|
||||||
src/icons.h \
|
src/icons.h \
|
||||||
src/gui.h \
|
src/gui.h \
|
||||||
src/gpx.h \
|
|
||||||
src/parser.h \
|
|
||||||
src/poi.h \
|
src/poi.h \
|
||||||
src/rtree.h \
|
src/rtree.h \
|
||||||
src/ll.h \
|
|
||||||
src/axisitem.h \
|
src/axisitem.h \
|
||||||
src/keys.h \
|
src/keys.h \
|
||||||
src/slideritem.h \
|
src/slideritem.h \
|
||||||
@ -52,13 +51,35 @@ HEADERS += src/config.h \
|
|||||||
src/graphitem.h \
|
src/graphitem.h \
|
||||||
src/graph.h \
|
src/graph.h \
|
||||||
src/pathitem.h \
|
src/pathitem.h \
|
||||||
src/pathview.h
|
src/pathview.h \
|
||||||
|
src/griditem.h \
|
||||||
|
src/data.h \
|
||||||
|
src/gpxparser.h \
|
||||||
|
src/tcxparser.h \
|
||||||
|
src/parser.h \
|
||||||
|
src/csvparser.h \
|
||||||
|
src/coordinates.h \
|
||||||
|
src/tile.h \
|
||||||
|
src/rd.h \
|
||||||
|
src/wgs84.h \
|
||||||
|
src/kmlparser.h \
|
||||||
|
src/trackdata.h \
|
||||||
|
src/routedata.h \
|
||||||
|
src/fitparser.h \
|
||||||
|
src/format.h \
|
||||||
|
src/path.h \
|
||||||
|
src/assert.h \
|
||||||
|
src/cadencegraph.h \
|
||||||
|
src/powergraph.h \
|
||||||
|
src/igcparser.h \
|
||||||
|
src/nmeaparser.h \
|
||||||
|
src/optionsdialog.h \
|
||||||
|
src/colorbox.h \
|
||||||
|
src/stylecombobox.h \
|
||||||
|
src/opengl.h
|
||||||
SOURCES += src/main.cpp \
|
SOURCES += src/main.cpp \
|
||||||
src/gui.cpp \
|
src/gui.cpp \
|
||||||
src/gpx.cpp \
|
|
||||||
src/parser.cpp \
|
|
||||||
src/poi.cpp \
|
src/poi.cpp \
|
||||||
src/ll.cpp \
|
|
||||||
src/axisitem.cpp \
|
src/axisitem.cpp \
|
||||||
src/slideritem.cpp \
|
src/slideritem.cpp \
|
||||||
src/markeritem.cpp \
|
src/markeritem.cpp \
|
||||||
@ -91,19 +112,47 @@ SOURCES += src/main.cpp \
|
|||||||
src/routeitem.cpp \
|
src/routeitem.cpp \
|
||||||
src/graphitem.cpp \
|
src/graphitem.cpp \
|
||||||
src/pathitem.cpp \
|
src/pathitem.cpp \
|
||||||
src/pathview.cpp
|
src/pathview.cpp \
|
||||||
|
src/griditem.cpp \
|
||||||
|
src/data.cpp \
|
||||||
|
src/gpxparser.cpp \
|
||||||
|
src/tcxparser.cpp \
|
||||||
|
src/csvparser.cpp \
|
||||||
|
src/coordinates.cpp \
|
||||||
|
src/kmlparser.cpp \
|
||||||
|
src/fitparser.cpp \
|
||||||
|
src/format.cpp \
|
||||||
|
src/graph.cpp \
|
||||||
|
src/cadencegraph.cpp \
|
||||||
|
src/powergraph.cpp \
|
||||||
|
src/igcparser.cpp \
|
||||||
|
src/path.cpp \
|
||||||
|
src/nmeaparser.cpp \
|
||||||
|
src/optionsdialog.cpp \
|
||||||
|
src/colorbox.cpp \
|
||||||
|
src/stylecombobox.cpp
|
||||||
RESOURCES += gpxsee.qrc
|
RESOURCES += gpxsee.qrc
|
||||||
TRANSLATIONS = lang/gpxsee_cs.ts
|
TRANSLATIONS = lang/gpxsee_cs.ts
|
||||||
macx {
|
macx {
|
||||||
ICON = icons/gpxsee.icns
|
ICON = icons/gpxsee.icns
|
||||||
QMAKE_INFO_PLIST = Info.plist
|
QMAKE_INFO_PLIST = Info.plist
|
||||||
APP_RESOURCES.files = icons/gpx.icns \
|
APP_RESOURCES.files = icons/gpx.icns \
|
||||||
|
icons/tcx.icns \
|
||||||
|
icons/kml.icns \
|
||||||
|
icons/fit.icns \
|
||||||
|
icons/igc.icns \
|
||||||
|
icons/nmea.icns \
|
||||||
pkg/maps.txt
|
pkg/maps.txt
|
||||||
APP_RESOURCES.path = Contents/Resources
|
APP_RESOURCES.path = Contents/Resources
|
||||||
QMAKE_BUNDLE_DATA += APP_RESOURCES
|
QMAKE_BUNDLE_DATA += APP_RESOURCES
|
||||||
}
|
}
|
||||||
win32 {
|
win32 {
|
||||||
RC_ICONS = icons/gpxsee.ico \
|
RC_ICONS = icons/gpxsee.ico \
|
||||||
icons/gpx.ico
|
icons/gpx.ico \
|
||||||
|
icons/tcx.ico \
|
||||||
|
icons/kml.ico \
|
||||||
|
icons/fit.ico \
|
||||||
|
icons/igc.ico \
|
||||||
|
icons/nmea.ico
|
||||||
}
|
}
|
||||||
DEFINES += APP_VERSION=\\\"$$VERSION\\\"
|
DEFINES += APP_VERSION=\\\"$$VERSION\\\"
|
||||||
|
@ -15,6 +15,10 @@
|
|||||||
<file>icons/arrow-right-double.png</file>
|
<file>icons/arrow-right-double.png</file>
|
||||||
<file>icons/view-fullscreen.png</file>
|
<file>icons/view-fullscreen.png</file>
|
||||||
<file>icons/office-chart-line-stacked.png</file>
|
<file>icons/office-chart-line-stacked.png</file>
|
||||||
|
<file>icons/preferences-desktop-display.png</file>
|
||||||
|
<file>icons/flag_48.png</file>
|
||||||
|
<file>icons/system-run.png</file>
|
||||||
|
<file>icons/document-print-preview.png</file>
|
||||||
<file>lang/gpxsee_cs.qm</file>
|
<file>lang/gpxsee_cs.qm</file>
|
||||||
</qresource>
|
</qresource>
|
||||||
</RCC>
|
</RCC>
|
||||||
|
BIN
icons/document-print-preview.png
Normal file
After Width: | Height: | Size: 3.3 KiB |
BIN
icons/fit.icns
Normal file
BIN
icons/fit.ico
Normal file
After Width: | Height: | Size: 361 KiB |
171
icons/fit.svg
Normal file
@ -0,0 +1,171 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||||
|
<svg
|
||||||
|
xmlns:dc="http://purl.org/dc/elements/1.1/"
|
||||||
|
xmlns:cc="http://creativecommons.org/ns#"
|
||||||
|
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
|
||||||
|
xmlns:svg="http://www.w3.org/2000/svg"
|
||||||
|
xmlns="http://www.w3.org/2000/svg"
|
||||||
|
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
|
||||||
|
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
|
||||||
|
version="1.1"
|
||||||
|
id="svg3390"
|
||||||
|
height="185"
|
||||||
|
width="185"
|
||||||
|
inkscape:version="0.91 r13725"
|
||||||
|
sodipodi:docname="fit.svg">
|
||||||
|
<sodipodi:namedview
|
||||||
|
pagecolor="#ffffff"
|
||||||
|
bordercolor="#666666"
|
||||||
|
borderopacity="1"
|
||||||
|
objecttolerance="10"
|
||||||
|
gridtolerance="10"
|
||||||
|
guidetolerance="10"
|
||||||
|
inkscape:pageopacity="0"
|
||||||
|
inkscape:pageshadow="2"
|
||||||
|
inkscape:window-width="1440"
|
||||||
|
inkscape:window-height="815"
|
||||||
|
id="namedview3427"
|
||||||
|
showgrid="false"
|
||||||
|
inkscape:zoom="3.1351351"
|
||||||
|
inkscape:cx="92.5"
|
||||||
|
inkscape:cy="92.5"
|
||||||
|
inkscape:window-x="0"
|
||||||
|
inkscape:window-y="0"
|
||||||
|
inkscape:window-maximized="1"
|
||||||
|
inkscape:current-layer="svg3390" />
|
||||||
|
<metadata
|
||||||
|
id="metadata3404">
|
||||||
|
<rdf:RDF>
|
||||||
|
<cc:Work
|
||||||
|
rdf:about="">
|
||||||
|
<dc:format>image/svg+xml</dc:format>
|
||||||
|
<dc:type
|
||||||
|
rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
|
||||||
|
<dc:title></dc:title>
|
||||||
|
</cc:Work>
|
||||||
|
</rdf:RDF>
|
||||||
|
</metadata>
|
||||||
|
<defs
|
||||||
|
id="defs3402" />
|
||||||
|
<path
|
||||||
|
style="fill:#ffffff;stroke:#999999;stroke-width:2.18774867"
|
||||||
|
id="path3392"
|
||||||
|
d="m 128.23996,2.2548915 -95.377018,0 0,181.0580085 134.394868,0 0,-141.313567 z m 0,0 0,39.7444415 39.01785,0" />
|
||||||
|
<rect
|
||||||
|
y="124.9782"
|
||||||
|
x="16.573463"
|
||||||
|
height="49.84631"
|
||||||
|
width="120.3215"
|
||||||
|
id="rect3426"
|
||||||
|
style="fill:#006600;fill-opacity:1;stroke:none;stroke-width:2;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1" />
|
||||||
|
<g
|
||||||
|
id="g3828"
|
||||||
|
transform="matrix(0.89093793,0,0,0.84489692,3.5017807,-51.565424)">
|
||||||
|
<g
|
||||||
|
id="g3715">
|
||||||
|
<circle
|
||||||
|
style="fill:#000000"
|
||||||
|
cx="113"
|
||||||
|
cy="90.875"
|
||||||
|
id="ellipse3717"
|
||||||
|
r="7.0209999" />
|
||||||
|
<circle
|
||||||
|
style="fill:none;fill-opacity:0;stroke:#000000;stroke-width:2;stroke-linejoin:round"
|
||||||
|
cx="113"
|
||||||
|
cy="90.875"
|
||||||
|
id="ellipse3719"
|
||||||
|
r="7.0209999" />
|
||||||
|
</g>
|
||||||
|
<polyline
|
||||||
|
style="fill:none;fill-opacity:0;stroke:#000000;stroke-width:4"
|
||||||
|
points="62.3563,178.566 73.5,125.854 96,151.875 113,90.875 136.5,172.375 148.831,160.03 "
|
||||||
|
id="polyline3721" />
|
||||||
|
<g
|
||||||
|
id="g3723">
|
||||||
|
<circle
|
||||||
|
style="fill:#000000"
|
||||||
|
cx="73.5"
|
||||||
|
cy="125.854"
|
||||||
|
id="ellipse3725"
|
||||||
|
r="7.0209999" />
|
||||||
|
<circle
|
||||||
|
style="fill:none;fill-opacity:0;stroke:#000000;stroke-width:2"
|
||||||
|
cx="73.5"
|
||||||
|
cy="125.854"
|
||||||
|
id="ellipse3727"
|
||||||
|
r="7.0209999" />
|
||||||
|
</g>
|
||||||
|
<g
|
||||||
|
id="g3729">
|
||||||
|
<circle
|
||||||
|
style="fill:#000000"
|
||||||
|
cx="136.5"
|
||||||
|
cy="172.375"
|
||||||
|
id="ellipse3731"
|
||||||
|
r="7.0209999" />
|
||||||
|
<circle
|
||||||
|
style="fill:none;fill-opacity:0;stroke:#000000;stroke-width:2"
|
||||||
|
cx="136.5"
|
||||||
|
cy="172.375"
|
||||||
|
id="ellipse3733"
|
||||||
|
r="7.0209999" />
|
||||||
|
</g>
|
||||||
|
<g
|
||||||
|
id="g3735">
|
||||||
|
<circle
|
||||||
|
style="fill:#000000"
|
||||||
|
cx="60.700001"
|
||||||
|
cy="186.39999"
|
||||||
|
id="ellipse3737"
|
||||||
|
r="7.0209999" />
|
||||||
|
<circle
|
||||||
|
style="fill:none;fill-opacity:0;stroke:#000000;stroke-width:2"
|
||||||
|
cx="60.700001"
|
||||||
|
cy="186.39999"
|
||||||
|
id="ellipse3739"
|
||||||
|
r="7.0209999" />
|
||||||
|
</g>
|
||||||
|
<g
|
||||||
|
id="g3741">
|
||||||
|
<circle
|
||||||
|
style="fill:#000000"
|
||||||
|
cx="154.5"
|
||||||
|
cy="154.354"
|
||||||
|
id="ellipse3743"
|
||||||
|
r="7.0209999" />
|
||||||
|
<circle
|
||||||
|
style="fill:none;fill-opacity:0;stroke:#000000;stroke-width:2"
|
||||||
|
cx="154.5"
|
||||||
|
cy="154.354"
|
||||||
|
id="ellipse3745"
|
||||||
|
r="7.0209999" />
|
||||||
|
</g>
|
||||||
|
<g
|
||||||
|
id="g3747">
|
||||||
|
<circle
|
||||||
|
style="fill:#000000"
|
||||||
|
cx="96"
|
||||||
|
cy="151.875"
|
||||||
|
id="ellipse3749"
|
||||||
|
r="7.0209999" />
|
||||||
|
<circle
|
||||||
|
style="fill:none;fill-opacity:0;stroke:#000000;stroke-width:2"
|
||||||
|
cx="96"
|
||||||
|
cy="151.875"
|
||||||
|
id="ellipse3751"
|
||||||
|
r="7.0209999" />
|
||||||
|
</g>
|
||||||
|
</g>
|
||||||
|
<text
|
||||||
|
transform="scale(0.9437456,1.0596076)"
|
||||||
|
id="text3921"
|
||||||
|
y="155.86783"
|
||||||
|
x="44.388157"
|
||||||
|
style="font-style:normal;font-variant:normal;font-weight:bold;font-stretch:normal;font-size:40px;line-height:100%;font-family:sans-serif;-inkscape-font-specification:'sans-serif, Bold';text-align:start;letter-spacing:0px;word-spacing:0px;writing-mode:lr-tb;text-anchor:start;fill:#ffffff;fill-opacity:1;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
|
||||||
|
xml:space="preserve"
|
||||||
|
sodipodi:linespacing="100%"><tspan
|
||||||
|
sodipodi:role="line"
|
||||||
|
id="tspan3429"
|
||||||
|
x="44.388157"
|
||||||
|
y="155.86783">FIT</tspan></text>
|
||||||
|
</svg>
|
After Width: | Height: | Size: 4.9 KiB |
BIN
icons/flag_48.png
Normal file
After Width: | Height: | Size: 7.1 KiB |
BIN
icons/gpx.icns
BIN
icons/gpx.ico
Before Width: | Height: | Size: 361 KiB After Width: | Height: | Size: 361 KiB |
146
icons/gpx.svg
Normal file
@ -0,0 +1,146 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||||
|
<svg
|
||||||
|
xmlns:dc="http://purl.org/dc/elements/1.1/"
|
||||||
|
xmlns:cc="http://creativecommons.org/ns#"
|
||||||
|
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
|
||||||
|
xmlns:svg="http://www.w3.org/2000/svg"
|
||||||
|
xmlns="http://www.w3.org/2000/svg"
|
||||||
|
version="1.1"
|
||||||
|
id="svg3390"
|
||||||
|
height="185"
|
||||||
|
width="185">
|
||||||
|
<metadata
|
||||||
|
id="metadata3404">
|
||||||
|
<rdf:RDF>
|
||||||
|
<cc:Work
|
||||||
|
rdf:about="">
|
||||||
|
<dc:format>image/svg+xml</dc:format>
|
||||||
|
<dc:type
|
||||||
|
rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
|
||||||
|
<dc:title></dc:title>
|
||||||
|
</cc:Work>
|
||||||
|
</rdf:RDF>
|
||||||
|
</metadata>
|
||||||
|
<defs
|
||||||
|
id="defs3402" />
|
||||||
|
<path
|
||||||
|
style="fill:#ffffff;stroke:#999999;stroke-width:2.18774867"
|
||||||
|
id="path3392"
|
||||||
|
d="m 128.23996,2.2548915 -95.377018,0 0,181.0580085 134.394868,0 0,-141.313567 z m 0,0 0,39.7444415 39.01785,0" />
|
||||||
|
<rect
|
||||||
|
y="124.9782"
|
||||||
|
x="16.573463"
|
||||||
|
height="49.84631"
|
||||||
|
width="120.3215"
|
||||||
|
id="rect3426"
|
||||||
|
style="fill:#003399;fill-opacity:1;stroke:none;stroke-width:2;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1" />
|
||||||
|
<g
|
||||||
|
id="g3828"
|
||||||
|
transform="matrix(0.89093793,0,0,0.84489692,3.5017807,-51.565424)">
|
||||||
|
<g
|
||||||
|
id="g3715">
|
||||||
|
<circle
|
||||||
|
style="fill:#000000"
|
||||||
|
cx="113"
|
||||||
|
cy="90.875"
|
||||||
|
id="ellipse3717"
|
||||||
|
r="7.0209999" />
|
||||||
|
<circle
|
||||||
|
style="fill:none;fill-opacity:0;stroke:#000000;stroke-width:2;stroke-linejoin:round"
|
||||||
|
cx="113"
|
||||||
|
cy="90.875"
|
||||||
|
id="ellipse3719"
|
||||||
|
r="7.0209999" />
|
||||||
|
</g>
|
||||||
|
<polyline
|
||||||
|
style="fill:none;fill-opacity:0;stroke:#000000;stroke-width:4"
|
||||||
|
points="62.3563,178.566 73.5,125.854 96,151.875 113,90.875 136.5,172.375 148.831,160.03 "
|
||||||
|
id="polyline3721" />
|
||||||
|
<g
|
||||||
|
id="g3723">
|
||||||
|
<circle
|
||||||
|
style="fill:#000000"
|
||||||
|
cx="73.5"
|
||||||
|
cy="125.854"
|
||||||
|
id="ellipse3725"
|
||||||
|
r="7.0209999" />
|
||||||
|
<circle
|
||||||
|
style="fill:none;fill-opacity:0;stroke:#000000;stroke-width:2"
|
||||||
|
cx="73.5"
|
||||||
|
cy="125.854"
|
||||||
|
id="ellipse3727"
|
||||||
|
r="7.0209999" />
|
||||||
|
</g>
|
||||||
|
<g
|
||||||
|
id="g3729">
|
||||||
|
<circle
|
||||||
|
style="fill:#000000"
|
||||||
|
cx="136.5"
|
||||||
|
cy="172.375"
|
||||||
|
id="ellipse3731"
|
||||||
|
r="7.0209999" />
|
||||||
|
<circle
|
||||||
|
style="fill:none;fill-opacity:0;stroke:#000000;stroke-width:2"
|
||||||
|
cx="136.5"
|
||||||
|
cy="172.375"
|
||||||
|
id="ellipse3733"
|
||||||
|
r="7.0209999" />
|
||||||
|
</g>
|
||||||
|
<g
|
||||||
|
id="g3735">
|
||||||
|
<circle
|
||||||
|
style="fill:#000000"
|
||||||
|
cx="60.700001"
|
||||||
|
cy="186.39999"
|
||||||
|
id="ellipse3737"
|
||||||
|
r="7.0209999" />
|
||||||
|
<circle
|
||||||
|
style="fill:none;fill-opacity:0;stroke:#000000;stroke-width:2"
|
||||||
|
cx="60.700001"
|
||||||
|
cy="186.39999"
|
||||||
|
id="ellipse3739"
|
||||||
|
r="7.0209999" />
|
||||||
|
</g>
|
||||||
|
<g
|
||||||
|
id="g3741">
|
||||||
|
<circle
|
||||||
|
style="fill:#000000"
|
||||||
|
cx="154.5"
|
||||||
|
cy="154.354"
|
||||||
|
id="ellipse3743"
|
||||||
|
r="7.0209999" />
|
||||||
|
<circle
|
||||||
|
style="fill:none;fill-opacity:0;stroke:#000000;stroke-width:2"
|
||||||
|
cx="154.5"
|
||||||
|
cy="154.354"
|
||||||
|
id="ellipse3745"
|
||||||
|
r="7.0209999" />
|
||||||
|
</g>
|
||||||
|
<g
|
||||||
|
id="g3747">
|
||||||
|
<circle
|
||||||
|
style="fill:#000000"
|
||||||
|
cx="96"
|
||||||
|
cy="151.875"
|
||||||
|
id="ellipse3749"
|
||||||
|
r="7.0209999" />
|
||||||
|
<circle
|
||||||
|
style="fill:none;fill-opacity:0;stroke:#000000;stroke-width:2"
|
||||||
|
cx="96"
|
||||||
|
cy="151.875"
|
||||||
|
id="ellipse3751"
|
||||||
|
r="7.0209999" />
|
||||||
|
</g>
|
||||||
|
</g>
|
||||||
|
<text
|
||||||
|
transform="scale(0.9437456,1.0596076)"
|
||||||
|
id="text3921"
|
||||||
|
y="155.86783"
|
||||||
|
x="31.672857"
|
||||||
|
style="font-style:normal;font-variant:normal;font-weight:bold;font-stretch:normal;font-size:40px;line-height:100%;font-family:sans-serif;-inkscape-font-specification:'sans-serif, Bold';text-align:start;letter-spacing:0px;word-spacing:0px;writing-mode:lr-tb;text-anchor:start;fill:#ffffff;fill-opacity:1;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
|
||||||
|
xml:space="preserve"><tspan
|
||||||
|
y="155.86783"
|
||||||
|
x="31.672857"
|
||||||
|
id="tspan3923"
|
||||||
|
style="font-style:normal;font-variant:normal;font-weight:bold;font-stretch:normal;font-size:40px;line-height:100%;font-family:sans-serif;-inkscape-font-specification:'sans-serif, Bold';text-align:start;writing-mode:lr-tb;text-anchor:start">GPX</tspan></text>
|
||||||
|
</svg>
|
After Width: | Height: | Size: 4.4 KiB |
BIN
icons/igc.icns
Normal file
BIN
icons/igc.ico
Normal file
After Width: | Height: | Size: 361 KiB |
145
icons/igc.svg
Normal file
@ -0,0 +1,145 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||||
|
<svg
|
||||||
|
xmlns:dc="http://purl.org/dc/elements/1.1/"
|
||||||
|
xmlns:cc="http://creativecommons.org/ns#"
|
||||||
|
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
|
||||||
|
xmlns:svg="http://www.w3.org/2000/svg"
|
||||||
|
xmlns="http://www.w3.org/2000/svg"
|
||||||
|
width="185"
|
||||||
|
height="185"
|
||||||
|
id="svg3390"
|
||||||
|
version="1.1">
|
||||||
|
<metadata
|
||||||
|
id="metadata3404">
|
||||||
|
<rdf:RDF>
|
||||||
|
<cc:Work
|
||||||
|
rdf:about="">
|
||||||
|
<dc:format>image/svg+xml</dc:format>
|
||||||
|
<dc:type
|
||||||
|
rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
|
||||||
|
<dc:title></dc:title>
|
||||||
|
</cc:Work>
|
||||||
|
</rdf:RDF>
|
||||||
|
</metadata>
|
||||||
|
<defs
|
||||||
|
id="defs3402" />
|
||||||
|
<path
|
||||||
|
d="m 128.23996,2.2548915 -95.377018,0 0,181.0580085 134.394868,0 0,-141.313567 z m 0,0 0,39.7444415 39.01785,0"
|
||||||
|
id="path3392"
|
||||||
|
style="fill:#ffffff;stroke:#999999;stroke-width:2.18774867" />
|
||||||
|
<rect
|
||||||
|
style="fill:#ff3300;fill-opacity:1;stroke:none;stroke-width:2;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
|
||||||
|
id="rect3426"
|
||||||
|
width="120.3215"
|
||||||
|
height="49.84631"
|
||||||
|
x="16.573463"
|
||||||
|
y="124.9782" />
|
||||||
|
<g
|
||||||
|
transform="matrix(0.89093793,0,0,0.84489692,3.5017807,-51.565424)"
|
||||||
|
id="g3828">
|
||||||
|
<g
|
||||||
|
id="g3715">
|
||||||
|
<circle
|
||||||
|
r="7.0209999"
|
||||||
|
id="ellipse3717"
|
||||||
|
cy="90.875"
|
||||||
|
cx="113"
|
||||||
|
style="fill:#000000" />
|
||||||
|
<circle
|
||||||
|
r="7.0209999"
|
||||||
|
id="ellipse3719"
|
||||||
|
cy="90.875"
|
||||||
|
cx="113"
|
||||||
|
style="fill:none;fill-opacity:0;stroke:#000000;stroke-width:2;stroke-linejoin:round" />
|
||||||
|
</g>
|
||||||
|
<polyline
|
||||||
|
id="polyline3721"
|
||||||
|
points="62.3563,178.566 73.5,125.854 96,151.875 113,90.875 136.5,172.375 148.831,160.03 "
|
||||||
|
style="fill:none;fill-opacity:0;stroke:#000000;stroke-width:4" />
|
||||||
|
<g
|
||||||
|
id="g3723">
|
||||||
|
<circle
|
||||||
|
r="7.0209999"
|
||||||
|
id="ellipse3725"
|
||||||
|
cy="125.854"
|
||||||
|
cx="73.5"
|
||||||
|
style="fill:#000000" />
|
||||||
|
<circle
|
||||||
|
r="7.0209999"
|
||||||
|
id="ellipse3727"
|
||||||
|
cy="125.854"
|
||||||
|
cx="73.5"
|
||||||
|
style="fill:none;fill-opacity:0;stroke:#000000;stroke-width:2" />
|
||||||
|
</g>
|
||||||
|
<g
|
||||||
|
id="g3729">
|
||||||
|
<circle
|
||||||
|
r="7.0209999"
|
||||||
|
id="ellipse3731"
|
||||||
|
cy="172.375"
|
||||||
|
cx="136.5"
|
||||||
|
style="fill:#000000" />
|
||||||
|
<circle
|
||||||
|
r="7.0209999"
|
||||||
|
id="ellipse3733"
|
||||||
|
cy="172.375"
|
||||||
|
cx="136.5"
|
||||||
|
style="fill:none;fill-opacity:0;stroke:#000000;stroke-width:2" />
|
||||||
|
</g>
|
||||||
|
<g
|
||||||
|
id="g3735">
|
||||||
|
<circle
|
||||||
|
r="7.0209999"
|
||||||
|
id="ellipse3737"
|
||||||
|
cy="186.39999"
|
||||||
|
cx="60.700001"
|
||||||
|
style="fill:#000000" />
|
||||||
|
<circle
|
||||||
|
r="7.0209999"
|
||||||
|
id="ellipse3739"
|
||||||
|
cy="186.39999"
|
||||||
|
cx="60.700001"
|
||||||
|
style="fill:none;fill-opacity:0;stroke:#000000;stroke-width:2" />
|
||||||
|
</g>
|
||||||
|
<g
|
||||||
|
id="g3741">
|
||||||
|
<circle
|
||||||
|
r="7.0209999"
|
||||||
|
id="ellipse3743"
|
||||||
|
cy="154.354"
|
||||||
|
cx="154.5"
|
||||||
|
style="fill:#000000" />
|
||||||
|
<circle
|
||||||
|
r="7.0209999"
|
||||||
|
id="ellipse3745"
|
||||||
|
cy="154.354"
|
||||||
|
cx="154.5"
|
||||||
|
style="fill:none;fill-opacity:0;stroke:#000000;stroke-width:2" />
|
||||||
|
</g>
|
||||||
|
<g
|
||||||
|
id="g3747">
|
||||||
|
<circle
|
||||||
|
r="7.0209999"
|
||||||
|
id="ellipse3749"
|
||||||
|
cy="151.875"
|
||||||
|
cx="96"
|
||||||
|
style="fill:#000000" />
|
||||||
|
<circle
|
||||||
|
r="7.0209999"
|
||||||
|
id="ellipse3751"
|
||||||
|
cy="151.875"
|
||||||
|
cx="96"
|
||||||
|
style="fill:none;fill-opacity:0;stroke:#000000;stroke-width:2" />
|
||||||
|
</g>
|
||||||
|
</g>
|
||||||
|
<text
|
||||||
|
xml:space="preserve"
|
||||||
|
style="font-style:normal;font-variant:normal;font-weight:bold;font-stretch:normal;font-size:40px;line-height:100%;font-family:sans-serif;-inkscape-font-specification:'sans-serif, Bold';text-align:start;letter-spacing:0px;word-spacing:0px;writing-mode:lr-tb;text-anchor:start;fill:#ffffff;fill-opacity:1;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
|
||||||
|
x="40.149723"
|
||||||
|
y="155.86783"
|
||||||
|
id="text3921"
|
||||||
|
transform="scale(0.9437456,1.0596076)"><tspan
|
||||||
|
y="155.86783"
|
||||||
|
x="40.149723"
|
||||||
|
id="tspan3448">IGC</tspan></text>
|
||||||
|
</svg>
|
After Width: | Height: | Size: 4.1 KiB |
BIN
icons/kml.icns
Normal file
BIN
icons/kml.ico
Normal file
After Width: | Height: | Size: 361 KiB |
143
icons/kml.svg
Normal file
@ -0,0 +1,143 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||||
|
<svg
|
||||||
|
xmlns:dc="http://purl.org/dc/elements/1.1/"
|
||||||
|
xmlns:cc="http://creativecommons.org/ns#"
|
||||||
|
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
|
||||||
|
xmlns:svg="http://www.w3.org/2000/svg"
|
||||||
|
xmlns="http://www.w3.org/2000/svg"
|
||||||
|
width="185"
|
||||||
|
height="185"
|
||||||
|
id="svg3390"
|
||||||
|
version="1.1">
|
||||||
|
<metadata
|
||||||
|
id="metadata3404">
|
||||||
|
<rdf:RDF>
|
||||||
|
<cc:Work
|
||||||
|
rdf:about="">
|
||||||
|
<dc:format>image/svg+xml</dc:format>
|
||||||
|
<dc:type
|
||||||
|
rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
|
||||||
|
<dc:title></dc:title>
|
||||||
|
</cc:Work>
|
||||||
|
</rdf:RDF>
|
||||||
|
</metadata>
|
||||||
|
<defs
|
||||||
|
id="defs3402" />
|
||||||
|
<path
|
||||||
|
d="m 128.23996,2.2548915 -95.377018,0 0,181.0580085 134.394868,0 0,-141.313567 z m 0,0 0,39.7444415 39.01785,0"
|
||||||
|
id="path3392"
|
||||||
|
style="fill:#ffffff;stroke:#999999;stroke-width:2.18774867" />
|
||||||
|
<rect
|
||||||
|
style="fill:#990000;fill-opacity:1;stroke:none;stroke-width:2;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
|
||||||
|
id="rect3426"
|
||||||
|
width="120.3215"
|
||||||
|
height="49.84631"
|
||||||
|
x="16.573463"
|
||||||
|
y="124.9782" />
|
||||||
|
<g
|
||||||
|
transform="matrix(0.89093793,0,0,0.84489692,3.5017807,-51.565424)"
|
||||||
|
id="g3828">
|
||||||
|
<g
|
||||||
|
id="g3715">
|
||||||
|
<circle
|
||||||
|
r="7.0209999"
|
||||||
|
id="ellipse3717"
|
||||||
|
cy="90.875"
|
||||||
|
cx="113"
|
||||||
|
style="fill:#000000" />
|
||||||
|
<circle
|
||||||
|
r="7.0209999"
|
||||||
|
id="ellipse3719"
|
||||||
|
cy="90.875"
|
||||||
|
cx="113"
|
||||||
|
style="fill:none;fill-opacity:0;stroke:#000000;stroke-width:2;stroke-linejoin:round" />
|
||||||
|
</g>
|
||||||
|
<polyline
|
||||||
|
id="polyline3721"
|
||||||
|
points="62.3563,178.566 73.5,125.854 96,151.875 113,90.875 136.5,172.375 148.831,160.03 "
|
||||||
|
style="fill:none;fill-opacity:0;stroke:#000000;stroke-width:4" />
|
||||||
|
<g
|
||||||
|
id="g3723">
|
||||||
|
<circle
|
||||||
|
r="7.0209999"
|
||||||
|
id="ellipse3725"
|
||||||
|
cy="125.854"
|
||||||
|
cx="73.5"
|
||||||
|
style="fill:#000000" />
|
||||||
|
<circle
|
||||||
|
r="7.0209999"
|
||||||
|
id="ellipse3727"
|
||||||
|
cy="125.854"
|
||||||
|
cx="73.5"
|
||||||
|
style="fill:none;fill-opacity:0;stroke:#000000;stroke-width:2" />
|
||||||
|
</g>
|
||||||
|
<g
|
||||||
|
id="g3729">
|
||||||
|
<circle
|
||||||
|
r="7.0209999"
|
||||||
|
id="ellipse3731"
|
||||||
|
cy="172.375"
|
||||||
|
cx="136.5"
|
||||||
|
style="fill:#000000" />
|
||||||
|
<circle
|
||||||
|
r="7.0209999"
|
||||||
|
id="ellipse3733"
|
||||||
|
cy="172.375"
|
||||||
|
cx="136.5"
|
||||||
|
style="fill:none;fill-opacity:0;stroke:#000000;stroke-width:2" />
|
||||||
|
</g>
|
||||||
|
<g
|
||||||
|
id="g3735">
|
||||||
|
<circle
|
||||||
|
r="7.0209999"
|
||||||
|
id="ellipse3737"
|
||||||
|
cy="186.39999"
|
||||||
|
cx="60.700001"
|
||||||
|
style="fill:#000000" />
|
||||||
|
<circle
|
||||||
|
r="7.0209999"
|
||||||
|
id="ellipse3739"
|
||||||
|
cy="186.39999"
|
||||||
|
cx="60.700001"
|
||||||
|
style="fill:none;fill-opacity:0;stroke:#000000;stroke-width:2" />
|
||||||
|
</g>
|
||||||
|
<g
|
||||||
|
id="g3741">
|
||||||
|
<circle
|
||||||
|
r="7.0209999"
|
||||||
|
id="ellipse3743"
|
||||||
|
cy="154.354"
|
||||||
|
cx="154.5"
|
||||||
|
style="fill:#000000" />
|
||||||
|
<circle
|
||||||
|
r="7.0209999"
|
||||||
|
id="ellipse3745"
|
||||||
|
cy="154.354"
|
||||||
|
cx="154.5"
|
||||||
|
style="fill:none;fill-opacity:0;stroke:#000000;stroke-width:2" />
|
||||||
|
</g>
|
||||||
|
<g
|
||||||
|
id="g3747">
|
||||||
|
<circle
|
||||||
|
r="7.0209999"
|
||||||
|
id="ellipse3749"
|
||||||
|
cy="151.875"
|
||||||
|
cx="96"
|
||||||
|
style="fill:#000000" />
|
||||||
|
<circle
|
||||||
|
r="7.0209999"
|
||||||
|
id="ellipse3751"
|
||||||
|
cy="151.875"
|
||||||
|
cx="96"
|
||||||
|
style="fill:none;fill-opacity:0;stroke:#000000;stroke-width:2" />
|
||||||
|
</g>
|
||||||
|
</g>
|
||||||
|
<text
|
||||||
|
xml:space="preserve"
|
||||||
|
style="font-style:normal;font-variant:normal;font-weight:bold;font-stretch:normal;font-size:40px;line-height:100%;font-family:sans-serif;-inkscape-font-specification:'sans-serif, Bold';text-align:start;letter-spacing:0px;word-spacing:0px;writing-mode:lr;text-anchor:start;fill:#ffffff;fill-opacity:1;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1;"
|
||||||
|
x="31.672857"
|
||||||
|
y="155.86783"
|
||||||
|
id="text3921"
|
||||||
|
transform="scale(0.9437456,1.0596076)"><tspan
|
||||||
|
id="tspan3429">KML</tspan></text>
|
||||||
|
</svg>
|
After Width: | Height: | Size: 4.1 KiB |
BIN
icons/nmea.icns
Normal file
BIN
icons/nmea.ico
Normal file
After Width: | Height: | Size: 361 KiB |
145
icons/nmea.svg
Normal file
@ -0,0 +1,145 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||||
|
<svg
|
||||||
|
xmlns:dc="http://purl.org/dc/elements/1.1/"
|
||||||
|
xmlns:cc="http://creativecommons.org/ns#"
|
||||||
|
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
|
||||||
|
xmlns:svg="http://www.w3.org/2000/svg"
|
||||||
|
xmlns="http://www.w3.org/2000/svg"
|
||||||
|
version="1.1"
|
||||||
|
id="svg3390"
|
||||||
|
height="185"
|
||||||
|
width="185">
|
||||||
|
<metadata
|
||||||
|
id="metadata3404">
|
||||||
|
<rdf:RDF>
|
||||||
|
<cc:Work
|
||||||
|
rdf:about="">
|
||||||
|
<dc:format>image/svg+xml</dc:format>
|
||||||
|
<dc:type
|
||||||
|
rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
|
||||||
|
<dc:title></dc:title>
|
||||||
|
</cc:Work>
|
||||||
|
</rdf:RDF>
|
||||||
|
</metadata>
|
||||||
|
<defs
|
||||||
|
id="defs3402" />
|
||||||
|
<path
|
||||||
|
style="fill:#ffffff;stroke:#999999;stroke-width:2.18774867"
|
||||||
|
id="path3392"
|
||||||
|
d="m 128.23996,2.2548915 -95.377018,0 0,181.0580085 134.394868,0 0,-141.313567 z m 0,0 0,39.7444415 39.01785,0" />
|
||||||
|
<rect
|
||||||
|
y="124.9782"
|
||||||
|
x="16.573463"
|
||||||
|
height="49.84631"
|
||||||
|
width="131.6837"
|
||||||
|
id="rect3426"
|
||||||
|
style="fill:#0083d7;fill-opacity:1;stroke:none;stroke-width:2;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1" />
|
||||||
|
<g
|
||||||
|
id="g3828"
|
||||||
|
transform="matrix(0.89093793,0,0,0.84489692,3.5017807,-51.565424)">
|
||||||
|
<g
|
||||||
|
id="g3715">
|
||||||
|
<circle
|
||||||
|
style="fill:#000000"
|
||||||
|
cx="113"
|
||||||
|
cy="90.875"
|
||||||
|
id="ellipse3717"
|
||||||
|
r="7.0209999" />
|
||||||
|
<circle
|
||||||
|
style="fill:none;fill-opacity:0;stroke:#000000;stroke-width:2;stroke-linejoin:round"
|
||||||
|
cx="113"
|
||||||
|
cy="90.875"
|
||||||
|
id="ellipse3719"
|
||||||
|
r="7.0209999" />
|
||||||
|
</g>
|
||||||
|
<polyline
|
||||||
|
style="fill:none;fill-opacity:0;stroke:#000000;stroke-width:4"
|
||||||
|
points="62.3563,178.566 73.5,125.854 96,151.875 113,90.875 136.5,172.375 148.831,160.03 "
|
||||||
|
id="polyline3721" />
|
||||||
|
<g
|
||||||
|
id="g3723">
|
||||||
|
<circle
|
||||||
|
style="fill:#000000"
|
||||||
|
cx="73.5"
|
||||||
|
cy="125.854"
|
||||||
|
id="ellipse3725"
|
||||||
|
r="7.0209999" />
|
||||||
|
<circle
|
||||||
|
style="fill:none;fill-opacity:0;stroke:#000000;stroke-width:2"
|
||||||
|
cx="73.5"
|
||||||
|
cy="125.854"
|
||||||
|
id="ellipse3727"
|
||||||
|
r="7.0209999" />
|
||||||
|
</g>
|
||||||
|
<g
|
||||||
|
id="g3729">
|
||||||
|
<circle
|
||||||
|
style="fill:#000000"
|
||||||
|
cx="136.5"
|
||||||
|
cy="172.375"
|
||||||
|
id="ellipse3731"
|
||||||
|
r="7.0209999" />
|
||||||
|
<circle
|
||||||
|
style="fill:none;fill-opacity:0;stroke:#000000;stroke-width:2"
|
||||||
|
cx="136.5"
|
||||||
|
cy="172.375"
|
||||||
|
id="ellipse3733"
|
||||||
|
r="7.0209999" />
|
||||||
|
</g>
|
||||||
|
<g
|
||||||
|
id="g3735">
|
||||||
|
<circle
|
||||||
|
style="fill:#000000"
|
||||||
|
cx="60.700001"
|
||||||
|
cy="186.39999"
|
||||||
|
id="ellipse3737"
|
||||||
|
r="7.0209999" />
|
||||||
|
<circle
|
||||||
|
style="fill:none;fill-opacity:0;stroke:#000000;stroke-width:2"
|
||||||
|
cx="60.700001"
|
||||||
|
cy="186.39999"
|
||||||
|
id="ellipse3739"
|
||||||
|
r="7.0209999" />
|
||||||
|
</g>
|
||||||
|
<g
|
||||||
|
id="g3741">
|
||||||
|
<circle
|
||||||
|
style="fill:#000000"
|
||||||
|
cx="154.5"
|
||||||
|
cy="154.354"
|
||||||
|
id="ellipse3743"
|
||||||
|
r="7.0209999" />
|
||||||
|
<circle
|
||||||
|
style="fill:none;fill-opacity:0;stroke:#000000;stroke-width:2"
|
||||||
|
cx="154.5"
|
||||||
|
cy="154.354"
|
||||||
|
id="ellipse3745"
|
||||||
|
r="7.0209999" />
|
||||||
|
</g>
|
||||||
|
<g
|
||||||
|
id="g3747">
|
||||||
|
<circle
|
||||||
|
style="fill:#000000"
|
||||||
|
cx="96"
|
||||||
|
cy="151.875"
|
||||||
|
id="ellipse3749"
|
||||||
|
r="7.0209999" />
|
||||||
|
<circle
|
||||||
|
style="fill:none;fill-opacity:0;stroke:#000000;stroke-width:2"
|
||||||
|
cx="96"
|
||||||
|
cy="151.875"
|
||||||
|
id="ellipse3751"
|
||||||
|
r="7.0209999" />
|
||||||
|
</g>
|
||||||
|
</g>
|
||||||
|
<text
|
||||||
|
transform="scale(0.9437456,1.0596076)"
|
||||||
|
id="text3921"
|
||||||
|
y="155.86783"
|
||||||
|
x="21.076782"
|
||||||
|
style="font-style:normal;font-variant:normal;font-weight:bold;font-stretch:normal;font-size:40px;line-height:100%;font-family:sans-serif;-inkscape-font-specification:'sans-serif, Bold';text-align:start;letter-spacing:0px;word-spacing:0px;writing-mode:lr-tb;text-anchor:start;fill:#ffffff;fill-opacity:1;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
|
||||||
|
xml:space="preserve"><tspan
|
||||||
|
y="155.86783"
|
||||||
|
x="21.076782"
|
||||||
|
id="tspan3429">NMEA</tspan></text>
|
||||||
|
</svg>
|
After Width: | Height: | Size: 4.1 KiB |
BIN
icons/preferences-desktop-display.png
Normal file
After Width: | Height: | Size: 3.3 KiB |
BIN
icons/system-run.png
Normal file
After Width: | Height: | Size: 3.1 KiB |
BIN
icons/tcx.icns
Normal file
BIN
icons/tcx.ico
Normal file
After Width: | Height: | Size: 361 KiB |
145
icons/tcx.svg
Normal file
@ -0,0 +1,145 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||||
|
<svg
|
||||||
|
xmlns:dc="http://purl.org/dc/elements/1.1/"
|
||||||
|
xmlns:cc="http://creativecommons.org/ns#"
|
||||||
|
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
|
||||||
|
xmlns:svg="http://www.w3.org/2000/svg"
|
||||||
|
xmlns="http://www.w3.org/2000/svg"
|
||||||
|
width="185"
|
||||||
|
height="185"
|
||||||
|
id="svg3390"
|
||||||
|
version="1.1">
|
||||||
|
<metadata
|
||||||
|
id="metadata3404">
|
||||||
|
<rdf:RDF>
|
||||||
|
<cc:Work
|
||||||
|
rdf:about="">
|
||||||
|
<dc:format>image/svg+xml</dc:format>
|
||||||
|
<dc:type
|
||||||
|
rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
|
||||||
|
<dc:title></dc:title>
|
||||||
|
</cc:Work>
|
||||||
|
</rdf:RDF>
|
||||||
|
</metadata>
|
||||||
|
<defs
|
||||||
|
id="defs3402" />
|
||||||
|
<path
|
||||||
|
d="m 128.23996,2.2548915 -95.377018,0 0,181.0580085 134.394868,0 0,-141.313567 z m 0,0 0,39.7444415 39.01785,0"
|
||||||
|
id="path3392"
|
||||||
|
style="fill:#ffffff;stroke:#999999;stroke-width:2.18774867" />
|
||||||
|
<rect
|
||||||
|
style="fill:#ffcc00;fill-opacity:1;stroke:none;stroke-width:2;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
|
||||||
|
id="rect3426"
|
||||||
|
width="120.3215"
|
||||||
|
height="49.84631"
|
||||||
|
x="16.573463"
|
||||||
|
y="124.9782" />
|
||||||
|
<g
|
||||||
|
transform="matrix(0.89093793,0,0,0.84489692,3.5017807,-51.565424)"
|
||||||
|
id="g3828">
|
||||||
|
<g
|
||||||
|
id="g3715">
|
||||||
|
<circle
|
||||||
|
r="7.0209999"
|
||||||
|
id="ellipse3717"
|
||||||
|
cy="90.875"
|
||||||
|
cx="113"
|
||||||
|
style="fill:#000000" />
|
||||||
|
<circle
|
||||||
|
r="7.0209999"
|
||||||
|
id="ellipse3719"
|
||||||
|
cy="90.875"
|
||||||
|
cx="113"
|
||||||
|
style="fill:none;fill-opacity:0;stroke:#000000;stroke-width:2;stroke-linejoin:round" />
|
||||||
|
</g>
|
||||||
|
<polyline
|
||||||
|
id="polyline3721"
|
||||||
|
points="62.3563,178.566 73.5,125.854 96,151.875 113,90.875 136.5,172.375 148.831,160.03 "
|
||||||
|
style="fill:none;fill-opacity:0;stroke:#000000;stroke-width:4" />
|
||||||
|
<g
|
||||||
|
id="g3723">
|
||||||
|
<circle
|
||||||
|
r="7.0209999"
|
||||||
|
id="ellipse3725"
|
||||||
|
cy="125.854"
|
||||||
|
cx="73.5"
|
||||||
|
style="fill:#000000" />
|
||||||
|
<circle
|
||||||
|
r="7.0209999"
|
||||||
|
id="ellipse3727"
|
||||||
|
cy="125.854"
|
||||||
|
cx="73.5"
|
||||||
|
style="fill:none;fill-opacity:0;stroke:#000000;stroke-width:2" />
|
||||||
|
</g>
|
||||||
|
<g
|
||||||
|
id="g3729">
|
||||||
|
<circle
|
||||||
|
r="7.0209999"
|
||||||
|
id="ellipse3731"
|
||||||
|
cy="172.375"
|
||||||
|
cx="136.5"
|
||||||
|
style="fill:#000000" />
|
||||||
|
<circle
|
||||||
|
r="7.0209999"
|
||||||
|
id="ellipse3733"
|
||||||
|
cy="172.375"
|
||||||
|
cx="136.5"
|
||||||
|
style="fill:none;fill-opacity:0;stroke:#000000;stroke-width:2" />
|
||||||
|
</g>
|
||||||
|
<g
|
||||||
|
id="g3735">
|
||||||
|
<circle
|
||||||
|
r="7.0209999"
|
||||||
|
id="ellipse3737"
|
||||||
|
cy="186.39999"
|
||||||
|
cx="60.700001"
|
||||||
|
style="fill:#000000" />
|
||||||
|
<circle
|
||||||
|
r="7.0209999"
|
||||||
|
id="ellipse3739"
|
||||||
|
cy="186.39999"
|
||||||
|
cx="60.700001"
|
||||||
|
style="fill:none;fill-opacity:0;stroke:#000000;stroke-width:2" />
|
||||||
|
</g>
|
||||||
|
<g
|
||||||
|
id="g3741">
|
||||||
|
<circle
|
||||||
|
r="7.0209999"
|
||||||
|
id="ellipse3743"
|
||||||
|
cy="154.354"
|
||||||
|
cx="154.5"
|
||||||
|
style="fill:#000000" />
|
||||||
|
<circle
|
||||||
|
r="7.0209999"
|
||||||
|
id="ellipse3745"
|
||||||
|
cy="154.354"
|
||||||
|
cx="154.5"
|
||||||
|
style="fill:none;fill-opacity:0;stroke:#000000;stroke-width:2" />
|
||||||
|
</g>
|
||||||
|
<g
|
||||||
|
id="g3747">
|
||||||
|
<circle
|
||||||
|
r="7.0209999"
|
||||||
|
id="ellipse3749"
|
||||||
|
cy="151.875"
|
||||||
|
cx="96"
|
||||||
|
style="fill:#000000" />
|
||||||
|
<circle
|
||||||
|
r="7.0209999"
|
||||||
|
id="ellipse3751"
|
||||||
|
cy="151.875"
|
||||||
|
cx="96"
|
||||||
|
style="fill:none;fill-opacity:0;stroke:#000000;stroke-width:2" />
|
||||||
|
</g>
|
||||||
|
</g>
|
||||||
|
<text
|
||||||
|
xml:space="preserve"
|
||||||
|
style="font-style:normal;font-variant:normal;font-weight:bold;font-stretch:normal;font-size:40px;line-height:100%;font-family:sans-serif;-inkscape-font-specification:'sans-serif, Bold';text-align:start;letter-spacing:0px;word-spacing:0px;writing-mode:lr-tb;text-anchor:start;fill:#ffffff;fill-opacity:1;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
|
||||||
|
x="35.911289"
|
||||||
|
y="155.86783"
|
||||||
|
id="text3921"
|
||||||
|
transform="scale(0.9437456,1.0596076)"><tspan
|
||||||
|
y="155.86783"
|
||||||
|
x="35.911289"
|
||||||
|
id="tspan3429">TCX</tspan></text>
|
||||||
|
</svg>
|
After Width: | Height: | Size: 4.1 KiB |
@ -4,7 +4,7 @@
|
|||||||
; The name of the installer
|
; The name of the installer
|
||||||
Name "GPXSee"
|
Name "GPXSee"
|
||||||
; Program version
|
; Program version
|
||||||
!define VERSION "2.19"
|
!define VERSION "3.6"
|
||||||
|
|
||||||
; The file to write
|
; The file to write
|
||||||
OutFile "GPXSee-${VERSION}.exe"
|
OutFile "GPXSee-${VERSION}.exe"
|
||||||
@ -21,8 +21,13 @@ InstallDirRegKey HKLM "Software\GPXSee" "Install_Dir"
|
|||||||
|
|
||||||
; Registry key for uninstaller
|
; Registry key for uninstaller
|
||||||
!define REGENTRY "Software\Microsoft\Windows\CurrentVersion\Uninstall\GPXSee"
|
!define REGENTRY "Software\Microsoft\Windows\CurrentVersion\Uninstall\GPXSee"
|
||||||
; GPX file type registry entry
|
; File types registry entries
|
||||||
!define REGGPX "GPXSee.gpx"
|
!define REGGPX "GPXSee.gpx"
|
||||||
|
!define REGTCX "GPXSee.tcx"
|
||||||
|
!define REGKML "GPXSee.kml"
|
||||||
|
!define REGFIT "GPXSee.fit"
|
||||||
|
!define REGIGC "GPXSee.igc"
|
||||||
|
!define REGNMEA "GPXSee.nmea"
|
||||||
|
|
||||||
; Start menu page configuration
|
; Start menu page configuration
|
||||||
!define MUI_STARTMENUPAGE_REGISTRY_ROOT "HKLM"
|
!define MUI_STARTMENUPAGE_REGISTRY_ROOT "HKLM"
|
||||||
@ -62,18 +67,6 @@ Section "GPXSee (required)" SEC_APP
|
|||||||
; Put the files there
|
; Put the files there
|
||||||
File "gpxsee.exe"
|
File "gpxsee.exe"
|
||||||
File "maps.txt"
|
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
|
; Create start menu entry and add links
|
||||||
SetShellVarContext all
|
SetShellVarContext all
|
||||||
@ -83,11 +76,48 @@ Section "GPXSee (required)" SEC_APP
|
|||||||
CreateShortCut "$SMPROGRAMS\$StartMenuFolder\GPXSee.lnk" "$INSTDIR\gpxsee.exe"
|
CreateShortCut "$SMPROGRAMS\$StartMenuFolder\GPXSee.lnk" "$INSTDIR\gpxsee.exe"
|
||||||
!insertmacro MUI_STARTMENU_WRITE_END
|
!insertmacro MUI_STARTMENU_WRITE_END
|
||||||
|
|
||||||
; Associate .gpx files
|
; Create the uninstaller
|
||||||
|
WriteUninstaller "$INSTDIR\uninstall.exe"
|
||||||
|
|
||||||
|
; Write the installation path into the registry
|
||||||
|
DetailPrint "Registering application..."
|
||||||
|
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
|
||||||
|
|
||||||
|
; Associate file formats
|
||||||
|
DetailPrint "Associating file types..."
|
||||||
WriteRegStr HKCR ".gpx" "" "${REGGPX}"
|
WriteRegStr HKCR ".gpx" "" "${REGGPX}"
|
||||||
WriteRegStr HKCR "${REGGPX}" "" "GPS Exchange Format"
|
WriteRegStr HKCR "${REGGPX}" "" "GPS Exchange Format"
|
||||||
WriteRegStr HKCR "${REGGPX}\DefaultIcon" "" "$INSTDIR\GPXSee.exe,1"
|
WriteRegStr HKCR "${REGGPX}\DefaultIcon" "" "$INSTDIR\GPXSee.exe,1"
|
||||||
WriteRegStr HKCR "${REGGPX}\shell\open\command" "" "$\"$INSTDIR\GPXSee.exe$\" $\"%1$\""
|
WriteRegStr HKCR "${REGGPX}\shell\open\command" "" "$\"$INSTDIR\GPXSee.exe$\" $\"%1$\""
|
||||||
|
WriteRegStr HKCR ".tcx" "" "${REGTCX}"
|
||||||
|
WriteRegStr HKCR "${REGTCX}" "" "Training Center XML"
|
||||||
|
WriteRegStr HKCR "${REGTCX}\DefaultIcon" "" "$INSTDIR\GPXSee.exe,2"
|
||||||
|
WriteRegStr HKCR "${REGTCX}\shell\open\command" "" "$\"$INSTDIR\GPXSee.exe$\" $\"%1$\""
|
||||||
|
WriteRegStr HKCR ".kml" "" "${REGKML}"
|
||||||
|
WriteRegStr HKCR "${REGKML}" "" "Keyhole Markup Language"
|
||||||
|
WriteRegStr HKCR "${REGKML}\DefaultIcon" "" "$INSTDIR\GPXSee.exe,3"
|
||||||
|
WriteRegStr HKCR "${REGKML}\shell\open\command" "" "$\"$INSTDIR\GPXSee.exe$\" $\"%1$\""
|
||||||
|
WriteRegStr HKCR ".fit" "" "${REGFIT}"
|
||||||
|
WriteRegStr HKCR "${REGFIT}" "" "Flexible and Interoperable Data Transfer"
|
||||||
|
WriteRegStr HKCR "${REGFIT}\DefaultIcon" "" "$INSTDIR\GPXSee.exe,4"
|
||||||
|
WriteRegStr HKCR "${REGFIT}\shell\open\command" "" "$\"$INSTDIR\GPXSee.exe$\" $\"%1$\""
|
||||||
|
WriteRegStr HKCR ".igc" "" "${REGIGC}"
|
||||||
|
WriteRegStr HKCR "${REGIGC}" "" "Flight Recorder Data Format"
|
||||||
|
WriteRegStr HKCR "${REGIGC}\DefaultIcon" "" "$INSTDIR\GPXSee.exe,5"
|
||||||
|
WriteRegStr HKCR "${REGIGC}\shell\open\command" "" "$\"$INSTDIR\GPXSee.exe$\" $\"%1$\""
|
||||||
|
WriteRegStr HKCR ".nmea" "" "${REGNMEA}"
|
||||||
|
WriteRegStr HKCR "${REGNMEA}" "" "NMEA 0183 data"
|
||||||
|
WriteRegStr HKCR "${REGNMEA}\DefaultIcon" "" "$INSTDIR\GPXSee.exe,6"
|
||||||
|
WriteRegStr HKCR "${REGNMEA}\shell\open\command" "" "$\"$INSTDIR\GPXSee.exe$\" $\"%1$\""
|
||||||
|
|
||||||
System::Call 'shell32.dll::SHChangeNotify(i, i, i, i) v (0x08000000, 0, 0, 0)'
|
System::Call 'shell32.dll::SHChangeNotify(i, i, i, i) v (0x08000000, 0, 0, 0)'
|
||||||
|
|
||||||
SectionEnd
|
SectionEnd
|
||||||
@ -100,6 +130,8 @@ Section "QT libs" SEC_QT
|
|||||||
File "Qt5PrintSupport.dll"
|
File "Qt5PrintSupport.dll"
|
||||||
File "Qt5Network.dll"
|
File "Qt5Network.dll"
|
||||||
File "libGLESv2.dll"
|
File "libGLESv2.dll"
|
||||||
|
File "libEGL.dll"
|
||||||
|
File "D3DCompiler_47.dll"
|
||||||
File /r "platforms"
|
File /r "platforms"
|
||||||
File /r "imageformats"
|
File /r "imageformats"
|
||||||
File /r "printsupport"
|
File /r "printsupport"
|
||||||
@ -149,6 +181,16 @@ Section "Uninstall"
|
|||||||
; Remove GPX file association
|
; Remove GPX file association
|
||||||
DeleteRegKey HKCR "${REGGPX}"
|
DeleteRegKey HKCR "${REGGPX}"
|
||||||
DeleteRegKey HKCR ".gpx"
|
DeleteRegKey HKCR ".gpx"
|
||||||
|
DeleteRegKey HKCR "${REGTCX}"
|
||||||
|
DeleteRegKey HKCR ".tcx"
|
||||||
|
DeleteRegKey HKCR "${REGKML}"
|
||||||
|
DeleteRegKey HKCR ".kml"
|
||||||
|
DeleteRegKey HKCR "${REGFIT}"
|
||||||
|
DeleteRegKey HKCR ".fit"
|
||||||
|
DeleteRegKey HKCR "${REGIGC}"
|
||||||
|
DeleteRegKey HKCR ".igc"
|
||||||
|
DeleteRegKey HKCR "${REGNMEA}"
|
||||||
|
DeleteRegKey HKCR ".nmea"
|
||||||
System::Call 'shell32.dll::SHChangeNotify(i, i, i, i) v (0x08000000, 0, 0, 0)'
|
System::Call 'shell32.dll::SHChangeNotify(i, i, i, i) v (0x08000000, 0, 0, 0)'
|
||||||
|
|
||||||
SectionEnd
|
SectionEnd
|
||||||
@ -170,4 +212,4 @@ LangString DESC_APP ${LANG_ENGLISH} \
|
|||||||
!insertmacro MUI_DESCRIPTION_TEXT ${SEC_QT} $(DESC_QT)
|
!insertmacro MUI_DESCRIPTION_TEXT ${SEC_QT} $(DESC_QT)
|
||||||
!insertmacro MUI_DESCRIPTION_TEXT ${SEC_MSVC} $(DESC_MSVC)
|
!insertmacro MUI_DESCRIPTION_TEXT ${SEC_MSVC} $(DESC_MSVC)
|
||||||
!insertmacro MUI_DESCRIPTION_TEXT ${SEC_APP} $(DESC_APP)
|
!insertmacro MUI_DESCRIPTION_TEXT ${SEC_APP} $(DESC_APP)
|
||||||
!insertmacro MUI_FUNCTION_DESCRIPTION_END
|
!insertmacro MUI_FUNCTION_DESCRIPTION_END
|
||||||
|
@ -4,7 +4,7 @@
|
|||||||
; The name of the installer
|
; The name of the installer
|
||||||
Name "GPXSee"
|
Name "GPXSee"
|
||||||
; Program version
|
; Program version
|
||||||
!define VERSION "2.19"
|
!define VERSION "3.6"
|
||||||
|
|
||||||
; The file to write
|
; The file to write
|
||||||
OutFile "GPXSee-${VERSION}_x64.exe"
|
OutFile "GPXSee-${VERSION}_x64.exe"
|
||||||
@ -21,8 +21,13 @@ InstallDirRegKey HKLM "Software\GPXSee" "Install_Dir"
|
|||||||
|
|
||||||
; Registry key for uninstaller
|
; Registry key for uninstaller
|
||||||
!define REGENTRY "Software\Microsoft\Windows\CurrentVersion\Uninstall\GPXSee"
|
!define REGENTRY "Software\Microsoft\Windows\CurrentVersion\Uninstall\GPXSee"
|
||||||
; GPX file type registry entry
|
; File types registry entries
|
||||||
!define REGGPX "GPXSee.gpx"
|
!define REGGPX "GPXSee.gpx"
|
||||||
|
!define REGTCX "GPXSee.tcx"
|
||||||
|
!define REGKML "GPXSee.kml"
|
||||||
|
!define REGFIT "GPXSee.fit"
|
||||||
|
!define REGIGC "GPXSee.igc"
|
||||||
|
!define REGNMEA "GPXSee.nmea"
|
||||||
|
|
||||||
; Start menu page configuration
|
; Start menu page configuration
|
||||||
!define MUI_STARTMENUPAGE_REGISTRY_ROOT "HKLM"
|
!define MUI_STARTMENUPAGE_REGISTRY_ROOT "HKLM"
|
||||||
@ -71,18 +76,6 @@ Section "GPXSee (required)" SEC_APP
|
|||||||
File "gpxsee.exe"
|
File "gpxsee.exe"
|
||||||
File "maps.txt"
|
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
|
; Create start menu entry and add links
|
||||||
SetShellVarContext all
|
SetShellVarContext all
|
||||||
!insertmacro MUI_STARTMENU_WRITE_BEGIN Application
|
!insertmacro MUI_STARTMENU_WRITE_BEGIN Application
|
||||||
@ -91,11 +84,48 @@ Section "GPXSee (required)" SEC_APP
|
|||||||
CreateShortCut "$SMPROGRAMS\$StartMenuFolder\GPXSee.lnk" "$INSTDIR\gpxsee.exe"
|
CreateShortCut "$SMPROGRAMS\$StartMenuFolder\GPXSee.lnk" "$INSTDIR\gpxsee.exe"
|
||||||
!insertmacro MUI_STARTMENU_WRITE_END
|
!insertmacro MUI_STARTMENU_WRITE_END
|
||||||
|
|
||||||
; Associate .gpx files
|
; Create the uninstaller
|
||||||
|
WriteUninstaller "$INSTDIR\uninstall.exe"
|
||||||
|
|
||||||
|
; Write the installation path into the registry
|
||||||
|
DetailPrint "Registering application..."
|
||||||
|
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
|
||||||
|
|
||||||
|
; Associate file formats
|
||||||
|
DetailPrint "Associating file types..."
|
||||||
WriteRegStr HKCR ".gpx" "" "${REGGPX}"
|
WriteRegStr HKCR ".gpx" "" "${REGGPX}"
|
||||||
WriteRegStr HKCR "${REGGPX}" "" "GPS Exchange Format"
|
WriteRegStr HKCR "${REGGPX}" "" "GPS Exchange Format"
|
||||||
WriteRegStr HKCR "${REGGPX}\DefaultIcon" "" "$INSTDIR\GPXSee.exe,1"
|
WriteRegStr HKCR "${REGGPX}\DefaultIcon" "" "$INSTDIR\GPXSee.exe,1"
|
||||||
WriteRegStr HKCR "${REGGPX}\shell\open\command" "" "$\"$INSTDIR\GPXSee.exe$\" $\"%1$\""
|
WriteRegStr HKCR "${REGGPX}\shell\open\command" "" "$\"$INSTDIR\GPXSee.exe$\" $\"%1$\""
|
||||||
|
WriteRegStr HKCR ".tcx" "" "${REGTCX}"
|
||||||
|
WriteRegStr HKCR "${REGTCX}" "" "Training Center XML"
|
||||||
|
WriteRegStr HKCR "${REGTCX}\DefaultIcon" "" "$INSTDIR\GPXSee.exe,2"
|
||||||
|
WriteRegStr HKCR "${REGTCX}\shell\open\command" "" "$\"$INSTDIR\GPXSee.exe$\" $\"%1$\""
|
||||||
|
WriteRegStr HKCR ".kml" "" "${REGKML}"
|
||||||
|
WriteRegStr HKCR "${REGKML}" "" "Keyhole Markup Language"
|
||||||
|
WriteRegStr HKCR "${REGKML}\DefaultIcon" "" "$INSTDIR\GPXSee.exe,3"
|
||||||
|
WriteRegStr HKCR "${REGKML}\shell\open\command" "" "$\"$INSTDIR\GPXSee.exe$\" $\"%1$\""
|
||||||
|
WriteRegStr HKCR ".fit" "" "${REGFIT}"
|
||||||
|
WriteRegStr HKCR "${REGFIT}" "" "Flexible and Interoperable Data Transfer"
|
||||||
|
WriteRegStr HKCR "${REGFIT}\DefaultIcon" "" "$INSTDIR\GPXSee.exe,4"
|
||||||
|
WriteRegStr HKCR "${REGFIT}\shell\open\command" "" "$\"$INSTDIR\GPXSee.exe$\" $\"%1$\""
|
||||||
|
WriteRegStr HKCR ".igc" "" "${REGIGC}"
|
||||||
|
WriteRegStr HKCR "${REGIGC}" "" "Flight Recorder Data Format"
|
||||||
|
WriteRegStr HKCR "${REGIGC}\DefaultIcon" "" "$INSTDIR\GPXSee.exe,5"
|
||||||
|
WriteRegStr HKCR "${REGIGC}\shell\open\command" "" "$\"$INSTDIR\GPXSee.exe$\" $\"%1$\""
|
||||||
|
WriteRegStr HKCR ".nmea" "" "${REGNMEA}"
|
||||||
|
WriteRegStr HKCR "${REGNMEA}" "" "NMEA 0183 data"
|
||||||
|
WriteRegStr HKCR "${REGNMEA}\DefaultIcon" "" "$INSTDIR\GPXSee.exe,6"
|
||||||
|
WriteRegStr HKCR "${REGNMEA}\shell\open\command" "" "$\"$INSTDIR\GPXSee.exe$\" $\"%1$\""
|
||||||
|
|
||||||
System::Call 'shell32.dll::SHChangeNotify(i, i, i, i) v (0x08000000, 0, 0, 0)'
|
System::Call 'shell32.dll::SHChangeNotify(i, i, i, i) v (0x08000000, 0, 0, 0)'
|
||||||
|
|
||||||
SectionEnd
|
SectionEnd
|
||||||
@ -108,6 +138,8 @@ Section "QT libs" SEC_QT
|
|||||||
File "Qt5PrintSupport.dll"
|
File "Qt5PrintSupport.dll"
|
||||||
File "Qt5Network.dll"
|
File "Qt5Network.dll"
|
||||||
File "libGLESv2.dll"
|
File "libGLESv2.dll"
|
||||||
|
File "libEGL.dll"
|
||||||
|
File "D3DCompiler_47.dll"
|
||||||
File /r "platforms"
|
File /r "platforms"
|
||||||
File /r "imageformats"
|
File /r "imageformats"
|
||||||
File /r "printsupport"
|
File /r "printsupport"
|
||||||
@ -150,9 +182,19 @@ Section "Uninstall"
|
|||||||
Delete "$SMPROGRAMS\$StartMenuFolder\*.*"
|
Delete "$SMPROGRAMS\$StartMenuFolder\*.*"
|
||||||
RMDir "$SMPROGRAMS\$StartMenuFolder"
|
RMDir "$SMPROGRAMS\$StartMenuFolder"
|
||||||
|
|
||||||
; Remove GPX file association
|
; Remove File associations
|
||||||
DeleteRegKey HKCR "${REGGPX}"
|
DeleteRegKey HKCR "${REGGPX}"
|
||||||
DeleteRegKey HKCR ".gpx"
|
DeleteRegKey HKCR ".gpx"
|
||||||
|
DeleteRegKey HKCR "${REGTCX}"
|
||||||
|
DeleteRegKey HKCR ".tcx"
|
||||||
|
DeleteRegKey HKCR "${REGKML}"
|
||||||
|
DeleteRegKey HKCR ".kml"
|
||||||
|
DeleteRegKey HKCR "${REGFIT}"
|
||||||
|
DeleteRegKey HKCR ".fit"
|
||||||
|
DeleteRegKey HKCR "${REGIGC}"
|
||||||
|
DeleteRegKey HKCR ".igc"
|
||||||
|
DeleteRegKey HKCR "${REGNMEA}"
|
||||||
|
DeleteRegKey HKCR ".nmea"
|
||||||
System::Call 'shell32.dll::SHChangeNotify(i, i, i, i) v (0x08000000, 0, 0, 0)'
|
System::Call 'shell32.dll::SHChangeNotify(i, i, i, i) v (0x08000000, 0, 0, 0)'
|
||||||
|
|
||||||
SectionEnd
|
SectionEnd
|
||||||
@ -174,4 +216,4 @@ LangString DESC_APP ${LANG_ENGLISH} \
|
|||||||
!insertmacro MUI_DESCRIPTION_TEXT ${SEC_QT} $(DESC_QT)
|
!insertmacro MUI_DESCRIPTION_TEXT ${SEC_QT} $(DESC_QT)
|
||||||
!insertmacro MUI_DESCRIPTION_TEXT ${SEC_MSVC} $(DESC_MSVC)
|
!insertmacro MUI_DESCRIPTION_TEXT ${SEC_MSVC} $(DESC_MSVC)
|
||||||
!insertmacro MUI_DESCRIPTION_TEXT ${SEC_APP} $(DESC_APP)
|
!insertmacro MUI_DESCRIPTION_TEXT ${SEC_APP} $(DESC_APP)
|
||||||
!insertmacro MUI_FUNCTION_DESCRIPTION_END
|
!insertmacro MUI_FUNCTION_DESCRIPTION_END
|
||||||
|
@ -3,6 +3,8 @@
|
|||||||
#include <QLocale>
|
#include <QLocale>
|
||||||
#include <QFileOpenEvent>
|
#include <QFileOpenEvent>
|
||||||
#include <QNetworkProxyFactory>
|
#include <QNetworkProxyFactory>
|
||||||
|
#include <QPixmapCache>
|
||||||
|
#include "opengl.h"
|
||||||
#include "gui.h"
|
#include "gui.h"
|
||||||
#include "app.h"
|
#include "app.h"
|
||||||
|
|
||||||
@ -20,6 +22,8 @@ App::App(int &argc, char **argv) : QApplication(argc, argv),
|
|||||||
#endif // Q_OS_MAC
|
#endif // Q_OS_MAC
|
||||||
|
|
||||||
QNetworkProxyFactory::setUseSystemConfiguration(true);
|
QNetworkProxyFactory::setUseSystemConfiguration(true);
|
||||||
|
QPixmapCache::setCacheLimit(65536);
|
||||||
|
OPENGL_SET_SAMPLES(4);
|
||||||
|
|
||||||
_gui = new GUI();
|
_gui = new GUI();
|
||||||
}
|
}
|
||||||
|
11
src/assert.h
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
#ifndef ASSERT_H
|
||||||
|
#define ASSERT_H
|
||||||
|
|
||||||
|
template<bool> struct CompileTimeAssert;
|
||||||
|
template<> struct CompileTimeAssert <true> {};
|
||||||
|
|
||||||
|
#define STATIC_ASSERT(e) \
|
||||||
|
(CompileTimeAssert <(e) != 0>())
|
||||||
|
|
||||||
|
#endif // ASSERT_H
|
||||||
|
|
@ -118,6 +118,7 @@ void AxisItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *option,
|
|||||||
QPen pen = QPen(Qt::black, AXIS_WIDTH);
|
QPen pen = QPen(Qt::black, AXIS_WIDTH);
|
||||||
|
|
||||||
|
|
||||||
|
painter->setRenderHint(QPainter::Antialiasing, false);
|
||||||
painter->setFont(font);
|
painter->setFont(font);
|
||||||
painter->setPen(pen);
|
painter->setPen(pen);
|
||||||
|
|
||||||
@ -202,3 +203,16 @@ QSizeF AxisItem::margin() const
|
|||||||
+ TICK/2, es.height()/2 + fm.descent());
|
+ TICK/2, es.height()/2 + fm.descent());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QList<qreal> AxisItem::ticks() const
|
||||||
|
{
|
||||||
|
struct Label l;
|
||||||
|
QList<qreal> list;
|
||||||
|
|
||||||
|
l = label(_range.min(), _range.max(), (_type == X) ? XTICKS : YTICKS);
|
||||||
|
for (int i = 0; i < ((l.max - l.min) / l.d) + 1; i++)
|
||||||
|
list.append(((_size/_range.size()) * ((l.min + i * l.d)
|
||||||
|
- _range.min())));
|
||||||
|
|
||||||
|
return list;
|
||||||
|
}
|
||||||
|
@ -20,6 +20,7 @@ public:
|
|||||||
void setLabel(const QString& label);
|
void setLabel(const QString& label);
|
||||||
|
|
||||||
QSizeF margin() const;
|
QSizeF margin() const;
|
||||||
|
QList<qreal> ticks() const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void updateBoundingRect();
|
void updateBoundingRect();
|
||||||
|
84
src/cadencegraph.cpp
Normal file
@ -0,0 +1,84 @@
|
|||||||
|
#include "data.h"
|
||||||
|
#include "cadencegraph.h"
|
||||||
|
|
||||||
|
|
||||||
|
CadenceGraph::CadenceGraph(QWidget *parent) : GraphTab(parent)
|
||||||
|
{
|
||||||
|
_units = Metric;
|
||||||
|
_showTracks = true;
|
||||||
|
|
||||||
|
GraphView::setYUnits(tr("1/min"));
|
||||||
|
setYLabel(tr("Cadence"));
|
||||||
|
|
||||||
|
setSliderPrecision(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
void CadenceGraph::setInfo()
|
||||||
|
{
|
||||||
|
if (_showTracks) {
|
||||||
|
GraphView::addInfo(tr("Average"), QString::number(avg() * yScale()
|
||||||
|
+ yOffset(), 'f', 1) + UNIT_SPACE + yUnits());
|
||||||
|
GraphView::addInfo(tr("Maximum"), QString::number(max() * yScale()
|
||||||
|
+ yOffset(), 'f', 1) + UNIT_SPACE + yUnits());
|
||||||
|
} else
|
||||||
|
clearInfo();
|
||||||
|
}
|
||||||
|
|
||||||
|
void CadenceGraph::loadData(const Data &data, const QList<PathItem *> &paths)
|
||||||
|
{
|
||||||
|
for (int i = 0; i < data.tracks().count(); i++) {
|
||||||
|
const Graph &graph = data.tracks().at(i)->cadence();
|
||||||
|
qreal sum = 0, w = 0;
|
||||||
|
|
||||||
|
if (graph.size() < 2) {
|
||||||
|
skipColor();
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (int j = 1; j < graph.size(); j++) {
|
||||||
|
qreal ds = graph.at(j).s() - graph.at(j-1).s();
|
||||||
|
sum += graph.at(j).y() * ds;
|
||||||
|
w += ds;
|
||||||
|
}
|
||||||
|
_avg.append(QPointF(data.tracks().at(i)->distance(), sum/w));
|
||||||
|
|
||||||
|
GraphView::loadGraph(graph, paths.at(i));
|
||||||
|
}
|
||||||
|
|
||||||
|
for (int i = 0; i < data.routes().count(); i++)
|
||||||
|
skipColor();
|
||||||
|
|
||||||
|
setInfo();
|
||||||
|
|
||||||
|
redraw();
|
||||||
|
}
|
||||||
|
|
||||||
|
qreal CadenceGraph::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 CadenceGraph::clear()
|
||||||
|
{
|
||||||
|
_avg.clear();
|
||||||
|
|
||||||
|
GraphView::clear();
|
||||||
|
}
|
||||||
|
|
||||||
|
void CadenceGraph::showTracks(bool show)
|
||||||
|
{
|
||||||
|
_showTracks = show;
|
||||||
|
|
||||||
|
showGraph(show);
|
||||||
|
setInfo();
|
||||||
|
|
||||||
|
redraw();
|
||||||
|
}
|
31
src/cadencegraph.h
Normal file
@ -0,0 +1,31 @@
|
|||||||
|
#ifndef CADENCEGRAPH_H
|
||||||
|
#define CADENCEGRAPH_H
|
||||||
|
|
||||||
|
#include "graphtab.h"
|
||||||
|
|
||||||
|
class CadenceGraph : public GraphTab
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
|
||||||
|
public:
|
||||||
|
CadenceGraph(QWidget *parent = 0);
|
||||||
|
|
||||||
|
QString label() const {return tr("Cadence");}
|
||||||
|
void loadData(const Data &data, const QList<PathItem *> &paths);
|
||||||
|
void clear();
|
||||||
|
void setUnits(enum Units) {}
|
||||||
|
void showTracks(bool show);
|
||||||
|
void showRoutes(bool show) {Q_UNUSED(show);}
|
||||||
|
|
||||||
|
private:
|
||||||
|
qreal avg() const;
|
||||||
|
qreal max() const {return bounds().bottom();}
|
||||||
|
void setInfo();
|
||||||
|
|
||||||
|
QList<QPointF> _avg;
|
||||||
|
|
||||||
|
enum Units _units;
|
||||||
|
bool _showTracks;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // CADENCEGRAPH_H
|
68
src/colorbox.cpp
Normal file
@ -0,0 +1,68 @@
|
|||||||
|
#include <QStylePainter>
|
||||||
|
#include <QStyleOptionComboBox>
|
||||||
|
#include <QMouseEvent>
|
||||||
|
#include <QColorDialog>
|
||||||
|
#include <QComboBox>
|
||||||
|
#include "colorbox.h"
|
||||||
|
|
||||||
|
|
||||||
|
ColorBox::ColorBox(QWidget *parent) : QWidget(parent)
|
||||||
|
{
|
||||||
|
_color = Qt::red;
|
||||||
|
setSizePolicy(QSizePolicy::QSizePolicy::Minimum, QSizePolicy::Fixed);
|
||||||
|
}
|
||||||
|
|
||||||
|
QSize ColorBox::sizeHint() const
|
||||||
|
{
|
||||||
|
static QSize size;
|
||||||
|
if (size.isValid())
|
||||||
|
return size;
|
||||||
|
|
||||||
|
QComboBox cb;
|
||||||
|
size = cb.sizeHint();
|
||||||
|
return size;
|
||||||
|
}
|
||||||
|
|
||||||
|
void ColorBox::paintEvent(QPaintEvent *event)
|
||||||
|
{
|
||||||
|
Q_UNUSED(event);
|
||||||
|
|
||||||
|
QStylePainter painter(this);
|
||||||
|
|
||||||
|
QStyleOptionComboBox option;
|
||||||
|
option.initFrom(this);
|
||||||
|
|
||||||
|
#if defined(Q_OS_MAC) || defined(Q_OS_WIN32)
|
||||||
|
painter.setBrush(_color);
|
||||||
|
painter.drawPrimitive(QStyle::PE_Frame, option);
|
||||||
|
#else // Q_OS_MAC || Q_OS_WIN32
|
||||||
|
// Fallback for some broken QT4 styles that do not draw the background
|
||||||
|
painter.setBrush(_color);
|
||||||
|
painter.setPen(Qt::NoPen);
|
||||||
|
painter.drawRect(event->rect().adjusted(2, 2, -2, -2));
|
||||||
|
// If works (QT5 and most QT4 styles) overpaints the previous rectangle
|
||||||
|
option.palette.setBrush(QPalette::Base, _color);
|
||||||
|
painter.drawPrimitive(QStyle::PE_PanelLineEdit, option);
|
||||||
|
painter.drawPrimitive(QStyle::PE_FrameLineEdit, option);
|
||||||
|
#endif // Q_OS_MAC || Q_OS_WIN32
|
||||||
|
}
|
||||||
|
|
||||||
|
void ColorBox::mousePressEvent(QMouseEvent *event)
|
||||||
|
{
|
||||||
|
if (event->button() != Qt::LeftButton)
|
||||||
|
return;
|
||||||
|
|
||||||
|
QColor color = QColorDialog::getColor(_color, this, QString(),
|
||||||
|
QColorDialog::ShowAlphaChannel);
|
||||||
|
if (color.isValid()) {
|
||||||
|
_color = color;
|
||||||
|
update();
|
||||||
|
emit colorChanged(_color);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void ColorBox::setColor(const QColor &color)
|
||||||
|
{
|
||||||
|
_color = color;
|
||||||
|
update();
|
||||||
|
}
|
29
src/colorbox.h
Normal file
@ -0,0 +1,29 @@
|
|||||||
|
#ifndef COLORBOX_H
|
||||||
|
#define COLORBOX_H
|
||||||
|
|
||||||
|
#include <QWidget>
|
||||||
|
|
||||||
|
class ColorBox : public QWidget
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
|
||||||
|
public:
|
||||||
|
ColorBox(QWidget *parent = 0);
|
||||||
|
|
||||||
|
const QColor &color() const {return _color;}
|
||||||
|
void setColor(const QColor &color);
|
||||||
|
|
||||||
|
QSize sizeHint() const;
|
||||||
|
|
||||||
|
signals:
|
||||||
|
void colorChanged(const QColor &color);
|
||||||
|
|
||||||
|
protected:
|
||||||
|
void mousePressEvent(QMouseEvent *event);
|
||||||
|
void paintEvent(QPaintEvent *event);
|
||||||
|
|
||||||
|
private:
|
||||||
|
QColor _color;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // COLORBOX_H
|
69
src/coordinates.cpp
Normal file
@ -0,0 +1,69 @@
|
|||||||
|
#include "rd.h"
|
||||||
|
#include "wgs84.h"
|
||||||
|
#include "coordinates.h"
|
||||||
|
|
||||||
|
#define MIN_LAT deg2rad(-90.0)
|
||||||
|
#define MAX_LAT deg2rad(90.0)
|
||||||
|
#define MIN_LON deg2rad(-180.0)
|
||||||
|
#define MAX_LON deg2rad(180.0)
|
||||||
|
|
||||||
|
qreal Coordinates::distanceTo(const Coordinates &c) const
|
||||||
|
{
|
||||||
|
qreal dLat = deg2rad(c.lat() - _lat);
|
||||||
|
qreal dLon = deg2rad(c.lon() - _lon);
|
||||||
|
qreal a = pow(sin(dLat / 2.0), 2.0)
|
||||||
|
+ cos(deg2rad(_lat)) * cos(deg2rad(c.lat())) * pow(sin(dLon / 2.0), 2.0);
|
||||||
|
|
||||||
|
return (WGS84_RADIUS * (2.0 * atan2(sqrt(a), sqrt(1.0 - a))));
|
||||||
|
}
|
||||||
|
|
||||||
|
QPointF Coordinates::toMercator() const
|
||||||
|
{
|
||||||
|
return QPointF(_lon, rad2deg(log(tan(M_PI/4.0 + deg2rad(_lat)/2.0))));
|
||||||
|
}
|
||||||
|
|
||||||
|
Coordinates Coordinates::fromMercator(const QPointF &m)
|
||||||
|
{
|
||||||
|
return Coordinates(m.x(), rad2deg(2 * atan(exp(deg2rad(m.y()))) - M_PI/2));
|
||||||
|
}
|
||||||
|
|
||||||
|
bool operator==(const Coordinates &c1, const Coordinates &c2)
|
||||||
|
{
|
||||||
|
return (c1.lat() == c2.lat() && c1.lon() == c2.lon());
|
||||||
|
}
|
||||||
|
|
||||||
|
QDebug operator<<(QDebug dbg, const Coordinates &coordinates)
|
||||||
|
{
|
||||||
|
dbg.nospace() << "Coordinates(" << coordinates.lon() << ", "
|
||||||
|
<< coordinates.lat() << ")";
|
||||||
|
|
||||||
|
return dbg.maybeSpace();
|
||||||
|
}
|
||||||
|
|
||||||
|
QPair<Coordinates, Coordinates> Coordinates::boundingRect(qreal distance) const
|
||||||
|
{
|
||||||
|
qreal radDist = distance / WGS84_RADIUS;
|
||||||
|
|
||||||
|
qreal minLat = deg2rad(_lat) - radDist;
|
||||||
|
qreal maxLat = deg2rad(_lat) + radDist;
|
||||||
|
|
||||||
|
qreal minLon, maxLon;
|
||||||
|
if (minLat > MIN_LAT && maxLat < MAX_LAT) {
|
||||||
|
qreal deltaLon = asin(sin(radDist) / cos(_lat));
|
||||||
|
minLon = deg2rad(_lon) - deltaLon;
|
||||||
|
if (minLon < MIN_LON)
|
||||||
|
minLon += 2.0 * M_PI;
|
||||||
|
maxLon = deg2rad(_lon) + deltaLon;
|
||||||
|
if (maxLon > MAX_LON)
|
||||||
|
maxLon -= 2.0 * M_PI;
|
||||||
|
} else {
|
||||||
|
// a pole is within the distance
|
||||||
|
minLat = qMax(minLat, MIN_LAT);
|
||||||
|
maxLat = qMin(maxLat, MAX_LAT);
|
||||||
|
minLon = MIN_LON;
|
||||||
|
maxLon = MAX_LON;
|
||||||
|
}
|
||||||
|
|
||||||
|
return QPair<Coordinates, Coordinates>(Coordinates(rad2deg(minLon),
|
||||||
|
rad2deg(minLat)), Coordinates(rad2deg(maxLon), rad2deg(maxLat)));
|
||||||
|
}
|
41
src/coordinates.h
Normal file
@ -0,0 +1,41 @@
|
|||||||
|
#ifndef COORDINATES_H
|
||||||
|
#define COORDINATES_H
|
||||||
|
|
||||||
|
#include <cmath>
|
||||||
|
#include <QPointF>
|
||||||
|
#include <QDebug>
|
||||||
|
|
||||||
|
class Coordinates
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
Coordinates() {_lon = NAN; _lat = NAN;}
|
||||||
|
Coordinates(const Coordinates &c) {_lon = c._lon; _lat = c._lat;}
|
||||||
|
Coordinates(qreal lon, qreal lat) {_lon = lon; _lat = lat;}
|
||||||
|
|
||||||
|
qreal &rlon() {return _lon;}
|
||||||
|
qreal &rlat() {return _lat;}
|
||||||
|
void setLon(qreal lon) {_lon = lon;}
|
||||||
|
void setLat(qreal lat) {_lat = lat;}
|
||||||
|
qreal lon() const {return _lon;}
|
||||||
|
qreal lat() const {return _lat;}
|
||||||
|
|
||||||
|
bool isNull() const
|
||||||
|
{return (std::isnan(_lon) || std::isnan(_lat)) ? true : false;}
|
||||||
|
bool isValid() const
|
||||||
|
{return (_lon >= -180.0 && _lon <= 180.0 && _lat >= -90.0
|
||||||
|
&& _lat <= 90.0) ? true : false;}
|
||||||
|
|
||||||
|
qreal distanceTo(const Coordinates &c) const;
|
||||||
|
QPair<Coordinates, Coordinates> boundingRect(qreal distance) const;
|
||||||
|
|
||||||
|
QPointF toMercator() const;
|
||||||
|
static Coordinates fromMercator(const QPointF &m);
|
||||||
|
|
||||||
|
private:
|
||||||
|
qreal _lat, _lon;
|
||||||
|
};
|
||||||
|
|
||||||
|
bool operator==(const Coordinates &c1, const Coordinates &c2);
|
||||||
|
QDebug operator<<(QDebug dbg, const Coordinates &trackpoint);
|
||||||
|
|
||||||
|
#endif // COORDINATES_H
|
44
src/csvparser.cpp
Normal file
@ -0,0 +1,44 @@
|
|||||||
|
#include "csvparser.h"
|
||||||
|
|
||||||
|
bool CSVParser::loadFile(QFile *file)
|
||||||
|
{
|
||||||
|
bool res;
|
||||||
|
|
||||||
|
_errorLine = 1;
|
||||||
|
_errorString.clear();
|
||||||
|
|
||||||
|
while (!file->atEnd()) {
|
||||||
|
QByteArray line = file->readLine();
|
||||||
|
QList<QByteArray> list = line.split(',');
|
||||||
|
if (list.size() < 3) {
|
||||||
|
_errorString = "Parse error";
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
qreal lat = list[0].trimmed().toDouble(&res);
|
||||||
|
if (!res || (lat < -90.0 || lat > 90.0)) {
|
||||||
|
_errorString = "Invalid latitude";
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
qreal lon = list[1].trimmed().toDouble(&res);
|
||||||
|
if (!res || (lon < -180.0 || lon > 180.0)) {
|
||||||
|
_errorString = "Invalid longitude";
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
Waypoint wp(Coordinates(lon, lat));
|
||||||
|
|
||||||
|
QByteArray ba = list[2].trimmed();
|
||||||
|
QString name = QString::fromUtf8(ba.data(), ba.size());
|
||||||
|
wp.setName(name);
|
||||||
|
|
||||||
|
if (list.size() > 3) {
|
||||||
|
ba = list[3].trimmed();
|
||||||
|
wp.setDescription(QString::fromUtf8(ba.data(), ba.size()));
|
||||||
|
}
|
||||||
|
|
||||||
|
_waypoints.append(wp);
|
||||||
|
_errorLine++;
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
23
src/csvparser.h
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
#ifndef CSVPARSER_H
|
||||||
|
#define CSVPARSER_H
|
||||||
|
|
||||||
|
#include "parser.h"
|
||||||
|
|
||||||
|
class CSVParser : public Parser
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
CSVParser(QList<TrackData> &tracks, QList<RouteData> &routes,
|
||||||
|
QList<Waypoint> &waypoints) : Parser(tracks, routes, waypoints)
|
||||||
|
{_errorLine = 0;}
|
||||||
|
~CSVParser() {}
|
||||||
|
|
||||||
|
bool loadFile(QFile *file);
|
||||||
|
QString errorString() const {return _errorString;}
|
||||||
|
int errorLine() const {return _errorLine;}
|
||||||
|
|
||||||
|
private:
|
||||||
|
QString _errorString;
|
||||||
|
int _errorLine;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // CSVPARSER_H
|
95
src/data.cpp
Normal file
@ -0,0 +1,95 @@
|
|||||||
|
#include <QFile>
|
||||||
|
#include <QFileInfo>
|
||||||
|
#include <QLineF>
|
||||||
|
#include "gpxparser.h"
|
||||||
|
#include "tcxparser.h"
|
||||||
|
#include "csvparser.h"
|
||||||
|
#include "kmlparser.h"
|
||||||
|
#include "fitparser.h"
|
||||||
|
#include "igcparser.h"
|
||||||
|
#include "nmeaparser.h"
|
||||||
|
#include "data.h"
|
||||||
|
|
||||||
|
|
||||||
|
Data::Data() : _errorLine(0)
|
||||||
|
{
|
||||||
|
_parsers.insert("gpx", new GPXParser(_trackData, _routeData,
|
||||||
|
_waypointData));
|
||||||
|
_parsers.insert("tcx", new TCXParser(_trackData, _routeData,
|
||||||
|
_waypointData));
|
||||||
|
_parsers.insert("kml", new KMLParser(_trackData, _routeData,
|
||||||
|
_waypointData));
|
||||||
|
_parsers.insert("fit", new FITParser(_trackData, _routeData,
|
||||||
|
_waypointData));
|
||||||
|
_parsers.insert("csv", new CSVParser(_trackData, _routeData,
|
||||||
|
_waypointData));
|
||||||
|
_parsers.insert("igc", new IGCParser(_trackData, _routeData,
|
||||||
|
_waypointData));
|
||||||
|
_parsers.insert("nmea", new NMEAParser(_trackData, _routeData,
|
||||||
|
_waypointData));
|
||||||
|
}
|
||||||
|
|
||||||
|
Data::~Data()
|
||||||
|
{
|
||||||
|
QHash<QString, Parser*>::iterator it;
|
||||||
|
|
||||||
|
for (it = _parsers.begin(); it != _parsers.end(); it++)
|
||||||
|
delete it.value();
|
||||||
|
|
||||||
|
for (int i = 0; i < _tracks.count(); i++)
|
||||||
|
delete _tracks.at(i);
|
||||||
|
for (int i = 0; i < _routes.count(); i++)
|
||||||
|
delete _routes.at(i);
|
||||||
|
}
|
||||||
|
|
||||||
|
void Data::createData()
|
||||||
|
{
|
||||||
|
for (int i = 0; i < _trackData.count(); i++)
|
||||||
|
_tracks.append(new Track(_trackData.at(i)));
|
||||||
|
for (int i = 0; i < _routeData.count(); i++)
|
||||||
|
_routes.append(new Route(_routeData.at(i)));
|
||||||
|
}
|
||||||
|
|
||||||
|
bool Data::loadFile(const QString &fileName)
|
||||||
|
{
|
||||||
|
QFile file(fileName);
|
||||||
|
QFileInfo fi(fileName);
|
||||||
|
|
||||||
|
|
||||||
|
_errorString.clear();
|
||||||
|
_errorLine = 0;
|
||||||
|
|
||||||
|
if (!file.open(QFile::ReadOnly)) {
|
||||||
|
_errorString = qPrintable(file.errorString());
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
QHash<QString, Parser*>::iterator it;
|
||||||
|
if ((it = _parsers.find(fi.suffix().toLower())) != _parsers.end()) {
|
||||||
|
if (it.value()->loadFile(&file)) {
|
||||||
|
createData();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
_errorLine = it.value()->errorLine();
|
||||||
|
_errorString = it.value()->errorString();
|
||||||
|
} else {
|
||||||
|
for (it = _parsers.begin(); it != _parsers.end(); it++) {
|
||||||
|
if (it.value()->loadFile(&file)) {
|
||||||
|
createData();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
file.reset();
|
||||||
|
}
|
||||||
|
|
||||||
|
fprintf(stderr, "Error loading data file: %s:\n", qPrintable(fileName));
|
||||||
|
for (it = _parsers.begin(); it != _parsers.end(); it++)
|
||||||
|
fprintf(stderr, "%s: line %d: %s\n", qPrintable(it.key()),
|
||||||
|
it.value()->errorLine(), qPrintable(it.value()->errorString()));
|
||||||
|
|
||||||
|
_errorLine = 0;
|
||||||
|
_errorString = "Unknown format";
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
@ -1,8 +1,9 @@
|
|||||||
#ifndef GPX_H
|
#ifndef DATA_H
|
||||||
#define GPX_H
|
#define DATA_H
|
||||||
|
|
||||||
#include <QVector>
|
#include <QVector>
|
||||||
#include <QList>
|
#include <QList>
|
||||||
|
#include <QHash>
|
||||||
#include <QPointF>
|
#include <QPointF>
|
||||||
#include <QString>
|
#include <QString>
|
||||||
#include "waypoint.h"
|
#include "waypoint.h"
|
||||||
@ -10,31 +11,34 @@
|
|||||||
#include "route.h"
|
#include "route.h"
|
||||||
#include "parser.h"
|
#include "parser.h"
|
||||||
|
|
||||||
class GPX
|
|
||||||
|
class Data
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
GPX();
|
Data();
|
||||||
~GPX();
|
~Data();
|
||||||
|
|
||||||
bool loadFile(const QString &fileName);
|
bool loadFile(const QString &fileName);
|
||||||
const QString &errorString() const {return _error;}
|
const QString &errorString() const {return _errorString;}
|
||||||
int errorLine() const {return _errorLine;}
|
int errorLine() const {return _errorLine;}
|
||||||
|
|
||||||
const QList<Track*> &tracks() const {return _tracks;}
|
const QList<Track*> &tracks() const {return _tracks;}
|
||||||
const QList<Route*> &routes() const {return _routes;}
|
const QList<Route*> &routes() const {return _routes;}
|
||||||
const QList<Waypoint> &waypoints() const {return _waypoint_data;}
|
const QList<Waypoint> &waypoints() const {return _waypointData;}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Parser _parser;
|
void createData();
|
||||||
QString _error;
|
|
||||||
|
QString _errorString;
|
||||||
int _errorLine;
|
int _errorLine;
|
||||||
|
QHash<QString, Parser*> _parsers;
|
||||||
|
|
||||||
QList<Track*> _tracks;
|
QList<Track*> _tracks;
|
||||||
QList<Route*> _routes;
|
QList<Route*> _routes;
|
||||||
|
|
||||||
QList<QVector<Trackpoint> > _track_data;
|
QList<TrackData> _trackData;
|
||||||
QList<QVector<Waypoint> > _route_data;
|
QList<RouteData> _routeData;
|
||||||
QList<Waypoint> _waypoint_data;
|
QList<Waypoint> _waypointData;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // GPX_H
|
#endif // DATA_H
|
@ -17,25 +17,39 @@
|
|||||||
#define USER_AGENT \
|
#define USER_AGENT \
|
||||||
APP_NAME "/" APP_VERSION " (" PLATFORM_STR "; Qt " QT_VERSION_STR ")"
|
APP_NAME "/" APP_VERSION " (" PLATFORM_STR "; Qt " QT_VERSION_STR ")"
|
||||||
|
|
||||||
|
#define ATTR_REDIRECT QNetworkRequest::RedirectionTargetAttribute
|
||||||
|
#define ATTR_FILE QNetworkRequest::User
|
||||||
|
#define ATTR_ORIGIN (QNetworkRequest::Attribute)(QNetworkRequest::User + 1)
|
||||||
|
#define ATTR_LEVEL (QNetworkRequest::Attribute)(QNetworkRequest::User + 2)
|
||||||
|
|
||||||
|
#define MAX_REDIRECT_LEVEL 5
|
||||||
|
|
||||||
|
|
||||||
Downloader::Downloader()
|
Downloader::Downloader()
|
||||||
{
|
{
|
||||||
connect(&_manager, SIGNAL(finished(QNetworkReply*)),
|
connect(&_manager, SIGNAL(finished(QNetworkReply*)),
|
||||||
SLOT(downloadFinished(QNetworkReply*)));
|
SLOT(downloadFinished(QNetworkReply*)));
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Downloader::doDownload(const Download &dl)
|
bool Downloader::doDownload(const Download &dl, const Redirect &redirect)
|
||||||
{
|
{
|
||||||
QUrl url(dl.url());
|
QUrl url(dl.url());
|
||||||
|
|
||||||
if (_errorDownloads.contains(url))
|
if (_errorDownloads.contains(url))
|
||||||
return false;
|
return false;
|
||||||
|
if (_currentDownloads.contains(url))
|
||||||
|
return false;
|
||||||
|
|
||||||
QNetworkRequest request(url);
|
QNetworkRequest request(url);
|
||||||
request.setAttribute(QNetworkRequest::User, QVariant(dl.file()));
|
request.setAttribute(ATTR_FILE, QVariant(dl.file()));
|
||||||
|
if (!redirect.isNull()) {
|
||||||
|
request.setAttribute(ATTR_ORIGIN, QVariant(redirect.origin()));
|
||||||
|
request.setAttribute(ATTR_LEVEL, QVariant(redirect.level()));
|
||||||
|
}
|
||||||
request.setRawHeader("User-Agent", USER_AGENT);
|
request.setRawHeader("User-Agent", USER_AGENT);
|
||||||
QNetworkReply *reply = _manager.get(request);
|
QNetworkReply *reply = _manager.get(request);
|
||||||
|
|
||||||
_currentDownloads.append(reply);
|
_currentDownloads.insert(url, reply);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -58,26 +72,49 @@ bool Downloader::saveToDisk(const QString &filename, QIODevice *data)
|
|||||||
|
|
||||||
void Downloader::downloadFinished(QNetworkReply *reply)
|
void Downloader::downloadFinished(QNetworkReply *reply)
|
||||||
{
|
{
|
||||||
QUrl url = reply->url();
|
QUrl url = reply->request().url();
|
||||||
|
|
||||||
if (reply->error()) {
|
if (reply->error()) {
|
||||||
_errorDownloads.insert(url);
|
QUrl origin = reply->request().attribute(ATTR_ORIGIN).toUrl();
|
||||||
fprintf(stderr, "Error downloading map tile: %s: %s\n",
|
if (origin.isEmpty()) {
|
||||||
url.toEncoded().constData(), qPrintable(reply->errorString()));
|
_errorDownloads.insert(url);
|
||||||
|
fprintf(stderr, "Error downloading map tile: %s: %s\n",
|
||||||
|
url.toEncoded().constData(), qPrintable(reply->errorString()));
|
||||||
|
} else {
|
||||||
|
_errorDownloads.insert(origin);
|
||||||
|
fprintf(stderr, "Error downloading map tile: %s -> %s: %s\n",
|
||||||
|
origin.toEncoded().constData(), url.toEncoded().constData(),
|
||||||
|
qPrintable(reply->errorString()));
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
QUrl redirect = reply->attribute(
|
QUrl location = reply->attribute(ATTR_REDIRECT).toUrl();
|
||||||
QNetworkRequest::RedirectionTargetAttribute).toUrl();
|
QString filename = reply->request().attribute(ATTR_FILE)
|
||||||
QString filename = reply->request().attribute(QNetworkRequest::User)
|
|
||||||
.toString();
|
.toString();
|
||||||
|
|
||||||
if (!redirect.isEmpty()) {
|
if (!location.isEmpty()) {
|
||||||
Download dl(redirect, filename);
|
QUrl origin = reply->request().attribute(ATTR_ORIGIN).toUrl();
|
||||||
doDownload(dl);
|
int level = reply->request().attribute(ATTR_LEVEL).toInt();
|
||||||
|
|
||||||
|
if (location == url) {
|
||||||
|
_errorDownloads.insert(url);
|
||||||
|
fprintf(stderr, "Error downloading map tile: %s: "
|
||||||
|
"redirect loop\n", url.toEncoded().constData());
|
||||||
|
} else if (level >= MAX_REDIRECT_LEVEL) {
|
||||||
|
_errorDownloads.insert(origin);
|
||||||
|
fprintf(stderr, "Error downloading map tile: %s: "
|
||||||
|
"redirect level limit reached\n",
|
||||||
|
origin.toEncoded().constData());
|
||||||
|
} else {
|
||||||
|
Redirect redirect(origin.isEmpty() ? url : origin, level + 1);
|
||||||
|
Download dl(location, filename);
|
||||||
|
doDownload(dl, redirect);
|
||||||
|
}
|
||||||
} else
|
} else
|
||||||
if (!saveToDisk(filename, reply))
|
if (!saveToDisk(filename, reply))
|
||||||
_errorDownloads.insert(url);
|
_errorDownloads.insert(url);
|
||||||
}
|
}
|
||||||
|
|
||||||
_currentDownloads.removeAll(reply);
|
_currentDownloads.remove(url);
|
||||||
reply->deleteLater();
|
reply->deleteLater();
|
||||||
|
|
||||||
if (_currentDownloads.isEmpty())
|
if (_currentDownloads.isEmpty())
|
||||||
|
@ -5,7 +5,7 @@
|
|||||||
#include <QNetworkRequest>
|
#include <QNetworkRequest>
|
||||||
#include <QNetworkReply>
|
#include <QNetworkReply>
|
||||||
#include <QUrl>
|
#include <QUrl>
|
||||||
#include <QList>
|
#include <QMap>
|
||||||
#include <QSet>
|
#include <QSet>
|
||||||
|
|
||||||
|
|
||||||
@ -39,15 +39,32 @@ private slots:
|
|||||||
void downloadFinished(QNetworkReply *reply);
|
void downloadFinished(QNetworkReply *reply);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
class Redirect
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
Redirect() : _level(0) {}
|
||||||
|
Redirect(const QUrl &origin, int level) :
|
||||||
|
_origin(origin), _level(level) {}
|
||||||
|
|
||||||
|
const QUrl &origin() const {return _origin;}
|
||||||
|
int level() const {return _level;}
|
||||||
|
|
||||||
|
bool isNull() const {return (_level == 0);}
|
||||||
|
|
||||||
|
private:
|
||||||
|
QUrl _origin;
|
||||||
|
int _level;
|
||||||
|
};
|
||||||
|
|
||||||
Downloader();
|
Downloader();
|
||||||
Downloader(Downloader const&);
|
Downloader(Downloader const&);
|
||||||
void operator=(Downloader const&);
|
void operator=(Downloader const&);
|
||||||
|
|
||||||
bool doDownload(const Download &dl);
|
bool doDownload(const Download &dl, const Redirect &redirect = Redirect());
|
||||||
bool saveToDisk(const QString &filename, QIODevice *data);
|
bool saveToDisk(const QString &filename, QIODevice *data);
|
||||||
|
|
||||||
QNetworkAccessManager _manager;
|
QNetworkAccessManager _manager;
|
||||||
QList<QNetworkReply *> _currentDownloads;
|
QMap<QUrl, QNetworkReply *> _currentDownloads;
|
||||||
QSet<QUrl> _errorDownloads;
|
QSet<QUrl> _errorDownloads;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
#include <cmath>
|
#include <cmath>
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
#include "gpx.h"
|
#include "data.h"
|
||||||
#include "elevationgraph.h"
|
#include "elevationgraph.h"
|
||||||
|
|
||||||
|
|
||||||
@ -107,14 +107,14 @@ void ElevationGraph::loadGraph(const Graph &graph, Type type, PathItem *path)
|
|||||||
GraphView::loadGraph(graph, path, type);
|
GraphView::loadGraph(graph, path, type);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ElevationGraph::loadGPX(const GPX &gpx, const QList<PathItem *> &paths)
|
void ElevationGraph::loadData(const Data &data, const QList<PathItem *> &paths)
|
||||||
{
|
{
|
||||||
int p = 0;
|
int p = 0;
|
||||||
|
|
||||||
for (int i = 0; i < gpx.tracks().count(); i++)
|
for (int i = 0; i < data.tracks().count(); i++)
|
||||||
loadGraph(gpx.tracks().at(i)->elevation(), Track, paths.at(p++));
|
loadGraph(data.tracks().at(i)->elevation(), Track, paths.at(p++));
|
||||||
for (int i = 0; i < gpx.routes().count(); i++)
|
for (int i = 0; i < data.routes().count(); i++)
|
||||||
loadGraph(gpx.routes().at(i)->elevation(), Route, paths.at(p++));
|
loadGraph(data.routes().at(i)->elevation(), Route, paths.at(p++));
|
||||||
|
|
||||||
setInfo();
|
setInfo();
|
||||||
|
|
||||||
|
@ -3,9 +3,6 @@
|
|||||||
|
|
||||||
#include "graphtab.h"
|
#include "graphtab.h"
|
||||||
|
|
||||||
class GPX;
|
|
||||||
class PathItem;
|
|
||||||
|
|
||||||
class ElevationGraph : public GraphTab
|
class ElevationGraph : public GraphTab
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
@ -14,7 +11,7 @@ public:
|
|||||||
ElevationGraph(QWidget *parent = 0);
|
ElevationGraph(QWidget *parent = 0);
|
||||||
|
|
||||||
QString label() const {return tr("Elevation");}
|
QString label() const {return tr("Elevation");}
|
||||||
void loadGPX(const GPX &gpx, const QList<PathItem *> &paths);
|
void loadData(const Data &data, const QList<PathItem *> &paths);
|
||||||
void clear();
|
void clear();
|
||||||
void setUnits(enum Units units);
|
void setUnits(enum Units units);
|
||||||
void showTracks(bool show);
|
void showTracks(bool show);
|
||||||
|
@ -11,23 +11,19 @@
|
|||||||
#include <QMessageBox>
|
#include <QMessageBox>
|
||||||
#include <QTabWidget>
|
#include <QTabWidget>
|
||||||
#include <QDoubleSpinBox>
|
#include <QDoubleSpinBox>
|
||||||
#include <QLocale>
|
|
||||||
#include "fileselectwidget.h"
|
#include "fileselectwidget.h"
|
||||||
#include "units.h"
|
#include "units.h"
|
||||||
#include "exportdialog.h"
|
#include "exportdialog.h"
|
||||||
|
|
||||||
|
|
||||||
ExportDialog::ExportDialog(QPrinter *printer, QWidget *parent)
|
ExportDialog::ExportDialog(Export *exp, QWidget *parent)
|
||||||
: QDialog(parent), _printer(printer)
|
: QDialog(parent), _export(exp)
|
||||||
{
|
{
|
||||||
int index;
|
int index;
|
||||||
|
|
||||||
_units = (QLocale::system().measurementSystem()
|
|
||||||
== QLocale::ImperialSystem) ? QPrinter::Inch : QPrinter::Millimeter;
|
|
||||||
|
|
||||||
_fileSelect = new FileSelectWidget();
|
_fileSelect = new FileSelectWidget();
|
||||||
_fileSelect->setFilter(tr("PDF files (*.pdf);;All files (*)"));
|
_fileSelect->setFilter(tr("PDF files (*.pdf);;All files (*)"));
|
||||||
_fileSelect->setFile(_printer->outputFileName());
|
_fileSelect->setFile(_export->fileName);
|
||||||
|
|
||||||
_paperSize = new QComboBox();
|
_paperSize = new QComboBox();
|
||||||
_paperSize->addItem("A3", QPrinter::A3);
|
_paperSize->addItem("A3", QPrinter::A3);
|
||||||
@ -36,7 +32,7 @@ ExportDialog::ExportDialog(QPrinter *printer, QWidget *parent)
|
|||||||
_paperSize->addItem("Tabloid", QPrinter::Tabloid);
|
_paperSize->addItem("Tabloid", QPrinter::Tabloid);
|
||||||
_paperSize->addItem("Legal", QPrinter::Legal);
|
_paperSize->addItem("Legal", QPrinter::Legal);
|
||||||
_paperSize->addItem("Letter", QPrinter::Letter);
|
_paperSize->addItem("Letter", QPrinter::Letter);
|
||||||
if ((index = _paperSize->findData(_printer->paperSize())) >= 0)
|
if ((index = _paperSize->findData(_export->paperSize)) >= 0)
|
||||||
_paperSize->setCurrentIndex(index);
|
_paperSize->setCurrentIndex(index);
|
||||||
|
|
||||||
_portrait = new QRadioButton(tr("Portrait"));
|
_portrait = new QRadioButton(tr("Portrait"));
|
||||||
@ -44,32 +40,34 @@ ExportDialog::ExportDialog(QPrinter *printer, QWidget *parent)
|
|||||||
QHBoxLayout *orientationLayout = new QHBoxLayout();
|
QHBoxLayout *orientationLayout = new QHBoxLayout();
|
||||||
orientationLayout->addWidget(_portrait);
|
orientationLayout->addWidget(_portrait);
|
||||||
orientationLayout->addWidget(_landscape);
|
orientationLayout->addWidget(_landscape);
|
||||||
if (_printer->orientation() == QPrinter::Portrait)
|
if (_export->orientation == QPrinter::Portrait)
|
||||||
_portrait->setChecked(true);
|
_portrait->setChecked(true);
|
||||||
else
|
else
|
||||||
_landscape->setChecked(true);
|
_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();
|
_topMargin = new QDoubleSpinBox();
|
||||||
_bottomMargin = new QDoubleSpinBox();
|
_bottomMargin = new QDoubleSpinBox();
|
||||||
_leftMargin = new QDoubleSpinBox();
|
_leftMargin = new QDoubleSpinBox();
|
||||||
_rightMargin = new QDoubleSpinBox();
|
_rightMargin = new QDoubleSpinBox();
|
||||||
_topMargin->setValue(top);
|
QString us = (_export->units == Imperial) ? tr("in") : tr("mm");
|
||||||
_topMargin->setSuffix(UNIT_SPACE + us);
|
_topMargin->setSuffix(UNIT_SPACE + us);
|
||||||
_bottomMargin->setValue(bottom);
|
|
||||||
_bottomMargin->setSuffix(UNIT_SPACE + us);
|
_bottomMargin->setSuffix(UNIT_SPACE + us);
|
||||||
_leftMargin->setValue(left);
|
|
||||||
_leftMargin->setSuffix(UNIT_SPACE + us);
|
_leftMargin->setSuffix(UNIT_SPACE + us);
|
||||||
_rightMargin->setValue(right);
|
|
||||||
_rightMargin->setSuffix(UNIT_SPACE + us);
|
_rightMargin->setSuffix(UNIT_SPACE + us);
|
||||||
if (_units == QPrinter::Inch) {
|
if (_export->units == Imperial) {
|
||||||
|
_topMargin->setValue(_export->margins.top() * MM2IN);
|
||||||
|
_bottomMargin->setValue(_export->margins.bottom() * MM2IN);
|
||||||
|
_leftMargin->setValue(_export->margins.left() * MM2IN);
|
||||||
|
_rightMargin->setValue(_export->margins.right() * MM2IN);
|
||||||
_topMargin->setSingleStep(0.1);
|
_topMargin->setSingleStep(0.1);
|
||||||
_bottomMargin->setSingleStep(0.1);
|
_bottomMargin->setSingleStep(0.1);
|
||||||
_leftMargin->setSingleStep(0.1);
|
_leftMargin->setSingleStep(0.1);
|
||||||
_rightMargin->setSingleStep(0.1);
|
_rightMargin->setSingleStep(0.1);
|
||||||
|
} else {
|
||||||
|
_topMargin->setValue(_export->margins.top());
|
||||||
|
_bottomMargin->setValue(_export->margins.bottom());
|
||||||
|
_leftMargin->setValue(_export->margins.left());
|
||||||
|
_rightMargin->setValue(_export->margins.right());
|
||||||
}
|
}
|
||||||
|
|
||||||
QGridLayout *marginsLayout = new QGridLayout();
|
QGridLayout *marginsLayout = new QGridLayout();
|
||||||
@ -91,6 +89,7 @@ ExportDialog::ExportDialog(QPrinter *printer, QWidget *parent)
|
|||||||
line->setFrameShadow(QFrame::Sunken);
|
line->setFrameShadow(QFrame::Sunken);
|
||||||
pageSetupLayout->addRow(line);
|
pageSetupLayout->addRow(line);
|
||||||
pageSetupLayout->addRow(tr("File:"), _fileSelect);
|
pageSetupLayout->addRow(tr("File:"), _fileSelect);
|
||||||
|
pageSetupLayout->setFieldGrowthPolicy(QFormLayout::ExpandingFieldsGrow);
|
||||||
#else // Q_OS_MAC
|
#else // Q_OS_MAC
|
||||||
pageSetupBox->setLayout(pageSetupLayout);
|
pageSetupBox->setLayout(pageSetupLayout);
|
||||||
#endif // Q_OS_MAC
|
#endif // Q_OS_MAC
|
||||||
@ -163,12 +162,16 @@ void ExportDialog::accept()
|
|||||||
QPrinter::PaperSize paperSize = static_cast<QPrinter::PaperSize>
|
QPrinter::PaperSize paperSize = static_cast<QPrinter::PaperSize>
|
||||||
(_paperSize->itemData(_paperSize->currentIndex()).toInt());
|
(_paperSize->itemData(_paperSize->currentIndex()).toInt());
|
||||||
|
|
||||||
_printer->setOutputFormat(QPrinter::PdfFormat);
|
_export->fileName = _fileSelect->file();
|
||||||
_printer->setOutputFileName(_fileSelect->file());
|
_export->paperSize = paperSize;
|
||||||
_printer->setPaperSize(paperSize);
|
_export->orientation = orientation;
|
||||||
_printer->setOrientation(orientation);
|
if (_export->units == Imperial)
|
||||||
_printer->setPageMargins(_leftMargin->value(), _topMargin->value(),
|
_export->margins = MarginsF(_leftMargin->value() / MM2IN,
|
||||||
_rightMargin->value(), _bottomMargin->value(), _units);
|
_topMargin->value() / MM2IN, _rightMargin->value() / MM2IN,
|
||||||
|
_bottomMargin->value() / MM2IN);
|
||||||
|
else
|
||||||
|
_export->margins = MarginsF(_leftMargin->value(), _topMargin->value(),
|
||||||
|
_rightMargin->value(), _bottomMargin->value());
|
||||||
|
|
||||||
QDialog::accept();
|
QDialog::accept();
|
||||||
}
|
}
|
||||||
|
@ -3,18 +3,29 @@
|
|||||||
|
|
||||||
#include <QDialog>
|
#include <QDialog>
|
||||||
#include <QPrinter>
|
#include <QPrinter>
|
||||||
|
#include "margins.h"
|
||||||
|
#include "units.h"
|
||||||
|
|
||||||
class QComboBox;
|
class QComboBox;
|
||||||
class QRadioButton;
|
class QRadioButton;
|
||||||
class FileSelectWidget;
|
class FileSelectWidget;
|
||||||
class QDoubleSpinBox;
|
class QDoubleSpinBox;
|
||||||
|
|
||||||
|
struct Export {
|
||||||
|
QString fileName;
|
||||||
|
QPrinter::PaperSize paperSize;
|
||||||
|
QPrinter::Orientation orientation;
|
||||||
|
MarginsF margins;
|
||||||
|
|
||||||
|
Units units;
|
||||||
|
};
|
||||||
|
|
||||||
class ExportDialog : public QDialog
|
class ExportDialog : public QDialog
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
ExportDialog(QPrinter *printer, QWidget *parent = 0);
|
ExportDialog(Export *exp, QWidget *parent = 0);
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
void accept();
|
void accept();
|
||||||
@ -22,9 +33,7 @@ public slots:
|
|||||||
private:
|
private:
|
||||||
bool checkFile();
|
bool checkFile();
|
||||||
|
|
||||||
QPrinter *_printer;
|
Export *_export;
|
||||||
|
|
||||||
QPrinter::Unit _units;
|
|
||||||
|
|
||||||
FileSelectWidget *_fileSelect;
|
FileSelectWidget *_fileSelect;
|
||||||
QComboBox *_paperSize;
|
QComboBox *_paperSize;
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
#include <QPushButton>
|
#include <QPushButton>
|
||||||
|
#include <QToolButton>
|
||||||
#include <QFileDialog>
|
#include <QFileDialog>
|
||||||
#include <QHBoxLayout>
|
#include <QHBoxLayout>
|
||||||
#include <QFileInfo>
|
#include <QFileInfo>
|
||||||
@ -12,7 +13,13 @@ FileSelectWidget::FileSelectWidget(QWidget *parent) : QWidget(parent)
|
|||||||
QFontMetrics fm(QApplication::font());
|
QFontMetrics fm(QApplication::font());
|
||||||
_edit = new QLineEdit();
|
_edit = new QLineEdit();
|
||||||
_edit->setMinimumWidth(fm.boundingRect(QDir::homePath()).width());
|
_edit->setMinimumWidth(fm.boundingRect(QDir::homePath()).width());
|
||||||
_button = new QPushButton(tr("Browse..."));
|
#ifdef Q_OS_WIN32
|
||||||
|
_button = new QPushButton("...");
|
||||||
|
_button->setMaximumWidth(_button->sizeHint().width() / 2);
|
||||||
|
#else // Q_OS_WIN32
|
||||||
|
_button = new QToolButton();
|
||||||
|
_button->setText("...");
|
||||||
|
#endif // Q_OS_WIN32
|
||||||
connect(_button, SIGNAL(clicked()), this, SLOT(browse()));
|
connect(_button, SIGNAL(clicked()), this, SLOT(browse()));
|
||||||
|
|
||||||
QHBoxLayout *layout = new QHBoxLayout();
|
QHBoxLayout *layout = new QHBoxLayout();
|
||||||
@ -20,6 +27,9 @@ FileSelectWidget::FileSelectWidget(QWidget *parent) : QWidget(parent)
|
|||||||
layout->addWidget(_edit);
|
layout->addWidget(_edit);
|
||||||
layout->addWidget(_button);
|
layout->addWidget(_button);
|
||||||
setLayout(layout);
|
setLayout(layout);
|
||||||
|
|
||||||
|
QSizePolicy p(QSizePolicy::MinimumExpanding, QSizePolicy::Fixed);
|
||||||
|
setSizePolicy(p);
|
||||||
}
|
}
|
||||||
|
|
||||||
void FileSelectWidget::browse()
|
void FileSelectWidget::browse()
|
||||||
|
@ -5,6 +5,7 @@
|
|||||||
#include <QLineEdit>
|
#include <QLineEdit>
|
||||||
|
|
||||||
class QPushButton;
|
class QPushButton;
|
||||||
|
class QToolButton;
|
||||||
|
|
||||||
class FileSelectWidget : public QWidget
|
class FileSelectWidget : public QWidget
|
||||||
{
|
{
|
||||||
@ -22,7 +23,11 @@ private slots:
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
QLineEdit *_edit;
|
QLineEdit *_edit;
|
||||||
|
#ifdef Q_OS_WIN32
|
||||||
QPushButton *_button;
|
QPushButton *_button;
|
||||||
|
#else // Q_OS_WIN32
|
||||||
|
QToolButton *_button;
|
||||||
|
#endif // Q_OS_WIN32
|
||||||
|
|
||||||
QString _filter;
|
QString _filter;
|
||||||
};
|
};
|
||||||
|
361
src/fitparser.cpp
Normal file
@ -0,0 +1,361 @@
|
|||||||
|
#include <cstring>
|
||||||
|
#include <QtEndian>
|
||||||
|
#include "assert.h"
|
||||||
|
#include "fitparser.h"
|
||||||
|
|
||||||
|
|
||||||
|
const quint32 FIT_MAGIC = 0x5449462E; // .FIT
|
||||||
|
|
||||||
|
#define RECORD_MESSAGE 20
|
||||||
|
#define TIMESTAMP_FIELD 253
|
||||||
|
|
||||||
|
|
||||||
|
FITParser::FITParser(QList<TrackData> &tracks, QList<RouteData> &routes,
|
||||||
|
QList<Waypoint> &waypoints) : Parser(tracks, routes, waypoints)
|
||||||
|
{
|
||||||
|
memset(_defs, 0, sizeof(_defs));
|
||||||
|
|
||||||
|
_device = 0;
|
||||||
|
_endian = 0;
|
||||||
|
_timestamp = 0;
|
||||||
|
_len = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
void FITParser::clearDefinitions()
|
||||||
|
{
|
||||||
|
for (int i = 0; i < 16; i++) {
|
||||||
|
if (_defs[i].fields)
|
||||||
|
delete[] _defs[i].fields;
|
||||||
|
if (_defs[i].devFields)
|
||||||
|
delete[] _defs[i].devFields;
|
||||||
|
}
|
||||||
|
|
||||||
|
memset(_defs, 0, sizeof(_defs));
|
||||||
|
}
|
||||||
|
|
||||||
|
void FITParser::warning(const char *text) const
|
||||||
|
{
|
||||||
|
const QFile *file = static_cast<QFile *>(_device);
|
||||||
|
fprintf(stderr, "%s:%d: %s\n", qPrintable(file->fileName()),
|
||||||
|
_len, text);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool FITParser::readData(char *data, size_t size)
|
||||||
|
{
|
||||||
|
qint64 n;
|
||||||
|
|
||||||
|
n = _device->read(data, size);
|
||||||
|
if (n < 0) {
|
||||||
|
_errorString = "I/O error";
|
||||||
|
return false;
|
||||||
|
} else if ((size_t)n < size) {
|
||||||
|
_errorString = "Premature end of data";
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
template<class T> bool FITParser::readValue(T &val)
|
||||||
|
{
|
||||||
|
T data;
|
||||||
|
|
||||||
|
if (!readData((char*)&data, sizeof(T)))
|
||||||
|
return false;
|
||||||
|
|
||||||
|
_len -= sizeof(T);
|
||||||
|
|
||||||
|
if (sizeof(T) > 1) {
|
||||||
|
if (_endian)
|
||||||
|
val = qFromBigEndian(data);
|
||||||
|
else
|
||||||
|
val = qFromLittleEndian(data);
|
||||||
|
} else
|
||||||
|
val = data;
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool FITParser::skipValue(size_t size)
|
||||||
|
{
|
||||||
|
size_t i;
|
||||||
|
quint8 val;
|
||||||
|
|
||||||
|
for (i = 0; i < size; i++)
|
||||||
|
if (!readValue(val))
|
||||||
|
return false;
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool FITParser::parseDefinitionMessage(quint8 header)
|
||||||
|
{
|
||||||
|
int local_id = header & 0x0f;
|
||||||
|
MessageDefinition* def = &_defs[local_id];
|
||||||
|
quint8 i;
|
||||||
|
|
||||||
|
|
||||||
|
if (def->fields) {
|
||||||
|
delete[] def->fields;
|
||||||
|
def->fields = 0;
|
||||||
|
}
|
||||||
|
if (def->devFields) {
|
||||||
|
delete[] def->devFields;
|
||||||
|
def->devFields = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
// reserved/unused
|
||||||
|
if (!readValue(i))
|
||||||
|
return false;
|
||||||
|
|
||||||
|
// endianness
|
||||||
|
if (!readValue(def->endian))
|
||||||
|
return false;
|
||||||
|
if (def->endian > 1) {
|
||||||
|
_errorString = "Bad endian field";
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
_endian = def->endian;
|
||||||
|
|
||||||
|
// global message number
|
||||||
|
if (!readValue(def->globalId))
|
||||||
|
return false;
|
||||||
|
|
||||||
|
// number of records
|
||||||
|
if (!readValue(def->numFields))
|
||||||
|
return false;
|
||||||
|
|
||||||
|
// definition records
|
||||||
|
def->fields = new Field[def->numFields];
|
||||||
|
for (i = 0; i < def->numFields; i++) {
|
||||||
|
STATIC_ASSERT(sizeof(def->fields[i]) == 3);
|
||||||
|
if (!readData((char*)&(def->fields[i]), sizeof(def->fields[i])))
|
||||||
|
return false;
|
||||||
|
_len -= sizeof(def->fields[i]);
|
||||||
|
}
|
||||||
|
|
||||||
|
// developer definition records
|
||||||
|
if (header & 0x20) {
|
||||||
|
if (!readValue(def->numDevFields))
|
||||||
|
return false;
|
||||||
|
|
||||||
|
def->devFields = new Field[def->numDevFields];
|
||||||
|
for (i = 0; i < def->numDevFields; i++) {
|
||||||
|
STATIC_ASSERT(sizeof(def->devFields[i]) == 3);
|
||||||
|
if (!readData((char*)&(def->devFields[i]),
|
||||||
|
sizeof(def->devFields[i])))
|
||||||
|
return false;
|
||||||
|
_len -= sizeof(def->devFields[i]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool FITParser::readField(Field *f, quint32 &val)
|
||||||
|
{
|
||||||
|
quint8 v8 = (quint8)-1;
|
||||||
|
quint16 v16 = (quint16)-1;
|
||||||
|
bool ret;
|
||||||
|
|
||||||
|
val = (quint32)-1;
|
||||||
|
|
||||||
|
switch (f->type) {
|
||||||
|
case 1: // sint8
|
||||||
|
case 2: // uint8
|
||||||
|
if (f->size == 1) {
|
||||||
|
ret = readValue(v8);
|
||||||
|
val = v8;
|
||||||
|
} else
|
||||||
|
ret = skipValue(f->size);
|
||||||
|
break;
|
||||||
|
case 0x83: // sint16
|
||||||
|
case 0x84: // uint16
|
||||||
|
if (f->size == 2) {
|
||||||
|
ret = readValue(v16);
|
||||||
|
val = v16;
|
||||||
|
} else
|
||||||
|
ret = skipValue(f->size);
|
||||||
|
break;
|
||||||
|
case 0x85: // sint32
|
||||||
|
case 0x86: // uint32
|
||||||
|
if (f->size == 4)
|
||||||
|
ret = readValue(val);
|
||||||
|
else
|
||||||
|
ret = skipValue(f->size);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
ret = skipValue(f->size);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool FITParser::parseData(MessageDefinition *def, quint8 offset)
|
||||||
|
{
|
||||||
|
Field *field;
|
||||||
|
quint32 timestamp = _timestamp + offset;
|
||||||
|
quint32 val;
|
||||||
|
Trackpoint trackpoint;
|
||||||
|
int i;
|
||||||
|
|
||||||
|
|
||||||
|
if (!def->fields && !def->devFields) {
|
||||||
|
_errorString = "Undefined data message";
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
_endian = def->endian;
|
||||||
|
|
||||||
|
for (i = 0; i < def->numFields; i++) {
|
||||||
|
field = &def->fields[i];
|
||||||
|
if (!readField(field, val))
|
||||||
|
return false;
|
||||||
|
|
||||||
|
if (field->id == TIMESTAMP_FIELD)
|
||||||
|
_timestamp = timestamp = val;
|
||||||
|
else if (def->globalId == RECORD_MESSAGE) {
|
||||||
|
switch (field->id) {
|
||||||
|
case 0:
|
||||||
|
if (val != 0x7fffffff)
|
||||||
|
trackpoint.rcoordinates().setLat(
|
||||||
|
((qint32)val / (double)0x7fffffff) * 180);
|
||||||
|
break;
|
||||||
|
case 1:
|
||||||
|
if (val != 0x7fffffff)
|
||||||
|
trackpoint.rcoordinates().setLon(
|
||||||
|
((qint32)val / (double)0x7fffffff) * 180);
|
||||||
|
break;
|
||||||
|
case 2:
|
||||||
|
if (val != 0xffff)
|
||||||
|
trackpoint.setElevation((val / 5.0) - 500);
|
||||||
|
break;
|
||||||
|
case 3:
|
||||||
|
if (val != 0xff)
|
||||||
|
trackpoint.setHeartRate(val);
|
||||||
|
break;
|
||||||
|
case 4:
|
||||||
|
if (val != 0xff)
|
||||||
|
trackpoint.setCadence(val);
|
||||||
|
break;
|
||||||
|
case 6:
|
||||||
|
if (val != 0xffff)
|
||||||
|
trackpoint.setSpeed(val / 1000.0f);
|
||||||
|
break;
|
||||||
|
case 7:
|
||||||
|
if (val != 0xffff)
|
||||||
|
trackpoint.setPower(val);
|
||||||
|
break;
|
||||||
|
case 13:
|
||||||
|
if (val != 0x7f)
|
||||||
|
trackpoint.setTemperature((qint8)val);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
for (i = 0; i < def->numDevFields; i++) {
|
||||||
|
field = &def->devFields[i];
|
||||||
|
if (!readField(field, val))
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
if (def->globalId == RECORD_MESSAGE) {
|
||||||
|
if (trackpoint.coordinates().isValid()) {
|
||||||
|
trackpoint.setTimestamp(QDateTime::fromTime_t(timestamp
|
||||||
|
+ 631065600));
|
||||||
|
_tracks.last().append(trackpoint);
|
||||||
|
} else {
|
||||||
|
if (trackpoint.coordinates().isNull())
|
||||||
|
warning("Missing coordinates");
|
||||||
|
else {
|
||||||
|
_errorString = "Invalid coordinates";
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool FITParser::parseDataMessage(quint8 header)
|
||||||
|
{
|
||||||
|
int local_id = header & 0xf;
|
||||||
|
MessageDefinition* def = &_defs[local_id];
|
||||||
|
return parseData(def, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool FITParser::parseCompressedMessage(quint8 header)
|
||||||
|
{
|
||||||
|
int local_id = (header >> 5) & 3;
|
||||||
|
MessageDefinition* def = &_defs[local_id];
|
||||||
|
return parseData(def, header & 0x1f);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool FITParser::parseRecord()
|
||||||
|
{
|
||||||
|
quint8 header;
|
||||||
|
|
||||||
|
if (!readValue(header))
|
||||||
|
return false;
|
||||||
|
|
||||||
|
if (header & 0x80)
|
||||||
|
return parseCompressedMessage(header);
|
||||||
|
else if (header & 0x40)
|
||||||
|
return parseDefinitionMessage(header);
|
||||||
|
else
|
||||||
|
return parseDataMessage(header);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool FITParser::parseHeader()
|
||||||
|
{
|
||||||
|
FileHeader hdr;
|
||||||
|
quint16 crc;
|
||||||
|
qint64 len;
|
||||||
|
|
||||||
|
STATIC_ASSERT(sizeof(hdr) == 12);
|
||||||
|
len = _device->read((char*)&hdr, sizeof(hdr));
|
||||||
|
if (len < 0) {
|
||||||
|
_errorString = "I/O error";
|
||||||
|
return false;
|
||||||
|
} else if ((size_t)len < sizeof(hdr)
|
||||||
|
|| hdr.magic != qToLittleEndian(FIT_MAGIC)) {
|
||||||
|
_errorString = "Not a FIT file";
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
_len = qFromLittleEndian(hdr.dataSize);
|
||||||
|
|
||||||
|
if (hdr.headerSize > sizeof(hdr))
|
||||||
|
if (!readData((char *)&crc, sizeof(crc)))
|
||||||
|
return false;
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool FITParser::loadFile(QFile *file)
|
||||||
|
{
|
||||||
|
bool ret = true;
|
||||||
|
|
||||||
|
_device = file;
|
||||||
|
_endian = 0;
|
||||||
|
_timestamp = 0;
|
||||||
|
|
||||||
|
if (!parseHeader())
|
||||||
|
return false;
|
||||||
|
|
||||||
|
_tracks.append(TrackData());
|
||||||
|
|
||||||
|
while (_len)
|
||||||
|
if ((ret = parseRecord()) == false)
|
||||||
|
break;
|
||||||
|
|
||||||
|
clearDefinitions();
|
||||||
|
|
||||||
|
return ret;
|
||||||
|
}
|
66
src/fitparser.h
Normal file
@ -0,0 +1,66 @@
|
|||||||
|
#ifndef FITPARSER_H
|
||||||
|
#define FITPARSER_H
|
||||||
|
|
||||||
|
#include "parser.h"
|
||||||
|
|
||||||
|
class FITParser : public Parser
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
FITParser(QList<TrackData> &tracks, QList<RouteData> &routes,
|
||||||
|
QList<Waypoint> &waypoints);
|
||||||
|
~FITParser() {}
|
||||||
|
|
||||||
|
bool loadFile(QFile *file);
|
||||||
|
QString errorString() const {return _errorString;}
|
||||||
|
int errorLine() const {return 0;}
|
||||||
|
|
||||||
|
private:
|
||||||
|
typedef struct {
|
||||||
|
quint8 headerSize;
|
||||||
|
quint8 protocolVersion;
|
||||||
|
quint16 profileVersion;
|
||||||
|
quint32 dataSize;
|
||||||
|
quint32 magic;
|
||||||
|
} FileHeader;
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
quint8 id;
|
||||||
|
quint8 size;
|
||||||
|
quint8 type;
|
||||||
|
} Field;
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
quint8 endian;
|
||||||
|
quint16 globalId;
|
||||||
|
quint8 numFields;
|
||||||
|
Field *fields;
|
||||||
|
quint8 numDevFields;
|
||||||
|
Field *devFields;
|
||||||
|
} MessageDefinition;
|
||||||
|
|
||||||
|
|
||||||
|
void warning(const char *text) const;
|
||||||
|
void clearDefinitions();
|
||||||
|
|
||||||
|
bool readData(char *data, size_t size);
|
||||||
|
template<class T> bool readValue(T &val);
|
||||||
|
bool skipValue(size_t size);
|
||||||
|
|
||||||
|
bool parseHeader();
|
||||||
|
bool parseRecord();
|
||||||
|
bool parseDefinitionMessage(quint8 header);
|
||||||
|
bool parseCompressedMessage(quint8 header);
|
||||||
|
bool parseDataMessage(quint8 header);
|
||||||
|
bool parseData(MessageDefinition *def, quint8 offset);
|
||||||
|
bool readField(Field *f, quint32 &val);
|
||||||
|
|
||||||
|
QIODevice *_device;
|
||||||
|
QString _errorString;
|
||||||
|
|
||||||
|
quint32 _len;
|
||||||
|
quint8 _endian;
|
||||||
|
quint32 _timestamp;
|
||||||
|
MessageDefinition _defs[16];
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // FITPARSER_H
|
53
src/format.cpp
Normal file
@ -0,0 +1,53 @@
|
|||||||
|
#include <QApplication>
|
||||||
|
#include "coordinates.h"
|
||||||
|
#include "format.h"
|
||||||
|
|
||||||
|
QString Format::timeSpan(qreal time)
|
||||||
|
{
|
||||||
|
unsigned h, m, s;
|
||||||
|
|
||||||
|
h = time / 3600;
|
||||||
|
m = (time - (h * 3600)) / 60;
|
||||||
|
s = time - (h * 3600) - (m * 60);
|
||||||
|
|
||||||
|
return QString("%1:%2:%3").arg(h).arg(m, 2, 10, QChar('0'))
|
||||||
|
.arg(s, 2, 10, QChar('0'));
|
||||||
|
}
|
||||||
|
|
||||||
|
QString Format::distance(qreal value, Units units)
|
||||||
|
{
|
||||||
|
if (units == Imperial) {
|
||||||
|
if (value < MIINM)
|
||||||
|
return QString::number(value * M2FT, 'f', 0) + UNIT_SPACE
|
||||||
|
+ qApp->translate("Format", "ft");
|
||||||
|
else
|
||||||
|
return QString::number(value * M2MI, 'f', 1) + UNIT_SPACE
|
||||||
|
+ qApp->translate("Format", "mi");
|
||||||
|
} else {
|
||||||
|
if (value < KMINM)
|
||||||
|
return QString::number(value, 'f', 0) + UNIT_SPACE
|
||||||
|
+ qApp->translate("Format", "m");
|
||||||
|
else
|
||||||
|
return QString::number(value * M2KM, 'f', 1) + UNIT_SPACE
|
||||||
|
+ qApp->translate("Format", "km");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
QString Format::elevation(qreal value, Units units)
|
||||||
|
{
|
||||||
|
if (units == Metric)
|
||||||
|
return QString::number(value, 'f', 0) + UNIT_SPACE
|
||||||
|
+ qApp->translate("Format", "m");
|
||||||
|
else
|
||||||
|
return QString::number(value * M2FT, 'f', 0) + UNIT_SPACE
|
||||||
|
+ qApp->translate("Format", "ft");
|
||||||
|
}
|
||||||
|
|
||||||
|
QString Format::coordinates(const Coordinates &value)
|
||||||
|
{
|
||||||
|
QChar yH = (value.lat() < 0) ? 'S' : 'N';
|
||||||
|
QChar xH = (value.lon() < 0) ? 'W' : 'E';
|
||||||
|
|
||||||
|
return QString::number(qAbs(value.lat()), 'f', 5) + yH + "," + QChar(0x00A0)
|
||||||
|
+ QString::number(qAbs(value.lon()), 'f', 5) + xH;
|
||||||
|
}
|
17
src/format.h
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
#ifndef FORMAT_H
|
||||||
|
#define FORMAT_H
|
||||||
|
|
||||||
|
#include <QString>
|
||||||
|
#include "units.h"
|
||||||
|
|
||||||
|
class Coordinates;
|
||||||
|
|
||||||
|
namespace Format
|
||||||
|
{
|
||||||
|
QString timeSpan(qreal time);
|
||||||
|
QString distance(qreal value, Units units);
|
||||||
|
QString elevation(qreal value, Units units);
|
||||||
|
QString coordinates(const Coordinates &value);
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif // FORMAT_H
|
47
src/gpx.cpp
@ -1,47 +0,0 @@
|
|||||||
#include <QFile>
|
|
||||||
#include <QLineF>
|
|
||||||
#include "ll.h"
|
|
||||||
#include "gpx.h"
|
|
||||||
|
|
||||||
|
|
||||||
GPX::GPX() : _parser(_track_data, _route_data, _waypoint_data), _errorLine(0)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
GPX::~GPX()
|
|
||||||
{
|
|
||||||
for (int i = 0; i < _tracks.count(); i++)
|
|
||||||
delete _tracks.at(i);
|
|
||||||
for (int i = 0; i < _routes.count(); i++)
|
|
||||||
delete _routes.at(i);
|
|
||||||
}
|
|
||||||
|
|
||||||
bool GPX::loadFile(const QString &fileName)
|
|
||||||
{
|
|
||||||
bool ret;
|
|
||||||
QFile file(fileName);
|
|
||||||
|
|
||||||
|
|
||||||
_error.clear();
|
|
||||||
_errorLine = 0;
|
|
||||||
|
|
||||||
if (!file.open(QFile::ReadOnly | QFile::Text)) {
|
|
||||||
_error = qPrintable(file.errorString());
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
ret = _parser.loadFile(&file);
|
|
||||||
file.close();
|
|
||||||
if (ret == false) {
|
|
||||||
_error = _parser.errorString();
|
|
||||||
_errorLine = _parser.errorLine();
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
for (int i = 0; i < _track_data.count(); i++)
|
|
||||||
_tracks.append(new Track(_track_data.at(i)));
|
|
||||||
for (int i = 0; i < _route_data.count(); i++)
|
|
||||||
_routes.append(new Route(_route_data.at(i)));
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
205
src/gpxparser.cpp
Normal file
@ -0,0 +1,205 @@
|
|||||||
|
#include "gpxparser.h"
|
||||||
|
|
||||||
|
|
||||||
|
qreal GPXParser::number()
|
||||||
|
{
|
||||||
|
bool res;
|
||||||
|
qreal ret = _reader.readElementText().toDouble(&res);
|
||||||
|
if (!res)
|
||||||
|
_reader.raiseError(QString("Invalid %1").arg(
|
||||||
|
_reader.name().toString()));
|
||||||
|
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
QDateTime GPXParser::time()
|
||||||
|
{
|
||||||
|
QDateTime d = QDateTime::fromString(_reader.readElementText(),
|
||||||
|
Qt::ISODate);
|
||||||
|
if (!d.isValid())
|
||||||
|
_reader.raiseError(QString("Invalid %1").arg(
|
||||||
|
_reader.name().toString()));
|
||||||
|
|
||||||
|
return d;
|
||||||
|
}
|
||||||
|
|
||||||
|
Coordinates GPXParser::coordinates()
|
||||||
|
{
|
||||||
|
bool res;
|
||||||
|
qreal lon, lat;
|
||||||
|
const QXmlStreamAttributes &attr = _reader.attributes();
|
||||||
|
|
||||||
|
#if QT_VERSION < QT_VERSION_CHECK(5, 0, 0)
|
||||||
|
lon = attr.value("lon").toString().toDouble(&res);
|
||||||
|
#else // QT_VERSION < 5
|
||||||
|
lon = attr.value("lon").toDouble(&res);
|
||||||
|
#endif // QT_VERSION < 5
|
||||||
|
if (!res || (lon < -180.0 || lon > 180.0)) {
|
||||||
|
_reader.raiseError("Invalid longitude");
|
||||||
|
return Coordinates();
|
||||||
|
}
|
||||||
|
#if QT_VERSION < QT_VERSION_CHECK(5, 0, 0)
|
||||||
|
lat = attr.value("lat").toString().toDouble(&res);
|
||||||
|
#else // QT_VERSION < 5
|
||||||
|
lat = attr.value("lat").toDouble(&res);
|
||||||
|
#endif // QT_VERSION < 5
|
||||||
|
if (!res || (lat < -90.0 || lat > 90.0)) {
|
||||||
|
_reader.raiseError("Invalid latitude");
|
||||||
|
return Coordinates();
|
||||||
|
}
|
||||||
|
|
||||||
|
return Coordinates(lon, lat);
|
||||||
|
}
|
||||||
|
|
||||||
|
void GPXParser::tpExtension(Trackpoint &trackpoint)
|
||||||
|
{
|
||||||
|
while (_reader.readNextStartElement()) {
|
||||||
|
if (_reader.name() == "hr")
|
||||||
|
trackpoint.setHeartRate(number());
|
||||||
|
else if (_reader.name() == "atemp")
|
||||||
|
trackpoint.setTemperature(number());
|
||||||
|
else
|
||||||
|
_reader.skipCurrentElement();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void GPXParser::extensions(Trackpoint &trackpoint)
|
||||||
|
{
|
||||||
|
while (_reader.readNextStartElement()) {
|
||||||
|
if (_reader.name() == "speed")
|
||||||
|
trackpoint.setSpeed(number());
|
||||||
|
else if (_reader.name() == "hr" || _reader.name() == "heartrate")
|
||||||
|
trackpoint.setHeartRate(number());
|
||||||
|
else if (_reader.name() == "temp")
|
||||||
|
trackpoint.setTemperature(number());
|
||||||
|
else if (_reader.name() == "cadence")
|
||||||
|
trackpoint.setCadence(number());
|
||||||
|
else if (_reader.name() == "power")
|
||||||
|
trackpoint.setPower(number());
|
||||||
|
else if (_reader.name() == "TrackPointExtension")
|
||||||
|
tpExtension(trackpoint);
|
||||||
|
else
|
||||||
|
_reader.skipCurrentElement();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void GPXParser::trackpointData(Trackpoint &trackpoint)
|
||||||
|
{
|
||||||
|
qreal gh = NAN;
|
||||||
|
|
||||||
|
while (_reader.readNextStartElement()) {
|
||||||
|
if (_reader.name() == "ele")
|
||||||
|
trackpoint.setElevation(number());
|
||||||
|
else if (_reader.name() == "time")
|
||||||
|
trackpoint.setTimestamp(time());
|
||||||
|
else if (_reader.name() == "geoidheight")
|
||||||
|
gh = number();
|
||||||
|
else if (_reader.name() == "extensions")
|
||||||
|
extensions(trackpoint);
|
||||||
|
else
|
||||||
|
_reader.skipCurrentElement();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!std::isnan(gh) && !std::isnan(trackpoint.elevation()))
|
||||||
|
trackpoint.setElevation(trackpoint.elevation() - gh);
|
||||||
|
}
|
||||||
|
|
||||||
|
void GPXParser::waypointData(Waypoint &waypoint)
|
||||||
|
{
|
||||||
|
qreal gh = NAN;
|
||||||
|
|
||||||
|
while (_reader.readNextStartElement()) {
|
||||||
|
if (_reader.name() == "name")
|
||||||
|
waypoint.setName(_reader.readElementText());
|
||||||
|
else if (_reader.name() == "desc")
|
||||||
|
waypoint.setDescription(_reader.readElementText());
|
||||||
|
else if (_reader.name() == "ele")
|
||||||
|
waypoint.setElevation(number());
|
||||||
|
else if (_reader.name() == "geoidheight")
|
||||||
|
gh = number();
|
||||||
|
else if (_reader.name() == "time")
|
||||||
|
waypoint.setTimestamp(time());
|
||||||
|
else
|
||||||
|
_reader.skipCurrentElement();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!std::isnan(gh) && !std::isnan(waypoint.elevation()))
|
||||||
|
waypoint.setElevation(waypoint.elevation() - gh);
|
||||||
|
}
|
||||||
|
|
||||||
|
void GPXParser::trackpoints(TrackData &track)
|
||||||
|
{
|
||||||
|
while (_reader.readNextStartElement()) {
|
||||||
|
if (_reader.name() == "trkpt") {
|
||||||
|
track.append(Trackpoint(coordinates()));
|
||||||
|
trackpointData(track.last());
|
||||||
|
} else
|
||||||
|
_reader.skipCurrentElement();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void GPXParser::routepoints(RouteData &route)
|
||||||
|
{
|
||||||
|
while (_reader.readNextStartElement()) {
|
||||||
|
if (_reader.name() == "rtept") {
|
||||||
|
route.append(Waypoint(coordinates()));
|
||||||
|
waypointData(route.last());
|
||||||
|
} else if (_reader.name() == "name")
|
||||||
|
route.setName(_reader.readElementText());
|
||||||
|
else if (_reader.name() == "desc")
|
||||||
|
route.setDescription(_reader.readElementText());
|
||||||
|
else
|
||||||
|
_reader.skipCurrentElement();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void GPXParser::track(TrackData &track)
|
||||||
|
{
|
||||||
|
while (_reader.readNextStartElement()) {
|
||||||
|
if (_reader.name() == "trkseg")
|
||||||
|
trackpoints(track);
|
||||||
|
else if (_reader.name() == "name")
|
||||||
|
track.setName(_reader.readElementText());
|
||||||
|
else if (_reader.name() == "desc")
|
||||||
|
track.setDescription(_reader.readElementText());
|
||||||
|
else
|
||||||
|
_reader.skipCurrentElement();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void GPXParser::gpx()
|
||||||
|
{
|
||||||
|
while (_reader.readNextStartElement()) {
|
||||||
|
if (_reader.name() == "trk") {
|
||||||
|
_tracks.append(TrackData());
|
||||||
|
track(_tracks.back());
|
||||||
|
} else if (_reader.name() == "rte") {
|
||||||
|
_routes.append(RouteData());
|
||||||
|
routepoints(_routes.back());
|
||||||
|
} else if (_reader.name() == "wpt") {
|
||||||
|
_waypoints.append(Waypoint(coordinates()));
|
||||||
|
waypointData(_waypoints.last());
|
||||||
|
} else
|
||||||
|
_reader.skipCurrentElement();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
bool GPXParser::parse()
|
||||||
|
{
|
||||||
|
if (_reader.readNextStartElement()) {
|
||||||
|
if (_reader.name() == "gpx")
|
||||||
|
gpx();
|
||||||
|
else
|
||||||
|
_reader.raiseError("Not a GPX file");
|
||||||
|
}
|
||||||
|
|
||||||
|
return !_reader.error();
|
||||||
|
}
|
||||||
|
|
||||||
|
bool GPXParser::loadFile(QFile *file)
|
||||||
|
{
|
||||||
|
_reader.clear();
|
||||||
|
_reader.setDevice(file);
|
||||||
|
|
||||||
|
return parse();
|
||||||
|
}
|
36
src/gpxparser.h
Normal file
@ -0,0 +1,36 @@
|
|||||||
|
#ifndef GPXPARSER_H
|
||||||
|
#define GPXPARSER_H
|
||||||
|
|
||||||
|
#include <QXmlStreamReader>
|
||||||
|
#include "parser.h"
|
||||||
|
|
||||||
|
|
||||||
|
class GPXParser : public Parser
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
GPXParser(QList<TrackData> &tracks, QList<RouteData> &routes,
|
||||||
|
QList<Waypoint> &waypoints) : Parser(tracks, routes, waypoints) {}
|
||||||
|
~GPXParser() {}
|
||||||
|
|
||||||
|
bool loadFile(QFile *file);
|
||||||
|
QString errorString() const {return _reader.errorString();}
|
||||||
|
int errorLine() const {return _reader.lineNumber();}
|
||||||
|
|
||||||
|
private:
|
||||||
|
bool parse();
|
||||||
|
void gpx();
|
||||||
|
void track(TrackData &track);
|
||||||
|
void trackpoints(TrackData &track);
|
||||||
|
void routepoints(RouteData &route);
|
||||||
|
void tpExtension(Trackpoint &trackpoint);
|
||||||
|
void extensions(Trackpoint &trackpoint);
|
||||||
|
void trackpointData(Trackpoint &trackpoint);
|
||||||
|
void waypointData(Waypoint &waypoint);
|
||||||
|
qreal number();
|
||||||
|
QDateTime time();
|
||||||
|
Coordinates coordinates();
|
||||||
|
|
||||||
|
QXmlStreamReader _reader;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // GPXPARSER_H
|
9
src/graph.cpp
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
#include "graph.h"
|
||||||
|
|
||||||
|
QDebug operator<<(QDebug dbg, const GraphPoint &point)
|
||||||
|
{
|
||||||
|
dbg.nospace() << "GraphPoint(" << point.s() << ", " << point.t() << ", "
|
||||||
|
<< point.y() << ")";
|
||||||
|
|
||||||
|
return dbg.maybeSpace();
|
||||||
|
}
|
23
src/graph.h
@ -2,6 +2,7 @@
|
|||||||
#define GRAPH_H
|
#define GRAPH_H
|
||||||
|
|
||||||
#include <QVector>
|
#include <QVector>
|
||||||
|
#include <QDebug>
|
||||||
#include <cmath>
|
#include <cmath>
|
||||||
|
|
||||||
enum GraphType {Distance, Time};
|
enum GraphType {Distance, Time};
|
||||||
@ -15,6 +16,7 @@ public:
|
|||||||
qreal s() const {return _s;}
|
qreal s() const {return _s;}
|
||||||
qreal t() const {return _t;}
|
qreal t() const {return _t;}
|
||||||
qreal y() const {return _y;}
|
qreal y() const {return _y;}
|
||||||
|
qreal x(GraphType type) const {return (type == Distance) ? _s : _t;}
|
||||||
|
|
||||||
void setS(qreal s) {_s = s;}
|
void setS(qreal s) {_s = s;}
|
||||||
void setT(qreal t) {_t = t;}
|
void setT(qreal t) {_t = t;}
|
||||||
@ -26,6 +28,25 @@ private:
|
|||||||
qreal _y;
|
qreal _y;
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef QVector<GraphPoint> Graph;
|
Q_DECLARE_TYPEINFO(GraphPoint, Q_PRIMITIVE_TYPE);
|
||||||
|
QDebug operator<<(QDebug dbg, const GraphPoint &point);
|
||||||
|
|
||||||
|
|
||||||
|
class Graph : public QVector<GraphPoint>
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
Graph() : QVector<GraphPoint>() {_time = true;}
|
||||||
|
void append(const GraphPoint &p)
|
||||||
|
{
|
||||||
|
if (std::isnan(p.t()))
|
||||||
|
_time = false;
|
||||||
|
QVector<GraphPoint>::append(p);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool hasTime() const {return _time;}
|
||||||
|
|
||||||
|
private:
|
||||||
|
bool _time;
|
||||||
|
};
|
||||||
|
|
||||||
#endif // GRAPH_H
|
#endif // GRAPH_H
|
||||||
|
@ -2,67 +2,22 @@
|
|||||||
#include "graphitem.h"
|
#include "graphitem.h"
|
||||||
|
|
||||||
|
|
||||||
#define GRAPH_WIDTH 1
|
|
||||||
#define HOVER_WIDTH 2
|
|
||||||
|
|
||||||
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();
|
|
||||||
}
|
|
||||||
|
|
||||||
static bool hasTime(const Graph &graph)
|
|
||||||
{
|
|
||||||
for (int i = 0; i < graph.count(); i++)
|
|
||||||
if (std::isnan(graph.at(i).t()))
|
|
||||||
return false;
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
GraphItem::GraphItem(const Graph &graph, QGraphicsItem *parent)
|
GraphItem::GraphItem(const Graph &graph, QGraphicsItem *parent)
|
||||||
: QGraphicsObject(parent)
|
: QGraphicsObject(parent)
|
||||||
{
|
{
|
||||||
_id = 0;
|
_id = 0;
|
||||||
|
_width = 1;
|
||||||
|
|
||||||
|
_pen = QPen(Qt::black, _width);
|
||||||
|
|
||||||
_type = Distance;
|
_type = Distance;
|
||||||
|
_graph = graph;
|
||||||
|
_sx = 1.0; _sy = 1.0;
|
||||||
|
|
||||||
_pen = QPen(Qt::black, GRAPH_WIDTH);
|
setZValue(1.0);
|
||||||
_pen.setCosmetic(true);
|
|
||||||
|
|
||||||
_distancePath.moveTo(graph.first().s(), -graph.first().y());
|
updatePath();
|
||||||
for (int i = 1; i < graph.size(); i++)
|
updateBounds();
|
||||||
_distancePath.lineTo(graph.at(i).s(), -graph.at(i).y());
|
|
||||||
|
|
||||||
if (hasTime(graph)) {
|
|
||||||
_timePath.moveTo(graph.first().t(), -graph.first().y());
|
|
||||||
for (int i = 1; i < graph.size(); i++)
|
|
||||||
_timePath.lineTo(graph.at(i).t(), -graph.at(i).y());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void GraphItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *option,
|
void GraphItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *option,
|
||||||
@ -72,7 +27,7 @@ void GraphItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *option,
|
|||||||
Q_UNUSED(widget);
|
Q_UNUSED(widget);
|
||||||
|
|
||||||
painter->setPen(_pen);
|
painter->setPen(_pen);
|
||||||
painter->drawPath((_type == Distance) ? _distancePath : _timePath);
|
painter->drawPath(_path);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
QPen p = QPen(QBrush(Qt::red), 0);
|
QPen p = QPen(QBrush(Qt::red), 0);
|
||||||
@ -84,7 +39,10 @@ void GraphItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *option,
|
|||||||
void GraphItem::setGraphType(GraphType type)
|
void GraphItem::setGraphType(GraphType type)
|
||||||
{
|
{
|
||||||
prepareGeometryChange();
|
prepareGeometryChange();
|
||||||
|
|
||||||
_type = type;
|
_type = type;
|
||||||
|
updatePath();
|
||||||
|
updateBounds();
|
||||||
}
|
}
|
||||||
|
|
||||||
void GraphItem::setColor(const QColor &color)
|
void GraphItem::setColor(const QColor &color)
|
||||||
@ -93,39 +51,72 @@ void GraphItem::setColor(const QColor &color)
|
|||||||
update();
|
update();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void GraphItem::setWidth(int width)
|
||||||
|
{
|
||||||
|
prepareGeometryChange();
|
||||||
|
|
||||||
|
_width = width;
|
||||||
|
_pen.setWidth(width);
|
||||||
|
}
|
||||||
|
|
||||||
qreal GraphItem::yAtX(qreal x)
|
qreal GraphItem::yAtX(qreal x)
|
||||||
{
|
{
|
||||||
return ::yAtX((_type == Distance) ? _distancePath : _timePath, x);
|
int low = 0;
|
||||||
|
int high = _graph.count() - 1;
|
||||||
|
int mid = 0;
|
||||||
|
|
||||||
|
Q_ASSERT(high > low);
|
||||||
|
Q_ASSERT(x >= _graph.at(low).x(_type) && x <= _graph.at(high).x(_type));
|
||||||
|
|
||||||
|
while (low <= high) {
|
||||||
|
mid = low + ((high - low) / 2);
|
||||||
|
const GraphPoint &p = _graph.at(mid);
|
||||||
|
if (p.x(_type) > x)
|
||||||
|
high = mid - 1;
|
||||||
|
else if (p.x(_type) < x)
|
||||||
|
low = mid + 1;
|
||||||
|
else
|
||||||
|
return -p.y();
|
||||||
|
}
|
||||||
|
|
||||||
|
QLineF l;
|
||||||
|
if (_graph.at(mid).x(_type) < x)
|
||||||
|
l = QLineF(_graph.at(mid).x(_type), _graph.at(mid).y(),
|
||||||
|
_graph.at(mid+1).x(_type), _graph.at(mid+1).y());
|
||||||
|
else
|
||||||
|
l = QLineF(_graph.at(mid-1).x(_type), _graph.at(mid-1).y(),
|
||||||
|
_graph.at(mid).x(_type), _graph.at(mid).y());
|
||||||
|
|
||||||
|
return -l.pointAt((x - l.p1().x()) / (l.p2().x() - l.p1().x())).y();
|
||||||
}
|
}
|
||||||
|
|
||||||
qreal GraphItem::distanceAtTime(qreal time)
|
qreal GraphItem::distanceAtTime(qreal time)
|
||||||
{
|
{
|
||||||
int low = 0;
|
int low = 0;
|
||||||
int high = _timePath.elementCount() - 1;
|
int high = _graph.count() - 1;
|
||||||
int mid = 0;
|
int mid = 0;
|
||||||
|
|
||||||
Q_ASSERT(high > low);
|
Q_ASSERT(high > low);
|
||||||
Q_ASSERT(time >= _timePath.elementAt(low).x
|
Q_ASSERT(time >= _graph.at(low).t() && time <= _graph.at(high).t());
|
||||||
&& time <= _timePath.elementAt(high).x);
|
|
||||||
|
|
||||||
while (low <= high) {
|
while (low <= high) {
|
||||||
mid = low + ((high - low) / 2);
|
mid = low + ((high - low) / 2);
|
||||||
const QPainterPath::Element &e = _timePath.elementAt(mid);
|
const GraphPoint &p = _graph.at(mid);
|
||||||
if (e.x > time)
|
if (p.t() > time)
|
||||||
high = mid - 1;
|
high = mid - 1;
|
||||||
else if (e.x < time)
|
else if (p.t() < time)
|
||||||
low = mid + 1;
|
low = mid + 1;
|
||||||
else
|
else
|
||||||
return _distancePath.elementAt(mid).x;
|
return _graph.at(mid).s();
|
||||||
}
|
}
|
||||||
|
|
||||||
QLineF l;
|
QLineF l;
|
||||||
if (_timePath.elementAt(mid).x < time)
|
if (_graph.at(mid).t() < time)
|
||||||
l = QLineF(_timePath.elementAt(mid).x, _distancePath.elementAt(mid).x,
|
l = QLineF(_graph.at(mid).t(), _graph.at(mid).s(), _graph.at(mid+1).t(),
|
||||||
_timePath.elementAt(mid+1).x, _distancePath.elementAt(mid+1).x);
|
_graph.at(mid+1).s());
|
||||||
else
|
else
|
||||||
l = QLineF(_timePath.elementAt(mid-1).x, _distancePath.elementAt(mid-1).x,
|
l = QLineF(_graph.at(mid-1).t(), _graph.at(mid-1).s(),
|
||||||
_timePath.elementAt(mid).x, _distancePath.elementAt(mid).x);
|
_graph.at(mid).t(), _graph.at(mid).s());
|
||||||
|
|
||||||
return l.pointAt((time - l.p1().x()) / (l.p2().x() - l.p1().x())).y();
|
return l.pointAt((time - l.p1().x()) / (l.p2().x() - l.p1().x())).y();
|
||||||
}
|
}
|
||||||
@ -133,15 +124,13 @@ qreal GraphItem::distanceAtTime(qreal time)
|
|||||||
void GraphItem::emitSliderPositionChanged(qreal pos)
|
void GraphItem::emitSliderPositionChanged(qreal pos)
|
||||||
{
|
{
|
||||||
if (_type == Time) {
|
if (_type == Time) {
|
||||||
if (!_timePath.isEmpty()) {
|
if (_graph.hasTime()) {
|
||||||
if (pos <= _timePath.elementAt(_timePath.elementCount() - 1).x)
|
if (pos >= _graph.first().t() && pos <= _graph.last().t())
|
||||||
emit sliderPositionChanged(distanceAtTime(pos));
|
emit sliderPositionChanged(distanceAtTime(pos));
|
||||||
else
|
else
|
||||||
emit sliderPositionChanged(_distancePath.elementAt(
|
emit sliderPositionChanged(NAN);
|
||||||
_distancePath.elementCount() - 1).x + 1);
|
|
||||||
} else
|
} else
|
||||||
emit sliderPositionChanged(_distancePath.elementAt(
|
emit sliderPositionChanged(NAN);
|
||||||
_distancePath.elementCount() - 1).x + 1);
|
|
||||||
} else
|
} else
|
||||||
emit sliderPositionChanged(pos);
|
emit sliderPositionChanged(pos);
|
||||||
}
|
}
|
||||||
@ -149,12 +138,56 @@ void GraphItem::emitSliderPositionChanged(qreal pos)
|
|||||||
void GraphItem::selected(bool selected)
|
void GraphItem::selected(bool selected)
|
||||||
{
|
{
|
||||||
if (selected) {
|
if (selected) {
|
||||||
_pen.setWidth(HOVER_WIDTH);
|
_pen.setWidth(_width + 1);
|
||||||
setZValue(zValue() + 1.0);
|
setZValue(zValue() + 1.0);
|
||||||
} else {
|
} else {
|
||||||
_pen.setWidth(GRAPH_WIDTH);
|
_pen.setWidth(_width);
|
||||||
setZValue(zValue() - 1.0);
|
setZValue(zValue() - 1.0);
|
||||||
}
|
}
|
||||||
|
|
||||||
update();
|
update();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void GraphItem::setScale(qreal sx, qreal sy)
|
||||||
|
{
|
||||||
|
if (_sx == sx && _sy == sy)
|
||||||
|
return;
|
||||||
|
|
||||||
|
prepareGeometryChange();
|
||||||
|
|
||||||
|
_sx = sx; _sy = sy;
|
||||||
|
updatePath();
|
||||||
|
}
|
||||||
|
|
||||||
|
void GraphItem::updatePath()
|
||||||
|
{
|
||||||
|
_path = QPainterPath();
|
||||||
|
|
||||||
|
if (_type == Time && !_graph.hasTime())
|
||||||
|
return;
|
||||||
|
|
||||||
|
_path.moveTo(_graph.first().x(_type) * _sx, -_graph.first().y() * _sy);
|
||||||
|
for (int i = 1; i < _graph.size(); i++)
|
||||||
|
_path.lineTo(_graph.at(i).x(_type) * _sx, -_graph.at(i).y() * _sy);
|
||||||
|
}
|
||||||
|
|
||||||
|
void GraphItem::updateBounds()
|
||||||
|
{
|
||||||
|
if (_type == Time && !_graph.hasTime()) {
|
||||||
|
_bounds = QRectF();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
qreal bottom, top, left, right;
|
||||||
|
|
||||||
|
QPointF p = QPointF(_graph.first().x(_type), -_graph.first().y());
|
||||||
|
bottom = p.y(); top = p.y(); left = p.x(); right = p.x();
|
||||||
|
|
||||||
|
for (int i = 1; i < _graph.size(); i++) {
|
||||||
|
p = QPointF(_graph.at(i).x(_type), -_graph.at(i).y());
|
||||||
|
bottom = qMax(bottom, p.y()); top = qMin(top, p.y());
|
||||||
|
right = qMax(right, p.x()); left = qMin(left, p.x());
|
||||||
|
}
|
||||||
|
|
||||||
|
_bounds = QRectF(QPointF(left, top), QPointF(right, bottom));
|
||||||
|
}
|
||||||
|
@ -13,15 +13,18 @@ public:
|
|||||||
GraphItem(const Graph &graph, QGraphicsItem *parent = 0);
|
GraphItem(const Graph &graph, QGraphicsItem *parent = 0);
|
||||||
|
|
||||||
QRectF boundingRect() const
|
QRectF boundingRect() const
|
||||||
{return (_type == Distance) ? _distancePath.boundingRect()
|
{return _path.boundingRect();}
|
||||||
: _timePath.boundingRect();}
|
|
||||||
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option,
|
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option,
|
||||||
QWidget *widget);
|
QWidget *widget);
|
||||||
|
|
||||||
|
const QRectF &bounds() const {return _bounds;}
|
||||||
|
void setScale(qreal sx, qreal sy);
|
||||||
|
|
||||||
void setGraphType(GraphType type);
|
void setGraphType(GraphType type);
|
||||||
int id() const {return _id;}
|
int id() const {return _id;}
|
||||||
void setId(int id) {_id = id;}
|
void setId(int id) {_id = id;}
|
||||||
void setColor(const QColor &color);
|
void setColor(const QColor &color);
|
||||||
|
void setWidth(int width);
|
||||||
|
|
||||||
qreal yAtX(qreal x);
|
qreal yAtX(qreal x);
|
||||||
qreal distanceAtTime(qreal time);
|
qreal distanceAtTime(qreal time);
|
||||||
@ -34,10 +37,19 @@ public slots:
|
|||||||
void selected(bool selected);
|
void selected(bool selected);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
void updatePath();
|
||||||
|
void updateBounds();
|
||||||
|
|
||||||
int _id;
|
int _id;
|
||||||
QPen _pen;
|
QPen _pen;
|
||||||
QPainterPath _distancePath, _timePath;
|
int _width;
|
||||||
|
|
||||||
|
Graph _graph;
|
||||||
GraphType _type;
|
GraphType _type;
|
||||||
|
|
||||||
|
QPainterPath _path;
|
||||||
|
QRectF _bounds;
|
||||||
|
qreal _sx, _sy;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // GRAPHITEM_H
|
#endif // GRAPHITEM_H
|
||||||
|
@ -5,7 +5,7 @@
|
|||||||
#include "graphview.h"
|
#include "graphview.h"
|
||||||
#include "units.h"
|
#include "units.h"
|
||||||
|
|
||||||
class GPX;
|
class Data;
|
||||||
class PathItem;
|
class PathItem;
|
||||||
|
|
||||||
class GraphTab : public GraphView
|
class GraphTab : public GraphView
|
||||||
@ -17,7 +17,7 @@ public:
|
|||||||
{setFrameShape(QFrame::NoFrame);}
|
{setFrameShape(QFrame::NoFrame);}
|
||||||
|
|
||||||
virtual QString label() const = 0;
|
virtual QString label() const = 0;
|
||||||
virtual void loadGPX(const GPX &gpx, const QList<PathItem *> &paths) = 0;
|
virtual void loadData(const Data &data, const QList<PathItem *> &paths) = 0;
|
||||||
virtual void clear() = 0;
|
virtual void clear() = 0;
|
||||||
virtual void setUnits(enum Units units) = 0;
|
virtual void setUnits(enum Units units) = 0;
|
||||||
virtual void showTracks(bool show) = 0;
|
virtual void showTracks(bool show) = 0;
|
||||||
|
@ -1,12 +1,16 @@
|
|||||||
#include <QGraphicsSceneMouseEvent>
|
#include <QGraphicsScene>
|
||||||
#include <QEvent>
|
#include <QEvent>
|
||||||
|
#include <QMouseEvent>
|
||||||
#include <QPaintEngine>
|
#include <QPaintEngine>
|
||||||
#include <QPaintDevice>
|
#include <QPaintDevice>
|
||||||
|
#include <QSysInfo>
|
||||||
|
#include "opengl.h"
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
#include "axisitem.h"
|
#include "axisitem.h"
|
||||||
#include "slideritem.h"
|
#include "slideritem.h"
|
||||||
#include "sliderinfoitem.h"
|
#include "sliderinfoitem.h"
|
||||||
#include "infoitem.h"
|
#include "infoitem.h"
|
||||||
|
#include "griditem.h"
|
||||||
#include "graph.h"
|
#include "graph.h"
|
||||||
#include "graphitem.h"
|
#include "graphitem.h"
|
||||||
#include "pathitem.h"
|
#include "pathitem.h"
|
||||||
@ -15,39 +19,32 @@
|
|||||||
|
|
||||||
#define MARGIN 10.0
|
#define MARGIN 10.0
|
||||||
|
|
||||||
|
|
||||||
void Scene::mousePressEvent(QGraphicsSceneMouseEvent *e)
|
|
||||||
{
|
|
||||||
if (e->button() == Qt::LeftButton)
|
|
||||||
emit mouseClicked(e->scenePos());
|
|
||||||
|
|
||||||
QGraphicsScene::mousePressEvent(e);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
GraphView::GraphView(QWidget *parent)
|
GraphView::GraphView(QWidget *parent)
|
||||||
: QGraphicsView(parent)
|
: QGraphicsView(parent)
|
||||||
{
|
{
|
||||||
_scene = new Scene(this);
|
_scene = new QGraphicsScene(this);
|
||||||
setScene(_scene);
|
setScene(_scene);
|
||||||
|
|
||||||
|
setViewportUpdateMode(QGraphicsView::FullViewportUpdate);
|
||||||
|
setRenderHint(QPainter::Antialiasing, true);
|
||||||
setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
|
setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
|
||||||
setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
|
setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
|
||||||
|
|
||||||
_xAxis = new AxisItem(AxisItem::X);
|
_xAxis = new AxisItem(AxisItem::X);
|
||||||
_xAxis->setZValue(1.0);
|
_xAxis->setZValue(2.0);
|
||||||
_yAxis = new AxisItem(AxisItem::Y);
|
_yAxis = new AxisItem(AxisItem::Y);
|
||||||
_yAxis->setZValue(1.0);
|
_yAxis->setZValue(2.0);
|
||||||
_slider = new SliderItem();
|
_slider = new SliderItem();
|
||||||
_slider->setZValue(2.0);
|
_slider->setZValue(3.0);
|
||||||
_sliderInfo = new SliderInfoItem(_slider);
|
_sliderInfo = new SliderInfoItem(_slider);
|
||||||
_sliderInfo->setZValue(2.0);
|
_sliderInfo->setZValue(3.0);
|
||||||
_info = new InfoItem();
|
_info = new InfoItem();
|
||||||
|
_grid = new GridItem();
|
||||||
|
|
||||||
connect(_slider, SIGNAL(positionChanged(const QPointF&)), this,
|
connect(_slider, SIGNAL(positionChanged(const QPointF&)), this,
|
||||||
SLOT(emitSliderPositionChanged(const QPointF&)));
|
SLOT(emitSliderPositionChanged(const QPointF&)));
|
||||||
connect(_scene, SIGNAL(mouseClicked(const QPointF&)), this,
|
|
||||||
SLOT(newSliderPosition(const QPointF&)));
|
_width = 1;
|
||||||
|
|
||||||
_xScale = 1;
|
_xScale = 1;
|
||||||
_yScale = 1;
|
_yScale = 1;
|
||||||
@ -60,9 +57,7 @@ GraphView::GraphView(QWidget *parent)
|
|||||||
|
|
||||||
_units = Metric;
|
_units = Metric;
|
||||||
_graphType = Distance;
|
_graphType = Distance;
|
||||||
|
_xLabel = tr("Distance");
|
||||||
setGraphType(_graphType);
|
|
||||||
setUnits(_units);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
GraphView::~GraphView()
|
GraphView::~GraphView()
|
||||||
@ -75,6 +70,8 @@ GraphView::~GraphView()
|
|||||||
delete _slider;
|
delete _slider;
|
||||||
if (_info->scene() != _scene)
|
if (_info->scene() != _scene)
|
||||||
delete _info;
|
delete _info;
|
||||||
|
if (_grid->scene() != _scene)
|
||||||
|
delete _grid;
|
||||||
|
|
||||||
for (int i = 0; i < _graphs.count(); i++)
|
for (int i = 0; i < _graphs.count(); i++)
|
||||||
if (_graphs.at(i)->scene() != _scene)
|
if (_graphs.at(i)->scene() != _scene)
|
||||||
@ -153,7 +150,7 @@ void GraphView::setGraphType(GraphType type)
|
|||||||
for (int i = 0; i < _graphs.count(); i++) {
|
for (int i = 0; i < _graphs.count(); i++) {
|
||||||
_graphs.at(i)->setGraphType(type);
|
_graphs.at(i)->setGraphType(type);
|
||||||
if (_graphs.at(i)->scene() == _scene)
|
if (_graphs.at(i)->scene() == _scene)
|
||||||
_bounds |= _graphs.at(i)->boundingRect();
|
_bounds |= _graphs.at(i)->bounds();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (type == Distance)
|
if (type == Distance)
|
||||||
@ -165,6 +162,11 @@ void GraphView::setGraphType(GraphType type)
|
|||||||
redraw();
|
redraw();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void GraphView::showGrid(bool show)
|
||||||
|
{
|
||||||
|
_grid->setVisible(show);
|
||||||
|
}
|
||||||
|
|
||||||
void GraphView::loadGraph(const Graph &graph, PathItem *path, int id)
|
void GraphView::loadGraph(const Graph &graph, PathItem *path, int id)
|
||||||
{
|
{
|
||||||
if (graph.size() < 2)
|
if (graph.size() < 2)
|
||||||
@ -173,7 +175,8 @@ void GraphView::loadGraph(const Graph &graph, PathItem *path, int id)
|
|||||||
GraphItem *gi = new GraphItem(graph);
|
GraphItem *gi = new GraphItem(graph);
|
||||||
gi->setGraphType(_graphType);
|
gi->setGraphType(_graphType);
|
||||||
gi->setId(id);
|
gi->setId(id);
|
||||||
gi->setColor(_palette.color());
|
gi->setColor(_palette.nextColor());
|
||||||
|
gi->setWidth(_width);
|
||||||
|
|
||||||
connect(this, SIGNAL(sliderPositionChanged(qreal)), gi,
|
connect(this, SIGNAL(sliderPositionChanged(qreal)), gi,
|
||||||
SLOT(emitSliderPositionChanged(qreal)));
|
SLOT(emitSliderPositionChanged(qreal)));
|
||||||
@ -186,7 +189,7 @@ void GraphView::loadGraph(const Graph &graph, PathItem *path, int id)
|
|||||||
if (!_hide.contains(id)) {
|
if (!_hide.contains(id)) {
|
||||||
_visible.append(gi);
|
_visible.append(gi);
|
||||||
_scene->addItem(gi);
|
_scene->addItem(gi);
|
||||||
_bounds |= gi->boundingRect();
|
_bounds |= gi->bounds();
|
||||||
setXUnits();
|
setXUnits();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -219,7 +222,7 @@ void GraphView::showGraph(bool show, int id)
|
|||||||
else {
|
else {
|
||||||
addItem(gi);
|
addItem(gi);
|
||||||
_visible.append(gi);
|
_visible.append(gi);
|
||||||
_bounds |= gi->boundingRect();
|
_bounds |= gi->bounds();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -241,8 +244,7 @@ void GraphView::redraw(const QSizeF &size)
|
|||||||
QRectF r;
|
QRectF r;
|
||||||
QSizeF mx, my;
|
QSizeF mx, my;
|
||||||
RangeF rx, ry;
|
RangeF rx, ry;
|
||||||
QTransform transform;
|
qreal sx, sy;
|
||||||
qreal xs, ys;
|
|
||||||
|
|
||||||
|
|
||||||
if (_visible.isEmpty() || _bounds.isNull()) {
|
if (_visible.isEmpty() || _bounds.isNull()) {
|
||||||
@ -250,6 +252,7 @@ void GraphView::redraw(const QSizeF &size)
|
|||||||
removeItem(_yAxis);
|
removeItem(_yAxis);
|
||||||
removeItem(_slider);
|
removeItem(_slider);
|
||||||
removeItem(_info);
|
removeItem(_info);
|
||||||
|
removeItem(_grid);
|
||||||
_scene->setSceneRect(QRectF());
|
_scene->setSceneRect(QRectF());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -258,6 +261,7 @@ void GraphView::redraw(const QSizeF &size)
|
|||||||
addItem(_yAxis);
|
addItem(_yAxis);
|
||||||
addItem(_slider);
|
addItem(_slider);
|
||||||
addItem(_info);
|
addItem(_info);
|
||||||
|
addItem(_grid);
|
||||||
|
|
||||||
rx = RangeF(bounds().left() * _xScale, bounds().right() * _xScale);
|
rx = RangeF(bounds().left() * _xScale, bounds().right() * _xScale);
|
||||||
ry = RangeF(bounds().top() * _yScale + _yOffset, bounds().bottom() * _yScale
|
ry = RangeF(bounds().top() * _yScale + _yOffset, bounds().bottom() * _yScale
|
||||||
@ -275,26 +279,29 @@ void GraphView::redraw(const QSizeF &size)
|
|||||||
r.adjust(0, -(_minYRange/2 - r.height()/2), 0,
|
r.adjust(0, -(_minYRange/2 - r.height()/2), 0,
|
||||||
_minYRange/2 - r.height()/2);
|
_minYRange/2 - r.height()/2);
|
||||||
|
|
||||||
xs = (size.width() - (my.width() + mx.width())) / r.width();
|
sx = (size.width() - (my.width() + mx.width())) / r.width();
|
||||||
ys = (size.height() - (mx.height() + my.height())
|
sy = (size.height() - (mx.height() + my.height())
|
||||||
- _info->boundingRect().height()) / r.height();
|
- _info->boundingRect().height()) / r.height();
|
||||||
transform.scale(xs, ys);
|
|
||||||
|
|
||||||
for (int i = 0; i < _visible.size(); i++)
|
for (int i = 0; i < _visible.size(); i++)
|
||||||
_visible.at(i)->setTransform(transform);
|
_visible.at(i)->setScale(sx, sy);
|
||||||
|
|
||||||
QPointF p(r.left() * xs, r.top() * ys);
|
QPointF p(r.left() * sx, r.top() * sy);
|
||||||
QSizeF s(r.width() * xs, r.height() * ys);
|
QSizeF s(r.width() * sx, r.height() * sy);
|
||||||
r = QRectF(p, s);
|
r = QRectF(p, s);
|
||||||
if (r.height() < _minYRange * ys)
|
if (r.height() < _minYRange * sy)
|
||||||
r.adjust(0, -(_minYRange/2 * ys - r.height()/2), 0,
|
r.adjust(0, -(_minYRange/2 * sy - r.height()/2), 0,
|
||||||
(_minYRange/2) * ys - r.height()/2);
|
(_minYRange/2) * sy - r.height()/2);
|
||||||
|
|
||||||
_xAxis->setSize(r.width());
|
_xAxis->setSize(r.width());
|
||||||
_yAxis->setSize(r.height());
|
_yAxis->setSize(r.height());
|
||||||
_xAxis->setPos(r.bottomLeft());
|
_xAxis->setPos(r.bottomLeft());
|
||||||
_yAxis->setPos(r.bottomLeft());
|
_yAxis->setPos(r.bottomLeft());
|
||||||
|
|
||||||
|
_grid->setSize(r.size());
|
||||||
|
_grid->setTicks(_xAxis->ticks(), _yAxis->ticks());
|
||||||
|
_grid->setPos(r.bottomLeft());
|
||||||
|
|
||||||
_slider->setArea(r);
|
_slider->setArea(r);
|
||||||
updateSliderPosition();
|
updateSliderPosition();
|
||||||
|
|
||||||
@ -311,6 +318,14 @@ void GraphView::resizeEvent(QResizeEvent *)
|
|||||||
redraw();
|
redraw();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void GraphView::mousePressEvent(QMouseEvent *e)
|
||||||
|
{
|
||||||
|
if (e->button() == Qt::LeftButton)
|
||||||
|
newSliderPosition(mapToScene(e->pos()));
|
||||||
|
|
||||||
|
QGraphicsView::mousePressEvent(e);
|
||||||
|
}
|
||||||
|
|
||||||
void GraphView::plot(QPainter *painter, const QRectF &target)
|
void GraphView::plot(QPainter *painter, const QRectF &target)
|
||||||
{
|
{
|
||||||
qreal ratio = painter->paintEngine()->paintDevice()->logicalDpiX()
|
qreal ratio = painter->paintEngine()->paintDevice()->logicalDpiX()
|
||||||
@ -368,7 +383,7 @@ void GraphView::updateSliderInfo()
|
|||||||
if (!_sliderInfo->isVisible())
|
if (!_sliderInfo->isVisible())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
QRectF br(_visible.first()->boundingRect());
|
QRectF br(_visible.first()->bounds());
|
||||||
if (br.height() < _minYRange)
|
if (br.height() < _minYRange)
|
||||||
br.adjust(0, -(_minYRange/2 - br.height()/2), 0,
|
br.adjust(0, -(_minYRange/2 - br.height()/2), 0,
|
||||||
_minYRange/2 - br.height()/2);
|
_minYRange/2 - br.height()/2);
|
||||||
@ -392,6 +407,8 @@ void GraphView::emitSliderPositionChanged(const QPointF &pos)
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
_sliderPos = (pos.x() / _slider->area().width()) * bounds().width();
|
_sliderPos = (pos.x() / _slider->area().width()) * bounds().width();
|
||||||
|
_sliderPos = qMax(_sliderPos, bounds().left());
|
||||||
|
_sliderPos = qMin(_sliderPos, bounds().right());
|
||||||
updateSliderPosition();
|
updateSliderPosition();
|
||||||
|
|
||||||
emit sliderPositionChanged(_sliderPos);
|
emit sliderPositionChanged(_sliderPos);
|
||||||
@ -421,3 +438,31 @@ void GraphView::clearInfo()
|
|||||||
{
|
{
|
||||||
_info->clear();
|
_info->clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void GraphView::setPalette(const Palette &palette)
|
||||||
|
{
|
||||||
|
_palette = palette;
|
||||||
|
_palette.reset();
|
||||||
|
|
||||||
|
for (int i = 0; i < _graphs.count(); i++)
|
||||||
|
_graphs.at(i)->setColor(_palette.nextColor());
|
||||||
|
}
|
||||||
|
|
||||||
|
void GraphView::setGraphWidth(int width)
|
||||||
|
{
|
||||||
|
_width = width;
|
||||||
|
|
||||||
|
for (int i = 0; i < _graphs.count(); i++)
|
||||||
|
_graphs.at(i)->setWidth(width);
|
||||||
|
}
|
||||||
|
|
||||||
|
void GraphView::useOpenGL(bool use)
|
||||||
|
{
|
||||||
|
if (use) {
|
||||||
|
#ifdef Q_OS_WIN32
|
||||||
|
if (QSysInfo::WindowsVersion >= QSysInfo::WV_VISTA)
|
||||||
|
#endif // Q_OS_WIN32
|
||||||
|
setViewport(new OPENGL_WIDGET);
|
||||||
|
} else
|
||||||
|
setViewport(new QWidget);
|
||||||
|
}
|
||||||
|
@ -2,11 +2,8 @@
|
|||||||
#define GRAPHVIEW_H
|
#define GRAPHVIEW_H
|
||||||
|
|
||||||
#include <QGraphicsView>
|
#include <QGraphicsView>
|
||||||
#include <QGraphicsScene>
|
|
||||||
#include <QVector>
|
|
||||||
#include <QList>
|
#include <QList>
|
||||||
#include <QSet>
|
#include <QSet>
|
||||||
#include <QPointF>
|
|
||||||
#include "palette.h"
|
#include "palette.h"
|
||||||
#include "units.h"
|
#include "units.h"
|
||||||
#include "graph.h"
|
#include "graph.h"
|
||||||
@ -18,18 +15,7 @@ class SliderInfoItem;
|
|||||||
class InfoItem;
|
class InfoItem;
|
||||||
class GraphItem;
|
class GraphItem;
|
||||||
class PathItem;
|
class PathItem;
|
||||||
|
class GridItem;
|
||||||
class Scene : public QGraphicsScene
|
|
||||||
{
|
|
||||||
Q_OBJECT
|
|
||||||
|
|
||||||
public:
|
|
||||||
Scene(QObject *parent = 0) : QGraphicsScene(parent) {}
|
|
||||||
void mousePressEvent(QGraphicsSceneMouseEvent *e);
|
|
||||||
|
|
||||||
signals:
|
|
||||||
void mouseClicked(const QPointF &pos);
|
|
||||||
};
|
|
||||||
|
|
||||||
class GraphView : public QGraphicsView
|
class GraphView : public QGraphicsView
|
||||||
{
|
{
|
||||||
@ -47,6 +33,10 @@ public:
|
|||||||
void showGraph(bool show, int id = 0);
|
void showGraph(bool show, int id = 0);
|
||||||
void setGraphType(GraphType type);
|
void setGraphType(GraphType type);
|
||||||
void setUnits(Units units);
|
void setUnits(Units units);
|
||||||
|
void showGrid(bool show);
|
||||||
|
|
||||||
|
void setPalette(const Palette &palette);
|
||||||
|
void setGraphWidth(int width);
|
||||||
|
|
||||||
const QString &yLabel() const {return _yLabel;}
|
const QString &yLabel() const {return _yLabel;}
|
||||||
const QString &yUnits() const {return _yUnits;}
|
const QString &yUnits() const {return _yUnits;}
|
||||||
@ -65,6 +55,8 @@ public:
|
|||||||
|
|
||||||
void plot(QPainter *painter, const QRectF &target);
|
void plot(QPainter *painter, const QRectF &target);
|
||||||
|
|
||||||
|
void useOpenGL(bool use);
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void sliderPositionChanged(qreal);
|
void sliderPositionChanged(qreal);
|
||||||
|
|
||||||
@ -73,8 +65,7 @@ protected:
|
|||||||
void redraw(const QSizeF &size);
|
void redraw(const QSizeF &size);
|
||||||
void addInfo(const QString &key, const QString &value);
|
void addInfo(const QString &key, const QString &value);
|
||||||
void clearInfo();
|
void clearInfo();
|
||||||
void skipColor() {_palette.color();}
|
void skipColor() {_palette.nextColor();}
|
||||||
void resizeEvent(QResizeEvent *);
|
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void emitSliderPositionChanged(const QPointF &pos);
|
void emitSliderPositionChanged(const QPointF &pos);
|
||||||
@ -89,6 +80,9 @@ private:
|
|||||||
void removeItem(QGraphicsItem *item);
|
void removeItem(QGraphicsItem *item);
|
||||||
void addItem(QGraphicsItem *item);
|
void addItem(QGraphicsItem *item);
|
||||||
|
|
||||||
|
void resizeEvent(QResizeEvent *);
|
||||||
|
void mousePressEvent(QMouseEvent *);
|
||||||
|
|
||||||
qreal _xScale, _yScale;
|
qreal _xScale, _yScale;
|
||||||
qreal _yOffset;
|
qreal _yOffset;
|
||||||
QString _xUnits, _yUnits;
|
QString _xUnits, _yUnits;
|
||||||
@ -97,18 +91,20 @@ private:
|
|||||||
qreal _minYRange;
|
qreal _minYRange;
|
||||||
qreal _sliderPos;
|
qreal _sliderPos;
|
||||||
|
|
||||||
Scene *_scene;
|
QGraphicsScene *_scene;
|
||||||
|
|
||||||
AxisItem *_xAxis, *_yAxis;
|
AxisItem *_xAxis, *_yAxis;
|
||||||
SliderItem *_slider;
|
SliderItem *_slider;
|
||||||
SliderInfoItem *_sliderInfo;
|
SliderInfoItem *_sliderInfo;
|
||||||
InfoItem *_info;
|
InfoItem *_info;
|
||||||
|
GridItem *_grid;
|
||||||
|
|
||||||
QList<GraphItem*> _graphs;
|
QList<GraphItem*> _graphs;
|
||||||
QList<GraphItem*> _visible;
|
QList<GraphItem*> _visible;
|
||||||
QSet<int> _hide;
|
QSet<int> _hide;
|
||||||
QRectF _bounds;
|
QRectF _bounds;
|
||||||
Palette _palette;
|
Palette _palette;
|
||||||
|
int _width;
|
||||||
|
|
||||||
Units _units;
|
Units _units;
|
||||||
GraphType _graphType;
|
GraphType _graphType;
|
||||||
|
50
src/griditem.cpp
Normal file
@ -0,0 +1,50 @@
|
|||||||
|
#include <QPainter>
|
||||||
|
#include "griditem.h"
|
||||||
|
|
||||||
|
|
||||||
|
#define GRID_WIDTH 0
|
||||||
|
|
||||||
|
GridItem::GridItem(QGraphicsItem *parent) : QGraphicsItem(parent)
|
||||||
|
{
|
||||||
|
#ifndef Q_OS_MAC
|
||||||
|
setCacheMode(QGraphicsItem::DeviceCoordinateCache);
|
||||||
|
#endif // Q_OS_MAC
|
||||||
|
}
|
||||||
|
|
||||||
|
void GridItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *option,
|
||||||
|
QWidget *widget)
|
||||||
|
{
|
||||||
|
Q_UNUSED(option);
|
||||||
|
Q_UNUSED(widget);
|
||||||
|
QBrush brush(Qt::gray);
|
||||||
|
QPen pen = QPen(brush, GRID_WIDTH, Qt::DotLine);
|
||||||
|
|
||||||
|
|
||||||
|
painter->setRenderHint(QPainter::Antialiasing, false);
|
||||||
|
painter->setPen(pen);
|
||||||
|
|
||||||
|
for (int i = 0; i < _xTicks.size(); i++)
|
||||||
|
painter->drawLine(_xTicks.at(i), 0, _xTicks.at(i),
|
||||||
|
-_boundingRect.height());
|
||||||
|
for (int i = 0; i < _yTicks.size(); i++)
|
||||||
|
painter->drawLine(0, -_yTicks.at(i), boundingRect().width(),
|
||||||
|
-_yTicks.at(i));
|
||||||
|
|
||||||
|
/*
|
||||||
|
painter->setPen(Qt::red);
|
||||||
|
painter->drawRect(boundingRect());
|
||||||
|
*/
|
||||||
|
}
|
||||||
|
|
||||||
|
void GridItem::setTicks(const QList<qreal> &x, const QList<qreal> &y)
|
||||||
|
{
|
||||||
|
_xTicks = x; _yTicks = y;
|
||||||
|
update();
|
||||||
|
}
|
||||||
|
|
||||||
|
void GridItem::setSize(const QSizeF &size)
|
||||||
|
{
|
||||||
|
prepareGeometryChange();
|
||||||
|
|
||||||
|
_boundingRect = QRectF(QPointF(0, -size.height()), size);
|
||||||
|
}
|
23
src/griditem.h
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
#ifndef GRIDITEM_H
|
||||||
|
#define GRIDITEM_H
|
||||||
|
|
||||||
|
#include <QGraphicsItem>
|
||||||
|
|
||||||
|
class GridItem : public QGraphicsItem
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
GridItem(QGraphicsItem *parent = 0);
|
||||||
|
|
||||||
|
QRectF boundingRect() const {return _boundingRect;}
|
||||||
|
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option,
|
||||||
|
QWidget *widget);
|
||||||
|
|
||||||
|
void setTicks(const QList<qreal> &x, const QList<qreal> &y);
|
||||||
|
void setSize(const QSizeF &size);
|
||||||
|
|
||||||
|
private:
|
||||||
|
QRectF _boundingRect;
|
||||||
|
QList<qreal> _xTicks, _yTicks;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // GRIDITEM_H
|
662
src/gui.cpp
36
src/gui.h
@ -9,7 +9,8 @@
|
|||||||
#include "units.h"
|
#include "units.h"
|
||||||
#include "graph.h"
|
#include "graph.h"
|
||||||
#include "poi.h"
|
#include "poi.h"
|
||||||
#include "margins.h"
|
#include "exportdialog.h"
|
||||||
|
#include "optionsdialog.h"
|
||||||
|
|
||||||
class QMenu;
|
class QMenu;
|
||||||
class QToolBar;
|
class QToolBar;
|
||||||
@ -45,16 +46,17 @@ private slots:
|
|||||||
void reloadFile();
|
void reloadFile();
|
||||||
void openPOIFile();
|
void openPOIFile();
|
||||||
void closePOIFiles();
|
void closePOIFiles();
|
||||||
void showPOI(bool checked);
|
void showMap(bool show);
|
||||||
void showMap(bool checked);
|
void showGraphs(bool show);
|
||||||
void showGraphs(bool checked);
|
void showGraphGrids(bool show);
|
||||||
void showToolbars(bool checked);
|
void showToolbars(bool show);
|
||||||
void showFullscreen(bool checked);
|
void showFullscreen(bool show);
|
||||||
void showTracks(bool show);
|
void showTracks(bool show);
|
||||||
void showRoutes(bool show);
|
void showRoutes(bool show);
|
||||||
void clearMapCache();
|
void clearMapCache();
|
||||||
void nextMap();
|
void nextMap();
|
||||||
void prevMap();
|
void prevMap();
|
||||||
|
void openOptions();
|
||||||
|
|
||||||
void mapChanged(int);
|
void mapChanged(int);
|
||||||
void graphChanged(int);
|
void graphChanged(int);
|
||||||
@ -89,6 +91,7 @@ private:
|
|||||||
void createStatusBar();
|
void createStatusBar();
|
||||||
void createPathView();
|
void createPathView();
|
||||||
void createGraphTabs();
|
void createGraphTabs();
|
||||||
|
void createBrowser();
|
||||||
|
|
||||||
bool openPOIFile(const QString &fileName);
|
bool openPOIFile(const QString &fileName);
|
||||||
bool loadFile(const QString &fileName);
|
bool loadFile(const QString &fileName);
|
||||||
@ -97,19 +100,23 @@ private:
|
|||||||
void updateWindowTitle();
|
void updateWindowTitle();
|
||||||
void updateNavigationActions();
|
void updateNavigationActions();
|
||||||
void updateGraphTabs();
|
void updateGraphTabs();
|
||||||
void updateTrackView();
|
void updatePathView();
|
||||||
|
|
||||||
void setUnits(Units units);
|
void setUnits(Units units);
|
||||||
void setGraphType(GraphType type);
|
void setGraphType(GraphType type);
|
||||||
|
|
||||||
qreal distance();
|
qreal distance() const;
|
||||||
qreal time();
|
qreal time() const;
|
||||||
int mapIndex(const QString &name);
|
int mapIndex(const QString &name);
|
||||||
void readSettings();
|
void readSettings();
|
||||||
void writeSettings();
|
void writeSettings();
|
||||||
|
|
||||||
|
const QString fileFormats() const;
|
||||||
|
|
||||||
void keyPressEvent(QKeyEvent *event);
|
void keyPressEvent(QKeyEvent *event);
|
||||||
void closeEvent(QCloseEvent *event);
|
void closeEvent(QCloseEvent *event);
|
||||||
|
void dragEnterEvent(QDragEnterEvent *event);
|
||||||
|
void dropEvent(QDropEvent *event);
|
||||||
|
|
||||||
QToolBar *_fileToolBar;
|
QToolBar *_fileToolBar;
|
||||||
QToolBar *_showToolBar;
|
QToolBar *_showToolBar;
|
||||||
@ -137,6 +144,7 @@ private:
|
|||||||
QAction *_fullscreenAction;
|
QAction *_fullscreenAction;
|
||||||
QAction *_clearMapCacheAction;
|
QAction *_clearMapCacheAction;
|
||||||
QAction *_showGraphsAction;
|
QAction *_showGraphsAction;
|
||||||
|
QAction *_showGraphGridAction;
|
||||||
QAction *_distanceGraphAction;
|
QAction *_distanceGraphAction;
|
||||||
QAction *_timeGraphAction;
|
QAction *_timeGraphAction;
|
||||||
QAction *_showToolbarsAction;
|
QAction *_showToolbarsAction;
|
||||||
@ -153,6 +161,7 @@ private:
|
|||||||
QAction *_showWaypointsAction;
|
QAction *_showWaypointsAction;
|
||||||
QAction *_showWaypointLabelsAction;
|
QAction *_showWaypointLabelsAction;
|
||||||
QAction *_showRouteWaypointsAction;
|
QAction *_showRouteWaypointsAction;
|
||||||
|
QAction *_openOptionsAction;
|
||||||
QList<QAction*> _mapActions;
|
QList<QAction*> _mapActions;
|
||||||
QList<QAction*> _poiFilesActions;
|
QList<QAction*> _poiFilesActions;
|
||||||
|
|
||||||
@ -166,7 +175,7 @@ private:
|
|||||||
QTabWidget *_graphTabWidget;
|
QTabWidget *_graphTabWidget;
|
||||||
QList<GraphTab*> _tabs;
|
QList<GraphTab*> _tabs;
|
||||||
|
|
||||||
POI _poi;
|
POI *_poi;
|
||||||
QList<Map*> _maps;
|
QList<Map*> _maps;
|
||||||
|
|
||||||
FileBrowser *_browser;
|
FileBrowser *_browser;
|
||||||
@ -180,16 +189,15 @@ private:
|
|||||||
qreal _routeDistance;
|
qreal _routeDistance;
|
||||||
qreal _time;
|
qreal _time;
|
||||||
DateRange _dateRange;
|
DateRange _dateRange;
|
||||||
|
QString _pathName;
|
||||||
|
|
||||||
qreal _sliderPos;
|
qreal _sliderPos;
|
||||||
|
|
||||||
int _frameStyle;
|
int _frameStyle;
|
||||||
bool _showGraphs;
|
bool _showGraphs;
|
||||||
|
|
||||||
QString _exportFileName;
|
Export _export;
|
||||||
QPrinter::PaperSize _exportPaperSize;
|
Options _options;
|
||||||
QPrinter::Orientation _exportOrientation;
|
|
||||||
MarginsF _exportMargins;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // GUI_H
|
#endif // GUI_H
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
#include "gpx.h"
|
#include "data.h"
|
||||||
#include "heartrategraph.h"
|
#include "heartrategraph.h"
|
||||||
|
|
||||||
|
|
||||||
@ -24,10 +24,10 @@ void HeartRateGraph::setInfo()
|
|||||||
clearInfo();
|
clearInfo();
|
||||||
}
|
}
|
||||||
|
|
||||||
void HeartRateGraph::loadGPX(const GPX &gpx, const QList<PathItem *> &paths)
|
void HeartRateGraph::loadData(const Data &data, const QList<PathItem *> &paths)
|
||||||
{
|
{
|
||||||
for (int i = 0; i < gpx.tracks().count(); i++) {
|
for (int i = 0; i < data.tracks().count(); i++) {
|
||||||
const Graph &graph = gpx.tracks().at(i)->heartRate();
|
const Graph &graph = data.tracks().at(i)->heartRate();
|
||||||
qreal sum = 0, w = 0;
|
qreal sum = 0, w = 0;
|
||||||
|
|
||||||
if (graph.size() < 2) {
|
if (graph.size() < 2) {
|
||||||
@ -40,12 +40,12 @@ void HeartRateGraph::loadGPX(const GPX &gpx, const QList<PathItem *> &paths)
|
|||||||
sum += graph.at(j).y() * ds;
|
sum += graph.at(j).y() * ds;
|
||||||
w += ds;
|
w += ds;
|
||||||
}
|
}
|
||||||
_avg.append(QPointF(gpx.tracks().at(i)->distance(), sum/w));
|
_avg.append(QPointF(data.tracks().at(i)->distance(), sum/w));
|
||||||
|
|
||||||
GraphView::loadGraph(graph, paths.at(i));
|
GraphView::loadGraph(graph, paths.at(i));
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int i = 0; i < gpx.routes().count(); i++)
|
for (int i = 0; i < data.routes().count(); i++)
|
||||||
skipColor();
|
skipColor();
|
||||||
|
|
||||||
setInfo();
|
setInfo();
|
||||||
|
@ -3,8 +3,6 @@
|
|||||||
|
|
||||||
#include "graphtab.h"
|
#include "graphtab.h"
|
||||||
|
|
||||||
class GPX;
|
|
||||||
|
|
||||||
class HeartRateGraph : public GraphTab
|
class HeartRateGraph : public GraphTab
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
@ -13,7 +11,7 @@ public:
|
|||||||
HeartRateGraph(QWidget *parent = 0);
|
HeartRateGraph(QWidget *parent = 0);
|
||||||
|
|
||||||
QString label() const {return tr("Heart rate");}
|
QString label() const {return tr("Heart rate");}
|
||||||
void loadGPX(const GPX &gpx, const QList<PathItem *> &paths);
|
void loadData(const Data &data, const QList<PathItem *> &paths);
|
||||||
void clear();
|
void clear();
|
||||||
void setUnits(enum Units) {}
|
void setUnits(enum Units) {}
|
||||||
void showTracks(bool show);
|
void showTracks(bool show);
|
||||||
|
38
src/icons.h
@ -1,20 +1,28 @@
|
|||||||
#ifndef ICONS_H
|
#ifndef ICONS_H
|
||||||
#define ICONS_H
|
#define ICONS_H
|
||||||
|
|
||||||
#define APP_ICON ":/icons/gpxsee.png"
|
#define APP_ICON ":/icons/gpxsee.png"
|
||||||
#define OPEN_FILE_ICON ":/icons/document-open.png"
|
|
||||||
#define EXPORT_FILE_ICON ":/icons/document-export.png"
|
// Toolbar/menu icons
|
||||||
#define PRINT_FILE_ICON ":/icons/document-print.png"
|
#define OPEN_FILE_ICON ":/icons/document-open.png"
|
||||||
#define CLOSE_FILE_ICON ":/icons/dialog-close.png"
|
#define EXPORT_FILE_ICON ":/icons/document-export.png"
|
||||||
#define SHOW_POI_ICON ":/icons/flag.png"
|
#define PRINT_FILE_ICON ":/icons/document-print.png"
|
||||||
#define SHOW_MAP_ICON ":/icons/applications-internet.png"
|
#define CLOSE_FILE_ICON ":/icons/dialog-close.png"
|
||||||
#define SHOW_GRAPHS_ICON ":/icons/office-chart-line-stacked.png"
|
#define SHOW_POI_ICON ":/icons/flag.png"
|
||||||
#define QUIT_ICON ":/icons/application-exit.png"
|
#define SHOW_MAP_ICON ":/icons/applications-internet.png"
|
||||||
#define RELOAD_FILE_ICON ":/icons/view-refresh.png"
|
#define SHOW_GRAPHS_ICON ":/icons/office-chart-line-stacked.png"
|
||||||
#define NEXT_FILE_ICON ":/icons/arrow-right.png"
|
#define QUIT_ICON ":/icons/application-exit.png"
|
||||||
#define PREV_FILE_ICON ":/icons/arrow-left.png"
|
#define RELOAD_FILE_ICON ":/icons/view-refresh.png"
|
||||||
#define LAST_FILE_ICON ":/icons/arrow-right-double.png"
|
#define NEXT_FILE_ICON ":/icons/arrow-right.png"
|
||||||
#define FIRST_FILE_ICON ":/icons/arrow-left-double.png"
|
#define PREV_FILE_ICON ":/icons/arrow-left.png"
|
||||||
#define FULLSCREEN_ICON ":/icons/view-fullscreen.png"
|
#define LAST_FILE_ICON ":/icons/arrow-right-double.png"
|
||||||
|
#define FIRST_FILE_ICON ":/icons/arrow-left-double.png"
|
||||||
|
#define FULLSCREEN_ICON ":/icons/view-fullscreen.png"
|
||||||
|
|
||||||
|
// Options dialog icons
|
||||||
|
#define APPEARANCE_ICON ":/icons/preferences-desktop-display.png"
|
||||||
|
#define POI_ICON ":/icons/flag_48.png"
|
||||||
|
#define SYSTEM_ICON ":/icons/system-run.png"
|
||||||
|
#define PRINT_EXPORT_ICON ":/icons/document-print-preview.png"
|
||||||
|
|
||||||
#endif /* ICONS_H */
|
#endif /* ICONS_H */
|
||||||
|
249
src/igcparser.cpp
Normal file
@ -0,0 +1,249 @@
|
|||||||
|
#include <cstring>
|
||||||
|
#include "misc.h"
|
||||||
|
#include "igcparser.h"
|
||||||
|
|
||||||
|
|
||||||
|
static bool readLat(const char *data, qreal &lat)
|
||||||
|
{
|
||||||
|
int d = str2int(data, 2);
|
||||||
|
int mi = str2int(data + 2, 2);
|
||||||
|
int mf = str2int(data + 4, 3);
|
||||||
|
if (d < 0 || mi < 0 || mf < 0)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
if (!(data[7] == 'N' || data[7] == 'S'))
|
||||||
|
return false;
|
||||||
|
|
||||||
|
lat = d + (((qreal)mi + (qreal)mf/1000) / 60);
|
||||||
|
if (lat > 90)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
if (data[7] == 'S')
|
||||||
|
lat = -lat;
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
static bool readLon(const char *data, qreal &lon)
|
||||||
|
{
|
||||||
|
int d = str2int(data, 3);
|
||||||
|
int mi = str2int(data + 3, 2);
|
||||||
|
int mf = str2int(data + 5, 3);
|
||||||
|
if (d < 0 || mi < 0 || mf < 0)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
if (!(data[8] == 'E' || data[8] == 'W'))
|
||||||
|
return false;
|
||||||
|
|
||||||
|
lon = d + (((qreal)mi + (qreal)mf/1000) / 60);
|
||||||
|
if (lon > 180)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
if (data[8] == 'W')
|
||||||
|
lon = -lon;
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
static bool readAltitude(const char *data, qreal &ele)
|
||||||
|
{
|
||||||
|
int p;
|
||||||
|
|
||||||
|
if (!(data[0] == 'A' || data[0] == 'V'))
|
||||||
|
return false;
|
||||||
|
|
||||||
|
if (data[1] == '-')
|
||||||
|
p = str2int(data + 2, 4);
|
||||||
|
else
|
||||||
|
p = str2int(data + 1, 5);
|
||||||
|
|
||||||
|
int g = str2int(data + 6, 5);
|
||||||
|
if (p < 0 || g < 0)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
if (data[0] == 'A')
|
||||||
|
ele = (qreal)g;
|
||||||
|
else
|
||||||
|
ele = NAN;
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
static bool readTimestamp(const char *data, QTime &time)
|
||||||
|
{
|
||||||
|
int h = str2int(data, 2);
|
||||||
|
int m = str2int(data + 2, 2);
|
||||||
|
int s = str2int(data + 4, 2);
|
||||||
|
|
||||||
|
if (h < 0 || m < 0 || s < 0)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
time = QTime(h, m, s);
|
||||||
|
if (!time.isValid())
|
||||||
|
return false;
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
static bool readARecord(const char *line, qint64 len)
|
||||||
|
{
|
||||||
|
if (len < 9 || line[0] != 'A')
|
||||||
|
return false;
|
||||||
|
|
||||||
|
for (int i = 1; i < 7; i++)
|
||||||
|
if (!::isprint(line[i]))
|
||||||
|
return false;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool IGCParser::readHRecord(const char *line, int len)
|
||||||
|
{
|
||||||
|
if (len < 10 || ::strncmp(line, "HFDTE", 5))
|
||||||
|
return true;
|
||||||
|
|
||||||
|
int d = str2int(line + 5, 2);
|
||||||
|
int m = str2int(line + 7, 2);
|
||||||
|
int y = str2int(line + 9, 2);
|
||||||
|
|
||||||
|
if (y < 0 || m < 0 || d < 0) {
|
||||||
|
_errorString = "Invalid date header format";
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
_date = QDate(y + 2000 < QDate::currentDate().year() ? 2000 + y : 1900 + y,
|
||||||
|
m, d);
|
||||||
|
if (!_date.isValid()) {
|
||||||
|
_errorString = "Invalid date";
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool IGCParser::readBRecord(const char *line, int len)
|
||||||
|
{
|
||||||
|
qreal lat, lon, ele;
|
||||||
|
QTime time;
|
||||||
|
|
||||||
|
|
||||||
|
if (len < 35)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
if (!readTimestamp(line + 1, time)) {
|
||||||
|
_errorString = "Invalid timestamp";
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!readLat(line + 7, lat)) {
|
||||||
|
_errorString = "Invalid latitude";
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (!readLon(line + 15, lon)) {
|
||||||
|
_errorString = "Invalid longitude";
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!readAltitude(line + 24, ele)) {
|
||||||
|
_errorString = "Invalid altitude";
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
if (time < _time)
|
||||||
|
_date = _date.addDays(1);
|
||||||
|
_time = time;
|
||||||
|
|
||||||
|
Trackpoint t(Coordinates(lon, lat));
|
||||||
|
t.setTimestamp(QDateTime(_date, _time, Qt::UTC));
|
||||||
|
t.setElevation(ele);
|
||||||
|
_tracks.last().append(t);
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool IGCParser::readCRecord(const char *line, int len)
|
||||||
|
{
|
||||||
|
qreal lat, lon;
|
||||||
|
|
||||||
|
|
||||||
|
if (len < 18)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
if (!readLat(line + 1, lat)) {
|
||||||
|
_errorString = "Invalid latitude";
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (!readLon(line + 9, lon)) {
|
||||||
|
_errorString = "Invalid longitude";
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!(lat == 0 && lon == 0)) {
|
||||||
|
QByteArray ba(line + 18, len - 19);
|
||||||
|
|
||||||
|
Waypoint w(Coordinates(lon, lat));
|
||||||
|
w.setName(QString(ba.trimmed()));
|
||||||
|
_routes.last().append(w);
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool IGCParser::loadFile(QFile *file)
|
||||||
|
{
|
||||||
|
qint64 len;
|
||||||
|
char line[76 + 2 + 1 + 1];
|
||||||
|
bool route = false, track = false;
|
||||||
|
|
||||||
|
|
||||||
|
_errorLine = 1;
|
||||||
|
_errorString.clear();
|
||||||
|
|
||||||
|
while (!file->atEnd()) {
|
||||||
|
len = file->readLine(line, sizeof(line));
|
||||||
|
|
||||||
|
if (len < 0) {
|
||||||
|
_errorString = "I/O error";
|
||||||
|
return false;
|
||||||
|
} else if (len > (qint64)sizeof(line) - 1) {
|
||||||
|
_errorString = "Line limit exceeded";
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (_errorLine == 1) {
|
||||||
|
if (!readARecord(line, len)) {
|
||||||
|
_errorString = "Invalid/missing A record";
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if (line[0] == 'H') {
|
||||||
|
if (!readHRecord(line, len))
|
||||||
|
return false;
|
||||||
|
} else if (line[0] == 'C') {
|
||||||
|
if (route) {
|
||||||
|
if (!readCRecord(line, len))
|
||||||
|
return false;
|
||||||
|
} else {
|
||||||
|
route = true;
|
||||||
|
_routes.append(RouteData());
|
||||||
|
}
|
||||||
|
} else if (line[0] == 'B') {
|
||||||
|
if (_date.isNull()) {
|
||||||
|
_errorString = "Missing date header";
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (!track) {
|
||||||
|
_tracks.append(TrackData());
|
||||||
|
_time = QTime(0, 0);
|
||||||
|
track = true;
|
||||||
|
}
|
||||||
|
if (!readBRecord(line, len))
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
_errorLine++;
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
33
src/igcparser.h
Normal file
@ -0,0 +1,33 @@
|
|||||||
|
#ifndef IGCPARSER_H
|
||||||
|
#define IGCPARSER_H
|
||||||
|
|
||||||
|
#include <QDate>
|
||||||
|
#include <QTime>
|
||||||
|
#include "parser.h"
|
||||||
|
|
||||||
|
|
||||||
|
class IGCParser : public Parser
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
IGCParser(QList<TrackData> &tracks, QList<RouteData> &routes,
|
||||||
|
QList<Waypoint> &waypoints) : Parser(tracks, routes, waypoints)
|
||||||
|
{_errorLine = 0;}
|
||||||
|
~IGCParser() {}
|
||||||
|
|
||||||
|
bool loadFile(QFile *file);
|
||||||
|
QString errorString() const {return _errorString;}
|
||||||
|
int errorLine() const {return _errorLine;}
|
||||||
|
|
||||||
|
private:
|
||||||
|
bool readHRecord(const char *line, int len);
|
||||||
|
bool readBRecord(const char *line, int len);
|
||||||
|
bool readCRecord(const char *line, int len);
|
||||||
|
|
||||||
|
int _errorLine;
|
||||||
|
QString _errorString;
|
||||||
|
|
||||||
|
QDate _date;
|
||||||
|
QTime _time;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // IGCPARSER_H
|
@ -7,7 +7,9 @@
|
|||||||
|
|
||||||
InfoItem::InfoItem(QGraphicsItem *parent) : QGraphicsItem(parent)
|
InfoItem::InfoItem(QGraphicsItem *parent) : QGraphicsItem(parent)
|
||||||
{
|
{
|
||||||
|
#ifndef Q_OS_MAC
|
||||||
|
setCacheMode(QGraphicsItem::DeviceCoordinateCache);
|
||||||
|
#endif // Q_OS_MAC
|
||||||
}
|
}
|
||||||
|
|
||||||
void InfoItem::updateBoundingRect()
|
void InfoItem::updateBoundingRect()
|
||||||
@ -40,6 +42,9 @@ void InfoItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *option,
|
|||||||
QList<KV>::const_iterator i;
|
QList<KV>::const_iterator i;
|
||||||
int width = 0;
|
int width = 0;
|
||||||
|
|
||||||
|
|
||||||
|
painter->setRenderHint(QPainter::Antialiasing, false);
|
||||||
|
|
||||||
for (i = _list.constBegin(); i != _list.constEnd(); i++) {
|
for (i = _list.constBegin(); i != _list.constEnd(); i++) {
|
||||||
painter->drawText(width, fm.height() - fm.descent(), i->key + ": ");
|
painter->drawText(width, fm.height() - fm.descent(), i->key + ": ");
|
||||||
width += fm.width(i->key + ": ");
|
width += fm.width(i->key + ": ");
|
||||||
|
368
src/kmlparser.cpp
Normal file
@ -0,0 +1,368 @@
|
|||||||
|
#include "kmlparser.h"
|
||||||
|
|
||||||
|
|
||||||
|
qreal KMLParser::number()
|
||||||
|
{
|
||||||
|
bool res;
|
||||||
|
qreal ret = _reader.readElementText().toDouble(&res);
|
||||||
|
if (!res)
|
||||||
|
_reader.raiseError(QString("Invalid %1").arg(
|
||||||
|
_reader.name().toString()));
|
||||||
|
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
QDateTime KMLParser::time()
|
||||||
|
{
|
||||||
|
QDateTime d = QDateTime::fromString(_reader.readElementText(),
|
||||||
|
Qt::ISODate);
|
||||||
|
if (!d.isValid())
|
||||||
|
_reader.raiseError(QString("Invalid %1").arg(
|
||||||
|
_reader.name().toString()));
|
||||||
|
|
||||||
|
return d;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool KMLParser::coord(Trackpoint &trackpoint)
|
||||||
|
{
|
||||||
|
QString data = _reader.readElementText();
|
||||||
|
const QChar *sp, *ep, *cp, *vp;
|
||||||
|
int c = 0;
|
||||||
|
qreal val[3];
|
||||||
|
bool res;
|
||||||
|
|
||||||
|
|
||||||
|
sp = data.constData();
|
||||||
|
ep = sp + data.size();
|
||||||
|
|
||||||
|
for (cp = sp; cp < ep; cp++)
|
||||||
|
if (!cp->isSpace())
|
||||||
|
break;
|
||||||
|
|
||||||
|
for (vp = cp; cp <= ep; cp++) {
|
||||||
|
if (cp->isSpace() || cp->isNull()) {
|
||||||
|
if (c > 2)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
#if QT_VERSION < QT_VERSION_CHECK(5, 0, 0)
|
||||||
|
val[c] = QString(vp, cp - vp).toDouble(&res);
|
||||||
|
#else // QT_VERSION < 5
|
||||||
|
val[c] = QStringRef(&data, vp - sp, cp - vp).toDouble(&res);
|
||||||
|
#endif // QT_VERSION < 5
|
||||||
|
if (!res)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
if (c == 1) {
|
||||||
|
trackpoint.setCoordinates(Coordinates(val[0], val[1]));
|
||||||
|
if (!trackpoint.coordinates().isValid())
|
||||||
|
return false;
|
||||||
|
} else if (c == 2)
|
||||||
|
trackpoint.setElevation(val[2]);
|
||||||
|
|
||||||
|
while (cp->isSpace())
|
||||||
|
cp++;
|
||||||
|
vp = cp;
|
||||||
|
c++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool KMLParser::pointCoordinates(Waypoint &waypoint)
|
||||||
|
{
|
||||||
|
QString data = _reader.readElementText();
|
||||||
|
const QChar *sp, *ep, *cp, *vp;
|
||||||
|
int c = 0;
|
||||||
|
qreal val[3];
|
||||||
|
bool res;
|
||||||
|
|
||||||
|
|
||||||
|
sp = data.constData();
|
||||||
|
ep = sp + data.size();
|
||||||
|
|
||||||
|
for (cp = sp; cp < ep; cp++)
|
||||||
|
if (!cp->isSpace())
|
||||||
|
break;
|
||||||
|
|
||||||
|
for (vp = cp; cp <= ep; cp++) {
|
||||||
|
if (*cp == ',') {
|
||||||
|
if (c > 1)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
#if QT_VERSION < QT_VERSION_CHECK(5, 0, 0)
|
||||||
|
val[c] = QString(vp, cp - vp).toDouble(&res);
|
||||||
|
#else // QT_VERSION < 5
|
||||||
|
val[c] = QStringRef(&data, vp - sp, cp - vp).toDouble(&res);
|
||||||
|
#endif // QT_VERSION < 5
|
||||||
|
if (!res)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
c++;
|
||||||
|
vp = cp + 1;
|
||||||
|
} else if (cp->isSpace() || cp->isNull()) {
|
||||||
|
if (c < 1)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
#if QT_VERSION < QT_VERSION_CHECK(5, 0, 0)
|
||||||
|
val[c] = QString(vp, cp - vp).toDouble(&res);
|
||||||
|
#else // QT_VERSION < 5
|
||||||
|
val[c] = QStringRef(&data, vp - sp, cp - vp).toDouble(&res);
|
||||||
|
#endif // QT_VERSION < 5
|
||||||
|
if (!res)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
waypoint.setCoordinates(Coordinates(val[0], val[1]));
|
||||||
|
if (!waypoint.coordinates().isValid())
|
||||||
|
return false;
|
||||||
|
if (c == 2)
|
||||||
|
waypoint.setElevation(val[2]);
|
||||||
|
|
||||||
|
while (cp->isSpace())
|
||||||
|
cp++;
|
||||||
|
c = 3;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool KMLParser::lineCoordinates(TrackData &track)
|
||||||
|
{
|
||||||
|
QString data = _reader.readElementText();
|
||||||
|
const QChar *sp, *ep, *cp, *vp;
|
||||||
|
int c = 0;
|
||||||
|
qreal val[3];
|
||||||
|
bool res;
|
||||||
|
|
||||||
|
|
||||||
|
sp = data.constData();
|
||||||
|
ep = sp + data.size();
|
||||||
|
|
||||||
|
for (cp = sp; cp < ep; cp++)
|
||||||
|
if (!cp->isSpace())
|
||||||
|
break;
|
||||||
|
|
||||||
|
for (vp = cp; cp <= ep; cp++) {
|
||||||
|
if (*cp == ',') {
|
||||||
|
if (c > 1)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
#if QT_VERSION < QT_VERSION_CHECK(5, 0, 0)
|
||||||
|
val[c] = QString(vp, cp - vp).toDouble(&res);
|
||||||
|
#else // QT_VERSION < 5
|
||||||
|
val[c] = QStringRef(&data, vp - sp, cp - vp).toDouble(&res);
|
||||||
|
#endif // QT_VERSION < 5
|
||||||
|
if (!res)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
c++;
|
||||||
|
vp = cp + 1;
|
||||||
|
} else if (cp->isSpace() || cp->isNull()) {
|
||||||
|
if (c < 1 || c > 2)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
#if QT_VERSION < QT_VERSION_CHECK(5, 0, 0)
|
||||||
|
val[c] = QString(vp, cp - vp).toDouble(&res);
|
||||||
|
#else // QT_VERSION < 5
|
||||||
|
val[c] = QStringRef(&data, vp - sp, cp - vp).toDouble(&res);
|
||||||
|
#endif // QT_VERSION < 5
|
||||||
|
if (!res)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
track.append(Trackpoint(Coordinates(val[0], val[1])));
|
||||||
|
if (!track.last().coordinates().isValid())
|
||||||
|
return false;
|
||||||
|
if (c == 2)
|
||||||
|
track.last().setElevation(val[2]);
|
||||||
|
|
||||||
|
while (cp->isSpace())
|
||||||
|
cp++;
|
||||||
|
c = 0;
|
||||||
|
vp = cp;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
QDateTime KMLParser::timeStamp()
|
||||||
|
{
|
||||||
|
QDateTime ts;
|
||||||
|
|
||||||
|
while (_reader.readNextStartElement()) {
|
||||||
|
if (_reader.name() == "when")
|
||||||
|
ts = time();
|
||||||
|
else
|
||||||
|
_reader.skipCurrentElement();
|
||||||
|
}
|
||||||
|
|
||||||
|
return ts;
|
||||||
|
}
|
||||||
|
|
||||||
|
void KMLParser::lineString(TrackData &track)
|
||||||
|
{
|
||||||
|
while (_reader.readNextStartElement()) {
|
||||||
|
if (_reader.name() == "coordinates") {
|
||||||
|
if (!lineCoordinates(track))
|
||||||
|
_reader.raiseError("Invalid coordinates");
|
||||||
|
} else
|
||||||
|
_reader.skipCurrentElement();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void KMLParser::point(Waypoint &waypoint)
|
||||||
|
{
|
||||||
|
while (_reader.readNextStartElement()) {
|
||||||
|
if (_reader.name() == "coordinates") {
|
||||||
|
if (!pointCoordinates(waypoint))
|
||||||
|
_reader.raiseError("Invalid coordinates");
|
||||||
|
} else
|
||||||
|
_reader.skipCurrentElement();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (waypoint.coordinates().isNull())
|
||||||
|
_reader.raiseError("Missing Point coordinates");
|
||||||
|
}
|
||||||
|
|
||||||
|
void KMLParser::track(TrackData &track)
|
||||||
|
{
|
||||||
|
const char mismatchError[] = "gx:coord/when element count mismatch";
|
||||||
|
int i = track.size();
|
||||||
|
|
||||||
|
while (_reader.readNextStartElement()) {
|
||||||
|
if (_reader.name() == "when") {
|
||||||
|
track.append(Trackpoint());
|
||||||
|
track.last().setTimestamp(time());
|
||||||
|
} else if (_reader.name() == "coord") {
|
||||||
|
if (i == track.size()) {
|
||||||
|
_reader.raiseError(mismatchError);
|
||||||
|
return;
|
||||||
|
} else if (!coord(track[i])) {
|
||||||
|
_reader.raiseError("Invalid coordinates");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
i++;
|
||||||
|
} else
|
||||||
|
_reader.skipCurrentElement();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (i != track.size())
|
||||||
|
_reader.raiseError(mismatchError);
|
||||||
|
}
|
||||||
|
|
||||||
|
void KMLParser::multiGeometry(const QString &name, const QString &desc,
|
||||||
|
const QDateTime timestamp)
|
||||||
|
{
|
||||||
|
while (_reader.readNextStartElement()) {
|
||||||
|
if (_reader.name() == "Point") {
|
||||||
|
_waypoints.append(Waypoint());
|
||||||
|
Waypoint &w = _waypoints.last();
|
||||||
|
w.setName(name);
|
||||||
|
w.setDescription(desc);
|
||||||
|
w.setTimestamp(timestamp);
|
||||||
|
point(w);
|
||||||
|
} else if (_reader.name() == "LineString") {
|
||||||
|
_tracks.append(TrackData());
|
||||||
|
TrackData &t = _tracks.last();
|
||||||
|
t.setName(name);
|
||||||
|
t.setDescription(desc);
|
||||||
|
lineString(t);
|
||||||
|
} else
|
||||||
|
_reader.skipCurrentElement();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void KMLParser::placemark()
|
||||||
|
{
|
||||||
|
QString name, desc;
|
||||||
|
QDateTime timestamp;
|
||||||
|
|
||||||
|
while (_reader.readNextStartElement()) {
|
||||||
|
if (_reader.name() == "name")
|
||||||
|
name = _reader.readElementText();
|
||||||
|
else if (_reader.name() == "description")
|
||||||
|
desc = _reader.readElementText();
|
||||||
|
else if (_reader.name() == "TimeStamp")
|
||||||
|
timestamp = timeStamp();
|
||||||
|
else if (_reader.name() == "MultiGeometry")
|
||||||
|
multiGeometry(name, desc, timestamp);
|
||||||
|
else if (_reader.name() == "Point") {
|
||||||
|
_waypoints.append(Waypoint());
|
||||||
|
Waypoint &w = _waypoints.last();
|
||||||
|
w.setName(name);
|
||||||
|
w.setDescription(desc);
|
||||||
|
w.setTimestamp(timestamp);
|
||||||
|
point(w);
|
||||||
|
} else if (_reader.name() == "LineString") {
|
||||||
|
_tracks.append(TrackData());
|
||||||
|
TrackData &t = _tracks.last();
|
||||||
|
t.setName(name);
|
||||||
|
t.setDescription(desc);
|
||||||
|
lineString(t);
|
||||||
|
} else if (_reader.name() == "Track") {
|
||||||
|
_tracks.append(TrackData());
|
||||||
|
TrackData &t = _tracks.last();
|
||||||
|
t.setName(name);
|
||||||
|
t.setDescription(desc);
|
||||||
|
track(t);
|
||||||
|
} else
|
||||||
|
_reader.skipCurrentElement();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void KMLParser::folder()
|
||||||
|
{
|
||||||
|
while (_reader.readNextStartElement()) {
|
||||||
|
if (_reader.name() == "Placemark")
|
||||||
|
placemark();
|
||||||
|
else if (_reader.name() == "Folder")
|
||||||
|
folder();
|
||||||
|
else
|
||||||
|
_reader.skipCurrentElement();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void KMLParser::document()
|
||||||
|
{
|
||||||
|
while (_reader.readNextStartElement()) {
|
||||||
|
if (_reader.name() == "Placemark")
|
||||||
|
placemark();
|
||||||
|
else if (_reader.name() == "Folder")
|
||||||
|
folder();
|
||||||
|
else
|
||||||
|
_reader.skipCurrentElement();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void KMLParser::kml()
|
||||||
|
{
|
||||||
|
while (_reader.readNextStartElement()) {
|
||||||
|
if (_reader.name() == "Document")
|
||||||
|
document();
|
||||||
|
else if (_reader.name() == "Placemark")
|
||||||
|
placemark();
|
||||||
|
else
|
||||||
|
_reader.skipCurrentElement();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
bool KMLParser::parse()
|
||||||
|
{
|
||||||
|
if (_reader.readNextStartElement()) {
|
||||||
|
if (_reader.name() == "kml")
|
||||||
|
kml();
|
||||||
|
else
|
||||||
|
_reader.raiseError("Not a KML file");
|
||||||
|
}
|
||||||
|
|
||||||
|
return !_reader.error();
|
||||||
|
}
|
||||||
|
|
||||||
|
bool KMLParser::loadFile(QFile *file)
|
||||||
|
{
|
||||||
|
_reader.clear();
|
||||||
|
_reader.setDevice(file);
|
||||||
|
|
||||||
|
return parse();
|
||||||
|
}
|
40
src/kmlparser.h
Normal file
@ -0,0 +1,40 @@
|
|||||||
|
#ifndef KMLPARSER_H
|
||||||
|
#define KMLPARSER_H
|
||||||
|
|
||||||
|
#include <QXmlStreamReader>
|
||||||
|
#include <QDateTime>
|
||||||
|
#include "parser.h"
|
||||||
|
|
||||||
|
class KMLParser : public Parser
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
KMLParser(QList<TrackData> &tracks, QList<RouteData> &routes,
|
||||||
|
QList<Waypoint> &waypoints) : Parser(tracks, routes, waypoints) {}
|
||||||
|
~KMLParser() {}
|
||||||
|
|
||||||
|
bool loadFile(QFile *file);
|
||||||
|
QString errorString() const {return _reader.errorString();}
|
||||||
|
int errorLine() const {return _reader.lineNumber();}
|
||||||
|
|
||||||
|
private:
|
||||||
|
bool parse();
|
||||||
|
void kml();
|
||||||
|
void document();
|
||||||
|
void folder();
|
||||||
|
void placemark();
|
||||||
|
void multiGeometry(const QString &name, const QString &desc,
|
||||||
|
const QDateTime timestamp);
|
||||||
|
void track(TrackData &track);
|
||||||
|
void lineString(TrackData &track);
|
||||||
|
void point(Waypoint &waypoint);
|
||||||
|
bool pointCoordinates(Waypoint &waypoint);
|
||||||
|
bool lineCoordinates(TrackData &track);
|
||||||
|
bool coord(Trackpoint &trackpoint);
|
||||||
|
QDateTime timeStamp();
|
||||||
|
qreal number();
|
||||||
|
QDateTime time();
|
||||||
|
|
||||||
|
QXmlStreamReader _reader;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // KMLPARSER_H
|
86
src/ll.cpp
@ -1,86 +0,0 @@
|
|||||||
#include <cmath>
|
|
||||||
#include "ll.h"
|
|
||||||
|
|
||||||
// MSVC workarounds
|
|
||||||
#ifndef M_PI
|
|
||||||
#define M_PI 3.14159265358979323846
|
|
||||||
#endif // M_PI
|
|
||||||
#if defined(_MSC_VER) && (_MSC_VER < 1800)
|
|
||||||
#define log2(n) (log(n)/log(2.0))
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
#define WGS84_RADIUS 6378137.0
|
|
||||||
#define deg2rad(d) (((d)*M_PI)/180.0)
|
|
||||||
#define rad2deg(d) (((d)*180.0)/M_PI)
|
|
||||||
|
|
||||||
qreal llDistance(const QPointF &p1, const QPointF &p2)
|
|
||||||
{
|
|
||||||
qreal dLat = deg2rad(p2.y() - p1.y());
|
|
||||||
qreal dLon = deg2rad(p2.x() - p1.x());
|
|
||||||
qreal a = pow(sin(dLat / 2.0), 2.0)
|
|
||||||
+ cos(deg2rad(p1.y())) * cos(deg2rad(p2.y())) * pow(sin(dLon / 2.0), 2.0);
|
|
||||||
qreal c = 2.0 * atan2(sqrt(a), sqrt(1.0 - a));
|
|
||||||
|
|
||||||
return (WGS84_RADIUS * c);
|
|
||||||
}
|
|
||||||
|
|
||||||
QPointF ll2mercator(const QPointF &ll)
|
|
||||||
{
|
|
||||||
QPointF m;
|
|
||||||
|
|
||||||
m.setX(ll.x());
|
|
||||||
m.setY(rad2deg(log(tan(M_PI/4.0 + deg2rad(ll.y())/2.0))));
|
|
||||||
|
|
||||||
return m;
|
|
||||||
}
|
|
||||||
|
|
||||||
QPointF mercator2ll(const QPointF &m)
|
|
||||||
{
|
|
||||||
QPointF ll;
|
|
||||||
|
|
||||||
ll.setX(m.x());
|
|
||||||
ll.setY(rad2deg(2 * atan(exp(deg2rad(m.y()))) - M_PI/2));
|
|
||||||
|
|
||||||
return ll;
|
|
||||||
}
|
|
||||||
|
|
||||||
QPoint mercator2tile(const QPointF &m, int z)
|
|
||||||
{
|
|
||||||
QPoint tile;
|
|
||||||
|
|
||||||
tile.setX((int)(floor((m.x() + 180.0) / 360.0 * pow(2.0, z))));
|
|
||||||
tile.setY((int)(floor((1.0 - (m.y() / 180.0)) / 2.0 * pow(2.0, z))));
|
|
||||||
|
|
||||||
return tile;
|
|
||||||
}
|
|
||||||
|
|
||||||
QPointF tile2mercator(const QPoint &tile, int z)
|
|
||||||
{
|
|
||||||
QPointF m;
|
|
||||||
|
|
||||||
m.setX(tile.x() / pow(2.0, z) * 360.0 - 180);
|
|
||||||
qreal n = M_PI - 2.0 * M_PI * tile.y() / pow(2.0, z);
|
|
||||||
m.setY(rad2deg(atan(0.5 * (exp(n) - exp(-n)))));
|
|
||||||
|
|
||||||
return ll2mercator(m);
|
|
||||||
}
|
|
||||||
|
|
||||||
int scale2zoom(qreal scale)
|
|
||||||
{
|
|
||||||
int zoom;
|
|
||||||
|
|
||||||
zoom = (int)log2(360.0/(scale * (qreal)TILE_SIZE));
|
|
||||||
|
|
||||||
if (zoom < ZOOM_MIN)
|
|
||||||
return ZOOM_MIN;
|
|
||||||
if (zoom > ZOOM_MAX)
|
|
||||||
return ZOOM_MAX;
|
|
||||||
return zoom;
|
|
||||||
}
|
|
||||||
|
|
||||||
qreal zoom2resolution(int zoom, qreal y)
|
|
||||||
{
|
|
||||||
return (WGS84_RADIUS * 2 * M_PI / 256 * cos(2 * atan(exp(deg2rad(y)))
|
|
||||||
- M_PI/2)) / pow(2.0, zoom);
|
|
||||||
}
|
|
18
src/ll.h
@ -1,18 +0,0 @@
|
|||||||
#ifndef LL_H
|
|
||||||
#define LL_H
|
|
||||||
|
|
||||||
#include <QPointF>
|
|
||||||
|
|
||||||
#define TILE_SIZE 256
|
|
||||||
#define ZOOM_MAX 18
|
|
||||||
#define ZOOM_MIN 3
|
|
||||||
|
|
||||||
QPointF ll2mercator(const QPointF &ll);
|
|
||||||
QPointF mercator2ll(const QPointF &m);
|
|
||||||
qreal llDistance(const QPointF &p1, const QPointF &p2);
|
|
||||||
QPoint mercator2tile(const QPointF &m, int zoom);
|
|
||||||
QPointF tile2mercator(const QPoint &tile, int zoom);
|
|
||||||
int scale2zoom(qreal scale);
|
|
||||||
qreal zoom2resolution(int zoom, qreal y);
|
|
||||||
|
|
||||||
#endif // LL_H
|
|
@ -1,7 +1,6 @@
|
|||||||
#include <QFileInfo>
|
#include <QFileInfo>
|
||||||
#include <QDir>
|
#include <QDir>
|
||||||
#include "downloader.h"
|
#include "downloader.h"
|
||||||
#include "ll.h"
|
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
#include "map.h"
|
#include "map.h"
|
||||||
|
|
||||||
@ -91,7 +90,7 @@ void Map::loadTilesSync(QList<Tile> &list)
|
|||||||
|
|
||||||
void Map::fillTile(Tile &tile)
|
void Map::fillTile(Tile &tile)
|
||||||
{
|
{
|
||||||
tile.pixmap() = QPixmap(TILE_SIZE, TILE_SIZE);
|
tile.pixmap() = QPixmap(Tile::size(), Tile::size());
|
||||||
tile.pixmap().fill();
|
tile.pixmap().fill();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
19
src/map.h
@ -1,24 +1,7 @@
|
|||||||
#ifndef MAP_H
|
#ifndef MAP_H
|
||||||
#define MAP_H
|
#define MAP_H
|
||||||
|
|
||||||
#include <QPixmap>
|
#include "tile.h"
|
||||||
|
|
||||||
class Tile
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
Tile(const QPoint &xy, int zoom)
|
|
||||||
{_xy = xy; _zoom = zoom;}
|
|
||||||
|
|
||||||
int zoom() const {return _zoom;}
|
|
||||||
const QPoint& xy() const {return _xy;}
|
|
||||||
QPixmap& pixmap() {return _pixmap;}
|
|
||||||
|
|
||||||
private:
|
|
||||||
int _zoom;
|
|
||||||
QPoint _xy;
|
|
||||||
QPixmap _pixmap;
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
class Map : public QObject
|
class Map : public QObject
|
||||||
{
|
{
|
||||||
|
@ -2,7 +2,8 @@
|
|||||||
#include "markeritem.h"
|
#include "markeritem.h"
|
||||||
|
|
||||||
|
|
||||||
#define SIZE 8
|
#define SIZE 8
|
||||||
|
#define WIDTH 2
|
||||||
|
|
||||||
MarkerItem::MarkerItem(QGraphicsItem *parent) : QGraphicsItem(parent)
|
MarkerItem::MarkerItem(QGraphicsItem *parent) : QGraphicsItem(parent)
|
||||||
{
|
{
|
||||||
@ -19,18 +20,11 @@ void MarkerItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *option
|
|||||||
{
|
{
|
||||||
Q_UNUSED(option);
|
Q_UNUSED(option);
|
||||||
Q_UNUSED(widget);
|
Q_UNUSED(widget);
|
||||||
bool aa;
|
|
||||||
|
|
||||||
|
painter->setRenderHint(QPainter::Antialiasing, false);
|
||||||
if ((aa = painter->testRenderHint(QPainter::Antialiasing)))
|
painter->setPen(QPen(Qt::red, WIDTH));
|
||||||
painter->setRenderHint(QPainter::Antialiasing, false);
|
|
||||||
|
|
||||||
painter->setPen(Qt::red);
|
|
||||||
painter->drawLine(-SIZE/2, 0, SIZE/2, 0);
|
painter->drawLine(-SIZE/2, 0, SIZE/2, 0);
|
||||||
painter->drawLine(0, -SIZE/2, 0, SIZE/2);
|
painter->drawLine(0, -SIZE/2, 0, SIZE/2);
|
||||||
|
|
||||||
if (aa)
|
|
||||||
painter->setRenderHint(QPainter::Antialiasing, true);
|
|
||||||
|
|
||||||
// painter->drawRect(boundingRect());
|
// painter->drawRect(boundingRect());
|
||||||
}
|
}
|
||||||
|
52
src/misc.cpp
@ -1,5 +1,5 @@
|
|||||||
#include <cmath>
|
#include <cmath>
|
||||||
#include <QApplication>
|
#include <cctype>
|
||||||
#include "misc.h"
|
#include "misc.h"
|
||||||
|
|
||||||
|
|
||||||
@ -35,52 +35,16 @@ double niceNum(double x, int round)
|
|||||||
return nf * pow(10.0, expv);
|
return nf * pow(10.0, expv);
|
||||||
}
|
}
|
||||||
|
|
||||||
QString timeSpan(qreal time)
|
int str2int(const char *str, int len)
|
||||||
{
|
{
|
||||||
unsigned h, m, s;
|
int res = 0;
|
||||||
|
|
||||||
h = time / 3600;
|
for (const char *sp = str; sp < str + len; sp++) {
|
||||||
m = (time - (h * 3600)) / 60;
|
if (::isdigit(*sp))
|
||||||
s = time - (h * 3600) - (m * 60);
|
res = res * 10 + *sp - '0';
|
||||||
|
|
||||||
return QString("%1:%2:%3").arg(h).arg(m, 2, 10, QChar('0'))
|
|
||||||
.arg(s, 2, 10, QChar('0'));
|
|
||||||
}
|
|
||||||
|
|
||||||
QString distance(qreal value, Units units)
|
|
||||||
{
|
|
||||||
if (units == Imperial) {
|
|
||||||
if (value < MIINM)
|
|
||||||
return QString::number(value * M2FT, 'f', 0) + UNIT_SPACE
|
|
||||||
+ qApp->translate("Misc", "ft");
|
|
||||||
else
|
else
|
||||||
return QString::number(value * M2MI, 'f', 1) + UNIT_SPACE
|
return -1;
|
||||||
+ qApp->translate("Misc", "mi");
|
|
||||||
} else {
|
|
||||||
if (value < KMINM)
|
|
||||||
return QString::number(value, 'f', 0) + UNIT_SPACE
|
|
||||||
+ qApp->translate("Misc", "m");
|
|
||||||
else
|
|
||||||
return QString::number(value * M2KM, 'f', 1) + UNIT_SPACE
|
|
||||||
+ qApp->translate("Misc", "km");
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
QString elevation(qreal value, Units units)
|
return res;
|
||||||
{
|
|
||||||
if (units == Metric)
|
|
||||||
return QString::number(value, 'f', 0) + UNIT_SPACE
|
|
||||||
+ qApp->translate("Misc", "m");
|
|
||||||
else
|
|
||||||
return QString::number(value * M2FT, 'f', 0) + UNIT_SPACE
|
|
||||||
+ qApp->translate("Misc", "ft");
|
|
||||||
}
|
|
||||||
|
|
||||||
QString coordinates(const QPointF &value)
|
|
||||||
{
|
|
||||||
QChar yH = (value.y() < 0) ? 'S' : 'N';
|
|
||||||
QChar xH = (value.x() < 0) ? 'W' : 'E';
|
|
||||||
|
|
||||||
return QString::number(qAbs(value.y()), 'f', 5) + yH + "," + QChar(0x00A0)
|
|
||||||
+ QString::number(qAbs(value.x()), 'f', 5) + xH;
|
|
||||||
}
|
}
|
||||||
|
10
src/misc.h
@ -1,15 +1,7 @@
|
|||||||
#ifndef MISC_H
|
#ifndef MISC_H
|
||||||
#define MISC_H
|
#define MISC_H
|
||||||
|
|
||||||
#include <QString>
|
|
||||||
#include <QPoint>
|
|
||||||
#include "units.h"
|
|
||||||
|
|
||||||
double niceNum(double x, int round);
|
double niceNum(double x, int round);
|
||||||
|
int str2int(const char *str, int len);
|
||||||
QString timeSpan(qreal time);
|
|
||||||
QString distance(qreal value, Units units);
|
|
||||||
QString elevation(qreal value, Units units);
|
|
||||||
QString coordinates(const QPointF &value);
|
|
||||||
|
|
||||||
#endif // MISC_H
|
#endif // MISC_H
|
||||||
|
527
src/nmeaparser.cpp
Normal file
@ -0,0 +1,527 @@
|
|||||||
|
#include <cstring>
|
||||||
|
#include "misc.h"
|
||||||
|
#include "nmeaparser.h"
|
||||||
|
|
||||||
|
|
||||||
|
static bool validSentence(const char *line, int len)
|
||||||
|
{
|
||||||
|
const char *lp;
|
||||||
|
|
||||||
|
if (len < 12 || line[0] != '$')
|
||||||
|
return false;
|
||||||
|
|
||||||
|
for (lp = line + len - 1; lp > line + 3; lp--)
|
||||||
|
if (!::isspace(*lp))
|
||||||
|
break;
|
||||||
|
if (*(lp-2) != '*' || !::isalnum(*(lp-1)) || !::isalnum(*(lp)))
|
||||||
|
return false;
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
static bool readFloat(const char *data, int len, qreal &f)
|
||||||
|
{
|
||||||
|
bool ok;
|
||||||
|
|
||||||
|
f = QString(QByteArray::fromRawData(data, len)).toFloat(&ok);
|
||||||
|
|
||||||
|
return ok;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool NMEAParser::readAltitude(const char *data, int len, qreal &ele)
|
||||||
|
{
|
||||||
|
if (!len) {
|
||||||
|
ele = NAN;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!readFloat(data, len, ele)) {
|
||||||
|
_errorString = "Invalid altitude";
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool NMEAParser::readGeoidHeight(const char *data, int len, qreal &gh)
|
||||||
|
{
|
||||||
|
if (!len) {
|
||||||
|
gh = 0;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!readFloat(data, len, gh)) {
|
||||||
|
_errorString = "Invalid geoid height";
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool NMEAParser::readTime(const char *data, int len, QTime &time)
|
||||||
|
{
|
||||||
|
int h, m, s, ms = 0;
|
||||||
|
|
||||||
|
|
||||||
|
if (!len) {
|
||||||
|
time = QTime();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (len < 6)
|
||||||
|
goto error;
|
||||||
|
|
||||||
|
h = str2int(data, 2);
|
||||||
|
m = str2int(data + 2, 2);
|
||||||
|
s = str2int(data + 4, 2);
|
||||||
|
if (h < 0 || m < 0 || s < 0)
|
||||||
|
goto error;
|
||||||
|
|
||||||
|
if (len > 7 && data[6] == '.') {
|
||||||
|
if ((ms = str2int(data + 7, len - 7)) < 0)
|
||||||
|
goto error;
|
||||||
|
}
|
||||||
|
|
||||||
|
time = QTime(h, m, s, ms);
|
||||||
|
if (!time.isValid())
|
||||||
|
goto error;
|
||||||
|
|
||||||
|
return true;
|
||||||
|
|
||||||
|
error:
|
||||||
|
_errorString = "Invalid time";
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool NMEAParser::readDate(const char *data, int len, QDate &date)
|
||||||
|
{
|
||||||
|
int y, m, d;
|
||||||
|
|
||||||
|
|
||||||
|
if (!len) {
|
||||||
|
date = QDate();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (len < 6)
|
||||||
|
goto error;
|
||||||
|
|
||||||
|
d = str2int(data, 2);
|
||||||
|
m = str2int(data + 2, 2);
|
||||||
|
y = str2int(data + 4, len - 4);
|
||||||
|
if (d < 0 || m < 0 || y < 0)
|
||||||
|
goto error;
|
||||||
|
|
||||||
|
if (len - 4 == 2)
|
||||||
|
date = QDate(y + 2000 < QDate::currentDate().year()
|
||||||
|
? 2000 + y : 1900 + y, m, d);
|
||||||
|
else
|
||||||
|
date = QDate(y, m, d);
|
||||||
|
if (!date.isValid())
|
||||||
|
goto error;
|
||||||
|
|
||||||
|
return true;
|
||||||
|
|
||||||
|
error:
|
||||||
|
_errorString = "Invalid date";
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool NMEAParser::readLat(const char *data, int len, qreal &lat)
|
||||||
|
{
|
||||||
|
int d, mi;
|
||||||
|
qreal mf;
|
||||||
|
bool ok;
|
||||||
|
|
||||||
|
|
||||||
|
if (!len) {
|
||||||
|
lat = NAN;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (len < 7 || data[4] != '.')
|
||||||
|
goto error;
|
||||||
|
|
||||||
|
d = str2int(data, 2);
|
||||||
|
mi = str2int(data + 2, 2);
|
||||||
|
mf = QString(QByteArray::fromRawData(data + 4, len - 4)).toFloat(&ok);
|
||||||
|
if (d < 0 || mi < 0 || !ok)
|
||||||
|
goto error;
|
||||||
|
|
||||||
|
lat = d + (((qreal)mi + mf) / 60.0);
|
||||||
|
if (lat > 90)
|
||||||
|
goto error;
|
||||||
|
|
||||||
|
return true;
|
||||||
|
|
||||||
|
error:
|
||||||
|
_errorString = "Invalid ltitude";
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool NMEAParser::readNS(const char *data, int len, qreal &lat)
|
||||||
|
{
|
||||||
|
if (!len) {
|
||||||
|
lat = NAN;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (len != 1 || !(*data == 'N' || *data == 'S')) {
|
||||||
|
_errorString = "Invalid N/S value";
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (*data == 'S')
|
||||||
|
lat = -lat;
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool NMEAParser::readLon(const char *data, int len, qreal &lon)
|
||||||
|
{
|
||||||
|
int d, mi;
|
||||||
|
qreal mf;
|
||||||
|
bool ok;
|
||||||
|
|
||||||
|
|
||||||
|
if (!len) {
|
||||||
|
lon = NAN;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (len < 8 || data[5] != '.')
|
||||||
|
goto error;
|
||||||
|
|
||||||
|
d = str2int(data, 3);
|
||||||
|
mi = str2int(data + 3, 2);
|
||||||
|
mf = QString(QByteArray::fromRawData(data + 5, len - 5)).toFloat(&ok);
|
||||||
|
if (d < 0 || mi < 0 || !ok)
|
||||||
|
goto error;
|
||||||
|
|
||||||
|
lon = d + (((qreal)mi + mf) / 60.0);
|
||||||
|
if (lon > 180)
|
||||||
|
goto error;
|
||||||
|
|
||||||
|
return true;
|
||||||
|
|
||||||
|
error:
|
||||||
|
_errorString = "Invalid longitude";
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool NMEAParser::readEW(const char *data, int len, qreal &lon)
|
||||||
|
{
|
||||||
|
if (!len) {
|
||||||
|
lon = NAN;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (len != 1 || !(*data == 'E' || *data == 'W')) {
|
||||||
|
_errorString = "Invalid E/W value";
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (*data == 'W')
|
||||||
|
lon = -lon;
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool NMEAParser::readRMC(const char *line, int len)
|
||||||
|
{
|
||||||
|
int col = 1;
|
||||||
|
const char *vp = line;
|
||||||
|
qreal lat, lon;
|
||||||
|
QTime time;
|
||||||
|
QDate date;
|
||||||
|
bool valid = true;
|
||||||
|
|
||||||
|
for (const char *lp = line; lp < line + len; lp++) {
|
||||||
|
if (*lp == ',' || *lp == '*') {
|
||||||
|
switch (col) {
|
||||||
|
case 1:
|
||||||
|
if (!readTime(vp, lp - vp, time))
|
||||||
|
return false;
|
||||||
|
break;
|
||||||
|
case 2:
|
||||||
|
if (*vp != 'A')
|
||||||
|
valid = false;
|
||||||
|
break;
|
||||||
|
case 3:
|
||||||
|
if (!readLat(vp, lp - vp, lat))
|
||||||
|
return false;
|
||||||
|
break;
|
||||||
|
case 4:
|
||||||
|
if (!readNS(vp, lp - vp, lat))
|
||||||
|
return false;
|
||||||
|
break;
|
||||||
|
case 5:
|
||||||
|
if (!readLon(vp, lp - vp, lon))
|
||||||
|
return false;
|
||||||
|
break;
|
||||||
|
case 6:
|
||||||
|
if (!readEW(vp, lp - vp, lon))
|
||||||
|
return false;
|
||||||
|
break;
|
||||||
|
case 9:
|
||||||
|
if (!readDate(vp, lp - vp, date))
|
||||||
|
return false;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
col++;
|
||||||
|
vp = lp + 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (col < 9) {
|
||||||
|
_errorString = "Invalid RMC sentence";
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!date.isNull()) {
|
||||||
|
if (_date.isNull() && !_time.isNull() && !_tracks.last().isEmpty())
|
||||||
|
_tracks.last().last().setTimestamp(QDateTime(date, _time, Qt::UTC));
|
||||||
|
_date = date;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (valid && !_GGA && !std::isnan(lat) && !std::isnan(lon)) {
|
||||||
|
Trackpoint t(Coordinates(lon, lat));
|
||||||
|
if (!_date.isNull() && !time.isNull())
|
||||||
|
t.setTimestamp(QDateTime(_date, time, Qt::UTC));
|
||||||
|
_tracks.last().append(t);
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool NMEAParser::readGGA(const char *line, int len)
|
||||||
|
{
|
||||||
|
int col = 1;
|
||||||
|
const char *vp = line;
|
||||||
|
qreal lat, lon, ele, gh;
|
||||||
|
|
||||||
|
for (const char *lp = line; lp < line + len; lp++) {
|
||||||
|
if (*lp == ',' || *lp == '*') {
|
||||||
|
switch (col) {
|
||||||
|
case 1:
|
||||||
|
if (!readTime(vp, lp - vp, _time))
|
||||||
|
return false;
|
||||||
|
break;
|
||||||
|
case 2:
|
||||||
|
if (!readLat(vp, lp - vp, lat))
|
||||||
|
return false;
|
||||||
|
break;
|
||||||
|
case 3:
|
||||||
|
if (!readNS(vp, lp - vp, lat))
|
||||||
|
return false;
|
||||||
|
break;
|
||||||
|
case 4:
|
||||||
|
if (!readLon(vp, lp - vp, lon))
|
||||||
|
return false;
|
||||||
|
break;
|
||||||
|
case 5:
|
||||||
|
if (!readEW(vp, lp - vp, lon))
|
||||||
|
return false;
|
||||||
|
break;
|
||||||
|
case 9:
|
||||||
|
if (!readAltitude(vp, lp - vp, ele))
|
||||||
|
return false;
|
||||||
|
break;
|
||||||
|
case 10:
|
||||||
|
if ((lp - vp) && !((lp - vp) == 1 && *vp == 'M')) {
|
||||||
|
_errorString = "Invalid altitude units";
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case 11:
|
||||||
|
if (!readGeoidHeight(vp, lp - vp, gh))
|
||||||
|
return false;
|
||||||
|
break;
|
||||||
|
case 12:
|
||||||
|
if ((lp - vp) && !((lp - vp) == 1 && *vp == 'M')) {
|
||||||
|
_errorString = "Invalid geoid height units";
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
col++;
|
||||||
|
vp = lp + 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (col < 12) {
|
||||||
|
_errorString = "Invalid GGA sentence";
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!std::isnan(lat) && !std::isnan(lon)) {
|
||||||
|
Trackpoint t(Coordinates(lon, lat));
|
||||||
|
if (!(_time.isNull() || _date.isNull()))
|
||||||
|
t.setTimestamp(QDateTime(_date, _time, Qt::UTC));
|
||||||
|
if (!std::isnan(ele))
|
||||||
|
t.setElevation(ele - gh);
|
||||||
|
_tracks.last().append(t);
|
||||||
|
|
||||||
|
_GGA = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool NMEAParser::readWPL(const char *line, int len)
|
||||||
|
{
|
||||||
|
int col = 1;
|
||||||
|
const char *vp = line;
|
||||||
|
qreal lat, lon;
|
||||||
|
QString name;
|
||||||
|
|
||||||
|
for (const char *lp = line; lp < line + len; lp++) {
|
||||||
|
if (*lp == ',' || *lp == '*') {
|
||||||
|
switch (col) {
|
||||||
|
case 1:
|
||||||
|
if (!readLat(vp, lp - vp, lat))
|
||||||
|
return false;
|
||||||
|
break;
|
||||||
|
case 2:
|
||||||
|
if (!readNS(vp, lp - vp, lat))
|
||||||
|
return false;
|
||||||
|
break;
|
||||||
|
case 3:
|
||||||
|
if (!readLon(vp, lp - vp, lon))
|
||||||
|
return false;
|
||||||
|
break;
|
||||||
|
case 4:
|
||||||
|
if (!readEW(vp, lp - vp, lon))
|
||||||
|
return false;
|
||||||
|
break;
|
||||||
|
case 5:
|
||||||
|
name = QString(QByteArray(vp, lp - vp));
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
col++;
|
||||||
|
vp = lp + 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (col < 4) {
|
||||||
|
_errorString = "Invalid WPL sentence";
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!std::isnan(lat) && !std::isnan(lon)) {
|
||||||
|
Waypoint w(Coordinates(lon, lat));
|
||||||
|
w.setName(name);
|
||||||
|
_waypoints.append(w);
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool NMEAParser::readZDA(const char *line, int len)
|
||||||
|
{
|
||||||
|
int col = 1;
|
||||||
|
const char *vp = line;
|
||||||
|
int d, m, y;
|
||||||
|
|
||||||
|
for (const char *lp = line; lp < line + len; lp++) {
|
||||||
|
if (*lp == ',' || *lp == '*') {
|
||||||
|
switch (col) {
|
||||||
|
case 2:
|
||||||
|
if (!(lp - vp))
|
||||||
|
return true;
|
||||||
|
if ((d = str2int(vp, lp - vp)) < 0) {
|
||||||
|
_errorString = "Invalid day";
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case 3:
|
||||||
|
if (!(lp - vp))
|
||||||
|
return true;
|
||||||
|
if ((m = str2int(vp, lp - vp)) < 0) {
|
||||||
|
_errorString = "Invalid month";
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case 4:
|
||||||
|
if (!(lp - vp))
|
||||||
|
return true;
|
||||||
|
if ((y = str2int(vp, lp - vp)) < 0) {
|
||||||
|
_errorString = "Invalid year";
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
col++;
|
||||||
|
vp = lp + 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (col < 4) {
|
||||||
|
_errorString = "Invalid ZDA sentence";
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
_date = QDate(y, m, d);
|
||||||
|
if (!_date.isValid()) {
|
||||||
|
_errorString = "Invalid date";
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool NMEAParser::loadFile(QFile *file)
|
||||||
|
{
|
||||||
|
qint64 len;
|
||||||
|
char line[80 + 2 + 1 + 1];
|
||||||
|
|
||||||
|
|
||||||
|
_errorLine = 1;
|
||||||
|
_errorString.clear();
|
||||||
|
_date = QDate();
|
||||||
|
_time = QTime();
|
||||||
|
_GGA = false;
|
||||||
|
|
||||||
|
_tracks.append(TrackData());
|
||||||
|
|
||||||
|
while (!file->atEnd()) {
|
||||||
|
len = file->readLine(line, sizeof(line));
|
||||||
|
|
||||||
|
if (len < 0) {
|
||||||
|
_errorString = "I/O error";
|
||||||
|
return false;
|
||||||
|
} else if (len > (qint64)sizeof(line) - 1) {
|
||||||
|
_errorString = "Line limit exceeded";
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (validSentence(line, len)) {
|
||||||
|
if (!memcmp(line + 3, "RMC,", 4)) {
|
||||||
|
if (!readRMC(line + 7, len))
|
||||||
|
return false;
|
||||||
|
} else if (!memcmp(line + 3, "GGA,", 4)) {
|
||||||
|
if (!readGGA(line + 7, len))
|
||||||
|
return false;
|
||||||
|
} else if (!memcmp(line + 3, "WPL,", 4)) {
|
||||||
|
if (!readWPL(line + 7, len))
|
||||||
|
return false;
|
||||||
|
} else if (!memcmp(line + 3, "ZDA,", 4)) {
|
||||||
|
if (!readZDA(line + 7, len))
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
_errorLine++;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!_tracks.last().size() && !_waypoints.size()) {
|
||||||
|
_errorString = "No usable NMEA sentence found";
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
43
src/nmeaparser.h
Normal file
@ -0,0 +1,43 @@
|
|||||||
|
#ifndef NMEAPARSER_H
|
||||||
|
#define NMEAPARSER_H
|
||||||
|
|
||||||
|
#include <QDate>
|
||||||
|
#include "parser.h"
|
||||||
|
|
||||||
|
|
||||||
|
class NMEAParser : public Parser
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
NMEAParser(QList<TrackData> &tracks, QList<RouteData> &routes,
|
||||||
|
QList<Waypoint> &waypoints) : Parser(tracks, routes, waypoints)
|
||||||
|
{_errorLine = 0; _GGA = false;}
|
||||||
|
~NMEAParser() {}
|
||||||
|
|
||||||
|
bool loadFile(QFile *file);
|
||||||
|
QString errorString() const {return _errorString;}
|
||||||
|
int errorLine() const {return _errorLine;}
|
||||||
|
|
||||||
|
private:
|
||||||
|
bool readEW(const char *data, int len, qreal &lon);
|
||||||
|
bool readLon(const char *data, int len, qreal &lon);
|
||||||
|
bool readNS(const char *data, int len, qreal &lat);
|
||||||
|
bool readLat(const char *data, int len, qreal &lat);
|
||||||
|
bool readDate(const char *data, int len, QDate &date);
|
||||||
|
bool readTime(const char *data, int len, QTime &time);
|
||||||
|
bool readAltitude(const char *data, int len, qreal &ele);
|
||||||
|
bool readGeoidHeight(const char *data, int len, qreal &gh);
|
||||||
|
|
||||||
|
bool readRMC(const char *line, int len);
|
||||||
|
bool readGGA(const char *line, int len);
|
||||||
|
bool readWPL(const char *line, int len);
|
||||||
|
bool readZDA(const char *line, int len);
|
||||||
|
|
||||||
|
int _errorLine;
|
||||||
|
QString _errorString;
|
||||||
|
|
||||||
|
QDate _date;
|
||||||
|
QTime _time;
|
||||||
|
bool _GGA;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // NMEAPARSER_H
|
26
src/opengl.h
Normal file
@ -0,0 +1,26 @@
|
|||||||
|
#include <QtGlobal>
|
||||||
|
#if QT_VERSION < QT_VERSION_CHECK(5, 4, 0) || defined(Q_OS_MAC)
|
||||||
|
#include <QGLWidget>
|
||||||
|
#include <QGLFormat>
|
||||||
|
#else
|
||||||
|
#include <QOpenGLWidget>
|
||||||
|
#include <QSurfaceFormat>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if QT_VERSION < QT_VERSION_CHECK(5, 4, 0) || defined(Q_OS_MAC)
|
||||||
|
#define OPENGL_WIDGET QGLWidget
|
||||||
|
#else
|
||||||
|
#define OPENGL_WIDGET QOpenGLWidget
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if QT_VERSION < QT_VERSION_CHECK(5, 4, 0) || defined(Q_OS_MAC)
|
||||||
|
#define OPENGL_SET_SAMPLES(samples) \
|
||||||
|
{QGLFormat fmt; \
|
||||||
|
fmt.setSamples(samples); \
|
||||||
|
QGLFormat::setDefaultFormat(fmt);}
|
||||||
|
#else
|
||||||
|
#define OPENGL_SET_SAMPLES(samples) \
|
||||||
|
{QSurfaceFormat fmt; \
|
||||||
|
fmt.setSamples(samples);\
|
||||||
|
QSurfaceFormat::setDefaultFormat(fmt);}
|
||||||
|
#endif
|
284
src/optionsdialog.cpp
Normal file
@ -0,0 +1,284 @@
|
|||||||
|
#include <QVBoxLayout>
|
||||||
|
#include <QFormLayout>
|
||||||
|
#include <QDialogButtonBox>
|
||||||
|
#include <QListWidget>
|
||||||
|
#include <QListWidgetItem>
|
||||||
|
#include <QStackedWidget>
|
||||||
|
#include <QTabWidget>
|
||||||
|
#include <QSpinBox>
|
||||||
|
#include <QGroupBox>
|
||||||
|
#include <QCheckBox>
|
||||||
|
#include <QComboBox>
|
||||||
|
#include <QSysInfo>
|
||||||
|
#include "config.h"
|
||||||
|
#include "icons.h"
|
||||||
|
#include "colorbox.h"
|
||||||
|
#include "stylecombobox.h"
|
||||||
|
#include "optionsdialog.h"
|
||||||
|
|
||||||
|
#define MENU_MARGIN 20
|
||||||
|
#define MENU_ICON_SIZE 32
|
||||||
|
|
||||||
|
|
||||||
|
QWidget *OptionsDialog::createAppearancePage()
|
||||||
|
{
|
||||||
|
_baseColor = new ColorBox();
|
||||||
|
_baseColor->setColor(_options->palette.color());
|
||||||
|
_colorOffset = new QDoubleSpinBox();
|
||||||
|
_colorOffset->setMinimum(0);
|
||||||
|
_colorOffset->setMaximum(1.0);
|
||||||
|
_colorOffset->setSingleStep(0.01);
|
||||||
|
_colorOffset->setValue(_options->palette.shift());
|
||||||
|
|
||||||
|
QFormLayout *paletteLayout = new QFormLayout();
|
||||||
|
paletteLayout->addRow(tr("Base color:"), _baseColor);
|
||||||
|
paletteLayout->addRow(tr("Palette shift:"), _colorOffset);
|
||||||
|
|
||||||
|
QWidget *colorTab = new QWidget();
|
||||||
|
colorTab->setLayout(paletteLayout);
|
||||||
|
|
||||||
|
|
||||||
|
_trackWidth = new QSpinBox();
|
||||||
|
_trackWidth->setValue(_options->trackWidth);
|
||||||
|
_trackWidth->setMinimum(1);
|
||||||
|
_trackStyle = new StyleComboBox();
|
||||||
|
_trackStyle->setValue(_options->trackStyle);
|
||||||
|
QFormLayout *trackLayout = new QFormLayout();
|
||||||
|
trackLayout->addRow(tr("Track width:"), _trackWidth);
|
||||||
|
trackLayout->addRow(tr("Track style:"), _trackStyle);
|
||||||
|
#ifndef Q_OS_MAC
|
||||||
|
QGroupBox *trackBox = new QGroupBox(tr("Tracks"));
|
||||||
|
trackBox->setLayout(trackLayout);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
_routeWidth = new QSpinBox();
|
||||||
|
_routeWidth->setValue(_options->routeWidth);
|
||||||
|
_routeWidth->setMinimum(1);
|
||||||
|
_routeStyle = new StyleComboBox();
|
||||||
|
_routeStyle->setValue(_options->routeStyle);
|
||||||
|
QFormLayout *routeLayout = new QFormLayout();
|
||||||
|
routeLayout->addRow(tr("Route width:"), _routeWidth);
|
||||||
|
routeLayout->addRow(tr("Route style:"), _routeStyle);
|
||||||
|
#ifndef Q_OS_MAC
|
||||||
|
QGroupBox *routeBox = new QGroupBox(tr("Routes"));
|
||||||
|
routeBox->setLayout(routeLayout);
|
||||||
|
#endif // Q_OS_MAC
|
||||||
|
|
||||||
|
_pathAA = new QCheckBox(tr("Use anti-aliasing"));
|
||||||
|
_pathAA->setChecked(_options->pathAntiAliasing);
|
||||||
|
QFormLayout *pathAALayout = new QFormLayout();
|
||||||
|
pathAALayout->addWidget(_pathAA);
|
||||||
|
|
||||||
|
QWidget *pathTab = new QWidget();
|
||||||
|
QVBoxLayout *pathTabLayout = new QVBoxLayout();
|
||||||
|
#ifdef Q_OS_MAC
|
||||||
|
QFrame *l1 = new QFrame();
|
||||||
|
l1->setFrameShape(QFrame::HLine);
|
||||||
|
l1->setFrameShadow(QFrame::Sunken);
|
||||||
|
QFrame *l2 = new QFrame();
|
||||||
|
l2->setFrameShape(QFrame::HLine);
|
||||||
|
l2->setFrameShadow(QFrame::Sunken);
|
||||||
|
|
||||||
|
pathTabLayout->addLayout(trackLayout);
|
||||||
|
pathTabLayout->addWidget(l1);
|
||||||
|
pathTabLayout->addLayout(routeLayout);
|
||||||
|
pathTabLayout->addWidget(l2);
|
||||||
|
#else
|
||||||
|
pathTabLayout->addWidget(trackBox);
|
||||||
|
pathTabLayout->addWidget(routeBox);
|
||||||
|
#endif
|
||||||
|
pathTabLayout->addLayout(pathAALayout);
|
||||||
|
pathTab->setLayout(pathTabLayout);
|
||||||
|
|
||||||
|
_graphWidth = new QSpinBox();
|
||||||
|
_graphWidth->setValue(_options->graphWidth);
|
||||||
|
_graphWidth->setMinimum(1);
|
||||||
|
QFormLayout *graphLayout = new QFormLayout();
|
||||||
|
graphLayout->addRow(tr("Line width:"), _graphWidth);
|
||||||
|
|
||||||
|
_graphAA = new QCheckBox(tr("Use anti-aliasing"));
|
||||||
|
_graphAA->setChecked(_options->graphAntiAliasing);
|
||||||
|
QFormLayout *graphAALayout = new QFormLayout();
|
||||||
|
graphAALayout->addWidget(_graphAA);
|
||||||
|
|
||||||
|
|
||||||
|
QWidget *graphTab = new QWidget();
|
||||||
|
QVBoxLayout *graphTabLayout = new QVBoxLayout();
|
||||||
|
graphTabLayout->addLayout(graphLayout);
|
||||||
|
graphTabLayout->addLayout(graphAALayout);
|
||||||
|
graphTabLayout->addStretch();
|
||||||
|
graphTab->setLayout(graphTabLayout);
|
||||||
|
|
||||||
|
QTabWidget *appearancePage = new QTabWidget();
|
||||||
|
appearancePage->addTab(colorTab, tr("Colors"));
|
||||||
|
appearancePage->addTab(pathTab, tr("Paths"));
|
||||||
|
appearancePage->addTab(graphTab, tr("Graphs"));
|
||||||
|
|
||||||
|
return appearancePage;
|
||||||
|
}
|
||||||
|
|
||||||
|
QWidget *OptionsDialog::createPOIPage()
|
||||||
|
{
|
||||||
|
_poiRadius = new QDoubleSpinBox();
|
||||||
|
_poiRadius->setSingleStep(1);
|
||||||
|
_poiRadius->setDecimals(1);
|
||||||
|
if (_options->units == Imperial) {
|
||||||
|
_poiRadius->setValue(_options->poiRadius / MIINM);
|
||||||
|
_poiRadius->setSuffix(UNIT_SPACE + tr("mi"));
|
||||||
|
} else {
|
||||||
|
_poiRadius->setValue(_options->poiRadius / KMINM);
|
||||||
|
_poiRadius->setSuffix(UNIT_SPACE + tr("km"));
|
||||||
|
}
|
||||||
|
|
||||||
|
QFormLayout *poiLayout = new QFormLayout();
|
||||||
|
poiLayout->addRow(tr("POI radius:"), _poiRadius);
|
||||||
|
|
||||||
|
QWidget *poiTab = new QWidget();
|
||||||
|
poiTab->setLayout(poiLayout);
|
||||||
|
|
||||||
|
QTabWidget *poiPage = new QTabWidget();
|
||||||
|
poiPage->addTab(poiTab, tr("POI"));
|
||||||
|
|
||||||
|
return poiPage;
|
||||||
|
}
|
||||||
|
|
||||||
|
QWidget *OptionsDialog::createExportPage()
|
||||||
|
{
|
||||||
|
_name = new QCheckBox(tr("Name"));
|
||||||
|
_name->setChecked(_options->printName);
|
||||||
|
_date = new QCheckBox(tr("Date"));
|
||||||
|
_date->setChecked(_options->printDate);
|
||||||
|
_distance = new QCheckBox(tr("Distance"));
|
||||||
|
_distance->setChecked(_options->printDistance);
|
||||||
|
_time = new QCheckBox(tr("Time"));
|
||||||
|
_time->setChecked(_options->printTime);
|
||||||
|
_itemCount = new QCheckBox(tr("Item count (>1)"));
|
||||||
|
_itemCount->setChecked(_options->printItemCount);
|
||||||
|
|
||||||
|
QFormLayout *headerTabLayout = new QFormLayout();
|
||||||
|
headerTabLayout->addWidget(_name);
|
||||||
|
headerTabLayout->addWidget(_date);
|
||||||
|
headerTabLayout->addWidget(_distance);
|
||||||
|
headerTabLayout->addWidget(_time);
|
||||||
|
headerTabLayout->addItem(new QSpacerItem(10, 10));
|
||||||
|
headerTabLayout->addWidget(_itemCount);
|
||||||
|
QWidget *headerTab = new QWidget();
|
||||||
|
headerTab->setLayout(headerTabLayout);
|
||||||
|
|
||||||
|
|
||||||
|
_separateGraphPage = new QCheckBox(tr("Separate graph page"));
|
||||||
|
_separateGraphPage->setChecked(_options->separateGraphPage);
|
||||||
|
|
||||||
|
QFormLayout *graphTabLayout = new QFormLayout();
|
||||||
|
graphTabLayout->addWidget(_separateGraphPage);
|
||||||
|
QWidget *graphTab = new QWidget();
|
||||||
|
graphTab->setLayout(graphTabLayout);
|
||||||
|
|
||||||
|
|
||||||
|
QTabWidget *exportPage = new QTabWidget();
|
||||||
|
exportPage->addTab(headerTab, tr("Header"));
|
||||||
|
exportPage->addTab(graphTab, tr("Graphs"));
|
||||||
|
|
||||||
|
return exportPage;
|
||||||
|
}
|
||||||
|
|
||||||
|
QWidget *OptionsDialog::createSystemPage()
|
||||||
|
{
|
||||||
|
_useOpenGL = new QCheckBox(tr("Use OpenGL"));
|
||||||
|
#ifdef Q_OS_WIN32
|
||||||
|
if (QSysInfo::WindowsVersion < QSysInfo::WV_VISTA) {
|
||||||
|
_useOpenGL->setChecked(false);
|
||||||
|
_useOpenGL->setEnabled(false);
|
||||||
|
} else
|
||||||
|
#endif // Q_OS_WIN32
|
||||||
|
_useOpenGL->setChecked(_options->useOpenGL);
|
||||||
|
|
||||||
|
QFormLayout *systemLayout = new QFormLayout();
|
||||||
|
systemLayout->addWidget(_useOpenGL);
|
||||||
|
|
||||||
|
QWidget *systemTab = new QWidget();
|
||||||
|
systemTab->setLayout(systemLayout);
|
||||||
|
|
||||||
|
QTabWidget *systemPage = new QTabWidget();
|
||||||
|
systemPage->addTab(systemTab, tr("System"));
|
||||||
|
|
||||||
|
return systemPage;
|
||||||
|
}
|
||||||
|
|
||||||
|
OptionsDialog::OptionsDialog(Options *options, QWidget *parent)
|
||||||
|
: QDialog(parent), _options(options)
|
||||||
|
{
|
||||||
|
QStackedWidget *pages = new QStackedWidget();
|
||||||
|
pages->addWidget(createAppearancePage());
|
||||||
|
pages->addWidget(createPOIPage());
|
||||||
|
pages->addWidget(createExportPage());
|
||||||
|
pages->addWidget(createSystemPage());
|
||||||
|
|
||||||
|
QListWidget *menu = new QListWidget();
|
||||||
|
menu->setIconSize(QSize(MENU_ICON_SIZE, MENU_ICON_SIZE));
|
||||||
|
new QListWidgetItem(QIcon(QPixmap(APPEARANCE_ICON)), tr("Appearance"),
|
||||||
|
menu);
|
||||||
|
new QListWidgetItem(QIcon(QPixmap(POI_ICON)), tr("POI"), menu);
|
||||||
|
new QListWidgetItem(QIcon(QPixmap(PRINT_EXPORT_ICON)), tr("Print & Export"),
|
||||||
|
menu);
|
||||||
|
new QListWidgetItem(QIcon(QPixmap(SYSTEM_ICON)), tr("System"), menu);
|
||||||
|
|
||||||
|
QHBoxLayout *contentLayout = new QHBoxLayout();
|
||||||
|
contentLayout->addWidget(menu);
|
||||||
|
contentLayout->addWidget(pages);
|
||||||
|
|
||||||
|
menu->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Preferred);
|
||||||
|
menu->setMaximumWidth(menu->sizeHintForColumn(0) + 2 * menu->frameWidth()
|
||||||
|
+ MENU_MARGIN);
|
||||||
|
pages->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::Preferred);
|
||||||
|
pages->setMinimumWidth(2 * menu->size().width());
|
||||||
|
|
||||||
|
connect(menu, SIGNAL(currentRowChanged(int)), pages,
|
||||||
|
SLOT(setCurrentIndex(int)));
|
||||||
|
menu->item(0)->setSelected(true);
|
||||||
|
|
||||||
|
|
||||||
|
QDialogButtonBox *buttonBox = new QDialogButtonBox(QDialogButtonBox::Ok
|
||||||
|
| QDialogButtonBox::Cancel);
|
||||||
|
connect(buttonBox, SIGNAL(accepted()), this, SLOT(accept()));
|
||||||
|
connect(buttonBox, SIGNAL(rejected()), this, SLOT(reject()));
|
||||||
|
|
||||||
|
QVBoxLayout *layout = new QVBoxLayout;
|
||||||
|
layout->addLayout(contentLayout);
|
||||||
|
layout->addWidget(buttonBox);
|
||||||
|
setLayout(layout);
|
||||||
|
|
||||||
|
setWindowTitle(tr("Options"));
|
||||||
|
setWindowFlags(windowFlags() & ~Qt::WindowContextHelpButtonHint);
|
||||||
|
}
|
||||||
|
|
||||||
|
void OptionsDialog::accept()
|
||||||
|
{
|
||||||
|
_options->palette.setColor(_baseColor->color());
|
||||||
|
_options->palette.setShift(_colorOffset->value());
|
||||||
|
_options->trackWidth = _trackWidth->value();
|
||||||
|
_options->trackStyle = (Qt::PenStyle) _trackStyle->itemData(
|
||||||
|
_trackStyle->currentIndex()).toInt();
|
||||||
|
_options->routeWidth = _routeWidth->value();
|
||||||
|
_options->routeStyle = (Qt::PenStyle) _routeStyle->itemData(
|
||||||
|
_routeStyle->currentIndex()).toInt();
|
||||||
|
_options->pathAntiAliasing = _pathAA->isChecked();
|
||||||
|
_options->graphWidth = _graphWidth->value();
|
||||||
|
_options->graphAntiAliasing = _graphAA->isChecked();
|
||||||
|
|
||||||
|
if (_options->units == Imperial)
|
||||||
|
_options->poiRadius = _poiRadius->value() * MIINM;
|
||||||
|
else
|
||||||
|
_options->poiRadius = _poiRadius->value() * KMINM;
|
||||||
|
|
||||||
|
_options->useOpenGL = _useOpenGL->isChecked();
|
||||||
|
|
||||||
|
_options->printName = _name->isChecked();
|
||||||
|
_options->printDate = _date->isChecked();
|
||||||
|
_options->printDistance = _distance->isChecked();
|
||||||
|
_options->printTime = _time->isChecked();
|
||||||
|
_options->printItemCount = _itemCount->isChecked();
|
||||||
|
_options->separateGraphPage = _separateGraphPage->isChecked();
|
||||||
|
|
||||||
|
QDialog::accept();
|
||||||
|
}
|
77
src/optionsdialog.h
Normal file
@ -0,0 +1,77 @@
|
|||||||
|
#ifndef OPTIONSDIALOG_H
|
||||||
|
#define OPTIONSDIALOG_H
|
||||||
|
|
||||||
|
#include <QDialog>
|
||||||
|
#include "palette.h"
|
||||||
|
#include "units.h"
|
||||||
|
|
||||||
|
class ColorBox;
|
||||||
|
class StyleComboBox;
|
||||||
|
class QSpinBox;
|
||||||
|
class QDoubleSpinBox;
|
||||||
|
class QComboBox;
|
||||||
|
class QCheckBox;
|
||||||
|
|
||||||
|
struct Options {
|
||||||
|
// Appearance
|
||||||
|
Palette palette;
|
||||||
|
int trackWidth;
|
||||||
|
int routeWidth;
|
||||||
|
Qt::PenStyle trackStyle;
|
||||||
|
Qt::PenStyle routeStyle;
|
||||||
|
int graphWidth;
|
||||||
|
bool pathAntiAliasing;
|
||||||
|
bool graphAntiAliasing;
|
||||||
|
// POI
|
||||||
|
int poiRadius;
|
||||||
|
// System
|
||||||
|
bool useOpenGL;
|
||||||
|
// Print/Export
|
||||||
|
bool printName;
|
||||||
|
bool printDate;
|
||||||
|
bool printDistance;
|
||||||
|
bool printTime;
|
||||||
|
bool printItemCount;
|
||||||
|
bool separateGraphPage;
|
||||||
|
|
||||||
|
Units units;
|
||||||
|
};
|
||||||
|
|
||||||
|
class OptionsDialog : public QDialog
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
|
||||||
|
public:
|
||||||
|
OptionsDialog(Options *options, QWidget *parent = 0);
|
||||||
|
|
||||||
|
public slots:
|
||||||
|
void accept();
|
||||||
|
|
||||||
|
private:
|
||||||
|
QWidget *createAppearancePage();
|
||||||
|
QWidget *createPOIPage();
|
||||||
|
QWidget *createSystemPage();
|
||||||
|
QWidget *createExportPage();
|
||||||
|
|
||||||
|
Options *_options;
|
||||||
|
|
||||||
|
ColorBox *_baseColor;
|
||||||
|
QDoubleSpinBox *_colorOffset;
|
||||||
|
QSpinBox *_trackWidth;
|
||||||
|
StyleComboBox *_trackStyle;
|
||||||
|
QSpinBox *_routeWidth;
|
||||||
|
StyleComboBox *_routeStyle;
|
||||||
|
QCheckBox *_pathAA;
|
||||||
|
QSpinBox *_graphWidth;
|
||||||
|
QCheckBox *_graphAA;
|
||||||
|
QDoubleSpinBox *_poiRadius;
|
||||||
|
QCheckBox *_useOpenGL;
|
||||||
|
QCheckBox *_name;
|
||||||
|
QCheckBox *_date;
|
||||||
|
QCheckBox *_distance;
|
||||||
|
QCheckBox *_time;
|
||||||
|
QCheckBox *_itemCount;
|
||||||
|
QCheckBox *_separateGraphPage;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // OPTIONSDIALOG_H
|
@ -1,62 +1,46 @@
|
|||||||
#include "palette.h"
|
#include "palette.h"
|
||||||
|
|
||||||
|
Palette::Palette(const QColor &color, qreal shift)
|
||||||
#define HUE_INIT 0.1f
|
|
||||||
#define HUE_INCREMENT 0.62f
|
|
||||||
#define SATURATION 0.99f
|
|
||||||
#define VALUE 0.99f
|
|
||||||
|
|
||||||
static unsigned hsv2rgb(float h, float s, float v)
|
|
||||||
{
|
{
|
||||||
unsigned hi;
|
_h = 0; _s = 0; _v = 0; _a = 1.0;
|
||||||
float r = 0, g = 0, b = 0, p, q, t, f;
|
|
||||||
|
|
||||||
hi = (unsigned)(h * 6.0f);
|
setColor(color);
|
||||||
f = h * 6.0f - hi;
|
setShift(shift);
|
||||||
p = v * (1.0f - s);
|
|
||||||
q = v * (1.0f - f * s);
|
|
||||||
t = v * (1.0f - (1.0f - f) * s);
|
|
||||||
|
|
||||||
switch (hi) {
|
_state = _h;
|
||||||
case 0:
|
|
||||||
r = v; g = t; b = p;
|
|
||||||
break;
|
|
||||||
case 1:
|
|
||||||
r = q; g = v; b = p;
|
|
||||||
break;
|
|
||||||
case 2:
|
|
||||||
r = p; g = v; b = t;
|
|
||||||
break;
|
|
||||||
case 3:
|
|
||||||
r = p; g = q; b = v;
|
|
||||||
break;
|
|
||||||
case 4:
|
|
||||||
r = t; g = p; b = v;
|
|
||||||
break;
|
|
||||||
case 5:
|
|
||||||
r = v; g = p; b = q;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
return ((unsigned)(r * 256) << 16)
|
|
||||||
+ ((unsigned)(g * 256) << 8)
|
|
||||||
+ (unsigned)(b * 256);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Palette::Palette()
|
void Palette::setColor(const QColor &color)
|
||||||
{
|
{
|
||||||
_hueState = HUE_INIT;
|
if (color.isValid())
|
||||||
|
color.getHsvF(&_h, &_s, &_v, &_a);
|
||||||
}
|
}
|
||||||
|
|
||||||
QColor Palette::color()
|
void Palette::setShift(qreal shift)
|
||||||
{
|
{
|
||||||
_hueState += HUE_INCREMENT;
|
if (shift >= 0 && shift <= 1.0)
|
||||||
_hueState -= (int) _hueState;
|
_shift = shift;
|
||||||
|
}
|
||||||
|
|
||||||
return QColor(hsv2rgb(_hueState, SATURATION, VALUE));
|
QColor Palette::nextColor()
|
||||||
|
{
|
||||||
|
QColor ret = QColor::fromHsvF(_state, _s, _v, _a);
|
||||||
|
|
||||||
|
_state += _shift;
|
||||||
|
_state -= (int) _state;
|
||||||
|
|
||||||
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Palette::reset()
|
void Palette::reset()
|
||||||
{
|
{
|
||||||
_hueState = HUE_INIT;
|
_state = _h;
|
||||||
|
}
|
||||||
|
|
||||||
|
QDebug operator<<(QDebug dbg, const Palette &palette)
|
||||||
|
{
|
||||||
|
dbg.nospace() << "Palette(" << palette.color() << ", " << palette.shift()
|
||||||
|
<< ")";
|
||||||
|
|
||||||
|
return dbg.maybeSpace();
|
||||||
}
|
}
|
||||||
|
@ -2,16 +2,32 @@
|
|||||||
#define PALETTE_H
|
#define PALETTE_H
|
||||||
|
|
||||||
#include <QColor>
|
#include <QColor>
|
||||||
|
#include <QDebug>
|
||||||
|
|
||||||
class Palette
|
class Palette
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
Palette();
|
Palette(const QColor &color = Qt::blue, qreal shift = 0.62);
|
||||||
QColor color();
|
|
||||||
|
QColor color() const {return QColor::fromHsvF(_h, _s, _v, _a).toRgb();}
|
||||||
|
qreal shift() const {return _shift;}
|
||||||
|
void setColor(const QColor &color);
|
||||||
|
void setShift(qreal shift);
|
||||||
|
|
||||||
|
QColor nextColor();
|
||||||
void reset();
|
void reset();
|
||||||
|
|
||||||
|
bool operator==(const Palette &other) const
|
||||||
|
{return (_h == other._h && _s == other._s && _v == other._v
|
||||||
|
&& _a == other._a && _shift == other._shift);}
|
||||||
|
bool operator!=(const Palette &other) const
|
||||||
|
{return !(*this == other);}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
float _hueState;
|
qreal _h, _s, _v, _a, _shift;
|
||||||
|
qreal _state;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
QDebug operator<<(QDebug dbg, const Palette &palette);
|
||||||
|
|
||||||
#endif // PALLETE_H
|
#endif // PALLETE_H
|
||||||
|
252
src/parser.cpp
@ -1,252 +0,0 @@
|
|||||||
#include "parser.h"
|
|
||||||
|
|
||||||
|
|
||||||
void Parser::handleTrackpointData(DataType type, const QString &value)
|
|
||||||
{
|
|
||||||
switch (type) {
|
|
||||||
case Elevation:
|
|
||||||
_track->last().setElevation(value.toLatin1().toDouble());
|
|
||||||
break;
|
|
||||||
case Time:
|
|
||||||
_track->last().setTimestamp(QDateTime::fromString(value.toLatin1(),
|
|
||||||
Qt::ISODate));
|
|
||||||
break;
|
|
||||||
case Geoidheight:
|
|
||||||
_track->last().setGeoidHeight(value.toLatin1().toDouble());
|
|
||||||
break;
|
|
||||||
case Speed:
|
|
||||||
_track->last().setSpeed(value.toDouble());
|
|
||||||
break;
|
|
||||||
case HeartRate:
|
|
||||||
_track->last().setHeartRate(value.toDouble());
|
|
||||||
break;
|
|
||||||
case Temperature:
|
|
||||||
_track->last().setTemperature(value.toDouble());
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void Parser::handleWaypointData(DataType type, const QString &value)
|
|
||||||
{
|
|
||||||
switch (type) {
|
|
||||||
case Name:
|
|
||||||
_waypoints.last().setName(value);
|
|
||||||
break;
|
|
||||||
case Description:
|
|
||||||
_waypoints.last().setDescription(value);
|
|
||||||
break;
|
|
||||||
case Time:
|
|
||||||
_waypoints.last().setTimestamp(QDateTime::fromString(
|
|
||||||
value.toLatin1(), Qt::ISODate));
|
|
||||||
break;
|
|
||||||
case Elevation:
|
|
||||||
_waypoints.last().setElevation(value.toLatin1().toDouble());
|
|
||||||
break;
|
|
||||||
case Geoidheight:
|
|
||||||
_waypoints.last().setGeoidHeight(value.toLatin1().toDouble());
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void Parser::handleRoutepointData(DataType type, const QString &value)
|
|
||||||
{
|
|
||||||
switch (type) {
|
|
||||||
case Name:
|
|
||||||
_route->last().setName(value);
|
|
||||||
break;
|
|
||||||
case Description:
|
|
||||||
_route->last().setDescription(value);
|
|
||||||
break;
|
|
||||||
case Time:
|
|
||||||
_route->last().setTimestamp(QDateTime::fromString(
|
|
||||||
value.toLatin1(), Qt::ISODate));
|
|
||||||
break;
|
|
||||||
case Elevation:
|
|
||||||
_route->last().setElevation(value.toLatin1().toDouble());
|
|
||||||
break;
|
|
||||||
case Geoidheight:
|
|
||||||
_route->last().setGeoidHeight(value.toLatin1().toDouble());
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void Parser::handleTrackpointAttributes(const QXmlStreamAttributes &attr)
|
|
||||||
{
|
|
||||||
_track->last().setCoordinates(QPointF(
|
|
||||||
attr.value("lon").toLatin1().toDouble(),
|
|
||||||
attr.value("lat").toLatin1().toDouble()));
|
|
||||||
}
|
|
||||||
|
|
||||||
void Parser::handleRoutepointAttributes(const QXmlStreamAttributes &attr)
|
|
||||||
{
|
|
||||||
_route->last().setCoordinates(QPointF(
|
|
||||||
attr.value("lon").toLatin1().toDouble(),
|
|
||||||
attr.value("lat").toLatin1().toDouble()));
|
|
||||||
}
|
|
||||||
|
|
||||||
void Parser::handleWaypointAttributes(const QXmlStreamAttributes &attr)
|
|
||||||
{
|
|
||||||
_waypoints.last().setCoordinates(QPointF(
|
|
||||||
attr.value("lon").toLatin1().toDouble(),
|
|
||||||
attr.value("lat").toLatin1().toDouble()));
|
|
||||||
}
|
|
||||||
|
|
||||||
void Parser::tpExtension()
|
|
||||||
{
|
|
||||||
while (_reader.readNextStartElement()) {
|
|
||||||
if (_reader.name() == "hr")
|
|
||||||
handleTrackpointData(HeartRate, _reader.readElementText());
|
|
||||||
else if (_reader.name() == "atemp")
|
|
||||||
handleTrackpointData(Temperature, _reader.readElementText());
|
|
||||||
else
|
|
||||||
_reader.skipCurrentElement();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void Parser::extensions()
|
|
||||||
{
|
|
||||||
while (_reader.readNextStartElement()) {
|
|
||||||
if (_reader.name() == "speed")
|
|
||||||
handleTrackpointData(Speed, _reader.readElementText());
|
|
||||||
else if (_reader.name() == "hr" || _reader.name() == "heartrate")
|
|
||||||
handleTrackpointData(HeartRate, _reader.readElementText());
|
|
||||||
else if (_reader.name() == "temp")
|
|
||||||
handleTrackpointData(Temperature, _reader.readElementText());
|
|
||||||
else if (_reader.name() == "TrackPointExtension")
|
|
||||||
tpExtension();
|
|
||||||
else
|
|
||||||
_reader.skipCurrentElement();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void Parser::trackpointData()
|
|
||||||
{
|
|
||||||
while (_reader.readNextStartElement()) {
|
|
||||||
if (_reader.name() == "ele")
|
|
||||||
handleTrackpointData(Elevation, _reader.readElementText());
|
|
||||||
else if (_reader.name() == "time")
|
|
||||||
handleTrackpointData(Time, _reader.readElementText());
|
|
||||||
else if (_reader.name() == "geoidheight")
|
|
||||||
handleTrackpointData(Geoidheight, _reader.readElementText());
|
|
||||||
else if (_reader.name() == "extensions")
|
|
||||||
extensions();
|
|
||||||
else
|
|
||||||
_reader.skipCurrentElement();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void Parser::routepointData()
|
|
||||||
{
|
|
||||||
while (_reader.readNextStartElement()) {
|
|
||||||
if (_reader.name() == "name")
|
|
||||||
handleRoutepointData(Name, _reader.readElementText());
|
|
||||||
else if (_reader.name() == "desc")
|
|
||||||
handleRoutepointData(Description, _reader.readElementText());
|
|
||||||
else if (_reader.name() == "ele")
|
|
||||||
handleRoutepointData(Elevation, _reader.readElementText());
|
|
||||||
else if (_reader.name() == "geoidheight")
|
|
||||||
handleRoutepointData(Geoidheight, _reader.readElementText());
|
|
||||||
else if (_reader.name() == "time")
|
|
||||||
handleRoutepointData(Time, _reader.readElementText());
|
|
||||||
else
|
|
||||||
_reader.skipCurrentElement();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void Parser::trackpoints()
|
|
||||||
{
|
|
||||||
while (_reader.readNextStartElement()) {
|
|
||||||
if (_reader.name() == "trkpt") {
|
|
||||||
_track->append(Trackpoint());
|
|
||||||
handleTrackpointAttributes(_reader.attributes());
|
|
||||||
trackpointData();
|
|
||||||
} else
|
|
||||||
_reader.skipCurrentElement();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void Parser::routepoints()
|
|
||||||
{
|
|
||||||
while (_reader.readNextStartElement()) {
|
|
||||||
if (_reader.name() == "rtept") {
|
|
||||||
_route->append(Waypoint());
|
|
||||||
handleRoutepointAttributes(_reader.attributes());
|
|
||||||
routepointData();
|
|
||||||
} else
|
|
||||||
_reader.skipCurrentElement();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void Parser::track()
|
|
||||||
{
|
|
||||||
while (_reader.readNextStartElement()) {
|
|
||||||
if (_reader.name() == "trkseg") {
|
|
||||||
trackpoints();
|
|
||||||
} else
|
|
||||||
_reader.skipCurrentElement();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void Parser::waypointData()
|
|
||||||
{
|
|
||||||
while (_reader.readNextStartElement()) {
|
|
||||||
if (_reader.name() == "name")
|
|
||||||
handleWaypointData(Name, _reader.readElementText());
|
|
||||||
else if (_reader.name() == "desc")
|
|
||||||
handleWaypointData(Description, _reader.readElementText());
|
|
||||||
else if (_reader.name() == "ele")
|
|
||||||
handleWaypointData(Elevation, _reader.readElementText());
|
|
||||||
else if (_reader.name() == "geoidheight")
|
|
||||||
handleWaypointData(Geoidheight, _reader.readElementText());
|
|
||||||
else if (_reader.name() == "time")
|
|
||||||
handleWaypointData(Time, _reader.readElementText());
|
|
||||||
else
|
|
||||||
_reader.skipCurrentElement();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void Parser::gpx()
|
|
||||||
{
|
|
||||||
while (_reader.readNextStartElement()) {
|
|
||||||
if (_reader.name() == "trk") {
|
|
||||||
_tracks.append(QVector<Trackpoint>());
|
|
||||||
_track = &_tracks.back();
|
|
||||||
track();
|
|
||||||
} else if (_reader.name() == "rte") {
|
|
||||||
_routes.append(QVector<Waypoint>());
|
|
||||||
_route = &_routes.back();
|
|
||||||
routepoints();
|
|
||||||
} else if (_reader.name() == "wpt") {
|
|
||||||
_waypoints.append(Waypoint());
|
|
||||||
handleWaypointAttributes(_reader.attributes());
|
|
||||||
waypointData();
|
|
||||||
} else
|
|
||||||
_reader.skipCurrentElement();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
bool Parser::parse()
|
|
||||||
{
|
|
||||||
if (_reader.readNextStartElement()) {
|
|
||||||
if (_reader.name() == "gpx")
|
|
||||||
gpx();
|
|
||||||
else
|
|
||||||
_reader.raiseError("Not a GPX file.");
|
|
||||||
}
|
|
||||||
|
|
||||||
return !_reader.error();
|
|
||||||
}
|
|
||||||
|
|
||||||
bool Parser::loadFile(QIODevice *device)
|
|
||||||
{
|
|
||||||
_reader.clear();
|
|
||||||
_reader.setDevice(device);
|
|
||||||
|
|
||||||
return parse();
|
|
||||||
}
|
|
53
src/parser.h
@ -1,55 +1,30 @@
|
|||||||
#ifndef PARSER_H
|
#ifndef PARSER_H
|
||||||
#define PARSER_H
|
#define PARSER_H
|
||||||
|
|
||||||
#include <QXmlStreamReader>
|
#include <QString>
|
||||||
#include <QVector>
|
|
||||||
#include <QList>
|
#include <QList>
|
||||||
#include "trackpoint.h"
|
#include <QFile>
|
||||||
|
#include "trackdata.h"
|
||||||
|
#include "routedata.h"
|
||||||
#include "waypoint.h"
|
#include "waypoint.h"
|
||||||
|
|
||||||
|
|
||||||
class Parser
|
class Parser
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
Parser(QList<QVector<Trackpoint> > &tracks,
|
Parser(QList<TrackData> &tracks, QList<RouteData> &routes,
|
||||||
QList<QVector<Waypoint> > &routes, QList<Waypoint> &waypoints)
|
QList<Waypoint> &waypoints) : _tracks(tracks), _routes(routes),
|
||||||
: _tracks(tracks), _routes(routes), _waypoints(waypoints)
|
_waypoints(waypoints) {}
|
||||||
{_track = 0; _route = 0;}
|
virtual ~Parser() {}
|
||||||
|
|
||||||
bool loadFile(QIODevice *device);
|
virtual bool loadFile(QFile *file) = 0;
|
||||||
QString errorString() const {return _reader.errorString();}
|
virtual QString errorString() const = 0;
|
||||||
int errorLine() const {return _reader.lineNumber();}
|
virtual int errorLine() const = 0;
|
||||||
|
|
||||||
private:
|
protected:
|
||||||
enum DataType {
|
QList<TrackData> &_tracks;
|
||||||
Name, Description, Elevation, Time, Geoidheight, Speed, HeartRate,
|
QList<RouteData> &_routes;
|
||||||
Temperature
|
|
||||||
};
|
|
||||||
|
|
||||||
bool parse();
|
|
||||||
void gpx();
|
|
||||||
void track();
|
|
||||||
void trackpoints();
|
|
||||||
void routepoints();
|
|
||||||
void tpExtension();
|
|
||||||
void extensions();
|
|
||||||
void trackpointData();
|
|
||||||
void routepointData();
|
|
||||||
void waypointData();
|
|
||||||
|
|
||||||
void handleWaypointAttributes(const QXmlStreamAttributes &attr);
|
|
||||||
void handleWaypointData(DataType type, const QString &value);
|
|
||||||
void handleTrackpointAttributes(const QXmlStreamAttributes &attr);
|
|
||||||
void handleTrackpointData(DataType type, const QString &value);
|
|
||||||
void handleRoutepointAttributes(const QXmlStreamAttributes &attr);
|
|
||||||
void handleRoutepointData(DataType type, const QString &value);
|
|
||||||
|
|
||||||
QXmlStreamReader _reader;
|
|
||||||
QList<QVector<Trackpoint> > &_tracks;
|
|
||||||
QList<QVector<Waypoint> > &_routes;
|
|
||||||
QList<Waypoint> &_waypoints;
|
QList<Waypoint> &_waypoints;
|
||||||
QVector<Trackpoint> *_track;
|
|
||||||
QVector<Waypoint> *_route;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // PARSER_H
|
#endif // PARSER_H
|
||||||
|
9
src/path.cpp
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
#include "path.h"
|
||||||
|
|
||||||
|
QDebug operator<<(QDebug dbg, const PathPoint &point)
|
||||||
|
{
|
||||||
|
dbg.nospace() << "PathPoint(" << point.distance() << ", "
|
||||||
|
<< point.coordinates() << ")";
|
||||||
|
|
||||||
|
return dbg.maybeSpace();
|
||||||
|
}
|
28
src/path.h
Normal file
@ -0,0 +1,28 @@
|
|||||||
|
#ifndef PATH_H
|
||||||
|
#define PATH_H
|
||||||
|
|
||||||
|
#include <QVector>
|
||||||
|
#include "coordinates.h"
|
||||||
|
|
||||||
|
class PathPoint
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
PathPoint() :
|
||||||
|
_coordinates(Coordinates()), _distance(NAN) {}
|
||||||
|
PathPoint(const Coordinates &coordinates, qreal distance)
|
||||||
|
: _coordinates(coordinates), _distance(distance) {}
|
||||||
|
|
||||||
|
const Coordinates &coordinates() const {return _coordinates;}
|
||||||
|
qreal distance() const {return _distance;}
|
||||||
|
|
||||||
|
private:
|
||||||
|
Coordinates _coordinates;
|
||||||
|
qreal _distance;
|
||||||
|
};
|
||||||
|
|
||||||
|
Q_DECLARE_TYPEINFO(PathPoint, Q_PRIMITIVE_TYPE);
|
||||||
|
QDebug operator<<(QDebug dbg, const PathPoint &point);
|
||||||
|
|
||||||
|
typedef QVector<PathPoint> Path;
|
||||||
|
|
||||||
|
#endif // PATH_H
|
@ -1,3 +1,4 @@
|
|||||||
|
#include <cmath>
|
||||||
#include <QApplication>
|
#include <QApplication>
|
||||||
#include <QCursor>
|
#include <QCursor>
|
||||||
#include <QPainter>
|
#include <QPainter>
|
||||||
@ -5,25 +6,19 @@
|
|||||||
#include "pathitem.h"
|
#include "pathitem.h"
|
||||||
|
|
||||||
|
|
||||||
#define PATH_WIDTH 3
|
|
||||||
#define HOVER_WIDTH 4
|
|
||||||
|
|
||||||
void PathItem::updateShape()
|
void PathItem::updateShape()
|
||||||
{
|
{
|
||||||
QPainterPathStroker s;
|
QPainterPathStroker s;
|
||||||
s.setWidth(HOVER_WIDTH * 1.0/scale());
|
s.setWidth((_width + 1) * 1.0/scale());
|
||||||
_shape = s.createStroke(_path);
|
_shape = s.createStroke(_path);
|
||||||
|
|
||||||
if (qMax(boundingRect().width(), boundingRect().height()) * scale() <= 768)
|
|
||||||
setCacheMode(QGraphicsItem::DeviceCoordinateCache);
|
|
||||||
else
|
|
||||||
setCacheMode(QGraphicsItem::NoCache);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
PathItem::PathItem(QGraphicsItem *parent) : QGraphicsObject(parent)
|
PathItem::PathItem(QGraphicsItem *parent) : QGraphicsObject(parent)
|
||||||
{
|
{
|
||||||
|
_width = 3;
|
||||||
|
|
||||||
QBrush brush(Qt::SolidPattern);
|
QBrush brush(Qt::SolidPattern);
|
||||||
_pen = QPen(brush, PATH_WIDTH);
|
_pen = QPen(brush, _width);
|
||||||
|
|
||||||
_units = Metric;
|
_units = Metric;
|
||||||
|
|
||||||
@ -53,7 +48,7 @@ void PathItem::setScale(qreal scale)
|
|||||||
{
|
{
|
||||||
prepareGeometryChange();
|
prepareGeometryChange();
|
||||||
|
|
||||||
_pen.setWidthF(PATH_WIDTH * 1.0/scale);
|
_pen.setWidthF(_width * 1.0/scale);
|
||||||
QGraphicsItem::setScale(scale);
|
QGraphicsItem::setScale(scale);
|
||||||
_marker->setScale(1.0/scale);
|
_marker->setScale(1.0/scale);
|
||||||
|
|
||||||
@ -66,26 +61,76 @@ void PathItem::setColor(const QColor &color)
|
|||||||
update();
|
update();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void PathItem::setWidth(int width)
|
||||||
|
{
|
||||||
|
prepareGeometryChange();
|
||||||
|
|
||||||
|
_width = width;
|
||||||
|
_pen.setWidthF(_width * 1.0/scale());
|
||||||
|
|
||||||
|
updateShape();
|
||||||
|
}
|
||||||
|
|
||||||
|
void PathItem::setStyle(Qt::PenStyle style)
|
||||||
|
{
|
||||||
|
_pen.setStyle(style);
|
||||||
|
update();
|
||||||
|
}
|
||||||
|
|
||||||
void PathItem::setUnits(enum Units units)
|
void PathItem::setUnits(enum Units units)
|
||||||
{
|
{
|
||||||
_units = units;
|
_units = units;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QPointF PathItem::position(qreal x) const
|
||||||
|
{
|
||||||
|
int low = 0;
|
||||||
|
int high = _distance.count() - 1;
|
||||||
|
int mid = 0;
|
||||||
|
|
||||||
|
|
||||||
|
Q_ASSERT(_distance.count() == _path.elementCount());
|
||||||
|
Q_ASSERT(high > low);
|
||||||
|
Q_ASSERT(x >= _distance.at(low) && x <= _distance.at(high));
|
||||||
|
|
||||||
|
while (low <= high) {
|
||||||
|
mid = low + ((high - low) / 2);
|
||||||
|
qreal val = _distance.at(mid);
|
||||||
|
if (val > x)
|
||||||
|
high = mid - 1;
|
||||||
|
else if (val < x)
|
||||||
|
low = mid + 1;
|
||||||
|
else
|
||||||
|
return _path.elementAt(mid);
|
||||||
|
}
|
||||||
|
|
||||||
|
QLineF l;
|
||||||
|
qreal p1, p2;
|
||||||
|
if (_distance.at(mid) < x) {
|
||||||
|
l = QLineF(_path.elementAt(mid), _path.elementAt(mid+1));
|
||||||
|
p1 = _distance.at(mid); p2 = _distance.at(mid+1);
|
||||||
|
} else {
|
||||||
|
l = QLineF(_path.elementAt(mid-1), _path.elementAt(mid));
|
||||||
|
p1 = _distance.at(mid-1); p2 = _distance.at(mid);
|
||||||
|
}
|
||||||
|
|
||||||
|
return l.pointAt((x - p1) / (p2 - p1));
|
||||||
|
}
|
||||||
|
|
||||||
void PathItem::moveMarker(qreal distance)
|
void PathItem::moveMarker(qreal distance)
|
||||||
{
|
{
|
||||||
if (distance > _distance)
|
if (distance >= _distance.first() && distance <= _distance.last()) {
|
||||||
_marker->setVisible(false);
|
|
||||||
else {
|
|
||||||
_marker->setVisible(true);
|
_marker->setVisible(true);
|
||||||
_marker->setPos(_path.pointAtPercent(distance / _distance));
|
_marker->setPos(position(distance));
|
||||||
}
|
} else
|
||||||
|
_marker->setVisible(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
void PathItem::hoverEnterEvent(QGraphicsSceneHoverEvent *event)
|
void PathItem::hoverEnterEvent(QGraphicsSceneHoverEvent *event)
|
||||||
{
|
{
|
||||||
Q_UNUSED(event);
|
Q_UNUSED(event);
|
||||||
|
|
||||||
_pen.setWidthF(HOVER_WIDTH * 1.0/scale());
|
_pen.setWidthF((_width + 1) * 1.0/scale());
|
||||||
setZValue(zValue() + 1.0);
|
setZValue(zValue() + 1.0);
|
||||||
update();
|
update();
|
||||||
|
|
||||||
@ -96,7 +141,7 @@ void PathItem::hoverLeaveEvent(QGraphicsSceneHoverEvent *event)
|
|||||||
{
|
{
|
||||||
Q_UNUSED(event);
|
Q_UNUSED(event);
|
||||||
|
|
||||||
_pen.setWidthF(PATH_WIDTH * 1.0/scale());
|
_pen.setWidthF(_width * 1.0/scale());
|
||||||
setZValue(zValue() - 1.0);
|
setZValue(zValue() - 1.0);
|
||||||
update();
|
update();
|
||||||
|
|
||||||
|
@ -24,6 +24,8 @@ public:
|
|||||||
void setScale(qreal scale);
|
void setScale(qreal scale);
|
||||||
void setUnits(enum Units units);
|
void setUnits(enum Units units);
|
||||||
void setColor(const QColor &color);
|
void setColor(const QColor &color);
|
||||||
|
void setWidth(int width);
|
||||||
|
void setStyle(Qt::PenStyle style);
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
void moveMarker(qreal distance);
|
void moveMarker(qreal distance);
|
||||||
@ -34,18 +36,20 @@ signals:
|
|||||||
protected:
|
protected:
|
||||||
void updateShape();
|
void updateShape();
|
||||||
|
|
||||||
|
QVector<qreal> _distance;
|
||||||
QPainterPath _path;
|
QPainterPath _path;
|
||||||
QPainterPath _shape;
|
|
||||||
QPen _pen;
|
|
||||||
|
|
||||||
MarkerItem *_marker;
|
MarkerItem *_marker;
|
||||||
|
|
||||||
Units _units;
|
Units _units;
|
||||||
qreal _distance;
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
QPointF position(qreal distance) const;
|
||||||
|
|
||||||
void hoverEnterEvent(QGraphicsSceneHoverEvent *event);
|
void hoverEnterEvent(QGraphicsSceneHoverEvent *event);
|
||||||
void hoverLeaveEvent(QGraphicsSceneHoverEvent *event);
|
void hoverLeaveEvent(QGraphicsSceneHoverEvent *event);
|
||||||
|
|
||||||
|
int _width;
|
||||||
|
QPen _pen;
|
||||||
|
QPainterPath _shape;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // PATHITEM_H
|
#endif // PATHITEM_H
|
||||||
|
586
src/pathview.cpp
@ -1,9 +1,12 @@
|
|||||||
#include <QGraphicsView>
|
#include <QGraphicsView>
|
||||||
#include <QGraphicsScene>
|
#include <QGraphicsScene>
|
||||||
#include <QWheelEvent>
|
#include <QWheelEvent>
|
||||||
#include "ll.h"
|
#include <QSysInfo>
|
||||||
|
#include "opengl.h"
|
||||||
|
#include "rd.h"
|
||||||
|
#include "wgs84.h"
|
||||||
#include "poi.h"
|
#include "poi.h"
|
||||||
#include "gpx.h"
|
#include "data.h"
|
||||||
#include "map.h"
|
#include "map.h"
|
||||||
#include "trackitem.h"
|
#include "trackitem.h"
|
||||||
#include "routeitem.h"
|
#include "routeitem.h"
|
||||||
@ -12,8 +15,77 @@
|
|||||||
#include "pathview.h"
|
#include "pathview.h"
|
||||||
|
|
||||||
|
|
||||||
#define MARGIN 10.0
|
#define ZOOM_MAX 18
|
||||||
#define SCALE_OFFSET 7
|
#define ZOOM_MIN 3
|
||||||
|
#define MARGIN 10.0
|
||||||
|
#define SCALE_OFFSET 7
|
||||||
|
|
||||||
|
static QPoint mercator2tile(const QPointF &m, int z)
|
||||||
|
{
|
||||||
|
QPoint tile;
|
||||||
|
|
||||||
|
tile.setX((int)(floor((m.x() + 180.0) / 360.0 * (1<<z))));
|
||||||
|
tile.setY((int)(floor((1.0 - (m.y() / 180.0)) / 2.0 * (1<<z))));
|
||||||
|
|
||||||
|
return tile;
|
||||||
|
}
|
||||||
|
|
||||||
|
static QPointF tile2mercator(const QPoint &tile, int z)
|
||||||
|
{
|
||||||
|
QPointF m;
|
||||||
|
|
||||||
|
m.setX(((360.0 * tile.x()) / (qreal)(1<<z)) - 180.0);
|
||||||
|
m.setY((1.0 - (2.0 * tile.y()) / (qreal)(1<<z)) * 180.0);
|
||||||
|
|
||||||
|
return m;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int scale2zoom(qreal scale)
|
||||||
|
{
|
||||||
|
int zoom = (int)log2(360.0/(scale * (qreal)Tile::size()));
|
||||||
|
|
||||||
|
if (zoom < ZOOM_MIN)
|
||||||
|
return ZOOM_MIN;
|
||||||
|
if (zoom > ZOOM_MAX)
|
||||||
|
return ZOOM_MAX;
|
||||||
|
|
||||||
|
return zoom;
|
||||||
|
}
|
||||||
|
|
||||||
|
qreal mapScale(int zoom)
|
||||||
|
{
|
||||||
|
return ((360.0/(qreal)(1<<zoom))/(qreal)Tile::size());
|
||||||
|
}
|
||||||
|
|
||||||
|
static QRectF mapBounds()
|
||||||
|
{
|
||||||
|
return QRectF(QPointF(-180, -180), QSizeF(360, 360));
|
||||||
|
}
|
||||||
|
|
||||||
|
static qreal zoom2resolution(int zoom, qreal y)
|
||||||
|
{
|
||||||
|
return (WGS84_RADIUS * 2 * M_PI / Tile::size()
|
||||||
|
* cos(2.0 * atan(exp(deg2rad(y))) - M_PI/2)) / (qreal)(1<<zoom);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void unite(QRectF &rect, const QPointF &p)
|
||||||
|
{
|
||||||
|
if (p.x() < rect.left())
|
||||||
|
rect.setLeft(p.x());
|
||||||
|
if (p.x() > rect.right())
|
||||||
|
rect.setRight(p.x());
|
||||||
|
if (p.y() > rect.bottom())
|
||||||
|
rect.setBottom(p.y());
|
||||||
|
if (p.y() < rect.top())
|
||||||
|
rect.setTop(p.y());
|
||||||
|
}
|
||||||
|
|
||||||
|
static QRectF scaled(const QRectF &rect, qreal factor)
|
||||||
|
{
|
||||||
|
return QRectF(QPointF(rect.left() * factor, rect.top() * factor),
|
||||||
|
QSizeF(rect.width() * factor, rect.height() * factor));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
PathView::PathView(QWidget *parent)
|
PathView::PathView(QWidget *parent)
|
||||||
: QGraphicsView(parent)
|
: QGraphicsView(parent)
|
||||||
@ -25,14 +97,16 @@ PathView::PathView(QWidget *parent)
|
|||||||
setViewportUpdateMode(QGraphicsView::FullViewportUpdate);
|
setViewportUpdateMode(QGraphicsView::FullViewportUpdate);
|
||||||
setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
|
setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
|
||||||
setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
|
setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
|
||||||
setRenderHints(QPainter::Antialiasing);
|
setRenderHint(QPainter::Antialiasing, true);
|
||||||
|
setAcceptDrops(false);
|
||||||
|
|
||||||
_mapScale = new ScaleItem();
|
_mapScale = new ScaleItem();
|
||||||
_mapScale->setZValue(2.0);
|
_mapScale->setZValue(2.0);
|
||||||
|
|
||||||
_zoom = ZOOM_MAX;
|
_zoom = ZOOM_MAX;
|
||||||
_scale = mapScale(_zoom);
|
_res = 1.0;
|
||||||
_map = 0;
|
_map = 0;
|
||||||
|
_poi = 0;
|
||||||
|
|
||||||
_units = Metric;
|
_units = Metric;
|
||||||
|
|
||||||
@ -40,11 +114,18 @@ PathView::PathView(QWidget *parent)
|
|||||||
_showRoutes = true;
|
_showRoutes = true;
|
||||||
_showWaypoints = true;
|
_showWaypoints = true;
|
||||||
_showWaypointLabels = true;
|
_showWaypointLabels = true;
|
||||||
|
_showPOI = true;
|
||||||
_showPOILabels = true;
|
_showPOILabels = true;
|
||||||
_overlapPOIs = true;
|
_overlapPOIs = true;
|
||||||
_showRouteWaypoints = true;
|
_showRouteWaypoints = true;
|
||||||
|
_trackWidth = 3;
|
||||||
|
_routeWidth = 3;
|
||||||
|
_trackStyle = Qt::SolidLine;
|
||||||
|
_routeStyle = Qt::DashLine;
|
||||||
|
|
||||||
_plot = false;
|
_plot = false;
|
||||||
|
|
||||||
|
_scene->setSceneRect(scaled(mapBounds(), 1.0 / mapScale(_zoom)));
|
||||||
}
|
}
|
||||||
|
|
||||||
PathView::~PathView()
|
PathView::~PathView()
|
||||||
@ -56,222 +137,179 @@ PathView::~PathView()
|
|||||||
PathItem *PathView::addTrack(const Track &track)
|
PathItem *PathView::addTrack(const Track &track)
|
||||||
{
|
{
|
||||||
if (track.isNull()) {
|
if (track.isNull()) {
|
||||||
_palette.color();
|
_palette.nextColor();
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
TrackItem *ti = new TrackItem(track);
|
TrackItem *ti = new TrackItem(track);
|
||||||
_tracks.append(ti);
|
_tracks.append(ti);
|
||||||
_zoom = qMin(_zoom, scale2zoom(trackScale()));
|
_tr |= ti->path().boundingRect();
|
||||||
_scale = mapScale(_zoom);
|
_zoom = scale2zoom(contentsScale());
|
||||||
ti->setScale(1.0/_scale);
|
ti->setScale(1.0/mapScale(_zoom));
|
||||||
ti->setColor(_palette.color());
|
ti->setColor(_palette.nextColor());
|
||||||
|
ti->setWidth(_trackWidth);
|
||||||
|
ti->setStyle(_trackStyle);
|
||||||
ti->setVisible(_showTracks);
|
ti->setVisible(_showTracks);
|
||||||
_scene->addItem(ti);
|
_scene->addItem(ti);
|
||||||
|
|
||||||
|
if (_poi)
|
||||||
|
addPOI(_poi->points(ti));
|
||||||
|
|
||||||
return ti;
|
return ti;
|
||||||
}
|
}
|
||||||
|
|
||||||
PathItem *PathView::addRoute(const Route &route)
|
PathItem *PathView::addRoute(const Route &route)
|
||||||
{
|
{
|
||||||
if (route.isNull()) {
|
if (route.isNull()) {
|
||||||
_palette.color();
|
_palette.nextColor();
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
RouteItem *ri = new RouteItem(route);
|
RouteItem *ri = new RouteItem(route);
|
||||||
_routes.append(ri);
|
_routes.append(ri);
|
||||||
_zoom = qMin(_zoom, scale2zoom(routeScale()));
|
_rr |= ri->path().boundingRect();
|
||||||
_scale = mapScale(_zoom);
|
_zoom = scale2zoom(contentsScale());
|
||||||
ri->setScale(1.0/_scale);
|
ri->setScale(1.0/mapScale(_zoom));
|
||||||
ri->setColor(_palette.color());
|
ri->setColor(_palette.nextColor());
|
||||||
|
ri->setWidth(_routeWidth);
|
||||||
|
ri->setStyle(_routeStyle);
|
||||||
ri->setVisible(_showRoutes);
|
ri->setVisible(_showRoutes);
|
||||||
ri->showWaypoints(_showRouteWaypoints);
|
ri->showWaypoints(_showRouteWaypoints);
|
||||||
ri->showWaypointLabels(_showWaypointLabels);
|
ri->showWaypointLabels(_showWaypointLabels);
|
||||||
_scene->addItem(ri);
|
_scene->addItem(ri);
|
||||||
|
|
||||||
|
if (_poi)
|
||||||
|
addPOI(_poi->points(ri));
|
||||||
|
|
||||||
return ri;
|
return ri;
|
||||||
}
|
}
|
||||||
|
|
||||||
void PathView::addWaypoints(const QList<Waypoint> &waypoints)
|
void PathView::addWaypoints(const QList<Waypoint> &waypoints)
|
||||||
{
|
{
|
||||||
|
qreal scale = mapScale(_zoom);
|
||||||
|
|
||||||
for (int i = 0; i < waypoints.count(); i++) {
|
for (int i = 0; i < waypoints.count(); i++) {
|
||||||
const Waypoint &w = waypoints.at(i);
|
const Waypoint &w = waypoints.at(i);
|
||||||
|
|
||||||
WaypointItem *wi = new WaypointItem(w);
|
WaypointItem *wi = new WaypointItem(w);
|
||||||
wi->setScale(1.0/_scale);
|
_waypoints.append(wi);
|
||||||
|
updateWaypointsBoundingRect(wi->coordinates());
|
||||||
|
wi->setScale(1.0/scale);
|
||||||
wi->setZValue(1);
|
wi->setZValue(1);
|
||||||
wi->showLabel(_showWaypointLabels);
|
wi->showLabel(_showWaypointLabels);
|
||||||
wi->setVisible(_showWaypoints);
|
wi->setVisible(_showWaypoints);
|
||||||
_scene->addItem(wi);
|
_scene->addItem(wi);
|
||||||
|
|
||||||
_waypoints.append(wi);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
_zoom = qMin(_zoom, scale2zoom(waypointScale()));
|
if (_poi)
|
||||||
_scale = mapScale(_zoom);
|
addPOI(_poi->points(waypoints));
|
||||||
|
|
||||||
|
_zoom = scale2zoom(contentsScale());
|
||||||
}
|
}
|
||||||
|
|
||||||
QList<PathItem *> PathView::loadGPX(const GPX &gpx)
|
QList<PathItem *> PathView::loadData(const Data &data)
|
||||||
{
|
{
|
||||||
QList<PathItem *> paths;
|
QList<PathItem *> paths;
|
||||||
int zoom = _zoom;
|
int zoom = _zoom;
|
||||||
|
|
||||||
|
|
||||||
for (int i = 0; i < gpx.tracks().count(); i++)
|
for (int i = 0; i < data.tracks().count(); i++)
|
||||||
paths.append(addTrack(*(gpx.tracks().at(i))));
|
paths.append(addTrack(*(data.tracks().at(i))));
|
||||||
for (int i = 0; i < gpx.routes().count(); i++)
|
|
||||||
paths.append(addRoute(*(gpx.routes().at(i))));
|
for (int i = 0; i < data.routes().count(); i++)
|
||||||
addWaypoints(gpx.waypoints());
|
paths.append(addRoute(*(data.routes().at(i))));
|
||||||
|
|
||||||
|
addWaypoints(data.waypoints());
|
||||||
|
|
||||||
if (_tracks.empty() && _routes.empty() && _waypoints.empty())
|
if (_tracks.empty() && _routes.empty() && _waypoints.empty())
|
||||||
return paths;
|
return paths;
|
||||||
|
|
||||||
if ((_tracks.size() + _routes.size() > 1 && _zoom < zoom)
|
if (_zoom < zoom)
|
||||||
|| (_waypoints.size() && _zoom < zoom))
|
rescale(_zoom);
|
||||||
rescale(_scale);
|
else
|
||||||
|
updatePOIVisibility();
|
||||||
|
|
||||||
QRectF br = trackBoundingRect() | routeBoundingRect()
|
QPointF center = contentsCenter();
|
||||||
| waypointBoundingRect();
|
centerOn(center);
|
||||||
QRectF ba = br.adjusted(-TILE_SIZE, -TILE_SIZE, TILE_SIZE, TILE_SIZE);
|
|
||||||
_scene->setSceneRect(ba);
|
|
||||||
centerOn(ba.center());
|
|
||||||
|
|
||||||
_mapScale->setZoom(_zoom, -(br.center().ry() * _scale));
|
_res = zoom2resolution(_zoom, -(center.y() * mapScale(_zoom)));
|
||||||
|
_mapScale->setResolution(_res);
|
||||||
if (_mapScale->scene() != _scene)
|
if (_mapScale->scene() != _scene)
|
||||||
_scene->addItem(_mapScale);
|
_scene->addItem(_mapScale);
|
||||||
|
|
||||||
return paths;
|
return paths;
|
||||||
}
|
}
|
||||||
|
|
||||||
QRectF PathView::trackBoundingRect() const
|
void PathView::updateWaypointsBoundingRect(const QPointF &wp)
|
||||||
{
|
{
|
||||||
if (_tracks.empty())
|
if (_wr.isNull()) {
|
||||||
return QRectF();
|
if (_wp.isNull())
|
||||||
|
_wp = wp;
|
||||||
QRectF br = _tracks.at(0)->sceneBoundingRect();
|
else {
|
||||||
for (int i = 1; i < _tracks.size(); i++)
|
_wr = QRectF(_wp, wp).normalized();
|
||||||
br |= _tracks.at(i)->sceneBoundingRect();
|
_wp = QPointF();
|
||||||
|
}
|
||||||
return br;
|
} else
|
||||||
|
unite(_wr, wp);
|
||||||
}
|
}
|
||||||
|
|
||||||
QRectF PathView::routeBoundingRect() const
|
qreal PathView::contentsScale() const
|
||||||
{
|
{
|
||||||
if (_routes.empty())
|
QRectF br = _tr | _rr | _wr;
|
||||||
return QRectF();
|
if (!br.isNull() && !_wp.isNull())
|
||||||
|
unite(br, _wp);
|
||||||
|
|
||||||
QRectF br = _routes.at(0)->sceneBoundingRect();
|
if (br.isNull())
|
||||||
for (int i = 1; i < _routes.size(); i++)
|
|
||||||
br |= _routes.at(i)->sceneBoundingRect();
|
|
||||||
|
|
||||||
return br;
|
|
||||||
}
|
|
||||||
|
|
||||||
QRectF PathView::waypointBoundingRect() const
|
|
||||||
{
|
|
||||||
qreal bottom, top, left, right;
|
|
||||||
|
|
||||||
if (_waypoints.empty())
|
|
||||||
return QRectF();
|
|
||||||
|
|
||||||
const QPointF &p = _waypoints.at(0)->pos();
|
|
||||||
bottom = p.y();
|
|
||||||
top = p.y();
|
|
||||||
left = p.x();
|
|
||||||
right = p.x();
|
|
||||||
|
|
||||||
for (int i = 1; i < _waypoints.size(); i++) {
|
|
||||||
const QPointF &p = _waypoints.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 PathView::trackScale() const
|
|
||||||
{
|
|
||||||
if (_tracks.empty())
|
|
||||||
return mapScale(ZOOM_MAX);
|
return mapScale(ZOOM_MAX);
|
||||||
|
|
||||||
QRectF br = _tracks.at(0)->path().boundingRect();
|
|
||||||
|
|
||||||
for (int i = 1; i < _tracks.size(); i++)
|
|
||||||
br |= _tracks.at(i)->path().boundingRect();
|
|
||||||
|
|
||||||
QPointF sc(br.width() / (viewport()->width() - MARGIN/2),
|
QPointF sc(br.width() / (viewport()->width() - MARGIN/2),
|
||||||
br.height() / (viewport()->height() - MARGIN/2));
|
br.height() / (viewport()->height() - MARGIN/2));
|
||||||
|
|
||||||
return qMax(sc.x(), sc.y());
|
return qMax(sc.x(), sc.y());
|
||||||
}
|
}
|
||||||
|
|
||||||
qreal PathView::routeScale() const
|
QPointF PathView::contentsCenter() const
|
||||||
{
|
{
|
||||||
if (_routes.empty())
|
QRectF br = _tr | _rr | _wr;
|
||||||
return mapScale(ZOOM_MAX);
|
if (!br.isNull() && !_wp.isNull())
|
||||||
|
unite(br, _wp);
|
||||||
|
|
||||||
QRectF br = _routes.at(0)->path().boundingRect();
|
qreal scale = mapScale(_zoom);
|
||||||
|
|
||||||
for (int i = 1; i < _routes.size(); i++)
|
if (br.isNull())
|
||||||
br |= _routes.at(i)->path().boundingRect();
|
return _wp / scale;
|
||||||
|
else
|
||||||
QPointF sc(br.width() / (viewport()->width() - MARGIN/2),
|
return scaled(br, 1.0/scale).center();
|
||||||
br.height() / (viewport()->height() - MARGIN/2));
|
|
||||||
|
|
||||||
return qMax(sc.x(), sc.y());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
qreal PathView::waypointScale() const
|
void PathView::updatePOIVisibility()
|
||||||
{
|
|
||||||
qreal bottom, top, left, right;
|
|
||||||
|
|
||||||
if (_waypoints.size() < 2)
|
|
||||||
return mapScale(ZOOM_MAX);
|
|
||||||
|
|
||||||
const QPointF &p = _waypoints.at(0)->coordinates();
|
|
||||||
bottom = p.y();
|
|
||||||
top = p.y();
|
|
||||||
left = p.x();
|
|
||||||
right = p.x();
|
|
||||||
|
|
||||||
for (int i = 1; i < _waypoints.size(); i++) {
|
|
||||||
const QPointF &p = _waypoints.at(i)->coordinates();
|
|
||||||
bottom = qMax(bottom, p.y());
|
|
||||||
top = qMin(top, p.y());
|
|
||||||
right = qMax(right, p.x());
|
|
||||||
left = qMin(left, p.x());
|
|
||||||
}
|
|
||||||
|
|
||||||
QRectF br(QPointF(left, top), QPointF(right, bottom));
|
|
||||||
QPointF sc(br.width() / (viewport()->width() - MARGIN/2),
|
|
||||||
br.height() / (viewport()->height() - MARGIN/2));
|
|
||||||
|
|
||||||
return qMax(sc.x(), sc.y());
|
|
||||||
}
|
|
||||||
|
|
||||||
qreal PathView::mapScale(int zoom) const
|
|
||||||
{
|
|
||||||
return ((360.0/(qreal)(1<<zoom))/(qreal)TILE_SIZE);
|
|
||||||
}
|
|
||||||
|
|
||||||
void PathView::checkPOIOverlap()
|
|
||||||
{
|
{
|
||||||
QHash<Waypoint, WaypointItem*>::const_iterator it, jt;
|
QHash<Waypoint, WaypointItem*>::const_iterator it, jt;
|
||||||
|
|
||||||
for (it = _pois.constBegin(); it != _pois.constEnd(); it++) {
|
if (!_showPOI)
|
||||||
for (jt = _pois.constBegin(); jt != _pois.constEnd(); jt++) {
|
return;
|
||||||
if (it != jt && it.value()->isVisible() && jt.value()->isVisible()
|
|
||||||
&& it.value()->collidesWithItem(jt.value()))
|
for (it = _pois.constBegin(); it != _pois.constEnd(); it++)
|
||||||
jt.value()->hide();
|
it.value()->show();
|
||||||
|
|
||||||
|
if (!_overlapPOIs) {
|
||||||
|
for (it = _pois.constBegin(); it != _pois.constEnd(); it++) {
|
||||||
|
for (jt = _pois.constBegin(); jt != _pois.constEnd(); jt++) {
|
||||||
|
if (it.value()->isVisible() && jt.value()->isVisible()
|
||||||
|
&& it != jt && it.value()->collidesWithItem(jt.value()))
|
||||||
|
jt.value()->hide();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void PathView::rescale(qreal scale)
|
void PathView::rescale(int zoom)
|
||||||
{
|
{
|
||||||
|
_zoom = zoom;
|
||||||
|
qreal scale = mapScale(zoom);
|
||||||
|
|
||||||
|
_scene->setSceneRect(scaled(mapBounds(), 1.0 / scale));
|
||||||
|
|
||||||
for (int i = 0; i < _tracks.size(); i++)
|
for (int i = 0; i < _tracks.size(); i++)
|
||||||
_tracks.at(i)->setScale(1.0/scale);
|
_tracks.at(i)->setScale(1.0/scale);
|
||||||
|
|
||||||
@ -282,19 +320,62 @@ void PathView::rescale(qreal scale)
|
|||||||
_waypoints.at(i)->setScale(1.0/scale);
|
_waypoints.at(i)->setScale(1.0/scale);
|
||||||
|
|
||||||
QHash<Waypoint, WaypointItem*>::const_iterator it;
|
QHash<Waypoint, WaypointItem*>::const_iterator it;
|
||||||
for (it = _pois.constBegin(); it != _pois.constEnd(); it++) {
|
for (it = _pois.constBegin(); it != _pois.constEnd(); it++)
|
||||||
it.value()->setScale(1.0/scale);
|
it.value()->setScale(1.0/scale);
|
||||||
it.value()->show();
|
|
||||||
|
updatePOIVisibility();
|
||||||
|
}
|
||||||
|
|
||||||
|
void PathView::setPalette(const Palette &palette)
|
||||||
|
{
|
||||||
|
_palette = palette;
|
||||||
|
_palette.reset();
|
||||||
|
|
||||||
|
for (int i = 0; i < _tracks.count(); i++)
|
||||||
|
_tracks.at(i)->setColor(_palette.nextColor());
|
||||||
|
for (int i = 0; i < _routes.count(); i++)
|
||||||
|
_routes.at(i)->setColor(_palette.nextColor());
|
||||||
|
}
|
||||||
|
|
||||||
|
void PathView::setPOI(POI *poi)
|
||||||
|
{
|
||||||
|
if (_poi)
|
||||||
|
disconnect(_poi, SIGNAL(pointsChanged()), this, SLOT(updatePOI()));
|
||||||
|
|
||||||
|
_poi = poi;
|
||||||
|
|
||||||
|
if (_poi)
|
||||||
|
connect(_poi, SIGNAL(pointsChanged()), this, SLOT(updatePOI()));
|
||||||
|
|
||||||
|
updatePOI();
|
||||||
|
}
|
||||||
|
|
||||||
|
void PathView::updatePOI()
|
||||||
|
{
|
||||||
|
QHash<Waypoint, WaypointItem*>::const_iterator it;
|
||||||
|
|
||||||
|
for (it = _pois.constBegin(); it != _pois.constEnd(); it++) {
|
||||||
|
_scene->removeItem(it.value());
|
||||||
|
delete it.value();
|
||||||
}
|
}
|
||||||
|
_pois.clear();
|
||||||
|
|
||||||
if (!_overlapPOIs)
|
if (!_poi)
|
||||||
checkPOIOverlap();
|
return;
|
||||||
|
|
||||||
_scale = scale;
|
for (int i = 0; i < _tracks.size(); i++)
|
||||||
|
addPOI(_poi->points(_tracks.at(i)));
|
||||||
|
for (int i = 0; i < _routes.size(); i++)
|
||||||
|
addPOI(_poi->points(_routes.at(i)));
|
||||||
|
addPOI(_poi->points(_waypoints));
|
||||||
|
|
||||||
|
updatePOIVisibility();
|
||||||
}
|
}
|
||||||
|
|
||||||
void PathView::addPOI(const QVector<Waypoint> &waypoints)
|
void PathView::addPOI(const QVector<Waypoint> &waypoints)
|
||||||
{
|
{
|
||||||
|
qreal scale = mapScale(_zoom);
|
||||||
|
|
||||||
for (int i = 0; i < waypoints.size(); i++) {
|
for (int i = 0; i < waypoints.size(); i++) {
|
||||||
const Waypoint &w = waypoints.at(i);
|
const Waypoint &w = waypoints.at(i);
|
||||||
|
|
||||||
@ -302,36 +383,26 @@ void PathView::addPOI(const QVector<Waypoint> &waypoints)
|
|||||||
continue;
|
continue;
|
||||||
|
|
||||||
WaypointItem *pi = new WaypointItem(w);
|
WaypointItem *pi = new WaypointItem(w);
|
||||||
pi->setScale(1.0/_scale);
|
pi->setScale(1.0/scale);
|
||||||
pi->setZValue(1);
|
pi->setZValue(1);
|
||||||
pi->showLabel(_showPOILabels);
|
pi->showLabel(_showPOILabels);
|
||||||
|
pi->setVisible(_showPOI);
|
||||||
_scene->addItem(pi);
|
_scene->addItem(pi);
|
||||||
|
|
||||||
_pois.insert(w, pi);
|
_pois.insert(w, pi);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void PathView::loadPOI(const POI &poi)
|
|
||||||
{
|
|
||||||
if (!_tracks.size() && !_routes.size() && !_waypoints.size())
|
|
||||||
return;
|
|
||||||
|
|
||||||
for (int i = 0; i < _tracks.size(); i++)
|
|
||||||
addPOI(poi.points(_tracks.at(i)->path()));
|
|
||||||
for (int i = 0; i < _routes.size(); i++)
|
|
||||||
addPOI(poi.points(_routes.at(i)->path()));
|
|
||||||
addPOI(poi.points(_waypoints));
|
|
||||||
|
|
||||||
if (!_overlapPOIs)
|
|
||||||
checkPOIOverlap();
|
|
||||||
}
|
|
||||||
|
|
||||||
void PathView::setMap(Map *map)
|
void PathView::setMap(Map *map)
|
||||||
{
|
{
|
||||||
_map = map;
|
|
||||||
if (_map)
|
if (_map)
|
||||||
connect(_map, SIGNAL(loaded()), this, SLOT(redraw()),
|
disconnect(_map, SIGNAL(loaded()), this, SLOT(redraw()));
|
||||||
Qt::UniqueConnection);
|
|
||||||
|
_map = map;
|
||||||
|
|
||||||
|
if (_map)
|
||||||
|
connect(_map, SIGNAL(loaded()), this, SLOT(redraw()));
|
||||||
|
|
||||||
resetCachedContent();
|
resetCachedContent();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -358,50 +429,45 @@ void PathView::redraw()
|
|||||||
resetCachedContent();
|
resetCachedContent();
|
||||||
}
|
}
|
||||||
|
|
||||||
void PathView::rescale()
|
void PathView::zoom(int z, const QPoint &pos)
|
||||||
{
|
|
||||||
_zoom = qMin(qMin(scale2zoom(trackScale()), scale2zoom(routeScale())),
|
|
||||||
scale2zoom(waypointScale()));
|
|
||||||
|
|
||||||
rescale(mapScale(_zoom));
|
|
||||||
_mapScale->setZoom(_zoom);
|
|
||||||
}
|
|
||||||
|
|
||||||
void PathView::zoom(int z, const QPointF &pos)
|
|
||||||
{
|
{
|
||||||
if (_tracks.isEmpty() && _routes.isEmpty() && _waypoints.isEmpty())
|
if (_tracks.isEmpty() && _routes.isEmpty() && _waypoints.isEmpty())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
qreal scale = _scale;
|
QPoint offset = pos - viewport()->rect().center();
|
||||||
|
QPointF spos = mapToScene(pos);
|
||||||
|
|
||||||
|
qreal os = mapScale(_zoom);
|
||||||
_zoom = z;
|
_zoom = z;
|
||||||
|
|
||||||
rescale(mapScale(_zoom));
|
rescale(_zoom);
|
||||||
QRectF br = trackBoundingRect() | routeBoundingRect()
|
|
||||||
| waypointBoundingRect();
|
|
||||||
QRectF ba = br.adjusted(-TILE_SIZE, -TILE_SIZE, TILE_SIZE, TILE_SIZE);
|
|
||||||
_scene->setSceneRect(ba);
|
|
||||||
|
|
||||||
if (br.width() < viewport()->size().width()
|
QPointF center = (spos * (os/mapScale(_zoom))) - offset;
|
||||||
&& br.height() < viewport()->size().height())
|
centerOn(center);
|
||||||
centerOn(br.center());
|
|
||||||
else
|
|
||||||
centerOn(pos * scale/_scale);
|
|
||||||
|
|
||||||
_mapScale->setZoom(_zoom);
|
_res = zoom2resolution(_zoom, -(center.y() * mapScale(_zoom)));
|
||||||
|
_mapScale->setResolution(_res);
|
||||||
|
|
||||||
resetCachedContent();
|
resetCachedContent();
|
||||||
}
|
}
|
||||||
|
|
||||||
void PathView::wheelEvent(QWheelEvent *event)
|
void PathView::wheelEvent(QWheelEvent *event)
|
||||||
{
|
{
|
||||||
if (_tracks.isEmpty() && _routes.isEmpty() && _waypoints.isEmpty())
|
|
||||||
return;
|
|
||||||
|
|
||||||
QPointF pos = mapToScene(event->pos());
|
|
||||||
int z = (event->delta() > 0) ?
|
int z = (event->delta() > 0) ?
|
||||||
qMin(_zoom + 1, ZOOM_MAX) : qMax(_zoom - 1, ZOOM_MIN);
|
qMin(_zoom + 1, ZOOM_MAX) : qMax(_zoom - 1, ZOOM_MIN);
|
||||||
|
|
||||||
zoom(z, pos);
|
zoom(z, event->pos());
|
||||||
|
}
|
||||||
|
|
||||||
|
void PathView::mouseDoubleClickEvent(QMouseEvent *event)
|
||||||
|
{
|
||||||
|
if (event->button() != Qt::LeftButton && event->button() != Qt::RightButton)
|
||||||
|
return;
|
||||||
|
|
||||||
|
int z = (event->button() == Qt::LeftButton) ?
|
||||||
|
qMin(_zoom + 1, ZOOM_MAX) : qMax(_zoom - 1, ZOOM_MIN);
|
||||||
|
|
||||||
|
zoom(z, event->pos());
|
||||||
}
|
}
|
||||||
|
|
||||||
void PathView::keyPressEvent(QKeyEvent *event)
|
void PathView::keyPressEvent(QKeyEvent *event)
|
||||||
@ -414,7 +480,7 @@ void PathView::keyPressEvent(QKeyEvent *event)
|
|||||||
z = qMax(_zoom - 1, ZOOM_MIN);
|
z = qMax(_zoom - 1, ZOOM_MIN);
|
||||||
|
|
||||||
if (z >= 0)
|
if (z >= 0)
|
||||||
zoom(z, mapToScene(QRect(QPoint(), size()).center()));
|
zoom(z, QRect(QPoint(), size()).center());
|
||||||
else
|
else
|
||||||
QWidget::keyPressEvent(event);
|
QWidget::keyPressEvent(event);
|
||||||
}
|
}
|
||||||
@ -453,18 +519,6 @@ void PathView::plot(QPainter *painter, const QRectF &target)
|
|||||||
setUpdatesEnabled(true);
|
setUpdatesEnabled(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
void PathView::clearPOI()
|
|
||||||
{
|
|
||||||
QHash<Waypoint, WaypointItem*>::const_iterator it;
|
|
||||||
|
|
||||||
for (it = _pois.constBegin(); it != _pois.constEnd(); it++) {
|
|
||||||
_scene->removeItem(it.value());
|
|
||||||
delete it.value();
|
|
||||||
}
|
|
||||||
|
|
||||||
_pois.clear();
|
|
||||||
}
|
|
||||||
|
|
||||||
void PathView::clear()
|
void PathView::clear()
|
||||||
{
|
{
|
||||||
if (_mapScale->scene() == _scene)
|
if (_mapScale->scene() == _scene)
|
||||||
@ -478,7 +532,9 @@ void PathView::clear()
|
|||||||
_palette.reset();
|
_palette.reset();
|
||||||
|
|
||||||
_zoom = ZOOM_MAX;
|
_zoom = ZOOM_MAX;
|
||||||
_scale = mapScale(_zoom);
|
_res = 1.0;
|
||||||
|
_tr = QRectF(); _rr = QRectF(); _wr = QRectF();
|
||||||
|
_wp = QPointF();
|
||||||
|
|
||||||
_scene->setSceneRect(QRectF());
|
_scene->setSceneRect(QRectF());
|
||||||
}
|
}
|
||||||
@ -526,6 +582,17 @@ void PathView::showRouteWaypoints(bool show)
|
|||||||
_routes.at(i)->showWaypoints(show);
|
_routes.at(i)->showWaypoints(show);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void PathView::showPOI(bool show)
|
||||||
|
{
|
||||||
|
_showPOI = show;
|
||||||
|
|
||||||
|
QHash<Waypoint, WaypointItem*>::const_iterator it;
|
||||||
|
for (it = _pois.constBegin(); it != _pois.constEnd(); it++)
|
||||||
|
it.value()->setVisible(show);
|
||||||
|
|
||||||
|
updatePOIVisibility();
|
||||||
|
}
|
||||||
|
|
||||||
void PathView::showPOILabels(bool show)
|
void PathView::showPOILabels(bool show)
|
||||||
{
|
{
|
||||||
_showPOILabels = show;
|
_showPOILabels = show;
|
||||||
@ -534,19 +601,46 @@ void PathView::showPOILabels(bool show)
|
|||||||
for (it = _pois.constBegin(); it != _pois.constEnd(); it++)
|
for (it = _pois.constBegin(); it != _pois.constEnd(); it++)
|
||||||
it.value()->showLabel(show);
|
it.value()->showLabel(show);
|
||||||
|
|
||||||
setPOIOverlap(_overlapPOIs);
|
updatePOIVisibility();
|
||||||
}
|
}
|
||||||
|
|
||||||
void PathView::setPOIOverlap(bool overlap)
|
void PathView::setPOIOverlap(bool overlap)
|
||||||
{
|
{
|
||||||
_overlapPOIs = overlap;
|
_overlapPOIs = overlap;
|
||||||
|
|
||||||
if (_overlapPOIs) {
|
updatePOIVisibility();
|
||||||
QHash<Waypoint, WaypointItem*>::const_iterator it;
|
}
|
||||||
for (it = _pois.constBegin(); it != _pois.constEnd(); it++)
|
|
||||||
it.value()->show();
|
void PathView::setTrackWidth(int width)
|
||||||
} else
|
{
|
||||||
checkPOIOverlap();
|
_trackWidth = width;
|
||||||
|
|
||||||
|
for (int i = 0; i < _tracks.count(); i++)
|
||||||
|
_tracks.at(i)->setWidth(width);
|
||||||
|
}
|
||||||
|
|
||||||
|
void PathView::setRouteWidth(int width)
|
||||||
|
{
|
||||||
|
_routeWidth = width;
|
||||||
|
|
||||||
|
for (int i = 0; i < _routes.count(); i++)
|
||||||
|
_routes.at(i)->setWidth(width);
|
||||||
|
}
|
||||||
|
|
||||||
|
void PathView::setTrackStyle(Qt::PenStyle style)
|
||||||
|
{
|
||||||
|
_trackStyle = style;
|
||||||
|
|
||||||
|
for (int i = 0; i < _tracks.count(); i++)
|
||||||
|
_tracks.at(i)->setStyle(style);
|
||||||
|
}
|
||||||
|
|
||||||
|
void PathView::setRouteStyle(Qt::PenStyle style)
|
||||||
|
{
|
||||||
|
_routeStyle = style;
|
||||||
|
|
||||||
|
for (int i = 0; i < _routes.count(); i++)
|
||||||
|
_routes.at(i)->setStyle(style);
|
||||||
}
|
}
|
||||||
|
|
||||||
void PathView::drawBackground(QPainter *painter, const QRectF &rect)
|
void PathView::drawBackground(QPainter *painter, const QRectF &rect)
|
||||||
@ -557,57 +651,51 @@ void PathView::drawBackground(QPainter *painter, const QRectF &rect)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
QRectF rr(rect.topLeft() * _scale, rect.size());
|
qreal scale = mapScale(_zoom);
|
||||||
|
QRectF rr(rect.topLeft() * scale, rect.size());
|
||||||
QPoint tile = mercator2tile(QPointF(rr.topLeft().x(), -rr.topLeft().y()),
|
QPoint tile = mercator2tile(QPointF(rr.topLeft().x(), -rr.topLeft().y()),
|
||||||
_zoom);
|
_zoom);
|
||||||
QPointF tm = tile2mercator(tile, _zoom);
|
QPointF tm = tile2mercator(tile, _zoom);
|
||||||
QPoint tl = mapToScene(mapFromScene(QPointF(tm.x() / _scale,
|
QPoint tl = QPoint((int)(tm.x() / scale), (int)(-tm.y() / scale));
|
||||||
-tm.y() / _scale))).toPoint();
|
|
||||||
|
|
||||||
QList<Tile> tiles;
|
QList<Tile> tiles;
|
||||||
for (int i = 0; i <= rr.size().width() / TILE_SIZE + 1; i++) {
|
QSizeF s(rect.right() - tl.x(), rect.bottom() - tl.y());
|
||||||
for (int j = 0; j <= rr.size().height() / TILE_SIZE + 1; j++) {
|
for (int i = 0; i < ceil(s.width() / Tile::size()); i++)
|
||||||
|
for (int j = 0; j < ceil(s.height() / Tile::size()); j++)
|
||||||
tiles.append(Tile(QPoint(tile.x() + i, tile.y() + j), _zoom));
|
tiles.append(Tile(QPoint(tile.x() + i, tile.y() + j), _zoom));
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
_map->loadTiles(tiles, _plot);
|
_map->loadTiles(tiles, _plot);
|
||||||
|
|
||||||
for (int i = 0; i < tiles.count(); i++) {
|
for (int i = 0; i < tiles.count(); i++) {
|
||||||
Tile &t = tiles[i];
|
Tile &t = tiles[i];
|
||||||
QPoint tp(tl.x() + (t.xy().x() - tile.x()) * TILE_SIZE,
|
QPoint tp(tl.x() + (t.xy().x() - tile.x()) * Tile::size(),
|
||||||
tl.y() + (t.xy().y() - tile.y()) * TILE_SIZE);
|
tl.y() + (t.xy().y() - tile.y()) * Tile::size());
|
||||||
painter->drawPixmap(tp, t.pixmap());
|
painter->drawPixmap(tp, t.pixmap());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void PathView::resizeEvent(QResizeEvent *e)
|
void PathView::resizeEvent(QResizeEvent *event)
|
||||||
{
|
{
|
||||||
|
Q_UNUSED(event);
|
||||||
|
|
||||||
if (_tracks.isEmpty() && _routes.isEmpty() && _waypoints.isEmpty())
|
if (_tracks.isEmpty() && _routes.isEmpty() && _waypoints.isEmpty())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
rescale();
|
int zoom = scale2zoom(contentsScale());
|
||||||
|
if (zoom != _zoom)
|
||||||
|
rescale(zoom);
|
||||||
|
|
||||||
QRectF br = trackBoundingRect() | routeBoundingRect()
|
QPointF center = contentsCenter();
|
||||||
| waypointBoundingRect();
|
centerOn(center);
|
||||||
QRectF ba = br.adjusted(-TILE_SIZE, -TILE_SIZE, TILE_SIZE, TILE_SIZE);
|
|
||||||
|
|
||||||
if (ba.width() < e->size().width()) {
|
_res = zoom2resolution(_zoom, -(center.y() * mapScale(_zoom)));
|
||||||
qreal diff = e->size().width() - ba.width();
|
_mapScale->setResolution(_res);
|
||||||
ba.adjust(-diff/2, 0, diff/2, 0);
|
|
||||||
}
|
|
||||||
if (ba.height() < e->size().height()) {
|
|
||||||
qreal diff = e->size().height() - ba.height();
|
|
||||||
ba.adjust(0, -diff/2, 0, diff/2);
|
|
||||||
}
|
|
||||||
|
|
||||||
_scene->setSceneRect(ba);
|
|
||||||
|
|
||||||
centerOn(br.center());
|
|
||||||
resetCachedContent();
|
resetCachedContent();
|
||||||
}
|
}
|
||||||
|
|
||||||
void PathView::paintEvent(QPaintEvent *e)
|
void PathView::paintEvent(QPaintEvent *event)
|
||||||
{
|
{
|
||||||
QPointF scenePos = mapToScene(rect().bottomRight() + QPoint(
|
QPointF scenePos = mapToScene(rect().bottomRight() + QPoint(
|
||||||
-(SCALE_OFFSET + _mapScale->boundingRect().width()),
|
-(SCALE_OFFSET + _mapScale->boundingRect().width()),
|
||||||
@ -615,5 +703,29 @@ void PathView::paintEvent(QPaintEvent *e)
|
|||||||
if (_mapScale->pos() != scenePos && !_plot)
|
if (_mapScale->pos() != scenePos && !_plot)
|
||||||
_mapScale->setPos(scenePos);
|
_mapScale->setPos(scenePos);
|
||||||
|
|
||||||
QGraphicsView::paintEvent(e);
|
QGraphicsView::paintEvent(event);
|
||||||
|
}
|
||||||
|
|
||||||
|
void PathView::scrollContentsBy(int dx, int dy)
|
||||||
|
{
|
||||||
|
QGraphicsView::scrollContentsBy(dx, dy);
|
||||||
|
|
||||||
|
QPointF center = mapToScene(viewport()->rect().center());
|
||||||
|
qreal res = zoom2resolution(_zoom, -(center.y() * mapScale(_zoom)));
|
||||||
|
|
||||||
|
if (qMax(res, _res) / qMin(res, _res) > 1.1) {
|
||||||
|
_mapScale->setResolution(res);
|
||||||
|
_res = res;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void PathView::useOpenGL(bool use)
|
||||||
|
{
|
||||||
|
if (use) {
|
||||||
|
#ifdef Q_OS_WIN32
|
||||||
|
if (QSysInfo::WindowsVersion >= QSysInfo::WV_VISTA)
|
||||||
|
#endif // Q_OS_WIN32
|
||||||
|
setViewport(new OPENGL_WIDGET);
|
||||||
|
} else
|
||||||
|
setViewport(new QWidget);
|
||||||
}
|
}
|
||||||
|
@ -9,7 +9,7 @@
|
|||||||
#include "palette.h"
|
#include "palette.h"
|
||||||
#include "waypoint.h"
|
#include "waypoint.h"
|
||||||
|
|
||||||
class GPX;
|
class Data;
|
||||||
class POI;
|
class POI;
|
||||||
class Map;
|
class Map;
|
||||||
class Track;
|
class Track;
|
||||||
@ -28,12 +28,10 @@ public:
|
|||||||
PathView(QWidget *parent = 0);
|
PathView(QWidget *parent = 0);
|
||||||
~PathView();
|
~PathView();
|
||||||
|
|
||||||
QList<PathItem*> loadGPX(const GPX &gpx);
|
QList<PathItem*> loadData(const Data &data);
|
||||||
|
|
||||||
void loadPOI(const POI &poi);
|
|
||||||
void clearPOI();
|
|
||||||
void clear();
|
|
||||||
|
|
||||||
|
void setPalette(const Palette &palette);
|
||||||
|
void setPOI(POI *poi);
|
||||||
void setMap(Map *map);
|
void setMap(Map *map);
|
||||||
void setUnits(enum Units units);
|
void setUnits(enum Units units);
|
||||||
|
|
||||||
@ -43,9 +41,14 @@ public:
|
|||||||
int routeCount() const {return _routes.count();}
|
int routeCount() const {return _routes.count();}
|
||||||
int waypointCount() const {return _waypoints.count();}
|
int waypointCount() const {return _waypoints.count();}
|
||||||
|
|
||||||
|
void clear();
|
||||||
|
|
||||||
|
void useOpenGL(bool use);
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
void redraw();
|
void redraw();
|
||||||
|
|
||||||
|
void showPOI(bool show);
|
||||||
void setPOIOverlap(bool overlap);
|
void setPOIOverlap(bool overlap);
|
||||||
void showWaypointLabels(bool show);
|
void showWaypointLabels(bool show);
|
||||||
void showPOILabels(bool show);
|
void showPOILabels(bool show);
|
||||||
@ -53,54 +56,66 @@ public slots:
|
|||||||
void showRoutes(bool show);
|
void showRoutes(bool show);
|
||||||
void showWaypoints(bool show);
|
void showWaypoints(bool show);
|
||||||
void showRouteWaypoints(bool show);
|
void showRouteWaypoints(bool show);
|
||||||
|
void setTrackWidth(int width);
|
||||||
|
void setRouteWidth(int width);
|
||||||
|
void setTrackStyle(Qt::PenStyle style);
|
||||||
|
void setRouteStyle(Qt::PenStyle style);
|
||||||
|
|
||||||
|
private slots:
|
||||||
|
void updatePOI();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
PathItem *addTrack(const Track &track);
|
PathItem *addTrack(const Track &track);
|
||||||
PathItem *addRoute(const Route &route);
|
PathItem *addRoute(const Route &route);
|
||||||
void addWaypoints(const QList<Waypoint> &waypoints);
|
void addWaypoints(const QList<Waypoint> &waypoints);
|
||||||
void addPOI(const QVector<Waypoint> &waypoints);
|
void addPOI(const QVector<Waypoint> &waypoints);
|
||||||
|
void loadPOI();
|
||||||
|
void clearPOI();
|
||||||
|
|
||||||
QRectF trackBoundingRect() const;
|
qreal contentsScale() const;
|
||||||
QRectF routeBoundingRect() const;
|
QPointF contentsCenter() const;
|
||||||
QRectF waypointBoundingRect() const;
|
void rescale(int zoom);
|
||||||
qreal trackScale() const;
|
void zoom(int z, const QPoint &pos);
|
||||||
qreal routeScale() const;
|
void updatePOIVisibility();
|
||||||
qreal waypointScale() const;
|
void updateWaypointsBoundingRect(const QPointF &wp);
|
||||||
qreal mapScale(int zoom) const;
|
|
||||||
void rescale(qreal scale);
|
|
||||||
void rescale();
|
|
||||||
void zoom(int z, const QPointF &pos);
|
|
||||||
void checkPOIOverlap();
|
|
||||||
|
|
||||||
|
void mouseDoubleClickEvent(QMouseEvent *event);
|
||||||
void wheelEvent(QWheelEvent *event);
|
void wheelEvent(QWheelEvent *event);
|
||||||
void keyPressEvent(QKeyEvent *event);
|
void keyPressEvent(QKeyEvent *event);
|
||||||
void drawBackground(QPainter *painter, const QRectF &rect);
|
void drawBackground(QPainter *painter, const QRectF &rect);
|
||||||
void resizeEvent(QResizeEvent *e);
|
void resizeEvent(QResizeEvent *event);
|
||||||
void paintEvent(QPaintEvent *e);
|
void paintEvent(QPaintEvent *event);
|
||||||
|
void scrollContentsBy(int dx, int dy);
|
||||||
|
|
||||||
QGraphicsScene *_scene;
|
QGraphicsScene *_scene;
|
||||||
|
ScaleItem *_mapScale;
|
||||||
QList<TrackItem*> _tracks;
|
QList<TrackItem*> _tracks;
|
||||||
QList<RouteItem*> _routes;
|
QList<RouteItem*> _routes;
|
||||||
QList<WaypointItem*> _waypoints;
|
QList<WaypointItem*> _waypoints;
|
||||||
QHash<Waypoint, WaypointItem*> _pois;
|
QHash<Waypoint, WaypointItem*> _pois;
|
||||||
|
|
||||||
Map *_map;
|
|
||||||
ScaleItem *_mapScale;
|
|
||||||
|
|
||||||
Palette _palette;
|
|
||||||
|
|
||||||
qreal _scale;
|
|
||||||
int _zoom;
|
int _zoom;
|
||||||
|
QRectF _tr, _rr, _wr;
|
||||||
|
QPointF _wp;
|
||||||
|
qreal _res;
|
||||||
|
|
||||||
|
Map *_map;
|
||||||
|
POI *_poi;
|
||||||
|
Palette _palette;
|
||||||
Units _units;
|
Units _units;
|
||||||
|
|
||||||
bool _showTracks;
|
bool _showTracks;
|
||||||
bool _showRoutes;
|
bool _showRoutes;
|
||||||
bool _showWaypoints;
|
bool _showWaypoints;
|
||||||
bool _showWaypointLabels;
|
bool _showWaypointLabels;
|
||||||
|
bool _showPOI;
|
||||||
bool _showPOILabels;
|
bool _showPOILabels;
|
||||||
bool _overlapPOIs;
|
bool _overlapPOIs;
|
||||||
bool _showRouteWaypoints;
|
bool _showRouteWaypoints;
|
||||||
|
int _trackWidth;
|
||||||
|
int _routeWidth;
|
||||||
|
Qt::PenStyle _trackStyle;
|
||||||
|
Qt::PenStyle _routeStyle;
|
||||||
|
|
||||||
bool _plot;
|
bool _plot;
|
||||||
};
|
};
|
||||||
|
207
src/poi.cpp
@ -1,139 +1,52 @@
|
|||||||
#include <QFile>
|
#include <QFile>
|
||||||
#include <QSet>
|
#include <QSet>
|
||||||
#include <QList>
|
#include <QList>
|
||||||
#include <QPainterPath>
|
#include "pathitem.h"
|
||||||
#include "waypointitem.h"
|
#include "waypointitem.h"
|
||||||
#include "ll.h"
|
#include "data.h"
|
||||||
#include "gpx.h"
|
|
||||||
#include "poi.h"
|
#include "poi.h"
|
||||||
|
|
||||||
|
|
||||||
|
POI::POI(QObject *parent) : QObject(parent)
|
||||||
|
{
|
||||||
|
_errorLine = 0;
|
||||||
|
_radius = 1000;
|
||||||
|
}
|
||||||
|
|
||||||
bool POI::loadFile(const QString &fileName)
|
bool POI::loadFile(const QString &fileName)
|
||||||
{
|
{
|
||||||
QString error;
|
Data data;
|
||||||
int errorLine;
|
FileIndex index;
|
||||||
|
|
||||||
_error.clear();
|
_errorString.clear();
|
||||||
_errorLine = 0;
|
_errorLine = 0;
|
||||||
|
|
||||||
|
|
||||||
if (loadCSVFile(fileName))
|
|
||||||
return true;
|
|
||||||
else {
|
|
||||||
error = _error;
|
|
||||||
errorLine = _errorLine;
|
|
||||||
}
|
|
||||||
if (loadGPXFile(fileName))
|
|
||||||
return true;
|
|
||||||
|
|
||||||
fprintf(stderr, "Error loading POI file: %s:\n", qPrintable(fileName));
|
|
||||||
fprintf(stderr, "CSV: line %d: %s\n", errorLine, qPrintable(error));
|
|
||||||
fprintf(stderr, "GPX: line %d: %s\n", _errorLine, qPrintable(_error));
|
|
||||||
|
|
||||||
if (errorLine > _errorLine) {
|
|
||||||
_errorLine = errorLine;
|
|
||||||
_error = error;
|
|
||||||
}
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool POI::loadGPXFile(const QString &fileName)
|
|
||||||
{
|
|
||||||
GPX gpx;
|
|
||||||
FileIndex index;
|
|
||||||
|
|
||||||
index.enabled = true;
|
index.enabled = true;
|
||||||
index.start = _data.size();
|
index.start = _data.size();
|
||||||
|
|
||||||
if (gpx.loadFile(fileName)) {
|
if (!data.loadFile(fileName)) {
|
||||||
for (int i = 0; i < gpx.waypoints().size(); i++)
|
_errorString = data.errorString();
|
||||||
_data.append(gpx.waypoints().at(i));
|
_errorLine = data.errorLine();
|
||||||
index.end = _data.size() - 1;
|
|
||||||
|
|
||||||
for (int i = index.start; i <= index.end; i++) {
|
|
||||||
const QPointF &p = _data.at(i).coordinates();
|
|
||||||
qreal c[2];
|
|
||||||
c[0] = p.x();
|
|
||||||
c[1] = p.y();
|
|
||||||
_tree.Insert(c, c, i);
|
|
||||||
}
|
|
||||||
|
|
||||||
_files.append(fileName);
|
|
||||||
_indexes.append(index);
|
|
||||||
|
|
||||||
return true;
|
|
||||||
} else {
|
|
||||||
_error = gpx.errorString();
|
|
||||||
_errorLine = gpx.errorLine();
|
|
||||||
}
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool POI::loadCSVFile(const QString &fileName)
|
|
||||||
{
|
|
||||||
QFile file(fileName);
|
|
||||||
FileIndex index;
|
|
||||||
bool ret;
|
|
||||||
int ln = 1;
|
|
||||||
|
|
||||||
index.enabled = true;
|
|
||||||
index.start = _data.size();
|
|
||||||
|
|
||||||
if (!file.open(QFile::ReadOnly | QFile::Text)) {
|
|
||||||
_error = qPrintable(file.errorString());
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
while (!file.atEnd()) {
|
for (int i = 0; i < data.waypoints().size(); i++)
|
||||||
QByteArray line = file.readLine();
|
_data.append(data.waypoints().at(i));
|
||||||
QList<QByteArray> list = line.split(',');
|
|
||||||
if (list.size() < 3) {
|
|
||||||
_error = "Parse error";
|
|
||||||
_errorLine = ln;
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
qreal lat = list[0].trimmed().toDouble(&ret);
|
|
||||||
if (!ret) {
|
|
||||||
_error = "Invalid latitude";
|
|
||||||
_errorLine = ln;
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
qreal lon = list[1].trimmed().toDouble(&ret);
|
|
||||||
if (!ret) {
|
|
||||||
_error = "Invalid longitude";
|
|
||||||
_errorLine = ln;
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
Waypoint wp(QPointF(lon, lat));
|
|
||||||
|
|
||||||
QByteArray ba = list[2].trimmed();
|
|
||||||
QString name = QString::fromUtf8(ba.data(), ba.size());
|
|
||||||
wp.setName(name);
|
|
||||||
|
|
||||||
if (list.size() > 3) {
|
|
||||||
ba = list[3].trimmed();
|
|
||||||
wp.setDescription(QString::fromUtf8(ba.data(), ba.size()));
|
|
||||||
}
|
|
||||||
|
|
||||||
_data.append(wp);
|
|
||||||
ln++;
|
|
||||||
}
|
|
||||||
index.end = _data.size() - 1;
|
index.end = _data.size() - 1;
|
||||||
|
|
||||||
for (int i = index.start; i <= index.end; i++) {
|
for (int i = index.start; i <= index.end; i++) {
|
||||||
const QPointF &p = _data.at(i).coordinates();
|
const Coordinates &p = _data.at(i).coordinates();
|
||||||
qreal c[2];
|
qreal c[2];
|
||||||
c[0] = p.x();
|
c[0] = p.lon();
|
||||||
c[1] = p.y();
|
c[1] = p.lat();
|
||||||
_tree.Insert(c, c, i);
|
_tree.Insert(c, c, i);
|
||||||
}
|
}
|
||||||
|
|
||||||
_files.append(fileName);
|
_files.append(fileName);
|
||||||
_indexes.append(index);
|
_indexes.append(index);
|
||||||
|
|
||||||
|
emit pointsChanged();
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -145,18 +58,23 @@ static bool cb(size_t data, void* context)
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
QVector<Waypoint> POI::points(const QPainterPath &path, qreal radius) const
|
QVector<Waypoint> POI::points(const PathItem *path) const
|
||||||
{
|
{
|
||||||
QVector<Waypoint> ret;
|
QVector<Waypoint> ret;
|
||||||
QSet<int> set;
|
QSet<int> set;
|
||||||
qreal min[2], max[2];
|
qreal min[2], max[2];
|
||||||
|
const QPainterPath &pp = path->path();
|
||||||
|
|
||||||
|
for (int i = 0; i < pp.elementCount(); i++) {
|
||||||
|
const QPainterPath::Element &pe = pp.elementAt(i);
|
||||||
|
Coordinates p = Coordinates::fromMercator(QPointF(pe.x, -pe.y));
|
||||||
|
|
||||||
|
QPair<Coordinates, Coordinates> br = p.boundingRect(_radius);
|
||||||
|
min[0] = br.first.lon();
|
||||||
|
min[1] = br.first.lat();
|
||||||
|
max[0] = br.second.lon();
|
||||||
|
max[1] = br.second.lat();
|
||||||
|
|
||||||
for (int i = 0; i < path.elementCount(); i++) {
|
|
||||||
QPointF p = mercator2ll(path.elementAt(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);
|
_tree.Search(min, max, cb, &set);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -169,7 +87,7 @@ QVector<Waypoint> POI::points(const QPainterPath &path, qreal radius) const
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
QVector<Waypoint> POI::points(const QList<WaypointItem*> &list, qreal radius)
|
QVector<Waypoint> POI::points(const QList<WaypointItem*> &list)
|
||||||
const
|
const
|
||||||
{
|
{
|
||||||
QVector<Waypoint> ret;
|
QVector<Waypoint> ret;
|
||||||
@ -177,11 +95,41 @@ QVector<Waypoint> POI::points(const QList<WaypointItem*> &list, qreal radius)
|
|||||||
qreal min[2], max[2];
|
qreal min[2], max[2];
|
||||||
|
|
||||||
for (int i = 0; i < list.count(); i++) {
|
for (int i = 0; i < list.count(); i++) {
|
||||||
const QPointF &p = list.at(i)->waypoint().coordinates();
|
const Coordinates &p = list.at(i)->waypoint().coordinates();
|
||||||
min[0] = p.x() - radius;
|
|
||||||
min[1] = p.y() - radius;
|
QPair<Coordinates, Coordinates> br = p.boundingRect(_radius);
|
||||||
max[0] = p.x() + radius;
|
min[0] = br.first.lon();
|
||||||
max[1] = p.y() + radius;
|
min[1] = br.first.lat();
|
||||||
|
max[0] = br.second.lon();
|
||||||
|
max[1] = br.second.lat();
|
||||||
|
|
||||||
|
_tree.Search(min, max, cb, &set);
|
||||||
|
}
|
||||||
|
|
||||||
|
QSet<int>::const_iterator i = set.constBegin();
|
||||||
|
while (i != set.constEnd()) {
|
||||||
|
ret.append(_data.at(*i));
|
||||||
|
++i;
|
||||||
|
}
|
||||||
|
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
QVector<Waypoint> POI::points(const QList<Waypoint> &list) const
|
||||||
|
{
|
||||||
|
QVector<Waypoint> ret;
|
||||||
|
QSet<int> set;
|
||||||
|
qreal min[2], max[2];
|
||||||
|
|
||||||
|
for (int i = 0; i < list.count(); i++) {
|
||||||
|
const Coordinates &p = list.at(i).coordinates();
|
||||||
|
|
||||||
|
QPair<Coordinates, Coordinates> br = p.boundingRect(_radius);
|
||||||
|
min[0] = br.first.lon();
|
||||||
|
min[1] = br.first.lat();
|
||||||
|
max[0] = br.second.lon();
|
||||||
|
max[1] = br.second.lat();
|
||||||
|
|
||||||
_tree.Search(min, max, cb, &set);
|
_tree.Search(min, max, cb, &set);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -209,13 +157,15 @@ void POI::enableFile(const QString &fileName, bool enable)
|
|||||||
continue;
|
continue;
|
||||||
|
|
||||||
for (int j = idx.start; j <= idx.end; j++) {
|
for (int j = idx.start; j <= idx.end; j++) {
|
||||||
const QPointF &p = _data.at(j).coordinates();
|
const Coordinates &p = _data.at(j).coordinates();
|
||||||
qreal c[2];
|
qreal c[2];
|
||||||
c[0] = p.x();
|
c[0] = p.lon();
|
||||||
c[1] = p.y();
|
c[1] = p.lat();
|
||||||
_tree.Insert(c, c, j);
|
_tree.Insert(c, c, j);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
emit pointsChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
void POI::clear()
|
void POI::clear()
|
||||||
@ -224,4 +174,13 @@ void POI::clear()
|
|||||||
_data.clear();
|
_data.clear();
|
||||||
_files.clear();
|
_files.clear();
|
||||||
_indexes.clear();
|
_indexes.clear();
|
||||||
|
|
||||||
|
emit pointsChanged();
|
||||||
|
}
|
||||||
|
|
||||||
|
void POI::setRadius(unsigned radius)
|
||||||
|
{
|
||||||
|
_radius = radius;
|
||||||
|
|
||||||
|
emit pointsChanged();
|
||||||
}
|
}
|
||||||
|