1
0
mirror of https://github.com/tumic0/GPXSee.git synced 2024-11-27 21:24:47 +01:00

Added missing routes related stuff

Refactoring/optimization/cleanup
This commit is contained in:
Martin Tůma 2016-08-09 23:08:49 +02:00
parent aacc04520f
commit 20b107581e
17 changed files with 277 additions and 239 deletions

View File

@ -15,13 +15,13 @@
<translation>Výška</translation>
</message>
<message>
<location filename="../src/elevationgraph.cpp" line="92"/>
<location filename="../src/elevationgraph.cpp" line="85"/>
<source>km</source>
<translation>km</translation>
</message>
<message>
<location filename="../src/elevationgraph.cpp" line="89"/>
<location filename="../src/elevationgraph.cpp" line="109"/>
<location filename="../src/elevationgraph.cpp" line="82"/>
<location filename="../src/elevationgraph.cpp" line="102"/>
<source>m</source>
<translation>m</translation>
</message>
@ -41,13 +41,13 @@
<translation>Minimum</translation>
</message>
<message>
<location filename="../src/elevationgraph.cpp" line="100"/>
<location filename="../src/elevationgraph.cpp" line="93"/>
<source>mi</source>
<translation>mi</translation>
</message>
<message>
<location filename="../src/elevationgraph.cpp" line="97"/>
<location filename="../src/elevationgraph.cpp" line="112"/>
<location filename="../src/elevationgraph.cpp" line="90"/>
<location filename="../src/elevationgraph.cpp" line="105"/>
<source>ft</source>
<translation>ft</translation>
</message>
@ -163,371 +163,358 @@
<context>
<name>GUI</name>
<message>
<location filename="../src/gui.cpp" line="482"/>
<location filename="../src/gui.cpp" line="486"/>
<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="546"/>
<location filename="../src/gui.cpp" line="550"/>
<source>Open file</source>
<translation>Otevřít soubor</translation>
</message>
<message>
<location filename="../src/gui.cpp" line="622"/>
<location filename="../src/gui.cpp" line="631"/>
<source>Open POI file</source>
<translation>Otevřít POI soubor</translation>
</message>
<message>
<location filename="../src/gui.cpp" line="194"/>
<location filename="../src/gui.cpp" line="198"/>
<source>Open</source>
<translation>Otevřít</translation>
</message>
<message>
<location filename="../src/gui.cpp" line="178"/>
<location filename="../src/gui.cpp" line="182"/>
<source>Quit</source>
<translation>Ukončit</translation>
</message>
<message>
<location filename="../src/gui.cpp" line="186"/>
<location filename="../src/gui.cpp" line="498"/>
<location filename="../src/gui.cpp" line="499"/>
<location filename="../src/gui.cpp" line="190"/>
<location filename="../src/gui.cpp" line="502"/>
<location filename="../src/gui.cpp" line="503"/>
<source>Keyboard controls</source>
<translation>Ovládací klávesy</translation>
</message>
<message>
<location filename="../src/gui.cpp" line="210"/>
<location filename="../src/gui.cpp" line="214"/>
<source>Close</source>
<translation>Zavřít</translation>
</message>
<message>
<location filename="../src/gui.cpp" line="216"/>
<location filename="../src/gui.cpp" line="220"/>
<source>Reload</source>
<translation>Znovu načíst</translation>
</message>
<message>
<location filename="../src/gui.cpp" line="414"/>
<location filename="../src/gui.cpp" line="418"/>
<source>Show</source>
<translation>Zobrazit</translation>
</message>
<message>
<location filename="../src/gui.cpp" line="343"/>
<location filename="../src/gui.cpp" line="408"/>
<location filename="../src/gui.cpp" line="347"/>
<location filename="../src/gui.cpp" line="412"/>
<source>File</source>
<translation>Soubor</translation>
</message>
<message>
<location filename="../src/gui.cpp" line="184"/>
<location filename="../src/gui.cpp" line="521"/>
<location filename="../src/gui.cpp" line="522"/>
<location filename="../src/gui.cpp" line="188"/>
<location filename="../src/gui.cpp" line="525"/>
<location filename="../src/gui.cpp" line="526"/>
<source>Data sources</source>
<translation>Zdroje dat</translation>
</message>
<message>
<location filename="../src/gui.cpp" line="224"/>
<location filename="../src/gui.cpp" line="228"/>
<source>Load POI file</source>
<translation>Nahrát POI soubor</translation>
</message>
<message>
<location filename="../src/gui.cpp" line="227"/>
<location filename="../src/gui.cpp" line="231"/>
<source>Close POI files</source>
<translation>Zavřit POI soubory</translation>
</message>
<message>
<location filename="../src/gui.cpp" line="229"/>
<location filename="../src/gui.cpp" line="233"/>
<source>Overlap POIs</source>
<translation>Překrývat POI</translation>
</message>
<message>
<location filename="../src/gui.cpp" line="233"/>
<location filename="../src/gui.cpp" line="237"/>
<source>Show POI labels</source>
<translation>Zobrazovat názvy POI</translation>
</message>
<message>
<location filename="../src/gui.cpp" line="238"/>
<location filename="../src/gui.cpp" line="242"/>
<source>Show POIs</source>
<translation>Zobrazit POI</translation>
</message>
<message>
<location filename="../src/gui.cpp" line="246"/>
<location filename="../src/gui.cpp" line="250"/>
<source>Show map</source>
<translation>Zobrazit mapu</translation>
</message>
<message>
<location filename="../src/gui.cpp" line="252"/>
<location filename="../src/gui.cpp" line="256"/>
<source>Clear tile cache</source>
<translation>Vymazat mezipaměť dlaždic</translation>
</message>
<message>
<location filename="../src/gui.cpp" line="261"/>
<location filename="../src/gui.cpp" line="265"/>
<location filename="../src/gui.cpp" line="508"/>
<location filename="../src/gui.cpp" line="269"/>
<location filename="../src/gui.cpp" line="512"/>
<source>Next map</source>
<translation>Následující mapa</translation>
</message>
<message>
<location filename="../src/gui.cpp" line="272"/>
<source>Show tracks</source>
<translation>Zobrazit cesty</translation>
</message>
<message>
<location filename="../src/gui.cpp" line="276"/>
<source>Show routes</source>
<translation>Zobrazit trasy</translation>
</message>
<message>
<location filename="../src/gui.cpp" line="280"/>
<source>Show waypoints</source>
<translation>Zobrazit navigační body</translation>
</message>
<message>
<location filename="../src/gui.cpp" line="284"/>
<location filename="../src/gui.cpp" line="288"/>
<source>Waypoint labels</source>
<translation>Názvy navigačních bodů</translation>
</message>
<message>
<location filename="../src/gui.cpp" line="288"/>
<location filename="../src/gui.cpp" line="292"/>
<source>Route Waypoints</source>
<translation>Body tras</translation>
</message>
<message>
<location filename="../src/gui.cpp" line="294"/>
<location filename="../src/gui.cpp" line="298"/>
<source>Show graphs</source>
<translation>Zobrazovat grafy</translation>
</message>
<message>
<location filename="../src/gui.cpp" line="300"/>
<location filename="../src/gui.cpp" line="304"/>
<source>Show toolbars</source>
<translation>Zobrazovat nástrojové lišty</translation>
</message>
<message>
<location filename="../src/gui.cpp" line="306"/>
<location filename="../src/gui.cpp" line="310"/>
<source>Metric</source>
<translation>Metrické</translation>
</message>
<message>
<location filename="../src/gui.cpp" line="311"/>
<location filename="../src/gui.cpp" line="315"/>
<source>Imperial</source>
<translation>Imperiální</translation>
</message>
<message>
<location filename="../src/gui.cpp" line="317"/>
<location filename="../src/gui.cpp" line="321"/>
<source>Fullscreen mode</source>
<translation>Celoobrazovkový režim</translation>
</message>
<message>
<location filename="../src/gui.cpp" line="325"/>
<location filename="../src/gui.cpp" line="329"/>
<source>Next</source>
<translation>Následující</translation>
</message>
<message>
<location filename="../src/gui.cpp" line="328"/>
<location filename="../src/gui.cpp" line="332"/>
<source>Previous</source>
<translation>Předchozí</translation>
</message>
<message>
<location filename="../src/gui.cpp" line="332"/>
<location filename="../src/gui.cpp" line="336"/>
<source>Last</source>
<translation>Poslední</translation>
</message>
<message>
<location filename="../src/gui.cpp" line="335"/>
<location filename="../src/gui.cpp" line="339"/>
<source>First</source>
<translation>První</translation>
</message>
<message>
<location filename="../src/gui.cpp" line="357"/>
<location filename="../src/gui.cpp" line="361"/>
<source>Map</source>
<translation>Mapa</translation>
</message>
<message>
<location filename="../src/gui.cpp" line="364"/>
<location filename="../src/gui.cpp" line="368"/>
<source>POI</source>
<translation>POI</translation>
</message>
<message>
<location filename="../src/gui.cpp" line="365"/>
<location filename="../src/gui.cpp" line="369"/>
<source>POI files</source>
<translation>POI soubory</translation>
</message>
<message>
<location filename="../src/gui.cpp" line="376"/>
<location filename="../src/gui.cpp" line="380"/>
<source>Data</source>
<translation>Data</translation>
</message>
<message>
<location filename="../src/gui.cpp" line="377"/>
<location filename="../src/gui.cpp" line="381"/>
<source>Display</source>
<translation>Zobrazit</translation>
</message>
<message>
<location filename="../src/gui.cpp" line="385"/>
<location filename="../src/gui.cpp" line="389"/>
<source>Settings</source>
<translation>Nastavení</translation>
</message>
<message>
<location filename="../src/gui.cpp" line="386"/>
<location filename="../src/gui.cpp" line="390"/>
<source>Units</source>
<translation>Jednotky</translation>
</message>
<message>
<location filename="../src/gui.cpp" line="395"/>
<location filename="../src/gui.cpp" line="399"/>
<source>Help</source>
<translation>Nápověda</translation>
</message>
<message>
<location filename="../src/gui.cpp" line="510"/>
<location filename="../src/gui.cpp" line="514"/>
<source>Previous map</source>
<translation>Předchozí mapa</translation>
</message>
<message>
<location filename="../src/gui.cpp" line="708"/>
<location filename="../src/gui.cpp" line="711"/>
<location filename="../src/gui.cpp" line="718"/>
<location filename="../src/gui.cpp" line="721"/>
<source>Date</source>
<translation>Datum</translation>
</message>
<message>
<location filename="../src/gui.cpp" line="889"/>
<location filename="../src/gui.cpp" line="280"/>
<location filename="../src/gui.cpp" line="730"/>
<source>Routes</source>
<translation>Počet tras</translation>
</message>
<message>
<location filename="../src/gui.cpp" line="903"/>
<source>No GPX files loaded</source>
<translation>Nejsou načteny žádné GPX soubory</translation>
</message>
<message>
<location filename="../src/gui.cpp" line="501"/>
<location filename="../src/gui.cpp" line="910"/>
<source>%1 files</source>
<translation>%1 souborů</translation>
</message>
<message>
<location filename="../src/gui.cpp" line="505"/>
<source>Next file</source>
<translation>Následující soubor</translation>
</message>
<message>
<location filename="../src/gui.cpp" line="478"/>
<location filename="../src/gui.cpp" line="482"/>
<source>Version </source>
<translation>Verze </translation>
</message>
<message>
<location filename="../src/gui.cpp" line="199"/>
<location filename="../src/gui.cpp" line="203"/>
<source>Print...</source>
<translation>Tisknout...</translation>
</message>
<message>
<location filename="../src/gui.cpp" line="204"/>
<location filename="../src/gui.cpp" line="208"/>
<source>Export to PDF...</source>
<translation>Exportovat do PDF...</translation>
</message>
<message>
<location filename="../src/gui.cpp" line="502"/>
<location filename="../src/gui.cpp" line="284"/>
<location filename="../src/gui.cpp" line="732"/>
<source>Waypoints</source>
<translation>Navigační body</translation>
</message>
<message>
<location filename="../src/gui.cpp" line="506"/>
<source>Previous file</source>
<translation>Předchozí soubor</translation>
</message>
<message>
<location filename="../src/gui.cpp" line="504"/>
<location filename="../src/gui.cpp" line="508"/>
<source>First file</source>
<translation>První soubor</translation>
</message>
<message>
<location filename="../src/gui.cpp" line="505"/>
<location filename="../src/gui.cpp" line="509"/>
<source>Last file</source>
<translation>Poslední soubor</translation>
</message>
<message>
<location filename="../src/gui.cpp" line="506"/>
<location filename="../src/gui.cpp" line="510"/>
<source>Append modifier</source>
<translation>Modifikátor nahradit/přidat</translation>
</message>
<message>
<location filename="../src/gui.cpp" line="525"/>
<location filename="../src/gui.cpp" line="529"/>
<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="528"/>
<location filename="../src/gui.cpp" line="532"/>
<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="536"/>
<location filename="../src/gui.cpp" line="540"/>
<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="547"/>
<location filename="../src/gui.cpp" line="551"/>
<source>GPX files (*.gpx);;All files (*)</source>
<translation>Soubory GPX (*.gpx);;Všechny soubory (*)</translation>
</message>
<message>
<location filename="../src/gui.cpp" line="613"/>
<location filename="../src/gui.cpp" line="639"/>
<location filename="../src/gui.cpp" line="622"/>
<location filename="../src/gui.cpp" line="648"/>
<source>Line: %1</source>
<translation>Řádka: %1</translation>
</message>
<message>
<location filename="../src/gui.cpp" line="623"/>
<location filename="../src/gui.cpp" line="632"/>
<source>GPX files (*.gpx);;CSV files (*.csv);;All files (*)</source>
<translation>Soubory GPX (*.gpx);;Soubory CSV (*.csv);;Všechny soubory (*)</translation>
</message>
<message>
<location filename="../src/gui.cpp" line="714"/>
<location filename="../src/gui.cpp" line="276"/>
<location filename="../src/gui.cpp" line="728"/>
<source>Tracks</source>
<translation>Počet tras</translation>
<translation>Počet cest</translation>
</message>
<message>
<location filename="../src/gui.cpp" line="720"/>
<source>mi</source>
<translation>mi</translation>
</message>
<message>
<location filename="../src/gui.cpp" line="189"/>
<location filename="../src/gui.cpp" line="476"/>
<location filename="../src/gui.cpp" line="193"/>
<location filename="../src/gui.cpp" line="480"/>
<source>About GPXSee</source>
<translation>O aplikaci GPXSee</translation>
</message>
<message>
<location filename="../src/gui.cpp" line="418"/>
<location filename="../src/gui.cpp" line="422"/>
<source>Navigation</source>
<translation>Navigace</translation>
</message>
<message>
<location filename="../src/gui.cpp" line="524"/>
<location filename="../src/gui.cpp" line="528"/>
<source>Map sources</source>
<translation>Mapové zdroje</translation>
</message>
<message>
<location filename="../src/gui.cpp" line="535"/>
<location filename="../src/gui.cpp" line="539"/>
<source>POIs</source>
<translation>POI body</translation>
</message>
<message>
<location filename="../src/gui.cpp" line="719"/>
<location filename="../src/gui.cpp" line="722"/>
<location filename="../src/gui.cpp" line="735"/>
<source>Distance</source>
<translation>Vzdálenost</translation>
</message>
<message>
<location filename="../src/gui.cpp" line="727"/>
<location filename="../src/gui.cpp" line="737"/>
<source>Time</source>
<translation>Čas</translation>
</message>
<message>
<location filename="../src/gui.cpp" line="896"/>
<source>%1 tracks</source>
<translation>Počet tras: %1</translation>
</message>
<message>
<location filename="../src/gui.cpp" line="723"/>
<source>km</source>
<translation>km</translation>
</message>
<message>
<location filename="../src/gui.cpp" line="615"/>
<location filename="../src/gui.cpp" line="640"/>
<location filename="../src/gui.cpp" line="624"/>
<location filename="../src/gui.cpp" line="649"/>
<source>Error</source>
<translation>Chyba</translation>
</message>
<message>
<location filename="../src/gui.cpp" line="610"/>
<location filename="../src/gui.cpp" line="619"/>
<source>Error loading GPX file:
%1</source>
<translation>Soubor GPX nelze otevřít:
%1</translation>
</message>
<message>
<location filename="../src/gui.cpp" line="636"/>
<location filename="../src/gui.cpp" line="645"/>
<source>Error loading POI file:
%1</source>
<translation>Soubor POI nelze otevřít:
@ -548,7 +535,7 @@
<translation>Tep</translation>
</message>
<message>
<location filename="../src/heartrategraph.cpp" line="81"/>
<location filename="../src/heartrategraph.cpp" line="80"/>
<source>km</source>
<translation>km</translation>
</message>
@ -568,17 +555,17 @@
<translation>Maximum</translation>
</message>
<message>
<location filename="../src/heartrategraph.cpp" line="78"/>
<location filename="../src/heartrategraph.cpp" line="77"/>
<source>m</source>
<translation>m</translation>
</message>
<message>
<location filename="../src/heartrategraph.cpp" line="86"/>
<location filename="../src/heartrategraph.cpp" line="85"/>
<source>ft</source>
<translation>ft</translation>
</message>
<message>
<location filename="../src/heartrategraph.cpp" line="89"/>
<location filename="../src/heartrategraph.cpp" line="88"/>
<source>mi</source>
<translation>mi</translation>
</message>
@ -645,22 +632,22 @@
<translation>Rychlost</translation>
</message>
<message>
<location filename="../src/speedgraph.cpp" line="75"/>
<location filename="../src/speedgraph.cpp" line="73"/>
<source>m</source>
<translation>m</translation>
</message>
<message>
<location filename="../src/speedgraph.cpp" line="78"/>
<location filename="../src/speedgraph.cpp" line="76"/>
<source>km</source>
<translation></translation>
</message>
<message>
<location filename="../src/speedgraph.cpp" line="83"/>
<location filename="../src/speedgraph.cpp" line="81"/>
<source>ft</source>
<translation>ft</translation>
</message>
<message>
<location filename="../src/speedgraph.cpp" line="95"/>
<location filename="../src/speedgraph.cpp" line="93"/>
<source>km/h</source>
<translation>km/h</translation>
</message>
@ -675,12 +662,12 @@
<translation>Maximum</translation>
</message>
<message>
<location filename="../src/speedgraph.cpp" line="86"/>
<location filename="../src/speedgraph.cpp" line="84"/>
<source>mi</source>
<translation>mi</translation>
</message>
<message>
<location filename="../src/speedgraph.cpp" line="98"/>
<location filename="../src/speedgraph.cpp" line="96"/>
<source>mi/h</source>
<translation>mi/h</translation>
</message>
@ -714,32 +701,32 @@
<translation>Maximum</translation>
</message>
<message>
<location filename="../src/temperaturegraph.cpp" line="80"/>
<location filename="../src/temperaturegraph.cpp" line="79"/>
<source>m</source>
<translation>m</translation>
</message>
<message>
<location filename="../src/temperaturegraph.cpp" line="83"/>
<location filename="../src/temperaturegraph.cpp" line="82"/>
<source>km</source>
<translation>km</translation>
</message>
<message>
<location filename="../src/temperaturegraph.cpp" line="88"/>
<location filename="../src/temperaturegraph.cpp" line="87"/>
<source>ft</source>
<translation>ft</translation>
</message>
<message>
<location filename="../src/temperaturegraph.cpp" line="91"/>
<location filename="../src/temperaturegraph.cpp" line="90"/>
<source>mi</source>
<translation>mi</translation>
</message>
<message>
<location filename="../src/temperaturegraph.cpp" line="100"/>
<location filename="../src/temperaturegraph.cpp" line="99"/>
<source>C</source>
<translation>C</translation>
</message>
<message>
<location filename="../src/temperaturegraph.cpp" line="104"/>
<location filename="../src/temperaturegraph.cpp" line="103"/>
<source>F</source>
<translation>F</translation>
</message>

