diff --git a/lang/gpxsee_cs.ts b/lang/gpxsee_cs.ts index b04b3371..5f494db4 100644 --- a/lang/gpxsee_cs.ts +++ b/lang/gpxsee_cs.ts @@ -15,13 +15,13 @@ Výška - + km km - - + + m m @@ -41,13 +41,13 @@ Minimum - + mi mi - - + + ft ft @@ -163,371 +163,358 @@ GUI - + GPXSee is distributed under the terms of the GNU General Public License version 3. For more info about GPXSee visit the project homepage at 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 - + Open file Otevřít soubor - + Open POI file Otevřít POI soubor - + Open Otevřít - + Quit Ukončit - - - + + + Keyboard controls Ovládací klávesy - + Close Zavřít - + Reload Znovu načíst - + Show Zobrazit - - + + File Soubor - - - + + + Data sources Zdroje dat - + Load POI file Nahrát POI soubor - + Close POI files Zavřit POI soubory - + Overlap POIs Překrývat POI - + Show POI labels Zobrazovat názvy POI - + Show POIs Zobrazit POI - + Show map Zobrazit mapu - + Clear tile cache Vymazat mezipaměť dlaždic - - + + Next map Následující mapa - - Show tracks - Zobrazit cesty - - - - Show routes - Zobrazit trasy - - - - Show waypoints - Zobrazit navigační body - - - + Waypoint labels Názvy navigačních bodů - + Route Waypoints Body tras - + Show graphs Zobrazovat grafy - + Show toolbars Zobrazovat nástrojové lišty - + Metric Metrické - + Imperial Imperiální - + Fullscreen mode Celoobrazovkový režim - + Next Následující - + Previous Předchozí - + Last Poslední - + First První - + Map Mapa - + POI POI - + POI files POI soubory - + Data Data - + Display Zobrazit - + Settings Nastavení - + Units Jednotky - + Help Nápověda - + Previous map Předchozí mapa - - + + Date Datum - + + + Routes + Počet tras + + + No GPX files loaded Nejsou načteny žádné GPX soubory - + + %1 files + %1 souborů + + + Next file Následující soubor - + Version Verze - + Print... Tisknout... - + Export to PDF... Exportovat do PDF... - + + + Waypoints + Navigační body + + + Previous file Předchozí soubor - + First file První soubor - + Last file Poslední soubor - + Append modifier Modifikátor nahradit/přidat - + Map (tiles) source URLs are read on program startup from the following file: URL mapových zdrojů (dlaždic) jsou načteny při startu programu z následujícího souboru: - + 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: 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: - + To make GPXSee load a POI file automatically on startup, add the file to the following directory: POI soubory, které se mají automaticky nahrát při startu programu jsou načítány z následujícího adresáře: - + GPX files (*.gpx);;All files (*) Soubory GPX (*.gpx);;Všechny soubory (*) - - + + Line: %1 Řádka: %1 - + GPX files (*.gpx);;CSV files (*.csv);;All files (*) Soubory GPX (*.gpx);;Soubory CSV (*.csv);;Všechny soubory (*) - + + Tracks - Počet tras + Počet cest - - mi - mi - - - - + + About GPXSee O aplikaci GPXSee - + Navigation Navigace - + Map sources Mapové zdroje - + POIs POI body - - + Distance Vzdálenost - + Time Čas - - %1 tracks - Počet tras: %1 - - - - km - km - - - - + + Error Chyba - + Error loading GPX file: %1 Soubor GPX nelze otevřít: %1 - + Error loading POI file: %1 Soubor POI nelze otevřít: @@ -548,7 +535,7 @@ Tep - + km km @@ -568,17 +555,17 @@ Maximum - + m m - + ft ft - + mi mi @@ -645,22 +632,22 @@ Rychlost - + m m - + km - + ft ft - + km/h km/h @@ -675,12 +662,12 @@ Maximum - + mi mi - + mi/h mi/h @@ -714,32 +701,32 @@ Maximum - + m m - + km km - + ft ft - + mi mi - + C C - + F F diff --git a/src/elevationgraph.cpp b/src/elevationgraph.cpp index d960801e..6e754390 100644 --- a/src/elevationgraph.cpp +++ b/src/elevationgraph.cpp @@ -56,17 +56,10 @@ void ElevationGraph::loadPath(const QVector &data) void ElevationGraph::loadGPX(const GPX &gpx) { - for (int i = 0; i < gpx.trackCount(); i++) { - QVector data; - gpx.track(i).elevationGraph(data); - loadPath(data); - } - - for (int i = 0; i < gpx.routeCount(); i++) { - QVector 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(); diff --git a/src/gpx.cpp b/src/gpx.cpp index 7fc445e4..161a8098 100644 --- a/src/gpx.cpp +++ b/src/gpx.cpp @@ -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; } diff --git a/src/gpx.h b/src/gpx.h index e3862f30..b1daaf8e 100644 --- a/src/gpx.h +++ b/src/gpx.h @@ -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 &waypoints() const {return _waypoints;} + const QList &tracks() const {return _tracks;} + const QList &routes() const {return _routes;} + const QList &waypoints() const {return _waypoint_data;} private: Parser _parser; QString _error; int _errorLine; - QList > _tracks; - QList > _routes; - QList _waypoints; + QList _tracks; + QList _routes; + + QList > _track_data; + QList > _route_data; + QList _waypoint_data; }; #endif // GPX_H diff --git a/src/gui.cpp b/src/gui.cpp index e803f311..03e8e845 100644 --- a/src/gui.cpp +++ b/src/gui.cpp @@ -39,6 +39,8 @@ #include "gui.h" +#include + 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)); diff --git a/src/gui.h b/src/gui.h index acb45cb2..5c14835d 100644 --- a/src/gui.h +++ b/src/gui.h @@ -162,6 +162,8 @@ private: Map *_currentMap; int _trackCount; + int _routeCount; + int _waypointCount; qreal _distance; qreal _time; DateRange _dateRange; diff --git a/src/heartrategraph.cpp b/src/heartrategraph.cpp index b6eee0bd..c80b5d5a 100644 --- a/src/heartrategraph.cpp +++ b/src/heartrategraph.cpp @@ -23,11 +23,10 @@ void HeartRateGraph::setInfo() void HeartRateGraph::loadGPX(const GPX &gpx) { - for (int i = 0; i < gpx.trackCount(); i++) { - QVector data; + for (int i = 0; i < gpx.tracks().count(); i++) { + QVector 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(); diff --git a/src/route.cpp b/src/route.cpp index 5cb9b2e7..9f0bfcf0 100644 --- a/src/route.cpp +++ b/src/route.cpp @@ -6,20 +6,25 @@ Route::Route(const QVector &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 &graph) const +QVector Route::elevation() const { - if (!_data.size()) - return; + QVector 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(); } diff --git a/src/route.h b/src/route.h index 4e3607c1..2042ba0a 100644 --- a/src/route.h +++ b/src/route.h @@ -10,10 +10,11 @@ public: Route(const QVector &data); const QVector &route() const {return _data;} - void elevationGraph(QVector &graph) const; - qreal distance() const {return _dd.last();} + QVector elevation() const; - bool isNull() const {return (_data.count() < 2) ? true : false;} + qreal distance() const; + + bool isNull() const {return _dd.isEmpty();} private: const QVector &_data; diff --git a/src/routeitem.cpp b/src/routeitem.cpp index fbe6fce4..0e6bbef1 100644 --- a/src/routeitem.cpp +++ b/src/routeitem.cpp @@ -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 childs = childItems(); + for (int i = 0; i < childs.count(); i++) { + if (childs.at(i) != _marker) { + WaypointItem *wi = static_cast(childs.at(i)); + wi->showLabel(show); + } + } +} diff --git a/src/routeitem.h b/src/routeitem.h index 161e5a49..916c25bf 100644 --- a/src/routeitem.h +++ b/src/routeitem.h @@ -23,6 +23,7 @@ public: void moveMarker(qreal t); void showWaypoints(bool show); + void showWaypointLabels(bool show); private: QPainterPath _path; diff --git a/src/speedgraph.cpp b/src/speedgraph.cpp index a2aebe5f..a73970bc 100644 --- a/src/speedgraph.cpp +++ b/src/speedgraph.cpp @@ -24,22 +24,20 @@ void SpeedGraph::setInfo() void SpeedGraph::loadGPX(const GPX &gpx) { - for (int i = 0; i < gpx.trackCount(); i++) { - QVector data; - - gpx.track(i).speedGraph(data); + for (int i = 0; i < gpx.tracks().count(); i++) { + QVector 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(); diff --git a/src/temperaturegraph.cpp b/src/temperaturegraph.cpp index 25cf9dd4..c9228955 100644 --- a/src/temperaturegraph.cpp +++ b/src/temperaturegraph.cpp @@ -25,11 +25,10 @@ void TemperatureGraph::setInfo() void TemperatureGraph::loadGPX(const GPX &gpx) { - for (int i = 0; i < gpx.trackCount(); i++) { - QVector data; + for (int i = 0; i < gpx.tracks().count(); i++) { + QVector 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(); diff --git a/src/track.cpp b/src/track.cpp index 7fb6cb8c..2f8a5c33 100644 --- a/src/track.cpp +++ b/src/track.cpp @@ -84,36 +84,35 @@ Track::Track(const QVector &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 &graph) const +QVector Track::elevation() const { QVector 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 &graph) const +QVector Track::speed() const { qreal v, ds; qint64 dt; QVector 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 &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 &graph) const +QVector Track::heartRate() const { QVector 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 &graph) const +QVector Track::temperature() const { - if (!_data.size()) - return; + QVector 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 &track) const +QVector Track::track() const { + QVector 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(); } diff --git a/src/track.h b/src/track.h index dea99b12..2c080d88 100644 --- a/src/track.h +++ b/src/track.h @@ -10,16 +10,17 @@ class Track public: Track(const QVector &data); - void elevationGraph(QVector &graph) const; - void speedGraph(QVector &graph) const; - void heartRateGraph(QVector &graph) const; - void temperatureGraph(QVector &graph) const; - void track(QVector &track) const; - qreal distance() const {return _dd.last();} + QVector track() const; + QVector elevation() const; + QVector speed() const; + QVector heartRate() const; + QVector 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 &_data; diff --git a/src/trackitem.cpp b/src/trackitem.cpp index bcf41139..d00def1b 100644 --- a/src/trackitem.cpp +++ b/src/trackitem.cpp @@ -34,9 +34,7 @@ void TrackItem::updateShape() TrackItem::TrackItem(const Track &track, QGraphicsItem *parent) : QGraphicsItem(parent) { - QVector t; - - track.track(t); + const QVector &t = track.track(); Q_ASSERT(t.count() >= 2); const QPointF &p = t.at(0); diff --git a/src/trackview.cpp b/src/trackview.cpp index b171268c..5beaf499 100644 --- a/src/trackview.cpp +++ b/src/trackview.cpp @@ -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)