Compare commits
65 Commits
Author | SHA1 | Date | |
---|---|---|---|
8a90a736d2 | |||
aac9bf024b | |||
585ded6b1c | |||
b9098c0dc5 | |||
584245785e | |||
66ce91c237 | |||
d134938ff8 | |||
9e583a9dab | |||
62ff4bb7c4 | |||
4b66aaa78b | |||
c97aa9c25d | |||
f1c6db0b46 | |||
9bd70ec96e | |||
984d3bb6c5 | |||
87a4398131 | |||
324ac2e0f4 | |||
8591d3f34c | |||
1a53968bd3 | |||
82cf7b49ca | |||
9789982626 | |||
eb03fe6ead | |||
0d1b416c4f | |||
c89f8dbb47 | |||
e4d777bace | |||
640829d89d | |||
78fb5c1547 | |||
6a25ad6379 | |||
5693375a3f | |||
10b903c129 | |||
9a0d304e8d | |||
0e5eb7287d | |||
7827509a4a | |||
974290ce8b | |||
09c097cc68 | |||
7f12c0ca95 | |||
a773921da0 | |||
b67428065f | |||
5bbf117f64 | |||
1744764025 | |||
c425b3868d | |||
84e61c657e | |||
721ee2aaa9 | |||
6cc22afcdc | |||
b99def1b30 | |||
1c5a19a33a | |||
27194d3d36 | |||
375ef20592 | |||
e86c19635e | |||
d7fd40d9d2 | |||
94fc5e17d0 | |||
425c75416a | |||
1160c6d385 | |||
a6b2a477a1 | |||
0ca264b176 | |||
be3c101c07 | |||
cb52ad8bc5 | |||
12d5dcc78c | |||
afd87c6fa2 | |||
c7d68f924f | |||
89304c0d5c | |||
c57a0f4061 | |||
f02ff1fa01 | |||
434df521fb | |||
9d90b97ba3 | |||
09631de5a2 |
111
Info.plist
@ -35,6 +35,54 @@
|
||||
<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/octet-stream</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>
|
||||
</array>
|
||||
|
||||
<key>UTImportedTypeDeclarations</key>
|
||||
@ -60,6 +108,69 @@
|
||||
<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/octet-stream</string>
|
||||
</dict>
|
||||
</dict>
|
||||
</array>
|
||||
|
||||
</dict>
|
||||
|
51
gpxsee.pro
@ -1,5 +1,5 @@
|
||||
TARGET = GPXSee
|
||||
VERSION = 2.19
|
||||
VERSION = 3.0
|
||||
QT += core \
|
||||
gui \
|
||||
network
|
||||
@ -8,11 +8,8 @@ greaterThan(QT_MAJOR_VERSION, 4): QT += printsupport
|
||||
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 +49,29 @@ 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
|
||||
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 +104,37 @@ 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
|
||||
RESOURCES += gpxsee.qrc
|
||||
TRANSLATIONS = lang/gpxsee_cs.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 \
|
||||
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
|
||||
}
|
||||
DEFINES += APP_VERSION=\\\"$$VERSION\\\"
|
||||
|
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/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/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/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 |
@ -1,11 +1,35 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!DOCTYPE TS>
|
||||
<TS version="2.1" language="cs_CZ">
|
||||
<context>
|
||||
<name>CadenceGraph</name>
|
||||
<message>
|
||||
<location filename="../src/cadencegraph.cpp" line="10"/>
|
||||
<source>1/min</source>
|
||||
<translation>1/min</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/cadencegraph.cpp" line="11"/>
|
||||
<location filename="../src/cadencegraph.h" line="13"/>
|
||||
<source>Cadence</source>
|
||||
<translation>Kadence</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/cadencegraph.cpp" line="19"/>
|
||||
<source>Average</source>
|
||||
<translation>Průměr</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/cadencegraph.cpp" line="21"/>
|
||||
<source>Maximum</source>
|
||||
<translation>Maximum</translation>
|
||||
</message>
|
||||
</context>
|
||||
<context>
|
||||
<name>ElevationGraph</name>
|
||||
<message>
|
||||
<location filename="../src/elevationgraph.cpp" line="48"/>
|
||||
<location filename="../src/elevationgraph.h" line="16"/>
|
||||
<location filename="../src/elevationgraph.h" line="13"/>
|
||||
<source>Elevation</source>
|
||||
<translation>Výška</translation>
|
||||
</message>
|
||||
@ -43,7 +67,7 @@
|
||||
<context>
|
||||
<name>ExportDialog</name>
|
||||
<message>
|
||||
<location filename="../src/exportdialog.cpp" line="121"/>
|
||||
<location filename="../src/exportdialog.cpp" line="122"/>
|
||||
<source>Export to PDF</source>
|
||||
<translation>Exportovat do PDF</translation>
|
||||
</message>
|
||||
@ -98,34 +122,34 @@
|
||||
<translation>Soubor:</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/exportdialog.cpp" line="99"/>
|
||||
<location filename="../src/exportdialog.cpp" line="100"/>
|
||||
<source>Output file</source>
|
||||
<translation>Výstupní soubor</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/exportdialog.cpp" line="106"/>
|
||||
<location filename="../src/exportdialog.cpp" line="107"/>
|
||||
<source>Export</source>
|
||||
<translation>Exportovat</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/exportdialog.cpp" line="128"/>
|
||||
<location filename="../src/exportdialog.cpp" line="138"/>
|
||||
<location filename="../src/exportdialog.cpp" line="143"/>
|
||||
<location filename="../src/exportdialog.cpp" line="129"/>
|
||||
<location filename="../src/exportdialog.cpp" line="139"/>
|
||||
<location filename="../src/exportdialog.cpp" line="144"/>
|
||||
<source>Error</source>
|
||||
<translation>Chyba</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/exportdialog.cpp" line="128"/>
|
||||
<location filename="../src/exportdialog.cpp" line="129"/>
|
||||
<source>No output file selected.</source>
|
||||
<translation>Nebyl zvolen žádný výstupní soubor.</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/exportdialog.cpp" line="138"/>
|
||||
<location filename="../src/exportdialog.cpp" line="139"/>
|
||||
<source>%1 is a directory.</source>
|
||||
<translation>%1 je adresář.</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/exportdialog.cpp" line="143"/>
|
||||
<location filename="../src/exportdialog.cpp" line="144"/>
|
||||
<source>%1 is not writable.</source>
|
||||
<translation>%1 nelze zapsat.</translation>
|
||||
</message>
|
||||
@ -133,440 +157,485 @@
|
||||
<context>
|
||||
<name>FileSelectWidget</name>
|
||||
<message>
|
||||
<location filename="../src/fileselectwidget.cpp" line="15"/>
|
||||
<source>Browse...</source>
|
||||
<translation>Procházet...</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/fileselectwidget.cpp" line="28"/>
|
||||
<location filename="../src/fileselectwidget.cpp" line="38"/>
|
||||
<source>Select file</source>
|
||||
<translation>Vybrat soubor</translation>
|
||||
</message>
|
||||
</context>
|
||||
<context>
|
||||
<name>Format</name>
|
||||
<message>
|
||||
<location filename="../src/format.cpp" line="22"/>
|
||||
<location filename="../src/format.cpp" line="43"/>
|
||||
<source>ft</source>
|
||||
<translation>ft</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/format.cpp" line="25"/>
|
||||
<source>mi</source>
|
||||
<translation>mi</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/format.cpp" line="29"/>
|
||||
<location filename="../src/format.cpp" line="40"/>
|
||||
<source>m</source>
|
||||
<translation>m</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/format.cpp" line="32"/>
|
||||
<source>km</source>
|
||||
<translation>km</translation>
|
||||
</message>
|
||||
</context>
|
||||
<context>
|
||||
<name>GUI</name>
|
||||
<message>
|
||||
<location filename="../src/gui.cpp" line="513"/>
|
||||
<location filename="../src/gui.cpp" line="550"/>
|
||||
<source>GPXSee is distributed under the terms of the GNU General Public License version 3. For more info about GPXSee visit the project homepage at </source>
|
||||
<translation>Program GPXSee je distribuován pod podmínkami licence GNU General Public License verze 3. Pro více informací navštivte stránky programu na adrese </translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/gui.cpp" line="577"/>
|
||||
<location filename="../src/gui.cpp" line="614"/>
|
||||
<source>Open file</source>
|
||||
<translation>Otevřít soubor</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/gui.cpp" line="658"/>
|
||||
<location filename="../src/gui.cpp" line="695"/>
|
||||
<source>Open POI file</source>
|
||||
<translation>Otevřít POI soubor</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/gui.cpp" line="204"/>
|
||||
<location filename="../src/gui.cpp" line="225"/>
|
||||
<source>Open</source>
|
||||
<translation>Otevřít</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/gui.cpp" line="188"/>
|
||||
<location filename="../src/gui.cpp" line="209"/>
|
||||
<source>Quit</source>
|
||||
<translation>Ukončit</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/gui.cpp" line="196"/>
|
||||
<location filename="../src/gui.cpp" line="529"/>
|
||||
<location filename="../src/gui.cpp" line="530"/>
|
||||
<location filename="../src/gui.cpp" line="217"/>
|
||||
<location filename="../src/gui.cpp" line="566"/>
|
||||
<location filename="../src/gui.cpp" line="567"/>
|
||||
<source>Keyboard controls</source>
|
||||
<translation>Ovládací klávesy</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/gui.cpp" line="220"/>
|
||||
<location filename="../src/gui.cpp" line="241"/>
|
||||
<source>Close</source>
|
||||
<translation>Zavřít</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/gui.cpp" line="226"/>
|
||||
<location filename="../src/gui.cpp" line="247"/>
|
||||
<source>Reload</source>
|
||||
<translation>Znovu načíst</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/gui.cpp" line="446"/>
|
||||
<location filename="../src/gui.cpp" line="476"/>
|
||||
<source>Show</source>
|
||||
<translation>Zobrazit</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/gui.cpp" line="370"/>
|
||||
<location filename="../src/gui.cpp" line="440"/>
|
||||
<location filename="../src/gui.cpp" line="398"/>
|
||||
<location filename="../src/gui.cpp" line="470"/>
|
||||
<source>File</source>
|
||||
<translation>Soubor</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/gui.cpp" line="194"/>
|
||||
<location filename="../src/gui.cpp" line="552"/>
|
||||
<location filename="../src/gui.cpp" line="553"/>
|
||||
<location filename="../src/gui.cpp" line="111"/>
|
||||
<source>Supported files (*.csv *.fit *.gpx *.kml *.tcx)</source>
|
||||
<translation>Podporované soubory (*.csv *.fit *.gpx *.kml *.tcx)</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/gui.cpp" line="112"/>
|
||||
<source>FIT files (*.fit)</source>
|
||||
<translation>Soubory FIT (*.fit)</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/gui.cpp" line="215"/>
|
||||
<location filename="../src/gui.cpp" line="589"/>
|
||||
<location filename="../src/gui.cpp" line="590"/>
|
||||
<source>Data sources</source>
|
||||
<translation>Zdroje dat</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/gui.cpp" line="234"/>
|
||||
<location filename="../src/gui.cpp" line="255"/>
|
||||
<source>Load POI file</source>
|
||||
<translation>Nahrát POI soubor</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/gui.cpp" line="237"/>
|
||||
<location filename="../src/gui.cpp" line="258"/>
|
||||
<source>Close POI files</source>
|
||||
<translation>Zavřit POI soubory</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/gui.cpp" line="239"/>
|
||||
<location filename="../src/gui.cpp" line="260"/>
|
||||
<source>Overlap POIs</source>
|
||||
<translation>Překrývat POI</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/gui.cpp" line="243"/>
|
||||
<location filename="../src/gui.cpp" line="264"/>
|
||||
<source>Show POI labels</source>
|
||||
<translation>Zobrazovat názvy POI</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/gui.cpp" line="248"/>
|
||||
<location filename="../src/gui.cpp" line="269"/>
|
||||
<source>Show POIs</source>
|
||||
<translation>Zobrazit POI</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/gui.cpp" line="256"/>
|
||||
<location filename="../src/gui.cpp" line="278"/>
|
||||
<source>Show map</source>
|
||||
<translation>Zobrazit mapu</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/gui.cpp" line="262"/>
|
||||
<location filename="../src/gui.cpp" line="284"/>
|
||||
<source>Clear tile cache</source>
|
||||
<translation>Vymazat mezipaměť dlaždic</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/gui.cpp" line="271"/>
|
||||
<location filename="../src/gui.cpp" line="275"/>
|
||||
<location filename="../src/gui.cpp" line="539"/>
|
||||
<location filename="../src/gui.cpp" line="293"/>
|
||||
<location filename="../src/gui.cpp" line="297"/>
|
||||
<location filename="../src/gui.cpp" line="576"/>
|
||||
<source>Next map</source>
|
||||
<translation>Následující mapa</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/gui.cpp" line="282"/>
|
||||
<location filename="../src/gui.cpp" line="304"/>
|
||||
<source>Show tracks</source>
|
||||
<translation>Zobrazit cesty</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/gui.cpp" line="286"/>
|
||||
<location filename="../src/gui.cpp" line="308"/>
|
||||
<source>Show routes</source>
|
||||
<translation>Zobrazit trasy</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/gui.cpp" line="290"/>
|
||||
<location filename="../src/gui.cpp" line="312"/>
|
||||
<source>Show waypoints</source>
|
||||
<translation>Zobrazit navigační body</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/gui.cpp" line="294"/>
|
||||
<location filename="../src/gui.cpp" line="316"/>
|
||||
<source>Waypoint labels</source>
|
||||
<translation>Názvy navigačních bodů</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/gui.cpp" line="305"/>
|
||||
<location filename="../src/gui.cpp" line="327"/>
|
||||
<source>Show graphs</source>
|
||||
<translation>Zobrazovat grafy</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/gui.cpp" line="327"/>
|
||||
<location filename="../src/gui.cpp" line="349"/>
|
||||
<source>Show grid</source>
|
||||
<translation>Zobrazit mřížku</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/gui.cpp" line="355"/>
|
||||
<source>Show toolbars</source>
|
||||
<translation>Zobrazovat nástrojové lišty</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/gui.cpp" line="333"/>
|
||||
<location filename="../src/gui.cpp" line="361"/>
|
||||
<source>Metric</source>
|
||||
<translation>Metrické</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/gui.cpp" line="338"/>
|
||||
<location filename="../src/gui.cpp" line="366"/>
|
||||
<source>Imperial</source>
|
||||
<translation>Imperiální</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/gui.cpp" line="344"/>
|
||||
<location filename="../src/gui.cpp" line="372"/>
|
||||
<source>Fullscreen mode</source>
|
||||
<translation>Celoobrazovkový režim</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/gui.cpp" line="352"/>
|
||||
<location filename="../src/gui.cpp" line="380"/>
|
||||
<source>Next</source>
|
||||
<translation>Následující</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/gui.cpp" line="355"/>
|
||||
<location filename="../src/gui.cpp" line="383"/>
|
||||
<source>Previous</source>
|
||||
<translation>Předchozí</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/gui.cpp" line="359"/>
|
||||
<location filename="../src/gui.cpp" line="387"/>
|
||||
<source>Last</source>
|
||||
<translation>Poslední</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/gui.cpp" line="362"/>
|
||||
<location filename="../src/gui.cpp" line="390"/>
|
||||
<source>First</source>
|
||||
<translation>První</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/gui.cpp" line="384"/>
|
||||
<location filename="../src/gui.cpp" line="412"/>
|
||||
<source>Map</source>
|
||||
<translation>Mapa</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/gui.cpp" line="391"/>
|
||||
<location filename="../src/gui.cpp" line="419"/>
|
||||
<source>Graph</source>
|
||||
<translation>Graf</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/gui.cpp" line="397"/>
|
||||
<location filename="../src/gui.cpp" line="427"/>
|
||||
<source>POI</source>
|
||||
<translation>POI</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/gui.cpp" line="398"/>
|
||||
<location filename="../src/gui.cpp" line="428"/>
|
||||
<source>POI files</source>
|
||||
<translation>POI soubory</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/gui.cpp" line="409"/>
|
||||
<location filename="../src/gui.cpp" line="439"/>
|
||||
<source>Data</source>
|
||||
<translation>Data</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/gui.cpp" line="410"/>
|
||||
<location filename="../src/gui.cpp" line="440"/>
|
||||
<source>Display</source>
|
||||
<translation>Zobrazit</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/gui.cpp" line="418"/>
|
||||
<location filename="../src/gui.cpp" line="448"/>
|
||||
<source>Settings</source>
|
||||
<translation>Nastavení</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/gui.cpp" line="419"/>
|
||||
<location filename="../src/gui.cpp" line="449"/>
|
||||
<source>Units</source>
|
||||
<translation>Jednotky</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/gui.cpp" line="427"/>
|
||||
<location filename="../src/gui.cpp" line="457"/>
|
||||
<source>Help</source>
|
||||
<translation>Nápověda</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/gui.cpp" line="541"/>
|
||||
<location filename="../src/gui.cpp" line="578"/>
|
||||
<source>Previous map</source>
|
||||
<translation>Předchozí mapa</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/gui.cpp" line="746"/>
|
||||
<location filename="../src/gui.cpp" line="749"/>
|
||||
<location filename="../src/gui.cpp" line="113"/>
|
||||
<source>GPX files (*.gpx)</source>
|
||||
<translation>Soubory GPX (*.gpx)</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/gui.cpp" line="114"/>
|
||||
<source>TCX files (*.tcx)</source>
|
||||
<translation>Soubory TCX (*.tcx)</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/gui.cpp" line="113"/>
|
||||
<source>KML files (*.kml)</source>
|
||||
<translation>Soubory KML (*.kml)</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/gui.cpp" line="112"/>
|
||||
<source>CSV files (*.csv)</source>
|
||||
<translation>Soubory CSV (*.csv)</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/gui.cpp" line="114"/>
|
||||
<source>All files (*)</source>
|
||||
<translation>Všechny soubory (*)</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/gui.cpp" line="781"/>
|
||||
<location filename="../src/gui.cpp" line="784"/>
|
||||
<source>Date</source>
|
||||
<translation>Datum</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/gui.cpp" line="758"/>
|
||||
<location filename="../src/gui.cpp" line="793"/>
|
||||
<source>Routes</source>
|
||||
<translation>Trasy</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/gui.cpp" line="948"/>
|
||||
<location filename="../src/gui.cpp" line="981"/>
|
||||
<source>No GPX files loaded</source>
|
||||
<translation>Nejsou načteny žádné GPX soubory</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/gui.cpp" line="952"/>
|
||||
<source>%1 files</source>
|
||||
<translation>%1 souborů</translation>
|
||||
<message numerus="yes">
|
||||
<location filename="../src/gui.cpp" line="985"/>
|
||||
<source>%n files</source>
|
||||
<translation>
|
||||
<numerusform>%n soubor</numerusform>
|
||||
<numerusform>%n soubory</numerusform>
|
||||
<numerusform>%n souborů</numerusform>
|
||||
</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/gui.cpp" line="532"/>
|
||||
<location filename="../src/gui.cpp" line="569"/>
|
||||
<source>Next file</source>
|
||||
<translation>Následující soubor</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/gui.cpp" line="509"/>
|
||||
<location filename="../src/gui.cpp" line="546"/>
|
||||
<source>Version </source>
|
||||
<translation>Verze </translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/gui.cpp" line="209"/>
|
||||
<location filename="../src/gui.cpp" line="230"/>
|
||||
<source>Print...</source>
|
||||
<translation>Tisknout...</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/gui.cpp" line="214"/>
|
||||
<location filename="../src/gui.cpp" line="235"/>
|
||||
<source>Export to PDF...</source>
|
||||
<translation>Exportovat do PDF...</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/gui.cpp" line="760"/>
|
||||
<location filename="../src/gui.cpp" line="795"/>
|
||||
<source>Waypoints</source>
|
||||
<translation>Navigační body</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/gui.cpp" line="533"/>
|
||||
<location filename="../src/gui.cpp" line="570"/>
|
||||
<source>Previous file</source>
|
||||
<translation>Předchozí soubor</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/gui.cpp" line="298"/>
|
||||
<location filename="../src/gui.cpp" line="320"/>
|
||||
<source>Route waypoints</source>
|
||||
<translation>Body tras</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/gui.cpp" line="535"/>
|
||||
<location filename="../src/gui.cpp" line="572"/>
|
||||
<source>First file</source>
|
||||
<translation>První soubor</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/gui.cpp" line="536"/>
|
||||
<location filename="../src/gui.cpp" line="573"/>
|
||||
<source>Last file</source>
|
||||
<translation>Poslední soubor</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/gui.cpp" line="537"/>
|
||||
<location filename="../src/gui.cpp" line="574"/>
|
||||
<source>Append modifier</source>
|
||||
<translation>Modifikátor nahradit/přidat</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/gui.cpp" line="556"/>
|
||||
<location filename="../src/gui.cpp" line="593"/>
|
||||
<source>Map (tiles) source URLs are read on program startup from the following file:</source>
|
||||
<translation>URL mapových zdrojů (dlaždic) jsou načteny při startu programu z následujícího souboru:</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/gui.cpp" line="559"/>
|
||||
<location filename="../src/gui.cpp" line="596"/>
|
||||
<source>The file format is one map entry per line, consisting of the map name and tiles URL delimited by a TAB character. The tile X and Y coordinates are replaced with $x and $y in the URL and the zoom level is replaced with $z. An example map file could look like:</source>
|
||||
<translation>Formát souboru je jeden mapový záznam na řádku, kde mapový záznam sestává ze jména mapy a URL dlaždic navzájem oddělených tabulátorem. Souřadnice dlaždice jsou v URL nahrazeny řetězci $x a $y, úroven přiblížení (zoom) pak řetězcem $z. Příklad:</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/gui.cpp" line="567"/>
|
||||
<location filename="../src/gui.cpp" line="604"/>
|
||||
<source>To make GPXSee load a POI file automatically on startup, add the file to the following directory:</source>
|
||||
<translation>POI soubory, které se mají automaticky nahrát při startu programu jsou načítány z následujícího adresáře:</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/gui.cpp" line="578"/>
|
||||
<source>GPX files (*.gpx);;All files (*)</source>
|
||||
<translation>Soubory GPX (*.gpx);;Všechny soubory (*)</translation>
|
||||
<location filename="../src/gui.cpp" line="684"/>
|
||||
<source>Error loading data file:</source>
|
||||
<translation>Datový soubor nelze načíst:</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/gui.cpp" line="649"/>
|
||||
<location filename="../src/gui.cpp" line="675"/>
|
||||
<location filename="../src/gui.cpp" line="687"/>
|
||||
<location filename="../src/gui.cpp" line="712"/>
|
||||
<source>Line: %1</source>
|
||||
<translation>Řádka: %1</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/gui.cpp" line="659"/>
|
||||
<source>GPX files (*.gpx);;CSV files (*.csv);;All files (*)</source>
|
||||
<translation>Soubory GPX (*.gpx);;Soubory CSV (*.csv);;Všechny soubory (*)</translation>
|
||||
<location filename="../src/gui.cpp" line="709"/>
|
||||
<source>Error loading POI file:</source>
|
||||
<translation>Soubor POI nelze načíst:</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/gui.cpp" line="756"/>
|
||||
<location filename="../src/gui.cpp" line="791"/>
|
||||
<source>Tracks</source>
|
||||
<translation>Cesty</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/gui.cpp" line="199"/>
|
||||
<location filename="../src/gui.cpp" line="507"/>
|
||||
<location filename="../src/gui.cpp" line="220"/>
|
||||
<location filename="../src/gui.cpp" line="544"/>
|
||||
<source>About GPXSee</source>
|
||||
<translation>O aplikaci GPXSee</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/gui.cpp" line="451"/>
|
||||
<location filename="../src/gui.cpp" line="481"/>
|
||||
<source>Navigation</source>
|
||||
<translation>Navigace</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/gui.cpp" line="555"/>
|
||||
<location filename="../src/gui.cpp" line="592"/>
|
||||
<source>Map sources</source>
|
||||
<translation>Mapové zdroje</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/gui.cpp" line="566"/>
|
||||
<location filename="../src/gui.cpp" line="603"/>
|
||||
<source>POIs</source>
|
||||
<translation>POI body</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/gui.cpp" line="313"/>
|
||||
<location filename="../src/gui.cpp" line="763"/>
|
||||
<location filename="../src/gui.cpp" line="335"/>
|
||||
<location filename="../src/gui.cpp" line="798"/>
|
||||
<source>Distance</source>
|
||||
<translation>Vzdálenost</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/gui.cpp" line="319"/>
|
||||
<location filename="../src/gui.cpp" line="765"/>
|
||||
<location filename="../src/gui.cpp" line="342"/>
|
||||
<location filename="../src/gui.cpp" line="800"/>
|
||||
<source>Time</source>
|
||||
<translation>Čas</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/gui.cpp" line="651"/>
|
||||
<location filename="../src/gui.cpp" line="676"/>
|
||||
<source>Error</source>
|
||||
<translation>Chyba</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/gui.cpp" line="646"/>
|
||||
<source>Error loading GPX file:
|
||||
%1</source>
|
||||
<translation>Soubor GPX nelze otevřít:
|
||||
%1</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/gui.cpp" line="672"/>
|
||||
<source>Error loading POI file:
|
||||
%1</source>
|
||||
<translation>Soubor POI nelze otevřít:
|
||||
%1</translation>
|
||||
</message>
|
||||
</context>
|
||||
<context>
|
||||
<name>GraphView</name>
|
||||
<message>
|
||||
<location filename="../src/graphview.cpp" line="111"/>
|
||||
<location filename="../src/graphview.cpp" line="102"/>
|
||||
<source>m</source>
|
||||
<translation>m</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/graphview.cpp" line="114"/>
|
||||
<location filename="../src/graphview.cpp" line="105"/>
|
||||
<source>km</source>
|
||||
<translation>km</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/graphview.cpp" line="119"/>
|
||||
<location filename="../src/graphview.cpp" line="110"/>
|
||||
<source>ft</source>
|
||||
<translation>ft</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/graphview.cpp" line="122"/>
|
||||
<location filename="../src/graphview.cpp" line="113"/>
|
||||
<source>mi</source>
|
||||
<translation>mi</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/graphview.cpp" line="128"/>
|
||||
<location filename="../src/graphview.cpp" line="119"/>
|
||||
<source>s</source>
|
||||
<translation>s</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/graphview.cpp" line="131"/>
|
||||
<location filename="../src/graphview.cpp" line="122"/>
|
||||
<source>min</source>
|
||||
<translation>min</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/graphview.cpp" line="134"/>
|
||||
<location filename="../src/graphview.cpp" line="125"/>
|
||||
<source>h</source>
|
||||
<translation>h</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/graphview.cpp" line="160"/>
|
||||
<location filename="../src/graphview.cpp" line="54"/>
|
||||
<location filename="../src/graphview.cpp" line="151"/>
|
||||
<source>Distance</source>
|
||||
<translation>Vzdálenost</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/graphview.cpp" line="162"/>
|
||||
<location filename="../src/graphview.cpp" line="153"/>
|
||||
<source>Time</source>
|
||||
<translation>Čas</translation>
|
||||
</message>
|
||||
@ -575,7 +644,7 @@
|
||||
<name>HeartRateGraph</name>
|
||||
<message>
|
||||
<location filename="../src/heartrategraph.cpp" line="11"/>
|
||||
<location filename="../src/heartrategraph.h" line="15"/>
|
||||
<location filename="../src/heartrategraph.h" line="13"/>
|
||||
<source>Heart rate</source>
|
||||
<translation>Tep</translation>
|
||||
</message>
|
||||
@ -596,34 +665,43 @@
|
||||
</message>
|
||||
</context>
|
||||
<context>
|
||||
<name>Misc</name>
|
||||
<name>PowerGraph</name>
|
||||
<message>
|
||||
<location filename="../src/misc.cpp" line="55"/>
|
||||
<location filename="../src/misc.cpp" line="76"/>
|
||||
<source>ft</source>
|
||||
<translation>ft</translation>
|
||||
<location filename="../src/powergraph.cpp" line="10"/>
|
||||
<source>W</source>
|
||||
<translation>W</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/misc.cpp" line="58"/>
|
||||
<source>mi</source>
|
||||
<translation>mi</translation>
|
||||
<location filename="../src/powergraph.cpp" line="11"/>
|
||||
<location filename="../src/powergraph.h" line="13"/>
|
||||
<source>Power</source>
|
||||
<translation>Výkon</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/misc.cpp" line="62"/>
|
||||
<location filename="../src/misc.cpp" line="73"/>
|
||||
<source>m</source>
|
||||
<translation>m</translation>
|
||||
<location filename="../src/powergraph.cpp" line="19"/>
|
||||
<source>Average</source>
|
||||
<translation>Průměr</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/misc.cpp" line="65"/>
|
||||
<source>km</source>
|
||||
<translation>km</translation>
|
||||
<location filename="../src/powergraph.cpp" line="21"/>
|
||||
<source>Maximum</source>
|
||||
<translation>Maximum</translation>
|
||||
</message>
|
||||
</context>
|
||||
<context>
|
||||
<name>RouteItem</name>
|
||||
<message>
|
||||
<location filename="../src/routeitem.cpp" line="15"/>
|
||||
<source>Name</source>
|
||||
<translation>Název</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/routeitem.cpp" line="17"/>
|
||||
<source>Description</source>
|
||||
<translation>Popis</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/routeitem.cpp" line="18"/>
|
||||
<source>Distance</source>
|
||||
<translation>Vzdálenost</translation>
|
||||
</message>
|
||||
@ -655,7 +733,7 @@
|
||||
<name>SpeedGraph</name>
|
||||
<message>
|
||||
<location filename="../src/speedgraph.cpp" line="12"/>
|
||||
<location filename="../src/speedgraph.h" line="16"/>
|
||||
<location filename="../src/speedgraph.h" line="14"/>
|
||||
<source>Speed</source>
|
||||
<translation>Rychlost</translation>
|
||||
</message>
|
||||
@ -684,7 +762,7 @@
|
||||
<name>TemperatureGraph</name>
|
||||
<message>
|
||||
<location filename="../src/temperaturegraph.cpp" line="11"/>
|
||||
<location filename="../src/temperaturegraph.h" line="15"/>
|
||||
<location filename="../src/temperaturegraph.h" line="13"/>
|
||||
<source>Temperature</source>
|
||||
<translation>Teplota</translation>
|
||||
</message>
|
||||
@ -718,16 +796,26 @@
|
||||
<name>TrackItem</name>
|
||||
<message>
|
||||
<location filename="../src/trackitem.cpp" line="14"/>
|
||||
<source>Name</source>
|
||||
<translation>Název</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/trackitem.cpp" line="16"/>
|
||||
<source>Description</source>
|
||||
<translation>Popis</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/trackitem.cpp" line="17"/>
|
||||
<source>Distance</source>
|
||||
<translation>Vzdálenost</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/trackitem.cpp" line="17"/>
|
||||
<location filename="../src/trackitem.cpp" line="20"/>
|
||||
<source>Time</source>
|
||||
<translation>Čas</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/trackitem.cpp" line="19"/>
|
||||
<location filename="../src/trackitem.cpp" line="23"/>
|
||||
<source>Date</source>
|
||||
<translation>Datum</translation>
|
||||
</message>
|
||||
@ -735,27 +823,27 @@
|
||||
<context>
|
||||
<name>WaypointItem</name>
|
||||
<message>
|
||||
<location filename="../src/waypointitem.cpp" line="18"/>
|
||||
<location filename="../src/waypointitem.cpp" line="17"/>
|
||||
<source>Name</source>
|
||||
<translation>Název</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/waypointitem.cpp" line="19"/>
|
||||
<location filename="../src/waypointitem.cpp" line="18"/>
|
||||
<source>Coordinates</source>
|
||||
<translation>Souřadnice</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/waypointitem.cpp" line="22"/>
|
||||
<location filename="../src/waypointitem.cpp" line="21"/>
|
||||
<source>Elevation</source>
|
||||
<translation>Výška</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/waypointitem.cpp" line="25"/>
|
||||
<location filename="../src/waypointitem.cpp" line="24"/>
|
||||
<source>Date</source>
|
||||
<translation>Datum</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/waypointitem.cpp" line="28"/>
|
||||
<location filename="../src/waypointitem.cpp" line="27"/>
|
||||
<source>Description</source>
|
||||
<translation>Popis</translation>
|
||||
</message>
|
||||
|
@ -4,7 +4,7 @@
|
||||
; The name of the installer
|
||||
Name "GPXSee"
|
||||
; Program version
|
||||
!define VERSION "2.19"
|
||||
!define VERSION "3.0"
|
||||
|
||||
; The file to write
|
||||
OutFile "GPXSee-${VERSION}.exe"
|
||||
@ -21,8 +21,11 @@ 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"
|
||||
|
||||
; Start menu page configuration
|
||||
!define MUI_STARTMENUPAGE_REGISTRY_ROOT "HKLM"
|
||||
@ -62,18 +65,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 +74,40 @@ 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$\""
|
||||
|
||||
System::Call 'shell32.dll::SHChangeNotify(i, i, i, i) v (0x08000000, 0, 0, 0)'
|
||||
|
||||
SectionEnd
|
||||
@ -149,6 +169,12 @@ 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"
|
||||
System::Call 'shell32.dll::SHChangeNotify(i, i, i, i) v (0x08000000, 0, 0, 0)'
|
||||
|
||||
SectionEnd
|
||||
|
@ -4,7 +4,7 @@
|
||||
; The name of the installer
|
||||
Name "GPXSee"
|
||||
; Program version
|
||||
!define VERSION "2.19"
|
||||
!define VERSION "3.0"
|
||||
|
||||
; The file to write
|
||||
OutFile "GPXSee-${VERSION}_x64.exe"
|
||||
@ -21,8 +21,11 @@ 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"
|
||||
|
||||
; Start menu page configuration
|
||||
!define MUI_STARTMENUPAGE_REGISTRY_ROOT "HKLM"
|
||||
@ -71,18 +74,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 +82,40 @@ 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$\""
|
||||
|
||||
System::Call 'shell32.dll::SHChangeNotify(i, i, i, i) v (0x08000000, 0, 0, 0)'
|
||||
|
||||
SectionEnd
|
||||
@ -150,9 +170,15 @@ 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"
|
||||
System::Call 'shell32.dll::SHChangeNotify(i, i, i, i) v (0x08000000, 0, 0, 0)'
|
||||
|
||||
SectionEnd
|
||||
|
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
|
37
src/coordinates.cpp
Normal file
@ -0,0 +1,37 @@
|
||||
#include "rd.h"
|
||||
#include "wgs84.h"
|
||||
#include "coordinates.h"
|
||||
|
||||
|
||||
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();
|
||||
}
|
40
src/coordinates.h
Normal file
@ -0,0 +1,40 @@
|
||||
#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;
|
||||
|
||||
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
|
48
src/csvparser.cpp
Normal file
@ -0,0 +1,48 @@
|
||||
#include "csvparser.h"
|
||||
|
||||
bool CSVParser::loadFile(QFile *file)
|
||||
{
|
||||
bool res;
|
||||
int ln = 1;
|
||||
|
||||
_errorLine = 0;
|
||||
_errorString.clear();
|
||||
|
||||
while (!file->atEnd()) {
|
||||
QByteArray line = file->readLine();
|
||||
QList<QByteArray> list = line.split(',');
|
||||
if (list.size() < 3) {
|
||||
_errorString = "Parse error";
|
||||
_errorLine = ln;
|
||||
return false;
|
||||
}
|
||||
|
||||
qreal lat = list[0].trimmed().toDouble(&res);
|
||||
if (!res || (lat < -90.0 || lat > 90.0)) {
|
||||
_errorString = "Invalid latitude";
|
||||
_errorLine = ln;
|
||||
return false;
|
||||
}
|
||||
qreal lon = list[1].trimmed().toDouble(&res);
|
||||
if (!res || (lon < -180.0 || lon > 180.0)) {
|
||||
_errorString = "Invalid longitude";
|
||||
_errorLine = ln;
|
||||
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);
|
||||
ln++;
|
||||
}
|
||||
|
||||
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
|
89
src/data.cpp
Normal file
@ -0,0 +1,89 @@
|
||||
#include <QFile>
|
||||
#include <QFileInfo>
|
||||
#include <QLineF>
|
||||
#include "gpxparser.h"
|
||||
#include "tcxparser.h"
|
||||
#include "csvparser.h"
|
||||
#include "kmlparser.h"
|
||||
#include "fitparser.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));
|
||||
}
|
||||
|
||||
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
|
@ -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();
|
||||
|
||||
|
@ -3,9 +3,6 @@
|
||||
|
||||
#include "graphtab.h"
|
||||
|
||||
class GPX;
|
||||
class PathItem;
|
||||
|
||||
class ElevationGraph : public GraphTab
|
||||
{
|
||||
Q_OBJECT
|
||||
@ -14,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);
|
||||
|
@ -91,6 +91,7 @@ ExportDialog::ExportDialog(QPrinter *printer, QWidget *parent)
|
||||
line->setFrameShadow(QFrame::Sunken);
|
||||
pageSetupLayout->addRow(line);
|
||||
pageSetupLayout->addRow(tr("File:"), _fileSelect);
|
||||
pageSetupLayout->setFieldGrowthPolicy(QFormLayout::ExpandingFieldsGrow);
|
||||
#else // Q_OS_MAC
|
||||
pageSetupBox->setLayout(pageSetupLayout);
|
||||
#endif // Q_OS_MAC
|
||||
|
@ -1,4 +1,5 @@
|
||||
#include <QPushButton>
|
||||
#include <QToolButton>
|
||||
#include <QFileDialog>
|
||||
#include <QHBoxLayout>
|
||||
#include <QFileInfo>
|
||||
@ -12,7 +13,13 @@ FileSelectWidget::FileSelectWidget(QWidget *parent) : QWidget(parent)
|
||||
QFontMetrics fm(QApplication::font());
|
||||
_edit = new QLineEdit();
|
||||
_edit->setMinimumWidth(fm.boundingRect(QDir::homePath()).width());
|
||||
_button = new QPushButton(tr("Browse..."));
|
||||
#ifdef Q_OS_WIN32
|
||||
_button = new QPushButton("...");
|
||||
_button->setMaximumWidth(_button->sizeHint().width() / 2);
|
||||
#else // Q_OS_WIN32
|
||||
_button = new QToolButton();
|
||||
_button->setText("...");
|
||||
#endif // Q_OS_WIN32
|
||||
connect(_button, SIGNAL(clicked()), this, SLOT(browse()));
|
||||
|
||||
QHBoxLayout *layout = new QHBoxLayout();
|
||||
@ -20,6 +27,9 @@ FileSelectWidget::FileSelectWidget(QWidget *parent) : QWidget(parent)
|
||||
layout->addWidget(_edit);
|
||||
layout->addWidget(_button);
|
||||
setLayout(layout);
|
||||
|
||||
QSizePolicy p(QSizePolicy::MinimumExpanding, QSizePolicy::Fixed);
|
||||
setSizePolicy(p);
|
||||
}
|
||||
|
||||
void FileSelectWidget::browse()
|
||||
|
@ -5,6 +5,7 @@
|
||||
#include <QLineEdit>
|
||||
|
||||
class QPushButton;
|
||||
class QToolButton;
|
||||
|
||||
class FileSelectWidget : public QWidget
|
||||
{
|
||||
@ -22,7 +23,11 @@ private slots:
|
||||
|
||||
private:
|
||||
QLineEdit *_edit;
|
||||
#ifdef Q_OS_WIN32
|
||||
QPushButton *_button;
|
||||
#else // Q_OS_WIN32
|
||||
QToolButton *_button;
|
||||
#endif // Q_OS_WIN32
|
||||
|
||||
QString _filter;
|
||||
};
|
||||
|
355
src/fitparser.cpp
Normal file
@ -0,0 +1,355 @@
|
||||
#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));
|
||||
}
|
||||
|
||||
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)
|
||||
{
|
||||
_device = file;
|
||||
_endian = 0;
|
||||
_timestamp = 0;
|
||||
bool ret = true;
|
||||
|
||||
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 &graphpoint)
|
||||
{
|
||||
dbg.nospace() << "GraphPoint(" << graphpoint.s() << ", "
|
||||
<< graphpoint.t() << ", " << graphpoint.y() << ")";
|
||||
|
||||
return dbg.maybeSpace();
|
||||
}
|
23
src/graph.h
@ -2,6 +2,7 @@
|
||||
#define GRAPH_H
|
||||
|
||||
#include <QVector>
|
||||
#include <QDebug>
|
||||
#include <cmath>
|
||||
|
||||
enum GraphType {Distance, Time};
|
||||
@ -15,6 +16,7 @@ public:
|
||||
qreal s() const {return _s;}
|
||||
qreal t() const {return _t;}
|
||||
qreal y() const {return _y;}
|
||||
qreal x(GraphType type) const {return (type == Distance) ? _s : _t;}
|
||||
|
||||
void setS(qreal s) {_s = s;}
|
||||
void setT(qreal t) {_t = t;}
|
||||
@ -26,6 +28,25 @@ private:
|
||||
qreal _y;
|
||||
};
|
||||
|
||||
typedef QVector<GraphPoint> Graph;
|
||||
Q_DECLARE_TYPEINFO(GraphPoint, Q_PRIMITIVE_TYPE);
|
||||
QDebug operator<<(QDebug dbg, const GraphPoint &graphpoint);
|
||||
|
||||
|
||||
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
|
||||
|
@ -5,64 +5,19 @@
|
||||
#define GRAPH_WIDTH 1
|
||||
#define HOVER_WIDTH 2
|
||||
|
||||
static qreal yAtX(const QPainterPath &path, qreal x)
|
||||
{
|
||||
int low = 0;
|
||||
int high = path.elementCount() - 1;
|
||||
int mid = 0;
|
||||
|
||||
Q_ASSERT(high > low);
|
||||
Q_ASSERT(x >= path.elementAt(low).x && x <= path.elementAt(high).x);
|
||||
|
||||
while (low <= high) {
|
||||
mid = low + ((high - low) / 2);
|
||||
const QPainterPath::Element &e = path.elementAt(mid);
|
||||
if (e.x > x)
|
||||
high = mid - 1;
|
||||
else if (e.x < x)
|
||||
low = mid + 1;
|
||||
else
|
||||
return e.y;
|
||||
}
|
||||
|
||||
QLineF l;
|
||||
if (path.elementAt(mid).x < x)
|
||||
l = QLineF(path.elementAt(mid).x, path.elementAt(mid).y,
|
||||
path.elementAt(mid+1).x, path.elementAt(mid+1).y);
|
||||
else
|
||||
l = QLineF(path.elementAt(mid-1).x, path.elementAt(mid-1).y,
|
||||
path.elementAt(mid).x, path.elementAt(mid).y);
|
||||
|
||||
return l.pointAt((x - l.p1().x()) / (l.p2().x() - l.p1().x())).y();
|
||||
}
|
||||
|
||||
static bool hasTime(const Graph &graph)
|
||||
{
|
||||
for (int i = 0; i < graph.count(); i++)
|
||||
if (std::isnan(graph.at(i).t()))
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
GraphItem::GraphItem(const Graph &graph, QGraphicsItem *parent)
|
||||
: QGraphicsObject(parent)
|
||||
{
|
||||
_id = 0;
|
||||
_type = Distance;
|
||||
|
||||
_pen = QPen(Qt::black, GRAPH_WIDTH);
|
||||
_pen.setCosmetic(true);
|
||||
|
||||
_distancePath.moveTo(graph.first().s(), -graph.first().y());
|
||||
for (int i = 1; i < graph.size(); i++)
|
||||
_distancePath.lineTo(graph.at(i).s(), -graph.at(i).y());
|
||||
_type = Distance;
|
||||
_graph = graph;
|
||||
_sx = 1.0; _sy = 1.0;
|
||||
|
||||
if (hasTime(graph)) {
|
||||
_timePath.moveTo(graph.first().t(), -graph.first().y());
|
||||
for (int i = 1; i < graph.size(); i++)
|
||||
_timePath.lineTo(graph.at(i).t(), -graph.at(i).y());
|
||||
}
|
||||
updatePath();
|
||||
updateBounds();
|
||||
}
|
||||
|
||||
void GraphItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *option,
|
||||
@ -72,7 +27,7 @@ void GraphItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *option,
|
||||
Q_UNUSED(widget);
|
||||
|
||||
painter->setPen(_pen);
|
||||
painter->drawPath((_type == Distance) ? _distancePath : _timePath);
|
||||
painter->drawPath(_path);
|
||||
|
||||
/*
|
||||
QPen p = QPen(QBrush(Qt::red), 0);
|
||||
@ -84,7 +39,10 @@ void GraphItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *option,
|
||||
void GraphItem::setGraphType(GraphType type)
|
||||
{
|
||||
prepareGeometryChange();
|
||||
|
||||
_type = type;
|
||||
updatePath();
|
||||
updateBounds();
|
||||
}
|
||||
|
||||
void GraphItem::setColor(const QColor &color)
|
||||
@ -95,37 +53,62 @@ void GraphItem::setColor(const QColor &color)
|
||||
|
||||
qreal GraphItem::yAtX(qreal x)
|
||||
{
|
||||
return ::yAtX((_type == Distance) ? _distancePath : _timePath, x);
|
||||
int low = 0;
|
||||
int high = _graph.count() - 1;
|
||||
int mid = 0;
|
||||
|
||||
Q_ASSERT(high > low);
|
||||
Q_ASSERT(x >= _graph.at(low).x(_type) && x <= _graph.at(high).x(_type));
|
||||
|
||||
while (low <= high) {
|
||||
mid = low + ((high - low) / 2);
|
||||
const GraphPoint &p = _graph.at(mid);
|
||||
if (p.x(_type) > x)
|
||||
high = mid - 1;
|
||||
else if (p.x(_type) < x)
|
||||
low = mid + 1;
|
||||
else
|
||||
return -p.y();
|
||||
}
|
||||
|
||||
QLineF l;
|
||||
if (_graph.at(mid).x(_type) < x)
|
||||
l = QLineF(_graph.at(mid).x(_type), _graph.at(mid).y(),
|
||||
_graph.at(mid+1).x(_type), _graph.at(mid+1).y());
|
||||
else
|
||||
l = QLineF(_graph.at(mid-1).x(_type), _graph.at(mid-1).y(),
|
||||
_graph.at(mid).x(_type), _graph.at(mid).y());
|
||||
|
||||
return -l.pointAt((x - l.p1().x()) / (l.p2().x() - l.p1().x())).y();
|
||||
}
|
||||
|
||||
qreal GraphItem::distanceAtTime(qreal time)
|
||||
{
|
||||
int low = 0;
|
||||
int high = _timePath.elementCount() - 1;
|
||||
int high = _graph.count() - 1;
|
||||
int mid = 0;
|
||||
|
||||
Q_ASSERT(high > low);
|
||||
Q_ASSERT(time >= _timePath.elementAt(low).x
|
||||
&& time <= _timePath.elementAt(high).x);
|
||||
Q_ASSERT(time >= _graph.at(low).t() && time <= _graph.at(high).t());
|
||||
|
||||
while (low <= high) {
|
||||
mid = low + ((high - low) / 2);
|
||||
const QPainterPath::Element &e = _timePath.elementAt(mid);
|
||||
if (e.x > time)
|
||||
const GraphPoint &p = _graph.at(mid);
|
||||
if (p.t() > time)
|
||||
high = mid - 1;
|
||||
else if (e.x < time)
|
||||
else if (p.t() < time)
|
||||
low = mid + 1;
|
||||
else
|
||||
return _distancePath.elementAt(mid).x;
|
||||
return _graph.at(mid).s();
|
||||
}
|
||||
|
||||
QLineF l;
|
||||
if (_timePath.elementAt(mid).x < time)
|
||||
l = QLineF(_timePath.elementAt(mid).x, _distancePath.elementAt(mid).x,
|
||||
_timePath.elementAt(mid+1).x, _distancePath.elementAt(mid+1).x);
|
||||
if (_graph.at(mid).t() < time)
|
||||
l = QLineF(_graph.at(mid).t(), _graph.at(mid).s(), _graph.at(mid+1).t(),
|
||||
_graph.at(mid+1).s());
|
||||
else
|
||||
l = QLineF(_timePath.elementAt(mid-1).x, _distancePath.elementAt(mid-1).x,
|
||||
_timePath.elementAt(mid).x, _distancePath.elementAt(mid).x);
|
||||
l = QLineF(_graph.at(mid-1).t(), _graph.at(mid-1).s(),
|
||||
_graph.at(mid).t(), _graph.at(mid).s());
|
||||
|
||||
return l.pointAt((time - l.p1().x()) / (l.p2().x() - l.p1().x())).y();
|
||||
}
|
||||
@ -133,15 +116,13 @@ qreal GraphItem::distanceAtTime(qreal time)
|
||||
void GraphItem::emitSliderPositionChanged(qreal pos)
|
||||
{
|
||||
if (_type == Time) {
|
||||
if (!_timePath.isEmpty()) {
|
||||
if (pos <= _timePath.elementAt(_timePath.elementCount() - 1).x)
|
||||
if (_graph.hasTime()) {
|
||||
if (pos <= _graph.last().t())
|
||||
emit sliderPositionChanged(distanceAtTime(pos));
|
||||
else
|
||||
emit sliderPositionChanged(_distancePath.elementAt(
|
||||
_distancePath.elementCount() - 1).x + 1);
|
||||
emit sliderPositionChanged(_graph.last().s() + 1);
|
||||
} else
|
||||
emit sliderPositionChanged(_distancePath.elementAt(
|
||||
_distancePath.elementCount() - 1).x + 1);
|
||||
emit sliderPositionChanged(_graph.last().s() + 1);
|
||||
} else
|
||||
emit sliderPositionChanged(pos);
|
||||
}
|
||||
@ -158,3 +139,47 @@ void GraphItem::selected(bool selected)
|
||||
|
||||
update();
|
||||
}
|
||||
|
||||
void GraphItem::setScale(qreal sx, qreal sy)
|
||||
{
|
||||
if (_sx == sx && _sy == sy)
|
||||
return;
|
||||
|
||||
prepareGeometryChange();
|
||||
|
||||
_sx = sx; _sy = sy;
|
||||
updatePath();
|
||||
}
|
||||
|
||||
void GraphItem::updatePath()
|
||||
{
|
||||
_path = QPainterPath();
|
||||
|
||||
if (_type == Time && !_graph.hasTime())
|
||||
return;
|
||||
|
||||
_path.moveTo(_graph.first().x(_type) * _sx, -_graph.first().y() * _sy);
|
||||
for (int i = 1; i < _graph.size(); i++)
|
||||
_path.lineTo(_graph.at(i).x(_type) * _sx, -_graph.at(i).y() * _sy);
|
||||
}
|
||||
|
||||
void GraphItem::updateBounds()
|
||||
{
|
||||
if (_type == Time && !_graph.hasTime()) {
|
||||
_bounds = QRectF();
|
||||
return;
|
||||
}
|
||||
|
||||
qreal bottom, top, left, right;
|
||||
|
||||
QPointF p = QPointF(_graph.first().x(_type), -_graph.first().y());
|
||||
bottom = p.y(); top = p.y(); left = p.x(); right = p.x();
|
||||
|
||||
for (int i = 1; i < _graph.size(); i++) {
|
||||
p = QPointF(_graph.at(i).x(_type), -_graph.at(i).y());
|
||||
bottom = qMax(bottom, p.y()); top = qMin(top, p.y());
|
||||
right = qMax(right, p.x()); left = qMin(left, p.x());
|
||||
}
|
||||
|
||||
_bounds = QRectF(QPointF(left, top), QPointF(right, bottom));
|
||||
}
|
||||
|
@ -13,11 +13,13 @@ public:
|
||||
GraphItem(const Graph &graph, QGraphicsItem *parent = 0);
|
||||
|
||||
QRectF boundingRect() const
|
||||
{return (_type == Distance) ? _distancePath.boundingRect()
|
||||
: _timePath.boundingRect();}
|
||||
{return _path.boundingRect();}
|
||||
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option,
|
||||
QWidget *widget);
|
||||
|
||||
const QRectF &bounds() const {return _bounds;}
|
||||
void setScale(qreal sx, qreal sy);
|
||||
|
||||
void setGraphType(GraphType type);
|
||||
int id() const {return _id;}
|
||||
void setId(int id) {_id = id;}
|
||||
@ -34,10 +36,18 @@ public slots:
|
||||
void selected(bool selected);
|
||||
|
||||
private:
|
||||
void updatePath();
|
||||
void updateBounds();
|
||||
|
||||
int _id;
|
||||
QPen _pen;
|
||||
QPainterPath _distancePath, _timePath;
|
||||
|
||||
Graph _graph;
|
||||
GraphType _type;
|
||||
|
||||
QPainterPath _path;
|
||||
QRectF _bounds;
|
||||
qreal _sx, _sy;
|
||||
};
|
||||
|
||||
#endif // GRAPHITEM_H
|
||||
|
@ -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,5 +1,6 @@
|
||||
#include <QGraphicsSceneMouseEvent>
|
||||
#include <QGraphicsScene>
|
||||
#include <QEvent>
|
||||
#include <QMouseEvent>
|
||||
#include <QPaintEngine>
|
||||
#include <QPaintDevice>
|
||||
#include "config.h"
|
||||
@ -7,6 +8,7 @@
|
||||
#include "slideritem.h"
|
||||
#include "sliderinfoitem.h"
|
||||
#include "infoitem.h"
|
||||
#include "griditem.h"
|
||||
#include "graph.h"
|
||||
#include "graphitem.h"
|
||||
#include "pathitem.h"
|
||||
@ -15,20 +17,10 @@
|
||||
|
||||
#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();
|
||||
setScene(_scene);
|
||||
|
||||
setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
|
||||
@ -43,11 +35,10 @@ GraphView::GraphView(QWidget *parent)
|
||||
_sliderInfo = new SliderInfoItem(_slider);
|
||||
_sliderInfo->setZValue(2.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&)));
|
||||
|
||||
_xScale = 1;
|
||||
_yScale = 1;
|
||||
@ -60,9 +51,7 @@ GraphView::GraphView(QWidget *parent)
|
||||
|
||||
_units = Metric;
|
||||
_graphType = Distance;
|
||||
|
||||
setGraphType(_graphType);
|
||||
setUnits(_units);
|
||||
_xLabel = tr("Distance");
|
||||
}
|
||||
|
||||
GraphView::~GraphView()
|
||||
@ -75,6 +64,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)
|
||||
@ -153,7 +144,7 @@ void GraphView::setGraphType(GraphType type)
|
||||
for (int i = 0; i < _graphs.count(); i++) {
|
||||
_graphs.at(i)->setGraphType(type);
|
||||
if (_graphs.at(i)->scene() == _scene)
|
||||
_bounds |= _graphs.at(i)->boundingRect();
|
||||
_bounds |= _graphs.at(i)->bounds();
|
||||
}
|
||||
|
||||
if (type == Distance)
|
||||
@ -165,6 +156,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)
|
||||
@ -186,7 +182,7 @@ void GraphView::loadGraph(const Graph &graph, PathItem *path, int id)
|
||||
if (!_hide.contains(id)) {
|
||||
_visible.append(gi);
|
||||
_scene->addItem(gi);
|
||||
_bounds |= gi->boundingRect();
|
||||
_bounds |= gi->bounds();
|
||||
setXUnits();
|
||||
}
|
||||
}
|
||||
@ -219,7 +215,7 @@ void GraphView::showGraph(bool show, int id)
|
||||
else {
|
||||
addItem(gi);
|
||||
_visible.append(gi);
|
||||
_bounds |= gi->boundingRect();
|
||||
_bounds |= gi->bounds();
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -241,8 +237,7 @@ void GraphView::redraw(const QSizeF &size)
|
||||
QRectF r;
|
||||
QSizeF mx, my;
|
||||
RangeF rx, ry;
|
||||
QTransform transform;
|
||||
qreal xs, ys;
|
||||
qreal sx, sy;
|
||||
|
||||
|
||||
if (_visible.isEmpty() || _bounds.isNull()) {
|
||||
@ -250,6 +245,7 @@ void GraphView::redraw(const QSizeF &size)
|
||||
removeItem(_yAxis);
|
||||
removeItem(_slider);
|
||||
removeItem(_info);
|
||||
removeItem(_grid);
|
||||
_scene->setSceneRect(QRectF());
|
||||
return;
|
||||
}
|
||||
@ -258,6 +254,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
|
||||
@ -275,26 +272,29 @@ void GraphView::redraw(const QSizeF &size)
|
||||
r.adjust(0, -(_minYRange/2 - r.height()/2), 0,
|
||||
_minYRange/2 - r.height()/2);
|
||||
|
||||
xs = (size.width() - (my.width() + mx.width())) / r.width();
|
||||
ys = (size.height() - (mx.height() + my.height())
|
||||
sx = (size.width() - (my.width() + mx.width())) / r.width();
|
||||
sy = (size.height() - (mx.height() + my.height())
|
||||
- _info->boundingRect().height()) / r.height();
|
||||
transform.scale(xs, ys);
|
||||
|
||||
for (int i = 0; i < _visible.size(); i++)
|
||||
_visible.at(i)->setTransform(transform);
|
||||
_visible.at(i)->setScale(sx, sy);
|
||||
|
||||
QPointF p(r.left() * xs, r.top() * ys);
|
||||
QSizeF s(r.width() * xs, r.height() * ys);
|
||||
QPointF p(r.left() * sx, r.top() * sy);
|
||||
QSizeF s(r.width() * sx, r.height() * sy);
|
||||
r = QRectF(p, s);
|
||||
if (r.height() < _minYRange * ys)
|
||||
r.adjust(0, -(_minYRange/2 * ys - r.height()/2), 0,
|
||||
(_minYRange/2) * ys - r.height()/2);
|
||||
if (r.height() < _minYRange * sy)
|
||||
r.adjust(0, -(_minYRange/2 * sy - r.height()/2), 0,
|
||||
(_minYRange/2) * sy - r.height()/2);
|
||||
|
||||
_xAxis->setSize(r.width());
|
||||
_yAxis->setSize(r.height());
|
||||
_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();
|
||||
|
||||
@ -311,6 +311,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()
|
||||
@ -368,7 +376,7 @@ void GraphView::updateSliderInfo()
|
||||
if (!_sliderInfo->isVisible())
|
||||
return;
|
||||
|
||||
QRectF br(_visible.first()->boundingRect());
|
||||
QRectF br(_visible.first()->bounds());
|
||||
if (br.height() < _minYRange)
|
||||
br.adjust(0, -(_minYRange/2 - br.height()/2), 0,
|
||||
_minYRange/2 - br.height()/2);
|
||||
|
@ -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,7 @@ public:
|
||||
void showGraph(bool show, int id = 0);
|
||||
void setGraphType(GraphType type);
|
||||
void setUnits(Units units);
|
||||
void showGrid(bool show);
|
||||
|
||||
const QString &yLabel() const {return _yLabel;}
|
||||
const QString &yUnits() const {return _yUnits;}
|
||||
@ -74,7 +61,6 @@ protected:
|
||||
void addInfo(const QString &key, const QString &value);
|
||||
void clearInfo();
|
||||
void skipColor() {_palette.color();}
|
||||
void resizeEvent(QResizeEvent *);
|
||||
|
||||
private slots:
|
||||
void emitSliderPositionChanged(const QPointF &pos);
|
||||
@ -89,6 +75,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,12 +86,13 @@ 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;
|
||||
|
48
src/griditem.cpp
Normal file
@ -0,0 +1,48 @@
|
||||
#include <QPainter>
|
||||
#include "griditem.h"
|
||||
|
||||
|
||||
#define GRID_WIDTH 0
|
||||
|
||||
GridItem::GridItem(QGraphicsItem *parent) : QGraphicsItem(parent)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
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
|
261
src/gui.cpp
@ -1,4 +1,5 @@
|
||||
#include <QApplication>
|
||||
#include <QSplitter>
|
||||
#include <QVBoxLayout>
|
||||
#include <QMenuBar>
|
||||
#include <QStatusBar>
|
||||
@ -18,25 +19,29 @@
|
||||
#include <QLabel>
|
||||
#include <QSettings>
|
||||
#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"
|
||||
|
||||
|
||||
@ -52,20 +57,17 @@ 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);
|
||||
@ -81,7 +83,7 @@ GUI::GUI(QWidget *parent) : QMainWindow(parent)
|
||||
_sliderPos = 0;
|
||||
|
||||
updateGraphTabs();
|
||||
updateTrackView();
|
||||
updatePathView();
|
||||
updateStatusBarInfo();
|
||||
|
||||
readSettings();
|
||||
@ -92,6 +94,7 @@ GUI::GUI(QWidget *parent) : QMainWindow(parent)
|
||||
_exportFileName = QString("%1/export.pdf").arg(QDir::currentPath());
|
||||
_exportMargins = MarginsF(5.0, 5.0, 5.0, 5.0);
|
||||
|
||||
setAcceptDrops(true);
|
||||
QPixmapCache::setCacheLimit(65536);
|
||||
}
|
||||
|
||||
@ -103,6 +106,22 @@ GUI::~GUI()
|
||||
}
|
||||
}
|
||||
|
||||
const QString GUI::fileFormats() const
|
||||
{
|
||||
return tr("Supported files (*.csv *.fit *.gpx *.kml *.tcx)") + ";;"
|
||||
+ tr("CSV files (*.csv)") + ";;" + tr("FIT files (*.fit)") + ";;"
|
||||
+ tr("GPX files (*.gpx)") + ";;" + tr("KML files (*.kml)") + ";;"
|
||||
+ tr("TCX files (*.tcx)") + ";;" + tr("All files (*)");
|
||||
}
|
||||
|
||||
void GUI::createBrowser()
|
||||
{
|
||||
QStringList filter;
|
||||
filter << "*.gpx" << "*.tcx" << "*.kml" << "*.fit" << "*.csv";
|
||||
_browser = new FileBrowser(this);
|
||||
_browser->setFilter(filter);
|
||||
}
|
||||
|
||||
void GUI::loadMaps()
|
||||
{
|
||||
if (QFile::exists(USER_MAP_FILE))
|
||||
@ -117,13 +136,15 @@ void GUI::loadPOIs()
|
||||
QDir userDir(USER_POI_DIR);
|
||||
QDir globalDir(GLOBAL_POI_DIR);
|
||||
|
||||
_poi = new POI(this);
|
||||
|
||||
if (userDir.exists())
|
||||
list = userDir.entryInfoList(QStringList(), QDir::Files);
|
||||
else
|
||||
list = globalDir.entryInfoList(QStringList(), QDir::Files);
|
||||
|
||||
for (int i = 0; i < list.size(); ++i)
|
||||
_poi.loadFile(list.at(i).absoluteFilePath());
|
||||
_poi->loadFile(list.at(i).absoluteFilePath());
|
||||
}
|
||||
|
||||
void GUI::createMapActions()
|
||||
@ -151,7 +172,7 @@ void GUI::createPOIFilesActions()
|
||||
{
|
||||
_poiFilesSM = new QSignalMapper(this);
|
||||
|
||||
for (int i = 0; i < _poi.files().count(); i++)
|
||||
for (int i = 0; i < _poi->files().count(); i++)
|
||||
createPOIFileAction(i);
|
||||
|
||||
connect(_poiFilesSM, SIGNAL(mapped(int)), this, SLOT(poiFileChecked(int)));
|
||||
@ -159,7 +180,7 @@ void GUI::createPOIFilesActions()
|
||||
|
||||
QAction *GUI::createPOIFileAction(int index)
|
||||
{
|
||||
QAction *a = new QAction(QFileInfo(_poi.files().at(index)).fileName(),
|
||||
QAction *a = new QAction(QFileInfo(_poi->files().at(index)).fileName(),
|
||||
this);
|
||||
a->setCheckable(true);
|
||||
|
||||
@ -248,7 +269,8 @@ void GUI::createActions()
|
||||
tr("Show POIs"), this);
|
||||
_showPOIAction->setCheckable(true);
|
||||
_showPOIAction->setShortcut(SHOW_POI_SHORTCUT);
|
||||
connect(_showPOIAction, SIGNAL(triggered(bool)), this, SLOT(showPOI(bool)));
|
||||
connect(_showPOIAction, SIGNAL(triggered(bool)), _pathView,
|
||||
SLOT(showPOI(bool)));
|
||||
addAction(_showPOIAction);
|
||||
createPOIFilesActions();
|
||||
|
||||
@ -316,12 +338,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);
|
||||
@ -392,6 +420,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"));
|
||||
@ -458,20 +488,25 @@ 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
|
||||
|
||||
_pathView->setPOI(_poi);
|
||||
}
|
||||
|
||||
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
|
||||
@ -479,6 +514,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++)
|
||||
@ -575,7 +612,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++)
|
||||
@ -594,61 +631,61 @@ 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);
|
||||
if (_showPOIAction->isChecked())
|
||||
_pathView->loadPOI(_poi);
|
||||
_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();
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
@ -656,7 +693,7 @@ bool GUI::loadFile(const QString &fileName)
|
||||
void GUI::openPOIFile()
|
||||
{
|
||||
QStringList files = QFileDialog::getOpenFileNames(this, tr("Open POI file"),
|
||||
QString(), tr("GPX files (*.gpx);;CSV files (*.csv);;All files (*)"));
|
||||
QString(), fileFormats());
|
||||
QStringList list = files;
|
||||
|
||||
for (QStringList::Iterator it = list.begin(); it != list.end(); it++)
|
||||
@ -665,21 +702,21 @@ void GUI::openPOIFile()
|
||||
|
||||
bool GUI::openPOIFile(const QString &fileName)
|
||||
{
|
||||
if (fileName.isEmpty())
|
||||
if (fileName.isEmpty() || _poi->files().contains(fileName))
|
||||
return false;
|
||||
|
||||
if (!_poi.loadFile(fileName)) {
|
||||
QString error = tr("Error loading POI file:\n%1")
|
||||
.arg(_poi.errorString()) + QString("\n");
|
||||
if (_poi.errorLine())
|
||||
error.append(tr("Line: %1").arg(_poi.errorLine()));
|
||||
QMessageBox::critical(this, tr("Error"), error);
|
||||
if (!_poi->loadFile(fileName)) {
|
||||
QString error = tr("Error loading POI file:") + "\n\n"
|
||||
+ fileName + "\n\n" + _poi->errorString();
|
||||
if (_poi->errorLine())
|
||||
error.append("\n" + tr("Line: %1").arg(_poi->errorLine()));
|
||||
QMessageBox::critical(this, APP_NAME, error);
|
||||
|
||||
return false;
|
||||
} else {
|
||||
_pathView->showPOI(true);
|
||||
_showPOIAction->setChecked(true);
|
||||
_pathView->loadPOI(_poi);
|
||||
QAction *action = createPOIFileAction(_poi.files().indexOf(fileName));
|
||||
QAction *action = createPOIFileAction(_poi->files().indexOf(fileName));
|
||||
action->setChecked(true);
|
||||
_poiFilesMenu->addAction(action);
|
||||
|
||||
@ -695,9 +732,7 @@ void GUI::closePOIFiles()
|
||||
delete _poiFilesActions[i];
|
||||
_poiFilesActions.clear();
|
||||
|
||||
_pathView->clearPOI();
|
||||
|
||||
_poi.clear();
|
||||
_poi->clear();
|
||||
}
|
||||
|
||||
void GUI::printFile()
|
||||
@ -760,9 +795,9 @@ void GUI::plot(QPrinter *printer)
|
||||
info.insert(tr("Waypoints"), QString::number(_waypointCount));
|
||||
|
||||
if (d > 0)
|
||||
info.insert(tr("Distance"), ::distance(d, units));
|
||||
info.insert(tr("Distance"), Format::distance(d, units));
|
||||
if (t > 0)
|
||||
info.insert(tr("Time"), ::timeSpan(t));
|
||||
info.insert(tr("Time"), Format::timeSpan(t));
|
||||
|
||||
|
||||
ratio = p.paintEngine()->paintDevice()->logicalDpiX() / SCREEN_DPI;
|
||||
@ -814,7 +849,7 @@ void GUI::reloadFile()
|
||||
updateStatusBarInfo();
|
||||
updateWindowTitle();
|
||||
updateGraphTabs();
|
||||
updateTrackView();
|
||||
updatePathView();
|
||||
if (_files.isEmpty())
|
||||
_fileActionGroup->setEnabled(false);
|
||||
else
|
||||
@ -848,33 +883,25 @@ void GUI::closeAll()
|
||||
updateStatusBarInfo();
|
||||
updateWindowTitle();
|
||||
updateGraphTabs();
|
||||
updateTrackView();
|
||||
updatePathView();
|
||||
}
|
||||
|
||||
void GUI::showPOI(bool checked)
|
||||
void GUI::showMap(bool show)
|
||||
{
|
||||
if (checked)
|
||||
_pathView->loadPOI(_poi);
|
||||
else
|
||||
_pathView->clearPOI();
|
||||
}
|
||||
|
||||
void GUI::showMap(bool checked)
|
||||
{
|
||||
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);
|
||||
@ -888,9 +915,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();
|
||||
|
||||
@ -936,6 +963,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();
|
||||
@ -949,18 +982,18 @@ void GUI::updateStatusBarInfo()
|
||||
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();
|
||||
}
|
||||
@ -1002,12 +1035,8 @@ void GUI::prevMap()
|
||||
|
||||
void GUI::poiFileChecked(int index)
|
||||
{
|
||||
_poi.enableFile(_poi.files().at(index),
|
||||
_poi->enableFile(_poi->files().at(index),
|
||||
_poiFilesActions.at(index)->isChecked());
|
||||
|
||||
_pathView->clearPOI();
|
||||
if (_showPOIAction->isChecked())
|
||||
_pathView->loadPOI(_poi);
|
||||
}
|
||||
|
||||
void GUI::sliderPositionChanged(qreal pos)
|
||||
@ -1070,7 +1099,7 @@ void GUI::updateGraphTabs()
|
||||
}
|
||||
}
|
||||
|
||||
void GUI::updateTrackView()
|
||||
void GUI::updatePathView()
|
||||
{
|
||||
_pathView->setHidden(!(_pathView->trackCount() + _pathView->routeCount()
|
||||
+ _pathView->waypointCount()));
|
||||
@ -1173,6 +1202,28 @@ void GUI::closeEvent(QCloseEvent *event)
|
||||
event->accept();
|
||||
}
|
||||
|
||||
void GUI::dragEnterEvent(QDragEnterEvent *event)
|
||||
{
|
||||
if (!event->mimeData()->hasUrls())
|
||||
return;
|
||||
if (event->proposedAction() != Qt::CopyAction)
|
||||
return;
|
||||
|
||||
QList<QUrl> urls = event->mimeData()->urls();
|
||||
for (int i = 0; i < urls.size(); i++)
|
||||
if (!urls.at(i).isLocalFile())
|
||||
return;
|
||||
|
||||
event->acceptProposedAction();
|
||||
}
|
||||
|
||||
void GUI::dropEvent(QDropEvent *event)
|
||||
{
|
||||
QList<QUrl> urls = event->mimeData()->urls();
|
||||
for (int i = 0; i < urls.size(); i++)
|
||||
openFile(urls.at(i).toLocalFile());
|
||||
}
|
||||
|
||||
void GUI::writeSettings()
|
||||
{
|
||||
QSettings settings(APP_NAME, APP_NAME);
|
||||
@ -1198,6 +1249,8 @@ void GUI::writeSettings()
|
||||
settings.setValue(SHOW_GRAPHS_SETTING, _showGraphsAction->isChecked());
|
||||
settings.setValue(GRAPH_TYPE_SETTING, _timeGraphAction->isChecked()
|
||||
? Time : Distance);
|
||||
settings.setValue(SHOW_GRAPH_GRIDS_SETTING,
|
||||
_showGraphGridAction->isChecked());
|
||||
settings.endGroup();
|
||||
|
||||
settings.beginGroup(POI_SETTINGS_GROUP);
|
||||
@ -1209,7 +1262,7 @@ void GUI::writeSettings()
|
||||
for (int i = 0, j = 0; i < _poiFilesActions.count(); i++) {
|
||||
if (!_poiFilesActions.at(i)->isChecked()) {
|
||||
settings.setArrayIndex(j++);
|
||||
settings.setValue(DISABLED_POI_FILE_SETTING, _poi.files().at(i));
|
||||
settings.setValue(DISABLED_POI_FILE_SETTING, _poi->files().at(i));
|
||||
}
|
||||
}
|
||||
settings.endArray();
|
||||
@ -1274,6 +1327,10 @@ void GUI::readSettings()
|
||||
_timeGraphAction->setChecked(true);
|
||||
} else
|
||||
_distanceGraphAction->setChecked(true);
|
||||
if (settings.value(SHOW_GRAPH_GRIDS_SETTING, true).toBool() == false)
|
||||
showGraphGrids(false);
|
||||
else
|
||||
_showGraphGridAction->setChecked(true);
|
||||
settings.endGroup();
|
||||
|
||||
settings.beginGroup(POI_SETTINGS_GROUP);
|
||||
@ -1287,15 +1344,17 @@ void GUI::readSettings()
|
||||
_showPOILabelsAction->setChecked(true);
|
||||
if (settings.value(SHOW_POI_SETTING, false).toBool() == true)
|
||||
_showPOIAction->setChecked(true);
|
||||
else
|
||||
_pathView->showPOI(false);
|
||||
for (int i = 0; i < _poiFilesActions.count(); i++)
|
||||
_poiFilesActions.at(i)->setChecked(true);
|
||||
int size = settings.beginReadArray(DISABLED_POI_FILE_SETTINGS_PREFIX);
|
||||
for (int i = 0; i < size; i++) {
|
||||
settings.setArrayIndex(i);
|
||||
int index = _poi.files().indexOf(settings.value(
|
||||
int index = _poi->files().indexOf(settings.value(
|
||||
DISABLED_POI_FILE_SETTING).toString());
|
||||
if (index >= 0) {
|
||||
_poi.enableFile(_poi.files().at(index), false);
|
||||
_poi->enableFile(_poi->files().at(index), false);
|
||||
_poiFilesActions.at(index)->setChecked(false);
|
||||
}
|
||||
}
|
||||
@ -1339,7 +1398,7 @@ int GUI::mapIndex(const QString &name)
|
||||
return 0;
|
||||
}
|
||||
|
||||
qreal GUI::distance()
|
||||
qreal GUI::distance() const
|
||||
{
|
||||
qreal dist = 0;
|
||||
|
||||
@ -1351,7 +1410,7 @@ qreal GUI::distance()
|
||||
return dist;
|
||||
}
|
||||
|
||||
qreal GUI::time()
|
||||
qreal GUI::time() const
|
||||
{
|
||||
return (_showTracksAction->isChecked()) ? _time : 0;
|
||||
}
|
||||
|
24
src/gui.h
@ -45,11 +45,11 @@ private slots:
|
||||
void reloadFile();
|
||||
void openPOIFile();
|
||||
void closePOIFiles();
|
||||
void showPOI(bool checked);
|
||||
void showMap(bool checked);
|
||||
void showGraphs(bool checked);
|
||||
void showToolbars(bool checked);
|
||||
void showFullscreen(bool checked);
|
||||
void 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();
|
||||
@ -89,6 +89,7 @@ private:
|
||||
void createStatusBar();
|
||||
void createPathView();
|
||||
void createGraphTabs();
|
||||
void createBrowser();
|
||||
|
||||
bool openPOIFile(const QString &fileName);
|
||||
bool loadFile(const QString &fileName);
|
||||
@ -97,19 +98,23 @@ 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);
|
||||
void dropEvent(QDropEvent *event);
|
||||
|
||||
QToolBar *_fileToolBar;
|
||||
QToolBar *_showToolBar;
|
||||
@ -137,6 +142,7 @@ private:
|
||||
QAction *_fullscreenAction;
|
||||
QAction *_clearMapCacheAction;
|
||||
QAction *_showGraphsAction;
|
||||
QAction *_showGraphGridAction;
|
||||
QAction *_distanceGraphAction;
|
||||
QAction *_timeGraphAction;
|
||||
QAction *_showToolbarsAction;
|
||||
@ -166,7 +172,7 @@ private:
|
||||
QTabWidget *_graphTabWidget;
|
||||
QList<GraphTab*> _tabs;
|
||||
|
||||
POI _poi;
|
||||
POI *_poi;
|
||||
QList<Map*> _maps;
|
||||
|
||||
FileBrowser *_browser;
|
||||
|
@ -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();
|
||||
|
@ -3,8 +3,6 @@
|
||||
|
||||
#include "graphtab.h"
|
||||
|
||||
class GPX;
|
||||
|
||||
class HeartRateGraph : public GraphTab
|
||||
{
|
||||
Q_OBJECT
|
||||
@ -13,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);
|
||||
|
@ -40,6 +40,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 + ": ");
|
||||
|
344
src/kmlparser.cpp
Normal file
@ -0,0 +1,344 @@
|
||||
#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 > 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;
|
||||
|
||||
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 > 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;
|
||||
|
||||
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::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() == "Point") {
|
||||
_waypoints.append(Waypoint());
|
||||
Waypoint &waypoint = _waypoints.last();
|
||||
waypoint.setName(name);
|
||||
waypoint.setDescription(desc);
|
||||
waypoint.setTimestamp(timestamp);
|
||||
point(waypoint);
|
||||
} else if (_reader.name() == "LineString") {
|
||||
_tracks.append(TrackData());
|
||||
TrackData &track = _tracks.last();
|
||||
track.setName(name);
|
||||
track.setDescription(desc);
|
||||
lineString(track);
|
||||
} else if (_reader.name() == "Track") {
|
||||
_tracks.append(TrackData());
|
||||
TrackData &track = _tracks.last();
|
||||
track.setName(name);
|
||||
track.setDescription(desc);
|
||||
Track(track);
|
||||
} 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();
|
||||
}
|
38
src/kmlparser.h
Normal file
@ -0,0 +1,38 @@
|
||||
#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 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());
|
||||
}
|
||||
|
51
src/misc.cpp
@ -1,5 +1,4 @@
|
||||
#include <cmath>
|
||||
#include <QApplication>
|
||||
#include "misc.h"
|
||||
|
||||
|
||||
@ -34,53 +33,3 @@ double niceNum(double x, int round)
|
||||
|
||||
return nf * pow(10.0, expv);
|
||||
}
|
||||
|
||||
QString 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 distance(qreal value, Units units)
|
||||
{
|
||||
if (units == Imperial) {
|
||||
if (value < MIINM)
|
||||
return QString::number(value * M2FT, 'f', 0) + UNIT_SPACE
|
||||
+ qApp->translate("Misc", "ft");
|
||||
else
|
||||
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");
|
||||
}
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
@ -1,15 +1,6 @@
|
||||
#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);
|
||||
|
||||
#endif // MISC_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.h
Normal file
@ -0,0 +1,9 @@
|
||||
#ifndef PATH_H
|
||||
#define PATH_H
|
||||
|
||||
#include <QVector>
|
||||
#include "coordinates.h"
|
||||
|
||||
typedef QVector<Coordinates> Path;
|
||||
|
||||
#endif // PATH_H
|
248
src/pathview.cpp
@ -1,9 +1,9 @@
|
||||
#include <QGraphicsView>
|
||||
#include <QGraphicsScene>
|
||||
#include <QWheelEvent>
|
||||
#include "ll.h"
|
||||
#include "rd.h"
|
||||
#include "poi.h"
|
||||
#include "gpx.h"
|
||||
#include "data.h"
|
||||
#include "map.h"
|
||||
#include "trackitem.h"
|
||||
#include "routeitem.h"
|
||||
@ -12,8 +12,43 @@
|
||||
#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 * pow(2.0, z))));
|
||||
tile.setY((int)(floor((1.0 - (m.y() / 180.0)) / 2.0 * pow(2.0, z))));
|
||||
|
||||
return tile;
|
||||
}
|
||||
|
||||
static QPointF tile2mercator(const QPoint &tile, int z)
|
||||
{
|
||||
Coordinates m;
|
||||
|
||||
m.setLon(tile.x() / pow(2.0, z) * 360.0 - 180);
|
||||
qreal n = M_PI - 2.0 * M_PI * tile.y() / pow(2.0, z);
|
||||
m.setLat(rad2deg(atan(0.5 * (exp(n) - exp(-n)))));
|
||||
|
||||
return m.toMercator();
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
PathView::PathView(QWidget *parent)
|
||||
: QGraphicsView(parent)
|
||||
@ -26,6 +61,7 @@ PathView::PathView(QWidget *parent)
|
||||
setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
|
||||
setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
|
||||
setRenderHints(QPainter::Antialiasing);
|
||||
setAcceptDrops(false);
|
||||
|
||||
_mapScale = new ScaleItem();
|
||||
_mapScale->setZValue(2.0);
|
||||
@ -33,6 +69,7 @@ PathView::PathView(QWidget *parent)
|
||||
_zoom = ZOOM_MAX;
|
||||
_scale = mapScale(_zoom);
|
||||
_map = 0;
|
||||
_poi = 0;
|
||||
|
||||
_units = Metric;
|
||||
|
||||
@ -40,6 +77,7 @@ PathView::PathView(QWidget *parent)
|
||||
_showRoutes = true;
|
||||
_showWaypoints = true;
|
||||
_showWaypointLabels = true;
|
||||
_showPOI = true;
|
||||
_showPOILabels = true;
|
||||
_overlapPOIs = true;
|
||||
_showRouteWaypoints = true;
|
||||
@ -69,6 +107,9 @@ PathItem *PathView::addTrack(const Track &track)
|
||||
ti->setVisible(_showTracks);
|
||||
_scene->addItem(ti);
|
||||
|
||||
if (_poi)
|
||||
addPOI(_poi->points(ti));
|
||||
|
||||
return ti;
|
||||
}
|
||||
|
||||
@ -90,6 +131,9 @@ PathItem *PathView::addRoute(const Route &route)
|
||||
ri->showWaypointLabels(_showWaypointLabels);
|
||||
_scene->addItem(ri);
|
||||
|
||||
if (_poi)
|
||||
addPOI(_poi->points(ri));
|
||||
|
||||
return ri;
|
||||
}
|
||||
|
||||
@ -108,21 +152,24 @@ void PathView::addWaypoints(const QList<Waypoint> &waypoints)
|
||||
_waypoints.append(wi);
|
||||
}
|
||||
|
||||
if (_poi)
|
||||
addPOI(_poi->points(waypoints));
|
||||
|
||||
_zoom = qMin(_zoom, scale2zoom(waypointScale()));
|
||||
_scale = mapScale(_zoom);
|
||||
}
|
||||
|
||||
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;
|
||||
@ -130,10 +177,13 @@ QList<PathItem *> PathView::loadGPX(const GPX &gpx)
|
||||
if ((_tracks.size() + _routes.size() > 1 && _zoom < zoom)
|
||||
|| (_waypoints.size() && _zoom < zoom))
|
||||
rescale(_scale);
|
||||
else
|
||||
updatePOIVisibility();
|
||||
|
||||
QRectF br = trackBoundingRect() | routeBoundingRect()
|
||||
| waypointBoundingRect();
|
||||
QRectF ba = br.adjusted(-TILE_SIZE, -TILE_SIZE, TILE_SIZE, TILE_SIZE);
|
||||
QRectF ba = br.adjusted(-Tile::size(), -Tile::size(), Tile::size(),
|
||||
Tile::size());
|
||||
_scene->setSceneRect(ba);
|
||||
centerOn(ba.center());
|
||||
|
||||
@ -254,24 +304,34 @@ qreal PathView::waypointScale() const
|
||||
|
||||
qreal PathView::mapScale(int zoom) const
|
||||
{
|
||||
return ((360.0/(qreal)(1<<zoom))/(qreal)TILE_SIZE);
|
||||
return ((360.0/(qreal)(1<<zoom))/(qreal)Tile::size());
|
||||
}
|
||||
|
||||
void PathView::checkPOIOverlap()
|
||||
void PathView::updatePOIVisibility()
|
||||
{
|
||||
QHash<Waypoint, WaypointItem*>::const_iterator it, jt;
|
||||
|
||||
for (it = _pois.constBegin(); it != _pois.constEnd(); it++) {
|
||||
for (jt = _pois.constBegin(); jt != _pois.constEnd(); jt++) {
|
||||
if (it != jt && it.value()->isVisible() && jt.value()->isVisible()
|
||||
&& it.value()->collidesWithItem(jt.value()))
|
||||
jt.value()->hide();
|
||||
if (!_showPOI)
|
||||
return;
|
||||
|
||||
for (it = _pois.constBegin(); it != _pois.constEnd(); it++)
|
||||
it.value()->show();
|
||||
|
||||
if (!_overlapPOIs) {
|
||||
for (it = _pois.constBegin(); it != _pois.constEnd(); it++) {
|
||||
for (jt = _pois.constBegin(); jt != _pois.constEnd(); jt++) {
|
||||
if (it.value()->isVisible() && jt.value()->isVisible()
|
||||
&& it != jt && it.value()->collidesWithItem(jt.value()))
|
||||
jt.value()->hide();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void PathView::rescale(qreal scale)
|
||||
{
|
||||
_scale = scale;
|
||||
|
||||
for (int i = 0; i < _tracks.size(); i++)
|
||||
_tracks.at(i)->setScale(1.0/scale);
|
||||
|
||||
@ -282,15 +342,45 @@ void PathView::rescale(qreal scale)
|
||||
_waypoints.at(i)->setScale(1.0/scale);
|
||||
|
||||
QHash<Waypoint, WaypointItem*>::const_iterator it;
|
||||
for (it = _pois.constBegin(); it != _pois.constEnd(); it++) {
|
||||
for (it = _pois.constBegin(); it != _pois.constEnd(); it++)
|
||||
it.value()->setScale(1.0/scale);
|
||||
it.value()->show();
|
||||
|
||||
updatePOIVisibility();
|
||||
}
|
||||
|
||||
void PathView::setPOI(POI *poi)
|
||||
{
|
||||
if (_poi)
|
||||
disconnect(_poi, SIGNAL(pointsChanged()), this, SLOT(updatePOI()));
|
||||
|
||||
_poi = poi;
|
||||
|
||||
if (_poi)
|
||||
connect(_poi, SIGNAL(pointsChanged()), this, SLOT(updatePOI()));
|
||||
|
||||
updatePOI();
|
||||
}
|
||||
|
||||
void PathView::updatePOI()
|
||||
{
|
||||
QHash<Waypoint, WaypointItem*>::const_iterator it;
|
||||
|
||||
for (it = _pois.constBegin(); it != _pois.constEnd(); it++) {
|
||||
_scene->removeItem(it.value());
|
||||
delete it.value();
|
||||
}
|
||||
_pois.clear();
|
||||
|
||||
if (!_overlapPOIs)
|
||||
checkPOIOverlap();
|
||||
if (!_poi)
|
||||
return;
|
||||
|
||||
_scale = scale;
|
||||
for (int i = 0; i < _tracks.size(); i++)
|
||||
addPOI(_poi->points(_tracks.at(i)));
|
||||
for (int i = 0; i < _routes.size(); i++)
|
||||
addPOI(_poi->points(_routes.at(i)));
|
||||
addPOI(_poi->points(_waypoints));
|
||||
|
||||
updatePOIVisibility();
|
||||
}
|
||||
|
||||
void PathView::addPOI(const QVector<Waypoint> &waypoints)
|
||||
@ -305,33 +395,23 @@ void PathView::addPOI(const QVector<Waypoint> &waypoints)
|
||||
pi->setScale(1.0/_scale);
|
||||
pi->setZValue(1);
|
||||
pi->showLabel(_showPOILabels);
|
||||
pi->setVisible(_showPOI);
|
||||
_scene->addItem(pi);
|
||||
|
||||
_pois.insert(w, pi);
|
||||
}
|
||||
}
|
||||
|
||||
void PathView::loadPOI(const POI &poi)
|
||||
{
|
||||
if (!_tracks.size() && !_routes.size() && !_waypoints.size())
|
||||
return;
|
||||
|
||||
for (int i = 0; i < _tracks.size(); i++)
|
||||
addPOI(poi.points(_tracks.at(i)->path()));
|
||||
for (int i = 0; i < _routes.size(); i++)
|
||||
addPOI(poi.points(_routes.at(i)->path()));
|
||||
addPOI(poi.points(_waypoints));
|
||||
|
||||
if (!_overlapPOIs)
|
||||
checkPOIOverlap();
|
||||
}
|
||||
|
||||
void PathView::setMap(Map *map)
|
||||
{
|
||||
_map = map;
|
||||
if (_map)
|
||||
connect(_map, SIGNAL(loaded()), this, SLOT(redraw()),
|
||||
Qt::UniqueConnection);
|
||||
disconnect(_map, SIGNAL(loaded()), this, SLOT(redraw()));
|
||||
|
||||
_map = map;
|
||||
|
||||
if (_map)
|
||||
connect(_map, SIGNAL(loaded()), this, SLOT(redraw()));
|
||||
|
||||
resetCachedContent();
|
||||
}
|
||||
|
||||
@ -367,25 +447,29 @@ void PathView::rescale()
|
||||
_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;
|
||||
|
||||
QPoint offset = pos - viewport()->rect().center();
|
||||
QPointF spos = mapToScene(pos);
|
||||
|
||||
qreal scale = _scale;
|
||||
_zoom = z;
|
||||
|
||||
rescale(mapScale(_zoom));
|
||||
QRectF br = trackBoundingRect() | routeBoundingRect()
|
||||
| waypointBoundingRect();
|
||||
QRectF ba = br.adjusted(-TILE_SIZE, -TILE_SIZE, TILE_SIZE, TILE_SIZE);
|
||||
QRectF ba = br.adjusted(-Tile::size(), -Tile::size(), Tile::size(),
|
||||
Tile::size());
|
||||
_scene->setSceneRect(ba);
|
||||
|
||||
if (br.width() < viewport()->size().width()
|
||||
&& br.height() < viewport()->size().height())
|
||||
centerOn(br.center());
|
||||
else
|
||||
centerOn(pos * scale/_scale);
|
||||
centerOn((spos * (scale/_scale)) - offset);
|
||||
|
||||
_mapScale->setZoom(_zoom);
|
||||
|
||||
@ -394,14 +478,21 @@ void PathView::zoom(int z, const QPointF &pos)
|
||||
|
||||
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)
|
||||
@ -414,7 +505,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);
|
||||
}
|
||||
@ -453,18 +544,6 @@ void PathView::plot(QPainter *painter, const QRectF &target)
|
||||
setUpdatesEnabled(true);
|
||||
}
|
||||
|
||||
void PathView::clearPOI()
|
||||
{
|
||||
QHash<Waypoint, WaypointItem*>::const_iterator it;
|
||||
|
||||
for (it = _pois.constBegin(); it != _pois.constEnd(); it++) {
|
||||
_scene->removeItem(it.value());
|
||||
delete it.value();
|
||||
}
|
||||
|
||||
_pois.clear();
|
||||
}
|
||||
|
||||
void PathView::clear()
|
||||
{
|
||||
if (_mapScale->scene() == _scene)
|
||||
@ -526,6 +605,17 @@ void PathView::showRouteWaypoints(bool show)
|
||||
_routes.at(i)->showWaypoints(show);
|
||||
}
|
||||
|
||||
void PathView::showPOI(bool show)
|
||||
{
|
||||
_showPOI = show;
|
||||
|
||||
QHash<Waypoint, WaypointItem*>::const_iterator it;
|
||||
for (it = _pois.constBegin(); it != _pois.constEnd(); it++)
|
||||
it.value()->setVisible(show);
|
||||
|
||||
updatePOIVisibility();
|
||||
}
|
||||
|
||||
void PathView::showPOILabels(bool show)
|
||||
{
|
||||
_showPOILabels = show;
|
||||
@ -534,19 +624,14 @@ void PathView::showPOILabels(bool show)
|
||||
for (it = _pois.constBegin(); it != _pois.constEnd(); it++)
|
||||
it.value()->showLabel(show);
|
||||
|
||||
setPOIOverlap(_overlapPOIs);
|
||||
updatePOIVisibility();
|
||||
}
|
||||
|
||||
void PathView::setPOIOverlap(bool overlap)
|
||||
{
|
||||
_overlapPOIs = overlap;
|
||||
|
||||
if (_overlapPOIs) {
|
||||
QHash<Waypoint, WaypointItem*>::const_iterator it;
|
||||
for (it = _pois.constBegin(); it != _pois.constEnd(); it++)
|
||||
it.value()->show();
|
||||
} else
|
||||
checkPOIOverlap();
|
||||
updatePOIVisibility();
|
||||
}
|
||||
|
||||
void PathView::drawBackground(QPainter *painter, const QRectF &rect)
|
||||
@ -565,8 +650,8 @@ void PathView::drawBackground(QPainter *painter, const QRectF &rect)
|
||||
-tm.y() / _scale))).toPoint();
|
||||
|
||||
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++) {
|
||||
for (int i = 0; i <= rr.size().width() / Tile::size() + 1; i++) {
|
||||
for (int j = 0; j <= rr.size().height() / Tile::size() + 1; j++) {
|
||||
tiles.append(Tile(QPoint(tile.x() + i, tile.y() + j), _zoom));
|
||||
}
|
||||
}
|
||||
@ -575,13 +660,13 @@ void PathView::drawBackground(QPainter *painter, const QRectF &rect)
|
||||
|
||||
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)
|
||||
{
|
||||
if (_tracks.isEmpty() && _routes.isEmpty() && _waypoints.isEmpty())
|
||||
return;
|
||||
@ -590,14 +675,15 @@ void PathView::resizeEvent(QResizeEvent *e)
|
||||
|
||||
QRectF br = trackBoundingRect() | routeBoundingRect()
|
||||
| waypointBoundingRect();
|
||||
QRectF ba = br.adjusted(-TILE_SIZE, -TILE_SIZE, TILE_SIZE, TILE_SIZE);
|
||||
QRectF ba = br.adjusted(-Tile::size(), -Tile::size(), Tile::size(),
|
||||
Tile::size());
|
||||
|
||||
if (ba.width() < e->size().width()) {
|
||||
qreal diff = e->size().width() - ba.width();
|
||||
if (ba.width() < event->size().width()) {
|
||||
qreal diff = event->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();
|
||||
if (ba.height() < event->size().height()) {
|
||||
qreal diff = event->size().height() - ba.height();
|
||||
ba.adjust(0, -diff/2, 0, diff/2);
|
||||
}
|
||||
|
||||
@ -607,7 +693,7 @@ void PathView::resizeEvent(QResizeEvent *e)
|
||||
resetCachedContent();
|
||||
}
|
||||
|
||||
void PathView::paintEvent(QPaintEvent *e)
|
||||
void PathView::paintEvent(QPaintEvent *event)
|
||||
{
|
||||
QPointF scenePos = mapToScene(rect().bottomRight() + QPoint(
|
||||
-(SCALE_OFFSET + _mapScale->boundingRect().width()),
|
||||
@ -615,5 +701,5 @@ void PathView::paintEvent(QPaintEvent *e)
|
||||
if (_mapScale->pos() != scenePos && !_plot)
|
||||
_mapScale->setPos(scenePos);
|
||||
|
||||
QGraphicsView::paintEvent(e);
|
||||
QGraphicsView::paintEvent(event);
|
||||
}
|
||||
|
@ -9,7 +9,7 @@
|
||||
#include "palette.h"
|
||||
#include "waypoint.h"
|
||||
|
||||
class GPX;
|
||||
class Data;
|
||||
class POI;
|
||||
class Map;
|
||||
class Track;
|
||||
@ -28,12 +28,9 @@ public:
|
||||
PathView(QWidget *parent = 0);
|
||||
~PathView();
|
||||
|
||||
QList<PathItem*> loadGPX(const GPX &gpx);
|
||||
|
||||
void loadPOI(const POI &poi);
|
||||
void clearPOI();
|
||||
void clear();
|
||||
QList<PathItem*> loadData(const Data &data);
|
||||
|
||||
void setPOI(POI *poi);
|
||||
void setMap(Map *map);
|
||||
void setUnits(enum Units units);
|
||||
|
||||
@ -43,9 +40,12 @@ public:
|
||||
int routeCount() const {return _routes.count();}
|
||||
int waypointCount() const {return _waypoints.count();}
|
||||
|
||||
void clear();
|
||||
|
||||
public slots:
|
||||
void redraw();
|
||||
|
||||
void showPOI(bool show);
|
||||
void setPOIOverlap(bool overlap);
|
||||
void showWaypointLabels(bool show);
|
||||
void showPOILabels(bool show);
|
||||
@ -54,11 +54,16 @@ public slots:
|
||||
void showWaypoints(bool show);
|
||||
void showRouteWaypoints(bool show);
|
||||
|
||||
private slots:
|
||||
void updatePOI();
|
||||
|
||||
private:
|
||||
PathItem *addTrack(const Track &track);
|
||||
PathItem *addRoute(const Route &route);
|
||||
void addWaypoints(const QList<Waypoint> &waypoints);
|
||||
void addPOI(const QVector<Waypoint> &waypoints);
|
||||
void loadPOI();
|
||||
void clearPOI();
|
||||
|
||||
QRectF trackBoundingRect() const;
|
||||
QRectF routeBoundingRect() const;
|
||||
@ -69,23 +74,25 @@ private:
|
||||
qreal mapScale(int zoom) const;
|
||||
void rescale(qreal scale);
|
||||
void rescale();
|
||||
void zoom(int z, const QPointF &pos);
|
||||
void checkPOIOverlap();
|
||||
void zoom(int z, const QPoint &pos);
|
||||
void updatePOIVisibility();
|
||||
|
||||
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);
|
||||
|
||||
QGraphicsScene *_scene;
|
||||
ScaleItem *_mapScale;
|
||||
QList<TrackItem*> _tracks;
|
||||
QList<RouteItem*> _routes;
|
||||
QList<WaypointItem*> _waypoints;
|
||||
QHash<Waypoint, WaypointItem*> _pois;
|
||||
|
||||
Map *_map;
|
||||
ScaleItem *_mapScale;
|
||||
POI *_poi;
|
||||
|
||||
Palette _palette;
|
||||
|
||||
@ -98,6 +105,7 @@ private:
|
||||
bool _showRoutes;
|
||||
bool _showWaypoints;
|
||||
bool _showWaypointLabels;
|
||||
bool _showPOI;
|
||||
bool _showPOILabels;
|
||||
bool _overlapPOIs;
|
||||
bool _showRouteWaypoints;
|
||||
|
197
src/poi.cpp
@ -1,139 +1,52 @@
|
||||
#include <QFile>
|
||||
#include <QSet>
|
||||
#include <QList>
|
||||
#include <QPainterPath>
|
||||
#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;
|
||||
}
|
||||
|
||||
bool POI::loadFile(const QString &fileName)
|
||||
{
|
||||
QString error;
|
||||
int errorLine;
|
||||
Data data;
|
||||
FileIndex index;
|
||||
|
||||
_error.clear();
|
||||
_errorString.clear();
|
||||
_errorLine = 0;
|
||||
|
||||
|
||||
if (loadCSVFile(fileName))
|
||||
return true;
|
||||
else {
|
||||
error = _error;
|
||||
errorLine = _errorLine;
|
||||
}
|
||||
if (loadGPXFile(fileName))
|
||||
return true;
|
||||
|
||||
fprintf(stderr, "Error loading POI file: %s:\n", qPrintable(fileName));
|
||||
fprintf(stderr, "CSV: line %d: %s\n", errorLine, qPrintable(error));
|
||||
fprintf(stderr, "GPX: line %d: %s\n", _errorLine, qPrintable(_error));
|
||||
|
||||
if (errorLine > _errorLine) {
|
||||
_errorLine = errorLine;
|
||||
_error = error;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
bool POI::loadGPXFile(const QString &fileName)
|
||||
{
|
||||
GPX gpx;
|
||||
FileIndex index;
|
||||
|
||||
index.enabled = true;
|
||||
index.start = _data.size();
|
||||
|
||||
if (gpx.loadFile(fileName)) {
|
||||
for (int i = 0; i < gpx.waypoints().size(); i++)
|
||||
_data.append(gpx.waypoints().at(i));
|
||||
index.end = _data.size() - 1;
|
||||
|
||||
for (int i = index.start; i <= index.end; i++) {
|
||||
const QPointF &p = _data.at(i).coordinates();
|
||||
qreal c[2];
|
||||
c[0] = p.x();
|
||||
c[1] = p.y();
|
||||
_tree.Insert(c, c, i);
|
||||
}
|
||||
|
||||
_files.append(fileName);
|
||||
_indexes.append(index);
|
||||
|
||||
return true;
|
||||
} else {
|
||||
_error = gpx.errorString();
|
||||
_errorLine = gpx.errorLine();
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
bool POI::loadCSVFile(const QString &fileName)
|
||||
{
|
||||
QFile file(fileName);
|
||||
FileIndex index;
|
||||
bool ret;
|
||||
int ln = 1;
|
||||
|
||||
index.enabled = true;
|
||||
index.start = _data.size();
|
||||
|
||||
if (!file.open(QFile::ReadOnly | QFile::Text)) {
|
||||
_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;
|
||||
}
|
||||
|
||||
@ -145,18 +58,19 @@ static bool cb(size_t data, void* context)
|
||||
return true;
|
||||
}
|
||||
|
||||
QVector<Waypoint> POI::points(const QPainterPath &path, qreal radius) const
|
||||
QVector<Waypoint> POI::points(const PathItem *path) const
|
||||
{
|
||||
QVector<Waypoint> ret;
|
||||
QSet<int> set;
|
||||
qreal min[2], max[2];
|
||||
const QPainterPath &pp = path->path();
|
||||
|
||||
for (int i = 0; i < path.elementCount(); i++) {
|
||||
QPointF p = mercator2ll(path.elementAt(i));
|
||||
min[0] = p.x() - radius;
|
||||
min[1] = -p.y() - radius;
|
||||
max[0] = p.x() + radius;
|
||||
max[1] = -p.y() + radius;
|
||||
for (int i = 0; i < pp.elementCount(); i++) {
|
||||
Coordinates p = Coordinates::fromMercator(pp.elementAt(i));
|
||||
min[0] = p.lon() - _radius;
|
||||
min[1] = -p.lat() - _radius;
|
||||
max[0] = p.lon() + _radius;
|
||||
max[1] = -p.lat() + _radius;
|
||||
_tree.Search(min, max, cb, &set);
|
||||
}
|
||||
|
||||
@ -169,7 +83,7 @@ QVector<Waypoint> POI::points(const QPainterPath &path, qreal radius) const
|
||||
return ret;
|
||||
}
|
||||
|
||||
QVector<Waypoint> POI::points(const QList<WaypointItem*> &list, qreal radius)
|
||||
QVector<Waypoint> POI::points(const QList<WaypointItem*> &list)
|
||||
const
|
||||
{
|
||||
QVector<Waypoint> ret;
|
||||
@ -177,11 +91,35 @@ QVector<Waypoint> POI::points(const QList<WaypointItem*> &list, qreal radius)
|
||||
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();
|
||||
min[0] = p.lon() - _radius;
|
||||
min[1] = p.lat() - _radius;
|
||||
max[0] = p.lon() + _radius;
|
||||
max[1] = p.lat() + _radius;
|
||||
_tree.Search(min, max, cb, &set);
|
||||
}
|
||||
|
||||
QSet<int>::const_iterator i = set.constBegin();
|
||||
while (i != set.constEnd()) {
|
||||
ret.append(_data.at(*i));
|
||||
++i;
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
QVector<Waypoint> POI::points(const QList<Waypoint> &list) const
|
||||
{
|
||||
QVector<Waypoint> ret;
|
||||
QSet<int> set;
|
||||
qreal min[2], max[2];
|
||||
|
||||
for (int i = 0; i < list.count(); i++) {
|
||||
const Coordinates &p = list.at(i).coordinates();
|
||||
min[0] = p.lon() - _radius;
|
||||
min[1] = p.lat() - _radius;
|
||||
max[0] = p.lon() + _radius;
|
||||
max[1] = p.lat() + _radius;
|
||||
_tree.Search(min, max, cb, &set);
|
||||
}
|
||||
|
||||
@ -209,13 +147,15 @@ 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);
|
||||
}
|
||||
}
|
||||
|
||||
emit pointsChanged();
|
||||
}
|
||||
|
||||
void POI::clear()
|
||||
@ -224,4 +164,13 @@ void POI::clear()
|
||||
_data.clear();
|
||||
_files.clear();
|
||||
_indexes.clear();
|
||||
|
||||
emit pointsChanged();
|
||||
}
|
||||
|
||||
void POI::setRadius(qreal radius)
|
||||
{
|
||||
_radius = radius;
|
||||
|
||||
emit pointsChanged();
|
||||
}
|
||||
|
33
src/poi.h
@ -8,28 +8,34 @@
|
||||
#include "waypoint.h"
|
||||
#include "rtree.h"
|
||||
|
||||
class QPainterPath;
|
||||
class PathItem;
|
||||
class WaypointItem;
|
||||
|
||||
#define POI_RADIUS 0.01
|
||||
|
||||
class POI
|
||||
class POI : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
POI() : _errorLine(0) {}
|
||||
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;}
|
||||
|
||||
QVector<Waypoint> points(const QPainterPath &path,
|
||||
qreal radius = POI_RADIUS) const;
|
||||
QVector<Waypoint> points(const QList<WaypointItem*> &list,
|
||||
qreal radius = POI_RADIUS) const;
|
||||
qreal radius() const {return _radius;}
|
||||
void setRadius(qreal radius);
|
||||
|
||||
QVector<Waypoint> points(const PathItem *path) const;
|
||||
QVector<Waypoint> points(const QList<WaypointItem*> &list) const;
|
||||
QVector<Waypoint> points(const QList<Waypoint> &list) const;
|
||||
|
||||
const QStringList &files() const {return _files;}
|
||||
void enableFile(const QString &fileName, bool enable);
|
||||
void clear();
|
||||
|
||||
signals:
|
||||
void pointsChanged();
|
||||
|
||||
private:
|
||||
typedef RTree<size_t, qreal, 2> POITree;
|
||||
typedef struct {
|
||||
@ -38,15 +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;
|
||||
|
||||
QString _error;
|
||||
qreal _radius;
|
||||
|
||||
QString _errorString;
|
||||
int _errorLine;
|
||||
};
|
||||
|
||||
|
84
src/powergraph.cpp
Normal file
@ -0,0 +1,84 @@
|
||||
#include "data.h"
|
||||
#include "powergraph.h"
|
||||
|
||||
|
||||
PowerGraph::PowerGraph(QWidget *parent) : GraphTab(parent)
|
||||
{
|
||||
_units = Metric;
|
||||
_showTracks = true;
|
||||
|
||||
GraphView::setYUnits(tr("W"));
|
||||
setYLabel(tr("Power"));
|
||||
|
||||
setSliderPrecision(1);
|
||||
}
|
||||
|
||||
void PowerGraph::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 PowerGraph::loadData(const Data &data, const QList<PathItem *> &paths)
|
||||
{
|
||||
for (int i = 0; i < data.tracks().count(); i++) {
|
||||
const Graph &graph = data.tracks().at(i)->power();
|
||||
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 PowerGraph::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 PowerGraph::clear()
|
||||
{
|
||||
_avg.clear();
|
||||
|
||||
GraphView::clear();
|
||||
}
|
||||
|
||||
void PowerGraph::showTracks(bool show)
|
||||
{
|
||||
_showTracks = show;
|
||||
|
||||
showGraph(show);
|
||||
setInfo();
|
||||
|
||||
redraw();
|
||||
}
|
31
src/powergraph.h
Normal file
@ -0,0 +1,31 @@
|
||||
#ifndef POWERGRAPH_H
|
||||
#define POWERGRAPH_H
|
||||
|
||||
#include "graphtab.h"
|
||||
|
||||
class PowerGraph : public GraphTab
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
PowerGraph(QWidget *parent = 0);
|
||||
|
||||
QString label() const {return tr("Power");}
|
||||
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 // POWERGRAPH_H
|
13
src/rd.h
Normal file
@ -0,0 +1,13 @@
|
||||
#ifndef RD_H
|
||||
#define RD_H
|
||||
|
||||
#include <cmath>
|
||||
|
||||
#ifndef M_PI
|
||||
#define M_PI 3.14159265358979323846
|
||||
#endif // M_PI
|
||||
|
||||
#define deg2rad(d) (((d)*M_PI)/180.0)
|
||||
#define rad2deg(d) (((d)*180.0)/M_PI)
|
||||
|
||||
#endif // RD_H
|
@ -1,13 +1,12 @@
|
||||
#include "ll.h"
|
||||
#include "route.h"
|
||||
|
||||
Route::Route(const QVector<Waypoint> &data) : _data(data)
|
||||
Route::Route(const RouteData &data) : _data(data)
|
||||
{
|
||||
qreal dist = 0;
|
||||
|
||||
_distance.append(dist);
|
||||
for (int i = 1; i < data.count(); i++) {
|
||||
dist += llDistance(data.at(i).coordinates(), data.at(i-1).coordinates());
|
||||
dist += data.at(i).coordinates().distanceTo(data.at(i-1).coordinates());
|
||||
_distance.append(dist);
|
||||
}
|
||||
}
|
||||
@ -19,7 +18,7 @@ Graph Route::elevation() const
|
||||
for (int i = 0; i < _data.size(); i++)
|
||||
if (_data.at(i).hasElevation())
|
||||
graph.append(GraphPoint(_distance.at(i), NAN,
|
||||
_data.at(i).elevation() - _data.at(i).geoidHeight()));
|
||||
_data.at(i).elevation()));
|
||||
|
||||
return graph;
|
||||
}
|
||||
|
@ -2,15 +2,15 @@
|
||||
#define ROUTE_H
|
||||
|
||||
#include <QVector>
|
||||
#include "waypoint.h"
|
||||
#include "routedata.h"
|
||||
#include "graph.h"
|
||||
|
||||
class Route
|
||||
{
|
||||
public:
|
||||
Route(const QVector<Waypoint> &data);
|
||||
Route(const RouteData &data);
|
||||
|
||||
const QVector<Waypoint> &route() const {return _data;}
|
||||
const RouteData &route() const {return _data;}
|
||||
Graph elevation() const;
|
||||
|
||||
qreal distance() const;
|
||||
@ -18,7 +18,7 @@ public:
|
||||
bool isNull() const {return (_data.count() < 2);}
|
||||
|
||||
private:
|
||||
const QVector<Waypoint> &_data;
|
||||
const RouteData &_data;
|
||||
QVector<qreal> _distance;
|
||||
};
|
||||
|
||||
|
21
src/routedata.h
Normal file
@ -0,0 +1,21 @@
|
||||
#ifndef ROUTEDATA_H
|
||||
#define ROUTEDATA_H
|
||||
|
||||
#include <QVector>
|
||||
#include <QString>
|
||||
#include "waypoint.h"
|
||||
|
||||
class RouteData : public QVector<Waypoint>
|
||||
{
|
||||
public:
|
||||
const QString& name() const {return _name;}
|
||||
const QString& description() const {return _desc;}
|
||||
void setName(const QString &name) {_name = name;}
|
||||
void setDescription(const QString &desc) {_desc = desc;}
|
||||
|
||||
private:
|
||||
QString _name;
|
||||
QString _desc;
|
||||
};
|
||||
|
||||
#endif // ROUTEDATA_H
|
@ -1,7 +1,6 @@
|
||||
#include <QApplication>
|
||||
#include <QPainter>
|
||||
#include "ll.h"
|
||||
#include "misc.h"
|
||||
#include "format.h"
|
||||
#include "waypoint.h"
|
||||
#include "waypointitem.h"
|
||||
#include "tooltip.h"
|
||||
@ -12,8 +11,12 @@ QString RouteItem::toolTip()
|
||||
{
|
||||
ToolTip tt;
|
||||
|
||||
if (!_name.isEmpty())
|
||||
tt.insert(qApp->translate("RouteItem", "Name"), _name);
|
||||
if (!_desc.isEmpty())
|
||||
tt.insert(qApp->translate("RouteItem", "Description"), _desc);
|
||||
tt.insert(qApp->translate("RouteItem", "Distance"),
|
||||
::distance(_distance, _units));
|
||||
Format::distance(_distance, _units));
|
||||
|
||||
return tt.toString();
|
||||
}
|
||||
@ -21,15 +24,19 @@ QString RouteItem::toolTip()
|
||||
RouteItem::RouteItem(const Route &route, QGraphicsItem *parent)
|
||||
: PathItem(parent)
|
||||
{
|
||||
QVector<Waypoint> r = route.route();
|
||||
const RouteData &r = route.route();
|
||||
Q_ASSERT(r.count() >= 2);
|
||||
QPointF p;
|
||||
|
||||
_name = r.name();
|
||||
_desc = r.description();
|
||||
|
||||
new WaypointItem(r.at(0), this);
|
||||
const QPointF &p = r.at(0).coordinates();
|
||||
_path.moveTo(ll2mercator(QPointF(p.x(), -p.y())));
|
||||
p = r.at(0).coordinates().toMercator();
|
||||
_path.moveTo(QPointF(p.x(), -p.y()));
|
||||
for (int i = 1; i < r.size(); i++) {
|
||||
const QPointF &p = r.at(i).coordinates();
|
||||
_path.lineTo(ll2mercator(QPointF(p.x(), -p.y())));
|
||||
p = r.at(i).coordinates().toMercator();
|
||||
_path.lineTo(QPointF(p.x(), -p.y()));
|
||||
new WaypointItem(r.at(i), this);
|
||||
}
|
||||
|
||||
|
@ -20,6 +20,9 @@ public:
|
||||
|
||||
private:
|
||||
QString toolTip();
|
||||
|
||||
QString _name;
|
||||
QString _desc;
|
||||
};
|
||||
|
||||
#endif // ROUTEITEM_H
|
||||
|
@ -1,22 +1,28 @@
|
||||
#include <QPainter>
|
||||
#include "config.h"
|
||||
#include "ll.h"
|
||||
#include "rd.h"
|
||||
#include "wgs84.h"
|
||||
#include "tile.h"
|
||||
#include "misc.h"
|
||||
#include "scaleitem.h"
|
||||
|
||||
|
||||
#define BORDER_WIDTH 1
|
||||
#define SCALE_WIDTH 132
|
||||
#define SCALE_HEIGHT 5
|
||||
#define SEGMENTS 3
|
||||
|
||||
#define PADDING 4
|
||||
#define SCALE_WIDTH 132
|
||||
#define SCALE_HEIGHT 5
|
||||
#define SEGMENTS 3
|
||||
#define PADDING 4
|
||||
|
||||
static qreal zoom2resolution(int zoom, qreal y)
|
||||
{
|
||||
return (WGS84_RADIUS * 2 * M_PI / Tile::size()
|
||||
* cos(2 * atan(exp(deg2rad(y))) - M_PI/2)) / pow(2.0, zoom);
|
||||
}
|
||||
|
||||
ScaleItem::ScaleItem(QGraphicsItem *parent) : QGraphicsItem(parent)
|
||||
{
|
||||
_units = Metric;
|
||||
_zoom = ZOOM_MIN;
|
||||
_zoom = 0;
|
||||
_lat = 0;
|
||||
|
||||
#ifndef Q_OS_MAC
|
||||
@ -52,19 +58,16 @@ void ScaleItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *option,
|
||||
QFontMetrics fm(font);
|
||||
QRect br;
|
||||
QPen pen = QPen(Qt::black, BORDER_WIDTH);
|
||||
bool aa;
|
||||
|
||||
|
||||
if ((aa = painter->testRenderHint(QPainter::Antialiasing)))
|
||||
painter->setRenderHint(QPainter::Antialiasing, false);
|
||||
|
||||
painter->setRenderHint(QPainter::Antialiasing, false);
|
||||
painter->setFont(font);
|
||||
painter->setPen(pen);
|
||||
|
||||
for (int i = 0; i <= SEGMENTS; i++) {
|
||||
QString label = QString::number(_length * i);
|
||||
br = fm.tightBoundingRect(label);
|
||||
painter->drawText(_width * i - br.width()/2, br.height(), label);
|
||||
painter->drawText(_width * i - br.width()/2, br.height() + 1, label);
|
||||
}
|
||||
painter->drawText(_width * SEGMENTS + PADDING, SCALE_HEIGHT + PADDING
|
||||
+ br.height() + fm.descent(), units());
|
||||
@ -79,9 +82,6 @@ void ScaleItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *option,
|
||||
painter->setPen(Qt::red);
|
||||
painter->drawRect(boundingRect());
|
||||
*/
|
||||
|
||||
if (aa)
|
||||
painter->setRenderHint(QPainter::Antialiasing, true);
|
||||
}
|
||||
|
||||
QString ScaleItem::units() const
|
||||
|
@ -12,6 +12,7 @@
|
||||
#define GRAPH_SETTINGS_GROUP "Graph"
|
||||
#define SHOW_GRAPHS_SETTING "show"
|
||||
#define GRAPH_TYPE_SETTING "type"
|
||||
#define SHOW_GRAPH_GRIDS_SETTING "grid"
|
||||
|
||||
#define MAP_SETTINGS_GROUP "Map"
|
||||
#define CURRENT_MAP_SETTING "map"
|
||||
|
@ -21,6 +21,7 @@ void SliderItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *option
|
||||
Q_UNUSED(option);
|
||||
Q_UNUSED(widget);
|
||||
|
||||
painter->setRenderHint(QPainter::Antialiasing, false);
|
||||
painter->setPen(Qt::red);
|
||||
painter->drawLine(0, 0, 0, -_area.height());
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
#include "config.h"
|
||||
#include "gpx.h"
|
||||
#include "data.h"
|
||||
#include "speedgraph.h"
|
||||
|
||||
|
||||
@ -25,22 +25,22 @@ void SpeedGraph::setInfo()
|
||||
clearInfo();
|
||||
}
|
||||
|
||||
void SpeedGraph::loadGPX(const GPX &gpx, const QList<PathItem *> &paths)
|
||||
void SpeedGraph::loadData(const Data &data, const QList<PathItem *> &paths)
|
||||
{
|
||||
for (int i = 0; i < gpx.tracks().count(); i++) {
|
||||
const Graph &graph = gpx.tracks().at(i)->speed();
|
||||
for (int i = 0; i < data.tracks().count(); i++) {
|
||||
const Graph &graph = data.tracks().at(i)->speed();
|
||||
if (graph.size() < 2) {
|
||||
skipColor();
|
||||
continue;
|
||||
}
|
||||
|
||||
_avg.append(QPointF(gpx.tracks().at(i)->distance(),
|
||||
gpx.tracks().at(i)->distance() / gpx.tracks().at(i)->time()));
|
||||
_avg.append(QPointF(data.tracks().at(i)->distance(),
|
||||
data.tracks().at(i)->distance() / data.tracks().at(i)->time()));
|
||||
|
||||
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();
|
||||
|
@ -4,8 +4,6 @@
|
||||
#include <QList>
|
||||
#include "graphtab.h"
|
||||
|
||||
class GPX;
|
||||
|
||||
class SpeedGraph : public GraphTab
|
||||
{
|
||||
Q_OBJECT
|
||||
@ -14,7 +12,7 @@ public:
|
||||
SpeedGraph(QWidget *parent = 0);
|
||||
|
||||
QString label() const {return tr("Speed");}
|
||||
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);
|
||||
|
217
src/tcxparser.cpp
Normal file
@ -0,0 +1,217 @@
|
||||
#include "tcxparser.h"
|
||||
|
||||
|
||||
void TCXParser::warning(const char *text) const
|
||||
{
|
||||
const QFile *file = static_cast<QFile *>(_reader.device());
|
||||
fprintf(stderr, "%s:%lld: %s\n", qPrintable(file->fileName()),
|
||||
_reader.lineNumber(), text);
|
||||
}
|
||||
|
||||
qreal TCXParser::number()
|
||||
{
|
||||
bool res;
|
||||
qreal ret = _reader.readElementText().toDouble(&res);
|
||||
if (!res)
|
||||
_reader.raiseError(QString("Invalid %1").arg(
|
||||
_reader.name().toString()));
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
QDateTime TCXParser::time()
|
||||
{
|
||||
QDateTime d = QDateTime::fromString(_reader.readElementText(),
|
||||
Qt::ISODate);
|
||||
if (!d.isValid())
|
||||
_reader.raiseError(QString("Invalid %1").arg(
|
||||
_reader.name().toString()));
|
||||
|
||||
return d;
|
||||
}
|
||||
|
||||
Coordinates TCXParser::position()
|
||||
{
|
||||
Coordinates pos;
|
||||
qreal val;
|
||||
bool res;
|
||||
|
||||
while (_reader.readNextStartElement()) {
|
||||
if (_reader.name() == "LatitudeDegrees") {
|
||||
val = _reader.readElementText().toDouble(&res);
|
||||
if (!res || (val < -90.0 || val > 90.0))
|
||||
_reader.raiseError("Invalid LatitudeDegrees");
|
||||
else
|
||||
pos.setLat(val);
|
||||
} else if (_reader.name() == "LongitudeDegrees") {
|
||||
val = _reader.readElementText().toDouble(&res);
|
||||
if (!res || (val < -180.0 || val > 180.0))
|
||||
_reader.raiseError("Invalid LongitudeDegrees");
|
||||
else
|
||||
pos.setLon(val);
|
||||
} else
|
||||
_reader.skipCurrentElement();
|
||||
}
|
||||
|
||||
return pos;
|
||||
}
|
||||
|
||||
void TCXParser::extensions(Trackpoint &trackpoint)
|
||||
{
|
||||
while (_reader.readNextStartElement()) {
|
||||
if (_reader.name() == "RunCadence")
|
||||
trackpoint.setCadence(number());
|
||||
else if (_reader.name() == "Watts")
|
||||
trackpoint.setPower(number());
|
||||
else
|
||||
_reader.skipCurrentElement();
|
||||
}
|
||||
}
|
||||
|
||||
void TCXParser::trackpointData(Trackpoint &trackpoint)
|
||||
{
|
||||
while (_reader.readNextStartElement()) {
|
||||
if (_reader.name() == "Position")
|
||||
trackpoint.setCoordinates(position());
|
||||
else if (_reader.name() == "AltitudeMeters")
|
||||
trackpoint.setElevation(number());
|
||||
else if (_reader.name() == "Time")
|
||||
trackpoint.setTimestamp(time());
|
||||
else if (_reader.name() == "HeartRateBpm")
|
||||
trackpoint.setHeartRate(number());
|
||||
else if (_reader.name() == "Cadence")
|
||||
trackpoint.setCadence(number());
|
||||
else if (_reader.name() == "Extensions")
|
||||
extensions(trackpoint);
|
||||
else
|
||||
_reader.skipCurrentElement();
|
||||
}
|
||||
}
|
||||
|
||||
void TCXParser::waypointData(Waypoint &waypoint)
|
||||
{
|
||||
while (_reader.readNextStartElement()) {
|
||||
if (_reader.name() == "Position")
|
||||
waypoint.setCoordinates(position());
|
||||
else if (_reader.name() == "Name")
|
||||
waypoint.setName(_reader.readElementText());
|
||||
else if (_reader.name() == "Notes")
|
||||
waypoint.setDescription(_reader.readElementText());
|
||||
else if (_reader.name() == "AltitudeMeters")
|
||||
waypoint.setElevation(number());
|
||||
else if (_reader.name() == "Time")
|
||||
waypoint.setTimestamp(time());
|
||||
else
|
||||
_reader.skipCurrentElement();
|
||||
}
|
||||
}
|
||||
|
||||
void TCXParser::trackpoints(TrackData &track)
|
||||
{
|
||||
while (_reader.readNextStartElement()) {
|
||||
if (_reader.name() == "Trackpoint") {
|
||||
Trackpoint t;
|
||||
trackpointData(t);
|
||||
if (!t.coordinates().isNull())
|
||||
track.append(t);
|
||||
else
|
||||
warning("Missing Trackpoint coordinates");
|
||||
} else
|
||||
_reader.skipCurrentElement();
|
||||
}
|
||||
}
|
||||
|
||||
void TCXParser::lap(TrackData &track)
|
||||
{
|
||||
while (_reader.readNextStartElement()) {
|
||||
if (_reader.name() == "Track")
|
||||
trackpoints(track);
|
||||
else
|
||||
_reader.skipCurrentElement();
|
||||
}
|
||||
}
|
||||
|
||||
void TCXParser::course(TrackData &track)
|
||||
{
|
||||
while (_reader.readNextStartElement()) {
|
||||
if (_reader.name() == "Track")
|
||||
trackpoints(track);
|
||||
else if (_reader.name() == "Name")
|
||||
track.setName(_reader.readElementText());
|
||||
else if (_reader.name() == "Notes")
|
||||
track.setDescription(_reader.readElementText());
|
||||
else if (_reader.name() == "CoursePoint") {
|
||||
Waypoint w;
|
||||
waypointData(w);
|
||||
if (!w.coordinates().isNull())
|
||||
_waypoints.append(w);
|
||||
else
|
||||
warning("Missing Trackpoint coordinates");
|
||||
} else
|
||||
_reader.skipCurrentElement();
|
||||
}
|
||||
}
|
||||
|
||||
void TCXParser::activity(TrackData &track)
|
||||
{
|
||||
while (_reader.readNextStartElement()) {
|
||||
if (_reader.name() == "Lap")
|
||||
lap(track);
|
||||
else
|
||||
_reader.skipCurrentElement();
|
||||
}
|
||||
}
|
||||
|
||||
void TCXParser::courses()
|
||||
{
|
||||
while (_reader.readNextStartElement()) {
|
||||
if (_reader.name() == "Course") {
|
||||
_tracks.append(TrackData());
|
||||
course(_tracks.back());
|
||||
} else
|
||||
_reader.skipCurrentElement();
|
||||
}
|
||||
}
|
||||
|
||||
void TCXParser::activities()
|
||||
{
|
||||
while (_reader.readNextStartElement()) {
|
||||
if (_reader.name() == "Activity") {
|
||||
_tracks.append(TrackData());
|
||||
activity(_tracks.back());
|
||||
} else
|
||||
_reader.skipCurrentElement();
|
||||
}
|
||||
}
|
||||
|
||||
void TCXParser::tcx()
|
||||
{
|
||||
while (_reader.readNextStartElement()) {
|
||||
if (_reader.name() == "Courses")
|
||||
courses();
|
||||
else if (_reader.name() == "Activities")
|
||||
activities();
|
||||
else
|
||||
_reader.skipCurrentElement();
|
||||
}
|
||||
}
|
||||
|
||||
bool TCXParser::parse()
|
||||
{
|
||||
if (_reader.readNextStartElement()) {
|
||||
if (_reader.name() == "TrainingCenterDatabase")
|
||||
tcx();
|
||||
else
|
||||
_reader.raiseError("Not a TCX file");
|
||||
}
|
||||
|
||||
return !_reader.error();
|
||||
}
|
||||
|
||||
bool TCXParser::loadFile(QFile *file)
|
||||
{
|
||||
_reader.clear();
|
||||
_reader.setDevice(file);
|
||||
|
||||
return parse();
|
||||
}
|
40
src/tcxparser.h
Normal file
@ -0,0 +1,40 @@
|
||||
#ifndef TCXPARSER_H
|
||||
#define TCXPARSER_H
|
||||
|
||||
#include <QXmlStreamReader>
|
||||
#include "parser.h"
|
||||
|
||||
|
||||
class TCXParser : public Parser
|
||||
{
|
||||
public:
|
||||
TCXParser(QList<TrackData> &tracks, QList<RouteData> &routes,
|
||||
QList<Waypoint> &waypoints) : Parser(tracks, routes, waypoints) {}
|
||||
~TCXParser() {}
|
||||
|
||||
bool loadFile(QFile *file);
|
||||
QString errorString() const {return _reader.errorString();}
|
||||
int errorLine() const {return _reader.lineNumber();}
|
||||
|
||||
private:
|
||||
bool parse();
|
||||
void tcx();
|
||||
void courses();
|
||||
void activities();
|
||||
void course(TrackData &track);
|
||||
void activity(TrackData &track);
|
||||
void lap(TrackData &track);
|
||||
void trackpoints(TrackData &track);
|
||||
void trackpointData(Trackpoint &trackpoint);
|
||||
void waypointData(Waypoint &waypoint);
|
||||
void extensions(Trackpoint &trackpoint);
|
||||
Coordinates position();
|
||||
qreal number();
|
||||
QDateTime time();
|
||||
|
||||
void warning(const char *text) const;
|
||||
|
||||
QXmlStreamReader _reader;
|
||||
};
|
||||
|
||||
#endif // TCXPARSER_H
|
@ -1,4 +1,4 @@
|
||||
#include "gpx.h"
|
||||
#include "data.h"
|
||||
#include "temperaturegraph.h"
|
||||
|
||||
|
||||
@ -26,10 +26,10 @@ void TemperatureGraph::setInfo()
|
||||
clearInfo();
|
||||
}
|
||||
|
||||
void TemperatureGraph::loadGPX(const GPX &gpx, const QList<PathItem *> &paths)
|
||||
void TemperatureGraph::loadData(const Data &data, const QList<PathItem *> &paths)
|
||||
{
|
||||
for (int i = 0; i < gpx.tracks().count(); i++) {
|
||||
const Graph &graph = gpx.tracks().at(i)->temperature();
|
||||
for (int i = 0; i < data.tracks().count(); i++) {
|
||||
const Graph &graph = data.tracks().at(i)->temperature();
|
||||
qreal sum = 0, w = 0;
|
||||
|
||||
if (graph.size() < 2) {
|
||||
@ -42,12 +42,12 @@ void TemperatureGraph::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();
|
||||
|
@ -3,8 +3,6 @@
|
||||
|
||||
#include "graphtab.h"
|
||||
|
||||
class GPX;
|
||||
|
||||
class TemperatureGraph : public GraphTab
|
||||
{
|
||||
Q_OBJECT
|
||||
@ -13,7 +11,7 @@ public:
|
||||
TemperatureGraph(QWidget *parent = 0);
|
||||
|
||||
QString label() const {return tr("Temperature");}
|
||||
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);
|
||||
|
25
src/tile.h
Normal file
@ -0,0 +1,25 @@
|
||||
#ifndef TILE_H
|
||||
#define TILE_H
|
||||
|
||||
#include <QPixmap>
|
||||
#include <QPoint>
|
||||
|
||||
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;}
|
||||
|
||||
static int size() {return 256;}
|
||||
|
||||
private:
|
||||
int _zoom;
|
||||
QPoint _xy;
|
||||
QPixmap _pixmap;
|
||||
};
|
||||
|
||||
#endif // TILE_H
|
163
src/track.cpp
@ -1,68 +1,55 @@
|
||||
#include "ll.h"
|
||||
#include "track.h"
|
||||
|
||||
|
||||
#define WINDOW_OE 31
|
||||
|
||||
#define WINDOW_EF 3
|
||||
#define WINDOW_SE 11
|
||||
#define WINDOW_SF 7
|
||||
#define WINDOW_HE 11
|
||||
#define WINDOW_HF 3
|
||||
#define WINDOW_CF 3
|
||||
#define WINDOW_PF 3
|
||||
|
||||
|
||||
static bool lt(const GraphPoint &v1, const GraphPoint &v2)
|
||||
static qreal median(QVector<qreal> v)
|
||||
{
|
||||
return v1.y() < v2.y();
|
||||
qSort(v.begin(), v.end());
|
||||
return v.at(v.size() / 2);
|
||||
}
|
||||
|
||||
static qreal median(QVector<GraphPoint> v)
|
||||
{
|
||||
qSort(v.begin(), v.end(), lt);
|
||||
return v.at(v.size() / 2).y();
|
||||
}
|
||||
|
||||
static qreal MAD(QVector<GraphPoint> v, qreal m)
|
||||
static qreal MAD(QVector<qreal> v, qreal m)
|
||||
{
|
||||
for (int i = 0; i < v.size(); i++)
|
||||
v[i].setY(qAbs(v.at(i).y() - m));
|
||||
qSort(v.begin(), v.end(), lt);
|
||||
return v.at(v.size() / 2).y();
|
||||
v[i] = qAbs(v.at(i) - m);
|
||||
qSort(v.begin(), v.end());
|
||||
return v.at(v.size() / 2);
|
||||
}
|
||||
|
||||
static QVector<GraphPoint> eliminate(const QVector<GraphPoint> &v, int window)
|
||||
static QSet<int> eliminate(const QVector<qreal> &v, int window)
|
||||
{
|
||||
QList<int> rm;
|
||||
QVector<GraphPoint> ret;
|
||||
QSet<int> rm;
|
||||
qreal m, M;
|
||||
|
||||
|
||||
if (v.size() < window)
|
||||
return QVector<GraphPoint>(v);
|
||||
return rm;
|
||||
|
||||
for (int i = window/2; i < v.size() - window/2; i++) {
|
||||
m = median(v.mid(i - window/2, window));
|
||||
M = MAD(v.mid(i - window/2, window), m);
|
||||
if (qAbs((0.6745 * (v.at(i).y() - m)) / M) > 3.5)
|
||||
rm.append(i);
|
||||
if (qAbs((0.6745 * (v.at(i) - m)) / M) > 3.5)
|
||||
rm.insert(i);
|
||||
}
|
||||
|
||||
QList<int>::const_iterator it = rm.begin();
|
||||
for (int i = 0; i < v.size(); i++) {
|
||||
if (it == rm.end() || *it != i)
|
||||
ret.append(v.at(i));
|
||||
else
|
||||
it++;
|
||||
}
|
||||
|
||||
return ret;
|
||||
return rm;
|
||||
}
|
||||
|
||||
static QVector<GraphPoint> filter(const QVector<GraphPoint> &v, int window)
|
||||
static Graph filter(const Graph &v, int window)
|
||||
{
|
||||
qreal acc = 0;
|
||||
QVector<GraphPoint> ret;
|
||||
Graph ret;
|
||||
|
||||
if (v.size() < window)
|
||||
return QVector<GraphPoint>(v);
|
||||
return ret;
|
||||
|
||||
for (int i = 0; i < window; i++)
|
||||
acc += v.at(i).y();
|
||||
@ -80,96 +67,139 @@ static QVector<GraphPoint> filter(const QVector<GraphPoint> &v, int window)
|
||||
return ret;
|
||||
}
|
||||
|
||||
Track::Track(const QVector<Trackpoint> &data) : _data(data)
|
||||
Track::Track(const TrackData &data) : _data(data)
|
||||
{
|
||||
qreal dist = 0;
|
||||
qreal dt, ds, total;
|
||||
|
||||
|
||||
_distance.append(0);
|
||||
_time.append(0);
|
||||
_distance.append(0);
|
||||
_speed.append(0);
|
||||
|
||||
for (int i = 1; i < data.count(); i++) {
|
||||
dist += llDistance(data.at(i).coordinates(), data.at(i-1).coordinates());
|
||||
_distance.append(dist);
|
||||
ds = data.at(i).coordinates().distanceTo(data.at(i-1).coordinates());
|
||||
_distance.append(ds);
|
||||
|
||||
if (data.first().hasTimestamp() && data.at(i).hasTimestamp())
|
||||
_time.append(_data.first().timestamp().msecsTo(
|
||||
_data.at(i).timestamp()) / 1000.0);
|
||||
else
|
||||
_time.append(NAN);
|
||||
|
||||
if (std::isnan(_time.at(i)) || std::isnan(_time.at(i-1)))
|
||||
_speed.append(NAN);
|
||||
else {
|
||||
dt = _time.at(i) - _time.at(i-1);
|
||||
if (!dt) {
|
||||
_speed.append(_speed.at(i-1));
|
||||
continue;
|
||||
}
|
||||
_speed.append(ds / dt);
|
||||
}
|
||||
}
|
||||
|
||||
_outliers = eliminate(_speed, WINDOW_OE);
|
||||
|
||||
total = 0;
|
||||
for (int i = 0; i < _data.size(); i++) {
|
||||
if (_outliers.contains(i))
|
||||
continue;
|
||||
total += _distance.at(i);
|
||||
_distance[i] = total;
|
||||
}
|
||||
}
|
||||
|
||||
Graph Track::elevation() const
|
||||
{
|
||||
QVector<GraphPoint> raw;
|
||||
Graph raw;
|
||||
|
||||
if (!_data.size())
|
||||
return raw;
|
||||
|
||||
for (int i = 0; i < _data.size(); i++)
|
||||
if (_data.at(i).hasElevation())
|
||||
if (_data.at(i).hasElevation() && !_outliers.contains(i))
|
||||
raw.append(GraphPoint(_distance.at(i), _time.at(i),
|
||||
_data.at(i).elevation() - _data.at(i).geoidHeight()));
|
||||
_data.at(i).elevation()));
|
||||
|
||||
return filter(raw, WINDOW_EF);
|
||||
}
|
||||
|
||||
Graph Track::speed() const
|
||||
{
|
||||
QVector<GraphPoint> raw;
|
||||
qreal v, ds, dt;
|
||||
Graph raw;
|
||||
qreal v;
|
||||
|
||||
if (!_data.size())
|
||||
return raw;
|
||||
|
||||
raw.append(GraphPoint(_distance.at(0), _time.at(0), 0));
|
||||
for (int i = 1; i < _data.size(); i++) {
|
||||
if (_data.at(i).hasSpeed())
|
||||
for (int i = 0; i < _data.size(); i++) {
|
||||
if (_data.at(i).hasSpeed() && !_outliers.contains(i))
|
||||
v = _data.at(i).speed();
|
||||
else if (_data.at(i).hasTimestamp() && _data.at(i-1).hasTimestamp()) {
|
||||
dt = _time.at(i) - _time.at(i-1);
|
||||
if (!dt)
|
||||
continue;
|
||||
ds = _distance.at(i) - _distance.at(i-1);
|
||||
v = ds / dt;
|
||||
} else
|
||||
else if (!std::isnan(_speed.at(i)) && !_outliers.contains(i))
|
||||
v = _speed.at(i);
|
||||
else
|
||||
continue;
|
||||
|
||||
raw.append(GraphPoint(_distance.at(i), _time.at(i), v));
|
||||
}
|
||||
|
||||
return filter(eliminate(raw, WINDOW_SE), WINDOW_SF);
|
||||
return filter(raw, WINDOW_SF);
|
||||
}
|
||||
|
||||
Graph Track::heartRate() const
|
||||
{
|
||||
QVector<GraphPoint> raw;
|
||||
Graph raw;
|
||||
|
||||
if (!_data.size())
|
||||
return raw;
|
||||
|
||||
for (int i = 0; i < _data.count(); i++)
|
||||
if (_data.at(i).hasHeartRate())
|
||||
if (_data.at(i).hasHeartRate() && !_outliers.contains(i))
|
||||
raw.append(GraphPoint(_distance.at(i), _time.at(i),
|
||||
_data.at(i).heartRate()));
|
||||
|
||||
return filter(eliminate(raw, WINDOW_HE), WINDOW_HF);
|
||||
return filter(raw, WINDOW_HF);
|
||||
}
|
||||
|
||||
Graph Track::temperature() const
|
||||
{
|
||||
QVector<GraphPoint> raw;
|
||||
Graph raw;
|
||||
|
||||
for (int i = 0; i < _data.size(); i++)
|
||||
if (_data.at(i).hasTemperature())
|
||||
if (_data.at(i).hasTemperature() && !_outliers.contains(i))
|
||||
raw.append(GraphPoint(_distance.at(i), _time.at(i),
|
||||
_data.at(i).temperature()));
|
||||
|
||||
return Graph(raw);
|
||||
return raw;
|
||||
}
|
||||
|
||||
Graph Track::cadence() const
|
||||
{
|
||||
Graph raw;
|
||||
|
||||
for (int i = 0; i < _data.size(); i++)
|
||||
if (_data.at(i).hasCadence() && !_outliers.contains(i))
|
||||
raw.append(GraphPoint(_distance.at(i), _time.at(i),
|
||||
_data.at(i).cadence()));
|
||||
|
||||
return filter(raw, WINDOW_CF);
|
||||
}
|
||||
|
||||
Graph Track::power() const
|
||||
{
|
||||
Graph raw;
|
||||
|
||||
for (int i = 0; i < _data.size(); i++)
|
||||
if (_data.at(i).hasPower() && !_outliers.contains(i))
|
||||
raw.append(GraphPoint(_distance.at(i), _time.at(i),
|
||||
_data.at(i).power()));
|
||||
|
||||
return filter(raw, WINDOW_PF);
|
||||
}
|
||||
|
||||
qreal Track::distance() const
|
||||
{
|
||||
return (_distance.isEmpty()) ? 0 : _distance.last();
|
||||
return _distance.isEmpty() ? 0 : _distance.last();
|
||||
}
|
||||
|
||||
qreal Track::time() const
|
||||
@ -182,3 +212,14 @@ QDateTime Track::date() const
|
||||
{
|
||||
return (_data.size()) ? _data.first().timestamp() : QDateTime();
|
||||
}
|
||||
|
||||
Path Track::track() const
|
||||
{
|
||||
Path ret;
|
||||
|
||||
for (int i = 0; i < _data.size(); i++)
|
||||
if (!_outliers.contains(i))
|
||||
ret.append(_data.at(i).coordinates());
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
20
src/track.h
@ -2,31 +2,43 @@
|
||||
#define TRACK_H
|
||||
|
||||
#include <QVector>
|
||||
#include <QSet>
|
||||
#include <QDateTime>
|
||||
#include "trackpoint.h"
|
||||
#include "trackdata.h"
|
||||
#include "graph.h"
|
||||
#include "path.h"
|
||||
|
||||
|
||||
class Track
|
||||
{
|
||||
public:
|
||||
Track(const QVector<Trackpoint> &data);
|
||||
Track(const TrackData &data);
|
||||
|
||||
const QVector<Trackpoint> &track() const {return _data;}
|
||||
Path track() const;
|
||||
Graph elevation() const;
|
||||
Graph speed() const;
|
||||
Graph heartRate() const;
|
||||
Graph temperature() const;
|
||||
Graph cadence() const;
|
||||
Graph power() const;
|
||||
|
||||
qreal distance() const;
|
||||
qreal time() const;
|
||||
QDateTime date() const;
|
||||
|
||||
const QString &name() const {return _data.name();}
|
||||
const QString &description() const {return _data.description();}
|
||||
|
||||
bool isNull() const {return (_data.size() < 2);}
|
||||
|
||||
private:
|
||||
const QVector<Trackpoint> &_data;
|
||||
const TrackData &_data;
|
||||
|
||||
QVector<qreal> _distance;
|
||||
QVector<qreal> _time;
|
||||
QVector<qreal> _speed;
|
||||
|
||||
QSet<int> _outliers;
|
||||
};
|
||||
|
||||
#endif // TRACK_H
|
||||
|
21
src/trackdata.h
Normal file
@ -0,0 +1,21 @@
|
||||
#ifndef TRACKDATA_H
|
||||
#define TRACKDATA_H
|
||||
|
||||
#include <QVector>
|
||||
#include <QString>
|
||||
#include "trackpoint.h"
|
||||
|
||||
class TrackData : public QVector<Trackpoint>
|
||||
{
|
||||
public:
|
||||
const QString& name() const {return _name;}
|
||||
const QString& description() const {return _desc;}
|
||||
void setName(const QString &name) {_name = name;}
|
||||
void setDescription(const QString &desc) {_desc = desc;}
|
||||
|
||||
private:
|
||||
QString _name;
|
||||
QString _desc;
|
||||
};
|
||||
|
||||
#endif // TRACKDATA_H
|
@ -1,8 +1,7 @@
|
||||
#include <QApplication>
|
||||
#include <QCursor>
|
||||
#include <QPainter>
|
||||
#include "ll.h"
|
||||
#include "misc.h"
|
||||
#include "format.h"
|
||||
#include "tooltip.h"
|
||||
#include "trackitem.h"
|
||||
|
||||
@ -11,10 +10,15 @@ QString TrackItem::toolTip()
|
||||
{
|
||||
ToolTip tt;
|
||||
|
||||
if (!_name.isEmpty())
|
||||
tt.insert(qApp->translate("TrackItem", "Name"), _name);
|
||||
if (!_desc.isEmpty())
|
||||
tt.insert(qApp->translate("TrackItem", "Description"), _desc);
|
||||
tt.insert(qApp->translate("TrackItem", "Distance"),
|
||||
::distance(_distance, _units));
|
||||
Format::distance(_distance, _units));
|
||||
if (_time > 0)
|
||||
tt.insert(qApp->translate("TrackItem", "Time"), ::timeSpan(_time));
|
||||
tt.insert(qApp->translate("TrackItem", "Time"),
|
||||
Format::timeSpan(_time));
|
||||
if (!_date.isNull())
|
||||
tt.insert(qApp->translate("TrackItem", "Date"),
|
||||
_date.toString(Qt::SystemLocaleShortDate));
|
||||
@ -25,18 +29,21 @@ QString TrackItem::toolTip()
|
||||
TrackItem::TrackItem(const Track &track, QGraphicsItem *parent)
|
||||
: PathItem(parent)
|
||||
{
|
||||
const QVector<Trackpoint> &t = track.track();
|
||||
QPointF p;
|
||||
QVector<Coordinates> t = track.track();
|
||||
Q_ASSERT(t.count() >= 2);
|
||||
|
||||
const QPointF &p = t.at(0).coordinates();
|
||||
_path.moveTo(ll2mercator(QPointF(p.x(), -p.y())));
|
||||
p = t.first().toMercator();
|
||||
_path.moveTo(QPointF(p.x(), -p.y()));
|
||||
for (int i = 1; i < t.size(); i++) {
|
||||
const QPointF &p = t.at(i).coordinates();
|
||||
_path.lineTo(ll2mercator(QPointF(p.x(), -p.y())));
|
||||
p = t.at(i).toMercator();
|
||||
_path.lineTo(QPointF(p.x(), -p.y()));
|
||||
}
|
||||
|
||||
updateShape();
|
||||
|
||||
_name = track.name();
|
||||
_desc = track.description();
|
||||
_date = track.date();
|
||||
_distance = track.distance();
|
||||
_time = track.time();
|
||||
|
@ -19,6 +19,8 @@ public:
|
||||
private:
|
||||
QString toolTip();
|
||||
|
||||
QString _name;
|
||||
QString _desc;
|
||||
QDateTime _date;
|
||||
qreal _time;
|
||||
};
|
||||
|
@ -4,8 +4,8 @@ QDebug operator<<(QDebug dbg, const Trackpoint &trackpoint)
|
||||
{
|
||||
dbg.nospace() << "Trackpoint(" << trackpoint.coordinates() << ", "
|
||||
<< trackpoint.timestamp() << ", " << trackpoint.elevation() << ", "
|
||||
<< trackpoint.geoidHeight() << ", " << trackpoint.speed() << ", "
|
||||
<< trackpoint.heartRate() << ", " << trackpoint.temperature() << ")";
|
||||
<< trackpoint.speed() << ", " << trackpoint.heartRate() << ", "
|
||||
<< trackpoint.temperature() << ")";
|
||||
|
||||
return dbg.maybeSpace();
|
||||
}
|
||||
|
@ -1,53 +1,62 @@
|
||||
#ifndef TRACKPOINT_H
|
||||
#define TRACKPOINT_H
|
||||
|
||||
#include <QPointF>
|
||||
#include <QDateTime>
|
||||
#include <QDebug>
|
||||
#include <cmath>
|
||||
#include "coordinates.h"
|
||||
|
||||
class Trackpoint
|
||||
{
|
||||
public:
|
||||
Trackpoint() {
|
||||
_elevation = NAN; _geoidHeight = 0; _speed = NAN; _heartRate = NAN;
|
||||
_temperature = NAN;
|
||||
}
|
||||
Trackpoint(const QPointF &coordinates) {_coordinates = coordinates;}
|
||||
Trackpoint()
|
||||
{_elevation = NAN; _speed = NAN; _heartRate = NAN; _temperature = NAN;
|
||||
_cadence = NAN; _power = NAN;}
|
||||
Trackpoint(const Coordinates &coordinates) : _coordinates(coordinates)
|
||||
{_elevation = NAN; _speed = NAN; _heartRate = NAN; _temperature = NAN;
|
||||
_cadence = NAN; _power = NAN;}
|
||||
|
||||
const QPointF &coordinates() const {return _coordinates;}
|
||||
const Coordinates &coordinates() const {return _coordinates;}
|
||||
Coordinates &rcoordinates() {return _coordinates;}
|
||||
const QDateTime ×tamp() const {return _timestamp;}
|
||||
qreal elevation() const {return _elevation;}
|
||||
qreal geoidHeight() const {return _geoidHeight;}
|
||||
qreal speed() const {return _speed;}
|
||||
qreal heartRate() const {return _heartRate;}
|
||||
qreal temperature() const {return _temperature;}
|
||||
qreal cadence() const {return _cadence;}
|
||||
qreal power() const {return _power;}
|
||||
|
||||
void setCoordinates(const QPointF &coordinates)
|
||||
void setCoordinates(const Coordinates &coordinates)
|
||||
{_coordinates = coordinates;}
|
||||
void setTimestamp(const QDateTime ×tamp) {_timestamp = timestamp;}
|
||||
void setElevation(qreal elevation) {_elevation = elevation;}
|
||||
void setGeoidHeight(qreal geoidHeight) {_geoidHeight = geoidHeight;}
|
||||
void setSpeed(qreal speed) {_speed = speed;}
|
||||
void setHeartRate(qreal heartRate) {_heartRate = heartRate;}
|
||||
void setTemperature(qreal temperature) {_temperature = temperature;}
|
||||
void setCadence(qreal cadence) {_cadence = cadence;}
|
||||
void setPower(qreal power) {_power = power;}
|
||||
|
||||
bool hasTimestamp() const {return !_timestamp.isNull();}
|
||||
bool hasElevation() const {return !std::isnan(_elevation);}
|
||||
bool hasSpeed() const {return !std::isnan(_speed);}
|
||||
bool hasHeartRate() const {return !std::isnan(_heartRate);}
|
||||
bool hasTemperature() const {return !std::isnan(_temperature);}
|
||||
bool hasCadence() const {return !std::isnan(_cadence);}
|
||||
bool hasPower() const {return !std::isnan(_power);}
|
||||
|
||||
private:
|
||||
QPointF _coordinates;
|
||||
Coordinates _coordinates;
|
||||
QDateTime _timestamp;
|
||||
qreal _elevation;
|
||||
qreal _geoidHeight;
|
||||
qreal _speed;
|
||||
qreal _heartRate;
|
||||
qreal _temperature;
|
||||
qreal _cadence;
|
||||
qreal _power;
|
||||
};
|
||||
|
||||
QDebug operator<<(QDebug dbg, const Trackpoint &trackpoint);
|
||||
|
||||
Q_DECLARE_TYPEINFO(Trackpoint, Q_MOVABLE_TYPE);
|
||||
|
||||
#endif // TRACKPOINT_H
|
||||
|
@ -1,35 +1,33 @@
|
||||
#ifndef WAYPOINT_H
|
||||
#define WAYPOINT_H
|
||||
|
||||
#include <QPointF>
|
||||
#include <QString>
|
||||
#include <QDateTime>
|
||||
#include <QHash>
|
||||
#include <QDebug>
|
||||
#include <cmath>
|
||||
#include "coordinates.h"
|
||||
|
||||
class Waypoint
|
||||
{
|
||||
public:
|
||||
Waypoint() {_elevation = NAN; _geoidHeight = 0;}
|
||||
Waypoint(const QPointF &coordinates)
|
||||
: _coordinates(coordinates) {_elevation = NAN; _geoidHeight = 0;}
|
||||
Waypoint() {_elevation = NAN;}
|
||||
Waypoint(const Coordinates &coordinates) : _coordinates(coordinates)
|
||||
{_elevation = NAN;}
|
||||
|
||||
const QPointF &coordinates() const {return _coordinates;}
|
||||
const Coordinates &coordinates() const {return _coordinates;}
|
||||
const QString &name() const {return _name;}
|
||||
const QString &description() const {return _description;}
|
||||
const QDateTime ×tamp() const {return _timestamp;}
|
||||
qreal elevation() const {return _elevation;}
|
||||
qreal geoidHeight() const {return _geoidHeight;}
|
||||
|
||||
void setCoordinates(const QPointF &coordinates)
|
||||
void setCoordinates(const Coordinates &coordinates)
|
||||
{_coordinates = coordinates;}
|
||||
void setName(const QString &name) {_name = name;}
|
||||
void setDescription(const QString &description)
|
||||
{_description = description;}
|
||||
void setTimestamp(const QDateTime ×tamp) {_timestamp = timestamp;}
|
||||
void setElevation(qreal elevation) {_elevation = elevation;}
|
||||
void setGeoidHeight(qreal geoidHeight) {_geoidHeight = geoidHeight;}
|
||||
|
||||
bool hasElevation() const {return !std::isnan(_elevation);}
|
||||
|
||||
@ -38,12 +36,11 @@ public:
|
||||
&& this->_coordinates == other._coordinates;}
|
||||
|
||||
private:
|
||||
QPointF _coordinates;
|
||||
Coordinates _coordinates;
|
||||
QString _name;
|
||||
QString _description;
|
||||
QDateTime _timestamp;
|
||||
qreal _elevation;
|
||||
qreal _geoidHeight;
|
||||
};
|
||||
|
||||
inline uint qHash(const Waypoint &key)
|
||||
@ -53,4 +50,6 @@ inline uint qHash(const Waypoint &key)
|
||||
|
||||
QDebug operator<<(QDebug dbg, const Waypoint &Waypoint);
|
||||
|
||||
Q_DECLARE_TYPEINFO(Waypoint, Q_MOVABLE_TYPE);
|
||||
|
||||
#endif // WAYPOINT_H
|
||||
|
@ -1,8 +1,7 @@
|
||||
#include <QApplication>
|
||||
#include <QPainter>
|
||||
#include "config.h"
|
||||
#include "ll.h"
|
||||
#include "misc.h"
|
||||
#include "format.h"
|
||||
#include "tooltip.h"
|
||||
#include "waypointitem.h"
|
||||
|
||||
@ -17,10 +16,10 @@ QString WaypointItem::toolTip()
|
||||
if (!_waypoint.name().isEmpty() && !_showLabel)
|
||||
tt.insert(qApp->translate("WaypointItem", "Name"), _waypoint.name());
|
||||
tt.insert(qApp->translate("WaypointItem", "Coordinates"),
|
||||
::coordinates(_waypoint.coordinates()));
|
||||
Format::coordinates(_waypoint.coordinates()));
|
||||
if (!std::isnan(_waypoint.elevation()))
|
||||
tt.insert(qApp->translate("WaypointItem", "Elevation"),
|
||||
::elevation(_waypoint.elevation() - _waypoint.geoidHeight(), _units));
|
||||
Format::elevation(_waypoint.elevation(), _units));
|
||||
if (!_waypoint.timestamp().isNull())
|
||||
tt.insert(qApp->translate("WaypointItem", "Date"),
|
||||
_waypoint.timestamp().toString(Qt::SystemLocaleShortDate));
|
||||
@ -39,8 +38,8 @@ WaypointItem::WaypointItem(const Waypoint &waypoint, QGraphicsItem *parent)
|
||||
_hover = false;
|
||||
|
||||
_waypoint = waypoint;
|
||||
_coordinates = ll2mercator(QPointF(waypoint.coordinates().x(),
|
||||
-waypoint.coordinates().y()));
|
||||
QPointF p = waypoint.coordinates().toMercator();
|
||||
_coordinates = QPointF(p.x(), -p.y());
|
||||
|
||||
updateShape();
|
||||
|
||||
|
6
src/wgs84.h
Normal file
@ -0,0 +1,6 @@
|
||||
#ifndef WGS84_H
|
||||
#define WGS84_H
|
||||
|
||||
#define WGS84_RADIUS 6378137.0
|
||||
|
||||
#endif // WGS84_H
|