mirror of
https://github.com/tumic0/GPXSee.git
synced 2025-07-01 05:19:15 +02:00
Compare commits
23 Commits
Author | SHA1 | Date | |
---|---|---|---|
4550e473de | |||
7079e30831 | |||
363fc47b88 | |||
db4dc37848 | |||
7abe931ef1 | |||
e583158492 | |||
413a9b25c4 | |||
8a44b7d290 | |||
a809c81fd6 | |||
df6aaf1883 | |||
91bf49610d | |||
4e543782ec | |||
d1bf74f43b | |||
0b4ee95591 | |||
5bd5b88be5 | |||
f54ca1529a | |||
0c002bc1e9 | |||
b0cafe69d0 | |||
f93b54aab0 | |||
a9b3d2595e | |||
81c0789319 | |||
c639c6deac | |||
69095ca9eb |
29
README.md
29
README.md
@ -1,4 +1,29 @@
|
||||
# GPXSee
|
||||
GPX viewer and analyzer
|
||||
GPX viewer and analyzer.
|
||||
|
||||
GPXSee Web page: http://tumic.wz.cz/gpxsee
|
||||
* User-definable map sources.
|
||||
* Track and elevation/speed graphs.
|
||||
* Support for multiple tracks in one view.
|
||||
* Support for POI files (Garmin CSV format).
|
||||
* Export to PDF.
|
||||
* Native GUI for Windows, Mac OS X and Linux.
|
||||
|
||||
## Build
|
||||
### Linux/OS X
|
||||
```shell
|
||||
lrelease gpxsee.pro
|
||||
qmake gpxsee.pro
|
||||
make
|
||||
```
|
||||
### Windows
|
||||
```shell
|
||||
lrelease gpxsee.pro
|
||||
qmake gpxsee.pro
|
||||
nmake release
|
||||
```
|
||||
|
||||
## Binaries
|
||||
Available at Sourceforge: http://sourceforge.net/projects/gpxsee
|
||||
|
||||
## Homepage
|
||||
GPXSee homepage: http://tumic.wz.cz/gpxsee
|
||||
|
@ -63,7 +63,7 @@ Section "GPXSee (required)" SEC_APP
|
||||
; Write the uninstall keys for Windows
|
||||
WriteRegStr HKCU "${REGENTRY}" "DisplayName" "GPXSee"
|
||||
WriteRegStr HKCU "${REGENTRY}" "Publisher" "Martin Tuma"
|
||||
WriteRegStr HKCU "${REGENTRY}" "DisplayVersion" "1.1"
|
||||
WriteRegStr HKCU "${REGENTRY}" "DisplayVersion" "2.1"
|
||||
WriteRegStr HKCU "${REGENTRY}" "UninstallString" '"$INSTDIR\uninstall.exe"'
|
||||
WriteRegDWORD HKCU "${REGENTRY}" "NoModify" 1
|
||||
WriteRegDWORD HKCU "${REGENTRY}" "NoRepair" 1
|
||||
@ -84,8 +84,10 @@ Section "QT libs" SEC_QT
|
||||
File "Qt5Gui.dll"
|
||||
File "Qt5Widgets.dll"
|
||||
File "Qt5PrintSupport.dll"
|
||||
File "Qt5Network.dll"
|
||||
File "libGLESv2.dll"
|
||||
File /r "platforms"
|
||||
File /r "imageformats"
|
||||
|
||||
SectionEnd
|
||||
|
||||
|
13
gpxsee.pro
13
gpxsee.pro
@ -1,6 +1,7 @@
|
||||
TARGET = GPXSee
|
||||
QT += core \
|
||||
gui
|
||||
gui \
|
||||
network
|
||||
greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
|
||||
greaterThan(QT_MAJOR_VERSION, 4): QT += printsupport
|
||||
HEADERS += src/config.h \
|
||||
@ -23,7 +24,10 @@ HEADERS += src/config.h \
|
||||
src/elevationgraph.h \
|
||||
src/speedgraph.h \
|
||||
src/sliderinfoitem.h \
|
||||
src/filebrowser.h
|
||||
src/filebrowser.h \
|
||||
src/map.h \
|
||||
src/maplist.h \
|
||||
src/downloader.h
|
||||
SOURCES += src/main.cpp \
|
||||
src/gui.cpp \
|
||||
src/gpx.cpp \
|
||||
@ -41,7 +45,10 @@ SOURCES += src/main.cpp \
|
||||
src/elevationgraph.cpp \
|
||||
src/speedgraph.cpp \
|
||||
src/sliderinfoitem.cpp \
|
||||
src/filebrowser.cpp
|
||||
src/filebrowser.cpp \
|
||||
src/map.cpp \
|
||||
src/maplist.cpp \
|
||||
src/downloader.cpp
|
||||
RESOURCES += gpxsee.qrc
|
||||
TRANSLATIONS = lang/gpxsee_cs.ts
|
||||
macx:ICON = icons/gpxsee.icns
|
||||
|
@ -7,6 +7,7 @@
|
||||
<file>icons/flag.png</file>
|
||||
<file>icons/gpxsee.png</file>
|
||||
<file>icons/application-exit.png</file>
|
||||
<file>icons/applications-internet.png</file>
|
||||
<file>icons/view-refresh.png</file>
|
||||
<file>lang/gpxsee_cs.qm</file>
|
||||
</qresource>
|
||||
|
BIN
icons/applications-internet.png
Normal file
BIN
icons/applications-internet.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 1.6 KiB |
@ -4,42 +4,42 @@
|
||||
<context>
|
||||
<name>ElevationGraph</name>
|
||||
<message>
|
||||
<location filename="../src/elevationgraph.cpp" line="12"/>
|
||||
<location filename="../src/elevationgraph.cpp" line="13"/>
|
||||
<source>Distance</source>
|
||||
<translation>Vzdálenost</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/elevationgraph.cpp" line="13"/>
|
||||
<location filename="../src/elevationgraph.cpp" line="14"/>
|
||||
<source>Elevation</source>
|
||||
<translation>Výška</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/elevationgraph.cpp" line="14"/>
|
||||
<location filename="../src/elevationgraph.cpp" line="15"/>
|
||||
<source>km</source>
|
||||
<translation>km</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/elevationgraph.cpp" line="15"/>
|
||||
<location filename="../src/elevationgraph.cpp" line="16"/>
|
||||
<source>m</source>
|
||||
<translation>m</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/elevationgraph.cpp" line="51"/>
|
||||
<location filename="../src/elevationgraph.cpp" line="52"/>
|
||||
<source>Ascent</source>
|
||||
<translation>Stoupání</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/elevationgraph.cpp" line="53"/>
|
||||
<location filename="../src/elevationgraph.cpp" line="54"/>
|
||||
<source>Descent</source>
|
||||
<translation>Klesání</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/elevationgraph.cpp" line="57"/>
|
||||
<location filename="../src/elevationgraph.cpp" line="58"/>
|
||||
<source>Minimum</source>
|
||||
<translation>Minimum</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/elevationgraph.cpp" line="55"/>
|
||||
<location filename="../src/elevationgraph.cpp" line="56"/>
|
||||
<source>Maximum</source>
|
||||
<translation>Maximum</translation>
|
||||
</message>
|
||||
@ -47,253 +47,291 @@
|
||||
<context>
|
||||
<name>GUI</name>
|
||||
<message>
|
||||
<location filename="../src/gui.cpp" line="90"/>
|
||||
<location filename="../src/gui.cpp" line="135"/>
|
||||
<source>About Qt</source>
|
||||
<translation>O Qt</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/gui.cpp" line="217"/>
|
||||
<location filename="../src/gui.cpp" line="295"/>
|
||||
<source>GPXSee is distributed under the terms of the GNU General Public License version 3. For more info about GPXSee visit the project homepage at </source>
|
||||
<translation>Program GPXSee je distribuován pod podmínkami licence GNU General Public License verze 3. Pro více informací navštivte stránky programu na adrese </translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/gui.cpp" line="247"/>
|
||||
<location filename="../src/gui.cpp" line="354"/>
|
||||
<source>Open file</source>
|
||||
<translation>Otevřít soubor</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/gui.cpp" line="104"/>
|
||||
<location filename="../src/gui.cpp" line="149"/>
|
||||
<source>Save as</source>
|
||||
<translation>Uložit jako</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/gui.cpp" line="293"/>
|
||||
<location filename="../src/gui.cpp" line="405"/>
|
||||
<source>Open POI file</source>
|
||||
<translation>Otevřít POI soubor</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/gui.cpp" line="95"/>
|
||||
<location filename="../src/gui.cpp" line="140"/>
|
||||
<source>Open</source>
|
||||
<translation>Otevřít</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/gui.cpp" line="80"/>
|
||||
<location filename="../src/gui.cpp" line="123"/>
|
||||
<source>Quit</source>
|
||||
<translation>Ukončit</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/gui.cpp" line="85"/>
|
||||
<location filename="../src/gui.cpp" line="233"/>
|
||||
<location filename="../src/gui.cpp" line="234"/>
|
||||
<location filename="../src/gui.cpp" line="130"/>
|
||||
<location filename="../src/gui.cpp" line="311"/>
|
||||
<location filename="../src/gui.cpp" line="312"/>
|
||||
<source>Keyboard controls</source>
|
||||
<translation>Ovládací klávesy</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/gui.cpp" line="99"/>
|
||||
<location filename="../src/gui.cpp" line="144"/>
|
||||
<source>Save</source>
|
||||
<translation>Uložit</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/gui.cpp" line="109"/>
|
||||
<location filename="../src/gui.cpp" line="154"/>
|
||||
<source>Close</source>
|
||||
<translation>Zavřít</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/gui.cpp" line="114"/>
|
||||
<location filename="../src/gui.cpp" line="159"/>
|
||||
<source>Reload</source>
|
||||
<translation>Znovu načíst</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/gui.cpp" line="121"/>
|
||||
<source>Load file</source>
|
||||
<translation>Nahrát soubor</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/gui.cpp" line="124"/>
|
||||
<location filename="../src/gui.cpp" line="244"/>
|
||||
<source>Show</source>
|
||||
<translation>Zobrazit</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/gui.cpp" line="131"/>
|
||||
<location filename="../src/gui.cpp" line="158"/>
|
||||
<location filename="../src/gui.cpp" line="198"/>
|
||||
<location filename="../src/gui.cpp" line="235"/>
|
||||
<source>File</source>
|
||||
<translation>Soubor</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/gui.cpp" line="145"/>
|
||||
<location filename="../src/gui.cpp" line="167"/>
|
||||
<location filename="../src/gui.cpp" line="128"/>
|
||||
<location filename="../src/gui.cpp" line="327"/>
|
||||
<location filename="../src/gui.cpp" line="328"/>
|
||||
<source>Data sources</source>
|
||||
<translation>Zdroje dat</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/gui.cpp" line="166"/>
|
||||
<source>Load POI file</source>
|
||||
<translation>Nahrát POI soubor</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/gui.cpp" line="169"/>
|
||||
<source>Show POIs</source>
|
||||
<translation>Zobrazit POI</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/gui.cpp" line="174"/>
|
||||
<source>Show map</source>
|
||||
<translation>Zobrazit mapu</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/gui.cpp" line="184"/>
|
||||
<source>Show graphs</source>
|
||||
<translation>Zobrazovat grafy</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/gui.cpp" line="189"/>
|
||||
<source>Show toolbars</source>
|
||||
<translation>Zobrazovat nástrojové lišty</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/gui.cpp" line="212"/>
|
||||
<source>Map</source>
|
||||
<translation>Mapa</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/gui.cpp" line="217"/>
|
||||
<source>POI</source>
|
||||
<translation>POI</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/gui.cpp" line="149"/>
|
||||
<location filename="../src/gui.cpp" line="221"/>
|
||||
<source>Settings</source>
|
||||
<translation>Nastavení</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/gui.cpp" line="225"/>
|
||||
<source>Help</source>
|
||||
<translation>Nápověda</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/gui.cpp" line="185"/>
|
||||
<location filename="../src/gui.cpp" line="263"/>
|
||||
<source>Elevation</source>
|
||||
<translation>Výška</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/gui.cpp" line="186"/>
|
||||
<location filename="../src/gui.cpp" line="264"/>
|
||||
<source>Speed</source>
|
||||
<translation>Rychlost</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/gui.cpp" line="236"/>
|
||||
<location filename="../src/gui.cpp" line="314"/>
|
||||
<source>Next file</source>
|
||||
<translation>Následující soubor</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/gui.cpp" line="237"/>
|
||||
<location filename="../src/gui.cpp" line="315"/>
|
||||
<source>Previous file</source>
|
||||
<translation>Předchozí soubor</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/gui.cpp" line="239"/>
|
||||
<location filename="../src/gui.cpp" line="317"/>
|
||||
<source>Append modifier</source>
|
||||
<translation>Modifikátor nahradit/přidat</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/gui.cpp" line="349"/>
|
||||
<location filename="../src/gui.cpp" line="331"/>
|
||||
<source>Map (tiles) source URLs are read on program startup from the following file:</source>
|
||||
<translation>URL mapových zdrojů (dlaždic) jsou načteny při startu programu z následujícího souboru:</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/gui.cpp" line="335"/>
|
||||
<source>The file format is one map entry per line, consisting of the map name and tiles URL delimited by a TAB character. The tile X and Y coordinates are replaced with $x and $y in the URL and the zoom level is replaced with $z. An example map file could look like:</source>
|
||||
<translation>Formát souboru je jeden mapový záznam na řádku, kde mapový záznam sestává ze jména mapy a URL dlaždic navzájem oddělených tabulátorem. Souřadnice dlaždice jsou v URL nahrazeny řetězci $x a $y, úroven přiblížení (zoom) pak řetězcem $z. Příklad:</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/gui.cpp" line="343"/>
|
||||
<source>To make GPXSee load a POI file automatically on startup, add the file to the following directory:</source>
|
||||
<translation>POI soubory, které se mají automaticky nahrát při startu programu jsou načítány z následujícího adresáře:</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/gui.cpp" line="396"/>
|
||||
<location filename="../src/gui.cpp" line="412"/>
|
||||
<source>Line: %1</source>
|
||||
<translation>Řádka: %1</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/gui.cpp" line="464"/>
|
||||
<source>Maximum</source>
|
||||
<translation>Maximum</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/gui.cpp" line="351"/>
|
||||
<location filename="../src/gui.cpp" line="466"/>
|
||||
<source>Minimum</source>
|
||||
<translation>Minimum</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/gui.cpp" line="88"/>
|
||||
<location filename="../src/gui.cpp" line="213"/>
|
||||
<location filename="../src/gui.cpp" line="133"/>
|
||||
<location filename="../src/gui.cpp" line="291"/>
|
||||
<source>About GPXSee</source>
|
||||
<translation>O aplikaci GPXSee</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/gui.cpp" line="215"/>
|
||||
<location filename="../src/gui.cpp" line="293"/>
|
||||
<source>GPX viewer and analyzer</source>
|
||||
<translation>Prohlížeč a analyzátor GPX</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/gui.cpp" line="330"/>
|
||||
<source>Map sources</source>
|
||||
<translation>Mapové zdroje</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/gui.cpp" line="342"/>
|
||||
<source>POIs</source>
|
||||
<translation>POI body</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/gui.cpp" line="457"/>
|
||||
<source>Distance</source>
|
||||
<translation>Vzdálenost</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/gui.cpp" line="344"/>
|
||||
<location filename="../src/gui.cpp" line="459"/>
|
||||
<source>Time</source>
|
||||
<translation>Čas</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/gui.cpp" line="345"/>
|
||||
<location filename="../src/gui.cpp" line="460"/>
|
||||
<source>Ascent</source>
|
||||
<translation>Stoupání</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/gui.cpp" line="346"/>
|
||||
<location filename="../src/gui.cpp" line="348"/>
|
||||
<location filename="../src/gui.cpp" line="350"/>
|
||||
<location filename="../src/gui.cpp" line="352"/>
|
||||
<location filename="../src/gui.cpp" line="461"/>
|
||||
<location filename="../src/gui.cpp" line="463"/>
|
||||
<location filename="../src/gui.cpp" line="465"/>
|
||||
<location filename="../src/gui.cpp" line="467"/>
|
||||
<source>m</source>
|
||||
<translation>m</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/gui.cpp" line="347"/>
|
||||
<location filename="../src/gui.cpp" line="462"/>
|
||||
<source>Descent</source>
|
||||
<translation>Klesání</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/gui.cpp" line="418"/>
|
||||
<location filename="../src/gui.cpp" line="558"/>
|
||||
<source>%1 tracks</source>
|
||||
<translation>Počet tras: %1</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/gui.cpp" line="343"/>
|
||||
<location filename="../src/gui.cpp" line="421"/>
|
||||
<location filename="../src/gui.cpp" line="458"/>
|
||||
<location filename="../src/gui.cpp" line="561"/>
|
||||
<source>km</source>
|
||||
<translation>km</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/gui.cpp" line="285"/>
|
||||
<location filename="../src/gui.cpp" line="297"/>
|
||||
<location filename="../src/gui.cpp" line="398"/>
|
||||
<location filename="../src/gui.cpp" line="413"/>
|
||||
<source>Error</source>
|
||||
<translation>Chyba</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/gui.cpp" line="286"/>
|
||||
<location filename="../src/gui.cpp" line="393"/>
|
||||
<source>Error loading GPX file:
|
||||
%1</source>
|
||||
<translation>Soubor GPX nelze otevřít:
|
||||
%1</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/gui.cpp" line="298"/>
|
||||
<location filename="../src/gui.cpp" line="409"/>
|
||||
<source>Error loading POI file:
|
||||
%1</source>
|
||||
<translation>Soubor POI nelze otevřít:
|
||||
%1</translation>
|
||||
</message>
|
||||
</context>
|
||||
<context>
|
||||
<name>QObject</name>
|
||||
<message>
|
||||
<location filename="../src/parser.cpp" line="97"/>
|
||||
<source>Not a GPX file.</source>
|
||||
<translation>Neplatný GPX soubor.</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/parser.cpp" line="106"/>
|
||||
<source>%1
|
||||
Line %2</source>
|
||||
<translation>%1
|
||||
Rádka %2</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/poi.cpp" line="31"/>
|
||||
<source>Invalid latitude
|
||||
Line %1</source>
|
||||
<translation>Neplatná zeměpisná šířka
|
||||
Rádka %1</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/poi.cpp" line="36"/>
|
||||
<source>Invalid longitude
|
||||
Line %1</source>
|
||||
<translation>Neplatná zeměpisná délka
|
||||
Rádka %1</translation>
|
||||
</message>
|
||||
</context>
|
||||
<context>
|
||||
<name>SpeedGraph</name>
|
||||
<message>
|
||||
<location filename="../src/speedgraph.cpp" line="11"/>
|
||||
<location filename="../src/speedgraph.cpp" line="9"/>
|
||||
<source>Distance</source>
|
||||
<translation>Vzdálenost</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/speedgraph.cpp" line="12"/>
|
||||
<location filename="../src/speedgraph.cpp" line="10"/>
|
||||
<source>Speed</source>
|
||||
<translation>Rychlost</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/speedgraph.cpp" line="13"/>
|
||||
<location filename="../src/speedgraph.cpp" line="11"/>
|
||||
<source>km</source>
|
||||
<translation></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/speedgraph.cpp" line="14"/>
|
||||
<location filename="../src/speedgraph.cpp" line="12"/>
|
||||
<source>km/h</source>
|
||||
<translation>km/h</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/speedgraph.cpp" line="37"/>
|
||||
<location filename="../src/speedgraph.cpp" line="35"/>
|
||||
<source>Average</source>
|
||||
<translation>Průměr</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/speedgraph.cpp" line="39"/>
|
||||
<location filename="../src/speedgraph.cpp" line="37"/>
|
||||
<source>Maximum</source>
|
||||
<translation>Maximum</translation>
|
||||
</message>
|
||||
|
@ -3,14 +3,12 @@
|
||||
#include "config.h"
|
||||
#include "axisitem.h"
|
||||
|
||||
#include <QDebug>
|
||||
|
||||
#define TICK 6
|
||||
#define PADDING 6
|
||||
#define XTICKS 15
|
||||
#define YTICKS 10
|
||||
|
||||
|
||||
struct Label {
|
||||
double min;
|
||||
double max;
|
||||
|
@ -1,11 +1,11 @@
|
||||
#include "colorshop.h"
|
||||
|
||||
|
||||
#define HUE_INIT 0.1f
|
||||
#define HUE_INCREMENT 0.62f
|
||||
#define SATURATION 0.99f
|
||||
#define VALUE 0.99f
|
||||
|
||||
|
||||
static unsigned hsv2rgb(float h, float s, float v)
|
||||
{
|
||||
unsigned hi;
|
||||
|
11
src/config.h
11
src/config.h
@ -3,11 +3,18 @@
|
||||
|
||||
#define APP_NAME "GPXSee"
|
||||
#define APP_HOMEPAGE "http://tumic.wz.cz/gpxsee"
|
||||
#define APP_VERSION "1.1"
|
||||
#define APP_VERSION "2.1"
|
||||
|
||||
#define FONT_FAMILY "Arial"
|
||||
#define FONT_SIZE 12
|
||||
|
||||
#define THIN_SPACE QString::fromUtf8("\xE2\x80\x89")
|
||||
#if defined(Q_OS_WIN32)
|
||||
#define APP_DIR "GPXSee"
|
||||
#else
|
||||
#define APP_DIR ".gpxsee"
|
||||
#endif
|
||||
#define POI_DIR APP_DIR"/POI"
|
||||
#define TILES_DIR APP_DIR"/tiles"
|
||||
#define MAP_LIST_FILE APP_DIR"/maps.txt"
|
||||
|
||||
#endif /* CONFIG_H */
|
||||
|
75
src/downloader.cpp
Normal file
75
src/downloader.cpp
Normal file
@ -0,0 +1,75 @@
|
||||
#include <QFile>
|
||||
#include <QFileInfo>
|
||||
#include "config.h"
|
||||
#include "downloader.h"
|
||||
|
||||
|
||||
#if defined(Q_OS_LINUX)
|
||||
#define PLATFORM_STR "Linux"
|
||||
#elif defined(Q_OS_WIN32)
|
||||
#define PLATFORM_STR "Windows"
|
||||
#elif defined(Q_OS_MAC)
|
||||
#define PLATFORM_STR "OS X"
|
||||
#else
|
||||
#define PLATFORM_STR "Unknown"
|
||||
#endif
|
||||
|
||||
#define USER_AGENT APP_NAME"/"APP_VERSION" ("PLATFORM_STR"; Qt "QT_VERSION_STR")"
|
||||
|
||||
Downloader::Downloader()
|
||||
{
|
||||
connect(&manager, SIGNAL(finished(QNetworkReply*)),
|
||||
SLOT(downloadFinished(QNetworkReply*)));
|
||||
}
|
||||
|
||||
void Downloader::doDownload(const Download &dl)
|
||||
{
|
||||
QUrl url(dl.url());
|
||||
QNetworkRequest request(url);
|
||||
request.setAttribute(QNetworkRequest::User, QVariant(dl.file()));
|
||||
request.setRawHeader("User-Agent", USER_AGENT);
|
||||
QNetworkReply *reply = manager.get(request);
|
||||
|
||||
currentDownloads.append(reply);
|
||||
}
|
||||
|
||||
bool Downloader::saveToDisk(const QString &filename, QIODevice *data)
|
||||
{
|
||||
QFile file(filename);
|
||||
|
||||
if (!file.open(QIODevice::WriteOnly)) {
|
||||
fprintf(stderr, "Error writing map tile: %s: %s\n",
|
||||
qPrintable(filename), qPrintable(file.errorString()));
|
||||
return false;
|
||||
}
|
||||
|
||||
file.write(data->readAll());
|
||||
file.close();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void Downloader::downloadFinished(QNetworkReply *reply)
|
||||
{
|
||||
QUrl url = reply->url();
|
||||
if (reply->error()) {
|
||||
fprintf(stderr, "Error downloading map tile: %s: %s\n",
|
||||
url.toEncoded().constData(), qPrintable(reply->errorString()));
|
||||
} else {
|
||||
QString filename = reply->request().attribute(QNetworkRequest::User)
|
||||
.toString();
|
||||
saveToDisk(filename, reply);
|
||||
}
|
||||
|
||||
currentDownloads.removeAll(reply);
|
||||
reply->deleteLater();
|
||||
|
||||
if (currentDownloads.isEmpty())
|
||||
emit finished();
|
||||
}
|
||||
|
||||
void Downloader::get(const QList<Download> &list)
|
||||
{
|
||||
for (int i = 0; i < list.count(); i++)
|
||||
doDownload(list.at(i));
|
||||
}
|
52
src/downloader.h
Normal file
52
src/downloader.h
Normal file
@ -0,0 +1,52 @@
|
||||
#ifndef DOWNLOADER_H
|
||||
#define DOWNLOADER_H
|
||||
|
||||
#include <QNetworkAccessManager>
|
||||
#include <QNetworkRequest>
|
||||
#include <QNetworkReply>
|
||||
#include <QUrl>
|
||||
#include <QList>
|
||||
|
||||
|
||||
class Download
|
||||
{
|
||||
public:
|
||||
Download(const QString &url, const QString &file)
|
||||
{_url = url; _file = file;}
|
||||
const QString& url() const {return _url;}
|
||||
const QString& file() const {return _file;}
|
||||
|
||||
private:
|
||||
QString _url;
|
||||
QString _file;
|
||||
};
|
||||
|
||||
|
||||
class Downloader : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
static Downloader& instance()
|
||||
{static Downloader i; return i;}
|
||||
void get(const QList<Download> &list);
|
||||
|
||||
signals:
|
||||
void finished();
|
||||
|
||||
private slots:
|
||||
void downloadFinished(QNetworkReply *reply);
|
||||
|
||||
private:
|
||||
Downloader();
|
||||
Downloader(Downloader const&);
|
||||
void operator=(Downloader const&);
|
||||
|
||||
void doDownload(const Download &dl);
|
||||
bool saveToDisk(const QString &filename, QIODevice *data);
|
||||
|
||||
QNetworkAccessManager manager;
|
||||
QList<QNetworkReply *> currentDownloads;
|
||||
};
|
||||
|
||||
#endif // DOWNLOADER_H
|
@ -2,6 +2,7 @@
|
||||
#include "config.h"
|
||||
#include "elevationgraph.h"
|
||||
|
||||
|
||||
ElevationGraph::ElevationGraph(QWidget *parent) : Graph(parent)
|
||||
{
|
||||
_ascent = 0;
|
||||
|
@ -2,8 +2,6 @@
|
||||
#include <QDir>
|
||||
#include "filebrowser.h"
|
||||
|
||||
#include <QDebug>
|
||||
|
||||
|
||||
FileBrowser::FileBrowser(QObject *parent) : QObject(parent)
|
||||
{
|
||||
|
16
src/gpx.cpp
16
src/gpx.cpp
@ -3,14 +3,11 @@
|
||||
#include "ll.h"
|
||||
#include "gpx.h"
|
||||
|
||||
#include <QDebug>
|
||||
|
||||
|
||||
#define WINDOW_EF 3
|
||||
#define WINDOW_SE 11
|
||||
#define WINDOW_SF 11
|
||||
|
||||
|
||||
static bool lt(const QPointF &p1, const QPointF &p2)
|
||||
{
|
||||
return p1.y() < p2.y();
|
||||
@ -90,14 +87,17 @@ bool GPX::loadFile(const QString &fileName)
|
||||
|
||||
_data.clear();
|
||||
_error.clear();
|
||||
_errorLine = 0;
|
||||
|
||||
if (!file.open(QFile::ReadOnly | QFile::Text)) {
|
||||
_error = qPrintable(file.errorString());
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!(ret = _parser.loadFile(&file, _data)))
|
||||
if (!(ret = _parser.loadFile(&file, _data))) {
|
||||
_error = _parser.errorString();
|
||||
_errorLine = _parser.errorLine();
|
||||
}
|
||||
file.close();
|
||||
|
||||
return ret;
|
||||
@ -150,12 +150,8 @@ void GPX::speedGraph(QVector<QPointF> &graph) const
|
||||
|
||||
void GPX::track(QVector<QPointF> &track) const
|
||||
{
|
||||
QPointF p;
|
||||
|
||||
for (int i = 0; i < _data.size(); i++) {
|
||||
ll2mercator(_data.at(i).coordinates, p);
|
||||
track.append(p);
|
||||
}
|
||||
for (int i = 0; i < _data.size(); i++)
|
||||
track.append(ll2mercator(_data.at(i).coordinates));
|
||||
}
|
||||
|
||||
qreal GPX::distance() const
|
||||
|
@ -11,6 +11,7 @@ class GPX
|
||||
public:
|
||||
bool loadFile(const QString &fileName);
|
||||
const QString &errorString() const {return _error;}
|
||||
int errorLine() const {return _errorLine;}
|
||||
|
||||
void elevationGraph(QVector<QPointF> &graph) const;
|
||||
void speedGraph(QVector<QPointF> &graph) const;
|
||||
@ -23,6 +24,7 @@ private:
|
||||
Parser _parser;
|
||||
QVector<TrackPoint> _data;
|
||||
QString _error;
|
||||
int _errorLine;
|
||||
};
|
||||
|
||||
#endif // GPX_H
|
||||
|
@ -9,12 +9,9 @@
|
||||
#include "config.h"
|
||||
#include "graph.h"
|
||||
|
||||
#include <QDebug>
|
||||
|
||||
|
||||
#define MARGIN 10.0
|
||||
|
||||
|
||||
void Scene::mousePressEvent(QGraphicsSceneMouseEvent *e)
|
||||
{
|
||||
if (e->button() == Qt::LeftButton)
|
||||
|
@ -10,6 +10,8 @@
|
||||
#include "colorshop.h"
|
||||
|
||||
|
||||
#define THIN_SPACE QString::fromUtf8("\xE2\x80\x89")
|
||||
|
||||
class SliderItem;
|
||||
class SliderInfoItem;
|
||||
class InfoItem;
|
||||
|
189
src/gui.cpp
189
src/gui.cpp
@ -7,10 +7,13 @@
|
||||
#include <QPrinter>
|
||||
#include <QPainter>
|
||||
#include <QKeyEvent>
|
||||
#include <QSignalMapper>
|
||||
#include "config.h"
|
||||
#include "icons.h"
|
||||
#include "keys.h"
|
||||
#include "gpx.h"
|
||||
#include "map.h"
|
||||
#include "maplist.h"
|
||||
#include "elevationgraph.h"
|
||||
#include "speedgraph.h"
|
||||
#include "track.h"
|
||||
@ -18,8 +21,6 @@
|
||||
#include "filebrowser.h"
|
||||
#include "gui.h"
|
||||
|
||||
#include <QDebug>
|
||||
|
||||
|
||||
static QString timeSpan(qreal time)
|
||||
{
|
||||
@ -36,6 +37,8 @@ static QString timeSpan(qreal time)
|
||||
|
||||
GUI::GUI()
|
||||
{
|
||||
loadFiles();
|
||||
|
||||
createActions();
|
||||
createMenus();
|
||||
createToolBars();
|
||||
@ -68,6 +71,46 @@ GUI::GUI()
|
||||
resize(600, 800);
|
||||
}
|
||||
|
||||
void GUI::loadFiles()
|
||||
{
|
||||
// Maps
|
||||
_maps = MapList::load(QString("%1/"MAP_LIST_FILE).arg(QDir::homePath()));
|
||||
|
||||
// POI files
|
||||
QDir dir(QString("%1/"POI_DIR).arg(QDir::homePath()));
|
||||
QFileInfoList list = dir.entryInfoList(QStringList(), QDir::Files);
|
||||
for (int i = 0; i < list.size(); ++i) {
|
||||
if (!_poi.loadFile(list.at(i).absoluteFilePath()))
|
||||
fprintf(stderr, "Error loading POI file: %s: %s",
|
||||
qPrintable(list.at(i).absoluteFilePath()),
|
||||
qPrintable(_poi.errorString()));
|
||||
}
|
||||
}
|
||||
|
||||
void GUI::createMapActions()
|
||||
{
|
||||
QActionGroup *ag = new QActionGroup(this);
|
||||
ag->setExclusive(true);
|
||||
|
||||
QSignalMapper *sm = new QSignalMapper(this);
|
||||
|
||||
for (int i = 0; i < _maps.count(); i++) {
|
||||
QAction *a = new QAction(_maps.at(i)->name(), this);
|
||||
a->setCheckable(true);
|
||||
a->setActionGroup(ag);
|
||||
|
||||
sm->setMapping(a, i);
|
||||
connect(a, SIGNAL(triggered()), sm, SLOT(map()));
|
||||
|
||||
_mapActions.append(a);
|
||||
}
|
||||
|
||||
connect(sm, SIGNAL(mapped(int)), this, SLOT(mapChanged(int)));
|
||||
|
||||
_mapActions.at(0)->setChecked(true);
|
||||
_currentMap = _maps.at(0);
|
||||
}
|
||||
|
||||
void GUI::createActions()
|
||||
{
|
||||
// Action Groups
|
||||
@ -82,6 +125,8 @@ void GUI::createActions()
|
||||
connect(_exitAction, SIGNAL(triggered()), this, SLOT(close()));
|
||||
|
||||
// Help & About
|
||||
_dataSourcesAction = new QAction(tr("Data sources"), this);
|
||||
connect(_dataSourcesAction, SIGNAL(triggered()), this, SLOT(dataSources()));
|
||||
_keysAction = new QAction(tr("Keyboard controls"), this);
|
||||
connect(_keysAction, SIGNAL(triggered()), this, SLOT(keys()));
|
||||
_aboutAction = new QAction(QIcon(QPixmap(APP_ICON)),
|
||||
@ -118,12 +163,34 @@ void GUI::createActions()
|
||||
|
||||
// POI actions
|
||||
_openPOIAction = new QAction(QIcon(QPixmap(OPEN_FILE_ICON)),
|
||||
tr("Load file"), this);
|
||||
tr("Load POI file"), this);
|
||||
connect(_openPOIAction, SIGNAL(triggered()), this, SLOT(openPOIFile()));
|
||||
_showPOIAction = new QAction(QIcon(QPixmap(SHOW_POI_ICON)),
|
||||
tr("Show"), this);
|
||||
tr("Show POIs"), this);
|
||||
_showPOIAction->setCheckable(true);
|
||||
connect(_showPOIAction, SIGNAL(triggered()), this, SLOT(showPOI()));
|
||||
connect(_showPOIAction, SIGNAL(triggered(bool)), this, SLOT(showPOI(bool)));
|
||||
|
||||
// Map actions
|
||||
_showMapAction = new QAction(QIcon(QPixmap(SHOW_MAP_ICON)), tr("Show map"),
|
||||
this);
|
||||
_showMapAction->setCheckable(true);
|
||||
connect(_showMapAction, SIGNAL(triggered(bool)), this, SLOT(showMap(bool)));
|
||||
if (_maps.empty())
|
||||
_showMapAction->setEnabled(false);
|
||||
else
|
||||
createMapActions();
|
||||
|
||||
// Settings actions
|
||||
_showGraphsAction = new QAction(tr("Show graphs"), this);
|
||||
_showGraphsAction->setCheckable(true);
|
||||
_showGraphsAction->setChecked(true);
|
||||
connect(_showGraphsAction, SIGNAL(triggered(bool)), this,
|
||||
SLOT(showGraphs(bool)));
|
||||
_showToolbarsAction = new QAction(tr("Show toolbars"), this);
|
||||
_showToolbarsAction->setCheckable(true);
|
||||
_showToolbarsAction->setChecked(true);
|
||||
connect(_showToolbarsAction, SIGNAL(triggered(bool)), this,
|
||||
SLOT(showToolbars(bool)));
|
||||
}
|
||||
|
||||
void GUI::createMenus()
|
||||
@ -137,16 +204,26 @@ void GUI::createMenus()
|
||||
_fileMenu->addAction(_reloadFileAction);
|
||||
_fileMenu->addSeparator();
|
||||
_fileMenu->addAction(_closeFileAction);
|
||||
#ifndef __APPLE__
|
||||
#ifndef Q_OS_MAC
|
||||
_fileMenu->addSeparator();
|
||||
_fileMenu->addAction(_exitAction);
|
||||
#endif // __APPLE__
|
||||
#endif // Q_OS_MAC
|
||||
|
||||
_mapMenu = menuBar()->addMenu(tr("Map"));
|
||||
_mapMenu->addActions(_mapActions);
|
||||
_mapMenu->addSeparator();
|
||||
_mapMenu->addAction(_showMapAction);
|
||||
|
||||
_poiMenu = menuBar()->addMenu(tr("POI"));
|
||||
_poiMenu->addAction(_openPOIAction);
|
||||
_poiMenu->addAction(_showPOIAction);
|
||||
|
||||
_settingsMenu = menuBar()->addMenu(tr("Settings"));
|
||||
_settingsMenu->addAction(_showToolbarsAction);
|
||||
_settingsMenu->addAction(_showGraphsAction);
|
||||
|
||||
_helpMenu = menuBar()->addMenu(tr("Help"));
|
||||
_helpMenu->addAction(_dataSourcesAction);
|
||||
_helpMenu->addAction(_keysAction);
|
||||
_helpMenu->addSeparator();
|
||||
_helpMenu->addAction(_aboutAction);
|
||||
@ -160,15 +237,16 @@ void GUI::createToolBars()
|
||||
_fileToolBar->addAction(_saveFileAction);
|
||||
_fileToolBar->addAction(_reloadFileAction);
|
||||
_fileToolBar->addAction(_closeFileAction);
|
||||
#ifdef __APPLE__
|
||||
#ifdef Q_OS_MAC
|
||||
_fileToolBar->setToolButtonStyle(Qt::ToolButtonTextUnderIcon);
|
||||
#endif // __APPLE__
|
||||
#endif // Q_OS_MAC
|
||||
|
||||
_poiToolBar = addToolBar(tr("POI"));
|
||||
_poiToolBar->addAction(_showPOIAction);
|
||||
#ifdef __APPLE__
|
||||
_poiToolBar->setToolButtonStyle(Qt::ToolButtonTextUnderIcon);
|
||||
#endif // __APPLE__
|
||||
_showToolBar = addToolBar(tr("Show"));
|
||||
_showToolBar->addAction(_showPOIAction);
|
||||
_showToolBar->addAction(_showMapAction);
|
||||
#ifdef Q_OS_MAC
|
||||
_showToolBar->setToolButtonStyle(Qt::ToolButtonTextUnderIcon);
|
||||
#endif // Q_OS_MAC
|
||||
}
|
||||
|
||||
void GUI::createTrackView()
|
||||
@ -242,6 +320,35 @@ void GUI::keys()
|
||||
msgBox.exec();
|
||||
}
|
||||
|
||||
void GUI::dataSources()
|
||||
{
|
||||
QMessageBox msgBox(this);
|
||||
|
||||
msgBox.setWindowTitle(tr("Data sources"));
|
||||
msgBox.setText(QString("<h3>") + tr("Data sources") + QString("</h3>"));
|
||||
msgBox.setInformativeText(
|
||||
QString("<h4>") + tr("Map sources") + QString("</h4><p>")
|
||||
+ tr("Map (tiles) source URLs are read on program startup from the "
|
||||
"following file:")
|
||||
+ QString("</p><p><code>") + QDir::homePath()
|
||||
+ QString("/"MAP_LIST_FILE"</code></p><p>")
|
||||
+ tr("The file format is one map entry per line, consisting of the map "
|
||||
"name and tiles URL delimited by a TAB character. The tile X and Y "
|
||||
"coordinates are replaced with $x and $y in the URL and the zoom "
|
||||
"level is replaced with $z. An example map file could look like:")
|
||||
+ QString("</p><p><code>Map1 http://tile.server.com/map/$z/$x/$y.png"
|
||||
"<br/>Map2 http://mapserver.org/map/$z-$x-$y</code></p>")
|
||||
|
||||
+ QString("<h4>") + tr("POIs") + QString("</h4><p>")
|
||||
+ tr("To make GPXSee load a POI file automatically on startup, add "
|
||||
"the file to the following directory:")
|
||||
+ QString("</p><p><code>") + QDir::homePath()
|
||||
+ QString("/"POI_DIR"</code></p>")
|
||||
);
|
||||
|
||||
msgBox.exec();
|
||||
}
|
||||
|
||||
void GUI::openFile()
|
||||
{
|
||||
QStringList files = QFileDialog::getOpenFileNames(this, tr("Open file"));
|
||||
@ -282,8 +389,13 @@ bool GUI::loadFile(const QString &fileName)
|
||||
|
||||
return true;
|
||||
} else {
|
||||
QMessageBox::critical(this, tr("Error"), fileName + QString("\n\n")
|
||||
+ tr("Error loading GPX file:\n%1").arg(gpx.errorString()));
|
||||
QString error = fileName + QString("\n\n")
|
||||
+ tr("Error loading GPX file:\n%1").arg(gpx.errorString())
|
||||
+ QString("\n");
|
||||
if (gpx.errorLine())
|
||||
error.append(tr("Line: %1").arg(gpx.errorLine()));
|
||||
|
||||
QMessageBox::critical(this, tr("Error"), error);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@ -294,8 +406,11 @@ void GUI::openPOIFile()
|
||||
|
||||
if (!fileName.isEmpty()) {
|
||||
if (!_poi.loadFile(fileName)) {
|
||||
QMessageBox::critical(this, tr("Error"),
|
||||
tr("Error loading POI file:\n%1").arg(_poi.errorString()));
|
||||
QString error = tr("Error loading POI file:\n%1")
|
||||
.arg(_poi.errorString()) + QString("\n");
|
||||
if (_poi.errorLine())
|
||||
error.append(tr("Line: %1").arg(_poi.errorLine()));
|
||||
QMessageBox::critical(this, tr("Error"), error);
|
||||
} else {
|
||||
_showPOIAction->setChecked(true);
|
||||
_track->loadPOI(_poi);
|
||||
@ -394,14 +509,39 @@ void GUI::closeFile()
|
||||
updateStatusBarInfo();
|
||||
}
|
||||
|
||||
void GUI::showPOI()
|
||||
void GUI::showPOI(bool checked)
|
||||
{
|
||||
if (_showPOIAction->isChecked())
|
||||
if (checked)
|
||||
_track->loadPOI(_poi);
|
||||
else
|
||||
_track->clearPOI();
|
||||
}
|
||||
|
||||
void GUI::showMap(bool checked)
|
||||
{
|
||||
if (checked)
|
||||
_track->setMap(_currentMap);
|
||||
else
|
||||
_track->setMap(0);
|
||||
}
|
||||
|
||||
void GUI::showGraphs(bool checked)
|
||||
{
|
||||
_trackGraphs->setHidden(!checked);
|
||||
}
|
||||
|
||||
void GUI::showToolbars(bool checked)
|
||||
{
|
||||
if (checked) {
|
||||
addToolBar(_fileToolBar);
|
||||
addToolBar(_showToolBar);
|
||||
_fileToolBar->show();
|
||||
_showToolBar->show();
|
||||
} else {
|
||||
removeToolBar(_fileToolBar);
|
||||
removeToolBar(_showToolBar);
|
||||
}
|
||||
}
|
||||
|
||||
void GUI::updateStatusBarInfo()
|
||||
{
|
||||
@ -422,6 +562,14 @@ void GUI::updateStatusBarInfo()
|
||||
_timeLabel->setText(timeSpan(_time));
|
||||
}
|
||||
|
||||
void GUI::mapChanged(int index)
|
||||
{
|
||||
_currentMap = _maps.at(index);
|
||||
|
||||
if (_showMapAction->isChecked())
|
||||
_track->setMap(_currentMap);
|
||||
}
|
||||
|
||||
void GUI::graphChanged(int index)
|
||||
{
|
||||
if (_trackGraphs->widget(index) == _elevationGraph)
|
||||
@ -430,7 +578,6 @@ void GUI::graphChanged(int index)
|
||||
_speedGraph->setSliderPosition(_elevationGraph->sliderPosition());
|
||||
}
|
||||
|
||||
|
||||
void GUI::keyPressEvent(QKeyEvent *event)
|
||||
{
|
||||
QString file;
|
||||
|
22
src/gui.h
22
src/gui.h
@ -16,6 +16,7 @@ class FileBrowser;
|
||||
class ElevationGraph;
|
||||
class SpeedGraph;
|
||||
class Track;
|
||||
class Map;
|
||||
|
||||
class GUI : public QMainWindow
|
||||
{
|
||||
@ -29,17 +30,25 @@ public:
|
||||
private slots:
|
||||
void about();
|
||||
void keys();
|
||||
void dataSources();
|
||||
void saveFile();
|
||||
void saveAs();
|
||||
void openFile();
|
||||
void closeFile();
|
||||
void reloadFile();
|
||||
void openPOIFile();
|
||||
void showPOI();
|
||||
void showPOI(bool checked);
|
||||
void showMap(bool checked);
|
||||
void showGraphs(bool checked);
|
||||
void showToolbars(bool checked);
|
||||
|
||||
void mapChanged(int);
|
||||
void graphChanged(int);
|
||||
|
||||
private:
|
||||
void loadFiles();
|
||||
|
||||
void createMapActions();
|
||||
void createActions();
|
||||
void createMenus();
|
||||
void createToolBars();
|
||||
@ -56,14 +65,17 @@ private:
|
||||
QMenu *_fileMenu;
|
||||
QMenu *_helpMenu;
|
||||
QMenu *_poiMenu;
|
||||
QMenu *_mapMenu;
|
||||
QMenu *_settingsMenu;
|
||||
|
||||
QToolBar *_fileToolBar;
|
||||
QToolBar *_poiToolBar;
|
||||
QToolBar *_showToolBar;
|
||||
QTabWidget *_trackGraphs;
|
||||
QActionGroup *_fileActionGroup;
|
||||
|
||||
QAction *_exitAction;
|
||||
QAction *_keysAction;
|
||||
QAction *_dataSourcesAction;
|
||||
QAction *_aboutAction;
|
||||
QAction *_aboutQtAction;
|
||||
QAction *_saveFileAction;
|
||||
@ -73,6 +85,10 @@ private:
|
||||
QAction *_reloadFileAction;
|
||||
QAction *_openPOIAction;
|
||||
QAction *_showPOIAction;
|
||||
QAction *_showMapAction;
|
||||
QAction *_showGraphsAction;
|
||||
QAction *_showToolbarsAction;
|
||||
QList<QAction*> _mapActions;
|
||||
|
||||
QLabel *_fileNameLabel;
|
||||
QLabel *_distanceLabel;
|
||||
@ -83,10 +99,12 @@ private:
|
||||
Track *_track;
|
||||
|
||||
POI _poi;
|
||||
QList<Map*> _maps;
|
||||
|
||||
FileBrowser *_browser;
|
||||
QList<QString> _files;
|
||||
QString _saveFileName;
|
||||
Map *_currentMap;
|
||||
|
||||
qreal _distance;
|
||||
qreal _time;
|
||||
|
@ -9,6 +9,7 @@
|
||||
#define SAVE_AS_ICON ":/icons/document-save-as.png"
|
||||
#define CLOSE_FILE_ICON ":/icons/dialog-close.png"
|
||||
#define SHOW_POI_ICON ":/icons/flag.png"
|
||||
#define SHOW_MAP_ICON ":/icons/applications-internet.png"
|
||||
#define QUIT_ICON ":/icons/application-exit.png"
|
||||
#define RELOAD_FILE_ICON ":/icons/view-refresh.png"
|
||||
|
||||
|
49
src/ll.cpp
49
src/ll.cpp
@ -1,9 +1,14 @@
|
||||
#include <cmath>
|
||||
#include "ll.h"
|
||||
|
||||
// MSVC workarounds
|
||||
#ifndef M_PI
|
||||
#define M_PI 3.14159265358979323846
|
||||
#endif // M_PI
|
||||
#if defined(_MSC_VER) && (_MSC_VER < 1800)
|
||||
#define log2(n) (log(n)/log(2.0))
|
||||
#endif
|
||||
|
||||
|
||||
#define WGS84_RADIUS 6378137.0
|
||||
#define deg2rad(d) (((d)*M_PI)/180.0)
|
||||
@ -20,8 +25,46 @@ qreal llDistance(const QPointF &p1, const QPointF &p2)
|
||||
return (WGS84_RADIUS * c);
|
||||
}
|
||||
|
||||
void ll2mercator(const QPointF &src, QPointF &dst)
|
||||
QPointF ll2mercator(const QPointF &ll)
|
||||
{
|
||||
dst.setX(src.x());
|
||||
dst.setY(rad2deg(log(tan(M_PI/4.0 + deg2rad(src.y())/2.0))));
|
||||
QPointF m;
|
||||
|
||||
m.setX(ll.x());
|
||||
m.setY(rad2deg(log(tan(M_PI/4.0 + deg2rad(ll.y())/2.0))));
|
||||
|
||||
return m;
|
||||
}
|
||||
|
||||
QPoint mercator2tile(const QPointF &m, int z)
|
||||
{
|
||||
QPoint tile;
|
||||
|
||||
tile.setX((int)(floor((m.x() + 180.0) / 360.0 * pow(2.0, z))));
|
||||
tile.setY((int)(floor((1.0 - (m.y() / 180.0)) / 2.0 * pow(2.0, z))));
|
||||
|
||||
return tile;
|
||||
}
|
||||
|
||||
QPointF tile2mercator(const QPoint &tile, int z)
|
||||
{
|
||||
QPointF m;
|
||||
|
||||
m.setX(tile.x() / pow(2.0, z) * 360.0 - 180);
|
||||
qreal n = M_PI - 2.0 * M_PI * tile.y() / pow(2.0, z);
|
||||
m.setY(rad2deg(atan(0.5 * (exp(n) - exp(-n)))));
|
||||
|
||||
return ll2mercator(m);
|
||||
}
|
||||
|
||||
int scale2zoom(qreal scale)
|
||||
{
|
||||
int zoom;
|
||||
|
||||
zoom = (int)log2(360.0/(scale * (qreal)TILE_SIZE));
|
||||
|
||||
if (zoom < ZOOM_MIN)
|
||||
return ZOOM_MIN;
|
||||
if (zoom > ZOOM_MAX)
|
||||
return ZOOM_MAX;
|
||||
return zoom;
|
||||
}
|
||||
|
9
src/ll.h
9
src/ll.h
@ -3,7 +3,14 @@
|
||||
|
||||
#include <QPointF>
|
||||
|
||||
void ll2mercator(const QPointF &src, QPointF &dst);
|
||||
#define TILE_SIZE 256
|
||||
#define ZOOM_MAX 18
|
||||
#define ZOOM_MIN 3
|
||||
|
||||
QPointF ll2mercator(const QPointF &ll);
|
||||
qreal llDistance(const QPointF &p1, const QPointF &p2);
|
||||
QPoint mercator2tile(const QPointF &m, int zoom);
|
||||
QPointF tile2mercator(const QPoint &tile, int zoom);
|
||||
int scale2zoom(qreal scale);
|
||||
|
||||
#endif // LL_H
|
||||
|
@ -13,9 +13,9 @@ int main(int argc, char *argv[])
|
||||
QTranslator translator;
|
||||
translator.load(QString(":/lang/gpxsee_") + locale);
|
||||
app.installTranslator(&translator);
|
||||
#ifdef __APPLE__
|
||||
#ifdef Q_OS_MAC
|
||||
app.setAttribute(Qt::AA_DontShowIconsInMenus);
|
||||
#endif // __APPLE__
|
||||
#endif // Q_OS_MAC
|
||||
|
||||
GUI gui;
|
||||
gui.setWindowIcon(QIcon(QPixmap(APP_ICON)));
|
||||
|
57
src/map.cpp
Normal file
57
src/map.cpp
Normal file
@ -0,0 +1,57 @@
|
||||
#include <QFileInfo>
|
||||
#include <QDir>
|
||||
#include "downloader.h"
|
||||
#include "ll.h"
|
||||
#include "config.h"
|
||||
#include "map.h"
|
||||
|
||||
|
||||
Map::Map(const QString &name, const QString &url)
|
||||
{
|
||||
_name = name;
|
||||
_url = url;
|
||||
|
||||
connect(&Downloader::instance(), SIGNAL(finished()), this,
|
||||
SLOT(emitLoaded()));
|
||||
|
||||
if (!QDir::home().mkpath(QString(TILES_DIR"/%1").arg(_name)))
|
||||
fprintf(stderr, "Error creating tiles dir: %s\n",
|
||||
qPrintable(QDir::home().absolutePath() + QString("/"TILES_DIR"/%1")
|
||||
.arg(_name)));
|
||||
}
|
||||
|
||||
void Map::emitLoaded()
|
||||
{
|
||||
emit loaded();
|
||||
}
|
||||
|
||||
void Map::loadTiles(QList<Tile> &list)
|
||||
{
|
||||
QList<Download> dl;
|
||||
|
||||
for (int i = 0; i < list.size(); ++i) {
|
||||
Tile &t = list[i];
|
||||
QString file = QString("%1/"TILES_DIR"/%2/%3-%4-%5")
|
||||
.arg(QDir::homePath()).arg(_name).arg(t.zoom()).arg(t.xy().rx())
|
||||
.arg(t.xy().ry());
|
||||
QFileInfo fi(file);
|
||||
|
||||
if (fi.exists()) {
|
||||
if (!t.pixmap().load(file))
|
||||
fprintf(stderr, "Error loading map tile: %s\n",
|
||||
qPrintable(file));
|
||||
} else {
|
||||
t.pixmap() = QPixmap(TILE_SIZE, TILE_SIZE);
|
||||
t.pixmap().fill();
|
||||
|
||||
QString url(_url);
|
||||
url.replace("$z", QString::number(t.zoom()));
|
||||
url.replace("$x", QString::number(t.xy().x()));
|
||||
url.replace("$y", QString::number(t.xy().y()));
|
||||
dl.append(Download(url, file));
|
||||
}
|
||||
}
|
||||
|
||||
if (!dl.empty())
|
||||
Downloader::instance().get(dl);
|
||||
}
|
46
src/map.h
Normal file
46
src/map.h
Normal file
@ -0,0 +1,46 @@
|
||||
#ifndef MAP_H
|
||||
#define MAP_H
|
||||
|
||||
#include <QPixmap>
|
||||
#include "downloader.h"
|
||||
|
||||
|
||||
class Tile
|
||||
{
|
||||
public:
|
||||
Tile(const QPoint &xy, int zoom)
|
||||
{_xy = xy; _zoom = zoom;}
|
||||
|
||||
int zoom() {return _zoom;}
|
||||
QPoint& xy() {return _xy;}
|
||||
QPixmap& pixmap() {return _pixmap;}
|
||||
|
||||
private:
|
||||
int _zoom;
|
||||
QPoint _xy;
|
||||
QPixmap _pixmap;
|
||||
};
|
||||
|
||||
|
||||
class Map : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
signals:
|
||||
void loaded();
|
||||
|
||||
public:
|
||||
Map(const QString &name, const QString &url);
|
||||
|
||||
const QString &name() {return _name;}
|
||||
void loadTiles(QList<Tile> &list);
|
||||
|
||||
private slots:
|
||||
void emitLoaded();
|
||||
|
||||
private:
|
||||
QString _name;
|
||||
QString _url;
|
||||
};
|
||||
|
||||
#endif // MAP_H
|
40
src/maplist.cpp
Normal file
40
src/maplist.cpp
Normal file
@ -0,0 +1,40 @@
|
||||
#include <QFile>
|
||||
#include <QFileInfo>
|
||||
#include "maplist.h"
|
||||
|
||||
|
||||
QList<Map*> MapList::load(const QString &fileName)
|
||||
{
|
||||
QList<Map*> mapList;
|
||||
QFileInfo fi(fileName);
|
||||
|
||||
if (!fi.exists())
|
||||
return mapList;
|
||||
|
||||
QFile file(fileName);
|
||||
|
||||
if (!file.open(QFile::ReadOnly | QFile::Text)) {
|
||||
fprintf(stderr, "Error opening map list file: %s: %s\n",
|
||||
qPrintable(fileName), qPrintable(file.errorString()));
|
||||
return mapList;
|
||||
}
|
||||
|
||||
int ln = 0;
|
||||
while (!file.atEnd()) {
|
||||
ln++;
|
||||
QByteArray line = file.readLine();
|
||||
QList<QByteArray> list = line.split('\t');
|
||||
if (list.size() != 2) {
|
||||
fprintf(stderr, "Invalid map list entry on line %d\n", ln);
|
||||
continue;
|
||||
}
|
||||
|
||||
QByteArray ba1 = list[0].trimmed();
|
||||
QByteArray ba2 = list[1].trimmed();
|
||||
|
||||
mapList.append(new Map(QString::fromUtf8(ba1.data(), ba1.size()),
|
||||
QString::fromLatin1(ba2.data(), ba2.size())));
|
||||
}
|
||||
|
||||
return mapList;
|
||||
}
|
14
src/maplist.h
Normal file
14
src/maplist.h
Normal file
@ -0,0 +1,14 @@
|
||||
#ifndef MAPLIST_H
|
||||
#define MAPLIST_H
|
||||
|
||||
#include <QList>
|
||||
#include "map.h"
|
||||
|
||||
|
||||
class MapList
|
||||
{
|
||||
public:
|
||||
static QList<Map*> load(const QString &fileName);
|
||||
};
|
||||
|
||||
#endif // MAPLIST_H
|
@ -1,6 +1,7 @@
|
||||
#include <QPainter>
|
||||
#include "markeritem.h"
|
||||
|
||||
|
||||
#define SIZE 8
|
||||
|
||||
MarkerItem::MarkerItem(QGraphicsItem *parent) : QGraphicsItem(parent)
|
||||
|
@ -1,7 +1,5 @@
|
||||
#include "parser.h"
|
||||
|
||||
#include <QDebug>
|
||||
|
||||
|
||||
void Parser::handleExtensionData(QVector<TrackPoint> &data,
|
||||
QStringRef element, const QString &value)
|
||||
@ -94,20 +92,12 @@ bool Parser::parse(QVector<TrackPoint> &data)
|
||||
if (_reader.name() == "gpx")
|
||||
gpx(data);
|
||||
else
|
||||
_reader.raiseError(QObject::tr("Not a GPX file."));
|
||||
_reader.raiseError("Not a GPX file.");
|
||||
}
|
||||
|
||||
return !_reader.error();
|
||||
}
|
||||
|
||||
|
||||
QString Parser::errorString() const
|
||||
{
|
||||
return QObject::tr("%1\nLine %2")
|
||||
.arg(_reader.errorString())
|
||||
.arg(_reader.lineNumber());
|
||||
}
|
||||
|
||||
bool Parser::loadFile(QIODevice *device, QVector<TrackPoint> &data)
|
||||
{
|
||||
_reader.clear();
|
||||
|
@ -20,7 +20,8 @@ class Parser
|
||||
{
|
||||
public:
|
||||
bool loadFile(QIODevice *device, QVector<TrackPoint> &data);
|
||||
QString errorString() const;
|
||||
QString errorString() const {return _reader.errorString();}
|
||||
int errorLine() const {return _reader.lineNumber();}
|
||||
|
||||
private:
|
||||
bool parse(QVector<TrackPoint> &data);
|
||||
|
45
src/poi.cpp
45
src/poi.cpp
@ -5,13 +5,16 @@
|
||||
#include "poi.h"
|
||||
|
||||
|
||||
#define BOUNDING_RECT_SIZE 0.01
|
||||
|
||||
bool POI::loadFile(const QString &fileName)
|
||||
{
|
||||
QFile file(fileName);
|
||||
bool ret;
|
||||
int ln = 1;
|
||||
int ln = 1, cnt = _data.size();
|
||||
|
||||
_error.clear();
|
||||
_errorLine = 0;
|
||||
|
||||
if (!file.open(QFile::ReadOnly | QFile::Text)) {
|
||||
_error = qPrintable(file.errorString());
|
||||
@ -22,69 +25,69 @@ bool POI::loadFile(const QString &fileName)
|
||||
QByteArray line = file.readLine();
|
||||
QList<QByteArray> list = line.split(',');
|
||||
if (list.size() < 3) {
|
||||
_error = QString("Parse error\nLine %1").arg(ln);
|
||||
_error = "Parse error";
|
||||
_errorLine = ln;
|
||||
return false;
|
||||
}
|
||||
|
||||
qreal lat = list[0].trimmed().toDouble(&ret);
|
||||
if (!ret) {
|
||||
_error = QObject::tr("Invalid latitude\nLine %1").arg(ln);
|
||||
_error = "Invalid latitude";
|
||||
_errorLine = ln;
|
||||
return false;
|
||||
}
|
||||
qreal lon = list[1].trimmed().toDouble(&ret);
|
||||
if (!ret) {
|
||||
_error = QObject::tr("Invalid longitude\nLine %1").arg(ln);
|
||||
_error = "Invalid longitude";
|
||||
_errorLine = ln;
|
||||
return false;
|
||||
}
|
||||
QByteArray ba = list[2].trimmed();
|
||||
|
||||
QPointF p;
|
||||
Entry entry;
|
||||
ll2mercator(QPointF(lon, lat), p);
|
||||
entry.description = QString::fromUtf8(ba.data(), ba.size());
|
||||
entry.coordinates = p;
|
||||
entry.coordinates = ll2mercator(QPointF(lon, lat));
|
||||
|
||||
_data.append(entry);
|
||||
ln++;
|
||||
}
|
||||
|
||||
for (int i = 0; i < _data.size(); ++i) {
|
||||
for (int i = cnt; i < _data.size(); ++i) {
|
||||
qreal c[2];
|
||||
c[0] = _data.at(i).coordinates.x();
|
||||
c[1] = _data.at(i).coordinates.y();
|
||||
_tree.Insert(c, c, &_data.at(i));
|
||||
_tree.Insert(c, c, i);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
static bool cb(const Entry* data, void* context)
|
||||
static bool cb(size_t data, void* context)
|
||||
{
|
||||
QSet<const Entry*> *set = (QSet<const Entry*>*) context;
|
||||
set->insert(data);
|
||||
QSet<int> *set = (QSet<int>*) context;
|
||||
set->insert((int)data);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
#define RECT 0.01
|
||||
QVector<Entry> POI::points(const QVector<QPointF> &path) const
|
||||
{
|
||||
QVector<Entry> ret;
|
||||
QSet<const Entry*> set;
|
||||
QSet<int> set;
|
||||
qreal min[2], max[2];
|
||||
|
||||
for (int i = 0; i < path.count(); i++) {
|
||||
min[0] = path.at(i).x() - RECT;
|
||||
min[1] = path.at(i).y() - RECT;
|
||||
max[0] = path.at(i).x() + RECT;
|
||||
max[1] = path.at(i).y() + RECT;
|
||||
min[0] = path.at(i).x() - BOUNDING_RECT_SIZE;
|
||||
min[1] = path.at(i).y() - BOUNDING_RECT_SIZE;
|
||||
max[0] = path.at(i).x() + BOUNDING_RECT_SIZE;
|
||||
max[1] = path.at(i).y() + BOUNDING_RECT_SIZE;
|
||||
_tree.Search(min, max, cb, &set);
|
||||
}
|
||||
|
||||
QSet<const Entry *>::const_iterator i = set.constBegin();
|
||||
QSet<int>::const_iterator i = set.constBegin();
|
||||
while (i != set.constEnd()) {
|
||||
ret.append(*(*i));
|
||||
++i;
|
||||
ret.append(_data.at(*i));
|
||||
++i;
|
||||
}
|
||||
|
||||
return ret;
|
||||
|
@ -28,16 +28,19 @@ class POI
|
||||
public:
|
||||
bool loadFile(const QString &fileName);
|
||||
QString errorString() const {return _error;}
|
||||
int errorLine() const {return _errorLine;}
|
||||
|
||||
QVector<Entry> points(const QVector<QPointF> &path) const;
|
||||
|
||||
void clear();
|
||||
|
||||
private:
|
||||
typedef RTree<const Entry*, qreal, 2> POITree;
|
||||
typedef RTree<size_t, qreal, 2> POITree;
|
||||
|
||||
POITree _tree;
|
||||
QVector<Entry> _data;
|
||||
QString _error;
|
||||
int _errorLine;
|
||||
};
|
||||
|
||||
#endif // POI_H
|
||||
|
@ -2,15 +2,13 @@
|
||||
#include "config.h"
|
||||
#include "poiitem.h"
|
||||
|
||||
#include <QDebug>
|
||||
|
||||
#define POINT_SIZE 8
|
||||
|
||||
|
||||
POIItem::POIItem(const QString &text, QGraphicsItem *parent)
|
||||
POIItem::POIItem(const Entry &entry, QGraphicsItem *parent)
|
||||
: QGraphicsItem(parent)
|
||||
{
|
||||
_text = text;
|
||||
_entry = entry;
|
||||
updateBoundingRect();
|
||||
}
|
||||
|
||||
@ -20,7 +18,7 @@ void POIItem::updateBoundingRect()
|
||||
font.setPixelSize(FONT_SIZE);
|
||||
font.setFamily(FONT_FAMILY);
|
||||
QFontMetrics fm(font);
|
||||
QRect ts = fm.tightBoundingRect(_text);
|
||||
QRect ts = fm.tightBoundingRect(_entry.description);
|
||||
|
||||
_boundingRect = QRectF(0, 0, ts.width() + POINT_SIZE,
|
||||
ts.height() + fm.descent() + POINT_SIZE);
|
||||
@ -35,11 +33,11 @@ void POIItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *option,
|
||||
font.setPixelSize(FONT_SIZE);
|
||||
font.setFamily(FONT_FAMILY);
|
||||
QFontMetrics fm(font);
|
||||
QRect ts = fm.tightBoundingRect(_text);
|
||||
QRect ts = fm.tightBoundingRect(_entry.description);
|
||||
|
||||
painter->setFont(font);
|
||||
painter->drawText(POINT_SIZE - qMax(ts.x(), 0), POINT_SIZE + ts.height(),
|
||||
_text);
|
||||
_entry.description);
|
||||
painter->setBrush(Qt::SolidPattern);
|
||||
painter->drawEllipse(0, 0, POINT_SIZE, POINT_SIZE);
|
||||
|
||||
|
@ -2,11 +2,13 @@
|
||||
#define POIITEM_H
|
||||
|
||||
#include <QGraphicsItem>
|
||||
#include "poi.h"
|
||||
|
||||
class POIItem : public QGraphicsItem
|
||||
{
|
||||
public:
|
||||
POIItem(const QString &text, QGraphicsItem *parent = 0);
|
||||
POIItem(const Entry &entry, QGraphicsItem *parent = 0);
|
||||
const Entry &entry() const {return _entry;}
|
||||
|
||||
QRectF boundingRect() const {return _boundingRect;}
|
||||
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option,
|
||||
@ -15,7 +17,7 @@ public:
|
||||
private:
|
||||
void updateBoundingRect();
|
||||
|
||||
QString _text;
|
||||
Entry _entry;
|
||||
QRectF _boundingRect;
|
||||
};
|
||||
|
||||
|
@ -1,7 +1,6 @@
|
||||
#include <QPainter>
|
||||
#include "slideritem.h"
|
||||
|
||||
#include <QDebug>
|
||||
|
||||
#define SIZE 10
|
||||
|
||||
|
@ -1,8 +1,6 @@
|
||||
#include "config.h"
|
||||
#include "speedgraph.h"
|
||||
|
||||
#include <QDebug>
|
||||
|
||||
|
||||
SpeedGraph::SpeedGraph(QWidget *parent) : Graph(parent)
|
||||
{
|
||||
|
193
src/track.cpp
193
src/track.cpp
@ -3,21 +3,28 @@
|
||||
#include <QGraphicsScene>
|
||||
#include <QPainterPath>
|
||||
#include <QWheelEvent>
|
||||
#include <QGraphicsEllipseItem>
|
||||
#include "poiitem.h"
|
||||
#include "markeritem.h"
|
||||
#include "ll.h"
|
||||
#include "track.h"
|
||||
|
||||
#include <QDebug>
|
||||
|
||||
#define MARGIN 10.0
|
||||
#define TRACK_WIDTH 3
|
||||
|
||||
Track::Track(QWidget *parent)
|
||||
: QGraphicsView(parent)
|
||||
{
|
||||
_scene = new QGraphicsScene(this);
|
||||
setScene(_scene);
|
||||
setResizeAnchor(QGraphicsView::AnchorViewCenter);
|
||||
setCacheMode(QGraphicsView::CacheBackground);
|
||||
setDragMode(QGraphicsView::ScrollHandDrag);
|
||||
setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
|
||||
setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
|
||||
|
||||
_zoom = -1;
|
||||
_scale = 1.0;
|
||||
_map = 0;
|
||||
_maxLen = 0;
|
||||
}
|
||||
|
||||
@ -33,6 +40,7 @@ void Track::loadGPX(const GPX &gpx)
|
||||
QGraphicsPathItem *pi;
|
||||
MarkerItem *mi;
|
||||
QColor color = _colorShop.color();
|
||||
qreal prevScale = _scale;
|
||||
|
||||
|
||||
gpx.track(track);
|
||||
@ -48,41 +56,82 @@ void Track::loadGPX(const GPX &gpx)
|
||||
|
||||
_maxLen = qMax(path.length(), _maxLen);
|
||||
|
||||
for (int i = 0; i < _trackPaths.size(); i++) {
|
||||
_trackPaths.at(i)->resetTransform();
|
||||
_scene->removeItem(_markers.at(i));
|
||||
}
|
||||
|
||||
pi = new QGraphicsPathItem(path);
|
||||
QBrush brush(color, Qt::SolidPattern);
|
||||
QPen pen(brush, 0);
|
||||
pi->setPen(pen);
|
||||
_scene->addItem(pi);
|
||||
_trackPaths.append(pi);
|
||||
_zoom = scale2zoom(trackScale());
|
||||
_scale = mapScale();
|
||||
QBrush brush(color, Qt::SolidPattern);
|
||||
QPen pen(brush, TRACK_WIDTH * _scale);
|
||||
pi->setPen(pen);
|
||||
pi->setScale(1.0/_scale);
|
||||
_scene->addItem(pi);
|
||||
|
||||
QTransform t = transform();
|
||||
|
||||
mi = new MarkerItem();
|
||||
mi->setPos(pi->path().pointAtPercent(0));
|
||||
mi = new MarkerItem(pi);
|
||||
_markers.append(mi);
|
||||
mi->setPos(pi->path().pointAtPercent(0));
|
||||
mi->setScale(_scale);
|
||||
|
||||
for (int i = 0; i < _trackPaths.size(); i++) {
|
||||
_markers.at(i)->setTransform(t);
|
||||
_scene->addItem(_markers.at(i));
|
||||
}
|
||||
|
||||
if (_trackPaths.size() > 1 && prevScale != _scale)
|
||||
rescale(_scale);
|
||||
_scene->setSceneRect(_scene->itemsBoundingRect());
|
||||
fitInView(_scene->sceneRect(), Qt::KeepAspectRatio);
|
||||
}
|
||||
|
||||
QTransform Track::transform() const
|
||||
qreal Track::trackScale() const
|
||||
{
|
||||
QPointF scale(_scene->itemsBoundingRect().width() / viewport()->width(),
|
||||
_scene->itemsBoundingRect().height() / viewport()->height());
|
||||
QTransform transform;
|
||||
transform.scale(qMax(scale.x(), scale.y()), qMax(scale.x(), scale.y()));
|
||||
qreal bottom, top, left, right;
|
||||
|
||||
return transform;
|
||||
bottom = _trackPaths.at(0)->path().boundingRect().bottom();
|
||||
top = _trackPaths.at(0)->path().boundingRect().top();
|
||||
left = _trackPaths.at(0)->path().boundingRect().left();
|
||||
right = _trackPaths.at(0)->path().boundingRect().right();
|
||||
|
||||
for (int i = 1; i < _trackPaths.size(); i++) {
|
||||
bottom = qMax(bottom, _trackPaths.at(i)->path().boundingRect().bottom());
|
||||
top = qMin(top, _trackPaths.at(i)->path().boundingRect().top());
|
||||
right = qMax(right, _trackPaths.at(i)->path().boundingRect().right());
|
||||
left = qMin(left, _trackPaths.at(i)->path().boundingRect().left());
|
||||
}
|
||||
|
||||
QRectF br(QPointF(left, top), QPointF(right, bottom));
|
||||
QPointF sc(br.width() / (viewport()->width() - MARGIN/2),
|
||||
br.height() / (viewport()->height() - MARGIN/2));
|
||||
|
||||
return qMax(sc.x(), sc.y());
|
||||
}
|
||||
|
||||
qreal Track::mapScale() const
|
||||
{
|
||||
return ((360.0/(qreal)(1<<_zoom))/(qreal)TILE_SIZE);
|
||||
}
|
||||
|
||||
void Track::rescale(qreal scale)
|
||||
{
|
||||
for (int i = 0; i < _trackPaths.size(); i++) {
|
||||
_markers.at(i)->setScale(scale);
|
||||
_trackPaths.at(i)->setScale(1.0/scale);
|
||||
|
||||
QPen pen(_trackPaths.at(i)->pen());
|
||||
pen.setWidthF(TRACK_WIDTH * scale);
|
||||
_trackPaths.at(i)->setPen(pen);
|
||||
}
|
||||
|
||||
QHash<Entry, POIItem*>::const_iterator it, jt;
|
||||
for (it = _pois.constBegin(); it != _pois.constEnd(); it++) {
|
||||
it.value()->setPos(QPointF(it.value()->entry().coordinates.x()
|
||||
* 1.0/scale, -it.value()->entry().coordinates.y() * 1.0/scale));
|
||||
it.value()->show();
|
||||
}
|
||||
|
||||
for (it = _pois.constBegin(); it != _pois.constEnd(); it++) {
|
||||
for (jt = _pois.constBegin(); jt != _pois.constEnd(); jt++) {
|
||||
if (it != jt && it.value()->isVisible() && jt.value()->isVisible()
|
||||
&& it.value()->collidesWithItem(jt.value()))
|
||||
jt.value()->hide();
|
||||
}
|
||||
}
|
||||
|
||||
_scale = scale;
|
||||
}
|
||||
|
||||
void Track::loadPOI(const POI &poi)
|
||||
@ -96,9 +145,9 @@ void Track::loadPOI(const POI &poi)
|
||||
if (_pois.contains(p.at(i)))
|
||||
continue;
|
||||
|
||||
POIItem *pi = new POIItem(p.at(i).description);
|
||||
pi->setPos(p.at(i).coordinates.x(), -p.at(i).coordinates.y());
|
||||
pi->setTransform(transform());
|
||||
POIItem *pi = new POIItem(p.at(i));
|
||||
pi->setPos(p.at(i).coordinates.x() * 1.0/_scale,
|
||||
-p.at(i).coordinates.y() * 1.0/_scale);
|
||||
pi->setZValue(1);
|
||||
_scene->addItem(pi);
|
||||
|
||||
@ -106,9 +155,6 @@ void Track::loadPOI(const POI &poi)
|
||||
}
|
||||
}
|
||||
|
||||
for (it = _pois.constBegin(); it != _pois.constEnd(); it++)
|
||||
it.value()->setTransform(transform());
|
||||
|
||||
for (it = _pois.constBegin(); it != _pois.constEnd(); it++) {
|
||||
for (jt = _pois.constBegin(); jt != _pois.constEnd(); jt++) {
|
||||
if (it != jt && it.value()->isVisible() && jt.value()->isVisible()
|
||||
@ -118,15 +164,48 @@ void Track::loadPOI(const POI &poi)
|
||||
}
|
||||
|
||||
_scene->setSceneRect(_scene->itemsBoundingRect());
|
||||
fitInView(_scene->sceneRect(), Qt::KeepAspectRatio);
|
||||
}
|
||||
|
||||
void Track::setMap(Map *map)
|
||||
{
|
||||
_map = map;
|
||||
if (_map)
|
||||
connect(_map, SIGNAL(loaded()), this, SLOT(redraw()));
|
||||
resetCachedContent();
|
||||
}
|
||||
|
||||
void Track::redraw()
|
||||
{
|
||||
resetCachedContent();
|
||||
}
|
||||
|
||||
void Track::wheelEvent(QWheelEvent *event)
|
||||
{
|
||||
float factor;
|
||||
QPointF pos = mapToScene(event->pos());
|
||||
qreal scale = _scale;
|
||||
|
||||
factor = pow(2.0, -event->delta() / 400.0);
|
||||
scale(factor, factor);
|
||||
_zoom = (event->delta() > 0) ?
|
||||
qMin(_zoom + 1, ZOOM_MAX) : qMax(_zoom - 1, ZOOM_MIN);
|
||||
|
||||
rescale(mapScale());
|
||||
_scene->setSceneRect(_scene->itemsBoundingRect());
|
||||
centerOn(pos * scale/_scale);
|
||||
resetCachedContent();
|
||||
}
|
||||
|
||||
void Track::showMarkers(bool show)
|
||||
{
|
||||
for (int i = 0; i < _markers.size(); i++)
|
||||
_markers.at(i)->setVisible(show);
|
||||
}
|
||||
|
||||
void Track::setTrackLineWidth(qreal width)
|
||||
{
|
||||
for (int i = 0; i < _trackPaths.size(); i++) {
|
||||
QPen pen(_trackPaths.at(i)->pen());
|
||||
pen.setWidthF(width);
|
||||
_trackPaths.at(i)->setPen(pen);
|
||||
}
|
||||
}
|
||||
|
||||
void Track::plot(QPainter *painter, const QRectF &target)
|
||||
@ -145,11 +224,11 @@ void Track::plot(QPainter *painter, const QRectF &target)
|
||||
adj = orig.adjusted(0, -diff/2, 0, diff/2);
|
||||
}
|
||||
|
||||
for (int i = 0; i < _markers.size(); i++)
|
||||
_markers.at(i)->setVisible(false);
|
||||
showMarkers(false);
|
||||
setTrackLineWidth(0);
|
||||
_scene->render(painter, target, adj, Qt::KeepAspectRatioByExpanding);
|
||||
for (int i = 0; i < _markers.size(); i++)
|
||||
_markers.at(i)->setVisible(true);
|
||||
setTrackLineWidth(TRACK_WIDTH * _scale);
|
||||
showMarkers(true);
|
||||
}
|
||||
|
||||
enum QPrinter::Orientation Track::orientation() const
|
||||
@ -193,3 +272,35 @@ void Track::movePositionMarker(qreal val)
|
||||
_markers.at(i)->setPos(pos);
|
||||
}
|
||||
}
|
||||
|
||||
void Track::drawBackground(QPainter *painter, const QRectF &rect)
|
||||
{
|
||||
if (_tracks.isEmpty() || !_map) {
|
||||
painter->fillRect(rect, Qt::white);
|
||||
return;
|
||||
}
|
||||
|
||||
painter->setWorldMatrixEnabled(false);
|
||||
|
||||
QRectF rr(rect.topLeft() * _scale, rect.size());
|
||||
QPoint tile = mercator2tile(QPointF(rr.topLeft().x(), -rr.topLeft().y()),
|
||||
_zoom);
|
||||
QPointF tm = tile2mercator(tile, _zoom);
|
||||
QPoint tl = mapFromScene(QPointF(tm.x() / _scale, -tm.y() / _scale));
|
||||
|
||||
QList<Tile> tiles;
|
||||
for (int i = 0; i <= rr.size().width() / TILE_SIZE + 1; i++) {
|
||||
for (int j = 0; j <= rr.size().height() / TILE_SIZE + 1; j++) {
|
||||
tiles.append(Tile(QPoint(tile.x() + i, tile.y() + j), _zoom));
|
||||
}
|
||||
}
|
||||
|
||||
_map->loadTiles(tiles);
|
||||
|
||||
for (int i = 0; i < tiles.count(); i++) {
|
||||
Tile &t = tiles[i];
|
||||
QPoint tp(tl.x() + (t.xy().rx() - tile.rx()) * TILE_SIZE,
|
||||
tl.y() + (t.xy().ry() - tile.ry()) * TILE_SIZE);
|
||||
painter->drawPixmap(tp, t.pixmap());
|
||||
}
|
||||
}
|
||||
|
21
src/track.h
21
src/track.h
@ -8,6 +8,7 @@
|
||||
#include <QPrinter>
|
||||
#include "poi.h"
|
||||
#include "gpx.h"
|
||||
#include "map.h"
|
||||
#include "colorshop.h"
|
||||
|
||||
|
||||
@ -23,29 +24,45 @@ public:
|
||||
~Track();
|
||||
|
||||
void loadGPX(const GPX &gpx);
|
||||
void loadPOI(const POI &poi);
|
||||
|
||||
void loadPOI(const POI &poi);
|
||||
void clearPOI();
|
||||
void clear();
|
||||
|
||||
void setMap(Map *map);
|
||||
|
||||
void plot(QPainter *painter, const QRectF &target);
|
||||
enum QPrinter::Orientation orientation() const;
|
||||
|
||||
public slots:
|
||||
void movePositionMarker(qreal val);
|
||||
|
||||
private slots:
|
||||
void redraw();
|
||||
|
||||
private:
|
||||
QTransform transform() const;
|
||||
qreal trackScale() const;
|
||||
qreal mapScale() const;
|
||||
void rescale(qreal scale);
|
||||
|
||||
void showMarkers(bool show);
|
||||
void setTrackLineWidth(qreal width);
|
||||
|
||||
void wheelEvent(QWheelEvent *event);
|
||||
void drawBackground(QPainter *painter, const QRectF &rect);
|
||||
|
||||
QGraphicsScene *_scene;
|
||||
QList<QVector<QPointF> > _tracks;
|
||||
QList<QGraphicsPathItem*> _trackPaths;
|
||||
QList<MarkerItem*> _markers;
|
||||
QHash<Entry, POIItem*> _pois;
|
||||
Map *_map;
|
||||
|
||||
ColorShop _colorShop;
|
||||
qreal _maxLen;
|
||||
|
||||
qreal _scale;
|
||||
int _zoom;
|
||||
};
|
||||
|
||||
#endif // TRACK_H
|
||||
|
Reference in New Issue
Block a user