Compare commits
131 Commits
Author | SHA1 | Date | |
---|---|---|---|
b79de29464 | |||
ae2765528d | |||
0356917790 | |||
7352b24473 | |||
3a9ec6247c | |||
e74ac78138 | |||
5fa91be4ac | |||
536b4fd121 | |||
0556ae0f58 | |||
e38fdb26d7 | |||
e420602c69 | |||
b2a49eaa23 | |||
211a4e4cef | |||
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 |
185
Info.plist
@ -35,6 +35,86 @@
|
||||
<key>CFBundleTypeRole</key>
|
||||
<string>Viewer</string>
|
||||
</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>
|
||||
|
||||
<key>UTImportedTypeDeclarations</key>
|
||||
@ -60,6 +140,111 @@
|
||||
<string>application/gpx+xml</string>
|
||||
</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>
|
||||
|
||||
</dict>
|
||||
|
11
README.md
@ -1,13 +1,16 @@
|
||||
# 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.
|
||||
* 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 POI files.
|
||||
* Export to PDF.
|
||||
* Full-screen mode
|
||||
* Print/export to PDF.
|
||||
* Full-screen mode.
|
||||
* Native GUI for Windows, Mac OS X and Linux.
|
||||
* Opens GPX, TCX, FIT, KML, IGC, NMEA and Garmin CSV files.
|
||||
|
||||