View File

@ -56,17 +56,10 @@ void ElevationGraph::loadPath(const QVector<QPointF> &data)
void ElevationGraph::loadGPX(const GPX &gpx)
{
for (int i = 0; i < gpx.trackCount(); i++) {
QVector<QPointF> data;
gpx.track(i).elevationGraph(data);
loadPath(data);
}
for (int i = 0; i < gpx.routeCount(); i++) {
QVector<QPointF> data;
gpx.route(i).elevationGraph(data);
loadPath(data);
}
for (int i = 0; i < gpx.tracks().count(); i++)
loadPath(gpx.tracks().at(i)->elevation());
for (int i = 0; i < gpx.routes().count(); i++)
loadPath(gpx.routes().at(i)->elevation());
setXUnits();
setInfo();

View File

@ -4,12 +4,24 @@
#include "gpx.h"
GPX::GPX() : _parser(_track_data, _route_data, _waypoint_data), _errorLine(0)
{
}
GPX::~GPX()
{
for (int i = 0; i < _tracks.count(); i++)
delete _tracks.at(i);
for (int i = 0; i < _routes.count(); i++)
delete _routes.at(i);
}
bool GPX::loadFile(const QString &fileName)
{
QFile file(fileName);
bool ret;
QFile file(fileName);
_tracks.clear();
_error.clear();
_errorLine = 0;
@ -18,11 +30,18 @@ bool GPX::loadFile(const QString &fileName)
return false;
}
if (!(ret = _parser.loadFile(&file))) {
ret = _parser.loadFile(&file);
file.close();
if (ret == false) {
_error = _parser.errorString();
_errorLine = _parser.errorLine();
return false;
}
file.close();
return ret;
for (int i = 0; i < _track_data.count(); i++)
_tracks.append(new Track(_track_data.at(i)));
for (int i = 0; i < _route_data.count(); i++)
_routes.append(new Route(_route_data.at(i)));
return true;
}

View File

@ -13,25 +13,28 @@
class GPX
{
public:
GPX() : _parser(_tracks, _routes, _waypoints), _errorLine(0) {}
GPX();
~GPX();
bool loadFile(const QString &fileName);
const QString &errorString() const {return _error;}
int errorLine() const {return _errorLine;}
int trackCount() const {return _tracks.count();}
Track track(int i) const {return Track(_tracks.at(i));}
int routeCount() const {return _routes.count();}
Route route(int i) const {return Route(_routes.at(i));}
const QList<Waypoint> &waypoints() const {return _waypoints;}
const QList<Track*> &tracks() const {return _tracks;}
const QList<Route*> &routes() const {return _routes;}
const QList<Waypoint> &waypoints() const {return _waypoint_data;}
private:
Parser _parser;
QString _error;
int _errorLine;
QList<QVector<Trackpoint> > _tracks;
QList<QVector<Waypoint> > _routes;
QList<Waypoint> _waypoints;
QList<Track*> _tracks;
QList<Route*> _routes;
QList<QVector<Trackpoint> > _track_data;
QList<QVector<Waypoint> > _route_data;
QList<Waypoint> _waypoint_data;
};
#endif // GPX_H

View File

@ -39,6 +39,8 @@
#include "gui.h"
#include <QElapsedTimer>
GUI::GUI(QWidget *parent) : QMainWindow(parent)
{
loadMaps();
@ -73,6 +75,8 @@ GUI::GUI(QWidget *parent) : QMainWindow(parent)
_distance = 0;
_time = 0;
_trackCount = 0;
_routeCount = 0;
_waypointCount = 0;
_sliderPos = 0;
@ -269,15 +273,15 @@ void GUI::createActions()
}
// Data actions
_showTracksAction = new QAction(tr("Show tracks"), this);
_showTracksAction = new QAction(tr("Tracks"), this);
_showTracksAction->setCheckable(true);
connect(_showTracksAction, SIGNAL(triggered(bool)), _track,
SLOT(showTracks(bool)));
_showRoutesAction = new QAction(tr("Show routes"), this);
_showRoutesAction = new QAction(tr("Routes"), this);
_showRoutesAction->setCheckable(true);
connect(_showRoutesAction, SIGNAL(triggered(bool)), _track,
SLOT(showRoutes(bool)));
_showWaypointsAction = new QAction(tr("Show waypoints"), this);
_showWaypointsAction = new QAction(tr("Waypoints"), this);
_showWaypointsAction->setCheckable(true);
connect(_showWaypointsAction, SIGNAL(triggered(bool)), _track,
SLOT(showWaypoints(bool)));
@ -592,17 +596,22 @@ bool GUI::loadFile(const QString &fileName)
_track->loadPOI(_poi);
_track->movePositionMarker(_sliderPos);
for (int i = 0; i < gpx.trackCount(); i++) {
_distance += gpx.track(i).distance();
_time += gpx.track(i).time();
const QDate &date = gpx.track(i).date().date();
for (int i = 0; i < gpx.tracks().count(); i++) {
_distance += gpx.tracks().at(i)->distance();
_time += gpx.tracks().at(i)->time();
const QDate &date = gpx.tracks().at(i)->date().date();
if (_dateRange.first.isNull() || _dateRange.first > date)
_dateRange.first = date;
if (_dateRange.second.isNull() || _dateRange.second < date)
_dateRange.second = date;
}
_trackCount += gpx.tracks().count();
_trackCount += gpx.trackCount();
for (int i = 0; i < gpx.routes().count(); i++)
_distance += gpx.routes().at(i)->distance();
_routeCount += gpx.routes().count();
_waypointCount += gpx.waypoints().count();
return true;
} else {
@ -700,6 +709,7 @@ void GUI::plot(QPrinter *printer)
QPainter p(printer);
TrackInfo info;
qreal ih, gh, mh, ratio;
Units units = _imperialUnitsAction->isChecked() ? Imperial : Metric;
if (_dateRange.first.isValid()) {
@ -711,18 +721,18 @@ void GUI::plot(QPrinter *printer)
info.insert(tr("Date"), QString("%1 - %2")
.arg(_dateRange.first.toString(format),
_dateRange.second.toString(format)));
info.insert(tr("Tracks"), QString::number(_trackCount));
}
}
if (_distance > 0) {
if (_imperialUnitsAction->isChecked()) {
info.insert(tr("Distance"), QString::number(_distance * M2MI, 'f',
1) + UNIT_SPACE + tr("mi"));
} else {
info.insert(tr("Distance"), QString::number(_distance * M2KM, 'f',
1) + UNIT_SPACE + tr("km"));
}
}
if (_trackCount)
info.insert(tr("Tracks"), QString::number(_trackCount));
if (_routeCount)
info.insert(tr("Routes"), QString::number(_routeCount));
if (_waypointCount)
info.insert(tr("Waypoints"), QString::number(_waypointCount));
if (_distance > 0)
info.insert(tr("Distance"), ::distance(_distance, units));
if (_time > 0)
info.insert(tr("Time"), timeSpan(_time));
@ -756,6 +766,8 @@ void GUI::reloadFile()
_time = 0;
_dateRange = DateRange(QDate(), QDate());
_trackCount = 0;
_routeCount = 0;
_waypointCount = 0;
for (int i = 0; i < _tabs.count(); i++)
_tabs.at(i)->clear();
@ -786,6 +798,8 @@ void GUI::closeFiles()
_time = 0;
_dateRange = DateRange(QDate(), QDate());
_trackCount = 0;
_routeCount = 0;
_waypointCount = 0;
_sliderPos = 0;
@ -893,7 +907,7 @@ void GUI::updateStatusBarInfo()
} else if (_files.count() == 1)
_fileNameLabel->setText(_files.at(0));
else
_fileNameLabel->setText(tr("%1 tracks").arg(_trackCount));
_fileNameLabel->setText(tr("%1 files").arg(_files.count()));
Units units = _imperialUnitsAction->isChecked() ? Imperial : Metric;
_distanceLabel->setText(distance(_distance, units));

