1
0
mirror of https://github.com/tumic0/GPXSee.git synced 2025-07-02 05:49:15 +02:00

Compare commits

...

165 Commits
4.7 ... 4.17

Author SHA1 Message Date
53a4b45b7b Fixed broken scene centering in some resize cases 2017-12-07 21:05:00 +01:00
53229681d2 Translations update 2017-12-03 16:52:12 +01:00
b2df7d207f Version++ 2017-12-03 14:21:52 +01:00
1ff2162811 Added the "always show map" option 2017-12-03 14:18:41 +01:00
0f10c7596b Removed some more unneeded code 2017-12-03 13:37:18 +01:00
4cc3bc28e2 Do not clear the image cache between files 2017-12-03 13:07:52 +01:00
3ce1918645 Speed up the osx build 2017-12-03 12:11:54 +01:00
d70f0cf9e0 Added missing QT path on OS X 2017-12-03 12:05:21 +01:00
34c5ba4669 Fixed typos 2017-12-03 11:52:41 +01:00
afbb8c3284 Added Travis CI OS X build 2017-12-03 11:20:30 +01:00
5bdc263cda Moved all the map bounds checking where it belongs 2017-12-03 10:41:07 +01:00
179f2f1451 Removed obsolete code 2017-12-03 10:24:24 +01:00
92e772a02b Fixed some corner case map drawing issues 2017-12-03 10:17:29 +01:00
cbdfe4c105 Added slider/marker color setting 2017-12-03 00:36:52 +01:00
a20a268975 includes cleanup 2017-12-02 20:33:29 +01:00
48e972f920 Include paths unification 2017-12-02 20:28:53 +01:00
c38f50538e Do not use the alpha channel for graphs 2017-12-02 18:24:44 +01:00
53147b5e6e Code cleanup 2017-12-01 22:24:04 +01:00
6c6e384862 Some more code cleanup 2017-12-01 21:27:12 +01:00
90b780a444 Code cleanup 2017-12-01 20:52:34 +01:00
56d1ac7ff2 Fixed broken zoom handling 2017-12-01 19:54:04 +01:00
00acd48009 Fixed some more track display corner cases + refactoring 2017-12-01 00:22:16 +01:00
e30078a63e Code cleanup 2017-11-27 23:50:55 +01:00
51c0c31838 Fixed broken map scale computation 2017-11-27 08:48:37 +01:00
bc218c9f65 Moved the datums initialization where it belongs 2017-11-26 22:52:50 +01:00
56e4c80999 Project structure refactoring 2017-11-26 18:54:03 +01:00
443b916301 Optimization 2017-11-19 23:01:17 +01:00
8675a0e945 Made the Lambert azimuthal equal-area projection naming consistent with other projections namings 2017-11-14 23:30:25 +01:00
0894fb0ddf Added support for Lambert Azimuthal Equal Area projections 2017-11-14 22:17:59 +01:00
73e15f8f11 Includes cleanup 2017-11-14 22:17:09 +01:00
0fe7843e52 Added debug output for tiles 2017-11-14 22:15:46 +01:00
e76439bb6e Added support for TCX multi-sport activities 2017-10-14 22:57:03 +02:00
b54aeff369 Fixed copy&paste error, code cleanup 2017-10-13 18:15:37 +02:00
72968efeef Added support for Temperature, Cadence and Heartrate in KML files 2017-10-13 08:15:54 +02:00
ec3f529b0f Version++ 2017-10-11 22:44:33 +02:00
57a171ee8c Fixed broaken loading of KML files with multitracks and folder element outside document element 2017-10-11 22:41:01 +02:00
d3193abd0b Improved map view map init 2017-10-11 22:39:42 +02:00
6809853a8a Added OS X signing certificate 2017-10-05 22:07:31 +02:00
3155e8436b Optimization & code cleanup 2017-10-04 23:15:39 +02:00
69f9d05ccb Update gpxsee_sv.ts (#36) 2017-10-02 22:37:15 +02:00
e24a3cd99a Silenced compiler warning 2017-09-30 09:52:36 +02:00
a94fa9f0ea Translations update 2017-09-29 11:59:55 +02:00
c4f2a44410 Version++ 2017-09-29 11:44:44 +02:00
da4a51e7fa Improved graph slider info 2017-09-29 11:43:09 +02:00
bb47a34823 Translations update 2017-09-26 07:51:55 +02:00
11196c0e35 Improved graph type/time type switching 2017-09-26 07:46:46 +02:00
00ef815738 Unified average speed handling 2017-09-25 19:56:04 +02:00
64f685cf60 Removed accidentally commited files 2017-09-24 22:11:50 +02:00
7ab13ec8e5 Added missing Q_OBJECT macro 2017-09-24 20:13:13 +02:00
d3fbbecb2d Graph items are now selecteble like path items (+ tool tips) 2017-09-24 19:54:13 +02:00
7bc83603ca Fixed the 1px content offset issue on zoom/map change 2017-09-17 14:10:37 +02:00
2cd35b139e Removed obsolete strings, added missing punctuation 2017-09-15 18:59:22 +02:00
a74afa54fd Update gpxsee_sv.ts (#32) 2017-09-15 18:55:49 +02:00
753c4e8db0 Do not enable alpha channel for background colors 2017-09-15 08:30:00 +02:00
d0b3f48caf Version++ 2017-09-15 00:41:48 +02:00
e47cd1be7e Translations update 2017-09-15 00:39:59 +02:00
d1ba35f012 Updated maximal zoom for OpenTopo map 2017-09-15 00:35:11 +02:00
b9489afbfe Settings improvements and code cleanup 2017-09-15 00:07:09 +02:00
a7506cfd82 Merge branch 'master' of https://github.com/tumic0/GPXSee 2017-09-14 20:22:11 +02:00
c060abe6a7 Silenced valgrind warnings 2017-09-14 20:19:19 +02:00
b457fc430c Fixed broken parsing of TCX files with heart rate data 2017-09-14 20:18:34 +02:00
89947851fd Fixed invalid memory access 2017-09-14 20:18:02 +02:00
7d40dfddb2 Fixed broken units setting for cadence, heart rate and power graphs 2017-09-14 20:16:42 +02:00
151ae03b53 Fixed broken options layout on OS X 2017-09-10 12:53:51 +02:00
9fd8b84c3b Added waypoints/POI size/color settings 2017-09-10 12:42:49 +02:00
47683e5447 Added map background color setting.
Redesigned appearance settings tab.
2017-09-10 00:09:39 +02:00
84bcf07bd4 Translations update 2017-09-09 22:04:47 +02:00
cc694971be Added support for limiting the maximal zoom level of online map sources 2017-09-09 12:33:43 +02:00
ba856d7eb6 Adjusted the scale bar (text) size to the remaining content in plot mode 2017-09-09 10:51:19 +02:00
b14eeb58ab Fixed scale size in hi-res prints 2017-08-31 16:28:37 +02:00
8e932b966c Fixed msvc warning 2017-08-31 15:32:44 +02:00
35818ce16e Removed obsolete size guard 2017-08-31 08:10:09 +02:00
6ef7537dff Added some more paper sizes 2017-08-31 07:57:46 +02:00
abbb823890 Removed DPI dependency in print font size computation 2017-08-31 00:07:29 +02:00
0a4f8a46d4 Update gpxsee_sv.ts (#31)
* Update gpxsee_sv.ts

* Update gpxsee_sv.ts

Sorry, missed 2 strings.
2017-08-30 21:59:14 +02:00
fd2823c703 Version++ 2017-08-30 13:59:22 +02:00
d16b61051f Localization update 2017-08-30 13:56:23 +02:00
e69f17aad5 Print font size id now appropriate to the page size 2017-08-30 13:09:54 +02:00
33b1e179d3 Use the correct DPI value for zooming 2017-08-29 15:31:12 +02:00
5efb9f8a4e Added resolution setting to export dialogue. 2017-08-28 17:48:46 +02:00
ebf39f11bd Added support for hi-resolution printing 2017-08-28 15:25:45 +02:00
8b7422b70a Code cleanup 2017-08-27 12:19:33 +02:00
ef3da2e156 Removed obsolete Windows XP bug workaround 2017-08-24 21:04:01 +02:00
6e13c2b704 Translations update 2017-08-24 19:40:52 +02:00
f3e4719439 Added map opacity (brightness) settings 2017-08-24 17:29:59 +02:00
7b6789e78d Version++ 2017-08-23 15:42:00 +02:00
95442461fc Added 4UMaps to map sources 2017-08-23 15:41:23 +02:00
729cbd641c Added support for the VICGRID and VICGRID94 projections 2017-08-23 10:46:28 +02:00
2e2dad8d04 Fixed broken xy2ll computation on southern hemispheres 2017-08-23 10:45:23 +02:00
4e3b6c2eb2 Added missing error check 2017-08-22 23:14:32 +02:00
6430933a96 Use the (incorrect) scale factor of 1 in France zone projections like OziExplorer does 2017-08-22 22:59:59 +02:00
3e14d4afda Added France Zone I-IV projections support 2017-08-22 19:03:35 +02:00
ebb30a3fca Made OZF3 files parsing more robust. 2017-08-22 15:57:37 +02:00
bd20d40ba7 Fixed content margin computation.
Code cleanup.
2017-08-20 10:49:58 +02:00
77823fba14 Added missing newlines 2017-08-15 15:58:23 +02:00
dcc5cbe9bc Added appveyor build config 2017-08-15 15:49:28 +02:00
cd3c99b065 Added QT4 Travis CI build config 2017-08-15 15:42:47 +02:00
83189a4e65 Version++ 2017-08-15 15:14:44 +02:00
797fd7f02b Fixed QT4 build 2017-08-15 15:13:34 +02:00
a45125be9a Code cleanup 2017-08-15 13:36:18 +02:00
a7154988ab Added support for maps with only 2 reference points 2017-08-14 23:57:53 +02:00
afe9a14d5b Improved debug output 2017-08-14 11:16:48 +02:00
b3f1596918 Make Coverity happy 2017-08-11 09:56:45 +02:00
cd90407f56 Version++ 2017-08-11 09:38:50 +02:00
73f06e61f0 Added support for OZF zoom levels 2017-08-11 00:22:21 +02:00
c708fa35fd Cosmetics 2017-08-10 08:58:21 +02:00
dcedfe1e9f Wrong parameters usage fix 2017-08-09 20:29:49 +02:00
daa9d296bd Code cleanup 2017-08-09 20:25:02 +02:00
b8a9a4481c Improved image part drawing procedure 2017-08-09 17:58:37 +02:00
e792bf3b23 Optimization 2017-08-09 11:32:05 +02:00
359a9f0a5a Avoid error summing when computing map positions 2017-08-08 18:41:19 +02:00
4b0b6513d1 Added missing endianity handling 2017-07-31 00:46:10 +02:00
c7762e26fb Added support for LinearRings in KML 2017-07-30 12:13:45 +02:00
5b8d41afb7 Detect OZF files by contents rather than by file extension 2017-07-29 22:19:03 +02:00
81e1664a9b Data/map loading code cleanup 2017-07-27 19:47:46 +02:00
fad3f116f5 Added missing error checks 2017-07-27 19:45:04 +02:00
a6e522d758 Make Coverity happy 2017-07-12 22:07:18 +02:00
ab65deadb6 Some more cosmetics 2017-07-12 21:30:54 +02:00
7f80e8f7b7 Cosmetics 2017-07-12 21:26:00 +02:00
9a5c5eaf61 Unified isNull() logic 2017-07-12 21:23:56 +02:00
9bc5016141 Indent cleanup 2017-07-12 20:54:00 +02:00
a4a46232e4 Version++ 2017-07-09 10:36:39 +02:00
d85fbe5b48 Do not duplicate Waypoints in POI search structures 2017-07-06 09:37:44 +02:00
141e0cb404 isNull() & isValid() logic improvement 2017-07-02 09:39:31 +02:00
2b7d0cd631 Unified isNull() and isValid() logic with other (QT) classes 2017-06-30 18:38:16 +02:00
d106f47771 Some more code cleanup 2017-06-30 18:15:22 +02:00
e48729fc84 Now using a separate class (RectC) for Coordinates rectangles 2017-06-29 22:29:27 +02:00
dca53bc622 Code cleanup 2017-06-29 19:53:42 +02:00
65045dfee4 Code cleanup 2017-06-27 22:42:59 +02:00
002b9c35e1 Don't rescale the view on map change 2017-06-26 00:20:42 +02:00
945528d6b1 Cosmetics 2017-06-26 00:16:38 +02:00
4697ba4ef0 Unify zoom level calculation logic 2017-06-25 16:25:29 +02:00
9bf1447a7e Back to zoom based zoom values 2017-06-25 16:23:43 +02:00
1a8114af8e Proper cleanup. 2017-06-25 12:34:48 +02:00
ad154dfd7d code cleanup 2017-06-25 12:27:53 +02:00
c2004ded31 Now using tmi index files (if present) when loading tar files 2017-06-25 12:24:05 +02:00
3ced367fab Cosmetics 2017-06-22 22:40:43 +02:00
506d1998f8 Updated project home page URL 2017-06-22 01:40:48 +02:00
afc5e9ca4b Using the platform-correct delimiter 2017-06-19 22:48:48 +02:00
425d0e3013 Cosmetics 2017-06-18 16:06:59 +02:00
3a8b1107fe Explicitly set compression method in NSIS scripts 2017-06-18 13:23:00 +02:00
ad7a413d50 Unified MSVC redistributables names with names used by windeployqt 2017-06-18 12:23:54 +02:00
8d5f72de64 Now using proper menu entries location on OS X
+ proper qt stuff localization
2017-05-31 23:37:02 +02:00
9e798e626c Decreased outlier detection window 2017-05-25 01:55:09 +02:00
cb70f0dded Merge pull request #27 from eson57/patch-1
Update gpxsee_sv.ts
2017-05-23 23:30:38 +02:00
400003f684 Update gpxsee_sv.ts 2017-05-23 21:50:21 +02:00
69db510b10 Decreased default speed filter value 2017-05-23 16:06:05 +02:00
cd9ea0f8a9 Unified settingsorder 2017-05-23 13:43:40 +02:00
0f6c8eb896 Code cleanup 2017-05-23 13:23:14 +02:00
6b3c0d05ca Merge branch 'master' of https://github.com/tumic0/GPXSee 2017-05-23 13:22:41 +02:00
b0cc028c4c Localization update 2017-05-23 13:03:28 +02:00
1513130435 Settings polishing on OS X 2017-05-23 12:50:46 +02:00
ec798451e8 Fixed POI radius setting handling 2017-05-23 00:26:59 +02:00
ffc61552d2 Code cleanup 2017-05-22 23:42:15 +02:00
aff7b1c13f Allow only odd window sizes for moving average filter 2017-05-22 23:41:01 +02:00
d54f22d3f0 Fixed crash with 0 window width 2017-05-22 22:37:35 +02:00
dba6291f3e Better (consistent) graph definition 2017-05-22 18:42:23 +02:00
e96cee2ea8 Improved filtering settings layout 2017-05-22 17:04:37 +02:00
1eaaea98a3 Version++ 2017-05-22 16:12:30 +02:00
a90073c422 Added missing icon 2017-05-22 16:10:44 +02:00
223a13583c Added data filtering settings 2017-05-22 14:54:22 +02:00
4386e1f2e1 Code cleanup 2017-05-16 13:18:57 +02:00
5bfe9c2527 Added missing ellipses 2017-05-16 12:59:59 +02:00
efa2b1c366 Code cleanup 2017-05-16 12:59:40 +02:00
e0ad64a902 Added missing units type setup for new items 2017-05-16 11:51:48 +02:00
207 changed files with 6870 additions and 3453 deletions

52
.appveyor.yml Normal file
View File

@ -0,0 +1,52 @@
version: 4.17.{build}
configuration: Release
platform: Any CPU
environment:
NSISDIR: C:\Program Files (x86)\NSIS
matrix:
- QTDIR: C:\Qt\5.9\msvc2015
PLATFORM: x86
NSI: gpxsee.nsi
OPENSSLDIR: C:\OpenSSL-Win32\bin
- QTDIR: C:\Qt\5.9\msvc2015_64
PLATFORM: x86_amd64
NSI: gpxsee64.nsi
OPENSSLDIR: C:\OpenSSL-Win64\bin
install:
- cmd: >-
set PATH=%QTDIR%\bin;%NSISDIR%;%PATH%
call "C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\vcvarsall.bat" %PLATFORM%
build_script:
- cmd: >-
lrelease gpxsee.pro
qmake gpxsee.pro
nmake release
md installer
copy release\GPXSee.exe installer
windeployqt --no-svg --release installer\GPXSee.exe
copy pkg\%NSI% installer
copy pkg\datums.csv installer
copy pkg\ellipsoids.csv installer
copy pkg\maps.txt installer
copy licence.txt installer
copy %OPENSSLDIR%\libeay32.dll installer
copy %OPENSSLDIR%\ssleay32.dll installer
makensis.exe installer\%NSI%
artifacts:
- path: installer\GPXSee-*.exe

18
.travis.yml Normal file
View File

@ -0,0 +1,18 @@
language: c++
os:
- linux
- osx
before_install:
- if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then sudo apt-get -qq update; fi
install:
- if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then brew install qt; fi
- if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then sudo apt-get install libqt4-dev; fi
script:
- if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then PATH=/usr/local/opt/qt/bin/:${PATH}; fi
- lrelease gpxsee.pro
- qmake gpxsee.pro
- make

View File

@ -15,7 +15,7 @@
<key>CFBundleExecutable</key>
<string>@EXECUTABLE@</string>
<key>CFBundleIdentifier</key>
<string>cz.wz.tumic.GPXSee</string>
<string>org.gpxsee.GPXSee</string>
<key>CFBundleDocumentTypes</key>
<array>

View File

@ -30,4 +30,4 @@ make
[Changelog](https://build.opensuse.org/package/view_file/home:tumic:GPXSee/gpxsee/gpxsee.changes)
## Homepage
GPXSee homepage: http://tumic.wz.cz/gpxsee
http://www.gpxsee.org

BIN
cert/mac/gpxsee.cer Normal file

Binary file not shown.

View File

@ -1,5 +1,5 @@
TARGET = GPXSee
VERSION = 4.7
VERSION = 4.17
QT += core \
gui \
network
@ -7,160 +7,182 @@ greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
greaterThan(QT_MAJOR_VERSION, 4): QT += printsupport
lessThan(QT_VERSION, 5.4): QT += opengl
macx: QT += opengl
INCLUDEPATH += ./src
HEADERS += src/config.h \
src/icons.h \
src/gui.h \
src/poi.h \
src/rtree.h \
src/axisitem.h \
src/keys.h \
src/slideritem.h \
src/markeritem.h \
src/infoitem.h \
src/elevationgraph.h \
src/speedgraph.h \
src/sliderinfoitem.h \
src/filebrowser.h \
src/map.h \
src/onlinemap.h \
src/downloader.h \
src/units.h \
src/scaleitem.h \
src/waypoint.h \
src/track.h \
src/graphview.h \
src/trackpoint.h \
src/waypointitem.h \
src/palette.h \
src/heartrategraph.h \
src/range.h \
src/cpuarch.h \
src/settings.h \
src/app.h \
src/trackinfo.h \
src/exportdialog.h \
src/fileselectwidget.h \
src/margins.h \
src/temperaturegraph.h \
src/graphtab.h \
src/misc.h \
src/trackitem.h \
src/tooltip.h \
src/route.h \
src/routeitem.h \
src/graphitem.h \
src/graph.h \
src/pathitem.h \
src/pathview.h \
src/griditem.h \
src/data.h \
src/gpxparser.h \
src/tcxparser.h \
src/parser.h \
src/csvparser.h \
src/coordinates.h \
src/tile.h \
src/rd.h \
src/wgs84.h \
src/kmlparser.h \
src/trackdata.h \
src/routedata.h \
src/fitparser.h \
src/format.h \
src/path.h \
src/assert.h \
src/cadencegraph.h \
src/powergraph.h \
src/igcparser.h \
src/nmeaparser.h \
src/optionsdialog.h \
src/colorbox.h \
src/stylecombobox.h \
src/opengl.h \
src/timetype.h \
src/emptymap.h \
src/offlinemap.h \
src/matrix.h \
src/tar.h \
src/atlas.h \
src/projection.h \
src/mercator.h \
src/transversemercator.h \
src/latlon.h \
src/utm.h \
src/lambertconic.h \
src/ellipsoid.h \
src/ozf.h \
src/datum.h \
src/maplist.h \
src/albersequal.h
src/common/staticassert.h \
src/common/coordinates.h \
src/common/range.h \
src/common/rectc.h \
src/common/wgs84.h \
src/GUI/app.h \
src/GUI/icons.h \
src/GUI/gui.h \
src/GUI/axisitem.h \
src/GUI/keys.h \
src/GUI/slideritem.h \
src/GUI/markeritem.h \
src/GUI/infoitem.h \
src/GUI/elevationgraph.h \
src/GUI/speedgraph.h \
src/GUI/sliderinfoitem.h \
src/GUI/filebrowser.h \
src/GUI/units.h \
src/GUI/scaleitem.h \
src/GUI/graphview.h \
src/GUI/waypointitem.h \
src/GUI/palette.h \
src/GUI/heartrategraph.h \
src/GUI/trackinfo.h \
src/GUI/exportdialog.h \
src/GUI/fileselectwidget.h \
src/GUI/margins.h \
src/GUI/temperaturegraph.h \
src/GUI/graphtab.h \
src/GUI/trackitem.h \
src/GUI/tooltip.h \
src/GUI/routeitem.h \
src/GUI/graphitem.h \
src/GUI/pathitem.h \
src/GUI/griditem.h \
src/GUI/format.h \
src/GUI/cadencegraph.h \
src/GUI/powergraph.h \
src/GUI/optionsdialog.h \
src/GUI/colorbox.h \
src/GUI/stylecombobox.h \
src/GUI/opengl.h \
src/GUI/timetype.h \
src/GUI/percentslider.h \
src/GUI/elevationgraphitem.h \
src/GUI/speedgraphitem.h \
src/GUI/heartrategraphitem.h \
src/GUI/temperaturegraphitem.h \
src/GUI/cadencegraphitem.h \
src/GUI/powergraphitem.h \
src/GUI/oddspinbox.h \
src/GUI/settings.h \
src/GUI/nicenum.h \
src/GUI/cpuarch.h \
src/GUI/searchpointer.h \
src/GUI/mapview.h \
src/map/projection.h \
src/map/ellipsoid.h \
src/map/datum.h \
src/map/mercator.h \
src/map/transversemercator.h \
src/map/latlon.h \
src/map/utm.h \
src/map/lambertconic.h \
src/map/lambertazimuthal.h \
src/map/albersequal.h \
src/map/map.h \
src/map/maplist.h \
src/map/onlinemap.h \
src/map/downloader.h \
src/map/tile.h \
src/map/emptymap.h \
src/map/offlinemap.h \
src/map/tar.h \
src/map/ozf.h \
src/map/atlas.h \
src/map/matrix.h \
src/map/misc.h \
src/data/graph.h \
src/data/poi.h \
src/data/waypoint.h \
src/data/track.h \
src/data/route.h \
src/data/trackpoint.h \
src/data/data.h \
src/data/parser.h \
src/data/trackdata.h \
src/data/routedata.h \
src/data/path.h \
src/data/rtree.h \
src/data/gpxparser.h \
src/data/tcxparser.h \
src/data/csvparser.h \
src/data/kmlparser.h \
src/data/fitparser.h \
src/data/igcparser.h \
src/data/nmeaparser.h \
src/data/str2int.h
SOURCES += src/main.cpp \
src/gui.cpp \
src/poi.cpp \
src/axisitem.cpp \
src/slideritem.cpp \
src/markeritem.cpp \
src/infoitem.cpp \
src/elevationgraph.cpp \
src/speedgraph.cpp \
src/sliderinfoitem.cpp \
src/filebrowser.cpp \
src/onlinemap.cpp \
src/downloader.cpp \
src/scaleitem.cpp \
src/track.cpp \
src/graphview.cpp \
src/waypointitem.cpp \
src/palette.cpp \
src/heartrategraph.cpp \
src/range.cpp \
src/app.cpp \
src/trackinfo.cpp \
src/exportdialog.cpp \
src/fileselectwidget.cpp \
src/temperaturegraph.cpp \
src/trackpoint.cpp \
src/misc.cpp \
src/waypoint.cpp \
src/trackitem.cpp \
src/tooltip.cpp \
src/route.cpp \
src/routeitem.cpp \
src/graphitem.cpp \
src/pathitem.cpp \
src/pathview.cpp \
src/griditem.cpp \
src/data.cpp \
src/gpxparser.cpp \
src/tcxparser.cpp \
src/csvparser.cpp \
src/coordinates.cpp \
src/kmlparser.cpp \
src/fitparser.cpp \
src/format.cpp \
src/graph.cpp \
src/cadencegraph.cpp \
src/powergraph.cpp \
src/igcparser.cpp \
src/path.cpp \
src/nmeaparser.cpp \
src/optionsdialog.cpp \
src/colorbox.cpp \
src/stylecombobox.cpp \
src/emptymap.cpp \
src/offlinemap.cpp \
src/matrix.cpp \
src/tar.cpp \
src/atlas.cpp \
src/mercator.cpp \
src/transversemercator.cpp \
src/utm.cpp \
src/lambertconic.cpp \
src/ellipsoid.cpp \
src/ozf.cpp \
src/datum.cpp \
src/maplist.cpp \
src/albersequal.cpp
src/common/coordinates.cpp \
src/common/rectc.cpp \
src/common/range.cpp \
src/GUI/app.cpp \
src/GUI/gui.cpp \
src/GUI/axisitem.cpp \
src/GUI/slideritem.cpp \
src/GUI/markeritem.cpp \
src/GUI/infoitem.cpp \
src/GUI/elevationgraph.cpp \
src/GUI/speedgraph.cpp \
src/GUI/sliderinfoitem.cpp \
src/GUI/filebrowser.cpp \
src/GUI/scaleitem.cpp \
src/GUI/graphview.cpp \
src/GUI/waypointitem.cpp \
src/GUI/palette.cpp \
src/GUI/heartrategraph.cpp \
src/GUI/trackinfo.cpp \
src/GUI/exportdialog.cpp \
src/GUI/fileselectwidget.cpp \
src/GUI/temperaturegraph.cpp \
src/GUI/trackitem.cpp \
src/GUI/tooltip.cpp \
src/GUI/routeitem.cpp \
src/GUI/graphitem.cpp \
src/GUI/pathitem.cpp \
src/GUI/griditem.cpp \
src/GUI/format.cpp \
src/GUI/cadencegraph.cpp \
src/GUI/powergraph.cpp \
src/GUI/optionsdialog.cpp \
src/GUI/colorbox.cpp \
src/GUI/stylecombobox.cpp \
src/GUI/oddspinbox.cpp \
src/GUI/percentslider.cpp \
src/GUI/elevationgraphitem.cpp \
src/GUI/speedgraphitem.cpp \
src/GUI/heartrategraphitem.cpp \
src/GUI/temperaturegraphitem.cpp \
src/GUI/cadencegraphitem.cpp \
src/GUI/powergraphitem.cpp \
src/GUI/nicenum.cpp \
src/GUI/mapview.cpp \
src/map/maplist.cpp \
src/map/onlinemap.cpp \
src/map/downloader.cpp \
src/map/emptymap.cpp \
src/map/offlinemap.cpp \
src/map/tar.cpp \
src/map/atlas.cpp \
src/map/ozf.cpp \
src/map/matrix.cpp \
src/map/ellipsoid.cpp \
src/map/datum.cpp \
src/map/projection.cpp \
src/map/mercator.cpp \
src/map/transversemercator.cpp \
src/map/utm.cpp \
src/map/lambertconic.cpp \
src/map/albersequal.cpp \
src/map/lambertazimuthal.cpp \
src/data/data.cpp \
src/data/poi.cpp \
src/data/track.cpp \
src/data/route.cpp \
src/data/path.cpp \
src/data/gpxparser.cpp \
src/data/tcxparser.cpp \
src/data/csvparser.cpp \
src/data/kmlparser.cpp \
src/data/fitparser.cpp \
src/data/igcparser.cpp \
src/data/nmeaparser.cpp \
src/data/str2int.cpp
RESOURCES += gpxsee.qrc
TRANSLATIONS = lang/gpxsee_cs.ts \
lang/gpxsee_sv.ts \

View File

@ -14,11 +14,12 @@
<file>icons/arrow-left-double.png</file>
<file>icons/arrow-right-double.png</file>
<file>icons/view-fullscreen.png</file>
<file>icons/office-chart-line-stacked.png</file>
<file>icons/office-chart-line.png</file>
<file>icons/preferences-desktop-display.png</file>
<file>icons/flag_48.png</file>
<file>icons/system-run.png</file>
<file>icons/document-print-preview.png</file>
<file>icons/view-filter.png</file>
<file>lang/gpxsee_cs.qm</file>
<file>lang/gpxsee_sv.qm</file>
<file>lang/gpxsee_de.qm</file>

Binary file not shown.

Before

Width:  |  Height:  |  Size: 727 B

BIN
icons/office-chart-line.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 728 B

BIN
icons/view-filter.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.4 KiB

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -5,10 +5,12 @@
; The name of the installer
Name "GPXSee"
; Program version
!define VERSION "4.7"
!define VERSION "4.17"
; The file to write
OutFile "GPXSee-${VERSION}.exe"
; Compression method
SetCompressor /SOLID lzma
; Required execution level
RequestExecutionLevel admin
@ -171,8 +173,8 @@ Section "MSVC runtime" SEC_MSVC
DetailPrint "Installing Visual C++ 2015 Redistributable..."
SetOutPath $TEMP
File "VC_redist.x86.exe"
ExecWait '"$TEMP/VC_redist.x86.exe" /install /quiet /norestart'
File "vcredist_x86.exe"
ExecWait '"$TEMP\vcredist_x86.exe" /install /quiet /norestart'
SetOutPath $INSTDIR
done:

View File

@ -5,10 +5,12 @@
; The name of the installer
Name "GPXSee"
; Program version
!define VERSION "4.7"
!define VERSION "4.17"
; The file to write
OutFile "GPXSee-${VERSION}_x64.exe"
; Compression method
SetCompressor /SOLID lzma
; Required execution level
RequestExecutionLevel admin
@ -173,8 +175,8 @@ Section "MSVC runtime" SEC_MSVC
DetailPrint "Installing Visual C++ 2015 Redistributable..."
SetOutPath $TEMP
File "VC_redist.x64.exe"
ExecWait '"$TEMP/VC_redist.x64.exe" /install /quiet /norestart'
File "vcredist_x64.exe"
ExecWait '"$TEMP\vcredist_x64.exe" /install /quiet /norestart'
SetOutPath $INSTDIR
done:

View File

@ -1,4 +1,5 @@
Open Topo Map https://a.tile.opentopomap.org/$z/$x/$y.png
Open Street Map http://tile.openstreetmap.org/$z/$x/$y.png
USGS Topo https://navigator.er.usgs.gov/tiles/tcr.cgi/$z/$x/$y.png
USGS Imagery https://navigator.er.usgs.gov/tiles/aerial_Imagery.cgi/$z/$x/$y
Open Topo Map https://a.tile.opentopomap.org/$z/$x/$y.png 17
4UMaps http://4umaps.eu/$z/$x/$y.png 15
Open Street Map http://tile.openstreetmap.org/$z/$x/$y.png 19
USGS Topo https://navigator.er.usgs.gov/tiles/tcr.cgi/$z/$x/$y.png 15
USGS Imagery https://navigator.er.usgs.gov/tiles/aerial_Imagery.cgi/$z/$x/$y 15

109
src/GUI/app.cpp Normal file
View File

@ -0,0 +1,109 @@
#include <QtGlobal>
#include <QTranslator>
#include <QLocale>
#include <QFileOpenEvent>
#include <QNetworkProxyFactory>
#include <QLibraryInfo>
#include "map/onlinemap.h"
#include "map/downloader.h"
#include "map/ellipsoid.h"
#include "map/datum.h"
#include "opengl.h"
#include "gui.h"
#include "config.h"
#include "app.h"
App::App(int &argc, char **argv) : QApplication(argc, argv),
_argc(argc), _argv(argv)
{
QTranslator *gpxsee = new QTranslator(this);
QString locale = QLocale::system().name();
gpxsee->load(QString(":/lang/gpxsee_") + locale);
installTranslator(gpxsee);
QTranslator *qt = new QTranslator(this);
qt->load(QLocale::system(), "qt", "_", QLibraryInfo::location(
QLibraryInfo::TranslationsPath));
installTranslator(qt);
#ifdef Q_OS_MAC
setAttribute(Qt::AA_DontShowIconsInMenus);
#endif // Q_OS_MAC
QNetworkProxyFactory::setUseSystemConfiguration(true);
OnlineMap::setDownloader(new Downloader(this));
OPENGL_SET_SAMPLES(4);
loadDatums();
_gui = new GUI();
}
App::~App()
{
delete _gui;
}
void App::run()
{
_gui->show();
for (int i = 1; i < _argc; i++)
_gui->openFile(QString::fromLocal8Bit(_argv[i]));
exec();
}
bool App::event(QEvent *event)
{
if (event->type() == QEvent::FileOpen) {
QFileOpenEvent *e = static_cast<QFileOpenEvent *>(event);
return _gui->openFile(e->file());
}
return QApplication::event(event);
}
void App::loadDatums()
{
QString ef, df;
bool ok = false;
if (QFile::exists(USER_ELLIPSOID_FILE))
ef = USER_ELLIPSOID_FILE;
else if (QFile::exists(GLOBAL_ELLIPSOID_FILE))
ef = GLOBAL_ELLIPSOID_FILE;
else
qWarning("No ellipsoids file found.");
if (QFile::exists(USER_DATUM_FILE))
df = USER_DATUM_FILE;
else if (QFile::exists(GLOBAL_DATUM_FILE))
df = GLOBAL_DATUM_FILE;
else
qWarning("No datums file found.");
if (!ef.isNull() && !df.isNull()) {
if (!Ellipsoid::loadList(ef)) {
if (Ellipsoid::errorLine())
qWarning("%s: parse error on line %d: %s", qPrintable(ef),
Ellipsoid::errorLine(), qPrintable(Ellipsoid::errorString()));
else
qWarning("%s: %s", qPrintable(ef), qPrintable(
Ellipsoid::errorString()));
} else {
if (!Datum::loadList(df)) {
if (Datum::errorLine())
qWarning("%s: parse error on line %d: %s", qPrintable(ef),
Datum::errorLine(), qPrintable(Datum::errorString()));
else
qWarning("%s: %s", qPrintable(ef), qPrintable(
Datum::errorString()));
} else
ok = true;
}
}
if (!ok)
qWarning("Maps based on a datum different from WGS84 won't work.");
}

View File

@ -18,6 +18,8 @@ protected:
bool event(QEvent *event);
private:
void loadDatums();
int &_argc;
char **_argv;
GUI *_gui;

View File

@ -1,7 +1,7 @@
#include <cmath>
#include <QPainter>
#include "config.h"
#include "misc.h"
#include "nicenum.h"
#include "axisitem.h"

View File

@ -2,7 +2,7 @@
#define AXISITEM_H
#include <QGraphicsItem>
#include "range.h"
#include "common/range.h"
class AxisItem : public QGraphicsItem
{

View File

@ -1,10 +1,10 @@
#include "data.h"
#include "data/data.h"
#include "cadencegraphitem.h"
#include "cadencegraph.h"
CadenceGraph::CadenceGraph(QWidget *parent) : GraphTab(parent)
{
_units = Metric;
_showTracks = true;
GraphView::setYUnits(tr("1/min"));
@ -28,21 +28,16 @@ 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));
CadenceGraphItem *gi = new CadenceGraphItem(graph, _graphType);
GraphView::addGraph(gi, paths.at(i));
GraphView::loadGraph(graph, paths.at(i));
_avg.append(QPointF(data.tracks().at(i)->distance(), gi->avg()));
}
for (int i = 0; i < data.routes().count(); i++)

View File

@ -13,7 +13,6 @@ public:
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);}
@ -24,7 +23,6 @@ private:
QList<QPointF> _avg;
enum Units _units;
bool _showTracks;
};