|
||||
|
||||
|
72
gpxsee.pro
@ -1,18 +1,17 @@
|
||||
TARGET = GPXSee
|
||||
VERSION = 2.20
|
||||
VERSION = 3.8
|
||||
QT += core \
|
||||
gui \
|
||||
network
|
||||
greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
|
||||
greaterThan(QT_MAJOR_VERSION, 4): QT += printsupport
|
||||
lessThan(QT_VERSION, 5.4): QT += opengl
|
||||
macx: QT += opengl
|
||||
HEADERS += src/config.h \
|
||||
src/icons.h \
|
||||
src/gui.h \
|
||||
src/gpx.h \
|
||||
src/parser.h \
|
||||
src/poi.h \
|
||||
src/rtree.h \
|
||||
src/ll.h \
|
||||
src/axisitem.h \
|
||||
src/keys.h \
|
||||
src/slideritem.h \
|
||||
@ -52,13 +51,35 @@ HEADERS += src/config.h \
|
||||
src/graphitem.h \
|
||||
src/graph.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 \
|
||||
src/gui.cpp \
|
||||
src/gpx.cpp \
|
||||
src/parser.cpp \
|
||||
src/poi.cpp \
|
||||
src/ll.cpp \
|
||||
src/axisitem.cpp \
|
||||
src/slideritem.cpp \
|
||||
src/markeritem.cpp \
|
||||
@ -91,19 +112,48 @@ SOURCES += src/main.cpp \
|
||||
src/routeitem.cpp \
|
||||
src/graphitem.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
|
||||
TRANSLATIONS = lang/gpxsee_cs.ts
|
||||
TRANSLATIONS = lang/gpxsee_cs.ts \
|
||||
lang/gpxsee_sv.ts
|
||||
macx {
|
||||
ICON = icons/gpxsee.icns
|
||||
QMAKE_INFO_PLIST = Info.plist
|
||||
APP_RESOURCES.files = icons/gpx.icns \
|
||||
icons/tcx.icns \
|
||||
icons/kml.icns \
|
||||
icons/fit.icns \
|
||||
icons/igc.icns \
|
||||
icons/nmea.icns \
|
||||
pkg/maps.txt
|
||||
APP_RESOURCES.path = Contents/Resources
|
||||
QMAKE_BUNDLE_DATA += APP_RESOURCES
|
||||
}
|
||||
win32 {
|
||||
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\\\"
|
||||
|
@ -15,6 +15,11 @@
|
||||
<file>icons/arrow-right-double.png</file>
|
||||
<file>icons/view-fullscreen.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_sv.qm</file>
|
||||
</qresource>
|
||||
</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 |
1022
lang/gpxsee_sv.ts
Normal file
@ -4,7 +4,7 @@
|
||||
; The name of the installer
|
||||
Name "GPXSee"
|
||||
; Program version
|
||||
!define VERSION "2.20"
|
||||
!define VERSION "3.8"
|
||||
|
||||
; The file to write
|
||||
OutFile "GPXSee-${VERSION}.exe"
|
||||
@ -21,8 +21,13 @@ InstallDirRegKey HKLM "Software\GPXSee" "Install_Dir"
|
||||
|
||||
; Registry key for uninstaller
|
||||
!define REGENTRY "Software\Microsoft\Windows\CurrentVersion\Uninstall\GPXSee"
|
||||
; GPX file type registry entry
|
||||
; File types registry entries
|
||||
!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
|
||||
!define MUI_STARTMENUPAGE_REGISTRY_ROOT "HKLM"
|
||||
@ -62,18 +67,6 @@ Section "GPXSee (required)" SEC_APP
|
||||
; Put the files there
|
||||
File "gpxsee.exe"
|
||||
File "maps.txt"
|
||||
|
||||
; Write the installation path into the registry
|
||||
WriteRegStr HKLM SOFTWARE\GPXSee "Install_Dir" "$INSTDIR"
|
||||
|
||||
; Write the uninstall keys for Windows
|
||||
WriteRegStr HKLM "${REGENTRY}" "DisplayName" "GPXSee"
|
||||
WriteRegStr HKLM "${REGENTRY}" "Publisher" "Martin Tuma"
|
||||
WriteRegStr HKLM "${REGENTRY}" "DisplayVersion" "${VERSION}"
|
||||
WriteRegStr HKLM "${REGENTRY}" "UninstallString" '"$INSTDIR\uninstall.exe"'
|
||||
WriteRegDWORD HKLM "${REGENTRY}" "NoModify" 1
|
||||
WriteRegDWORD HKLM "${REGENTRY}" "NoRepair" 1
|
||||
WriteUninstaller "$INSTDIR\uninstall.exe"
|
||||
|
||||
; Create start menu entry and add links
|
||||
SetShellVarContext all
|
||||
@ -83,11 +76,48 @@ Section "GPXSee (required)" SEC_APP
|
||||
CreateShortCut "$SMPROGRAMS\$StartMenuFolder\GPXSee.lnk" "$INSTDIR\gpxsee.exe"
|
||||
!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 "${REGGPX}" "" "GPS Exchange Format"
|
||||
WriteRegStr HKCR "${REGGPX}\DefaultIcon" "" "$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)'
|
||||
|
||||
SectionEnd
|
||||
@ -100,6 +130,8 @@ Section "QT libs" SEC_QT
|
||||
File "Qt5PrintSupport.dll"
|
||||
File "Qt5Network.dll"
|
||||
File "libGLESv2.dll"
|
||||
File "libEGL.dll"
|
||||
File "D3DCompiler_47.dll"
|
||||
File /r "platforms"
|
||||
File /r "imageformats"
|
||||
File /r "printsupport"
|
||||
@ -149,6 +181,16 @@ Section "Uninstall"
|
||||
; Remove GPX file association
|
||||
DeleteRegKey HKCR "${REGGPX}"
|
||||
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)'
|
||||
|
||||
SectionEnd
|
||||
@ -170,4 +212,4 @@ LangString DESC_APP ${LANG_ENGLISH} \
|
||||
!insertmacro MUI_DESCRIPTION_TEXT ${SEC_QT} $(DESC_QT)
|
||||
!insertmacro MUI_DESCRIPTION_TEXT ${SEC_MSVC} $(DESC_MSVC)
|
||||
!insertmacro MUI_DESCRIPTION_TEXT ${SEC_APP} $(DESC_APP)
|
||||
!insertmacro MUI_FUNCTION_DESCRIPTION_END
|
||||
!insertmacro MUI_FUNCTION_DESCRIPTION_END
|
||||
|
@ -4,7 +4,7 @@
|
||||
; The name of the installer
|
||||
Name "GPXSee"
|
||||
; Program version
|
||||
!define VERSION "2.20"
|
||||
!define VERSION "3.8"
|
||||
|
||||
; The file to write
|
||||
OutFile "GPXSee-${VERSION}_x64.exe"
|
||||
@ -21,8 +21,13 @@ InstallDirRegKey HKLM "Software\GPXSee" "Install_Dir"
|
||||
|
||||
; Registry key for uninstaller
|
||||
!define REGENTRY "Software\Microsoft\Windows\CurrentVersion\Uninstall\GPXSee"
|
||||
; GPX file type registry entry
|
||||
!define REGGPX "GPXSee.gpx"
|
||||
; File types registry entries
|
||||
!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
|
||||
!define MUI_STARTMENUPAGE_REGISTRY_ROOT "HKLM"
|
||||
@ -71,18 +76,6 @@ Section "GPXSee (required)" SEC_APP
|
||||
File "gpxsee.exe"
|
||||
File "maps.txt"
|
||||
|
||||
; Write the installation path into the registry
|
||||
WriteRegStr HKLM SOFTWARE\GPXSee "Install_Dir" "$INSTDIR"
|
||||
|
||||
; Write the uninstall keys for Windows
|
||||
WriteRegStr HKLM "${REGENTRY}" "DisplayName" "GPXSee"
|
||||
WriteRegStr HKLM "${REGENTRY}" "Publisher" "Martin Tuma"
|
||||
WriteRegStr HKLM "${REGENTRY}" "DisplayVersion" "${VERSION}"
|
||||
WriteRegStr HKLM "${REGENTRY}" "UninstallString" '"$INSTDIR\uninstall.exe"'
|
||||
WriteRegDWORD HKLM "${REGENTRY}" "NoModify" 1
|
||||
WriteRegDWORD HKLM "${REGENTRY}" "NoRepair" 1
|
||||
WriteUninstaller "$INSTDIR\uninstall.exe"
|
||||
|
||||
; Create start menu entry and add links
|
||||
SetShellVarContext all
|
||||
!insertmacro MUI_STARTMENU_WRITE_BEGIN Application
|
||||
@ -91,11 +84,48 @@ Section "GPXSee (required)" SEC_APP
|
||||
CreateShortCut "$SMPROGRAMS\$StartMenuFolder\GPXSee.lnk" "$INSTDIR\gpxsee.exe"
|
||||
!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 "${REGGPX}" "" "GPS Exchange Format"
|
||||
WriteRegStr HKCR "${REGGPX}\DefaultIcon" "" "$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)'
|
||||
|
||||
SectionEnd
|
||||
@ -108,6 +138,8 @@ Section "QT libs" SEC_QT
|
||||
File "Qt5PrintSupport.dll"
|
||||
File "Qt5Network.dll"
|
||||
File "libGLESv2.dll"
|
||||
File "libEGL.dll"
|
||||
File "D3DCompiler_47.dll"
|
||||
File /r "platforms"
|
||||
File /r "imageformats"
|
||||
File /r "printsupport"
|
||||
@ -150,9 +182,19 @@ Section "Uninstall"
|
||||
Delete "$SMPROGRAMS\$StartMenuFolder\*.*"
|
||||
RMDir "$SMPROGRAMS\$StartMenuFolder"
|
||||
|
||||
; Remove GPX file association
|
||||
; Remove File associations
|
||||
DeleteRegKey HKCR "${REGGPX}"
|
||||
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)'
|
||||
|
||||
SectionEnd
|
||||
@ -174,4 +216,4 @@ LangString DESC_APP ${LANG_ENGLISH} \
|
||||
!insertmacro MUI_DESCRIPTION_TEXT ${SEC_QT} $(DESC_QT)
|
||||
!insertmacro MUI_DESCRIPTION_TEXT ${SEC_MSVC} $(DESC_MSVC)
|
||||
!insertmacro MUI_DESCRIPTION_TEXT ${SEC_APP} $(DESC_APP)
|
||||
!insertmacro MUI_FUNCTION_DESCRIPTION_END
|
||||
!insertmacro MUI_FUNCTION_DESCRIPTION_END
|
||||
|
@ -3,6 +3,8 @@
|
||||
#include <QLocale>
|
||||
#include <QFileOpenEvent>
|
||||
#include <QNetworkProxyFactory>
|
||||
#include <QPixmapCache>
|
||||
#include "opengl.h"
|
||||
#include "gui.h"
|
||||
#include "app.h"
|
||||
|
||||
@ -20,6 +22,8 @@ App::App(int &argc, char **argv) : QApplication(argc, argv),
|
||||
#endif // Q_OS_MAC
|
||||
|
||||
QNetworkProxyFactory::setUseSystemConfiguration(true);
|
||||
QPixmapCache::setCacheLimit(65536);
|
||||
OPENGL_SET_SAMPLES(4);
|
||||
|
||||
_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);
|
||||
|
||||
|
||||
painter->setRenderHint(QPainter::Antialiasing, false);
|
||||
painter->setFont(font);
|
||||
painter->setPen(pen);
|
||||
|
||||
@ -202,3 +203,16 @@ QSizeF AxisItem::margin() const
|
||||
+ 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);
|
||||
|
||||
QSizeF margin() const;
|
||||
QList<qreal> ticks() const;
|
||||
|
||||
private:
|
||||
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
|
||||
#define GPX_H
|
||||
#ifndef DATA_H
|
||||
#define DATA_H
|
||||
|
||||
#include <QVector>
|
||||
#include <QList>
|
||||
#include <QHash>
|
||||
#include <QPointF>
|
||||
#include <QString>
|
||||
#include "waypoint.h"
|
||||
@ -10,31 +11,34 @@
|
||||
#include "route.h"
|
||||
#include "parser.h"
|
||||
|
||||
class GPX
|
||||
|
||||
class Data
|
||||
{
|
||||
public:
|
||||
GPX();
|
||||
~GPX();
|
||||
Data();
|
||||
~Data();
|
||||
|
||||
bool loadFile(const QString &fileName);
|
||||
const QString &errorString() const {return _error;}
|
||||
const QString &errorString() const {return _errorString;}
|
||||
int errorLine() const {return _errorLine;}
|
||||
|
||||
const QList<Track*> &tracks() const {return _tracks;}
|
||||
const QList<Route*> &routes() const {return _routes;}
|
||||
const QList<Waypoint> &waypoints() const {return _waypoint_data;}
|
||||
const QList<Waypoint> &waypoints() const {return _waypointData;}
|
||||
|
||||
private:
|
||||
Parser _parser;
|
||||
QString _error;
|
||||
void createData();
|
||||
|
||||
QString _errorString;
|
||||
int _errorLine;
|
||||
QHash<QString, Parser*> _parsers;
|
||||
|
||||
QList<Track*> _tracks;
|
||||
QList<Route*> _routes;
|
||||
|
||||
QList<QVector<Trackpoint> > _track_data;
|
||||
QList<QVector<Waypoint> > _route_data;
|
||||
QList<Waypoint> _waypoint_data;
|
||||
QList<TrackData> _trackData;
|
||||
QList<RouteData> _routeData;
|
||||
QList<Waypoint> _waypointData;
|
||||
};
|
||||
|
||||
#endif // GPX_H
|
||||
#endif // DATA_H
|
@ -17,25 +17,39 @@
|
||||
#define USER_AGENT \
|
||||
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()
|
||||
{
|
||||
connect(&_manager, SIGNAL(finished(QNetworkReply*)),
|
||||
SLOT(downloadFinished(QNetworkReply*)));
|
||||
}
|
||||
|
||||
bool Downloader::doDownload(const Download &dl)
|
||||
bool Downloader::doDownload(const Download &dl, const Redirect &redirect)
|
||||
{
|
||||
QUrl url(dl.url());
|
||||
|
||||
if (_errorDownloads.contains(url))
|
||||
return false;
|
||||
if (_currentDownloads.contains(url))
|
||||
return false;
|
||||
|
||||
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);
|
||||
QNetworkReply *reply = _manager.get(request);
|
||||
|
||||
_currentDownloads.append(reply);
|
||||
_currentDownloads.insert(url, reply);
|
||||
|
||||
return true;
|
||||
}
|
||||
@ -58,26 +72,49 @@ bool Downloader::saveToDisk(const QString &filename, QIODevice *data)
|
||||
|
||||
void Downloader::downloadFinished(QNetworkReply *reply)
|
||||
{
|
||||
QUrl url = reply->url();
|
||||
QUrl url = reply->request().url();
|
||||
|
||||
if (reply->error()) {
|
||||
_errorDownloads.insert(url);
|
||||
fprintf(stderr, "Error downloading map tile: %s: %s\n",
|
||||
url.toEncoded().constData(), qPrintable(reply->errorString()));
|
||||
QUrl origin = reply->request().attribute(ATTR_ORIGIN).toUrl();
|
||||
if (origin.isEmpty()) {
|
||||
_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 {
|
||||
QUrl redirect = reply->attribute(
|
||||
QNetworkRequest::RedirectionTargetAttribute).toUrl();
|
||||
QString filename = reply->request().attribute(QNetworkRequest::User)
|
||||
QUrl location = reply->attribute(ATTR_REDIRECT).toUrl();
|
||||
QString filename = reply->request().attribute(ATTR_FILE)
|
||||
.toString();
|
||||
|
||||
if (!redirect.isEmpty()) {
|
||||
Download dl(redirect, filename);
|
||||
doDownload(dl);
|
||||
if (!location.isEmpty()) {
|
||||
QUrl origin = reply->request().attribute(ATTR_ORIGIN).toUrl();
|
||||
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
|
||||
if (!saveToDisk(filename, reply))
|
||||
_errorDownloads.insert(url);
|
||||
}
|
||||
|
||||
_currentDownloads.removeAll(reply);
|
||||
_currentDownloads.remove(url);
|
||||
reply->deleteLater();
|
||||
|
||||
if (_currentDownloads.isEmpty())
|
||||
|
@ -5,7 +5,7 @@
|
||||
#include <QNetworkRequest>
|
||||
#include <QNetworkReply>
|
||||
#include <QUrl>
|
||||
#include <QList>
|
||||
#include <QMap>
|
||||
#include <QSet>
|
||||
|
||||
|
||||
@ -39,15 +39,32 @@ private slots:
|
||||
void downloadFinished(QNetworkReply *reply);
|
||||
|
||||
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 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);
|
||||
|
||||
QNetworkAccessManager _manager;
|
||||
QList<QNetworkReply *> _currentDownloads;
|
||||
QMap<QUrl, QNetworkReply *> _currentDownloads;
|
||||
QSet<QUrl> _errorDownloads;
|
||||
};
|
||||
|
||||
|
@ -1,6 +1,6 @@
|
||||
#include <cmath>
|
||||
#include "config.h"
|
||||
#include "gpx.h"
|
||||
#include "data.h"
|
||||
#include "elevationgraph.h"
|
||||
|
||||
|
||||
@ -107,14 +107,14 @@ void ElevationGraph::loadGraph(const Graph &graph, Type type, PathItem *path)
|
||||
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;
|
||||
|
||||
for (int i = 0; i < gpx.tracks().count(); i++)
|
||||
loadGraph(gpx.tracks().at(i)->elevation(), Track, paths.at(p++));
|
||||
for (int i = 0; i < gpx.routes().count(); i++)
|
||||
loadGraph(gpx.routes().at(i)->elevation(), Route, paths.at(p++));
|
||||
for (int i = 0; i < data.tracks().count(); i++)
|
||||
loadGraph(data.tracks().at(i)->elevation(), Track, paths.at(p++));
|
||||
for (int i = 0; i < data.routes().count(); i++)
|
||||
loadGraph(data.routes().at(i)->elevation(), Route, paths.at(p++));
|
||||
|
||||
setInfo();
|
||||
|
||||
|
@ -11,7 +11,7 @@ public:
|
||||
ElevationGraph(QWidget *parent = 0);
|
||||
|
||||
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 setUnits(enum Units units);
|
||||
void showTracks(bool show);
|
||||
|
@ -11,23 +11,19 @@
|
||||
#include <QMessageBox>
|
||||
#include <QTabWidget>
|
||||
#include <QDoubleSpinBox>
|
||||
#include <QLocale>
|
||||
#include "fileselectwidget.h"
|
||||
#include "units.h"
|
||||
#include "exportdialog.h"
|
||||
|
||||
|
||||
ExportDialog::ExportDialog(QPrinter *printer, QWidget *parent)
|
||||
: QDialog(parent), _printer(printer)
|
||||
ExportDialog::ExportDialog(Export *exp, QWidget *parent)
|
||||
: QDialog(parent), _export(exp)
|
||||
{
|
||||
int index;
|
||||
|
||||
_units = (QLocale::system().measurementSystem()
|
||||
== QLocale::ImperialSystem) ? QPrinter::Inch : QPrinter::Millimeter;
|
||||
|
||||
_fileSelect = new FileSelectWidget();
|
||||
_fileSelect->setFilter(tr("PDF files (*.pdf);;All files (*)"));
|
||||
_fileSelect->setFile(_printer->outputFileName());
|
||||
_fileSelect->setFile(_export->fileName);
|
||||
|
||||
_paperSize = new QComboBox();
|
||||
_paperSize->addItem("A3", QPrinter::A3);
|
||||
@ -36,7 +32,7 @@ ExportDialog::ExportDialog(QPrinter *printer, QWidget *parent)
|
||||
_paperSize->addItem("Tabloid", QPrinter::Tabloid);
|
||||
_paperSize->addItem("Legal", QPrinter::Legal);
|
||||
_paperSize->addItem("Letter", QPrinter::Letter);
|
||||
if ((index = _paperSize->findData(_printer->paperSize())) >= 0)
|
||||
if ((index = _paperSize->findData(_export->paperSize)) >= 0)
|
||||
_paperSize->setCurrentIndex(index);
|
||||
|
||||
_portrait = new QRadioButton(tr("Portrait"));
|
||||
@ -44,32 +40,34 @@ ExportDialog::ExportDialog(QPrinter *printer, QWidget *parent)
|
||||
QHBoxLayout *orientationLayout = new QHBoxLayout();
|
||||
orientationLayout->addWidget(_portrait);
|
||||
orientationLayout->addWidget(_landscape);
|
||||
if (_printer->orientation() == QPrinter::Portrait)
|
||||
if (_export->orientation == QPrinter::Portrait)
|
||||
_portrait->setChecked(true);
|
||||
else
|
||||
_landscape->setChecked(true);
|
||||
|
||||
qreal top, bottom, left, right;
|
||||
|
||||
_printer->getPageMargins(&left, &top, &right, &bottom, _units);
|
||||
QString us = _units == QPrinter::Inch ? tr("in") : tr("mm");
|
||||
_topMargin = new QDoubleSpinBox();
|
||||
_bottomMargin = new QDoubleSpinBox();
|
||||
_leftMargin = new QDoubleSpinBox();
|
||||
_rightMargin = new QDoubleSpinBox();
|
||||
_topMargin->setValue(top);
|
||||
QString us = (_export->units == Imperial) ? tr("in") : tr("mm");
|
||||
_topMargin->setSuffix(UNIT_SPACE + us);
|
||||
_bottomMargin->setValue(bottom);
|
||||
_bottomMargin->setSuffix(UNIT_SPACE + us);
|
||||
_leftMargin->setValue(left);
|
||||
_leftMargin->setSuffix(UNIT_SPACE + us);
|
||||
_rightMargin->setValue(right);
|
||||
_rightMargin->setSuffix(UNIT_SPACE + us);
|
||||
if (_units == QPrinter::Inch) {
|
||||
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);
|
||||
_bottomMargin->setSingleStep(0.1);
|
||||
_leftMargin->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();
|
||||
@ -164,12 +162,16 @@ void ExportDialog::accept()
|
||||
QPrinter::PaperSize paperSize = static_cast<QPrinter::PaperSize>
|
||||
(_paperSize->itemData(_paperSize->currentIndex()).toInt());
|
||||
|
||||
_printer->setOutputFormat(QPrinter::PdfFormat);
|
||||
_printer->setOutputFileName(_fileSelect->file());
|
||||
_printer->setPaperSize(paperSize);
|
||||
_printer->setOrientation(orientation);
|
||||
_printer->setPageMargins(_leftMargin->value(), _topMargin->value(),
|
||||
_rightMargin->value(), _bottomMargin->value(), _units);
|
||||
_export->fileName = _fileSelect->file();
|
||||
_export->paperSize = paperSize;
|
||||
_export->orientation = orientation;
|
||||
if (_export->units == Imperial)
|
||||
_export->margins = MarginsF(_leftMargin->value() / MM2IN,
|
||||
_topMargin->value() / MM2IN, _rightMargin->value() / MM2IN,
|
||||
_bottomMargin->value() / MM2IN);
|
||||
else
|
||||
_export->margins = MarginsF(_leftMargin->value(), _topMargin->value(),
|
||||
_rightMargin->value(), _bottomMargin->value());
|
||||
|
||||
QDialog::accept();
|
||||
}
|
||||
|
@ -3,18 +3,29 @@
|
||||
|
||||
#include <QDialog>
|
||||
#include <QPrinter>
|
||||
#include "margins.h"
|
||||
#include "units.h"
|
||||
|
||||
class QComboBox;
|
||||
class QRadioButton;
|
||||
class FileSelectWidget;
|
||||
class QDoubleSpinBox;
|
||||
|
||||
struct Export {
|
||||
QString fileName;
|
||||
QPrinter::PaperSize paperSize;
|
||||
QPrinter::Orientation orientation;
|
||||
MarginsF margins;
|
||||
|
||||
Units units;
|
||||
};
|
||||
|
||||
class ExportDialog : public QDialog
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
ExportDialog(QPrinter *printer, QWidget *parent = 0);
|
||||
ExportDialog(Export *exp, QWidget *parent = 0);
|
||||
|
||||
public slots:
|
||||
void accept();
|
||||
@ -22,9 +33,7 @@ public slots:
|
||||
private:
|
||||
bool checkFile();
|
||||
|
||||
QPrinter *_printer;
|
||||
|
||||
QPrinter::Unit _units;
|
||||
Export *_export;
|
||||
|
||||
FileSelectWidget *_fileSelect;
|
||||
QComboBox *_paperSize;
|
||||
|
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();
|
||||
}
|
22
src/graph.h
@ -2,6 +2,7 @@
|
||||
#define GRAPH_H
|
||||
|
||||
#include <QVector>
|
||||
#include <QDebug>
|
||||
#include <cmath>
|
||||
|
||||
enum GraphType {Distance, Time};
|
||||
@ -27,6 +28,25 @@ private:
|
||||
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
|
||||
|
@ -2,29 +2,19 @@
|
||||
#include "graphitem.h"
|
||||
|
||||
|
||||
#define GRAPH_WIDTH 1
|
||||
#define HOVER_WIDTH 2
|
||||
|
||||
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)
|
||||
: QGraphicsObject(parent)
|
||||
{
|
||||
_id = 0;
|
||||
_width = 1;
|
||||
|
||||
_pen = QPen(Qt::black, GRAPH_WIDTH);
|
||||
_pen = QPen(Qt::black, _width);
|
||||
|
||||
_type = Distance;
|
||||
_graph = graph;
|
||||
_sx = 1.0; _sy = 1.0;
|
||||
_time = hasTime(_graph);
|
||||
|
||||
setZValue(1.0);
|
||||
|
||||
updatePath();
|
||||
updateBounds();
|
||||
@ -61,6 +51,14 @@ void GraphItem::setColor(const QColor &color)
|
||||
update();
|
||||
}
|
||||
|
||||
void GraphItem::setWidth(int width)
|
||||
{
|
||||
prepareGeometryChange();
|
||||
|
||||
_width = width;
|
||||
_pen.setWidth(width);
|
||||
}
|
||||
|
||||
qreal GraphItem::yAtX(qreal x)
|
||||
{
|
||||
int low = 0;
|
||||
@ -126,13 +124,13 @@ qreal GraphItem::distanceAtTime(qreal time)
|
||||
void GraphItem::emitSliderPositionChanged(qreal pos)
|
||||
{
|
||||
if (_type == Time) {
|
||||
if (_time) {
|
||||
if (pos <= _graph.last().t())
|
||||
if (_graph.hasTime()) {
|
||||
if (pos >= _graph.first().t() && pos <= _graph.last().t())
|
||||
emit sliderPositionChanged(distanceAtTime(pos));
|
||||
else
|
||||
emit sliderPositionChanged(_graph.last().s() + 1);
|
||||
emit sliderPositionChanged(NAN);
|
||||
} else
|
||||
emit sliderPositionChanged(_graph.last().s() + 1);
|
||||
emit sliderPositionChanged(NAN);
|
||||
} else
|
||||
emit sliderPositionChanged(pos);
|
||||
}
|
||||
@ -140,10 +138,10 @@ void GraphItem::emitSliderPositionChanged(qreal pos)
|
||||
void GraphItem::selected(bool selected)
|
||||
{
|
||||
if (selected) {
|
||||
_pen.setWidth(HOVER_WIDTH);
|
||||
_pen.setWidth(_width + 1);
|
||||
setZValue(zValue() + 1.0);
|
||||
} else {
|
||||
_pen.setWidth(GRAPH_WIDTH);
|
||||
_pen.setWidth(_width);
|
||||
setZValue(zValue() - 1.0);
|
||||
}
|
||||
|
||||
@ -165,7 +163,7 @@ void GraphItem::updatePath()
|
||||
{
|
||||
_path = QPainterPath();
|
||||
|
||||
if (_type == Time && !_time)
|
||||
if (_type == Time && !_graph.hasTime())
|
||||
return;
|
||||
|
||||
_path.moveTo(_graph.first().x(_type) * _sx, -_graph.first().y() * _sy);
|
||||
@ -175,7 +173,7 @@ void GraphItem::updatePath()
|
||||
|
||||
void GraphItem::updateBounds()
|
||||
{
|
||||
if (_type == Time && !_time) {
|
||||
if (_type == Time && !_graph.hasTime()) {
|
||||
_bounds = QRectF();
|
||||
return;
|
||||
}
|
||||
|
@ -24,6 +24,7 @@ public:
|
||||
int id() const {return _id;}
|
||||
void setId(int id) {_id = id;}
|
||||
void setColor(const QColor &color);
|
||||
void setWidth(int width);
|
||||
|
||||
qreal yAtX(qreal x);
|
||||
qreal distanceAtTime(qreal time);
|
||||
@ -41,10 +42,10 @@ private:
|
||||
|
||||
int _id;
|
||||
QPen _pen;
|
||||
int _width;
|
||||
|
||||
Graph _graph;
|
||||
GraphType _type;
|
||||
bool _time;
|
||||
|
||||
QPainterPath _path;
|
||||
QRectF _bounds;
|
||||
|
@ -5,7 +5,7 @@
|
||||
#include "graphview.h"
|
||||
#include "units.h"
|
||||
|
||||
class GPX;
|
||||
class Data;
|
||||
class PathItem;
|
||||
|
||||
class GraphTab : public GraphView
|
||||
@ -17,7 +17,7 @@ public:
|
||||
{setFrameShape(QFrame::NoFrame);}
|
||||
|
||||
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 setUnits(enum Units units) = 0;
|
||||
virtual void showTracks(bool show) = 0;
|
||||
|
@ -1,12 +1,16 @@
|
||||
#include <QGraphicsSceneMouseEvent>
|
||||
#include <QGraphicsScene>
|
||||
#include <QEvent>
|
||||
#include <QMouseEvent>
|
||||
#include <QPaintEngine>
|
||||
#include <QPaintDevice>
|
||||
#include <QSysInfo>
|
||||
#include "opengl.h"
|
||||
#include "config.h"
|
||||
#include "axisitem.h"
|
||||
#include "slideritem.h"
|
||||
#include "sliderinfoitem.h"
|
||||
#include "infoitem.h"
|
||||
#include "griditem.h"
|
||||
#include "graph.h"
|
||||
#include "graphitem.h"
|
||||
#include "pathitem.h"
|
||||
@ -15,39 +19,32 @@
|
||||
|
||||
#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)
|
||||
: QGraphicsView(parent)
|
||||
{
|
||||
_scene = new Scene(this);
|
||||
_scene = new QGraphicsScene(this);
|
||||
setScene(_scene);
|
||||
|
||||
setViewportUpdateMode(QGraphicsView::FullViewportUpdate);
|
||||
setRenderHint(QPainter::Antialiasing, true);
|
||||
setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
|
||||
setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
|
||||
|
||||
_xAxis = new AxisItem(AxisItem::X);
|
||||
_xAxis->setZValue(1.0);
|
||||
_xAxis->setZValue(2.0);
|
||||
_yAxis = new AxisItem(AxisItem::Y);
|
||||
_yAxis->setZValue(1.0);
|
||||
_yAxis->setZValue(2.0);
|
||||
_slider = new SliderItem();
|
||||
_slider->setZValue(2.0);
|
||||
_slider->setZValue(3.0);
|
||||
_sliderInfo = new SliderInfoItem(_slider);
|
||||
_sliderInfo->setZValue(2.0);
|
||||
_sliderInfo->setZValue(3.0);
|
||||
_info = new InfoItem();
|
||||
_grid = new GridItem();
|
||||
|
||||
connect(_slider, SIGNAL(positionChanged(const QPointF&)), this,
|
||||
SLOT(emitSliderPositionChanged(const QPointF&)));
|
||||
connect(_scene, SIGNAL(mouseClicked(const QPointF&)), this,
|
||||
SLOT(newSliderPosition(const QPointF&)));
|
||||
|
||||
_width = 1;
|
||||
|
||||
_xScale = 1;
|
||||
_yScale = 1;
|
||||
@ -60,9 +57,7 @@ GraphView::GraphView(QWidget *parent)
|
||||
|
||||
_units = Metric;
|
||||
_graphType = Distance;
|
||||
|
||||
setGraphType(_graphType);
|
||||
setUnits(_units);
|
||||
_xLabel = tr("Distance");
|
||||
}
|
||||
|
||||
GraphView::~GraphView()
|
||||
@ -75,6 +70,8 @@ GraphView::~GraphView()
|
||||
delete _slider;
|
||||
if (_info->scene() != _scene)
|
||||
delete _info;
|
||||
if (_grid->scene() != _scene)
|
||||
delete _grid;
|
||||
|
||||
for (int i = 0; i < _graphs.count(); i++)
|
||||
if (_graphs.at(i)->scene() != _scene)
|
||||
@ -165,6 +162,11 @@ void GraphView::setGraphType(GraphType type)
|
||||
redraw();
|
||||
}
|
||||
|
||||
void GraphView::showGrid(bool show)
|
||||
{
|
||||
_grid->setVisible(show);
|
||||
}
|
||||
|
||||
void GraphView::loadGraph(const Graph &graph, PathItem *path, int id)
|
||||
{
|
||||
if (graph.size() < 2)
|
||||
@ -173,7 +175,8 @@ void GraphView::loadGraph(const Graph &graph, PathItem *path, int id)
|
||||
GraphItem *gi = new GraphItem(graph);
|
||||
gi->setGraphType(_graphType);
|
||||
gi->setId(id);
|
||||
gi->setColor(_palette.color());
|
||||
gi->setColor(_palette.nextColor());
|
||||
gi->setWidth(_width);
|
||||
|
||||
connect(this, SIGNAL(sliderPositionChanged(qreal)), gi,
|
||||
SLOT(emitSliderPositionChanged(qreal)));
|
||||
@ -249,6 +252,7 @@ void GraphView::redraw(const QSizeF &size)
|
||||
removeItem(_yAxis);
|
||||
removeItem(_slider);
|
||||
removeItem(_info);
|
||||
removeItem(_grid);
|
||||
_scene->setSceneRect(QRectF());
|
||||
return;
|
||||
}
|
||||
@ -257,6 +261,7 @@ void GraphView::redraw(const QSizeF &size)
|
||||
addItem(_yAxis);
|
||||
addItem(_slider);
|
||||
addItem(_info);
|
||||
addItem(_grid);
|
||||
|
||||
rx = RangeF(bounds().left() * _xScale, bounds().right() * _xScale);
|
||||
ry = RangeF(bounds().top() * _yScale + _yOffset, bounds().bottom() * _yScale
|
||||
@ -293,6 +298,10 @@ void GraphView::redraw(const QSizeF &size)
|
||||
_xAxis->setPos(r.bottomLeft());
|
||||
_yAxis->setPos(r.bottomLeft());
|
||||
|
||||
_grid->setSize(r.size());
|
||||
_grid->setTicks(_xAxis->ticks(), _yAxis->ticks());
|
||||
_grid->setPos(r.bottomLeft());
|
||||
|
||||
_slider->setArea(r);
|
||||
updateSliderPosition();
|
||||
|
||||
@ -309,6 +318,14 @@ void GraphView::resizeEvent(QResizeEvent *)
|
||||
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)
|
||||
{
|
||||
qreal ratio = painter->paintEngine()->paintDevice()->logicalDpiX()
|
||||
@ -390,6 +407,8 @@ void GraphView::emitSliderPositionChanged(const QPointF &pos)
|
||||
return;
|
||||
|
||||
_sliderPos = (pos.x() / _slider->area().width()) * bounds().width();
|
||||
_sliderPos = qMax(_sliderPos, bounds().left());
|
||||
_sliderPos = qMin(_sliderPos, bounds().right());
|
||||
updateSliderPosition();
|
||||
|
||||
emit sliderPositionChanged(_sliderPos);
|
||||
@ -419,3 +438,31 @@ void GraphView::clearInfo()
|
||||
{
|
||||
_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
|
||||
|
||||
#include <QGraphicsView>
|
||||
#include <QGraphicsScene>
|
||||
#include <QVector>
|
||||
#include <QList>
|
||||
#include <QSet>
|
||||
#include <QPointF>
|
||||
#include "palette.h"
|
||||
#include "units.h"
|
||||
#include "graph.h"
|
||||
@ -18,18 +15,7 @@ class SliderInfoItem;
|
||||
class InfoItem;
|
||||
class GraphItem;
|
||||
class PathItem;
|
||||
|
||||
class Scene : public QGraphicsScene
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
Scene(QObject *parent = 0) : QGraphicsScene(parent) {}
|
||||
void mousePressEvent(QGraphicsSceneMouseEvent *e);
|
||||
|
||||
signals:
|
||||
void mouseClicked(const QPointF &pos);
|
||||
};
|
||||
class GridItem;
|
||||
|
||||
class GraphView : public QGraphicsView
|
||||
{
|
||||
@ -47,6 +33,10 @@ public:
|
||||
void showGraph(bool show, int id = 0);
|
||||
void setGraphType(GraphType type);
|
||||
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 &yUnits() const {return _yUnits;}
|
||||
@ -65,6 +55,8 @@ public:
|
||||
|
||||
void plot(QPainter *painter, const QRectF &target);
|
||||
|
||||
void useOpenGL(bool use);
|
||||
|
||||
signals:
|
||||
void sliderPositionChanged(qreal);
|
||||
|
||||
@ -73,8 +65,7 @@ protected:
|
||||
void redraw(const QSizeF &size);
|
||||
void addInfo(const QString &key, const QString &value);
|
||||
void clearInfo();
|
||||
void skipColor() {_palette.color();}
|
||||
void resizeEvent(QResizeEvent *);
|
||||
void skipColor() {_palette.nextColor();}
|
||||
|
||||
private slots:
|
||||
void emitSliderPositionChanged(const QPointF &pos);
|
||||
@ -89,6 +80,9 @@ private:
|
||||
void removeItem(QGraphicsItem *item);
|
||||
void addItem(QGraphicsItem *item);
|
||||
|
||||
void resizeEvent(QResizeEvent *);
|
||||
void mousePressEvent(QMouseEvent *);
|
||||
|
||||
qreal _xScale, _yScale;
|
||||
qreal _yOffset;
|
||||
QString _xUnits, _yUnits;
|
||||
@ -97,18 +91,20 @@ private:
|
||||
qreal _minYRange;
|
||||
qreal _sliderPos;
|
||||
|
||||
Scene *_scene;
|
||||
QGraphicsScene *_scene;
|
||||
|
||||
AxisItem *_xAxis, *_yAxis;
|
||||
SliderItem *_slider;
|
||||
SliderInfoItem *_sliderInfo;
|
||||
InfoItem *_info;
|
||||
GridItem *_grid;
|
||||
|
||||
QList<GraphItem*> _graphs;
|
||||
QList<GraphItem*> _visible;
|
||||
QSet<int> _hide;
|
||||
QRectF _bounds;
|
||||
Palette _palette;
|
||||
int _width;
|
||||
|
||||
Units _units;
|
||||
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
|
595
src/gui.cpp
@ -1,4 +1,5 @@
|
||||
#include <QApplication>
|
||||
#include <QSplitter>
|
||||
#include <QVBoxLayout>
|
||||
#include <QMenuBar>
|
||||
#include <QStatusBar>
|
||||
@ -20,25 +21,25 @@
|
||||
#include <QLocale>
|
||||
#include <QMimeData>
|
||||
#include <QUrl>
|
||||
#include <QPixmapCache>
|
||||
#include "config.h"
|
||||
#include "icons.h"
|
||||
#include "keys.h"
|
||||
#include "settings.h"
|
||||
#include "gpx.h"
|
||||
#include "data.h"
|
||||
#include "map.h"
|
||||
#include "maplist.h"
|
||||
#include "elevationgraph.h"
|
||||
#include "speedgraph.h"
|
||||
#include "heartrategraph.h"
|
||||
#include "temperaturegraph.h"
|
||||
#include "cadencegraph.h"
|
||||
#include "powergraph.h"
|
||||
#include "pathview.h"
|
||||
#include "trackinfo.h"
|
||||
#include "filebrowser.h"
|
||||
#include "cpuarch.h"
|
||||
#include "exportdialog.h"
|
||||
#include "graphtab.h"
|
||||
#include "misc.h"
|
||||
#include "format.h"
|
||||
#include "gui.h"
|
||||
|
||||
|
||||
@ -54,24 +55,22 @@ GUI::GUI(QWidget *parent) : QMainWindow(parent)
|
||||
createMenus();
|
||||
createToolBars();
|
||||
|
||||
_browser = new FileBrowser(this);
|
||||
_browser->setFilter(QStringList("*.gpx"));
|
||||
createBrowser();
|
||||
|
||||
QVBoxLayout *layout = new QVBoxLayout;
|
||||
layout->addWidget(_pathView);
|
||||
layout->addWidget(_graphTabWidget);
|
||||
layout->setContentsMargins(0, 0, 0, 0);
|
||||
#ifdef Q_OS_WIN32
|
||||
layout->setSpacing(0);
|
||||
#endif // Q_OS_WIN32
|
||||
|
||||
QWidget *widget = new QWidget;
|
||||
widget->setLayout(layout);
|
||||
setCentralWidget(widget);
|
||||
QSplitter *splitter = new QSplitter();
|
||||
splitter->setOrientation(Qt::Vertical);
|
||||
splitter->setChildrenCollapsible(false);
|
||||
splitter->addWidget(_pathView);
|
||||
splitter->addWidget(_graphTabWidget);
|
||||
splitter->setContentsMargins(0, 0, 0, 0);
|
||||
splitter->setStretchFactor(0, 255);
|
||||
splitter->setStretchFactor(1, 1);
|
||||
setCentralWidget(splitter);
|
||||
|
||||
setWindowIcon(QIcon(QPixmap(APP_ICON)));
|
||||
setWindowTitle(APP_NAME);
|
||||
setUnifiedTitleAndToolBarOnMac(true);
|
||||
setAcceptDrops(true);
|
||||
|
||||
_trackCount = 0;
|
||||
_routeCount = 0;
|
||||
@ -83,19 +82,10 @@ GUI::GUI(QWidget *parent) : QMainWindow(parent)
|
||||
_sliderPos = 0;
|
||||
|
||||
updateGraphTabs();
|
||||
updateTrackView();
|
||||
updatePathView();
|
||||
updateStatusBarInfo();
|
||||
|
||||
readSettings();
|
||||
|
||||
_exportPaperSize = (QLocale::system().measurementSystem()
|
||||
== QLocale::ImperialSystem) ? QPrinter::Letter : QPrinter::A4;
|
||||
_exportOrientation = QPrinter::Portrait;
|
||||
_exportFileName = QString("%1/export.pdf").arg(QDir::currentPath());
|
||||
_exportMargins = MarginsF(5.0, 5.0, 5.0, 5.0);
|
||||
|
||||
setAcceptDrops(true);
|
||||
QPixmapCache::setCacheLimit(65536);
|
||||
}
|
||||
|
||||
GUI::~GUI()
|
||||
@ -106,6 +96,24 @@ GUI::~GUI()
|
||||
}
|
||||
}
|
||||
|
||||
const QString GUI::fileFormats() const
|
||||
{
|
||||
return tr("Supported files (*.csv *.fit *.gpx *.igc *.kml *.nmea *.tcx)")
|
||||
+ ";;" + tr("CSV files (*.csv)") + ";;" + tr("FIT files (*.fit)") + ";;"
|
||||
+ tr("GPX files (*.gpx)") + ";;" + tr("IGC files (*.igc)") + ";;"
|
||||
+ tr("KML files (*.kml)") + ";;" + tr("NMEA files (*.nmea)") + ";;"
|
||||
+ tr("TCX files (*.tcx)") + ";;" + tr("All files (*)");
|
||||
}
|
||||
|
||||
void GUI::createBrowser()
|
||||
{
|
||||
QStringList filter;
|
||||
filter << "*.gpx" << "*.tcx" << "*.kml" << "*.fit" << "*.csv" << "*.igc"
|
||||
<< "*.nmea";
|
||||
_browser = new FileBrowser(this);
|
||||
_browser->setFilter(filter);
|
||||
}
|
||||
|
||||
void GUI::loadMaps()
|
||||
{
|
||||
if (QFile::exists(USER_MAP_FILE))
|
||||
@ -127,8 +135,15 @@ void GUI::loadPOIs()
|
||||
else
|
||||
list = globalDir.entryInfoList(QStringList(), QDir::Files);
|
||||
|
||||
for (int i = 0; i < list.size(); ++i)
|
||||
_poi->loadFile(list.at(i).absoluteFilePath());
|
||||
for (int i = 0; i < list.size(); ++i) {
|
||||
if (!_poi->loadFile(list.at(i).absoluteFilePath())) {
|
||||
fprintf(stderr, "Error loading POI file: %s: %s\n",
|
||||
qPrintable(list.at(i).fileName()),
|
||||
qPrintable(_poi->errorString()));
|
||||
if (_poi->errorLine())
|
||||
fprintf(stderr, "Line: %d\n", _poi->errorLine());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void GUI::createMapActions()
|
||||
@ -180,7 +195,6 @@ void GUI::createActions()
|
||||
{
|
||||
QActionGroup *ag;
|
||||
|
||||
|
||||
// Action Groups
|
||||
_fileActionGroup = new QActionGroup(this);
|
||||
_fileActionGroup->setExclusive(false);
|
||||
@ -322,12 +336,18 @@ void GUI::createActions()
|
||||
_distanceGraphAction->setShortcut(DISTANCE_GRAPH_SHORTCUT);
|
||||
connect(_distanceGraphAction, SIGNAL(triggered()), this,
|
||||
SLOT(setDistanceGraph()));
|
||||
addAction(_distanceGraphAction);
|
||||
_timeGraphAction = new QAction(tr("Time"), this);
|
||||
_timeGraphAction->setCheckable(true);
|
||||
_timeGraphAction->setActionGroup(ag);
|
||||
_timeGraphAction->setShortcut(TIME_GRAPH_SHORTCUT);
|
||||
connect(_timeGraphAction, SIGNAL(triggered()), this,
|
||||
SLOT(setTimeGraph()));
|
||||
addAction(_timeGraphAction);
|
||||
_showGraphGridAction = new QAction(tr("Show grid"), this);
|
||||
_showGraphGridAction->setCheckable(true);
|
||||
connect(_showGraphGridAction, SIGNAL(triggered(bool)), this,
|
||||
SLOT(showGraphGrids(bool)));
|
||||
|
||||
// Settings actions
|
||||
_showToolbarsAction = new QAction(tr("Show toolbars"), this);
|
||||
@ -353,6 +373,9 @@ void GUI::createActions()
|
||||
connect(_fullscreenAction, SIGNAL(triggered(bool)), this,
|
||||
SLOT(showFullscreen(bool)));
|
||||
addAction(_fullscreenAction);
|
||||
_openOptionsAction = new QAction(tr("Options..."), this);
|
||||
connect(_openOptionsAction, SIGNAL(triggered()), this,
|
||||
SLOT(openOptions()));
|
||||
|
||||
// Navigation actions
|
||||
_nextAction = new QAction(QIcon(QPixmap(NEXT_FILE_ICON)), tr("Next"), this);
|
||||
@ -398,6 +421,8 @@ void GUI::createMenus()
|
||||
graphMenu->addAction(_distanceGraphAction);
|
||||
graphMenu->addAction(_timeGraphAction);
|
||||
graphMenu->addSeparator();
|
||||
graphMenu->addAction(_showGraphGridAction);
|
||||
graphMenu->addSeparator();
|
||||
graphMenu->addAction(_showGraphsAction);
|
||||
|
||||
QMenu *poiMenu = menuBar()->addMenu(tr("POI"));
|
||||
@ -427,8 +452,9 @@ void GUI::createMenus()
|
||||
unitsMenu->addAction(_imperialUnitsAction);
|
||||
settingsMenu->addSeparator();
|
||||
settingsMenu->addAction(_showToolbarsAction);
|
||||
settingsMenu->addSeparator();
|
||||
settingsMenu->addAction(_fullscreenAction);
|
||||
settingsMenu->addSeparator();
|
||||
settingsMenu->addAction(_openOptionsAction);
|
||||
|
||||
QMenu *helpMenu = menuBar()->addMenu(tr("Help"));
|
||||
helpMenu->addAction(_dataSourcesAction);
|
||||
@ -464,6 +490,9 @@ void GUI::createToolBars()
|
||||
void GUI::createPathView()
|
||||
{
|
||||
_pathView = new PathView(this);
|
||||
_pathView->setSizePolicy(QSizePolicy(QSizePolicy::Ignored,
|
||||
QSizePolicy::Expanding));
|
||||
_pathView->setMinimumHeight(200);
|
||||
#ifdef Q_OS_WIN32
|
||||
_pathView->setFrameShape(QFrame::NoFrame);
|
||||
#endif // Q_OS_WIN32
|
||||
@ -473,13 +502,13 @@ void GUI::createPathView()
|
||||
|
||||
void GUI::createGraphTabs()
|
||||
{
|
||||
_graphTabWidget = new QTabWidget;
|
||||
_graphTabWidget = new QTabWidget();
|
||||
connect(_graphTabWidget, SIGNAL(currentChanged(int)), this,
|
||||
SLOT(graphChanged(int)));
|
||||
|
||||
_graphTabWidget->setFixedHeight(200);
|
||||
_graphTabWidget->setSizePolicy(
|
||||
QSizePolicy(QSizePolicy::Ignored, QSizePolicy::Fixed));
|
||||
_graphTabWidget->setSizePolicy(QSizePolicy(QSizePolicy::Ignored,
|
||||
QSizePolicy::Preferred));
|
||||
_graphTabWidget->setMinimumHeight(200);
|
||||
#ifdef Q_OS_WIN32
|
||||
_graphTabWidget->setDocumentMode(true);
|
||||
#endif // Q_OS_WIN32
|
||||
@ -487,6 +516,8 @@ void GUI::createGraphTabs()
|
||||
_tabs.append(new ElevationGraph);
|
||||
_tabs.append(new SpeedGraph);
|
||||
_tabs.append(new HeartRateGraph);
|
||||
_tabs.append(new CadenceGraph);
|
||||
_tabs.append(new PowerGraph);
|
||||
_tabs.append(new TemperatureGraph);
|
||||
|
||||
for (int i = 0; i < _tabs.count(); i++)
|
||||
@ -583,7 +614,7 @@ void GUI::dataSources()
|
||||
void GUI::openFile()
|
||||
{
|
||||
QStringList files = QFileDialog::getOpenFileNames(this, tr("Open file"),
|
||||
QString(), tr("GPX files (*.gpx);;All files (*)"));
|
||||
QString(), fileFormats());
|
||||
QStringList list = files;
|
||||
|
||||
for (QStringList::Iterator it = list.begin(); it != list.end(); it++)
|
||||
@ -602,59 +633,69 @@ bool GUI::openFile(const QString &fileName)
|
||||
_browser->setCurrent(fileName);
|
||||
_fileActionGroup->setEnabled(true);
|
||||
_navigationActionGroup->setEnabled(true);
|
||||
|
||||
updateNavigationActions();
|
||||
updateStatusBarInfo();
|
||||
updateWindowTitle();
|
||||
updateGraphTabs();
|
||||
updatePathView();
|
||||
} else {
|
||||
if (_files.isEmpty())
|
||||
_fileActionGroup->setEnabled(false);
|
||||
ret = false;
|
||||
}
|
||||
|
||||
updateNavigationActions();
|
||||
updateStatusBarInfo();
|
||||
updateWindowTitle();
|
||||
updateGraphTabs();
|
||||
updateTrackView();
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
bool GUI::loadFile(const QString &fileName)
|
||||
{
|
||||
GPX gpx;
|
||||
Data data;
|
||||
QList<PathItem*> paths;
|
||||
|
||||
if (gpx.loadFile(fileName)) {
|
||||
paths = _pathView->loadGPX(gpx);
|
||||
if (data.loadFile(fileName)) {
|
||||
paths = _pathView->loadData(data);
|
||||
for (int i = 0; i < _tabs.count(); i++)
|
||||
_tabs.at(i)->loadGPX(gpx, paths);
|
||||
updateGraphTabs();
|
||||
_pathView->setHidden(false);
|
||||
_tabs.at(i)->loadData(data, paths);
|
||||
|
||||
for (int i = 0; i < gpx.tracks().count(); i++) {
|
||||
_trackDistance += gpx.tracks().at(i)->distance();
|
||||
_time += gpx.tracks().at(i)->time();
|
||||
const QDate &date = gpx.tracks().at(i)->date().date();
|
||||
for (int i = 0; i < data.tracks().count(); i++) {
|
||||
_trackDistance += data.tracks().at(i)->distance();
|
||||
_time += data.tracks().at(i)->time();
|
||||
const QDate &date = data.tracks().at(i)->date().date();
|
||||
if (_dateRange.first.isNull() || _dateRange.first > date)
|
||||
_dateRange.first = date;
|
||||
if (_dateRange.second.isNull() || _dateRange.second < date)
|
||||
_dateRange.second = date;
|
||||
}
|
||||
_trackCount += gpx.tracks().count();
|
||||
_trackCount += data.tracks().count();
|
||||
|
||||
for (int i = 0; i < gpx.routes().count(); i++)
|
||||
_routeDistance += gpx.routes().at(i)->distance();
|
||||
_routeCount += gpx.routes().count();
|
||||
for (int i = 0; i < data.routes().count(); i++)
|
||||
_routeDistance += data.routes().at(i)->distance();
|
||||
_routeCount += data.routes().count();
|
||||
|
||||
_waypointCount += gpx.waypoints().count();
|
||||
_waypointCount += data.waypoints().count();
|
||||
|
||||
if (_pathName.isNull()) {
|
||||
if (data.tracks().count() == 1 && !data.routes().count())
|
||||
_pathName = data.tracks().first()->name();
|
||||
else if (data.routes().count() == 1 && !data.tracks().count())
|
||||
_pathName = data.routes().first()->routeData().name();
|
||||
} else
|
||||
_pathName = QString();
|
||||
|
||||
return true;
|
||||
} else {
|
||||
QString error = fileName + QString("\n\n")
|
||||
+ tr("Error loading GPX file:\n%1").arg(gpx.errorString())
|
||||
+ QString("\n");
|
||||
if (gpx.errorLine())
|
||||
error.append(tr("Line: %1").arg(gpx.errorLine()));
|
||||
updateNavigationActions();
|
||||
updateStatusBarInfo();
|
||||
updateWindowTitle();
|
||||
updateGraphTabs();
|
||||
updatePathView();
|
||||
|
||||
QMessageBox::critical(this, tr("Error"), error);
|
||||
QString error = tr("Error loading data file:") + "\n\n"
|
||||
+ fileName + "\n\n" + data.errorString();
|
||||
if (data.errorLine())
|
||||
error.append("\n" + tr("Line: %1").arg(data.errorLine()));
|
||||
QMessageBox::critical(this, APP_NAME, error);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@ -662,9 +703,7 @@ bool GUI::loadFile(const QString &fileName)
|
||||
void GUI::openPOIFile()
|
||||
{
|
||||
QStringList files = QFileDialog::getOpenFileNames(this, tr("Open POI file"),
|
||||
QString(), tr("All POI files (*.gpx *.csv)") + ";;"
|
||||
+ tr("GPX files (*.gpx)") + ";;" + tr("CSV files (*.csv)") + ";;"
|
||||
+ tr("All files (*)"));
|
||||
QString(), fileFormats());
|
||||
QStringList list = files;
|
||||
|
||||
for (QStringList::Iterator it = list.begin(); it != list.end(); it++)
|
||||
@ -677,12 +716,11 @@ bool GUI::openPOIFile(const QString &fileName)
|
||||
return false;
|
||||
|
||||
if (!_poi->loadFile(fileName)) {
|
||||
QString error = fileName + QString("\n\n")
|
||||
+ tr("Error loading POI file:\n%1").arg(_poi->errorString())
|
||||
+ QString("\n");
|
||||
QString error = tr("Error loading POI file:") + "\n\n"
|
||||
+ fileName + "\n\n" + _poi->errorString();
|
||||
if (_poi->errorLine())
|
||||
error.append(tr("Line: %1").arg(_poi->errorLine()));
|
||||
QMessageBox::critical(this, tr("Error"), error);
|
||||
error.append("\n" + tr("Line: %1").arg(_poi->errorLine()));
|
||||
QMessageBox::critical(this, APP_NAME, error);
|
||||
|
||||
return false;
|
||||
} else {
|
||||
@ -716,26 +754,67 @@ void GUI::printFile()
|
||||
plot(&printer);
|
||||
}
|
||||
|
||||
void GUI::openOptions()
|
||||
{
|
||||
Options options(_options);
|
||||
|
||||
OptionsDialog dialog(&options, this);
|
||||
if (dialog.exec() != QDialog::Accepted)
|
||||
return;
|
||||
|
||||
if (options.palette != _options.palette) {
|
||||
_pathView->setPalette(options.palette);
|
||||
for (int i = 0; i < _tabs.count(); i++)
|
||||
_tabs.at(i)->setPalette(options.palette);
|
||||
}
|
||||
if (options.trackWidth != _options.trackWidth)
|
||||
_pathView->setTrackWidth(options.trackWidth);
|
||||
if (options.routeWidth != _options.routeWidth)
|
||||
_pathView->setRouteWidth(options.routeWidth);
|
||||
if (options.trackStyle != _options.trackStyle)
|
||||
_pathView->setTrackStyle(options.trackStyle);
|
||||
if (options.routeStyle != _options.routeStyle)
|
||||
_pathView->setRouteStyle(options.routeStyle);
|
||||
if (options.pathAntiAliasing != _options.pathAntiAliasing)
|
||||
_pathView->setRenderHint(QPainter::Antialiasing,
|
||||
options.pathAntiAliasing);
|
||||
if (options.graphWidth != _options.graphWidth)
|
||||
for (int i = 0; i < _tabs.count(); i++)
|
||||
_tabs.at(i)->setGraphWidth(options.graphWidth);
|
||||
if (options.graphAntiAliasing != _options.graphAntiAliasing)
|
||||
for (int i = 0; i < _tabs.count(); i++)
|
||||
_tabs.at(i)->setRenderHint(QPainter::Antialiasing,
|
||||
options.graphAntiAliasing);
|
||||
|
||||
if (options.poiRadius != _options.poiRadius)
|
||||
_poi->setRadius(options.poiRadius);
|
||||
|
||||
if (options.useOpenGL != _options.useOpenGL) {
|
||||
_pathView->useOpenGL(options.useOpenGL);
|
||||
for (int i = 0; i < _tabs.count(); i++)
|
||||
_tabs.at(i)->useOpenGL(options.useOpenGL);
|
||||
}
|
||||
|
||||
_options = options;
|
||||
}
|
||||
|
||||
void GUI::exportFile()
|
||||
{
|
||||
QPrinter printer(QPrinter::HighResolution);
|
||||
printer.setCreator(QString(APP_NAME) + QString(" ") + QString(APP_VERSION));
|
||||
printer.setOrientation(_exportOrientation);
|
||||
printer.setOutputFileName(_exportFileName);
|
||||
printer.setPaperSize(_exportPaperSize);
|
||||
printer.setPageMargins(_exportMargins.left(), _exportMargins.top(),
|
||||
_exportMargins.right(), _exportMargins.bottom(), QPrinter::Millimeter);
|
||||
ExportDialog dialog(&printer, this);
|
||||
ExportDialog dialog(&_export, this);
|
||||
if (dialog.exec() != QDialog::Accepted)
|
||||
return;
|
||||
|
||||
if (dialog.exec() == QDialog::Accepted) {
|
||||
_exportFileName = printer.outputFileName();
|
||||
_exportPaperSize = printer.paperSize();
|
||||
_exportOrientation = printer.orientation();
|
||||
printer.getPageMargins(&(_exportMargins.rleft()),
|
||||
&(_exportMargins.rtop()), &(_exportMargins.rright()),
|
||||
&(_exportMargins.rbottom()), QPrinter::Millimeter);
|
||||
plot(&printer);
|
||||
}
|
||||
QPrinter printer(QPrinter::HighResolution);
|
||||
printer.setOutputFormat(QPrinter::PdfFormat);
|
||||
printer.setCreator(QString(APP_NAME) + QString(" ")
|
||||
+ QString(APP_VERSION));
|
||||
printer.setOrientation(_export.orientation);
|
||||
printer.setOutputFileName(_export.fileName);
|
||||
printer.setPaperSize(_export.paperSize);
|
||||
printer.setPageMargins(_export.margins.left(), _export.margins.top(),
|
||||
_export.margins.right(), _export.margins.bottom(), QPrinter::Millimeter);
|
||||
|
||||
plot(&printer);
|
||||
}
|
||||
|
||||
void GUI::plot(QPrinter *printer)
|
||||
@ -747,7 +826,19 @@ void GUI::plot(QPrinter *printer)
|
||||
qreal d = distance();
|
||||
qreal t = time();
|
||||
|
||||
if (_dateRange.first.isValid()) {
|
||||
if (!_pathName.isNull() && _options.printName)
|
||||
info.insert(tr("Name"), _pathName);
|
||||
|
||||
if (_options.printItemCount) {
|
||||
if (_trackCount > 1)
|
||||
info.insert(tr("Tracks"), QString::number(_trackCount));
|
||||
if (_routeCount > 1)
|
||||
info.insert(tr("Routes"), QString::number(_routeCount));
|
||||
if (_waypointCount > 2)
|
||||
info.insert(tr("Waypoints"), QString::number(_waypointCount));
|
||||
}
|
||||
|
||||
if (_dateRange.first.isValid() && _options.printDate) {
|
||||
if (_dateRange.first == _dateRange.second) {
|
||||
QString format = QLocale::system().dateFormat(QLocale::LongFormat);
|
||||
info.insert(tr("Date"), _dateRange.first.toString(format));
|
||||
@ -759,17 +850,10 @@ void GUI::plot(QPrinter *printer)
|
||||
}
|
||||
}
|
||||
|
||||
if (_trackCount > 1)
|
||||
info.insert(tr("Tracks"), QString::number(_trackCount));
|
||||
if (_routeCount > 1)
|
||||
info.insert(tr("Routes"), QString::number(_routeCount));
|
||||
if (_waypointCount > 2)
|
||||
info.insert(tr("Waypoints"), QString::number(_waypointCount));
|
||||
|
||||
if (d > 0)
|
||||
info.insert(tr("Distance"), ::distance(d, units));
|
||||
if (t > 0)
|
||||
info.insert(tr("Time"), ::timeSpan(t));
|
||||
if (d > 0 && _options.printDistance)
|
||||
info.insert(tr("Distance"), Format::distance(d, units));
|
||||
if (t > 0 && _options.printTime)
|
||||
info.insert(tr("Time"), Format::timeSpan(t));
|
||||
|
||||
|
||||
ratio = p.paintEngine()->paintDevice()->logicalDpiX() / SCREEN_DPI;
|
||||
@ -781,7 +865,7 @@ void GUI::plot(QPrinter *printer)
|
||||
mh = ih / 2;
|
||||
info.plot(&p, QRectF(0, 0, printer->width(), ih));
|
||||
}
|
||||
if (_graphTabWidget->isVisible()) {
|
||||
if (_graphTabWidget->isVisible() && !_options.separateGraphPage) {
|
||||
qreal r = (((qreal)(printer)->width()) / (qreal)(printer->height()));
|
||||
gh = (printer->width() > printer->height())
|
||||
? 0.15 * r * (printer->height() - ih - 2*mh)
|
||||
@ -793,6 +877,27 @@ void GUI::plot(QPrinter *printer)
|
||||
gh = 0;
|
||||
_pathView->plot(&p, QRectF(0, ih + mh, printer->width(), printer->height()
|
||||
- (ih + 2*mh + gh)));
|
||||
|
||||
if (_graphTabWidget->isVisible() && _options.separateGraphPage) {
|
||||
printer->newPage();
|
||||
|
||||
int cnt = 0;
|
||||
for (int i = 0; i < _tabs.size(); i++)
|
||||
if (_tabs.at(i)->count())
|
||||
cnt++;
|
||||
|
||||
qreal sp = ratio * 20;
|
||||
gh = qMin((printer->height() - ((cnt - 1) * sp))/(qreal)cnt,
|
||||
0.20 * printer->height());
|
||||
|
||||
qreal y = 0;
|
||||
for (int i = 0; i < _tabs.size(); i++) {
|
||||
if (_tabs.at(i)->count()) {
|
||||
_tabs.at(i)->plot(&p, QRectF(0, y, printer->width(), gh));
|
||||
y += gh + sp;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void GUI::reloadFile()
|
||||
@ -804,6 +909,7 @@ void GUI::reloadFile()
|
||||
_routeDistance = 0;
|
||||
_time = 0;
|
||||
_dateRange = DateRange(QDate(), QDate());
|
||||
_pathName = QString();
|
||||
|
||||
for (int i = 0; i < _tabs.count(); i++)
|
||||
_tabs.at(i)->clear();
|
||||
@ -821,7 +927,7 @@ void GUI::reloadFile()
|
||||
updateStatusBarInfo();
|
||||
updateWindowTitle();
|
||||
updateGraphTabs();
|
||||
updateTrackView();
|
||||
updatePathView();
|
||||
if (_files.isEmpty())
|
||||
_fileActionGroup->setEnabled(false);
|
||||
else
|
||||
@ -837,6 +943,7 @@ void GUI::closeFiles()
|
||||
_routeDistance = 0;
|
||||
_time = 0;
|
||||
_dateRange = DateRange(QDate(), QDate());
|
||||
_pathName = QString();
|
||||
|
||||
_sliderPos = 0;
|
||||
|
||||
@ -855,25 +962,25 @@ void GUI::closeAll()
|
||||
updateStatusBarInfo();
|
||||
updateWindowTitle();
|
||||
updateGraphTabs();
|
||||
updateTrackView();
|
||||
updatePathView();
|
||||
}
|
||||
|
||||
void GUI::showMap(bool checked)
|
||||
void GUI::showMap(bool show)
|
||||
{
|
||||
if (checked)
|
||||
if (show)
|
||||
_pathView->setMap(_currentMap);
|
||||
else
|
||||
_pathView->setMap(0);
|
||||
}
|
||||
|
||||
void GUI::showGraphs(bool checked)
|
||||
void GUI::showGraphs(bool show)
|
||||
{
|
||||
_graphTabWidget->setHidden(!checked);
|
||||
_graphTabWidget->setHidden(!show);
|
||||
}
|
||||
|
||||
void GUI::showToolbars(bool checked)
|
||||
void GUI::showToolbars(bool show)
|
||||
{
|
||||
if (checked) {
|
||||
if (show) {
|
||||
addToolBar(_fileToolBar);
|
||||
addToolBar(_showToolBar);
|
||||
addToolBar(_navigationToolBar);
|
||||
@ -887,9 +994,9 @@ void GUI::showToolbars(bool checked)
|
||||
}
|
||||
}
|
||||
|
||||
void GUI::showFullscreen(bool checked)
|
||||
void GUI::showFullscreen(bool show)
|
||||
{
|
||||
if (checked) {
|
||||
if (show) {
|
||||
_frameStyle = _pathView->frameStyle();
|
||||
_showGraphs = _showGraphsAction->isChecked();
|
||||
|
||||
@ -935,6 +1042,12 @@ void GUI::showRoutes(bool show)
|
||||
updateStatusBarInfo();
|
||||
}
|
||||
|
||||
void GUI::showGraphGrids(bool show)
|
||||
{
|
||||
for (int i = 0; i < _tabs.size(); i++)
|
||||
_tabs.at(i)->showGrid(show);
|
||||
}
|
||||
|
||||
void GUI::clearMapCache()
|
||||
{
|
||||
_currentMap->clearCache();
|
||||
@ -944,22 +1057,22 @@ void GUI::clearMapCache()
|
||||
void GUI::updateStatusBarInfo()
|
||||
{
|
||||
if (_files.count() == 0)
|
||||
_fileNameLabel->setText(tr("No GPX files loaded"));
|
||||
_fileNameLabel->setText(tr("No files loaded"));
|
||||
else if (_files.count() == 1)
|
||||
_fileNameLabel->setText(_files.at(0));
|
||||
else
|
||||
_fileNameLabel->setText(tr("%1 files").arg(_files.count()));
|
||||
_fileNameLabel->setText(tr("%n files", "", _files.count()));
|
||||
|
||||
qreal d = distance();
|
||||
Units units = _imperialUnitsAction->isChecked() ? Imperial : Metric;
|
||||
if (d > 0)
|
||||
_distanceLabel->setText(::distance(distance(), units));
|
||||
_distanceLabel->setText(Format::distance(distance(), units));
|
||||
else
|
||||
_distanceLabel->clear();
|
||||
|
||||
qreal t = time();
|
||||
if (t > 0)
|
||||
_timeLabel->setText(::timeSpan(time()));
|
||||
_timeLabel->setText(Format::timeSpan(time()));
|
||||
else
|
||||
_timeLabel->clear();
|
||||
}
|
||||
@ -1065,7 +1178,7 @@ void GUI::updateGraphTabs()
|
||||
}
|
||||
}
|
||||
|
||||
void GUI::updateTrackView()
|
||||
void GUI::updatePathView()
|
||||
{
|
||||
_pathView->setHidden(!(_pathView->trackCount() + _pathView->routeCount()
|
||||
+ _pathView->waypointCount()));
|
||||
@ -1073,6 +1186,9 @@ void GUI::updateTrackView()
|
||||
|
||||
void GUI::setUnits(Units units)
|
||||
{
|
||||
_export.units = units;
|
||||
_options.units = units;
|
||||
|
||||
_pathView->setUnits(units);
|
||||
for (int i = 0; i <_tabs.count(); i++)
|
||||
_tabs.at(i)->setUnits(units);
|
||||
@ -1193,55 +1309,131 @@ void GUI::dropEvent(QDropEvent *event)
|
||||
void GUI::writeSettings()
|
||||
{
|
||||
QSettings settings(APP_NAME, APP_NAME);
|
||||
settings.clear();
|
||||
|
||||
settings.beginGroup(WINDOW_SETTINGS_GROUP);
|
||||
settings.setValue(WINDOW_SIZE_SETTING, size());
|
||||
settings.setValue(WINDOW_POS_SETTING, pos());
|
||||
if (size() != WINDOW_SIZE_DEFAULT)
|
||||
settings.setValue(WINDOW_SIZE_SETTING, size());
|
||||
if (pos() != WINDOW_POS_DEFAULT)
|
||||
settings.setValue(WINDOW_POS_SETTING, pos());
|
||||
settings.endGroup();
|
||||
|
||||
settings.beginGroup(SETTINGS_SETTINGS_GROUP);
|
||||
settings.setValue(UNITS_SETTING, _imperialUnitsAction->isChecked()
|
||||
if ((_imperialUnitsAction->isChecked() ? Imperial : Metric) !=
|
||||
UNITS_DEFAULT)
|
||||
settings.setValue(UNITS_SETTING, _imperialUnitsAction->isChecked()
|
||||
? Imperial : Metric);
|
||||
settings.setValue(SHOW_TOOLBARS_SETTING, _showToolbarsAction->isChecked());
|
||||
if (_showToolbarsAction->isChecked() != SHOW_TOOLBARS_DEFAULT)
|
||||
settings.setValue(SHOW_TOOLBARS_SETTING,
|
||||
_showToolbarsAction->isChecked());
|
||||
settings.endGroup();
|
||||
|
||||
settings.beginGroup(MAP_SETTINGS_GROUP);
|
||||
if (_currentMap)
|
||||
settings.setValue(CURRENT_MAP_SETTING, _currentMap->name());
|
||||
settings.setValue(SHOW_MAP_SETTING, _showMapAction->isChecked());
|
||||
if (_showMapAction->isChecked() != SHOW_MAP_DEFAULT)
|
||||
settings.setValue(SHOW_MAP_SETTING, _showMapAction->isChecked());
|
||||
settings.endGroup();
|
||||
|
||||
settings.beginGroup(GRAPH_SETTINGS_GROUP);
|
||||
settings.setValue(SHOW_GRAPHS_SETTING, _showGraphsAction->isChecked());
|
||||
settings.setValue(GRAPH_TYPE_SETTING, _timeGraphAction->isChecked()
|
||||
? Time : Distance);
|
||||
if (_showGraphsAction->isChecked() != SHOW_GRAPHS_DEFAULT)
|
||||
settings.setValue(SHOW_GRAPHS_SETTING, _showGraphsAction->isChecked());
|
||||
if ((_timeGraphAction->isChecked() ? Time : Distance) != GRAPH_TYPE_DEFAULT)
|
||||
settings.setValue(GRAPH_TYPE_SETTING, _timeGraphAction->isChecked()
|
||||
? Time : Distance);
|
||||
if (_showGraphGridAction->isChecked() != SHOW_GRAPH_GRIDS_DEFAULT)
|
||||
settings.setValue(SHOW_GRAPH_GRIDS_SETTING,
|
||||
_showGraphGridAction->isChecked());
|
||||
settings.endGroup();
|
||||
|
||||
settings.beginGroup(POI_SETTINGS_GROUP);
|
||||
settings.setValue(SHOW_POI_SETTING, _showPOIAction->isChecked());
|
||||
settings.setValue(OVERLAP_POI_SETTING, _overlapPOIAction->isChecked());
|
||||
if (_showPOIAction->isChecked() != SHOW_POI_DEFAULT)
|
||||
settings.setValue(SHOW_POI_SETTING, _showPOIAction->isChecked());
|
||||
if (_overlapPOIAction->isChecked() != OVERLAP_POI_DEFAULT)
|
||||
settings.setValue(OVERLAP_POI_SETTING, _overlapPOIAction->isChecked());
|
||||
|
||||
settings.remove(DISABLED_POI_FILE_SETTINGS_PREFIX);
|
||||
settings.beginWriteArray(DISABLED_POI_FILE_SETTINGS_PREFIX);
|
||||
for (int i = 0, j = 0; i < _poiFilesActions.count(); i++) {
|
||||
int j = 0;
|
||||
for (int i = 0; i < _poiFilesActions.count(); i++) {
|
||||
if (!_poiFilesActions.at(i)->isChecked()) {
|
||||
if (j == 0)
|
||||
settings.beginWriteArray(DISABLED_POI_FILE_SETTINGS_PREFIX);
|
||||
settings.setArrayIndex(j++);
|
||||
settings.setValue(DISABLED_POI_FILE_SETTING, _poi->files().at(i));
|
||||
}
|
||||
}
|
||||
settings.endArray();
|
||||
if (j != 0)
|
||||
settings.endArray();
|
||||
settings.endGroup();
|
||||
|
||||
settings.beginGroup(DATA_SETTINGS_GROUP);
|
||||
settings.setValue(SHOW_TRACKS_SETTING, _showTracksAction->isChecked());
|
||||
settings.setValue(SHOW_ROUTES_SETTING, _showRoutesAction->isChecked());
|
||||
settings.setValue(SHOW_WAYPOINTS_SETTING,
|
||||
_showWaypointsAction->isChecked());
|
||||
settings.setValue(SHOW_WAYPOINT_LABELS_SETTING,
|
||||
_showWaypointLabelsAction->isChecked());
|
||||
settings.setValue(SHOW_ROUTE_WAYPOINTS_SETTING,
|
||||
_showRouteWaypointsAction->isChecked());
|
||||
if (_showTracksAction->isChecked() != SHOW_TRACKS_DEFAULT)
|
||||
settings.setValue(SHOW_TRACKS_SETTING, _showTracksAction->isChecked());
|
||||
if (_showRoutesAction->isChecked() != SHOW_ROUTES_DEFAULT)
|
||||
settings.setValue(SHOW_ROUTES_SETTING, _showRoutesAction->isChecked());
|
||||
if (_showWaypointsAction->isChecked() != SHOW_WAYPOINTS_DEFAULT)
|
||||
settings.setValue(SHOW_WAYPOINTS_SETTING,
|
||||
_showWaypointsAction->isChecked());
|
||||
if (_showWaypointLabelsAction->isChecked() != SHOW_WAYPOINT_LABELS_DEFAULT)
|
||||
settings.setValue(SHOW_WAYPOINT_LABELS_SETTING,
|
||||
_showWaypointLabelsAction->isChecked());
|
||||
if (_showRouteWaypointsAction->isChecked() != SHOW_ROUTE_WAYPOINTS_DEFAULT)
|
||||
settings.setValue(SHOW_ROUTE_WAYPOINTS_SETTING,
|
||||
_showRouteWaypointsAction->isChecked());
|
||||
settings.endGroup();
|
||||
|
||||
settings.beginGroup(EXPORT_SETTINGS_GROUP);
|
||||
if (_export.orientation != PAPER_ORIENTATION_DEFAULT)
|
||||
settings.setValue(PAPER_ORIENTATION_SETTING, _export.orientation);
|
||||
if (_export.paperSize != PAPER_SIZE_DEFAULT)
|
||||
settings.setValue(PAPER_SIZE_SETTING, _export.paperSize);
|
||||
if (_export.margins.left() != MARGIN_LEFT_DEFAULT)
|
||||
settings.setValue(MARGIN_LEFT_SETTING, _export.margins.left());
|
||||
if (_export.margins.top() != MARGIN_TOP_DEFAULT)
|
||||
settings.setValue(MARGIN_TOP_SETTING, _export.margins.top());
|
||||
if (_export.margins.right() != MARGIN_RIGHT_DEFAULT)
|
||||
settings.setValue(MARGIN_RIGHT_SETTING, _export.margins.right());
|
||||
if (_export.margins.bottom() != MARGIN_BOTTOM_DEFAULT)
|
||||
settings.setValue(MARGIN_BOTTOM_SETTING, _export.margins.bottom());
|
||||
if (_export.fileName != EXPORT_FILENAME_DEFAULT)
|
||||
settings.setValue(EXPORT_FILENAME_SETTING, _export.fileName);
|
||||
settings.endGroup();
|
||||
|
||||
settings.beginGroup(OPTIONS_SETTINGS_GROUP);
|
||||
if (_options.palette.color() != PALETTE_COLOR_DEFAULT)
|
||||
settings.setValue(PALETTE_COLOR_SETTING, _options.palette.color());
|
||||
if (_options.palette.shift() != PALETTE_SHIFT_DEFAULT)
|
||||
settings.setValue(PALETTE_SHIFT_SETTING, _options.palette.shift());
|
||||
if (_options.trackWidth != TRACK_WIDTH_DEFAULT)
|
||||
settings.setValue(TRACK_WIDTH_SETTING, _options.trackWidth);
|
||||
if (_options.routeWidth != ROUTE_WIDTH_DEFAULT)
|
||||
settings.setValue(ROUTE_WIDTH_SETTING, _options.routeWidth);
|
||||
if (_options.trackStyle != TRACK_STYLE_DEFAULT)
|
||||
settings.setValue(TRACK_STYLE_SETTING, (int)_options.trackStyle);
|
||||
if (_options.routeStyle != ROUTE_STYLE_DEFAULT)
|
||||
settings.setValue(ROUTE_STYLE_SETTING, (int)_options.routeStyle);
|
||||
if (_options.graphWidth != GRAPH_WIDTH_DEFAULT)
|
||||
settings.setValue(GRAPH_WIDTH_SETTING, _options.graphWidth);
|
||||
if (_options.pathAntiAliasing != PATH_AA_DEFAULT)
|
||||
settings.setValue(PATH_AA_SETTING, _options.pathAntiAliasing);
|
||||
if (_options.graphAntiAliasing != GRAPH_AA_DEFAULT)
|
||||
settings.setValue(GRAPH_AA_SETTING, _options.graphAntiAliasing);
|
||||
if (_options.poiRadius != POI_RADIUS_DEFAULT)
|
||||
settings.setValue(POI_RADIUS_SETTING, _options.poiRadius);
|
||||
if (_options.useOpenGL != USE_OPENGL_DEFAULT)
|
||||
settings.setValue(USE_OPENGL_SETTING, _options.useOpenGL);
|
||||
if (_options.printName != PRINT_NAME_DEFAULT)
|
||||
settings.setValue(PRINT_NAME_SETTING, _options.printName);
|
||||
if (_options.printDate != PRINT_DATE_DEFAULT)
|
||||
settings.setValue(PRINT_DATE_SETTING, _options.printDate);
|
||||
if (_options.printDistance != PRINT_DISTANCE_DEFAULT)
|
||||
settings.setValue(PRINT_DISTANCE_SETTING, _options.printDistance);
|
||||
if (_options.printTime != PRINT_TIME_DEFAULT)
|
||||
settings.setValue(PRINT_TIME_SETTING, _options.printTime);
|
||||
if (_options.printItemCount != PRINT_ITEM_COUNT_DEFAULT)
|
||||
settings.setValue(PRINT_ITEM_COUNT_SETTING, _options.printItemCount);
|
||||
if (_options.separateGraphPage != SEPARATE_GRAPH_PAGE_DEFAULT)
|
||||
settings.setValue(SEPARATE_GRAPH_PAGE_SETTING,
|
||||
_options.separateGraphPage);
|
||||
settings.endGroup();
|
||||
}
|
||||
|
||||
@ -1250,26 +1442,26 @@ void GUI::readSettings()
|
||||
QSettings settings(APP_NAME, APP_NAME);
|
||||
|
||||
settings.beginGroup(WINDOW_SETTINGS_GROUP);
|
||||
resize(settings.value(WINDOW_SIZE_SETTING, QSize(600, 800)).toSize());
|
||||
move(settings.value(WINDOW_POS_SETTING, QPoint(10, 10)).toPoint());
|
||||
resize(settings.value(WINDOW_SIZE_SETTING, WINDOW_SIZE_DEFAULT).toSize());
|
||||
move(settings.value(WINDOW_POS_SETTING, WINDOW_POS_DEFAULT).toPoint());
|
||||
settings.endGroup();
|
||||
|
||||
settings.beginGroup(SETTINGS_SETTINGS_GROUP);
|
||||
Units u = QLocale::system().measurementSystem() == QLocale::ImperialSystem
|
||||
? Imperial : Metric;
|
||||
if (settings.value(UNITS_SETTING, u).toInt() == Imperial) {
|
||||
setImperialUnits();
|
||||
if (settings.value(UNITS_SETTING, UNITS_DEFAULT).toInt() == Imperial) {
|
||||
setUnits(Imperial);
|
||||
_imperialUnitsAction->setChecked(true);
|
||||
} else
|
||||
} else {
|
||||
setUnits(Metric);
|
||||
_metricUnitsAction->setChecked(true);
|
||||
if (settings.value(SHOW_TOOLBARS_SETTING, true).toBool() == false)
|
||||
}
|
||||
if (!settings.value(SHOW_TOOLBARS_SETTING, SHOW_TOOLBARS_DEFAULT).toBool())
|
||||
showToolbars(false);
|
||||
else
|
||||
_showToolbarsAction->setChecked(true);
|
||||
settings.endGroup();
|
||||
|
||||
settings.beginGroup(MAP_SETTINGS_GROUP);
|
||||
if (settings.value(SHOW_MAP_SETTING, true).toBool() == true)
|
||||
if (settings.value(SHOW_MAP_SETTING, SHOW_MAP_DEFAULT).toBool())
|
||||
_showMapAction->setChecked(true);
|
||||
if (_maps.count()) {
|
||||
int index = mapIndex(settings.value(CURRENT_MAP_SETTING).toString());
|
||||
@ -1282,27 +1474,33 @@ void GUI::readSettings()
|
||||
settings.endGroup();
|
||||
|
||||
settings.beginGroup(GRAPH_SETTINGS_GROUP);
|
||||
if (settings.value(SHOW_GRAPHS_SETTING, true).toBool() == false)
|
||||
if (!settings.value(SHOW_GRAPHS_SETTING, SHOW_GRAPHS_DEFAULT).toBool())
|
||||
showGraphs(false);
|
||||
else
|
||||
_showGraphsAction->setChecked(true);
|
||||
if (settings.value(GRAPH_TYPE_SETTING, Distance).toInt() == Time) {
|
||||
if (settings.value(GRAPH_TYPE_SETTING, GRAPH_TYPE_DEFAULT).toInt()
|
||||
== Time) {
|
||||
setTimeGraph();
|
||||
_timeGraphAction->setChecked(true);
|
||||
} else
|
||||
_distanceGraphAction->setChecked(true);
|
||||
if (!settings.value(SHOW_GRAPH_GRIDS_SETTING, SHOW_GRAPH_GRIDS_DEFAULT)
|
||||
.toBool())
|
||||
showGraphGrids(false);
|
||||
else
|
||||
_showGraphGridAction->setChecked(true);
|
||||
settings.endGroup();
|
||||
|
||||
settings.beginGroup(POI_SETTINGS_GROUP);
|
||||
if (settings.value(OVERLAP_POI_SETTING, true).toBool() == false)
|
||||
if (!settings.value(OVERLAP_POI_SETTING, OVERLAP_POI_DEFAULT).toBool())
|
||||
_pathView->setPOIOverlap(false);
|
||||
else
|
||||
_overlapPOIAction->setChecked(true);
|
||||
if (settings.value(LABELS_POI_SETTING, true).toBool() == false)
|
||||
if (!settings.value(LABELS_POI_SETTING, LABELS_POI_DEFAULT).toBool())
|
||||
_pathView->showPOILabels(false);
|
||||
else
|
||||
_showPOILabelsAction->setChecked(true);
|
||||
if (settings.value(SHOW_POI_SETTING, false).toBool() == true)
|
||||
if (settings.value(SHOW_POI_SETTING, SHOW_POI_DEFAULT).toBool())
|
||||
_showPOIAction->setChecked(true);
|
||||
else
|
||||
_pathView->showPOI(false);
|
||||
@ -1322,31 +1520,110 @@ void GUI::readSettings()
|
||||
settings.endGroup();
|
||||
|
||||
settings.beginGroup(DATA_SETTINGS_GROUP);
|
||||
if (settings.value(SHOW_TRACKS_SETTING, true).toBool() == false) {
|
||||
if (!settings.value(SHOW_TRACKS_SETTING, SHOW_TRACKS_DEFAULT).toBool()) {
|
||||
_pathView->showTracks(false);
|
||||
for (int i = 0; i < _tabs.count(); i++)
|
||||
_tabs.at(i)->showTracks(false);
|
||||
} else
|
||||
_showTracksAction->setChecked(true);
|
||||
if (settings.value(SHOW_ROUTES_SETTING, true).toBool() == false) {
|
||||
if (!settings.value(SHOW_ROUTES_SETTING, SHOW_ROUTES_DEFAULT).toBool()) {
|
||||
_pathView->showRoutes(false);
|
||||
for (int i = 0; i < _tabs.count(); i++)
|
||||
_tabs.at(i)->showRoutes(false);
|
||||
} else
|
||||
_showRoutesAction->setChecked(true);
|
||||
if (settings.value(SHOW_WAYPOINTS_SETTING, true).toBool() == false)
|
||||
if (!settings.value(SHOW_WAYPOINTS_SETTING, SHOW_WAYPOINTS_DEFAULT)
|
||||
.toBool())
|
||||
_pathView->showWaypoints(false);
|
||||
else
|
||||
_showWaypointsAction->setChecked(true);
|
||||
if (settings.value(SHOW_WAYPOINT_LABELS_SETTING, true).toBool() == false)
|
||||
if (!settings.value(SHOW_WAYPOINT_LABELS_SETTING,
|
||||
SHOW_WAYPOINT_LABELS_DEFAULT).toBool())
|
||||
_pathView->showWaypointLabels(false);
|
||||
else
|
||||
_showWaypointLabelsAction->setChecked(true);
|
||||
if (settings.value(SHOW_ROUTE_WAYPOINTS_SETTING, true).toBool() == false)
|
||||
if (!settings.value(SHOW_ROUTE_WAYPOINTS_SETTING,
|
||||
SHOW_ROUTE_WAYPOINTS_SETTING).toBool())
|
||||
_pathView->showRouteWaypoints(false);
|
||||
else
|
||||
_showRouteWaypointsAction->setChecked(true);
|
||||
settings.endGroup();
|
||||
|
||||
settings.beginGroup(EXPORT_SETTINGS_GROUP);
|
||||
_export.orientation = (QPrinter::Orientation) settings.value(
|
||||
PAPER_ORIENTATION_SETTING, PAPER_ORIENTATION_DEFAULT).toInt();
|
||||
_export.paperSize = (QPrinter::PaperSize) settings.value(PAPER_SIZE_SETTING,
|
||||
PAPER_SIZE_DEFAULT).toInt();
|
||||
qreal ml = settings.value(MARGIN_LEFT_SETTING, MARGIN_LEFT_DEFAULT)
|
||||
.toReal();
|
||||
qreal mt = settings.value(MARGIN_TOP_SETTING, MARGIN_TOP_DEFAULT).toReal();
|
||||
qreal mr = settings.value(MARGIN_RIGHT_SETTING, MARGIN_RIGHT_DEFAULT)
|
||||
.toReal();
|
||||
qreal mb = settings.value(MARGIN_BOTTOM_SETTING, MARGIN_BOTTOM_DEFAULT)
|
||||
.toReal();
|
||||
_export.margins = MarginsF(ml, mt, mr, mb);
|
||||
_export.fileName = settings.value(EXPORT_FILENAME_SETTING,
|
||||
EXPORT_FILENAME_DEFAULT).toString();
|
||||
settings.endGroup();
|
||||
|
||||
settings.beginGroup(OPTIONS_SETTINGS_GROUP);
|
||||
QColor pc = settings.value(PALETTE_COLOR_SETTING, PALETTE_COLOR_DEFAULT)
|
||||
.value<QColor>();
|
||||
qreal ps = settings.value(PALETTE_SHIFT_SETTING, PALETTE_SHIFT_DEFAULT)
|
||||
.toDouble();
|
||||
_options.palette = Palette(pc, ps);
|
||||
_options.trackWidth = settings.value(TRACK_WIDTH_SETTING,
|
||||
TRACK_WIDTH_DEFAULT).toInt();
|
||||
_options.routeWidth = settings.value(ROUTE_WIDTH_SETTING,
|
||||
ROUTE_WIDTH_DEFAULT).toInt();
|
||||
_options.trackStyle = (Qt::PenStyle) settings.value(TRACK_STYLE_SETTING,
|
||||
(int)TRACK_STYLE_DEFAULT).toInt();
|
||||
_options.routeStyle = (Qt::PenStyle) settings.value(ROUTE_STYLE_SETTING,
|
||||
(int)ROUTE_STYLE_DEFAULT).toInt();
|
||||
_options.pathAntiAliasing = settings.value(PATH_AA_SETTING, PATH_AA_DEFAULT)
|
||||
.toBool();
|
||||
_options.graphWidth = settings.value(GRAPH_WIDTH_SETTING,
|
||||
GRAPH_WIDTH_DEFAULT).toInt();
|
||||
_options.graphAntiAliasing = settings.value(GRAPH_AA_SETTING,
|
||||
GRAPH_AA_DEFAULT).toBool();
|
||||
_options.poiRadius = settings.value(POI_RADIUS_SETTING, POI_RADIUS_DEFAULT)
|
||||
.toInt();
|
||||
_options.useOpenGL = settings.value(USE_OPENGL_SETTING, USE_OPENGL_DEFAULT)
|
||||
.toBool();
|
||||
_options.printName = settings.value(PRINT_NAME_SETTING, PRINT_NAME_DEFAULT)
|
||||
.toBool();
|
||||
_options.printDate = settings.value(PRINT_DATE_SETTING, PRINT_DATE_DEFAULT)
|
||||
.toBool();
|
||||
_options.printDistance = settings.value(PRINT_DISTANCE_SETTING,
|
||||
PRINT_DISTANCE_DEFAULT).toBool();
|
||||
_options.printTime = settings.value(PRINT_TIME_SETTING, PRINT_TIME_DEFAULT)
|
||||
.toBool();
|
||||
_options.printItemCount = settings.value(PRINT_ITEM_COUNT_SETTING,
|
||||
PRINT_ITEM_COUNT_DEFAULT).toBool();
|
||||
_options.separateGraphPage = settings.value(SEPARATE_GRAPH_PAGE_SETTING,
|
||||
SEPARATE_GRAPH_PAGE_DEFAULT).toBool();
|
||||
|
||||
_pathView->setPalette(_options.palette);
|
||||
_pathView->setTrackWidth(_options.trackWidth);
|
||||
_pathView->setRouteWidth(_options.routeWidth);
|
||||
_pathView->setTrackStyle(_options.trackStyle);
|
||||
_pathView->setRouteStyle(_options.routeStyle);
|
||||
_pathView->setRenderHint(QPainter::Antialiasing, _options.pathAntiAliasing);
|
||||
if (_options.useOpenGL)
|
||||
_pathView->useOpenGL(true);
|
||||
|
||||
for (int i = 0; i < _tabs.count(); i++) {
|
||||
_tabs.at(i)->setPalette(_options.palette);
|
||||
_tabs.at(i)->setGraphWidth(_options.graphWidth);
|
||||
_tabs.at(i)->setRenderHint(QPainter::Antialiasing,
|
||||
_options.graphAntiAliasing);
|
||||
if (_options.useOpenGL)
|
||||
_tabs.at(i)->useOpenGL(true);
|
||||
}
|
||||
|
||||
_poi->setRadius(_options.poiRadius);
|
||||
|
||||
settings.endGroup();
|
||||
}
|
||||
|
||||
int GUI::mapIndex(const QString &name)
|
||||
@ -1358,7 +1635,7 @@ int GUI::mapIndex(const QString &name)
|
||||
return 0;
|
||||
}
|
||||
|
||||
qreal GUI::distance()
|
||||
qreal GUI::distance() const
|
||||
{
|
||||
qreal dist = 0;
|
||||
|
||||
@ -1370,7 +1647,7 @@ qreal GUI::distance()
|
||||
return dist;
|
||||
}
|
||||
|
||||
qreal GUI::time()
|
||||
qreal GUI::time() const
|
||||
{
|
||||
return (_showTracksAction->isChecked()) ? _time : 0;
|
||||
}
|
||||
|
31
src/gui.h
@ -9,7 +9,8 @@
|
||||
#include "units.h"
|
||||
#include "graph.h"
|
||||
#include "poi.h"
|
||||
#include "margins.h"
|
||||
#include "exportdialog.h"
|
||||
#include "optionsdialog.h"
|
||||
|
||||
class QMenu;
|
||||
class QToolBar;
|
||||
@ -45,15 +46,17 @@ private slots:
|
||||
void reloadFile();
|
||||
void openPOIFile();
|
||||
void closePOIFiles();
|
||||
void showMap(bool checked);
|
||||
void showGraphs(bool checked);
|
||||
void showToolbars(bool checked);
|
||||
void showFullscreen(bool checked);
|
||||
void showMap(bool show);
|
||||
void showGraphs(bool show);
|
||||
void showGraphGrids(bool show);
|
||||
void showToolbars(bool show);
|
||||
void showFullscreen(bool show);
|
||||
void showTracks(bool show);
|
||||
void showRoutes(bool show);
|
||||
void clearMapCache();
|
||||
void nextMap();
|
||||
void prevMap();
|
||||
void openOptions();
|
||||
|
||||
void mapChanged(int);
|
||||
void graphChanged(int);
|
||||
@ -88,6 +91,7 @@ private:
|
||||
void createStatusBar();
|
||||
void createPathView();
|
||||
void createGraphTabs();
|
||||
void createBrowser();
|
||||
|
||||
bool openPOIFile(const QString &fileName);
|
||||
bool loadFile(const QString &fileName);
|
||||
@ -96,17 +100,19 @@ private:
|
||||
void updateWindowTitle();
|
||||
void updateNavigationActions();
|
||||
void updateGraphTabs();
|
||||
void updateTrackView();
|
||||
void updatePathView();
|
||||
|
||||
void setUnits(Units units);
|
||||
void setGraphType(GraphType type);
|
||||
|
||||
qreal distance();
|
||||
qreal time();
|
||||
qreal distance() const;
|
||||
qreal time() const;
|
||||
int mapIndex(const QString &name);
|
||||
void readSettings();
|
||||
void writeSettings();
|
||||
|
||||
const QString fileFormats() const;
|
||||
|
||||
void keyPressEvent(QKeyEvent *event);
|
||||
void closeEvent(QCloseEvent *event);
|
||||
void dragEnterEvent(QDragEnterEvent *event);
|
||||
@ -138,6 +144,7 @@ private:
|
||||
QAction *_fullscreenAction;
|
||||
QAction *_clearMapCacheAction;
|
||||
QAction *_showGraphsAction;
|
||||
QAction *_showGraphGridAction;
|
||||
QAction *_distanceGraphAction;
|
||||
QAction *_timeGraphAction;
|
||||
QAction *_showToolbarsAction;
|
||||
@ -154,6 +161,7 @@ private:
|
||||
QAction *_showWaypointsAction;
|
||||
QAction *_showWaypointLabelsAction;
|
||||
QAction *_showRouteWaypointsAction;
|
||||
QAction *_openOptionsAction;
|
||||
QList<QAction*> _mapActions;
|
||||
QList<QAction*> _poiFilesActions;
|
||||
|
||||
@ -181,16 +189,15 @@ private:
|
||||
qreal _routeDistance;
|
||||
qreal _time;
|
||||
DateRange _dateRange;
|
||||
QString _pathName;
|
||||
|
||||
qreal _sliderPos;
|
||||
|
||||
int _frameStyle;
|
||||
bool _showGraphs;
|
||||
|
||||
QString _exportFileName;
|
||||
QPrinter::PaperSize _exportPaperSize;
|
||||
QPrinter::Orientation _exportOrientation;
|
||||
MarginsF _exportMargins;
|
||||
Export _export;
|
||||
Options _options;
|
||||
};
|
||||
|
||||
#endif // GUI_H
|
||||
|
@ -1,4 +1,4 @@
|
||||
#include "gpx.h"
|
||||
#include "data.h"
|
||||
#include "heartrategraph.h"
|
||||
|
||||
|
||||
@ -24,10 +24,10 @@ void HeartRateGraph::setInfo()
|
||||
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++) {
|
||||
const Graph &graph = gpx.tracks().at(i)->heartRate();
|
||||
for (int i = 0; i < data.tracks().count(); i++) {
|
||||
const Graph &graph = data.tracks().at(i)->heartRate();
|
||||
qreal sum = 0, w = 0;
|
||||
|
||||
if (graph.size() < 2) {
|
||||
@ -40,12 +40,12 @@ void HeartRateGraph::loadGPX(const GPX &gpx, const QList<PathItem *> &paths)
|
||||
sum += graph.at(j).y() * 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));
|
||||
}
|
||||
|
||||
for (int i = 0; i < gpx.routes().count(); i++)
|
||||
for (int i = 0; i < data.routes().count(); i++)
|
||||
skipColor();
|
||||
|
||||
setInfo();
|
||||
|
@ -11,7 +11,7 @@ public:
|
||||
HeartRateGraph(QWidget *parent = 0);
|
||||
|
||||
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 setUnits(enum Units) {}
|
||||
void showTracks(bool show);
|
||||
|
38
src/icons.h
@ -1,20 +1,28 @@
|
||||
#ifndef ICONS_H
|
||||
#define ICONS_H
|
||||
|
||||
#define APP_ICON ":/icons/gpxsee.png"
|
||||
#define OPEN_FILE_ICON ":/icons/document-open.png"
|
||||
#define EXPORT_FILE_ICON ":/icons/document-export.png"
|
||||
#define PRINT_FILE_ICON ":/icons/document-print.png"
|
||||
#define CLOSE_FILE_ICON ":/icons/dialog-close.png"
|
||||
#define SHOW_POI_ICON ":/icons/flag.png"
|
||||
#define SHOW_MAP_ICON ":/icons/applications-internet.png"
|
||||
#define SHOW_GRAPHS_ICON ":/icons/office-chart-line-stacked.png"
|
||||
#define QUIT_ICON ":/icons/application-exit.png"
|
||||
#define RELOAD_FILE_ICON ":/icons/view-refresh.png"
|
||||
#define NEXT_FILE_ICON ":/icons/arrow-right.png"
|
||||
#define PREV_FILE_ICON ":/icons/arrow-left.png"
|
||||
#define LAST_FILE_ICON ":/icons/arrow-right-double.png"
|
||||
#define FIRST_FILE_ICON ":/icons/arrow-left-double.png"
|
||||
#define FULLSCREEN_ICON ":/icons/view-fullscreen.png"
|
||||
#define APP_ICON ":/icons/gpxsee.png"
|
||||
|
||||
// Toolbar/menu icons
|
||||
#define OPEN_FILE_ICON ":/icons/document-open.png"
|
||||
#define EXPORT_FILE_ICON ":/icons/document-export.png"
|
||||
#define PRINT_FILE_ICON ":/icons/document-print.png"
|
||||
#define CLOSE_FILE_ICON ":/icons/dialog-close.png"
|
||||
#define SHOW_POI_ICON ":/icons/flag.png"
|
||||
#define SHOW_MAP_ICON ":/icons/applications-internet.png"
|
||||
#define SHOW_GRAPHS_ICON ":/icons/office-chart-line-stacked.png"
|
||||
#define QUIT_ICON ":/icons/application-exit.png"
|
||||
#define RELOAD_FILE_ICON ":/icons/view-refresh.png"
|
||||
#define NEXT_FILE_ICON ":/icons/arrow-right.png"
|
||||
#define PREV_FILE_ICON ":/icons/arrow-left.png"
|
||||
#define LAST_FILE_ICON ":/icons/arrow-right-double.png"
|
||||
#define FIRST_FILE_ICON ":/icons/arrow-left-double.png"
|
||||
#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 */
|
||||
|
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)
|
||||
{
|
||||
|
||||
#ifndef Q_OS_MAC
|
||||
setCacheMode(QGraphicsItem::DeviceCoordinateCache);
|
||||
#endif // Q_OS_MAC
|
||||
}
|
||||
|
||||
void InfoItem::updateBoundingRect()
|
||||
@ -40,6 +42,9 @@ void InfoItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *option,
|
||||
QList<KV>::const_iterator i;
|
||||
int width = 0;
|
||||
|
||||
|
||||
painter->setRenderHint(QPainter::Antialiasing, false);
|
||||
|
||||
for (i = _list.constBegin(); i != _list.constEnd(); i++) {
|
||||
painter->drawText(width, fm.height() - fm.descent(), i->key + ": ");
|
||||
width += fm.width(i->key + ": ");
|
||||
@ -73,6 +78,7 @@ void InfoItem::insert(const QString &key, const QString &value)
|
||||
_list[i] = kv;
|
||||
|
||||
updateBoundingRect();
|
||||
update();
|
||||
}
|
||||
|
||||
void InfoItem::clear()
|
||||
|
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 <QDir>
|
||||
#include "downloader.h"
|
||||
#include "ll.h"
|
||||
#include "config.h"
|
||||
#include "map.h"
|
||||
|
||||
@ -91,7 +90,7 @@ void Map::loadTilesSync(QList<Tile> &list)
|
||||
|
||||
void Map::fillTile(Tile &tile)
|
||||
{
|
||||
tile.pixmap() = QPixmap(TILE_SIZE, TILE_SIZE);
|
||||
tile.pixmap() = QPixmap(Tile::size(), Tile::size());
|
||||
tile.pixmap().fill();
|
||||
}
|
||||
|
||||
|
19
src/map.h
@ -1,24 +1,7 @@
|
||||
#ifndef MAP_H
|
||||
#define MAP_H
|
||||
|
||||
#include <QPixmap>
|
||||
|
||||
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;
|
||||
};
|
||||
|
||||
#include "tile.h"
|
||||
|
||||
class Map : public QObject
|
||||
{
|
||||
|
@ -2,7 +2,8 @@
|
||||
#include "markeritem.h"
|
||||
|
||||
|
||||
#define SIZE 8
|
||||
#define SIZE 8
|
||||
#define WIDTH 2
|
||||
|
||||
MarkerItem::MarkerItem(QGraphicsItem *parent) : QGraphicsItem(parent)
|
||||
{
|
||||
@ -19,18 +20,11 @@ void MarkerItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *option
|
||||
{
|
||||
Q_UNUSED(option);
|
||||
Q_UNUSED(widget);
|
||||
bool aa;
|
||||
|
||||
|
||||
if ((aa = painter->testRenderHint(QPainter::Antialiasing)))
|
||||
painter->setRenderHint(QPainter::Antialiasing, false);
|
||||
|
||||
painter->setPen(Qt::red);
|
||||
painter->setRenderHint(QPainter::Antialiasing, false);
|
||||
painter->setPen(QPen(Qt::red, WIDTH));
|
||||
painter->drawLine(-SIZE/2, 0, SIZE/2, 0);
|
||||
painter->drawLine(0, -SIZE/2, 0, SIZE/2);
|
||||
|
||||
if (aa)
|
||||
painter->setRenderHint(QPainter::Antialiasing, true);
|
||||
|
||||
// painter->drawRect(boundingRect());
|
||||
}
|
||||
|
52
src/misc.cpp
@ -1,5 +1,5 @@
|
||||
#include <cmath>
|
||||
#include <QApplication>
|
||||
#include <cctype>
|
||||
#include "misc.h"
|
||||
|
||||
|
||||
@ -35,52 +35,16 @@ double niceNum(double x, int round)
|
||||
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;
|
||||
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 distance(qreal value, Units units)
|
||||
{
|
||||
if (units == Imperial) {
|
||||
if (value < MIINM)
|
||||
return QString::number(value * M2FT, 'f', 0) + UNIT_SPACE
|
||||
+ qApp->translate("Misc", "ft");
|
||||
for (const char *sp = str; sp < str + len; sp++) {
|
||||
if (::isdigit(*sp))
|
||||
res = res * 10 + *sp - '0';
|
||||
else
|
||||
return QString::number(value * M2MI, 'f', 1) + UNIT_SPACE
|
||||
+ 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");
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
QString elevation(qreal value, Units units)
|
||||
{
|
||||
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;
|
||||
return res;
|
||||
}
|
||||
|
10
src/misc.h
@ -1,15 +1,7 @@
|
||||
#ifndef MISC_H
|
||||
#define MISC_H
|
||||
|
||||
#include <QString>
|
||||
#include <QPoint>
|
||||
#include "units.h"
|
||||
|
||||
double niceNum(double x, int round);
|
||||
|
||||
QString timeSpan(qreal time);
|
||||
QString distance(qreal value, Units units);
|
||||
QString elevation(qreal value, Units units);
|
||||
QString coordinates(const QPointF &value);
|
||||
int str2int(const char *str, int len);
|
||||
|
||||
#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"
|
||||
|
||||
|
||||
#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)
|
||||
Palette::Palette(const QColor &color, qreal shift)
|
||||
{
|
||||
unsigned hi;
|
||||
float r = 0, g = 0, b = 0, p, q, t, f;
|
||||
_h = 0; _s = 0; _v = 0; _a = 1.0;
|
||||
|
||||
hi = (unsigned)(h * 6.0f);
|
||||
f = h * 6.0f - hi;
|
||||
p = v * (1.0f - s);
|
||||
q = v * (1.0f - f * s);
|
||||
t = v * (1.0f - (1.0f - f) * s);
|
||||
setColor(color);
|
||||
setShift(shift);
|
||||
|
||||
switch (hi) {
|
||||
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);
|
||||
_state = _h;
|
||||
}
|
||||
|
||||
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;
|
||||
_hueState -= (int) _hueState;
|
||||
if (shift >= 0 && shift <= 1.0)
|
||||
_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()
|
||||
{
|
||||
_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
|
||||
|
||||
#include <QColor>
|
||||
#include <QDebug>
|
||||
|
||||
class Palette
|
||||
{
|
||||
public:
|
||||
Palette();
|
||||
QColor color();
|
||||
Palette(const QColor &color = Qt::blue, qreal shift = 0.62);
|
||||
|
||||
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();
|
||||
|
||||
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:
|
||||
float _hueState;
|
||||
qreal _h, _s, _v, _a, _shift;
|
||||
qreal _state;
|
||||
};
|
||||
|
||||
QDebug operator<<(QDebug dbg, const Palette &palette);
|
||||
|
||||
#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
|
||||
#define PARSER_H
|
||||
|
||||
#include <QXmlStreamReader>
|
||||
#include <QVector>
|
||||
#include <QString>
|
||||
#include <QList>
|
||||
#include "trackpoint.h"
|
||||
#include <QFile>
|
||||
#include "trackdata.h"
|
||||
#include "routedata.h"
|
||||
#include "waypoint.h"
|
||||
|
||||
|
||||
class Parser
|
||||
{
|
||||
public:
|
||||
Parser(QList<QVector<Trackpoint> > &tracks,
|
||||
QList<QVector<Waypoint> > &routes, QList<Waypoint> &waypoints)
|
||||
: _tracks(tracks), _routes(routes), _waypoints(waypoints)
|
||||
{_track = 0; _route = 0;}
|
||||
Parser(QList<TrackData> &tracks, QList<RouteData> &routes,
|
||||
QList<Waypoint> &waypoints) : _tracks(tracks), _routes(routes),
|
||||
_waypoints(waypoints) {}
|
||||
virtual ~Parser() {}
|
||||
|
||||
bool loadFile(QIODevice *device);
|
||||
QString errorString() const {return _reader.errorString();}
|
||||
int errorLine() const {return _reader.lineNumber();}
|
||||
virtual bool loadFile(QFile *file) = 0;
|
||||
virtual QString errorString() const = 0;
|
||||
virtual int errorLine() const = 0;
|
||||
|
||||
private:
|
||||
enum DataType {
|
||||
Name, Description, Elevation, Time, Geoidheight, Speed, HeartRate,
|
||||
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;
|
||||
protected:
|
||||
QList<TrackData> &_tracks;
|
||||
QList<RouteData> &_routes;
|
||||
QList<Waypoint> &_waypoints;
|
||||
QVector<Trackpoint> *_track;
|
||||
QVector<Waypoint> *_route;
|
||||
};
|
||||
|
||||
#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 <QCursor>
|
||||
#include <QPainter>
|
||||
@ -5,25 +6,19 @@
|
||||
#include "pathitem.h"
|
||||
|
||||
|
||||
#define PATH_WIDTH 3
|
||||
#define HOVER_WIDTH 4
|
||||
|
||||
void PathItem::updateShape()
|
||||
{
|
||||
QPainterPathStroker s;
|
||||
s.setWidth(HOVER_WIDTH * 1.0/scale());
|
||||
s.setWidth((_width + 1) * 1.0/scale());
|
||||
_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)
|
||||
{
|
||||
_width = 3;
|
||||
|
||||
QBrush brush(Qt::SolidPattern);
|
||||
_pen = QPen(brush, PATH_WIDTH);
|
||||
_pen = QPen(brush, _width);
|
||||
|
||||
_units = Metric;
|
||||
|
||||
@ -53,7 +48,7 @@ void PathItem::setScale(qreal scale)
|
||||
{
|
||||
prepareGeometryChange();
|
||||
|
||||
_pen.setWidthF(PATH_WIDTH * 1.0/scale);
|
||||
_pen.setWidthF(_width * 1.0/scale);
|
||||
QGraphicsItem::setScale(scale);
|
||||
_marker->setScale(1.0/scale);
|
||||
|
||||
@ -66,26 +61,76 @@ void PathItem::setColor(const QColor &color)
|
||||
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)
|
||||
{
|
||||
_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)
|
||||
{
|
||||
if (distance > _distance)
|
||||
_marker->setVisible(false);
|
||||
else {
|
||||
if (distance >= _distance.first() && distance <= _distance.last()) {
|
||||
_marker->setVisible(true);
|
||||
_marker->setPos(_path.pointAtPercent(distance / _distance));
|
||||
}
|
||||
_marker->setPos(position(distance));
|
||||
} else
|
||||
_marker->setVisible(false);
|
||||
}
|
||||
|
||||
void PathItem::hoverEnterEvent(QGraphicsSceneHoverEvent *event)
|
||||
{
|
||||
Q_UNUSED(event);
|
||||
|
||||
_pen.setWidthF(HOVER_WIDTH * 1.0/scale());
|
||||
_pen.setWidthF((_width + 1) * 1.0/scale());
|
||||
setZValue(zValue() + 1.0);
|
||||
update();
|
||||
|
||||
@ -96,7 +141,7 @@ void PathItem::hoverLeaveEvent(QGraphicsSceneHoverEvent *event)
|
||||
{
|
||||
Q_UNUSED(event);
|
||||
|
||||
_pen.setWidthF(PATH_WIDTH * 1.0/scale());
|
||||
_pen.setWidthF(_width * 1.0/scale());
|
||||
setZValue(zValue() - 1.0);
|
||||
update();
|
||||
|
||||
|
@ -24,6 +24,8 @@ public:
|
||||
void setScale(qreal scale);
|
||||
void setUnits(enum Units units);
|
||||
void setColor(const QColor &color);
|
||||
void setWidth(int width);
|
||||
void setStyle(Qt::PenStyle style);
|
||||
|
||||
public slots:
|
||||
void moveMarker(qreal distance);
|
||||
@ -34,18 +36,20 @@ signals:
|
||||
protected:
|
||||
void updateShape();
|
||||
|
||||
QVector<qreal> _distance;
|
||||
QPainterPath _path;
|
||||
QPainterPath _shape;
|
||||
QPen _pen;
|
||||
|
||||
MarkerItem *_marker;
|
||||
|
||||
Units _units;
|
||||
qreal _distance;
|
||||
|
||||
private:
|
||||
QPointF position(qreal distance) const;
|
||||
|
||||
void hoverEnterEvent(QGraphicsSceneHoverEvent *event);
|
||||
void hoverLeaveEvent(QGraphicsSceneHoverEvent *event);
|
||||
|
||||
int _width;
|
||||
QPen _pen;
|
||||
QPainterPath _shape;
|
||||
};
|
||||
|
||||
#endif // PATHITEM_H
|
||||
|
456
src/pathview.cpp
@ -1,9 +1,12 @@
|
||||
#include <QGraphicsView>
|
||||
#include <QGraphicsScene>
|
||||
#include <QWheelEvent>
|
||||
#include "ll.h"
|
||||
#include <QSysInfo>
|
||||
#include "opengl.h"
|
||||
#include "rd.h"
|
||||
#include "wgs84.h"
|
||||
#include "poi.h"
|
||||
#include "gpx.h"
|
||||
#include "data.h"
|
||||
#include "map.h"
|
||||
#include "trackitem.h"
|
||||
#include "routeitem.h"
|
||||
@ -12,8 +15,77 @@
|
||||
#include "pathview.h"
|
||||
|
||||
|
||||
#define MARGIN 10.0
|
||||
#define SCALE_OFFSET 7
|
||||
#define ZOOM_MAX 18
|
||||
#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)
|
||||
: QGraphicsView(parent)
|
||||
@ -25,14 +97,14 @@ PathView::PathView(QWidget *parent)
|
||||
setViewportUpdateMode(QGraphicsView::FullViewportUpdate);
|
||||
setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
|
||||
setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
|
||||
setRenderHints(QPainter::Antialiasing);
|
||||
setRenderHint(QPainter::Antialiasing, true);
|
||||
setAcceptDrops(false);
|
||||
|
||||
_mapScale = new ScaleItem();
|
||||
_mapScale->setZValue(2.0);
|
||||
|
||||
_zoom = ZOOM_MAX;
|
||||
_scale = mapScale(_zoom);
|
||||
_res = 1.0;
|
||||
_map = 0;
|
||||
_poi = 0;
|
||||
|
||||
@ -46,8 +118,14 @@ PathView::PathView(QWidget *parent)
|
||||
_showPOILabels = true;
|
||||
_overlapPOIs = true;
|
||||
_showRouteWaypoints = true;
|
||||
_trackWidth = 3;
|
||||
_routeWidth = 3;
|
||||
_trackStyle = Qt::SolidLine;
|
||||
_routeStyle = Qt::DashLine;
|
||||
|
||||
_plot = false;
|
||||
|
||||
_scene->setSceneRect(scaled(mapBounds(), 1.0 / mapScale(_zoom)));
|
||||
}
|
||||
|
||||
PathView::~PathView()
|
||||
@ -59,16 +137,18 @@ PathView::~PathView()
|
||||
PathItem *PathView::addTrack(const Track &track)
|
||||
{
|
||||
if (track.isNull()) {
|
||||
_palette.color();
|
||||
_palette.nextColor();
|
||||
return 0;
|
||||
}
|
||||
|
||||
TrackItem *ti = new TrackItem(track);
|
||||
_tracks.append(ti);
|
||||
_zoom = qMin(_zoom, scale2zoom(trackScale()));
|
||||
_scale = mapScale(_zoom);
|
||||
ti->setScale(1.0/_scale);
|
||||
ti->setColor(_palette.color());
|
||||
_tr |= ti->path().boundingRect();
|
||||
_zoom = scale2zoom(contentsScale());
|
||||
ti->setScale(1.0/mapScale(_zoom));
|
||||
ti->setColor(_palette.nextColor());
|
||||
ti->setWidth(_trackWidth);
|
||||
ti->setStyle(_trackStyle);
|
||||
ti->setVisible(_showTracks);
|
||||
_scene->addItem(ti);
|
||||
|
||||
@ -81,16 +161,18 @@ PathItem *PathView::addTrack(const Track &track)
|
||||
PathItem *PathView::addRoute(const Route &route)
|
||||
{
|
||||
if (route.isNull()) {
|
||||
_palette.color();
|
||||
_palette.nextColor();
|
||||
return 0;
|
||||
}
|
||||
|
||||
RouteItem *ri = new RouteItem(route);
|
||||
_routes.append(ri);
|
||||
_zoom = qMin(_zoom, scale2zoom(routeScale()));
|
||||
_scale = mapScale(_zoom);
|
||||
ri->setScale(1.0/_scale);
|
||||
ri->setColor(_palette.color());
|
||||
_rr |= ri->path().boundingRect();
|
||||
_zoom = scale2zoom(contentsScale());
|
||||
ri->setScale(1.0/mapScale(_zoom));
|
||||
ri->setColor(_palette.nextColor());
|
||||
ri->setWidth(_routeWidth);
|
||||
ri->setStyle(_routeStyle);
|
||||
ri->setVisible(_showRoutes);
|
||||
ri->showWaypoints(_showRouteWaypoints);
|
||||
ri->showWaypointLabels(_showWaypointLabels);
|
||||
@ -104,171 +186,100 @@ PathItem *PathView::addRoute(const Route &route)
|
||||
|
||||
void PathView::addWaypoints(const QList<Waypoint> &waypoints)
|
||||
{
|
||||
qreal scale = mapScale(_zoom);
|
||||
|
||||
for (int i = 0; i < waypoints.count(); i++) {
|
||||
const Waypoint &w = waypoints.at(i);
|
||||
|
||||
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->showLabel(_showWaypointLabels);
|
||||
wi->setVisible(_showWaypoints);
|
||||
_scene->addItem(wi);
|
||||
|
||||
_waypoints.append(wi);
|
||||
}
|
||||
|
||||
if (_poi)
|
||||
addPOI(_poi->points(waypoints));
|
||||
|
||||
_zoom = qMin(_zoom, scale2zoom(waypointScale()));
|
||||
_scale = mapScale(_zoom);
|
||||
_zoom = scale2zoom(contentsScale());
|
||||
}
|
||||
|
||||
QList<PathItem *> PathView::loadGPX(const GPX &gpx)
|
||||
QList<PathItem *> PathView::loadData(const Data &data)
|
||||
{
|
||||
QList<PathItem *> paths;
|
||||
int zoom = _zoom;
|
||||
|
||||
|
||||
for (int i = 0; i < gpx.tracks().count(); i++)
|
||||
paths.append(addTrack(*(gpx.tracks().at(i))));
|
||||
for (int i = 0; i < gpx.routes().count(); i++)
|
||||
paths.append(addRoute(*(gpx.routes().at(i))));
|
||||
addWaypoints(gpx.waypoints());
|
||||
for (int i = 0; i < data.tracks().count(); i++)
|
||||
paths.append(addTrack(*(data.tracks().at(i))));
|
||||
|
||||
for (int i = 0; i < data.routes().count(); i++)
|
||||
paths.append(addRoute(*(data.routes().at(i))));
|
||||
|
||||
addWaypoints(data.waypoints());
|
||||
|
||||
if (_tracks.empty() && _routes.empty() && _waypoints.empty())
|
||||
return paths;
|
||||
|
||||
if ((_tracks.size() + _routes.size() > 1 && _zoom < zoom)
|
||||
|| (_waypoints.size() && _zoom < zoom))
|
||||
rescale(_scale);
|
||||
if (_zoom < zoom)
|
||||
rescale(_zoom);
|
||||
else
|
||||
updatePOIVisibility();
|
||||
|
||||
QRectF br = trackBoundingRect() | routeBoundingRect()
|
||||
| waypointBoundingRect();
|
||||
QRectF ba = br.adjusted(-TILE_SIZE, -TILE_SIZE, TILE_SIZE, TILE_SIZE);
|
||||
_scene->setSceneRect(ba);
|
||||
centerOn(ba.center());
|
||||
QPointF center = contentsCenter();
|
||||
centerOn(center);
|
||||
|
||||
_mapScale->setZoom(_zoom, -(br.center().ry() * _scale));
|
||||
_res = zoom2resolution(_zoom, -(center.y() * mapScale(_zoom)));
|
||||
_mapScale->setResolution(_res);
|
||||
if (_mapScale->scene() != _scene)
|
||||
_scene->addItem(_mapScale);
|
||||
|
||||
return paths;
|
||||
}
|
||||
|
||||
QRectF PathView::trackBoundingRect() const
|
||||
void PathView::updateWaypointsBoundingRect(const QPointF &wp)
|
||||
{
|
||||
if (_tracks.empty())
|
||||
return QRectF();
|
||||
|
||||
QRectF br = _tracks.at(0)->sceneBoundingRect();
|
||||
for (int i = 1; i < _tracks.size(); i++)
|
||||
br |= _tracks.at(i)->sceneBoundingRect();
|
||||
|
||||
return br;
|
||||
if (_wr.isNull()) {
|
||||
if (_wp.isNull())
|
||||
_wp = wp;
|
||||
else {
|
||||
_wr = QRectF(_wp, wp).normalized();
|
||||
_wp = QPointF();
|
||||
}
|
||||
} else
|
||||
unite(_wr, wp);
|
||||
}
|
||||
|
||||
QRectF PathView::routeBoundingRect() const
|
||||
qreal PathView::contentsScale() const
|
||||
{
|
||||
if (_routes.empty())
|
||||
return QRectF();
|
||||
QRectF br = _tr | _rr | _wr;
|
||||
if (!br.isNull() && !_wp.isNull())
|
||||
unite(br, _wp);
|
||||
|
||||
QRectF br = _routes.at(0)->sceneBoundingRect();
|
||||
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())
|
||||
if (br.isNull())
|
||||
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),
|
||||
br.height() / (viewport()->height() - MARGIN/2));
|
||||
|
||||
return qMax(sc.x(), sc.y());
|
||||
}
|
||||
|
||||
qreal PathView::routeScale() const
|
||||
QPointF PathView::contentsCenter() const
|
||||
{
|
||||
if (_routes.empty())
|
||||
return mapScale(ZOOM_MAX);
|
||||
QRectF br = _tr | _rr | _wr;
|
||||
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++)
|
||||
br |= _routes.at(i)->path().boundingRect();
|
||||
|
||||
QPointF sc(br.width() / (viewport()->width() - MARGIN/2),
|
||||
br.height() / (viewport()->height() - MARGIN/2));
|
||||
|
||||
return qMax(sc.x(), sc.y());
|
||||
}
|
||||
|
||||
qreal PathView::waypointScale() const
|
||||
{
|
||||
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);
|
||||
if (br.isNull())
|
||||
return _wp / scale;
|
||||
else
|
||||
return scaled(br, 1.0/scale).center();
|
||||
}
|
||||
|
||||
void PathView::updatePOIVisibility()
|
||||
@ -292,9 +303,12 @@ void PathView::updatePOIVisibility()
|
||||
}
|
||||
}
|
||||
|
||||
void PathView::rescale(qreal scale)
|
||||
void PathView::rescale(int zoom)
|
||||
{
|
||||
_scale = scale;
|
||||
_zoom = zoom;
|
||||
qreal scale = mapScale(zoom);
|
||||
|
||||
_scene->setSceneRect(scaled(mapBounds(), 1.0 / scale));
|
||||
|
||||
for (int i = 0; i < _tracks.size(); i++)
|
||||
_tracks.at(i)->setScale(1.0/scale);
|
||||
@ -312,6 +326,17 @@ void PathView::rescale(qreal scale)
|
||||
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)
|
||||
@ -349,6 +374,8 @@ void PathView::updatePOI()
|
||||
|
||||
void PathView::addPOI(const QVector<Waypoint> &waypoints)
|
||||
{
|
||||
qreal scale = mapScale(_zoom);
|
||||
|
||||
for (int i = 0; i < waypoints.size(); i++) {
|
||||
const Waypoint &w = waypoints.at(i);
|
||||
|
||||
@ -356,7 +383,7 @@ void PathView::addPOI(const QVector<Waypoint> &waypoints)
|
||||
continue;
|
||||
|
||||
WaypointItem *pi = new WaypointItem(w);
|
||||
pi->setScale(1.0/_scale);
|
||||
pi->setScale(1.0/scale);
|
||||
pi->setZValue(1);
|
||||
pi->showLabel(_showPOILabels);
|
||||
pi->setVisible(_showPOI);
|
||||
@ -402,50 +429,45 @@ void PathView::redraw()
|
||||
resetCachedContent();
|
||||
}
|
||||
|
||||
void PathView::rescale()
|
||||
{
|
||||
_zoom = qMin(qMin(scale2zoom(trackScale()), scale2zoom(routeScale())),
|
||||
scale2zoom(waypointScale()));
|
||||
|
||||
rescale(mapScale(_zoom));
|
||||
_mapScale->setZoom(_zoom);
|
||||
}
|
||||
|
||||
void PathView::zoom(int z, const QPointF &pos)
|
||||
void PathView::zoom(int z, const QPoint &pos)
|
||||
{
|
||||
if (_tracks.isEmpty() && _routes.isEmpty() && _waypoints.isEmpty())
|
||||
return;
|
||||
|
||||
qreal scale = _scale;
|
||||
QPoint offset = pos - viewport()->rect().center();
|
||||
QPointF spos = mapToScene(pos);
|
||||
|
||||
qreal os = mapScale(_zoom);
|
||||
_zoom = z;
|
||||
|
||||
rescale(mapScale(_zoom));
|
||||
QRectF br = trackBoundingRect() | routeBoundingRect()
|
||||
| waypointBoundingRect();
|
||||
QRectF ba = br.adjusted(-TILE_SIZE, -TILE_SIZE, TILE_SIZE, TILE_SIZE);
|
||||
_scene->setSceneRect(ba);
|
||||
rescale(_zoom);
|
||||
|
||||
if (br.width() < viewport()->size().width()
|
||||
&& br.height() < viewport()->size().height())
|
||||
centerOn(br.center());
|
||||
else
|
||||
centerOn(pos * scale/_scale);
|
||||
QPointF center = (spos * (os/mapScale(_zoom))) - offset;
|
||||
centerOn(center);
|
||||
|
||||
_mapScale->setZoom(_zoom);
|
||||
_res = zoom2resolution(_zoom, -(center.y() * mapScale(_zoom)));
|
||||
_mapScale->setResolution(_res);
|
||||
|
||||
resetCachedContent();
|
||||
}
|
||||
|
||||
void PathView::wheelEvent(QWheelEvent *event)
|
||||
{
|
||||
if (_tracks.isEmpty() && _routes.isEmpty() && _waypoints.isEmpty())
|
||||
return;
|
||||
|
||||
QPointF pos = mapToScene(event->pos());
|
||||
int z = (event->delta() > 0) ?
|
||||
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)
|
||||
@ -458,7 +480,7 @@ void PathView::keyPressEvent(QKeyEvent *event)
|
||||
z = qMax(_zoom - 1, ZOOM_MIN);
|
||||
|
||||
if (z >= 0)
|
||||
zoom(z, mapToScene(QRect(QPoint(), size()).center()));
|
||||
zoom(z, QRect(QPoint(), size()).center());
|
||||
else
|
||||
QWidget::keyPressEvent(event);
|
||||
}
|
||||
@ -510,9 +532,11 @@ void PathView::clear()
|
||||
_palette.reset();
|
||||
|
||||
_zoom = ZOOM_MAX;
|
||||
_scale = mapScale(_zoom);
|
||||
_res = 1.0;
|
||||
_tr = QRectF(); _rr = QRectF(); _wr = QRectF();
|
||||
_wp = QPointF();
|
||||
|
||||
_scene->setSceneRect(QRectF());
|
||||
_scene->setSceneRect(scaled(mapBounds(), 1.0 / mapScale(_zoom)));
|
||||
}
|
||||
|
||||
void PathView::showTracks(bool show)
|
||||
@ -587,6 +611,38 @@ void PathView::setPOIOverlap(bool overlap)
|
||||
updatePOIVisibility();
|
||||
}
|
||||
|
||||
void PathView::setTrackWidth(int width)
|
||||
{
|
||||
_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)
|
||||
{
|
||||
if ((_tracks.isEmpty() && _routes.isEmpty() && _waypoints.isEmpty())
|
||||
@ -595,57 +651,51 @@ void PathView::drawBackground(QPainter *painter, const QRectF &rect)
|
||||
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()),
|
||||
_zoom);
|
||||
QPointF tm = tile2mercator(tile, _zoom);
|
||||
QPoint tl = mapToScene(mapFromScene(QPointF(tm.x() / _scale,
|
||||
-tm.y() / _scale))).toPoint();
|
||||
QPoint tl = QPoint((int)(tm.x() / scale), (int)(-tm.y() / scale));
|
||||
|
||||
|
||||
QList<Tile> tiles;
|
||||
for (int i = 0; i <= rr.size().width() / TILE_SIZE + 1; i++) {
|
||||
for (int j = 0; j <= rr.size().height() / TILE_SIZE + 1; j++) {
|
||||
QSizeF s(rect.right() - tl.x(), rect.bottom() - tl.y());
|
||||
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));
|
||||
}
|
||||
}
|
||||
|
||||
_map->loadTiles(tiles, _plot);
|
||||
|
||||
for (int i = 0; i < tiles.count(); i++) {
|
||||
Tile &t = tiles[i];
|
||||
QPoint tp(tl.x() + (t.xy().x() - tile.x()) * TILE_SIZE,
|
||||
tl.y() + (t.xy().y() - tile.y()) * TILE_SIZE);
|
||||
QPoint tp(tl.x() + (t.xy().x() - tile.x()) * Tile::size(),
|
||||
tl.y() + (t.xy().y() - tile.y()) * Tile::size());
|
||||
painter->drawPixmap(tp, t.pixmap());
|
||||
}
|
||||
}
|
||||
|
||||
void PathView::resizeEvent(QResizeEvent *e)
|
||||
void PathView::resizeEvent(QResizeEvent *event)
|
||||
{
|
||||
Q_UNUSED(event);
|
||||
|
||||
if (_tracks.isEmpty() && _routes.isEmpty() && _waypoints.isEmpty())
|
||||
return;
|
||||
|
||||
rescale();
|
||||
int zoom = scale2zoom(contentsScale());
|
||||
if (zoom != _zoom)
|
||||
rescale(zoom);
|
||||
|
||||
QRectF br = trackBoundingRect() | routeBoundingRect()
|
||||
| waypointBoundingRect();
|
||||
QRectF ba = br.adjusted(-TILE_SIZE, -TILE_SIZE, TILE_SIZE, TILE_SIZE);
|
||||
QPointF center = contentsCenter();
|
||||
centerOn(center);
|
||||
|
||||
if (ba.width() < e->size().width()) {
|
||||
qreal diff = e->size().width() - ba.width();
|
||||
ba.adjust(-diff/2, 0, diff/2, 0);
|
||||
}
|
||||
if (ba.height() < e->size().height()) {
|
||||
qreal diff = e->size().height() - ba.height();
|
||||
ba.adjust(0, -diff/2, 0, diff/2);
|
||||
}
|
||||
_res = zoom2resolution(_zoom, -(center.y() * mapScale(_zoom)));
|
||||
_mapScale->setResolution(_res);
|
||||
|
||||
_scene->setSceneRect(ba);
|
||||
|
||||
centerOn(br.center());
|
||||
resetCachedContent();
|
||||
}
|
||||
|
||||
void PathView::paintEvent(QPaintEvent *e)
|
||||
void PathView::paintEvent(QPaintEvent *event)
|
||||
{
|
||||
QPointF scenePos = mapToScene(rect().bottomRight() + QPoint(
|
||||
-(SCALE_OFFSET + _mapScale->boundingRect().width()),
|
||||
@ -653,5 +703,29 @@ void PathView::paintEvent(QPaintEvent *e)
|
||||
if (_mapScale->pos() != scenePos && !_plot)
|
||||
_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 "waypoint.h"
|
||||
|
||||
class GPX;
|
||||
class Data;
|
||||
class POI;
|
||||
class Map;
|
||||
class Track;
|
||||
@ -28,8 +28,9 @@ public:
|
||||
PathView(QWidget *parent = 0);
|
||||
~PathView();
|
||||
|
||||
QList<PathItem*> loadGPX(const GPX &gpx);
|
||||
QList<PathItem*> loadData(const Data &data);
|
||||
|
||||
void setPalette(const Palette &palette);
|
||||
void setPOI(POI *poi);
|
||||
void setMap(Map *map);
|
||||
void setUnits(enum Units units);
|
||||
@ -42,6 +43,8 @@ public:
|
||||
|
||||
void clear();
|
||||
|
||||
void useOpenGL(bool use);
|
||||
|
||||
public slots:
|
||||
void redraw();
|
||||
|
||||
@ -53,6 +56,10 @@ public slots:
|
||||
void showRoutes(bool show);
|
||||
void showWaypoints(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();
|
||||
@ -65,23 +72,20 @@ private:
|
||||
void loadPOI();
|
||||
void clearPOI();
|
||||
|
||||
QRectF trackBoundingRect() const;
|
||||
QRectF routeBoundingRect() const;
|
||||
QRectF waypointBoundingRect() const;
|
||||
qreal trackScale() const;
|
||||
qreal routeScale() const;
|
||||
qreal waypointScale() const;
|
||||
qreal mapScale(int zoom) const;
|
||||
void rescale(qreal scale);
|
||||
void rescale();
|
||||
void zoom(int z, const QPointF &pos);
|
||||
qreal contentsScale() const;
|
||||
QPointF contentsCenter() const;
|
||||
void rescale(int zoom);
|
||||
void zoom(int z, const QPoint &pos);
|
||||
void updatePOIVisibility();
|
||||
void updateWaypointsBoundingRect(const QPointF &wp);
|
||||
|
||||
void mouseDoubleClickEvent(QMouseEvent *event);
|
||||
void wheelEvent(QWheelEvent *event);
|
||||
void keyPressEvent(QKeyEvent *event);
|
||||
void drawBackground(QPainter *painter, const QRectF &rect);
|
||||
void resizeEvent(QResizeEvent *e);
|
||||
void paintEvent(QPaintEvent *e);
|
||||
void resizeEvent(QResizeEvent *event);
|
||||
void paintEvent(QPaintEvent *event);
|
||||
void scrollContentsBy(int dx, int dy);
|
||||
|
||||
QGraphicsScene *_scene;
|
||||
ScaleItem *_mapScale;
|
||||
@ -90,14 +94,14 @@ private:
|
||||
QList<WaypointItem*> _waypoints;
|
||||
QHash<Waypoint, WaypointItem*> _pois;
|
||||
|
||||
int _zoom;
|
||||
QRectF _tr, _rr, _wr;
|
||||
QPointF _wp;
|
||||
qreal _res;
|
||||
|
||||
Map *_map;
|
||||
POI *_poi;
|
||||
|
||||
Palette _palette;
|
||||
|
||||
qreal _scale;
|
||||
int _zoom;
|
||||
|
||||
Units _units;
|
||||
|
||||
bool _showTracks;
|
||||
@ -108,6 +112,10 @@ private:
|
||||
bool _showPOILabels;
|
||||
bool _overlapPOIs;
|
||||
bool _showRouteWaypoints;
|
||||
int _trackWidth;
|
||||
int _routeWidth;
|
||||
Qt::PenStyle _trackStyle;
|
||||
Qt::PenStyle _routeStyle;
|
||||
|
||||
bool _plot;
|
||||
};
|
||||
|
173
src/poi.cpp
@ -3,145 +3,50 @@
|
||||
#include <QList>
|
||||
#include "pathitem.h"
|
||||
#include "waypointitem.h"
|
||||
#include "ll.h"
|
||||
#include "gpx.h"
|
||||
#include "data.h"
|
||||
#include "poi.h"
|
||||
|
||||
|
||||
POI::POI(QObject *parent) : QObject(parent)
|
||||
{
|
||||
_errorLine = 0;
|
||||
_radius = 0.01;
|
||||
_radius = 1000;
|
||||
}
|
||||
|
||||
bool POI::loadFile(const QString &fileName)
|
||||
{
|
||||
QString error;
|
||||
int errorLine;
|
||||
Data data;
|
||||
FileIndex index;
|
||||
|
||||
_error.clear();
|
||||
_errorString.clear();
|
||||
_errorLine = 0;
|
||||
|
||||
if (loadCSVFile(fileName)) {
|
||||
emit pointsChanged();
|
||||
return true;
|
||||
} else {
|
||||
error = _error;
|
||||
errorLine = _errorLine;
|
||||
}
|
||||
if (loadGPXFile(fileName)) {
|
||||
emit pointsChanged();
|
||||
return true;
|
||||
}
|
||||
|
||||
fprintf(stderr, "Error loading POI file: %s:\n", qPrintable(fileName));
|
||||
fprintf(stderr, "CSV: line %d: %s\n", errorLine, qPrintable(error));
|
||||
fprintf(stderr, "GPX: line %d: %s\n", _errorLine, qPrintable(_error));
|
||||
|
||||
if (errorLine > _errorLine) {
|
||||
_errorLine = errorLine;
|
||||
_error = error;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
bool POI::loadGPXFile(const QString &fileName)
|
||||
{
|
||||
GPX gpx;
|
||||
FileIndex index;
|
||||
|
||||
index.enabled = true;
|
||||
index.start = _data.size();
|
||||
|
||||
if (gpx.loadFile(fileName)) {
|
||||
for (int i = 0; i < gpx.waypoints().size(); i++)
|
||||
_data.append(gpx.waypoints().at(i));
|
||||
index.end = _data.size() - 1;
|
||||
|
||||
for (int i = index.start; i <= index.end; i++) {
|
||||
const QPointF &p = _data.at(i).coordinates();
|
||||
qreal c[2];
|
||||
c[0] = p.x();
|
||||
c[1] = p.y();
|
||||
_tree.Insert(c, c, i);
|
||||
}
|
||||
|
||||
_files.append(fileName);
|
||||
_indexes.append(index);
|
||||
|
||||
return true;
|
||||
} else {
|
||||
_error = gpx.errorString();
|
||||
_errorLine = gpx.errorLine();
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
bool POI::loadCSVFile(const QString &fileName)
|
||||
{
|
||||
QFile file(fileName);
|
||||
FileIndex index;
|
||||
bool ret;
|
||||
int ln = 1;
|
||||
|
||||
index.enabled = true;
|
||||
index.start = _data.size();
|
||||
|
||||
if (!file.open(QFile::ReadOnly | QFile::Text)) {
|
||||
_error = qPrintable(file.errorString());
|
||||
if (!data.loadFile(fileName)) {
|
||||
_errorString = data.errorString();
|
||||
_errorLine = data.errorLine();
|
||||
return false;
|
||||
}
|
||||
|
||||
while (!file.atEnd()) {
|
||||
QByteArray line = file.readLine();
|
||||
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++;
|
||||
}
|
||||
for (int i = 0; i < data.waypoints().size(); i++)
|
||||
_data.append(data.waypoints().at(i));
|
||||
index.end = _data.size() - 1;
|
||||
|
||||
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];
|
||||
c[0] = p.x();
|
||||
c[1] = p.y();
|
||||
c[0] = p.lon();
|
||||
c[1] = p.lat();
|
||||
_tree.Insert(c, c, i);
|
||||
}
|
||||
|
||||
_files.append(fileName);
|
||||
_indexes.append(index);
|
||||
|
||||
emit pointsChanged();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -161,11 +66,15 @@ QVector<Waypoint> POI::points(const PathItem *path) const
|
||||
const QPainterPath &pp = path->path();
|
||||
|
||||
for (int i = 0; i < pp.elementCount(); i++) {
|
||||
QPointF p = mercator2ll(pp.elementAt(i));
|
||||
min[0] = p.x() - _radius;
|
||||
min[1] = -p.y() - _radius;
|
||||
max[0] = p.x() + _radius;
|
||||
max[1] = -p.y() + _radius;
|
||||
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();
|
||||
|
||||
_tree.Search(min, max, cb, &set);
|
||||
}
|
||||
|
||||
@ -186,11 +95,14 @@ QVector<Waypoint> POI::points(const QList<WaypointItem*> &list)
|
||||
qreal min[2], max[2];
|
||||
|
||||
for (int i = 0; i < list.count(); i++) {
|
||||
const QPointF &p = list.at(i)->waypoint().coordinates();
|
||||
min[0] = p.x() - _radius;
|
||||
min[1] = p.y() - _radius;
|
||||
max[0] = p.x() + _radius;
|
||||
max[1] = p.y() + _radius;
|
||||
const Coordinates &p = list.at(i)->waypoint().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);
|
||||
}
|
||||
|
||||
@ -210,11 +122,14 @@ QVector<Waypoint> POI::points(const QList<Waypoint> &list) const
|
||||
qreal min[2], max[2];
|
||||
|
||||
for (int i = 0; i < list.count(); i++) {
|
||||
const QPointF &p = list.at(i).coordinates();
|
||||
min[0] = p.x() - _radius;
|
||||
min[1] = p.y() - _radius;
|
||||
max[0] = p.x() + _radius;
|
||||
max[1] = p.y() + _radius;
|
||||
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);
|
||||
}
|
||||
|
||||
@ -242,10 +157,10 @@ void POI::enableFile(const QString &fileName, bool enable)
|
||||
continue;
|
||||
|
||||
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];
|
||||
c[0] = p.x();
|
||||
c[1] = p.y();
|
||||
c[0] = p.lon();
|
||||
c[1] = p.lat();
|
||||
_tree.Insert(c, c, j);
|
||||
}
|
||||
}
|
||||
@ -263,7 +178,7 @@ void POI::clear()
|
||||
emit pointsChanged();
|
||||
}
|
||||
|
||||
void POI::setRadius(qreal radius)
|
||||
void POI::setRadius(unsigned radius)
|
||||
{
|
||||
_radius = radius;
|
||||
|
||||
|
13
src/poi.h
@ -19,11 +19,11 @@ public:
|
||||
POI(QObject *parent = 0);
|
||||
|
||||
bool loadFile(const QString &fileName);
|
||||
const QString &errorString() const {return _error;}
|
||||
const QString &errorString() const {return _errorString;}
|
||||
int errorLine() const {return _errorLine;}
|
||||
|
||||
qreal radius() const {return _radius;}
|
||||
void setRadius(qreal radius);
|
||||
unsigned radius() const {return _radius;}
|
||||
void setRadius(unsigned radius);
|
||||
|
||||
QVector<Waypoint> points(const PathItem *path) const;
|
||||
QVector<Waypoint> points(const QList<WaypointItem*> &list) const;
|
||||
@ -44,17 +44,14 @@ private:
|
||||
bool enabled;
|
||||
} FileIndex;
|
||||
|
||||
bool loadCSVFile(const QString &fileName);
|
||||
bool loadGPXFile(const QString &fileName);
|
||||
|
||||
POITree _tree;
|
||||
QVector<Waypoint> _data;
|
||||
QStringList _files;
|
||||
QList<FileIndex> _indexes;
|
||||
|
||||
qreal _radius;
|
||||
unsigned _radius;
|
||||
|
||||
QString _error;
|
||||
QString _errorString;
|
||||
int _errorLine;
|
||||
};
|
||||
|
||||
|