View File

@ -162,6 +162,8 @@ private:
Map *_currentMap;
int _trackCount;
int _routeCount;
int _waypointCount;
qreal _distance;
qreal _time;
DateRange _dateRange;

View File

@ -23,11 +23,10 @@ void HeartRateGraph::setInfo()
void HeartRateGraph::loadGPX(const GPX &gpx)
{
for (int i = 0; i < gpx.trackCount(); i++) {
QVector<QPointF> data;
for (int i = 0; i < gpx.tracks().count(); i++) {
QVector<QPointF> data = gpx.tracks().at(i)->heartRate();
qreal sum = 0, w = 0;
gpx.track(i).heartRateGraph(data);
if (data.count() < 2) {
skipColor();
continue;
@ -37,12 +36,12 @@ void HeartRateGraph::loadGPX(const GPX &gpx)
sum += data.at(j).y() * (data.at(j).x() - data.at(j-1).x());
w += data.at(j).x() - data.at(j-1).x();
}
_avg.append(QPointF(gpx.track(i).distance(), sum/w));
_avg.append(QPointF(gpx.tracks().at(i)->distance(), sum/w));
loadData(data);
}
for (int i = 0; i < gpx.routeCount(); i++)
for (int i = 0; i < gpx.routes().count(); i++)
skipColor();
setXUnits();

View File

@ -6,20 +6,25 @@ Route::Route(const QVector<Waypoint> &data) : _data(data)
qreal dist = 0;
_dd.append(dist);
for (int i = 1; i < _data.count(); i++) {
dist += llDistance(_data.at(i).coordinates(),
_data.at(i-1).coordinates());
for (int i = 1; i < data.count(); i++) {
dist += llDistance(data.at(i).coordinates(), data.at(i-1).coordinates());
_dd.append(dist);
}
}
void Route::elevationGraph(QVector<QPointF> &graph) const
QVector<QPointF> Route::elevation() const
{
if (!_data.size())
return;
QVector<QPointF> graph;
for (int i = 0; i < _data.size(); i++)
if (_data.at(i).hasElevation())
graph.append(QPointF(_dd.at(i), _data.at(i).elevation()
- _data.at(i).geoidHeight()));
return graph;
}
qreal Route::distance() const
{
return (_dd.isEmpty()) ? 0 : _dd.last();
}

View File

@ -10,10 +10,11 @@ public:
Route(const QVector<Waypoint> &data);
const QVector<Waypoint> &route() const {return _data;}
void elevationGraph(QVector<QPointF> &graph) const;
qreal distance() const {return _dd.last();}
QVector<QPointF> elevation() const;
bool isNull() const {return (_data.count() < 2) ? true : false;}
qreal distance() const;
bool isNull() const {return _dd.isEmpty();}
private:
const QVector<Waypoint> &_data;

View File

@ -79,3 +79,14 @@ void RouteItem::showWaypoints(bool show)
if (childs.at(i) != _marker)
childs.at(i)->setVisible(show);
}
void RouteItem::showWaypointLabels(bool show)
{
QList<QGraphicsItem *> childs = childItems();
for (int i = 0; i < childs.count(); i++) {
if (childs.at(i) != _marker) {
WaypointItem *wi = static_cast<WaypointItem*>(childs.at(i));
wi->showLabel(show);
}
}
}

View File

@ -23,6 +23,7 @@ public:
void moveMarker(qreal t);
void showWaypoints(bool show);
void showWaypointLabels(bool show);
private:
QPainterPath _path;

View File

@ -24,22 +24,20 @@ void SpeedGraph::setInfo()
void SpeedGraph::loadGPX(const GPX &gpx)
{
for (int i = 0; i < gpx.trackCount(); i++) {
QVector<QPointF> data;
gpx.track(i).speedGraph(data);
for (int i = 0; i < gpx.tracks().count(); i++) {
QVector<QPointF> data = gpx.tracks().at(i)->speed();
if (data.count() < 2) {
skipColor();
continue;
}
_avg.append(QPointF(gpx.track(i).distance(), gpx.track(i).distance()
/ gpx.track(i).time()));
_avg.append(QPointF(gpx.tracks().at(i)->distance(),
gpx.tracks().at(i)->distance() / gpx.tracks().at(i)->time()));
loadData(data);
}
for (int i = 0; i < gpx.routeCount(); i++)
for (int i = 0; i < gpx.routes().count(); i++)
skipColor();
setXUnits();

View File

@ -25,11 +25,10 @@ void TemperatureGraph::setInfo()
void TemperatureGraph::loadGPX(const GPX &gpx)
{
for (int i = 0; i < gpx.trackCount(); i++) {
QVector<QPointF> data;
for (int i = 0; i < gpx.tracks().count(); i++) {
QVector<QPointF> data = gpx.tracks().at(i)->temperature();
qreal sum = 0, w = 0;
gpx.track(i).temperatureGraph(data);
if (data.count() < 2) {
skipColor();
continue;
@ -39,12 +38,12 @@ void TemperatureGraph::loadGPX(const GPX &gpx)
sum += data.at(j).y() * (data.at(j).x() - data.at(j-1).x());
w += data.at(j).x() - data.at(j-1).x();
}
_avg.append(QPointF(gpx.track(i).distance(), sum/w));
_avg.append(QPointF(gpx.tracks().at(i)->distance(), sum/w));
loadData(data);
}
for (int i = 0; i < gpx.routeCount(); i++)
for (int i = 0; i < gpx.routes().count(); i++)
skipColor();
setXUnits();

View File

@ -84,36 +84,35 @@ Track::Track(const QVector<Trackpoint> &data) : _data(data)
qreal dist = 0;
_dd.append(dist);
for (int i = 1; i < _data.count(); i++) {
dist += llDistance(_data.at(i).coordinates(),
_data.at(i-1).coordinates());
for (int i = 1; i < data.count(); i++) {
dist += llDistance(data.at(i).coordinates(), data.at(i-1).coordinates());
_dd.append(dist);
}
}
void Track::elevationGraph(QVector<QPointF> &graph) const
QVector<QPointF> Track::elevation() const
{
QVector<QPointF> raw;
if (!_data.size())
return;
return raw;
for (int i = 0; i < _data.size(); i++)
if (_data.at(i).hasElevation())
raw.append(QPointF(_dd.at(i), _data.at(i).elevation()
- _data.at(i).geoidHeight()));
graph = filter(raw, WINDOW_EF);
return filter(raw, WINDOW_EF);
}
void Track::speedGraph(QVector<QPointF> &graph) const
QVector<QPointF> Track::speed() const
{
qreal v, ds;
qint64 dt;
QVector<QPointF> raw;
if (!_data.size())
return;
return raw;
raw.append(QPointF(0, 0));
for (int i = 1; i < _data.size(); i++) {
@ -131,52 +130,56 @@ void Track::speedGraph(QVector<QPointF> &graph) const
raw.append(QPointF(_dd.at(i), v));
}
graph = filter(eliminate(raw, WINDOW_SE), WINDOW_SF);
return filter(eliminate(raw, WINDOW_SE), WINDOW_SF);
}
void Track::heartRateGraph(QVector<QPointF> &graph) const
QVector<QPointF> Track::heartRate() const
{
QVector<QPointF> raw;
if (!_data.size())
return;
return raw;
for (int i = 0; i < _data.count(); i++)
if (_data.at(i).hasHeartRate())
raw.append(QPointF(_dd.at(i), _data.at(i).heartRate()));
graph = filter(eliminate(raw, WINDOW_HE), WINDOW_HF);
return filter(eliminate(raw, WINDOW_HE), WINDOW_HF);
}
void Track::temperatureGraph(QVector<QPointF> &graph) const
QVector<QPointF> Track::temperature() const
{
if (!_data.size())
return;
QVector<QPointF> graph;
for (int i = 0; i < _data.size(); i++)
if (_data.at(i).hasTemperature())
graph.append(QPointF(_dd.at(i), _data.at(i).temperature()));
return graph;
}
void Track::track(QVector<QPointF> &track) const
QVector<QPointF> Track::track() const
{
QVector<QPointF> graph;
for (int i = 0; i < _data.size(); i++)
track.append(_data.at(i).coordinates());
graph.append(_data.at(i).coordinates());
return graph;
}
qreal Track::distance() const
{
return (_dd.isEmpty()) ? 0 : _dd.last();
}
qreal Track::time() const
{
if (_data.size() < 2)
return 0;
return (_data.first().timestamp().msecsTo(_data.last().timestamp())
/ 1000.0);
return (_data.size() < 2) ? 0 :
(_data.first().timestamp().msecsTo(_data.last().timestamp()) / 1000.0);
}
QDateTime Track::date() const
{
if (_data.size())
return _data.first().timestamp();
else
return QDateTime();
return (_data.size()) ? _data.first().timestamp() : QDateTime();
}

View File

@ -10,16 +10,17 @@ class Track
public:
Track(const QVector<Trackpoint> &data);
void elevationGraph(QVector<QPointF> &graph) const;
void speedGraph(QVector<QPointF> &graph) const;
void heartRateGraph(QVector<QPointF> &graph) const;
void temperatureGraph(QVector<QPointF> &graph) const;
void track(QVector<QPointF> &track) const;
qreal distance() const {return _dd.last();}
QVector<QPointF> track() const;
QVector<QPointF> elevation() const;
QVector<QPointF> speed() const;
QVector<QPointF> heartRate() const;
QVector<QPointF> temperature() const;
qreal distance() const;
qreal time() const;
QDateTime date() const;
bool isNull() const {return (_data.count() < 2) ? true : false;}
bool isNull() const {return _dd.isEmpty();}
private:
const QVector<Trackpoint> &_data;

View File

@ -34,9 +34,7 @@ void TrackItem::updateShape()
TrackItem::TrackItem(const Track &track, QGraphicsItem *parent)
: QGraphicsItem(parent)
{
QVector<QPointF> t;
track.track(t);
const QVector<QPointF> &t = track.track();
Q_ASSERT(t.count() >= 2);
const QPointF &p = t.at(0);

View File

@ -91,6 +91,7 @@ void TrackView::addRoute(const Route &route)
ri->setColor(_palette.color());
ri->setVisible(_showRoutes);
ri->showWaypoints(_showRouteWaypoints);
ri->showWaypointLabels(_showWaypointLabels);
_scene->addItem(ri);
_maxPath = qMax(ri->path().length(), _maxPath);
@ -120,10 +121,10 @@ void TrackView::loadGPX(const GPX &gpx)
{
int zoom = _zoom;
for (int i = 0; i < gpx.trackCount(); i++)
addTrack(gpx.track(i));
for (int i = 0; i < gpx.routeCount(); i++)
addRoute(gpx.route(i));
for (int i = 0; i < gpx.tracks().count(); i++)
addTrack(*(gpx.tracks().at(i)));
for (int i = 0; i < gpx.routes().count(); i++)
addRoute(*(gpx.routes().at(i)));
addWaypoints(gpx.waypoints());
if (_tracks.empty() && _routes.empty() && _waypoints.empty())
@ -540,6 +541,9 @@ void TrackView::showWaypointLabels(bool show)
for (int i = 0; i < _waypoints.size(); i++)
_waypoints.at(i)->showLabel(show);
for (int i = 0; i < _routes.size(); i++)
_routes.at(i)->showWaypointLabels(show);
}
void TrackView::showRouteWaypoints(bool show)