View File

@ -0,0 +1,26 @@
#include "tooltip.h"
#include "cadencegraphitem.h"
CadenceGraphItem::CadenceGraphItem(const Graph &graph, GraphType type,
QGraphicsItem *parent) : GraphItem(graph, type, parent)
{
qreal sum = 0;
for (int j = 1; j < graph.size(); j++)
sum += graph.at(j).y() * (graph.at(j).s() - graph.at(j-1).s());
_avg = sum/graph.last().s();
setToolTip(toolTip());
}
QString CadenceGraphItem::toolTip() const
{
ToolTip tt;
tt.insert(tr("Maximum"), QString::number(max(), 'f', 1)
+ UNIT_SPACE + tr("1/min"));
tt.insert(tr("Average"), QString::number(avg(), 'f', 1)
+ UNIT_SPACE + tr("1/min"));
return tt.toString();
}

View File

@ -0,0 +1,23 @@
#ifndef CADENCEGRAPHITEM_H
#define CADENCEGRAPHITEM_H
#include "graphitem.h"
class CadenceGraphItem : public GraphItem
{
Q_OBJECT
public:
CadenceGraphItem(const Graph &graph, GraphType type,
QGraphicsItem *parent = 0);
qreal max() const {return -bounds().top();}
qreal avg() const {return _avg;}
private:
QString toolTip() const;
qreal _avg;
};
#endif // CADENCEGRAPHITEM_H

View File

@ -9,6 +9,8 @@
ColorBox::ColorBox(QWidget *parent) : QWidget(parent)
{
_color = Qt::red;
_alpha = true;
setSizePolicy(QSizePolicy::QSizePolicy::Minimum, QSizePolicy::Fixed);
}
@ -51,9 +53,9 @@ void ColorBox::mousePressEvent(QMouseEvent *event)
{
if (event->button() != Qt::LeftButton)
return;
QColor color = QColorDialog::getColor(_color, this, QString(),
QColorDialog::ShowAlphaChannel);
QColorDialog::ColorDialogOptions options = _alpha
? QColorDialog::ShowAlphaChannel : (QColorDialog::ColorDialogOptions)0;
QColor color = QColorDialog::getColor(_color, this, QString(), options);
if (color.isValid()) {
_color = color;
update();

View File

@ -12,6 +12,7 @@ public:
const QColor &color() const {return _color;}
void setColor(const QColor &color);
void enableAlphaChannel(bool enable) {_alpha = enable;}
QSize sizeHint() const;
@ -24,6 +25,7 @@ protected:
private:
QColor _color;
bool _alpha;
};
#endif // COLORBOX_H

View File

@ -1,6 +1,8 @@
#include <cmath>
#include "data/data.h"
#include "config.h"
#include "data.h"
#include "tooltip.h"
#include "elevationgraphitem.h"
#include "elevationgraph.h"
@ -42,11 +44,8 @@ ElevationGraph::ElevationGraph(QWidget *parent) : GraphTab(parent)
_showRoutes = true;
_showTracks = true;
_units = Metric;
setYUnits();
setYUnits(Metric);
setYLabel(tr("Elevation"));
setMinYRange(50.0);
}
@ -68,43 +67,25 @@ void ElevationGraph::setInfo()
void ElevationGraph::loadGraph(const Graph &graph, Type type, PathItem *path)
{
qreal ascent = 0, descent = 0;
qreal min, max;
if (graph.size() < 2) {
skipColor();
return;
}
max = min = graph.at(0).y();
for (int j = 1; j < graph.size(); j++) {
qreal cur = graph.at(j).y();
qreal prev = graph.at(j-1).y();
if (cur > prev)
ascent += cur - prev;
if (cur < prev)
descent += prev - cur;
if (cur < min)
min = cur;
if (cur > max)
max = cur;
}
ElevationGraphItem *gi = new ElevationGraphItem(graph, _graphType);
GraphView::addGraph(gi, path, type);
if (type == Track) {
_trackAscent += ascent;
_trackDescent += descent;
_trackMax = nMax(_trackMax, max);
_trackMin = nMin(_trackMin, min);
_trackAscent += gi->ascent();
_trackDescent += gi->descent();
_trackMax = nMax(_trackMax, gi->max());
_trackMin = nMin(_trackMin, gi->min());
} else {
_routeAscent += ascent;
_routeDescent += descent;
_routeMax = nMax(_routeMax, max);
_routeMin = nMin(_routeMin, min);
_routeAscent += gi->ascent();
_routeDescent += gi->descent();
_routeMax = nMax(_routeMax, gi->max());
_routeMin = nMin(_routeMin, gi->min());
}
GraphView::loadGraph(graph, path, type);
}
void ElevationGraph::loadData(const Data &data, const QList<PathItem *> &paths)
@ -135,9 +116,9 @@ void ElevationGraph::clear()
GraphView::clear();
}
void ElevationGraph::setYUnits()
void ElevationGraph::setYUnits(Units units)
{
if (_units == Metric) {
if (units == Metric) {
GraphView::setYUnits(tr("m"));
setYScale(1);
} else {
@ -146,15 +127,12 @@ void ElevationGraph::setYUnits()
}
}
void ElevationGraph::setUnits(enum Units units)
void ElevationGraph::setUnits(Units units)
{
_units = units;
setYUnits();
setYUnits(units);
setInfo();
GraphView::setUnits(units);
redraw();
GraphView::setUnits(units);
}
void ElevationGraph::showTracks(bool show)

View File

@ -25,7 +25,7 @@ private:
qreal ascent() const;
qreal descent() const;
void setYUnits();
void setYUnits(Units units);
void setInfo();
void loadGraph(const Graph &graph, Type type, PathItem *path);
@ -35,7 +35,6 @@ private:
qreal _trackMax, _routeMax;
qreal _trackMin, _routeMin;
enum Units _units;
bool _showTracks, _showRoutes;
};

View File

@ -0,0 +1,43 @@
#include "tooltip.h"
#include "elevationgraphitem.h"
ElevationGraphItem::ElevationGraphItem(const Graph &graph, GraphType type,
QGraphicsItem *parent) : GraphItem(graph, type, parent)
{
_ascent = _descent = 0;
for (int j = 1; j < graph.size(); j++) {
qreal cur = graph.at(j).y();
qreal prev = graph.at(j-1).y();
if (cur > prev)
_ascent += cur - prev;
if (cur < prev)
_descent += prev - cur;
}
setToolTip(toolTip(Metric));
}
QString ElevationGraphItem::toolTip(Units units) const
{
ToolTip tt;
qreal scale = (units == Metric) ? 1.0 : M2FT;
QString su = (units == Metric) ? tr("m") : tr("ft");
tt.insert(tr("Ascent"), QString::number(ascent() * scale, 'f', 0)
+ UNIT_SPACE + su);
tt.insert(tr("Descent"), QString::number(descent() * scale, 'f', 0)
+ UNIT_SPACE + su);
tt.insert(tr("Maximum"), QString::number(max() * scale, 'f', 0)
+ UNIT_SPACE + su);
tt.insert(tr("Minimum"), QString::number(min() * scale, 'f', 0)
+ UNIT_SPACE + su);
return tt.toString();
}
void ElevationGraphItem::setUnits(Units units)
{
setToolTip(toolTip(units));
}

View File

@ -0,0 +1,27 @@
#ifndef ELEVATIONGRAPHITEM_H
#define ELEVATIONGRAPHITEM_H
#include "graphitem.h"
class ElevationGraphItem : public GraphItem
{
Q_OBJECT
public:
ElevationGraphItem(const Graph &graph, GraphType type,
QGraphicsItem *parent = 0);
qreal ascent() const {return _ascent;}
qreal descent() const {return _descent;}
qreal min() const {return -bounds().bottom();}
qreal max() const {return -bounds().top();}
void setUnits(Units units);
private:
QString toolTip(Units units) const;
qreal _ascent, _descent;
};
#endif // ELEVATIONGRAPHITEM_H

View File

@ -26,15 +26,28 @@ ExportDialog::ExportDialog(Export *exp, QWidget *parent)
_fileSelect->setFile(_export->fileName);
_paperSize = new QComboBox();
_paperSize->addItem("A2", QPrinter::A2);
_paperSize->addItem("A3", QPrinter::A3);
_paperSize->addItem("A4", QPrinter::A4);
_paperSize->addItem("A5", QPrinter::A5);
_paperSize->addItem("A6", QPrinter::A6);
_paperSize->addItem("B3", QPrinter::B3);
_paperSize->addItem("B4", QPrinter::B4);
_paperSize->addItem("B5", QPrinter::B5);
_paperSize->addItem("B6", QPrinter::B6);
_paperSize->addItem("Tabloid", QPrinter::Tabloid);
_paperSize->addItem("Legal", QPrinter::Legal);
_paperSize->addItem("Letter", QPrinter::Letter);
if ((index = _paperSize->findData(_export->paperSize)) >= 0)
_paperSize->setCurrentIndex(index);
_resolution = new QComboBox();
_resolution->addItem("300 DPI", 300);
_resolution->addItem("600 DPI", 600);
_resolution->addItem("1200 DPI", 1200);
if ((index = _resolution->findData(_export->resolution)) >= 0)
_resolution->setCurrentIndex(index);
_portrait = new QRadioButton(tr("Portrait"));
_landscape = new QRadioButton(tr("Landscape"));
QHBoxLayout *orientationLayout = new QHBoxLayout();
@ -81,6 +94,7 @@ ExportDialog::ExportDialog(Export *exp, QWidget *parent)
#endif // Q_OS_MAC
QFormLayout *pageSetupLayout = new QFormLayout;
pageSetupLayout->addRow(tr("Page size:"), _paperSize);
pageSetupLayout->addRow(tr("Resolution:"), _resolution);
pageSetupLayout->addRow(tr("Orientation:"), orientationLayout);
pageSetupLayout->addRow(tr("Margins:"), marginsLayout);
#ifdef Q_OS_MAC
@ -161,9 +175,11 @@ void ExportDialog::accept()
? QPrinter::Portrait : QPrinter::Landscape;
QPrinter::PaperSize paperSize = static_cast<QPrinter::PaperSize>
(_paperSize->itemData(_paperSize->currentIndex()).toInt());
int resolution = _resolution->itemData(_resolution->currentIndex()).toInt();
_export->fileName = _fileSelect->file();
_export->paperSize = paperSize;
_export->resolution = resolution;
_export->orientation = orientation;
if (_export->units == Imperial)
_export->margins = MarginsF(_leftMargin->value() / MM2IN,

View File

@ -16,6 +16,7 @@ struct Export {
QPrinter::PaperSize paperSize;
QPrinter::Orientation orientation;
MarginsF margins;
int resolution;
Units units;
};
@ -37,6 +38,7 @@ private:
FileSelectWidget *_fileSelect;
QComboBox *_paperSize;
QComboBox *_resolution;
QRadioButton *_portrait;
QRadioButton *_landscape;
QDoubleSpinBox *_topMargin;

View File

@ -1,8 +1,8 @@
#include <QApplication>
#include "coordinates.h"
#include "common/coordinates.h"
#include "format.h"
QString Format::timeSpan(qreal time)
QString Format::timeSpan(qreal time, bool full)
{
unsigned h, m, s;
@ -10,8 +10,12 @@ QString Format::timeSpan(qreal time)
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'));
if (full || h)
return QString("%1:%2:%3").arg(h, 2, 10, QChar('0'))
.arg(m, 2, 10, QChar('0')).arg(s, 2, 10, QChar('0'));
else
return QString("%1:%2").arg(m, 2, 10, QChar('0'))
.arg(s, 2, 10, QChar('0'));
}
QString Format::distance(qreal value, Units units)

View File

@ -8,7 +8,7 @@ class Coordinates;
namespace Format
{
QString timeSpan(qreal time);
QString timeSpan(qreal time, bool full = true);
QString distance(qreal value, Units units);
QString elevation(qreal value, Units units);
QString coordinates(const Coordinates &value);

View File

@ -2,7 +2,7 @@
#include "graphitem.h"
GraphItem::GraphItem(const Graph &graph, QGraphicsItem *parent)
GraphItem::GraphItem(const Graph &graph, GraphType type, QGraphicsItem *parent)
: QGraphicsObject(parent)
{
_id = 0;
@ -10,14 +10,32 @@ GraphItem::GraphItem(const Graph &graph, QGraphicsItem *parent)
_pen = QPen(Qt::black, _width);
_type = Distance;
_type = type;
_graph = graph;
_sx = 1.0; _sy = 1.0;
_time = true;
for (int i = 0; i < _graph.size(); i++) {
if (std::isnan(_graph.at(i).t())) {
_time = false;
break;
}
}
setZValue(1.0);
updatePath();
updateShape();
updateBounds();
setAcceptHoverEvents(true);
}
void GraphItem::updateShape()
{
QPainterPathStroker s;
s.setWidth(_width + 1);
_shape = s.createStroke(_path);
}
void GraphItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *option,
@ -38,25 +56,37 @@ void GraphItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *option,
void GraphItem::setGraphType(GraphType type)
{
if (type == _type)
return;
prepareGeometryChange();
_type = type;
updatePath();
updateShape();
updateBounds();
}
void GraphItem::setColor(const QColor &color)
{
if (_pen.color() == color)
return;
_pen.setColor(color);
update();
}
void GraphItem::setWidth(int width)
{
if (width == _width)
return;
prepareGeometryChange();
_width = width;
_pen.setWidth(width);
updateShape();
}
qreal GraphItem::yAtX(qreal x)
@ -124,7 +154,7 @@ qreal GraphItem::distanceAtTime(qreal time)
void GraphItem::emitSliderPositionChanged(qreal pos)
{
if (_type == Time) {
if (_graph.hasTime()) {
if (_time) {
if (pos >= _graph.first().t() && pos <= _graph.last().t())
emit sliderPositionChanged(distanceAtTime(pos));
else
@ -135,9 +165,9 @@ void GraphItem::emitSliderPositionChanged(qreal pos)
emit sliderPositionChanged(pos);
}
void GraphItem::selected(bool selected)
void GraphItem::hover(bool hover)
{
if (selected) {
if (hover) {
_pen.setWidth(_width + 1);
setZValue(zValue() + 1.0);
} else {
@ -157,13 +187,14 @@ void GraphItem::setScale(qreal sx, qreal sy)
_sx = sx; _sy = sy;
updatePath();
updateShape();
}
void GraphItem::updatePath()
{
_path = QPainterPath();
if (_type == Time && !_graph.hasTime())
if (_type == Time && !_time)
return;
_path.moveTo(_graph.first().x(_type) * _sx, -_graph.first().y() * _sy);
@ -173,7 +204,7 @@ void GraphItem::updatePath()
void GraphItem::updateBounds()
{
if (_type == Time && !_graph.hasTime()) {
if (_type == Time && !_time) {
_bounds = QRectF();
return;
}
@ -191,3 +222,25 @@ void GraphItem::updateBounds()
_bounds = QRectF(QPointF(left, top), QPointF(right, bottom));
}
void GraphItem::hoverEnterEvent(QGraphicsSceneHoverEvent *event)
{
Q_UNUSED(event);
_pen.setWidthF(_width + 1);
setZValue(zValue() + 1.0);
update();
emit selected(true);
}
void GraphItem::hoverLeaveEvent(QGraphicsSceneHoverEvent *event)
{
Q_UNUSED(event);
_pen.setWidthF(_width);
setZValue(zValue() - 1.0);
update();
emit selected(false);
}

View File

@ -3,41 +3,50 @@
#include <QGraphicsObject>
#include <QPen>
#include "graph.h"
#include "data/graph.h"
#include "units.h"
class GraphItem : public QGraphicsObject
{
Q_OBJECT
public:
GraphItem(const Graph &graph, QGraphicsItem *parent = 0);
GraphItem(const Graph &graph, GraphType type, QGraphicsItem *parent = 0);
QRectF boundingRect() const
{return _path.boundingRect();}
QPainterPath shape() const {return _shape;}
QRectF boundingRect() const {return _shape.boundingRect();}
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option,
QWidget *widget);
const QRectF &bounds() const {return _bounds;}
void setScale(qreal sx, qreal sy);
void setScale(qreal sx, qreal sy);
void setGraphType(GraphType type);
int id() const {return _id;}
void setId(int id) {_id = id;}
void setColor(const QColor &color);
void setWidth(int width);
virtual void setUnits(Units units) {Q_UNUSED(units);}
qreal yAtX(qreal x);
qreal distanceAtTime(qreal time);
void redraw();
signals:
void sliderPositionChanged(qreal);
void selected(bool);
public slots:
void emitSliderPositionChanged(qreal);
void selected(bool selected);
void hover(bool hover);
private:
void hoverEnterEvent(QGraphicsSceneHoverEvent *event);
void hoverLeaveEvent(QGraphicsSceneHoverEvent *event);
void updatePath();
void updateShape();
void updateBounds();
int _id;
@ -48,8 +57,11 @@ private:
GraphType _type;
QPainterPath _path;
QPainterPath _shape;
QRectF _bounds;
qreal _sx, _sy;
bool _time;
};
#endif // GRAPHITEM_H

View File

@ -19,8 +19,9 @@ public:
virtual QString label() const = 0;
virtual void loadData(const Data &data, const QList<PathItem *> &paths) = 0;
virtual void clear() {}
virtual void setUnits(enum Units units) {Q_UNUSED(units)}
virtual void clear() {GraphView::clear();}
virtual void setUnits(enum Units units) {GraphView::setUnits(units);}
virtual void setGraphType(GraphType type) {GraphView::setGraphType(type);}
virtual void setTimeType(enum TimeType type) {Q_UNUSED(type)}
virtual void showTracks(bool show) {Q_UNUSED(show)}
virtual void showRoutes(bool show) {Q_UNUSED(show)}

View File

@ -3,6 +3,7 @@
#include <QMouseEvent>
#include <QPaintEngine>
#include <QPaintDevice>
#include "data/graph.h"
#include "opengl.h"
#include "config.h"
#include "axisitem.h"
@ -10,9 +11,9 @@
#include "sliderinfoitem.h"
#include "infoitem.h"
#include "griditem.h"
#include "graph.h"
#include "graphitem.h"
#include "pathitem.h"
#include "format.h"
#include "graphview.h"
@ -139,7 +140,13 @@ void GraphView::setXUnits()
void GraphView::setUnits(Units units)
{
_units = units;
for (int i = 0; i < _graphs.count(); i++)
_graphs.at(i)->setUnits(units);
setXUnits();
redraw();
}
void GraphView::setGraphType(GraphType type)
@ -167,29 +174,34 @@ void GraphView::showGrid(bool show)
_grid->setVisible(show);
}
void GraphView::loadGraph(const Graph &graph, PathItem *path, int id)
void GraphView::showSliderInfo(bool show)
{
if (graph.size() < 2)
return;
_sliderInfo->setVisible(show);
}
GraphItem *gi = new GraphItem(graph);
gi->setGraphType(_graphType);
gi->setId(id);
gi->setColor(_palette.nextColor());
gi->setWidth(_width);
void GraphView::addGraph(GraphItem *graph, PathItem *path, int id)
{
QColor color(_palette.nextColor());
color.setAlpha(255);
connect(this, SIGNAL(sliderPositionChanged(qreal)), gi,
graph->setUnits(_units);
graph->setId(id);
graph->setColor(color);
graph->setWidth(_width);
connect(this, SIGNAL(sliderPositionChanged(qreal)), graph,
SLOT(emitSliderPositionChanged(qreal)));
connect(gi, SIGNAL(sliderPositionChanged(qreal)), path,
connect(graph, SIGNAL(sliderPositionChanged(qreal)), path,
SLOT(moveMarker(qreal)));
connect(path, SIGNAL(selected(bool)), gi, SLOT(selected(bool)));
connect(path, SIGNAL(selected(bool)), graph, SLOT(hover(bool)));
connect(graph, SIGNAL(selected(bool)), path, SLOT(hover(bool)));
_graphs.append(gi);
_graphs.append(graph);
if (!_hide.contains(id)) {
_visible.append(gi);
_scene->addItem(gi);
_bounds |= gi->bounds();
_visible.append(graph);
_scene->addItem(graph);
_bounds |= graph->bounds();
setXUnits();
}
}
@ -227,11 +239,6 @@ void GraphView::showGraph(bool show, int id)
}
}
void GraphView::redraw()
{
redraw(viewport()->size() - QSizeF(MARGIN, MARGIN));
}
QRectF GraphView::bounds() const
{
QRectF br(_bounds);
@ -239,6 +246,11 @@ QRectF GraphView::bounds() const
return br;
}
void GraphView::redraw()
{
redraw(viewport()->size() - QSizeF(MARGIN, MARGIN));
}
void GraphView::redraw(const QSizeF &size)
{
QRectF r;
@ -326,11 +338,9 @@ void GraphView::mousePressEvent(QMouseEvent *e)
QGraphicsView::mousePressEvent(e);
}
void GraphView::plot(QPainter *painter, const QRectF &target)
void GraphView::plot(QPainter *painter, const QRectF &target, qreal scale)
{
qreal ratio = painter->paintEngine()->paintDevice()->logicalDpiX()
/ SCREEN_DPI;
QSizeF canvas = QSizeF(target.width() / ratio, target.height() / ratio);
QSizeF canvas = QSizeF(target.width() / scale, target.height() / scale);
setUpdatesEnabled(false);
redraw(canvas);
@ -374,22 +384,26 @@ void GraphView::updateSliderPosition()
_slider->setVisible(false);
}
updateSliderInfo();
if (_slider->isVisible())
updateSliderInfo();
}
void GraphView::updateSliderInfo()
{
_sliderInfo->setVisible(_visible.count() == 1);
if (!_sliderInfo->isVisible())
return;
qreal r, y;
QRectF br(_visible.first()->bounds());
if (br.height() < _minYRange)
br.adjust(0, -(_minYRange/2 - br.height()/2), 0,
_minYRange/2 - br.height()/2);
if (_visible.count() > 1) {
r = 0;
y = 0;
} else {
QRectF br(_visible.first()->bounds());
if (br.height() < _minYRange)
br.adjust(0, -(_minYRange/2 - br.height()/2), 0,
_minYRange/2 - br.height()/2);
qreal y = _visible.first()->yAtX(_sliderPos);
qreal r = (y - br.bottom()) / br.height();
y = _visible.first()->yAtX(_sliderPos);
r = (y - br.bottom()) / br.height();
}
qreal pos = (_sliderPos / bounds().width()) * _slider->area().width();
SliderInfoItem::Side s = (pos + _sliderInfo->boundingRect().width()
@ -397,8 +411,11 @@ void GraphView::updateSliderInfo()
_sliderInfo->setSide(s);
_sliderInfo->setPos(QPointF(0, _slider->boundingRect().height() * r));
_sliderInfo->setText(QString::number(-y * _yScale + _yOffset, 'f',
_precision));
_sliderInfo->setText(_graphType == Time ? Format::timeSpan(_sliderPos,
bounds().width() > 3600) : QString::number(_sliderPos * _xScale, 'f', 1)
+ UNIT_SPACE + _xUnits, (_visible.count() > 1) ? QString()
: QString::number(-y * _yScale + _yOffset, 'f', _precision) + UNIT_SPACE
+ _yUnits);
}
void GraphView::emitSliderPositionChanged(const QPointF &pos)
@ -444,8 +461,11 @@ void GraphView::setPalette(const Palette &palette)
_palette = palette;
_palette.reset();
for (int i = 0; i < _graphs.count(); i++)
_graphs.at(i)->setColor(_palette.nextColor());
for (int i = 0; i < _graphs.count(); i++) {
QColor color(_palette.nextColor());
color.setAlpha(255);
_graphs.at(i)->setColor(color);
}
}
void GraphView::setGraphWidth(int width)
@ -454,6 +474,8 @@ void GraphView::setGraphWidth(int width)
for (int i = 0; i < _graphs.count(); i++)
_graphs.at(i)->setWidth(width);
redraw();
}
void GraphView::useOpenGL(bool use)
@ -463,3 +485,14 @@ void GraphView::useOpenGL(bool use)
else
setViewport(new QWidget);
}
void GraphView::useAntiAliasing(bool use)
{
setRenderHint(QPainter::Antialiasing, use);
}
void GraphView::setSliderColor(const QColor &color)
{
_slider->setColor(color);
_sliderInfo->setColor(color);
}

View File

@ -4,9 +4,9 @@
#include <QGraphicsView>
#include <QList>
#include <QSet>
#include "data/graph.h"
#include "palette.h"
#include "units.h"
#include "graph.h"
class AxisItem;
@ -25,18 +25,30 @@ public:
GraphView(QWidget *parent = 0);
~GraphView();
void loadGraph(const Graph &graph, PathItem *path, int id = 0);
int count() const {return _graphs.count();}
void redraw();
bool isEmpty() const {return _graphs.isEmpty();}
void clear();
void plot(QPainter *painter, const QRectF &target, qreal scale);
void setPalette(const Palette &palette);
void setGraphWidth(int width);
void showGrid(bool show);
void showSliderInfo(bool show);
void useOpenGL(bool use);
void useAntiAliasing(bool use);
void setSliderPosition(qreal pos);
void setSliderColor(const QColor &color);
signals:
void sliderPositionChanged(qreal);
protected:
void addGraph(GraphItem *graph, PathItem *path, int id = 0);
void showGraph(bool show, int id = 0);
void setGraphType(GraphType type);
void setUnits(Units units);
void showGrid(bool show);
void setPalette(const Palette &palette);
void setGraphWidth(int width);
const QString &yLabel() const {return _yLabel;}
const QString &yUnits() const {return _yUnits;}
@ -50,23 +62,16 @@ public:
void setSliderPrecision(int precision) {_precision = precision;}
void setMinYRange(qreal range) {_minYRange = range;}
qreal sliderPosition() const {return _sliderPos;}
void setSliderPosition(qreal pos);
void plot(QPainter *painter, const QRectF &target);
void useOpenGL(bool use);
signals:
void sliderPositionChanged(qreal);
protected:
QRectF bounds() const;
void redraw();
void redraw(const QSizeF &size);
void addInfo(const QString &key, const QString &value);
void clearInfo();
void skipColor() {_palette.nextColor();}
QList<GraphItem*> _graphs;
GraphType _graphType;
private slots:
void emitSliderPositionChanged(const QPointF &pos);
void newSliderPosition(const QPointF &pos);
@ -83,6 +88,7 @@ private:
void resizeEvent(QResizeEvent *);
void mousePressEvent(QMouseEvent *);
Units _units;
qreal _xScale, _yScale;
qreal _yOffset;
QString _xUnits, _yUnits;
@ -99,15 +105,11 @@ private:
InfoItem *_info;
GridItem *_grid;
QList<GraphItem*> _graphs;
QList<GraphItem*> _visible;
QSet<int> _hide;
QRectF _bounds;
Palette _palette;
int _width;
Units _units;
GraphType _graphType;
};
#endif // GRAPHVIEW_H

File diff suppressed because it is too large Load Diff

View File

@ -6,14 +6,13 @@
#include <QList>
#include <QDate>
#include <QPrinter>
#include "data/graph.h"
#include "data/poi.h"
#include "units.h"
#include "timetype.h"
#include "graph.h"
#include "poi.h"
#include "exportdialog.h"
#include "optionsdialog.h"
class QMenu;
class QToolBar;
class QTabWidget;
@ -24,7 +23,7 @@ class QSignalMapper;
class QPrinter;
class FileBrowser;
class GraphTab;
class PathView;
class MapView;
class Map;
class MapList;
@ -51,12 +50,12 @@ private slots:
void closePOIFiles();
void showGraphs(bool show);
void showGraphGrids(bool show);
void showGraphSliderInfo(bool show);
void showToolbars(bool show);
void showFullscreen(bool show);
void showTracks(bool show);
void showRoutes(bool show);
void loadMap();
void clearMapCache();
void nextMap();
void prevMap();
void openOptions();
@ -82,7 +81,6 @@ private slots:
private:
typedef QPair<QDate, QDate> DateRange;
void loadDatums();
void loadMaps();
void loadPOIs();
void closeFiles();
@ -95,7 +93,7 @@ private:
void createMenus();
void createToolBars();
void createStatusBar();
void createPathView();
void createMapView();
void createGraphTabs();
void createBrowser();
@ -106,7 +104,7 @@ private:
void updateWindowTitle();
void updateNavigationActions();
void updateGraphTabs();
void updatePathView();
void updateMapView();
TimeType timeType() const;
Units units() const;
@ -121,8 +119,6 @@ private:
void readSettings();
void writeSettings();
const QString fileFormats() const;
void keyPressEvent(QKeyEvent *event);
void closeEvent(QCloseEvent *event);
void dragEnterEvent(QDragEnterEvent *event);
@ -158,6 +154,7 @@ private:
QAction *_clearMapCacheAction;
QAction *_showGraphsAction;
QAction *_showGraphGridAction;
QAction *_showGraphSliderInfoAction;
QAction *_distanceGraphAction;
QAction *_timeGraphAction;
QAction *_showToolbarsAction;
@ -188,17 +185,17 @@ private:
QLabel *_distanceLabel;
QLabel *_timeLabel;
PathView *_pathView;
MapView *_mapView;
QTabWidget *_graphTabWidget;
QList<GraphTab*> _tabs;
POI *_poi;
MapList *_ml;
Map *_map;
FileBrowser *_browser;
QList<QString> _files;
Map *_map;
int _trackCount;
int _routeCount;
int _waypointCount;

View File

@ -1,10 +1,10 @@
#include "data.h"
#include "data/data.h"
#include "heartrategraphitem.h"
#include "heartrategraph.h"
HeartRateGraph::HeartRateGraph(QWidget *parent) : GraphTab(parent)
{
_units = Metric;
_showTracks = true;
GraphView::setYUnits(tr("1/min"));
@ -28,21 +28,16 @@ void HeartRateGraph::loadData(const Data &data, const QList<PathItem *> &paths)
{
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) {
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));
HeartRateGraphItem *gi = new HeartRateGraphItem(graph, _graphType);
GraphView::addGraph(gi, paths.at(i));
GraphView::loadGraph(graph, paths.at(i));
_avg.append(QPointF(data.tracks().at(i)->distance(), gi->avg()));
}
for (int i = 0; i < data.routes().count(); i++)

View File

@ -22,7 +22,6 @@ private:
QList<QPointF> _avg;
enum Units _units;
bool _showTracks;
};

View File

@ -0,0 +1,26 @@
#include "tooltip.h"
#include "heartrategraphitem.h"
HeartRateGraphItem::HeartRateGraphItem(const Graph &graph, GraphType type,
QGraphicsItem *parent) : GraphItem(graph, type, parent)
{
qreal sum = 0;
for (int j = 1; j < graph.size(); j++)
sum += graph.at(j).y() * (graph.at(j).s() - graph.at(j-1).s());
_avg = sum/graph.last().s();
setToolTip(toolTip());
}
QString HeartRateGraphItem::toolTip() const
{
ToolTip tt;
tt.insert(tr("Maximum"), QString::number(max(), 'f', 0)
+ UNIT_SPACE + tr("1/min"));
tt.insert(tr("Average"), QString::number(avg(), 'f', 0)
+ UNIT_SPACE + tr("1/min"));
return tt.toString();
}

View File

@ -0,0 +1,23 @@
#ifndef HEARTRATEGRAPHITEM_H
#define HEARTRATEGRAPHITEM_H
#include "graphitem.h"
class HeartRateGraphItem : public GraphItem
{
Q_OBJECT
public:
HeartRateGraphItem(const Graph &graph, GraphType type,
QGraphicsItem *parent = 0);
qreal max() const {return -bounds().top();}
qreal avg() const {return _avg;}
private:
QString toolTip() const;
qreal _avg;
};
#endif // HEARTRATEGRAPHITEM_H

View File

@ -10,7 +10,7 @@
#define CLOSE_FILE_ICON ":/icons/dialog-close.png"
#define SHOW_POI_ICON ":/icons/flag.png"
#define SHOW_MAP_ICON ":/icons/applications-internet.png"
#define SHOW_GRAPHS_ICON ":/icons/office-chart-line-stacked.png"
#define SHOW_GRAPHS_ICON ":/icons/office-chart-line.png"
#define QUIT_ICON ":/icons/application-exit.png"
#define RELOAD_FILE_ICON ":/icons/view-refresh.png"
#define NEXT_FILE_ICON ":/icons/arrow-right.png"
@ -24,5 +24,6 @@
#define POI_ICON ":/icons/flag_48.png"
#define SYSTEM_ICON ":/icons/system-run.png"
#define PRINT_EXPORT_ICON ":/icons/document-print-preview.png"
#define DATA_ICON ":/icons/view-filter.png"
#endif /* ICONS_H */

View File

@ -13,6 +13,9 @@
#define ZOOM_IN QKeySequence::ZoomIn
#define ZOOM_OUT QKeySequence::ZoomOut
#define TOGGLE_GRAPH_TYPE_KEY Qt::Key_X
#define TOGGLE_TIME_TYPE_KEY Qt::Key_T
#define QUIT_SHORTCUT QKeySequence(QKeySequence::Quit)
#define OPEN_SHORTCUT QKeySequence(QKeySequence::Open)
#define CLOSE_SHORTCUT QKeySequence(QKeySequence::Close)
@ -23,8 +26,6 @@
#define NEXT_MAP_SHORTCUT QKeySequence(QKeySequence::Forward)
#define PREV_MAP_SHORTCUT QKeySequence(QKeySequence::Back)
#define SHOW_GRAPHS_SHORTCUT QKeySequence(Qt::CTRL + Qt::Key_G)
#define DISTANCE_GRAPH_SHORTCUT QKeySequence(Qt::CTRL + Qt::Key_D)
#define TIME_GRAPH_SHORTCUT QKeySequence(Qt::CTRL + Qt::Key_T)
#ifdef Q_OS_MAC
#define FULLSCREEN_SHORTCUT QKeySequence(Qt::META + Qt::CTRL + Qt::Key_F)

View File

@ -2,38 +2,27 @@
#include <QGraphicsScene>
#include <QWheelEvent>
#include <QApplication>
#include <QPixmapCache>
#include <QScrollBar>
#include "data/poi.h"
#include "data/data.h"
#include "map/map.h"
#include "opengl.h"
#include "misc.h"
#include "poi.h"
#include "data.h"
#include "map.h"
#include "emptymap.h"
#include "trackitem.h"
#include "routeitem.h"
#include "waypointitem.h"
#include "scaleitem.h"
#include "keys.h"
#include "pathview.h"
#include "mapview.h"
#define MAX_ZOOM 1
#define MIN_ZOOM -3
#define MARGIN 10.0
#define SCALE_OFFSET 7
static void unite(QRectF &rect, const QPointF &p)
{
if (p.x() < rect.left())
rect.setLeft(p.x());
if (p.x() > rect.right())
rect.setRight(p.x());
if (p.y() > rect.bottom())
rect.setBottom(p.y());
if (p.y() < rect.top())
rect.setTop(p.y());
}
#define MAX_DIGITAL_ZOOM 2
#define MIN_DIGITAL_ZOOM -3
#define MARGIN 10.0
#define SCALE_OFFSET 7
PathView::PathView(Map *map, POI *poi, QWidget *parent)
: QGraphicsView(parent)
MapView::MapView(Map *map, POI *poi, QWidget *parent)
: QGraphicsView(parent)
{
Q_ASSERT(map != 0);
Q_ASSERT(poi != 0);
@ -50,13 +39,19 @@ PathView::PathView(Map *map, POI *poi, QWidget *parent)
_mapScale = new ScaleItem();
_mapScale->setZValue(2.0);
_scene->addItem(_mapScale);
_map = map;
_map->load();
connect(_map, SIGNAL(loaded()), this, SLOT(reloadMap()));
_poi = poi;
connect(_map, SIGNAL(loaded()), this, SLOT(redraw()));
connect(_poi, SIGNAL(pointsChanged()), this, SLOT(updatePOI()));
_units = Metric;
_opacity = 1.0;
_backgroundColor = Qt::white;
_markerColor = Qt::red;
_showMap = true;
_showTracks = true;
@ -71,21 +66,39 @@ PathView::PathView(Map *map, POI *poi, QWidget *parent)
_routeWidth = 3;
_trackStyle = Qt::SolidLine;
_routeStyle = Qt::DashLine;
_waypointSize = 8;
_waypointColor = Qt::black;
_poiSize = 8;
_poiColor = Qt::black;
_plot = false;
_digitalZoom = 0;
_map->setBackgroundColor(_backgroundColor);
_scene->setSceneRect(_map->bounds());
_res = _map->resolution(_scene->sceneRect().center());
centerOn(_scene->sceneRect().center());
}
PathView::~PathView()
void MapView::centerOn(const QPointF &pos)
{
if (_mapScale->scene() != _scene)
delete _mapScale;
QGraphicsView::centerOn(pos);
/* Fix the offset caused by QGraphicsView::centerOn() approximation */
QPointF center = mapToScene(viewport()->rect().center());
QPoint offset((int)(pos.x() - center.x()), (int)(pos.y() - center.y()));
if (qAbs(offset.x()) == 1)
horizontalScrollBar()->setValue(horizontalScrollBar()->value()
+ offset.x());
if (qAbs(offset.y()) == 1)
verticalScrollBar()->setValue(verticalScrollBar()->value()
+ offset.y());
_res = _map->resolution(pos);
_mapScale->setResolution(_res);
}
PathItem *PathView::addTrack(const Track &track)
PathItem *MapView::addTrack(const Track &track)
{
if (track.isNull()) {
_palette.nextColor();
@ -98,16 +111,19 @@ PathItem *PathView::addTrack(const Track &track)
ti->setColor(_palette.nextColor());
ti->setWidth(_trackWidth);
ti->setStyle(_trackStyle);
ti->setUnits(_units);
ti->setVisible(_showTracks);
ti->setDigitalZoom(_digitalZoom);
ti->setMarkerColor(_markerColor);
_scene->addItem(ti);
addPOI(_poi->points(ti->path()));
if (_showTracks)
addPOI(_poi->points(ti->path()));
return ti;
}
PathItem *PathView::addRoute(const Route &route)
PathItem *MapView::addRoute(const Route &route)
{
if (route.isNull()) {
_palette.nextColor();
@ -120,40 +136,46 @@ PathItem *PathView::addRoute(const Route &route)
ri->setColor(_palette.nextColor());
ri->setWidth(_routeWidth);
ri->setStyle(_routeStyle);
ri->setUnits(_units);
ri->setVisible(_showRoutes);
ri->showWaypoints(_showRouteWaypoints);
ri->showWaypointLabels(_showWaypointLabels);
ri->setDigitalZoom(_digitalZoom);
ri->setMarkerColor(_markerColor);
_scene->addItem(ri);
addPOI(_poi->points(ri->path()));
if (_showRoutes)
addPOI(_poi->points(ri->path()));
return ri;
}
void PathView::addWaypoints(const QList<Waypoint> &waypoints)
void MapView::addWaypoints(const QList<Waypoint> &waypoints)
{
for (int i = 0; i < waypoints.count(); i++) {
const Waypoint &w = waypoints.at(i);
WaypointItem *wi = new WaypointItem(w, _map);
_waypoints.append(wi);
Coordinates c = wi->waypoint().coordinates();
updateWaypointsBoundingRect(QPointF(c.lon(), c.lat()));
_wr.unite(wi->waypoint().coordinates());
wi->setZValue(1);
wi->setSize(_waypointSize);
wi->setColor(_waypointColor);
wi->showLabel(_showWaypointLabels);
wi->setUnits(_units);
wi->setVisible(_showWaypoints);
wi->setDigitalZoom(_digitalZoom);
_scene->addItem(wi);
}
addPOI(_poi->points(waypoints));
if (_showWaypoints)
addPOI(_poi->points(w));
}
}
QList<PathItem *> PathView::loadData(const Data &data)
QList<PathItem *> MapView::loadData(const Data &data)
{
QList<PathItem *> paths;
qreal scale = _map->zoom();
qreal zoom = _map->zoom();
for (int i = 0; i < data.tracks().count(); i++)
paths.append(addTrack(*(data.tracks().at(i))));
@ -164,59 +186,35 @@ QList<PathItem *> PathView::loadData(const Data &data)
if (_tracks.empty() && _routes.empty() && _waypoints.empty())
return paths;
if (mapScale() != scale)
if (mapZoom() != zoom)
rescale();
else
updatePOIVisibility();
QPointF center = contentCenter();
centerOn(center);
_res = _map->resolution(center);
_mapScale->setResolution(_res);
if (_mapScale->scene() != _scene)
_scene->addItem(_mapScale);
centerOn(contentCenter());
return paths;
}
void PathView::updateWaypointsBoundingRect(const QPointF &wp)
qreal MapView::mapZoom() const
{
if (_wr.isNull()) {
if (_wp.isNull())
_wp = wp;
else {
_wr = QRectF(_wp, wp).normalized();
_wp = QPointF();
}
} else
unite(_wr, wp);
RectC br = _tr | _rr | _wr;
return _map->zoomFit(viewport()->size() - QSize(2*MARGIN, 2*MARGIN),
br.isNull() ? RectC(_map->xy2ll(sceneRect().topLeft()),
_map->xy2ll(sceneRect().bottomRight())) : br);
}
qreal PathView::mapScale() const
QPointF MapView::contentCenter() const
{
QRectF br = _tr | _rr | _wr;
if (!br.isNull() && !_wp.isNull())
unite(br, _wp);
RectC br = _tr | _rr | _wr;
return _map->zoomFit(viewport()->size() - QSize(MARGIN/2, MARGIN/2), br);
return br.isNull() ? sceneRect().center() : _map->ll2xy(br.center());
}
QPointF PathView::contentCenter() const
void MapView::updatePOIVisibility()
{
QRectF br = _tr | _rr | _wr;
if (!br.isNull() && !_wp.isNull())
unite(br, _wp);
if (br.isNull())
return _map->ll2xy(_wp);
else
return _map->ll2xy(br.center());
}
void PathView::updatePOIVisibility()
{
QHash<Waypoint, WaypointItem*>::const_iterator it, jt;
QHash<SearchPointer<Waypoint>, WaypointItem*>::const_iterator it, jt;
if (!_showPOI)
return;
@ -235,7 +233,7 @@ void PathView::updatePOIVisibility()
}
}
void PathView::rescale()
void MapView::rescale()
{
_scene->setSceneRect(_map->bounds());
resetCachedContent();
@ -247,14 +245,14 @@ void PathView::rescale()
for (int i = 0; i < _waypoints.size(); i++)
_waypoints.at(i)->setMap(_map);
QHash<Waypoint, WaypointItem*>::const_iterator it;
QHash<SearchPointer<Waypoint>, WaypointItem*>::const_iterator it;
for (it = _pois.constBegin(); it != _pois.constEnd(); it++)
it.value()->setMap(_map);
updatePOIVisibility();
}
void PathView::setPalette(const Palette &palette)
void MapView::setPalette(const Palette &palette)
{
_palette = palette;
_palette.reset();
@ -265,18 +263,23 @@ void PathView::setPalette(const Palette &palette)
_routes.at(i)->setColor(_palette.nextColor());
}
void PathView::setMap(Map *map)
void MapView::setMap(Map *map)
{
QPointF pos = mapToScene(viewport()->rect().center());
Coordinates center = _map->xy2ll(pos);
qreal resolution = _map->resolution(pos);
_map->unload();
disconnect(_map, SIGNAL(loaded()), this, SLOT(redraw()));
disconnect(_map, SIGNAL(loaded()), this, SLOT(reloadMap()));
_map = map;
_map->load();
connect(_map, SIGNAL(loaded()), this, SLOT(redraw()));
_map->setBackgroundColor(_backgroundColor);
connect(_map, SIGNAL(loaded()), this, SLOT(reloadMap()));
resetDigitalZoom();
digitalZoom(0);
mapScale();
_map->zoomFit(resolution, center);
_scene->setSceneRect(_map->bounds());
for (int i = 0; i < _tracks.size(); i++)
@ -286,21 +289,18 @@ void PathView::setMap(Map *map)
for (int i = 0; i < _waypoints.size(); i++)
_waypoints.at(i)->setMap(map);
QHash<Waypoint, WaypointItem*>::const_iterator it;
QHash<SearchPointer<Waypoint>, WaypointItem*>::const_iterator it;
for (it = _pois.constBegin(); it != _pois.constEnd(); it++)
it.value()->setMap(_map);
updatePOIVisibility();
QPointF center = contentCenter();
centerOn(center);
_res = _map->resolution(center);
_mapScale->setResolution(_res);
centerOn(_map->ll2xy(center));
resetCachedContent();
QPixmapCache::clear();
}
void PathView::setPOI(POI *poi)
void MapView::setPOI(POI *poi)
{
disconnect(_poi, SIGNAL(pointsChanged()), this, SLOT(updatePOI()));
connect(poi, SIGNAL(pointsChanged()), this, SLOT(updatePOI()));
@ -310,9 +310,9 @@ void PathView::setPOI(POI *poi)
updatePOI();
}
void PathView::updatePOI()
void MapView::updatePOI()
{
QHash<Waypoint, WaypointItem*>::const_iterator it;
QHash<SearchPointer<Waypoint>, WaypointItem*>::const_iterator it;
for (it = _pois.constBegin(); it != _pois.constEnd(); it++) {
_scene->removeItem(it.value());
@ -320,35 +320,41 @@ void PathView::updatePOI()
}
_pois.clear();
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 (_showTracks)
for (int i = 0; i < _tracks.size(); i++)
addPOI(_poi->points(_tracks.at(i)->path()));
if (_showRoutes)
for (int i = 0; i < _routes.size(); i++)
addPOI(_poi->points(_routes.at(i)->path()));
if (_showWaypoints)
for (int i = 0; i< _waypoints.size(); i++)
addPOI(_poi->points(_waypoints.at(i)->waypoint()));
updatePOIVisibility();
}
void PathView::addPOI(const QVector<Waypoint> &waypoints)
void MapView::addPOI(const QList<Waypoint> &waypoints)
{
for (int i = 0; i < waypoints.size(); i++) {
const Waypoint &w = waypoints.at(i);
if (_pois.contains(w))
if (_pois.contains(SearchPointer<Waypoint>(&w)))
continue;
WaypointItem *pi = new WaypointItem(w, _map);
pi->setZValue(1);
pi->setSize(_poiSize);
pi->setColor(_poiColor);
pi->showLabel(_showPOILabels);
pi->setVisible(_showPOI);
pi->setDigitalZoom(_digitalZoom);
_scene->addItem(pi);
_pois.insert(w, pi);
_pois.insert(SearchPointer<Waypoint>(&(pi->waypoint())), pi);
}
}
void PathView::setUnits(enum Units units)
void MapView::setUnits(enum Units units)
{
_units = units;
@ -361,41 +367,28 @@ void PathView::setUnits(enum Units units)
for (int i = 0; i < _waypoints.size(); i++)
_waypoints.at(i)->setUnits(units);
QHash<Waypoint, WaypointItem*>::const_iterator it;
QHash<SearchPointer<Waypoint>, WaypointItem*>::const_iterator it;
for (it = _pois.constBegin(); it != _pois.constEnd(); it++)
it.value()->setUnits(units);
}
void PathView::redraw()
void MapView::clearMapCache()
{
_map->clearCache();
resetCachedContent();
}
void PathView::resetDigitalZoom()
void MapView::digitalZoom(int zoom)
{
QHash<Waypoint, WaypointItem*>::const_iterator it;
QHash<SearchPointer<Waypoint>, WaypointItem*>::const_iterator it;
_digitalZoom = 0;
resetTransform();
for (int i = 0; i < _tracks.size(); i++)
_tracks.at(i)->setDigitalZoom(0);
for (int i = 0; i < _routes.size(); i++)
_routes.at(i)->setDigitalZoom(0);
for (int i = 0; i < _waypoints.size(); i++)
_waypoints.at(i)->setDigitalZoom(0);
for (it = _pois.constBegin(); it != _pois.constEnd(); it++)
it.value()->setDigitalZoom(0);
_mapScale->setDigitalZoom(0);
}
void PathView::digitalZoom(int zoom)
{
QHash<Waypoint, WaypointItem*>::const_iterator it;
_digitalZoom += zoom;
scale(pow(2, zoom), pow(2, zoom));
if (zoom) {
_digitalZoom += zoom;
scale(pow(2, zoom), pow(2, zoom));
} else {
_digitalZoom = 0;
resetTransform();
}
for (int i = 0; i < _tracks.size(); i++)
_tracks.at(i)->setDigitalZoom(_digitalZoom);
@ -409,14 +402,14 @@ void PathView::digitalZoom(int zoom)
_mapScale->setDigitalZoom(_digitalZoom);
}
void PathView::zoom(int zoom, const QPoint &pos, const Coordinates &c)
void MapView::zoom(int zoom, const QPoint &pos, const Coordinates &c)
{
bool shift = QApplication::keyboardModifiers() & Qt::ShiftModifier;
if (_digitalZoom) {
if (((_digitalZoom > 0 && zoom > 0) && (!shift || _digitalZoom
>= MAX_ZOOM)) || ((_digitalZoom < 0 && zoom < 0) && (!shift
|| _digitalZoom <= MIN_ZOOM)))
>= MAX_DIGITAL_ZOOM)) || ((_digitalZoom < 0 && zoom < 0) && (!shift
|| _digitalZoom <= MIN_DIGITAL_ZOOM)))
return;
digitalZoom(zoom);
@ -426,15 +419,8 @@ void PathView::zoom(int zoom, const QPoint &pos, const Coordinates &c)
ns = (zoom > 0) ? _map->zoomIn() : _map->zoomOut();
if (ns != os) {
QPoint offset = pos - viewport()->rect().center();
rescale();
QPointF center = _map->ll2xy(c) - offset;
centerOn(center);
_res = _map->resolution(center);
_mapScale->setResolution(_res);
centerOn(_map->ll2xy(c) - (pos - viewport()->rect().center()));
} else {
if (shift)
digitalZoom(zoom);
@ -442,7 +428,7 @@ void PathView::zoom(int zoom, const QPoint &pos, const Coordinates &c)
}
}
void PathView::wheelEvent(QWheelEvent *event)
void MapView::wheelEvent(QWheelEvent *event)
{
static int deg = 0;
@ -455,7 +441,7 @@ void PathView::wheelEvent(QWheelEvent *event)
zoom((event->delta() > 0) ? 1 : -1, event->pos(), c);
}
void PathView::mouseDoubleClickEvent(QMouseEvent *event)
void MapView::mouseDoubleClickEvent(QMouseEvent *event)
{
if (event->button() != Qt::LeftButton && event->button() != Qt::RightButton)
return;
@ -464,11 +450,11 @@ void PathView::mouseDoubleClickEvent(QMouseEvent *event)
zoom((event->button() == Qt::LeftButton) ? 1 : -1, event->pos(), c);
}
void PathView::keyPressEvent(QKeyEvent *event)
void MapView::keyPressEvent(QKeyEvent *event)
{
int z;
QPoint pos = QRect(QPoint(), viewport()->size()).center();
QPoint pos = viewport()->rect().center();
Coordinates c = _map->xy2ll(mapToScene(pos));
if (event->matches(ZOOM_IN))
@ -476,7 +462,7 @@ void PathView::keyPressEvent(QKeyEvent *event)
else if (event->matches(ZOOM_OUT))
z = -1;
else if (_digitalZoom && event->key() == Qt::Key_Escape) {
resetDigitalZoom();
digitalZoom(0);
return;
} else {
QGraphicsView::keyPressEvent(event);
@ -486,13 +472,23 @@ void PathView::keyPressEvent(QKeyEvent *event)
zoom(z, pos, c);
}
void PathView::plot(QPainter *painter, const QRectF &target)
void MapView::plot(QPainter *painter, const QRectF &target, qreal scale,
bool hires)
{
QRect orig, adj;
qreal ratio, diff;
qreal ratio, diff, origRes, q;
QPointF origScene, origPos;
Coordinates origLL;
// Enter plot mode
setUpdatesEnabled(false);
_plot = true;
_map->setBlockingMode(true);
// Compute sizes & ratios
orig = viewport()->rect();
origPos = _mapScale->pos();
if (orig.height() * (target.width() / target.height()) - orig.width() < 0) {
ratio = target.height() / target.width();
@ -503,69 +499,106 @@ void PathView::plot(QPainter *painter, const QRectF &target)
diff = (orig.height() * ratio) - orig.width();
adj = orig.adjusted(-diff/2, 0, diff/2, 0);
}
q = (target.width() / scale) / adj.width();
setUpdatesEnabled(false);
_plot = true;
_map->setBlockingMode(true);
// Adjust the view for printing
if (hires) {
origScene = mapToScene(orig.center());
origLL = _map->xy2ll(origScene);
origRes = _map->resolution(origScene);
QPointF pos = _mapScale->pos();
_mapScale->setPos(mapToScene(QPoint(adj.bottomRight() + QPoint(
-(SCALE_OFFSET + _mapScale->boundingRect().width()),
-(SCALE_OFFSET + _mapScale->boundingRect().height())))));
QPointF s(painter->device()->logicalDpiX()
/ (qreal)metric(QPaintDevice::PdmDpiX),
painter->device()->logicalDpiY()
/ (qreal)metric(QPaintDevice::PdmDpiY));
adj = QRect(0, 0, adj.width() * s.x(), adj.height() * s.y());
_map->zoomFit(adj.size(), _tr | _rr | _wr);
rescale();
QPointF center = contentCenter();
centerOn(center);
adj.moveCenter(mapFromScene(center));
_mapScale->setDigitalZoom(-log2(s.x() / q));
_mapScale->setPos(mapToScene(QPoint(adj.bottomRight() + QPoint(
-(SCALE_OFFSET + _mapScale->boundingRect().width()) * (s.x() / q),
-(SCALE_OFFSET + _mapScale->boundingRect().height()) * (s.x() / q)))));
} else {
_mapScale->setDigitalZoom(-log2(1.0 / q));
_mapScale->setPos(mapToScene(QPoint(adj.bottomRight() + QPoint(
-(SCALE_OFFSET + _mapScale->boundingRect().width()) / q ,
-(SCALE_OFFSET + _mapScale->boundingRect().height()) / q))));
}
// Print the view
render(painter, target, adj);
_mapScale->setPos(pos);
// Revert view changes to display mode
if (hires) {
_map->zoomFit(origRes, origLL);
rescale();
centerOn(origScene);
}
_mapScale->setDigitalZoom(0);
_mapScale->setPos(origPos);
// Exit plot mode
_map->setBlockingMode(false);
_plot = false;
setUpdatesEnabled(true);
}
void PathView::clear()
void MapView::clear()
{
if (_mapScale->scene() == _scene)
_scene->removeItem(_mapScale);
_pois.clear();
_tracks.clear();
_routes.clear();
_waypoints.clear();
_scene->removeItem(_mapScale);
_scene->clear();
_scene->addItem(_mapScale);
_palette.reset();
_tr = QRectF(); _rr = QRectF(); _wr = QRectF();
_wp = QPointF();
_tr = RectC();
_rr = RectC();
_wr = RectC();
resetDigitalZoom();
resetCachedContent();
digitalZoom(0);
}
void PathView::showTracks(bool show)
void MapView::showTracks(bool show)
{
_showTracks = show;
for (int i = 0; i < _tracks.count(); i++)
_tracks.at(i)->setVisible(show);
updatePOI();
}
void PathView::showRoutes(bool show)
void MapView::showRoutes(bool show)
{
_showRoutes = show;
for (int i = 0; i < _routes.count(); i++)
_routes.at(i)->setVisible(show);
updatePOI();
}
void PathView::showWaypoints(bool show)
void MapView::showWaypoints(bool show)
{
_showWaypoints = show;
for (int i = 0; i < _waypoints.count(); i++)
_waypoints.at(i)->setVisible(show);
updatePOI();
}
void PathView::showWaypointLabels(bool show)
void MapView::showWaypointLabels(bool show)
{
_showWaypointLabels = show;
@ -576,7 +609,7 @@ void PathView::showWaypointLabels(bool show)
_routes.at(i)->showWaypointLabels(show);
}
void PathView::showRouteWaypoints(bool show)
void MapView::showRouteWaypoints(bool show)
{
_showRouteWaypoints = show;
@ -584,42 +617,42 @@ void PathView::showRouteWaypoints(bool show)
_routes.at(i)->showWaypoints(show);
}
void PathView::showMap(bool show)
void MapView::showMap(bool show)
{
_showMap = show;
resetCachedContent();
}
void PathView::showPOI(bool show)
void MapView::showPOI(bool show)
{
_showPOI = show;
QHash<Waypoint, WaypointItem*>::const_iterator it;
QHash<SearchPointer<Waypoint>, WaypointItem*>::const_iterator it;
for (it = _pois.constBegin(); it != _pois.constEnd(); it++)
it.value()->setVisible(show);
updatePOIVisibility();
}
void PathView::showPOILabels(bool show)
void MapView::showPOILabels(bool show)
{
_showPOILabels = show;
QHash<Waypoint, WaypointItem*>::const_iterator it;
QHash<SearchPointer<Waypoint>, WaypointItem*>::const_iterator it;
for (it = _pois.constBegin(); it != _pois.constEnd(); it++)
it.value()->showLabel(show);
updatePOIVisibility();
}
void PathView::setPOIOverlap(bool overlap)
void MapView::setPOIOverlap(bool overlap)
{
_overlapPOIs = overlap;
updatePOIVisibility();
}
void PathView::setTrackWidth(int width)
void MapView::setTrackWidth(int width)
{
_trackWidth = width;
@ -627,7 +660,7 @@ void PathView::setTrackWidth(int width)
_tracks.at(i)->setWidth(width);
}
void PathView::setRouteWidth(int width)
void MapView::setRouteWidth(int width)
{
_routeWidth = width;
@ -635,7 +668,7 @@ void PathView::setRouteWidth(int width)
_routes.at(i)->setWidth(width);
}
void PathView::setTrackStyle(Qt::PenStyle style)
void MapView::setTrackStyle(Qt::PenStyle style)
{
_trackStyle = style;
@ -643,7 +676,7 @@ void PathView::setTrackStyle(Qt::PenStyle style)
_tracks.at(i)->setStyle(style);
}
void PathView::setRouteStyle(Qt::PenStyle style)
void MapView::setRouteStyle(Qt::PenStyle style)
{
_routeStyle = style;
@ -651,30 +684,82 @@ void PathView::setRouteStyle(Qt::PenStyle style)
_routes.at(i)->setStyle(style);
}
void PathView::drawBackground(QPainter *painter, const QRectF &rect)
void MapView::setWaypointSize(int size)
{
if (_showMap)
_map->draw(painter, rect);
else
painter->fillRect(rect, Qt::white);
_waypointSize = size;
for (int i = 0; i < _waypoints.size(); i++)
_waypoints.at(i)->setSize(size);
}
void PathView::resizeEvent(QResizeEvent *event)
void MapView::setWaypointColor(const QColor &color)
{
qreal scale = _map->zoom();
if (mapScale() != scale)
_waypointColor = color;
for (int i = 0; i < _waypoints.size(); i++)
_waypoints.at(i)->setColor(color);
}
void MapView::setPOISize(int size)
{
QHash<SearchPointer<Waypoint>, WaypointItem*>::const_iterator it;
_poiSize = size;
for (it = _pois.constBegin(); it != _pois.constEnd(); it++)
it.value()->setSize(size);
}
void MapView::setPOIColor(const QColor &color)
{
QHash<SearchPointer<Waypoint>, WaypointItem*>::const_iterator it;
_poiColor = color;
for (it = _pois.constBegin(); it != _pois.constEnd(); it++)
it.value()->setColor(color);
}
void MapView::setMapOpacity(int opacity)
{
_opacity = opacity / 100.0;
resetCachedContent();
}
void MapView::setBackgroundColor(const QColor &color)
{
_backgroundColor = color;
_map->setBackgroundColor(color);
resetCachedContent();
}
void MapView::drawBackground(QPainter *painter, const QRectF &rect)
{
if (_showMap) {
QRectF ir = rect.intersected(_map->bounds());
if (_opacity < 1.0 || ir != rect)
painter->fillRect(rect, _backgroundColor);
if (_opacity < 1.0)
painter->setOpacity(_opacity);
_map->draw(painter, ir);
} else
painter->fillRect(rect, _backgroundColor);
}
void MapView::resizeEvent(QResizeEvent *event)
{
QGraphicsView::resizeEvent(event);
qreal zoom = _map->zoom();
if (mapZoom() != zoom)
rescale();
QPointF center = contentCenter();
centerOn(center);
_res = _map->resolution(center);
_mapScale->setResolution(_res);
QGraphicsView::resizeEvent(event);
centerOn(contentCenter());
}
void PathView::paintEvent(QPaintEvent *event)
void MapView::paintEvent(QPaintEvent *event)
{
QPointF scenePos = mapToScene(rect().bottomRight() + QPoint(
-(SCALE_OFFSET + _mapScale->boundingRect().width()),
@ -685,7 +770,7 @@ void PathView::paintEvent(QPaintEvent *event)
QGraphicsView::paintEvent(event);
}
void PathView::scrollContentsBy(int dx, int dy)
void MapView::scrollContentsBy(int dx, int dy)
{
QGraphicsView::scrollContentsBy(dx, dy);
@ -698,10 +783,30 @@ void PathView::scrollContentsBy(int dx, int dy)
}
}
void PathView::useOpenGL(bool use)
void MapView::useOpenGL(bool use)
{
if (use)
setViewport(new OPENGL_WIDGET);
else
setViewport(new QWidget);
}
void MapView::useAntiAliasing(bool use)
{
setRenderHint(QPainter::Antialiasing, use);
}
void MapView::setMarkerColor(const QColor &color)
{
_markerColor = color;
for (int i = 0; i < _tracks.size(); i++)
_tracks.at(i)->setMarkerColor(color);
for (int i = 0; i < _routes.size(); i++)
_routes.at(i)->setMarkerColor(color);
}
void MapView::reloadMap()
{
resetCachedContent();
}

View File

@ -1,13 +1,15 @@
#ifndef TRACKVIEW_H
#define TRACKVIEW_H
#ifndef MAPVIEW_H
#define MAPVIEW_H
#include <QGraphicsView>
#include <QVector>
#include <QHash>
#include <QList>
#include "common/rectc.h"
#include "data/waypoint.h"
#include "searchpointer.h"
#include "units.h"
#include "palette.h"
#include "waypoint.h"
class Data;
class POI;
@ -20,13 +22,12 @@ class WaypointItem;
class ScaleItem;
class PathItem;
class PathView : public QGraphicsView
class MapView : public QGraphicsView
{
Q_OBJECT
public:
PathView(Map *map, POI *poi, QWidget *parent = 0);
~PathView();
MapView(Map *map, POI *poi, QWidget *parent = 0);
QList<PathItem*> loadData(const Data &data);
@ -35,19 +36,25 @@ public:
void setMap(Map *map);
void setUnits(enum Units units);
void plot(QPainter *painter, const QRectF &target);
int trackCount() const {return _tracks.count();}
int routeCount() const {return _routes.count();}
int waypointCount() const {return _waypoints.count();}
void plot(QPainter *painter, const QRectF &target, qreal scale, bool hires);
void clear();
void setTrackWidth(int width);
void setRouteWidth(int width);
void setTrackStyle(Qt::PenStyle style);
void setRouteStyle(Qt::PenStyle style);
void setWaypointSize(int size);
void setWaypointColor(const QColor &color);
void setPOISize(int size);
void setPOIColor(const QColor &color);
void setMapOpacity(int opacity);
void setBackgroundColor(const QColor &color);
void useOpenGL(bool use);
void useAntiAliasing(bool use);
void setMarkerColor(const QColor &color);
public slots:
void redraw();
void showMap(bool show);
void showPOI(bool show);
void setPOIOverlap(bool overlap);
@ -57,30 +64,27 @@ public slots:
void showRoutes(bool show);
void showWaypoints(bool show);
void showRouteWaypoints(bool show);
void setTrackWidth(int width);
void setRouteWidth(int width);
void setTrackStyle(Qt::PenStyle style);
void setRouteStyle(Qt::PenStyle style);
void clearMapCache();
private slots:
void updatePOI();
void reloadMap();
private:
PathItem *addTrack(const Track &track);
PathItem *addRoute(const Route &route);
void addWaypoints(const QList<Waypoint> &waypoints);
void addPOI(const QVector<Waypoint> &waypoints);
void addPOI(const QList<Waypoint> &waypoints);
void loadPOI();
void clearPOI();
qreal mapScale() const;
qreal mapZoom() const;
QPointF contentCenter() const;
void rescale();
void centerOn(const QPointF &pos);
void zoom(int zoom, const QPoint &pos, const Coordinates &c);
void digitalZoom(int zoom);
void resetDigitalZoom();
void updatePOIVisibility();
void updateWaypointsBoundingRect(const QPointF &wp);
void mouseDoubleClickEvent(QMouseEvent *event);
void wheelEvent(QWheelEvent *event);
@ -95,10 +99,9 @@ private:
QList<TrackItem*> _tracks;
QList<RouteItem*> _routes;
QList<WaypointItem*> _waypoints;
QHash<Waypoint, WaypointItem*> _pois;
QHash<SearchPointer<Waypoint>, WaypointItem*> _pois;
QRectF _tr, _rr, _wr;
QPointF _wp;
RectC _tr, _rr, _wr;
qreal _res;
Map *_map;
@ -106,6 +109,8 @@ private:
Palette _palette;
Units _units;
qreal _opacity;
QColor _backgroundColor;
bool _showMap;
bool _showTracks;
bool _showRoutes;
@ -119,9 +124,14 @@ private:
int _routeWidth;
Qt::PenStyle _trackStyle;
Qt::PenStyle _routeStyle;
int _waypointSize;
int _poiSize;
QColor _waypointColor;
QColor _poiColor;
QColor _markerColor;
int _digitalZoom;
bool _plot;
};
#endif // TRACKVIEW_H
#endif // MAPVIEW_H

View File

@ -7,7 +7,7 @@
MarkerItem::MarkerItem(QGraphicsItem *parent) : QGraphicsItem(parent)
{
_color = Qt::red;
}
QRectF MarkerItem::boundingRect() const
@ -22,9 +22,15 @@ void MarkerItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *option
Q_UNUSED(widget);
painter->setRenderHint(QPainter::Antialiasing, false);
painter->setPen(QPen(Qt::red, WIDTH));
painter->setPen(QPen(_color, WIDTH));
painter->drawLine(-SIZE/2, 0, SIZE/2, 0);
painter->drawLine(0, -SIZE/2, 0, SIZE/2);
// painter->drawRect(boundingRect());
}
void MarkerItem::setColor(const QColor &color)
{
_color = color;
update();
}

View File

@ -2,6 +2,7 @@
#define MARKERITEM_H
#include <QGraphicsItem>
#include <QColor>
class MarkerItem : public QGraphicsItem
{
@ -11,6 +12,11 @@ public:
QRectF boundingRect() const;
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option,
QWidget *widget);
void setColor(const QColor &color);
private:
QColor _color;
};
#endif // MARKERITEM_H

View File

@ -1,7 +1,5 @@
#include <cmath>
#include <cctype>
#include "misc.h"
#include "nicenum.h"
double niceNum(double x, int round)
{
@ -34,23 +32,3 @@ double niceNum(double x, int round)
return nf * pow(10.0, expv);
}
int str2int(const char *str, int len)
{
int res = 0;
for (const char *sp = str; sp < str + len; sp++) {
if (::isdigit(*sp))
res = res * 10 + *sp - '0';
else
return -1;
}
return res;
}
QRectF scaled(const QRectF &rect, qreal factor)
{
return QRectF(QPointF(rect.left() * factor, rect.top() * factor),
QSizeF(rect.width() * factor, rect.height() * factor));
}

6
src/GUI/nicenum.h Normal file
View File

@ -0,0 +1,6 @@
#ifndef MISC_H
#define MISC_H
double niceNum(double x, int round);
#endif // MISC_H

20
src/GUI/oddspinbox.cpp Normal file
View File

@ -0,0 +1,20 @@
#include "oddspinbox.h"
OddSpinBox::OddSpinBox(QWidget *parent) : QSpinBox(parent)
{
setSingleStep(2);
setMinimum(1);
}
QValidator::State OddSpinBox::validate(QString &text, int &pos) const
{
Q_UNUSED(pos);
bool ok;
int val;
val = text.toInt(&ok);
if (!ok || val < 0 || val % 2 == 0)
return QValidator::Invalid;
return QValidator::Acceptable;
}

15
src/GUI/oddspinbox.h Normal file
View File

@ -0,0 +1,15 @@
#ifndef ODDSPINBOX_H
#define ODDSPINBOX_H
#include <QSpinBox>
class OddSpinBox : public QSpinBox
{
public:
OddSpinBox(QWidget *parent = 0);
protected:
QValidator::State validate(QString &text, int &pos) const;
};
#endif // ODDSPINBOX_H

551
src/GUI/optionsdialog.cpp Normal file
View File

@ -0,0 +1,551 @@
#include <QVBoxLayout>
#include <QFormLayout>
#include <QDialogButtonBox>
#include <QListWidget>
#include <QListWidgetItem>
#include <QStackedWidget>
#include <QTabWidget>
#include <QSpinBox>
#include <QGroupBox>
#include <QCheckBox>
#include <QComboBox>
#include <QRadioButton>
#include <QLabel>
#include <QSysInfo>
#include "config.h"
#include "icons.h"
#include "colorbox.h"
#include "stylecombobox.h"
#include "oddspinbox.h"
#include "percentslider.h"
#include "optionsdialog.h"
#define MENU_MARGIN 20
#define MENU_ICON_SIZE 32
#ifdef Q_OS_MAC
static QFrame *line()
{
QFrame *l = new QFrame();
l->setFrameShape(QFrame::HLine);
l->setFrameShadow(QFrame::Sunken);
return l;
}
#endif
QWidget *OptionsDialog::createGeneralPage()
{
_alwaysShowMap = new QCheckBox(tr("Always show the map"));
_alwaysShowMap->setChecked(_options->alwaysShowMap);
_alwaysShowMap->setToolTip("<p>" +
tr("Show the map even when no files are loaded.") + "</p>");
QFormLayout *showMapLayout = new QFormLayout();
showMapLayout->addWidget(_alwaysShowMap);
QWidget *generalTab = new QWidget();
QVBoxLayout *generalTabLayout = new QVBoxLayout();
generalTabLayout->addLayout(showMapLayout);
generalTabLayout->addStretch();
generalTab->setLayout(generalTabLayout);
QTabWidget *generalPage = new QTabWidget();
generalPage->addTab(generalTab, tr("General"));
return generalPage;
}
QWidget *OptionsDialog::createAppearancePage()
{
// Paths
_baseColor = new ColorBox();
_baseColor->setColor(_options->palette.color());
_colorOffset = new QDoubleSpinBox();
_colorOffset->setMinimum(0);
_colorOffset->setMaximum(1.0);
_colorOffset->setSingleStep(0.01);
_colorOffset->setValue(_options->palette.shift());
QFormLayout *paletteLayout = new QFormLayout();
paletteLayout->addRow(tr("Base color:"), _baseColor);
paletteLayout->addRow(tr("Palette shift:"), _colorOffset);
#ifndef Q_OS_MAC
QGroupBox *colorBox = new QGroupBox(tr("Colors"));
colorBox->setLayout(paletteLayout);
#endif // Q_OS_MAC
_trackWidth = new QSpinBox();
_trackWidth->setValue(_options->trackWidth);
_trackWidth->setMinimum(1);
_trackStyle = new StyleComboBox();
_trackStyle->setValue(_options->trackStyle);
QFormLayout *trackLayout = new QFormLayout();
#ifdef Q_OS_MAC
trackLayout->addRow(tr("Track width:"), _trackWidth);
trackLayout->addRow(tr("Track style:"), _trackStyle);
#else // Q_OS_MAC
trackLayout->addRow(tr("Width:"), _trackWidth);
trackLayout->addRow(tr("Style:"), _trackStyle);
QGroupBox *trackBox = new QGroupBox(tr("Tracks"));
trackBox->setLayout(trackLayout);
#endif // Q_OS_MAC
_routeWidth = new QSpinBox();
_routeWidth->setValue(_options->routeWidth);
_routeWidth->setMinimum(1);
_routeStyle = new StyleComboBox();
_routeStyle->setValue(_options->routeStyle);
QFormLayout *routeLayout = new QFormLayout();
#ifdef Q_OS_MAC
routeLayout->addRow(tr("Route width:"), _routeWidth);
routeLayout->addRow(tr("Route style:"), _routeStyle);
#else // Q_OS_MAC
routeLayout->addRow(tr("Width:"), _routeWidth);
routeLayout->addRow(tr("Style:"), _routeStyle);
QGroupBox *routeBox = new QGroupBox(tr("Routes"));
routeBox->setLayout(routeLayout);
#endif // Q_OS_MAC
_pathAA = new QCheckBox(tr("Use anti-aliasing"));
_pathAA->setChecked(_options->pathAntiAliasing);
QFormLayout *pathAALayout = new QFormLayout();
pathAALayout->addWidget(_pathAA);
QWidget *pathTab = new QWidget();
QVBoxLayout *pathTabLayout = new QVBoxLayout();
#ifdef Q_OS_MAC
pathTabLayout->addLayout(paletteLayout);
pathTabLayout->addWidget(line());
pathTabLayout->addLayout(trackLayout);
pathTabLayout->addWidget(line());
pathTabLayout->addLayout(routeLayout);
pathTabLayout->addWidget(line());
#else // Q_OS_MAC
pathTabLayout->addWidget(colorBox);
pathTabLayout->addWidget(trackBox);
pathTabLayout->addWidget(routeBox);
#endif // Q_OS_MAC
pathTabLayout->addLayout(pathAALayout);
pathTabLayout->addStretch();
pathTab->setLayout(pathTabLayout);
// Waypoints
_waypointSize = new QSpinBox();
_waypointSize->setMinimum(1);
_waypointSize->setValue(_options->waypointSize);
_waypointColor = new ColorBox();
_waypointColor->setColor(_options->waypointColor);
QFormLayout *waypointLayout = new QFormLayout();
#ifdef Q_OS_MAC
waypointLayout->addRow(tr("Waypoint color:"), _waypointColor);
waypointLayout->addRow(tr("Waypoint size:"), _waypointSize);
#else // Q_OS_MAC
waypointLayout->addRow(tr("Color:"), _waypointColor);
waypointLayout->addRow(tr("Size:"), _waypointSize);
QGroupBox *waypointBox = new QGroupBox(tr("Waypoints"));
waypointBox->setLayout(waypointLayout);
#endif // Q_OS_MAC
_poiSize = new QSpinBox();
_poiSize->setMinimum(1);
_poiSize->setValue(_options->poiSize);
_poiColor = new ColorBox();
_poiColor->setColor(_options->poiColor);
QFormLayout *poiLayout = new QFormLayout();
#ifdef Q_OS_MAC
poiLayout->addRow(tr("POI color:"), _poiColor);
poiLayout->addRow(tr("POI size:"), _poiSize);
#else // Q_OS_MAC
poiLayout->addRow(tr("Color:"), _poiColor);
poiLayout->addRow(tr("Size:"), _poiSize);
QGroupBox *poiBox = new QGroupBox(tr("POIs"));
poiBox->setLayout(poiLayout);
#endif // Q_OS_MAC
QWidget *pointTab = new QWidget();
QVBoxLayout *pointTabLayout = new QVBoxLayout();
#ifdef Q_OS_MAC
pointTabLayout->addLayout(waypointLayout);
pointTabLayout->addWidget(line());
pointTabLayout->addLayout(poiLayout);
#else // Q_OS_MAC
pointTabLayout->addWidget(waypointBox);
pointTabLayout->addWidget(poiBox);
#endif // Q_OS_MAC
pointTabLayout->addStretch();
pointTab->setLayout(pointTabLayout);
// Graphs
_sliderColor = new ColorBox();
_sliderColor->setColor(_options->sliderColor);
_graphWidth = new QSpinBox();
_graphWidth->setValue(_options->graphWidth);
_graphWidth->setMinimum(1);
QFormLayout *graphLayout = new QFormLayout();
graphLayout->addRow(tr("Line width:"), _graphWidth);
graphLayout->addRow(tr("Slider color:"), _sliderColor);
_graphAA = new QCheckBox(tr("Use anti-aliasing"));
_graphAA->setChecked(_options->graphAntiAliasing);
QFormLayout *graphAALayout = new QFormLayout();
graphAALayout->addWidget(_graphAA);
QWidget *graphTab = new QWidget();
QVBoxLayout *graphTabLayout = new QVBoxLayout();
graphTabLayout->addLayout(graphLayout);
graphTabLayout->addLayout(graphAALayout);
graphTabLayout->addStretch();
graphTab->setLayout(graphTabLayout);
// Map
_mapOpacity = new PercentSlider();
_mapOpacity->setValue(_options->mapOpacity);
_backgroundColor = new ColorBox();
_backgroundColor->setColor(_options->backgroundColor);
_backgroundColor->enableAlphaChannel(false);
QFormLayout *mapLayout = new QFormLayout();
mapLayout->addRow(tr("Background color:"), _backgroundColor);
mapLayout->addRow(tr("Map opacity:"), _mapOpacity);
QWidget *mapTab = new QWidget();
QVBoxLayout *mapTabLayout = new QVBoxLayout();
mapTabLayout->addLayout(mapLayout);
mapTabLayout->addStretch();
mapTab->setLayout(mapTabLayout);
QTabWidget *appearancePage = new QTabWidget();
appearancePage->addTab(pathTab, tr("Paths"));
appearancePage->addTab(pointTab, tr("Points"));
appearancePage->addTab(graphTab, tr("Graphs"));
appearancePage->addTab(mapTab, tr("Map"));
return appearancePage;
}
QWidget *OptionsDialog::createDataPage()
{
QString filterToolTip = tr("Moving average window size");
_elevationFilter = new OddSpinBox();
_elevationFilter->setValue(_options->elevationFilter);
_elevationFilter->setToolTip(filterToolTip);
_speedFilter = new OddSpinBox();
_speedFilter->setValue(_options->speedFilter);
_speedFilter->setToolTip(filterToolTip);
_heartRateFilter = new OddSpinBox();
_heartRateFilter->setValue(_options->heartRateFilter);
_heartRateFilter->setToolTip(filterToolTip);
_cadenceFilter = new OddSpinBox();
_cadenceFilter->setValue(_options->cadenceFilter);
_cadenceFilter->setToolTip(filterToolTip);
_powerFilter = new OddSpinBox();
_powerFilter->setValue(_options->powerFilter);
_powerFilter->setToolTip(filterToolTip);
QFormLayout *smoothLayout = new QFormLayout();
smoothLayout->addRow(tr("Elevation:"), _elevationFilter);
smoothLayout->addRow(tr("Speed:"), _speedFilter);
smoothLayout->addRow(tr("Heart rate:"), _heartRateFilter);
smoothLayout->addRow(tr("Cadence:"), _cadenceFilter);
smoothLayout->addRow(tr("Power:"), _powerFilter);
#ifndef Q_OS_MAC
QGroupBox *smoothBox = new QGroupBox(tr("Smoothing"));
smoothBox->setLayout(smoothLayout);
#endif // Q_OS_MAC
_outlierEliminate = new QCheckBox(tr("Eliminate GPS outliers"));
_outlierEliminate->setChecked(_options->outlierEliminate);
QFormLayout *outlierLayout = new QFormLayout();
outlierLayout->addWidget(_outlierEliminate);
#ifndef Q_OS_MAC
QGroupBox *outlierBox = new QGroupBox(tr("Outlier elimination"));
outlierBox->setLayout(outlierLayout);
#endif // Q_OS_MAC
QWidget *filterTab = new QWidget();
QVBoxLayout *filterTabLayout = new QVBoxLayout();
#ifdef Q_OS_MAC
filterTabLayout->addWidget(new QLabel(tr("Smoothing:")));
filterTabLayout->addLayout(smoothLayout);
filterTabLayout->addWidget(line());
filterTabLayout->addLayout(outlierLayout);
#else // Q_OS_MAC
filterTabLayout->addWidget(smoothBox);
filterTabLayout->addWidget(outlierBox);
#endif // Q_OS_MAC
filterTabLayout->addStretch();
filterTab->setLayout(filterTabLayout);
_pauseSpeed = new QDoubleSpinBox();
_pauseSpeed->setDecimals(1);
_pauseSpeed->setSingleStep(0.1);
_pauseSpeed->setMinimum(0.1);
if (_options->units == Imperial) {
_pauseSpeed->setValue(_options->pauseSpeed * MS2MIH);
_pauseSpeed->setSuffix(UNIT_SPACE + tr("mi/h"));
} else {
_pauseSpeed->setValue(_options->pauseSpeed * MS2KMH);
_pauseSpeed->setSuffix(UNIT_SPACE + tr("km/h"));
}
_pauseInterval = new QSpinBox();
_pauseInterval->setMinimum(1);
_pauseInterval->setSuffix(UNIT_SPACE + tr("s"));
_pauseInterval->setValue(_options->pauseInterval);
QFormLayout *pauseLayout = new QFormLayout();
pauseLayout->addRow(tr("Minimal speed:"), _pauseSpeed);
pauseLayout->addRow(tr("Minimal duration:"), _pauseInterval);
QWidget *pauseTab = new QWidget();
pauseTab->setLayout(pauseLayout);
QTabWidget *filterPage = new QTabWidget();
filterPage->addTab(filterTab, tr("Filtering"));
filterPage->addTab(pauseTab, tr("Pause detection"));
return filterPage;
}
QWidget *OptionsDialog::createPOIPage()
{
_poiRadius = new QDoubleSpinBox();
_poiRadius->setSingleStep(1);
_poiRadius->setDecimals(1);
if (_options->units == Imperial) {
_poiRadius->setValue(_options->poiRadius / MIINM);
_poiRadius->setSuffix(UNIT_SPACE + tr("mi"));
} else {
_poiRadius->setValue(_options->poiRadius / KMINM);
_poiRadius->setSuffix(UNIT_SPACE + tr("km"));
}
QFormLayout *poiLayout = new QFormLayout();
poiLayout->addRow(tr("POI radius:"), _poiRadius);
QWidget *poiTab = new QWidget();
poiTab->setLayout(poiLayout);
QTabWidget *poiPage = new QTabWidget();
poiPage->addTab(poiTab, tr("POI"));
return poiPage;
}
QWidget *OptionsDialog::createExportPage()
{
_wysiwyg = new QRadioButton(tr("WYSIWYG"));
_hires = new QRadioButton(tr("High-Resolution"));
if (_options->hiresPrint)
_hires->setChecked(true);
else
_wysiwyg->setChecked(true);
QLabel *lw = new QLabel(tr("The printed area is approximately the display"
" area. The map zoom level does not change."));
QLabel *lh = new QLabel(tr("The zoom level will be changed so that"
" the whole content (tracks/waypoints) fits to the printed area and"
" the map resolution is as close as possible to the print resolution."));
QFont f = lw->font();
f.setPointSize(f.pointSize() - 1);
lw->setWordWrap(true);
lh->setWordWrap(true);
lw->setFont(f);
lh->setFont(f);
QVBoxLayout *modeTabLayout = new QVBoxLayout();
modeTabLayout->addWidget(_wysiwyg);
modeTabLayout->addWidget(lw);
modeTabLayout->addSpacing(10);
modeTabLayout->addWidget(_hires);
modeTabLayout->addWidget(lh);
modeTabLayout->addStretch();
QWidget *modeTab = new QWidget();
modeTab->setLayout(modeTabLayout);
_name = new QCheckBox(tr("Name"));
_name->setChecked(_options->printName);
_date = new QCheckBox(tr("Date"));
_date->setChecked(_options->printDate);
_distance = new QCheckBox(tr("Distance"));
_distance->setChecked(_options->printDistance);
_time = new QCheckBox(tr("Time"));
_time->setChecked(_options->printTime);
_movingTime = new QCheckBox(tr("Moving time"));
_movingTime->setChecked(_options->printMovingTime);
_itemCount = new QCheckBox(tr("Item count (>1)"));
_itemCount->setChecked(_options->printItemCount);
QFormLayout *headerTabLayout = new QFormLayout();
headerTabLayout->addWidget(_name);
headerTabLayout->addWidget(_date);
headerTabLayout->addWidget(_distance);
headerTabLayout->addWidget(_time);
headerTabLayout->addWidget(_movingTime);
headerTabLayout->addItem(new QSpacerItem(10, 10));
headerTabLayout->addWidget(_itemCount);
QWidget *headerTab = new QWidget();
headerTab->setLayout(headerTabLayout);
_separateGraphPage = new QCheckBox(tr("Separate graph page"));
_separateGraphPage->setChecked(_options->separateGraphPage);
QFormLayout *graphTabLayout = new QFormLayout();
graphTabLayout->addWidget(_separateGraphPage);
QWidget *graphTab = new QWidget();
graphTab->setLayout(graphTabLayout);
QTabWidget *exportPage = new QTabWidget();
exportPage->addTab(modeTab, tr("Print mode"));
exportPage->addTab(headerTab, tr("Header"));
exportPage->addTab(graphTab, tr("Graphs"));
return exportPage;
}
QWidget *OptionsDialog::createSystemPage()
{
_useOpenGL = new QCheckBox(tr("Use OpenGL"));
_useOpenGL->setChecked(_options->useOpenGL);
_pixmapCache = new QSpinBox();
_pixmapCache->setMinimum(16);
_pixmapCache->setMaximum(1024);
_pixmapCache->setSuffix(UNIT_SPACE + tr("MB"));
_pixmapCache->setValue(_options->pixmapCache);
QFormLayout *cacheLayout = new QFormLayout();
cacheLayout->addRow(tr("Image cache size:"), _pixmapCache);
QFormLayout *openGLLayout = new QFormLayout();
openGLLayout->addWidget(_useOpenGL);
QWidget *systemTab = new QWidget();
QVBoxLayout *systemTabLayout = new QVBoxLayout();
systemTabLayout->addLayout(cacheLayout);
systemTabLayout->addLayout(openGLLayout);
systemTabLayout->addStretch();
systemTab->setLayout(systemTabLayout);
QTabWidget *systemPage = new QTabWidget();
systemPage->addTab(systemTab, tr("System"));
return systemPage;
}
OptionsDialog::OptionsDialog(Options *options, QWidget *parent)
: QDialog(parent), _options(options)
{
QStackedWidget *pages = new QStackedWidget();
pages->addWidget(createGeneralPage());
pages->addWidget(createAppearancePage());
pages->addWidget(createDataPage());
pages->addWidget(createPOIPage());
pages->addWidget(createExportPage());
pages->addWidget(createSystemPage());
QListWidget *menu = new QListWidget();
menu->setIconSize(QSize(MENU_ICON_SIZE, MENU_ICON_SIZE));
new QListWidgetItem(QIcon(QPixmap(APP_ICON)), tr("General"), menu);
new QListWidgetItem(QIcon(QPixmap(APPEARANCE_ICON)), tr("Appearance"),
menu);
new QListWidgetItem(QIcon(QPixmap(DATA_ICON)), tr("Data"), menu);
new QListWidgetItem(QIcon(QPixmap(POI_ICON)), tr("POI"), menu);
new QListWidgetItem(QIcon(QPixmap(PRINT_EXPORT_ICON)), tr("Print & Export"),
menu);
new QListWidgetItem(QIcon(QPixmap(SYSTEM_ICON)), tr("System"), menu);
QHBoxLayout *contentLayout = new QHBoxLayout();
contentLayout->addWidget(menu);
contentLayout->addWidget(pages);
menu->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Preferred);
menu->setMaximumWidth(menu->sizeHintForColumn(0) + 2 * menu->frameWidth()
+ MENU_MARGIN);
pages->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::Preferred);
pages->setMinimumWidth(2 * menu->size().width());
connect(menu, SIGNAL(currentRowChanged(int)), pages,
SLOT(setCurrentIndex(int)));
menu->item(0)->setSelected(true);
QDialogButtonBox *buttonBox = new QDialogButtonBox(QDialogButtonBox::Ok
| QDialogButtonBox::Cancel);
connect(buttonBox, SIGNAL(accepted()), this, SLOT(accept()));
connect(buttonBox, SIGNAL(rejected()), this, SLOT(reject()));
QVBoxLayout *layout = new QVBoxLayout;
layout->addLayout(contentLayout);
layout->addWidget(buttonBox);
setLayout(layout);
setWindowTitle(tr("Options"));
setWindowFlags(windowFlags() & ~Qt::WindowContextHelpButtonHint);
}
void OptionsDialog::accept()
{
_options->alwaysShowMap = _alwaysShowMap->isChecked();
_options->palette.setColor(_baseColor->color());
_options->palette.setShift(_colorOffset->value());
_options->mapOpacity = _mapOpacity->value();
_options->backgroundColor = _backgroundColor->color();
_options->trackWidth = _trackWidth->value();
_options->trackStyle = (Qt::PenStyle) _trackStyle->itemData(
_trackStyle->currentIndex()).toInt();
_options->routeWidth = _routeWidth->value();
_options->routeStyle = (Qt::PenStyle) _routeStyle->itemData(
_routeStyle->currentIndex()).toInt();
_options->pathAntiAliasing = _pathAA->isChecked();
_options->waypointSize = _waypointSize->value();
_options->waypointColor = _waypointColor->color();
_options->poiSize = _poiSize->value();
_options->poiColor = _poiColor->color();
_options->graphWidth = _graphWidth->value();
_options->sliderColor = _sliderColor->color();
_options->graphAntiAliasing = _graphAA->isChecked();
_options->elevationFilter = _elevationFilter->value();
_options->speedFilter = _speedFilter->value();
_options->heartRateFilter = _heartRateFilter->value();
_options->cadenceFilter = _cadenceFilter->value();
_options->powerFilter = _powerFilter->value();
_options->outlierEliminate = _outlierEliminate->isChecked();
qreal pauseSpeed = (_options->units == Imperial)
? _pauseSpeed->value() / MS2MIH : _pauseSpeed->value() / MS2KMH;
if (qAbs(pauseSpeed - _options->pauseSpeed) > 0.01)
_options->pauseSpeed = pauseSpeed;
_options->pauseInterval = _pauseInterval->value();
qreal poiRadius = (_options->units == Imperial)
? _poiRadius->value() * MIINM : _poiRadius->value() * KMINM;
if (qAbs(poiRadius - _options->poiRadius) > 0.01)
_options->poiRadius = poiRadius;
_options->useOpenGL = _useOpenGL->isChecked();
_options->pixmapCache = _pixmapCache->value();
_options->hiresPrint = _hires->isChecked();
_options->printName = _name->isChecked();
_options->printDate = _date->isChecked();
_options->printDistance = _distance->isChecked();
_options->printTime = _time->isChecked();
_options->printMovingTime = _movingTime->isChecked();
_options->printItemCount = _itemCount->isChecked();
_options->separateGraphPage = _separateGraphPage->isChecked();
QDialog::accept();
}

View File

@ -7,27 +7,49 @@
class ColorBox;
class StyleComboBox;
class OddSpinBox;
class QSpinBox;
class QDoubleSpinBox;
class QComboBox;
class QCheckBox;
class QRadioButton;
class PercentSlider;
struct Options {
// General
bool alwaysShowMap;
// Appearance
Palette palette;
int trackWidth;
int routeWidth;
Qt::PenStyle trackStyle;
Qt::PenStyle routeStyle;
QColor waypointColor;
QColor poiColor;
int waypointSize;
int poiSize;
int graphWidth;
QColor sliderColor;
bool pathAntiAliasing;
bool graphAntiAliasing;
int mapOpacity;
QColor backgroundColor;
// Data
int elevationFilter;
int speedFilter;
int heartRateFilter;
int cadenceFilter;
int powerFilter;
bool outlierEliminate;
qreal pauseSpeed;
int pauseInterval;
// POI
int poiRadius;
// System
bool useOpenGL;
int pixmapCache;
// Print/Export
bool hiresPrint;
bool printName;
bool printDate;
bool printDistance;
@ -50,25 +72,51 @@ public slots:
void accept();
private:
QWidget *createGeneralPage();
QWidget *createAppearancePage();
QWidget *createDataPage();
QWidget *createPOIPage();
QWidget *createSystemPage();
QWidget *createExportPage();
Options *_options;
// General
QCheckBox *_alwaysShowMap;
// Appearance
ColorBox *_baseColor;
QDoubleSpinBox *_colorOffset;
PercentSlider *_mapOpacity;
ColorBox *_backgroundColor;
QSpinBox *_trackWidth;
StyleComboBox *_trackStyle;
QSpinBox *_routeWidth;
StyleComboBox *_routeStyle;
QCheckBox *_pathAA;
QSpinBox *_waypointSize;
ColorBox *_waypointColor;
QSpinBox *_poiSize;
ColorBox *_poiColor;
QSpinBox *_graphWidth;
ColorBox *_sliderColor;
QCheckBox *_graphAA;
// Data
OddSpinBox *_elevationFilter;
OddSpinBox *_speedFilter;
OddSpinBox *_heartRateFilter;
OddSpinBox *_cadenceFilter;
OddSpinBox *_powerFilter;
QCheckBox *_outlierEliminate;
QDoubleSpinBox *_pauseSpeed;
QSpinBox *_pauseInterval;
// POI
QDoubleSpinBox *_poiRadius;
// System
QSpinBox *_pixmapCache;
QCheckBox *_useOpenGL;
// Print/Export
QRadioButton *_wysiwyg;
QRadioButton *_hires;
QCheckBox *_name;
QCheckBox *_date;
QCheckBox *_distance;

View File

@ -41,6 +41,5 @@ QDebug operator<<(QDebug dbg, const Palette &palette)
{
dbg.nospace() << "Palette(" << palette.color() << ", " << palette.shift()
<< ")";
return dbg.maybeSpace();
return dbg.space();
}

View File

@ -2,9 +2,9 @@
#include <QApplication>
#include <QCursor>
#include <QPainter>
#include "map/map.h"
#include "tooltip.h"
#include "map.h"
#include "misc.h"
#include "nicenum.h"
#include "pathitem.h"
@ -66,9 +66,10 @@ void PathItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *option,
void PathItem::setMap(Map *map)
{
_map = map;
prepareGeometryChange();
_map = map;
updatePainterPath(map);
updateShape();
@ -77,12 +78,18 @@ void PathItem::setMap(Map *map)
void PathItem::setColor(const QColor &color)
{
if (_pen.color() == color)
return;
_pen.setColor(color);
update();
}
void PathItem::setWidth(qreal width)
{
if (_width == width)
return;
prepareGeometryChange();
_width = width;
@ -93,12 +100,18 @@ void PathItem::setWidth(qreal width)
void PathItem::setStyle(Qt::PenStyle style)
{
if (_pen.style() == style)
return;
_pen.setStyle(style);
update();
}
void PathItem::setDigitalZoom(int zoom)
{
if (_digitalZoom == zoom)
return;
prepareGeometryChange();
_digitalZoom = zoom;
@ -154,6 +167,24 @@ void PathItem::moveMarker(qreal distance)
_marker->setVisible(false);
}
void PathItem::setMarkerColor(const QColor &color)
{
_marker->setColor(color);
}
void PathItem::hover(bool hover)
{
if (hover) {
_pen.setWidth(_width + 1);
setZValue(zValue() + 1.0);
} else {
_pen.setWidth(_width);
setZValue(zValue() - 1.0);
}
update();
}
void PathItem::hoverEnterEvent(QGraphicsSceneHoverEvent *event)
{
Q_UNUSED(event);

View File

@ -3,9 +3,8 @@
#include <QGraphicsObject>
#include <QPen>
#include "data/path.h"
#include "markeritem.h"
#include "path.h"
class Map;
@ -29,9 +28,11 @@ public:
void setWidth(qreal width);
void setStyle(Qt::PenStyle style);
void setDigitalZoom(int zoom);
void setMarkerColor(const QColor &color);
public slots:
void moveMarker(qreal distance);
void hover(bool hover);
signals:
void selected(bool);

48
src/GUI/percentslider.cpp Normal file
View File

@ -0,0 +1,48 @@
#include <QSlider>
#include <QLabel>
#include <QHBoxLayout>
#include "units.h"
#include "percentslider.h"
static QString format(int value)
{
return QString::number(value) + UNIT_SPACE + QString("%");
}
PercentSlider::PercentSlider(QWidget *parent) : QWidget(parent)
{
_slider = new QSlider(Qt::Horizontal);
_label = new QLabel();
_slider->setMinimum(0);
_slider->setMaximum(100);
QFontMetrics fm(_label->font());
_label->setFixedWidth(fm.boundingRect(format(_slider->maximum())).width());
_label->setAlignment(Qt::AlignRight);
connect(_slider, SIGNAL(sliderMoved(int)), this, SLOT(updateLabel(int)));
QHBoxLayout *layout = new QHBoxLayout();
layout->addWidget(_slider);
layout->addWidget(_label);
setLayout(layout);
}
void PercentSlider::updateLabel(int value)
{
_label->setText(format(value));
}
int PercentSlider::value() const
{
return _slider->value();
}
void PercentSlider::setValue(int value)
{
_slider->setValue(value);
_label->setText(format(value));
}

29
src/GUI/percentslider.h Normal file
View File

@ -0,0 +1,29 @@
#ifndef PERCENTSLIDER_H
#define PERCENTSLIDER_H
#include <QWidget>
class QSlider;
class QLabel;
class PercentSlider : public QWidget
{
Q_OBJECT
public:
PercentSlider(QWidget *parent = 0);
int value() const;
public slots:
void setValue(int value);
private slots:
void updateLabel(int value);
private:
QSlider *_slider;
QLabel *_label;
};
#endif // PERCENTSLIDER_H

View File

@ -1,10 +1,10 @@
#include "data.h"
#include "data/data.h"
#include "powergraphitem.h"
#include "powergraph.h"
PowerGraph::PowerGraph(QWidget *parent) : GraphTab(parent)
{
_units = Metric;
_showTracks = true;
GraphView::setYUnits(tr("W"));
@ -28,21 +28,16 @@ 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));
PowerGraphItem *gi = new PowerGraphItem(graph, _graphType);
GraphView::addGraph(gi, paths.at(i));
GraphView::loadGraph(graph, paths.at(i));
_avg.append(QPointF(data.tracks().at(i)->distance(), gi->avg()));
}
for (int i = 0; i < data.routes().count(); i++)

View File

@ -22,7 +22,6 @@ private:
QList<QPointF> _avg;
enum Units _units;
bool _showTracks;
};

View File

@ -0,0 +1,26 @@
#include "tooltip.h"
#include "powergraphitem.h"
PowerGraphItem::PowerGraphItem(const Graph &graph, GraphType type,
QGraphicsItem *parent) : GraphItem(graph, type, parent)
{
qreal sum = 0;
for (int j = 1; j < graph.size(); j++)
sum += graph.at(j).y() * (graph.at(j).s() - graph.at(j-1).s());
_avg = sum/graph.last().s();
setToolTip(toolTip());
}
QString PowerGraphItem::toolTip() const
{
ToolTip tt;
tt.insert(tr("Maximum"), QString::number(max(), 'f', 1)
+ UNIT_SPACE + tr("1/min"));
tt.insert(tr("Average"), QString::number(avg(), 'f', 1)
+ UNIT_SPACE + tr("1/min"));
return tt.toString();
}

23
src/GUI/powergraphitem.h Normal file
View File

@ -0,0 +1,23 @@
#ifndef POWERGRAPHITEM_H
#define POWERGRAPHITEM_H
#include "graphitem.h"
class PowerGraphItem : public GraphItem
{
Q_OBJECT
public:
PowerGraphItem(const Graph &graph, GraphType type,
QGraphicsItem *parent = 0);
qreal max() const {return -bounds().top();}
qreal avg() const {return _avg;}
private:
QString toolTip() const;
qreal _avg;
};
#endif // POWERGRAPHITEM_H

View File

@ -1,13 +1,13 @@
#include <QPainter>
#include "data/waypoint.h"
#include "map/map.h"
#include "format.h"
#include "waypoint.h"
#include "waypointitem.h"
#include "tooltip.h"
#include "map.h"
#include "routeitem.h"
QString RouteItem::toolTip(Units units)
QString RouteItem::toolTip(Units units) const
{
ToolTip tt;

View File

@ -1,8 +1,8 @@
#ifndef ROUTEITEM_H
#define ROUTEITEM_H
#include "data/route.h"
#include "pathitem.h"
#include "route.h"
#include "units.h"
class Map;
@ -14,7 +14,6 @@ class RouteItem : public PathItem
public:
RouteItem(const Route &route, Map *map, QGraphicsItem *parent = 0);
//void setScale(qreal scale);
void setMap(Map *map);
void setUnits(Units units);
@ -22,7 +21,7 @@ public:
void showWaypointLabels(bool show);
private:
QString toolTip(Units units);
QString toolTip(Units units) const;
QString _name;
QString _desc;

View File

@ -1,7 +1,7 @@
#include <cmath>
#include <QPainter>
#include "config.h"
#include "misc.h"
#include "nicenum.h"
#include "scaleitem.h"
@ -132,7 +132,7 @@ void ScaleItem::setUnits(enum Units units)
update();
}
void ScaleItem::setDigitalZoom(int zoom)
void ScaleItem::setDigitalZoom(qreal zoom)
{
prepareGeometryChange();
_digitalZoom = zoom;

View File

@ -15,7 +15,7 @@ public:
void setResolution(qreal res);
void setUnits(enum Units units);
void setDigitalZoom(int zoom);
void setDigitalZoom(qreal zoom);
private:
void updateBoundingRect();
@ -28,7 +28,7 @@ private:
Units _units;
bool _scale;
int _digitalZoom;
qreal _digitalZoom;
QRectF _boundingRect;
};

24
src/GUI/searchpointer.h Normal file
View File

@ -0,0 +1,24 @@
#ifndef SEARCHPOINTER_H
#define SEARCHPOINTER_H
template <class T>
class SearchPointer
{
public:
SearchPointer(const T *ptr) : _ptr(ptr) {}
const T *data() const {return _ptr;}
bool operator==(const SearchPointer<T> &other) const
{return *data() == *(other.data());}
private:
const T *_ptr;
};
template <class T>
inline uint qHash(const SearchPointer<T> &t)
{
return ::qHash(*(t.data()));
}
#endif // SEARCHPOINTER_H

View File

@ -25,6 +25,8 @@
#define GRAPH_TYPE_DEFAULT Distance
#define SHOW_GRAPH_GRIDS_SETTING "grid"
#define SHOW_GRAPH_GRIDS_DEFAULT true
#define SHOW_GRAPH_SLIDER_INFO_SETTING "sliderInfo"
#define SHOW_GRAPH_SLIDER_INFO_DEFAULT true
#define MAP_SETTINGS_GROUP "Map"
#define CURRENT_MAP_SETTING "map"
@ -70,12 +72,18 @@
#define EXPORT_FILENAME_SETTING "fileName"
#define EXPORT_FILENAME_DEFAULT QString("%1/export.pdf"). \
arg(QDir::currentPath())
#define RESOLUTION_SETTING "resolution"
#define RESOLUTION_DEFAULT 600
#define OPTIONS_SETTINGS_GROUP "Options"
#define PALETTE_COLOR_SETTING "paletteColor"
#define PALETTE_COLOR_DEFAULT QColor(Qt::blue)
#define PALETTE_SHIFT_SETTING "paletteShift"
#define PALETTE_SHIFT_DEFAULT 0.62
#define MAP_OPACITY_SETTING "mapOpacity"
#define MAP_OPACITY_DEFAULT 100
#define BACKGROUND_COLOR_SETTING "backgroundColor"
#define BACKGROUND_COLOR_DEFAULT QColor(Qt::white)
#define TRACK_WIDTH_SETTING "trackWidth"
#define TRACK_WIDTH_DEFAULT 3
#define ROUTE_WIDTH_SETTING "routeWidth"
@ -84,18 +92,44 @@
#define TRACK_STYLE_DEFAULT Qt::SolidLine
#define ROUTE_STYLE_SETTING "routeStyle"
#define ROUTE_STYLE_DEFAULT Qt::DotLine
#define WAYPOINT_SIZE_SETTING "waypointSize"
#define WAYPOINT_SIZE_DEFAULT 8
#define WAYPOINT_COLOR_SETTING "waypointColor"
#define WAYPOINT_COLOR_DEFAULT QColor(Qt::black)
#define POI_SIZE_SETTING "poiSize"
#define POI_SIZE_DEFAULT 8
#define POI_COLOR_SETTING "poiColor"
#define POI_COLOR_DEFAULT QColor(Qt::black)
#define GRAPH_WIDTH_SETTING "graphWidth"
#define GRAPH_WIDTH_DEFAULT 1
#define PATH_AA_SETTING "pathAntiAliasing"
#define PATH_AA_DEFAULT true
#define GRAPH_AA_SETTING "graphAntiAliasing"
#define GRAPH_AA_DEFAULT false
#define ELEVATION_FILTER_SETTING "elevationFilter"
#define ELEVATION_FILTER_DEFAULT 3
#define SPEED_FILTER_SETTING "speedFilter"
#define SPEED_FILTER_DEFAULT 5
#define HEARTRATE_FILTER_SETTING "heartrateFilter"
#define HEARTRATE_FILTER_DEFAULT 3
#define CADENCE_FILTER_SETTING "cadenceFilter"
#define CADENCE_FILTER_DEFAULT 3
#define POWER_FILTER_SETTING "powerFilter"
#define POWER_FILTER_DEFAULT 3
#define OUTLIER_ELIMINATE_SETTING "outlierEliminate"
#define OUTLIER_ELIMINATE_DEFAULT true
#define PAUSE_SPEED_SETTING "pauseSpeed"
#define PAUSE_SPEED_DEFAULT 0.5 /* m/s */
#define PAUSE_INTERVAL_SETTING "pauseInterval"
#define PAUSE_INTERVAL_DEFAULT 10 /* s */
#define POI_RADIUS_SETTING "poiRadius"
#define POI_RADIUS_DEFAULT (IMPERIAL_UNITS() ? MIINM : KMINM)
#define POI_RADIUS_DEFAULT (int)(IMPERIAL_UNITS() ? MIINM : KMINM)
#define USE_OPENGL_SETTING "useOpenGL"
#define USE_OPENGL_DEFAULT false
#define PIXMAP_CACHE_SETTING "pixmapCache"
#define PIXMAP_CACHE_DEFAULT 64
#define PIXMAP_CACHE_DEFAULT 64 /* MB */
#define HIRES_PRINT_SETTING "hiresPrint"
#define HIRES_PRINT_DEFAULT false
#define PRINT_NAME_SETTING "printName"
#define PRINT_NAME_DEFAULT true
#define PRINT_DATE_SETTING "printDate"
@ -110,5 +144,9 @@
#define PRINT_ITEM_COUNT_DEFAULT true
#define SEPARATE_GRAPH_PAGE_SETTING "separateGraphPage"
#define SEPARATE_GRAPH_PAGE_DEFAULT false
#define SLIDER_COLOR_SETTING "sliderColor"
#define SLIDER_COLOR_DEFAULT QColor(Qt::red)
#define ALWAYS_SHOW_MAP_SETTING "alwaysShowMap"
#define ALWAYS_SHOW_MAP_DEFAULT true
#endif // SETTINGS_H

View File

@ -0,0 +1,97 @@
#include <QPainter>
#include "config.h"
#include "sliderinfoitem.h"
#define SIZE 5
SliderInfoItem::SliderInfoItem(QGraphicsItem *parent) : QGraphicsItem(parent)
{
_side = Right;
_color = Qt::red;
}
void SliderInfoItem::updateBoundingRect()
{
QFont font;
font.setPixelSize(FONT_SIZE);
font.setFamily(FONT_FAMILY);
QFontMetrics fm(font);
qreal width = qMax(fm.width(_x), fm.width(_y));
qreal height = 2 * fm.height() - 2*fm.descent();
_boundingRect = (_side == Right)
? QRectF(-SIZE/2, -height/2, width + 1.5*SIZE, height)
: QRectF(-(width + SIZE), -height/2, width + 1.5*SIZE, height);
}
void SliderInfoItem::paint(QPainter *painter, const QStyleOptionGraphicsItem
*option, QWidget *widget)
{
Q_UNUSED(option);
Q_UNUSED(widget);
QFont font;
font.setPixelSize(FONT_SIZE);
font.setFamily(FONT_FAMILY);
QFontMetrics fm(font);
QRectF rx, ry;
qreal width = qMax(fm.width(_x), fm.width(_y));
if (_side == Right) {
ry = QRectF(SIZE, -fm.height() + fm.descent(), fm.width(_y),
fm.height() - fm.descent());
rx = QRectF(SIZE, 0, fm.width(_x), fm.height()
- fm.descent());
} else {
ry = QRectF(-(width + SIZE), -fm.height() + fm.descent(), fm.width(_y),
fm.height() - fm.descent());
rx = QRectF(-(width + SIZE), 0, fm.width(_x), fm.height()
- fm.descent());
}
painter->setPen(Qt::NoPen);
painter->setBrush(QBrush(QColor(255, 255, 255, 196)));
painter->drawRect(ry);
painter->drawRect(rx);
painter->setBrush(Qt::NoBrush);
painter->setFont(font);
painter->setRenderHint(QPainter::Antialiasing, false);
painter->setPen(_color);
if (_side == Right) {
painter->drawText(SIZE, -fm.descent()/2, _y);
painter->drawText(SIZE, fm.height() - fm.descent()*1.5, _x);
} else {
painter->drawText(-(width + SIZE), -fm.descent()/2, _y);
painter->drawText(-(width + SIZE), fm.height() - fm.descent()*1.5, _x);
}
painter->drawLine(QPointF(-SIZE/2, 0), QPointF(SIZE/2, 0));
//painter->drawRect(boundingRect());
}
void SliderInfoItem::setText(const QString &x, const QString &y)
{
prepareGeometryChange();
_x = x; _y = y;
updateBoundingRect();
}
void SliderInfoItem::setSide(Side side)
{
if (side == _side)
return;
prepareGeometryChange();
_side = side;
updateBoundingRect();
}
void SliderInfoItem::setColor(const QColor &color)
{
_color = color;
update();
}

View File

@ -14,15 +14,17 @@ public:
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option,
QWidget *widget);
void setText(const QString &text);
void setText(const QString &x, const QString &y);
void setSide(Side side);
void setColor(const QColor &color);
private:
void updateBoundingRect();
Side _side;
QString _text;
QString _x, _y;
QRectF _boundingRect;
QColor _color;
};
#endif // SLIDERINFOITEM_H

View File

@ -8,6 +8,8 @@ SliderItem::SliderItem(QGraphicsItem *parent) : QGraphicsObject(parent)
{
setFlag(ItemIsMovable);
setFlag(ItemSendsGeometryChanges);
_color = Qt::red;
}
QRectF SliderItem::boundingRect() const
@ -22,7 +24,7 @@ void SliderItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *option
Q_UNUSED(widget);
painter->setRenderHint(QPainter::Antialiasing, false);
painter->setPen(Qt::red);
painter->setPen(_color);
painter->drawLine(0, 0, 0, -_area.height());
// painter->drawRect(boundingRect());
@ -59,3 +61,9 @@ void SliderItem::setArea(const QRectF &area)
prepareGeometryChange();
_area = area;
}
void SliderItem::setColor(const QColor &color)
{
_color = color;
update();
}

View File

@ -3,6 +3,8 @@
#include <QGraphicsObject>
class QColor;
class SliderItem : public QGraphicsObject
{
Q_OBJECT
@ -17,6 +19,8 @@ public:
const QRectF &area() const {return _area;}
void setArea(const QRectF &area);
void setColor(const QColor &color);
void clear();
signals:
@ -27,6 +31,7 @@ protected:
private:
QRectF _area;
QColor _color;
};
#endif // SLIDERITEM_H

View File

@ -1,15 +1,16 @@
#include "data/data.h"
#include "config.h"
#include "data.h"
#include "tooltip.h"
#include "speedgraphitem.h"
#include "speedgraph.h"
SpeedGraph::SpeedGraph(QWidget *parent) : GraphTab(parent)
{
_units = Metric;
_timeType = Total;
_showTracks = true;
setYUnits();
setYUnits(Metric);
setYLabel(tr("Speed"));
setSliderPrecision(1);
@ -29,18 +30,21 @@ void SpeedGraph::setInfo()
void SpeedGraph::loadData(const Data &data, const QList<PathItem *> &paths)
{
for (int i = 0; i < data.tracks().count(); i++) {
const Graph &graph = data.tracks().at(i)->speed();
const Track *track = data.tracks().at(i);
const Graph &graph = track->speed();
if (graph.size() < 2) {
skipColor();
continue;
}
_avg.append(QPointF(data.tracks().at(i)->distance(),
data.tracks().at(i)->distance() / data.tracks().at(i)->time()));
_avgM.append(QPointF(data.tracks().at(i)->distance(),
data.tracks().at(i)->distance() / data.tracks().at(i)->movingTime()));
SpeedGraphItem *gi = new SpeedGraphItem(graph, _graphType,
track->movingTime());
gi->setTimeType(_timeType);
GraphView::addGraph(gi, paths.at(i));
GraphView::loadGraph(graph, paths.at(i));
_avg.append(QPointF(track->distance(), gi->avg()));
_mavg.append(QPointF(track->distance(), gi->mavg()));
}
for (int i = 0; i < data.routes().count(); i++)
@ -55,7 +59,7 @@ qreal SpeedGraph::avg() const
{
qreal sum = 0, w = 0;
QList<QPointF>::const_iterator it;
const QList<QPointF> &list = (_timeType == Moving) ? _avgM : _avg;
const QList<QPointF> &list = (_timeType == Moving) ? _mavg : _avg;
for (it = list.begin(); it != list.end(); it++) {
sum += it->y() * it->x();
@ -68,14 +72,14 @@ qreal SpeedGraph::avg() const
void SpeedGraph::clear()
{
_avg.clear();
_avgM.clear();
_mavg.clear();
GraphView::clear();
}
void SpeedGraph::setYUnits()
void SpeedGraph::setYUnits(Units units)
{
if (_units == Metric) {
if (units == Metric) {
GraphView::setYUnits(tr("km/h"));
setYScale(MS2KMH);
} else {
@ -84,21 +88,21 @@ void SpeedGraph::setYUnits()
}
}
void SpeedGraph::setUnits(enum Units units)
void SpeedGraph::setUnits(Units units)
{
_units = units;
setYUnits();
setYUnits(units);
setInfo();
GraphView::setUnits(units);
redraw();
GraphView::setUnits(units);
}
void SpeedGraph::setTimeType(enum TimeType type)
{
_timeType = type;
for (int i = 0; i < _graphs.size(); i++)
static_cast<SpeedGraphItem*>(_graphs.at(i))->setTimeType(type);
setInfo();
redraw();
}

View File

@ -14,20 +14,19 @@ public:
QString label() const {return tr("Speed");}
void loadData(const Data &data, const QList<PathItem *> &paths);
void clear();
void setUnits(enum Units units);
void setTimeType(enum TimeType type);
void setUnits(Units units);
void setTimeType(TimeType type);
void showTracks(bool show);
private:
qreal avg() const;
qreal max() const {return bounds().bottom();}
void setYUnits();
void setYUnits(Units units);
void setInfo();
QList<QPointF> _avg;
QList<QPointF> _avgM;
QList<QPointF> _mavg;
enum Units _units;
enum TimeType _timeType;
bool _showTracks;
};

View File

@ -0,0 +1,40 @@
#include "tooltip.h"
#include "speedgraphitem.h"
SpeedGraphItem::SpeedGraphItem(const Graph &graph, GraphType type,
qreal movingTime, QGraphicsItem *parent) : GraphItem(graph, type, parent)
{
_units = Metric;
_timeType = Total;
_avg = graph.last().s() / graph.last().t();
_mavg = graph.last().s() / movingTime;
setToolTip(toolTip());
}
QString SpeedGraphItem::toolTip() const
{
ToolTip tt;
qreal scale = (_units == Metric) ? MS2KMH : MS2MIH;
QString su = (_units == Metric) ? tr("km/h") : tr("mi/h");
tt.insert(tr("Maximum"), QString::number(max() * scale, 'f', 1)
+ UNIT_SPACE + su);
tt.insert(tr("Average"), QString::number((_timeType == Total)
? avg() * scale : mavg() * scale, 'f', 1) + UNIT_SPACE + su);
return tt.toString();
}
void SpeedGraphItem::setUnits(Units units)
{
_units = units;
setToolTip(toolTip());
}
void SpeedGraphItem::setTimeType(TimeType type)
{
_timeType = type;
setToolTip(toolTip());
}

31
src/GUI/speedgraphitem.h Normal file
View File

@ -0,0 +1,31 @@
#ifndef SPEEDGRAPHITEM_H
#define SPEEDGRAPHITEM_H
#include "timetype.h"
#include "graphitem.h"
class SpeedGraphItem : public GraphItem
{
Q_OBJECT
public:
SpeedGraphItem(const Graph &graph, GraphType type, qreal movingTime,
QGraphicsItem *parent = 0);
qreal max() const {return -bounds().top();}
qreal avg() const {return _avg;}
qreal mavg() const {return _mavg;}
void setUnits(Units units);
void setTimeType(TimeType type);
private:
QString toolTip() const;
qreal _avg, _mavg;
Units _units;
TimeType _timeType;
};
#endif // SPEEDGRAPHITEM_H

View File

@ -1,13 +1,13 @@
#include "data.h"
#include "data/data.h"
#include "temperaturegraphitem.h"
#include "temperaturegraph.h"
TemperatureGraph::TemperatureGraph(QWidget *parent) : GraphTab(parent)
{
_units = Metric;
_showTracks = true;
setYUnits();
setYUnits(Metric);
setYLabel(tr("Temperature"));
setSliderPrecision(1);
@ -30,21 +30,16 @@ void TemperatureGraph::loadData(const Data &data, const QList<PathItem *> &paths
{
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) {
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));
TemperatureGraphItem *gi = new TemperatureGraphItem(graph, _graphType);
GraphView::addGraph(gi, paths.at(i));
GraphView::loadGraph(graph, paths.at(i));
_avg.append(QPointF(data.tracks().at(i)->distance(), gi->avg()));
}
for (int i = 0; i < data.routes().count(); i++)
@ -75,9 +70,9 @@ void TemperatureGraph::clear()
GraphView::clear();
}
void TemperatureGraph::setYUnits()
void TemperatureGraph::setYUnits(Units units)
{
if (_units == Metric) {
if (units == Metric) {
GraphView::setYUnits(QChar(0x00B0) + tr("C"));
setYScale(1);
setYOffset(0);
@ -88,15 +83,12 @@ void TemperatureGraph::setYUnits()
}
}
void TemperatureGraph::setUnits(enum Units units)
void TemperatureGraph::setUnits(Units units)
{
_units = units;
setYUnits();
setYUnits(units);
setInfo();
GraphView::setUnits(units);
redraw();
GraphView::setUnits(units);
}
void TemperatureGraph::showTracks(bool show)

View File

@ -20,12 +20,11 @@ private:
qreal avg() const;
qreal min() const {return bounds().top();}
qreal max() const {return bounds().bottom();}
void setYUnits();
void setYUnits(Units units);
void setInfo();
QList<QPointF> _avg;
enum Units _units;
bool _showTracks;
};

View File

@ -0,0 +1,37 @@
#include "tooltip.h"
#include "temperaturegraphitem.h"
TemperatureGraphItem::TemperatureGraphItem(const Graph &graph, GraphType type,
QGraphicsItem *parent) : GraphItem(graph, type, parent)
{
qreal sum = 0;
for (int j = 1; j < graph.size(); j++)
sum += graph.at(j).y() * (graph.at(j).s() - graph.at(j-1).s());
_avg = sum/graph.last().s();
setToolTip(toolTip(Metric));
}
QString TemperatureGraphItem::toolTip(Units units) const
{
ToolTip tt;
qreal scale = (units == Metric) ? 1.0 : C2FS;
qreal offset = (units == Metric) ? 0 : C2FO;
QString su = (units == Metric) ?
QChar(0x00B0) + tr("C") : QChar(0x00B0) + tr("F");
tt.insert(tr("Average"), QString::number(avg() * scale + offset, 'f', 1)
+ UNIT_SPACE + su);
tt.insert(tr("Maximum"), QString::number(max() * scale + offset, 'f', 1)
+ UNIT_SPACE + su);
tt.insert(tr("Minimum"), QString::number(min() * scale + offset, 'f', 1)
+ UNIT_SPACE + su);
return tt.toString();
}
void TemperatureGraphItem::setUnits(Units units)
{
setToolTip(toolTip(units));
}

View File

@ -0,0 +1,26 @@
#ifndef TEMPERATUREGRAPHITEM_H
#define TEMPERATUREGRAPHITEM_H
#include "graphitem.h"
class TemperatureGraphItem : public GraphItem
{
Q_OBJECT
public:
TemperatureGraphItem(const Graph &graph, GraphType type,
QGraphicsItem *parent = 0);
qreal max() const {return -bounds().top();}
qreal min() const {return -bounds().bottom();}
qreal avg() const {return _avg;}
void setUnits(Units units);
private:
QString toolTip(Units units) const;
qreal _avg;
};
#endif // TEMPERATUREGRAPHITEM_H

Some files were not shown because too many files have changed in this diff Show More