diff --git a/lang/gpxsee_cs.ts b/lang/gpxsee_cs.ts index 8effd77f..6ffb154c 100644 --- a/lang/gpxsee_cs.ts +++ b/lang/gpxsee_cs.ts @@ -163,17 +163,17 @@ 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 @@ -189,8 +189,8 @@ - - + + Keyboard controls Ovládací klávesy @@ -205,20 +205,20 @@ Znovu načíst - + Show Zobrazit - - + + File Soubor - - + + Data sources Zdroje dat @@ -233,125 +233,130 @@ Zavřit POI soubory - + + Overlap POIs + Překrývat POI + + + Show POIs Zobrazit POI - + Show map Zobrazit mapu - + Clear tile cache Vymazat mezipaměť dlaždic - - + + Next map Následující mapa - + 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 - + Settings Nastavení - + Units Jednotky - + Help Nápověda - + Previous map Předchozí mapa - - + + Date Datum - + No GPX files loaded Nejsou načteny žádné GPX soubory - + Next file Následující soubor - + Version Verze @@ -366,123 +371,123 @@ Exportovat do PDF... - + 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 - + 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: @@ -538,30 +543,49 @@ mi + + Misc + + + + ft + ft + + + + mi + mi + + + + + m + m + + + + km + km + + QObject - mi mi - - ft ft - km km - - m m @@ -680,4 +704,45 @@ F + + TrackItem + + + Distance + Vzdálenost + + + + Time + Čas + + + + Date + Datum + + + + WaypointItem + + + Coordinates + Souřadnice + + + + Elevation + Výška + + + + Date + Datum + + + + Description + Popis + + diff --git a/src/gui.cpp b/src/gui.cpp index d5f37e3f..6bd2ced0 100644 --- a/src/gui.cpp +++ b/src/gui.cpp @@ -226,6 +226,10 @@ void GUI::createActions() _closePOIAction = new QAction(QIcon(QPixmap(CLOSE_FILE_ICON)), tr("Close POI files"), this); connect(_closePOIAction, SIGNAL(triggered()), this, SLOT(closePOIFiles())); + _overlapPOIAction = new QAction(tr("Overlap POIs"), this); + _overlapPOIAction->setCheckable(true); + connect(_overlapPOIAction, SIGNAL(triggered(bool)), this, + SLOT(overlapPOIs(bool))); _showPOIAction = new QAction(QIcon(QPixmap(SHOW_POI_ICON)), tr("Show POIs"), this); _showPOIAction->setCheckable(true); @@ -338,6 +342,8 @@ void GUI::createMenus() _poiMenu->addAction(_openPOIAction); _poiMenu->addAction(_closePOIAction); _poiMenu->addSeparator(); + _poiMenu->addAction(_overlapPOIAction); + _poiMenu->addSeparator(); _poiMenu->addAction(_showPOIAction); _settingsMenu = menuBar()->addMenu(tr("Settings")); @@ -601,8 +607,9 @@ bool GUI::openPOIFile(const QString &fileName) } else { _showPOIAction->setChecked(true); _track->loadPOI(_poi); - _poiFilesMenu->addAction(createPOIFileAction( - _poi.files().indexOf(fileName))); + QAction *action = createPOIFileAction(_poi.files().indexOf(fileName)); + action->setChecked(true); + _poiFilesMenu->addAction(action); return true; } @@ -764,6 +771,11 @@ void GUI::closeAll() updateTrackView(); } +void GUI::overlapPOIs(bool checked) +{ + _track->setPOIOverlap(checked); +} + void GUI::showPOI(bool checked) { if (checked) @@ -1082,6 +1094,7 @@ void GUI::writeSettings() settings.beginGroup(POI_SETTINGS_GROUP); settings.setValue(SHOW_POI_SETTING, _showPOIAction->isChecked()); + settings.setValue(OVERLAP_POI_SETTING, _overlapPOIAction->isChecked()); settings.remove(DISABLED_POI_FILE_SETTINGS_PREFIX); settings.beginWriteArray(DISABLED_POI_FILE_SETTINGS_PREFIX); @@ -1138,6 +1151,11 @@ void GUI::readSettings() settings.endGroup(); settings.beginGroup(POI_SETTINGS_GROUP); + if (settings.value(OVERLAP_POI_SETTING, true).toBool() == false) { + _track->setPOIOverlap(false); + _overlapPOIAction->setChecked(false); + } else + _overlapPOIAction->setChecked(true); if (settings.value(SHOW_POI_SETTING, false).toBool() == true) _showPOIAction->setChecked(true); for (int i = 0; i < _poiFilesActions.count(); i++) diff --git a/src/gui.h b/src/gui.h index 44324224..c56fdf1f 100644 --- a/src/gui.h +++ b/src/gui.h @@ -43,6 +43,7 @@ private slots: void reloadFile(); void openPOIFile(); void closePOIFiles(); + void overlapPOIs(bool checked); void showPOI(bool checked); void showMap(bool checked); void showGraphs(bool checked); @@ -128,6 +129,7 @@ private: QAction *_openPOIAction; QAction *_closePOIAction; QAction *_showPOIAction; + QAction *_overlapPOIAction; QAction *_showMapAction; QAction *_fullscreenAction; QAction *_clearMapCacheAction; diff --git a/src/ll.cpp b/src/ll.cpp index 98536f85..f4e39039 100644 --- a/src/ll.cpp +++ b/src/ll.cpp @@ -35,6 +35,16 @@ QPointF ll2mercator(const QPointF &ll) return m; } +QPointF mercator2ll(const QPointF &m) +{ + QPointF ll; + + ll.setX(m.x()); + ll.setY(rad2deg(2 * atan(exp(deg2rad(m.y()))) - M_PI/2)); + + return ll; +} + QPoint mercator2tile(const QPointF &m, int z) { QPoint tile; diff --git a/src/ll.h b/src/ll.h index 0b99094b..e84575d2 100644 --- a/src/ll.h +++ b/src/ll.h @@ -8,6 +8,7 @@ #define ZOOM_MIN 3 QPointF ll2mercator(const QPointF &ll); +QPointF mercator2ll(const QPointF &m); qreal llDistance(const QPointF &p1, const QPointF &p2); QPoint mercator2tile(const QPointF &m, int zoom); QPointF tile2mercator(const QPoint &tile, int zoom); diff --git a/src/misc.cpp b/src/misc.cpp index 995b2a91..f3a68376 100644 --- a/src/misc.cpp +++ b/src/misc.cpp @@ -1,7 +1,8 @@ #include -#include +#include #include "misc.h" + double niceNum(double x, int round) { int expv; @@ -50,28 +51,29 @@ QString distance(qreal value, Units units) { if (units == Imperial) { if (value < MIINM) - return QString::number(value * M2FT, 'f', 0) - + UNIT_SPACE + QObject::tr("ft"); + return QString::number(value * M2FT, 'f', 0) + UNIT_SPACE + + qApp->translate("Misc", "ft"); else - return QString::number(value * M2MI, 'f', 1) - + UNIT_SPACE + QObject::tr("mi"); + return QString::number(value * M2MI, 'f', 1) + UNIT_SPACE + + qApp->translate("Misc", "mi"); } else { if (value < KMINM) return QString::number(value, 'f', 0) + UNIT_SPACE - + QObject::tr("m"); + + qApp->translate("Misc", "m"); else - return QString::number(value * M2KM, 'f', 1) - + UNIT_SPACE + QObject::tr("km"); + return QString::number(value * M2KM, 'f', 1) + UNIT_SPACE + + qApp->translate("Misc", "km"); } } QString elevation(qreal value, Units units) { if (units == Metric) - return QString::number(value, 'f', 0) + UNIT_SPACE + QObject::tr("m"); + return QString::number(value, 'f', 0) + UNIT_SPACE + + qApp->translate("Misc", "m"); else return QString::number(value * M2FT, 'f', 0) + UNIT_SPACE - + QObject::tr("ft"); + + qApp->translate("Misc", "ft"); } QString coordinates(const QPointF &value) @@ -79,7 +81,6 @@ QString coordinates(const QPointF &value) QChar yH = (value.y() < 0) ? 'S' : 'N'; QChar xH = (value.x() < 0) ? 'W' : 'E'; - return QString::number(qAbs(value.y()), 'f', 5) + QChar(0x00B0) + " " + yH - + ", " + QString::number(qAbs(value.x()), 'f', 5) + QChar(0x00B0) + " " - + xH ; + return QString::number(qAbs(value.y()), 'f', 5) + yH + "," + QChar(0x00A0) + + QString::number(qAbs(value.x()), 'f', 5) + xH; } diff --git a/src/poi.cpp b/src/poi.cpp index 361b05c6..5364e84c 100644 --- a/src/poi.cpp +++ b/src/poi.cpp @@ -52,10 +52,10 @@ bool POI::loadGPXFile(const QString &fileName) index.end = _data.size() - 1; for (int i = index.start; i <= index.end; i++) { - QPointF p = ll2mercator(_data.at(i).coordinates()); + const QPointF &p = _data.at(i).coordinates(); qreal c[2]; c[0] = p.x(); - c[1] = -p.y(); + c[1] = p.y(); _tree.Insert(c, c, i); } @@ -124,10 +124,10 @@ bool POI::loadCSVFile(const QString &fileName) index.end = _data.size() - 1; for (int i = index.start; i <= index.end; i++) { - QPointF p = ll2mercator(_data.at(i).coordinates()); + const QPointF &p = _data.at(i).coordinates(); qreal c[2]; c[0] = p.x(); - c[1] = -p.y(); + c[1] = p.y(); _tree.Insert(c, c, i); } @@ -152,11 +152,11 @@ QVector POI::points(const QPainterPath &path, qreal radius) const qreal min[2], max[2]; for (int i = 0; i < path.elementCount(); i++) { - const QPointF &p = path.elementAt(i); + QPointF p = mercator2ll(path.elementAt(i)); min[0] = p.x() - radius; - min[1] = p.y() - radius; + min[1] = -p.y() - radius; max[0] = p.x() + radius; - max[1] = p.y() + radius; + max[1] = -p.y() + radius; _tree.Search(min, max, cb, &set); } @@ -177,7 +177,7 @@ QVector POI::points(const QList &list, qreal radius) qreal min[2], max[2]; for (int i = 0; i < list.count(); i++) { - const QPointF &p = list.at(i)->coordinates(); + const QPointF &p = list.at(i)->waypoint().coordinates(); min[0] = p.x() - radius; min[1] = p.y() - radius; max[0] = p.x() + radius; diff --git a/src/settings.h b/src/settings.h index fc826bb8..20519bb4 100644 --- a/src/settings.h +++ b/src/settings.h @@ -15,6 +15,7 @@ #define SHOW_MAP_SETTING "show" #define POI_SETTINGS_GROUP "POI" +#define OVERLAP_POI_SETTING "overlap" #define SHOW_POI_SETTING "show" #define DISABLED_POI_FILE_SETTINGS_PREFIX "disabled" #define DISABLED_POI_FILE_SETTING "file" diff --git a/src/tooltip.cpp b/src/tooltip.cpp index d0abe7a9..89488f0c 100644 --- a/src/tooltip.cpp +++ b/src/tooltip.cpp @@ -1,26 +1,20 @@ #include "tooltip.h" -ToolTip::ToolTip() -{ -} - void ToolTip::insert(const QString &key, const QString &value) { - KV kv(key, value); - int i; - - if ((i = _list.indexOf(kv)) < 0) - _list.append(kv); - else - _list[i] = kv; + QPair entry(key, value); + _list.append(entry); } QString ToolTip::toString() { - QString ret; + QString ret = ""; for (int i = 0; i < _list.count(); i++) - ret += "" + _list.at(i).key + ": " + _list.at(i).value + ""; + ret += "" + _list.at(i).first + + ": " + _list.at(i).second + ""; + + ret += ""; return ret; } diff --git a/src/tooltip.h b/src/tooltip.h index cae45d0a..5ec984a4 100644 --- a/src/tooltip.h +++ b/src/tooltip.h @@ -3,28 +3,16 @@ #include #include +#include class ToolTip { public: - ToolTip(); - void insert(const QString &key, const QString &value); QString toString(); private: - class KV { - public: - QString key; - QString value; - - KV(const QString &k, const QString &v) - {key = k; value = v;} - bool operator==(const KV &other) const - {return this->key == other.key;} - }; - - QList _list; + QList > _list; }; #endif // TOOLTIP_H diff --git a/src/trackitem.cpp b/src/trackitem.cpp index b3168ce7..fa7da9ae 100644 --- a/src/trackitem.cpp +++ b/src/trackitem.cpp @@ -1,3 +1,4 @@ +#include #include #include #include "ll.h" @@ -12,11 +13,13 @@ QString TrackItem::toolTip() { ToolTip tt; - tt.insert("Distance", ::distance(_distance, _units)); + tt.insert(qApp->translate("TrackItem", "Distance"), + ::distance(_distance, _units)); if (_time > 0) - tt.insert("Time", ::timeSpan(_time)); + tt.insert(qApp->translate("TrackItem", "Time"), ::timeSpan(_time)); if (!_date.isNull()) - tt.insert("Date", _date.toString(Qt::SystemLocaleShortDate)); + tt.insert(qApp->translate("TrackItem", "Date"), + _date.toString(Qt::SystemLocaleShortDate)); return tt.toString(); } diff --git a/src/trackview.cpp b/src/trackview.cpp index f52af029..9964433e 100644 --- a/src/trackview.cpp +++ b/src/trackview.cpp @@ -39,6 +39,7 @@ TrackView::TrackView(QWidget *parent) _plot = false; _units = Metric; + _overlap = true; } TrackView::~TrackView() @@ -199,6 +200,19 @@ qreal TrackView::mapScale(int zoom) const return ((360.0/(qreal)(1<::const_iterator it, jt; + + for (it = _pois.constBegin(); it != _pois.constEnd(); it++) { + for (jt = _pois.constBegin(); jt != _pois.constEnd(); jt++) { + if (it != jt && it.value()->isVisible() && jt.value()->isVisible() + && it.value()->collidesWithItem(jt.value())) + jt.value()->hide(); + } + } +} + void TrackView::rescale(qreal scale) { for (int i = 0; i < _paths.size(); i++) { @@ -209,19 +223,14 @@ void TrackView::rescale(qreal scale) for (int i = 0; i < _waypoints.size(); i++) _waypoints.at(i)->setScale(1.0/scale); - QHash::const_iterator it, jt; + QHash::const_iterator it; for (it = _pois.constBegin(); it != _pois.constEnd(); it++) { it.value()->setScale(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(); - } - } + if (!_overlap) + checkPOIOverlap(); _scale = scale; } @@ -245,8 +254,6 @@ void TrackView::addPOI(const QVector &waypoints) void TrackView::loadPOI(const POI &poi) { - QHash::const_iterator it,jt; - if (!_paths.size() && !_waypoints.size()) return; @@ -254,13 +261,8 @@ void TrackView::loadPOI(const POI &poi) addPOI(poi.points(_paths.at(i)->path())); addPOI(poi.points(_waypoints)); - for (it = _pois.constBegin(); it != _pois.constEnd(); it++) { - for (jt = _pois.constBegin(); jt != _pois.constEnd(); jt++) { - if (it != jt && it.value()->isVisible() && jt.value()->isVisible() - && it.value()->collidesWithItem(jt.value())) - jt.value()->hide(); - } - } + if (!_overlap) + checkPOIOverlap(); } void TrackView::setMap(Map *map) @@ -434,6 +436,18 @@ void TrackView::movePositionMarker(qreal val) } } +void TrackView::setPOIOverlap(bool overlap) +{ + _overlap = overlap; + + if (_overlap) { + QHash::const_iterator it; + for (it = _pois.constBegin(); it != _pois.constEnd(); it++) + it.value()->show(); + } else + checkPOIOverlap(); +} + void TrackView::drawBackground(QPainter *painter, const QRectF &rect) { if ((_paths.isEmpty() && _waypoints.isEmpty()) || !_map) { diff --git a/src/trackview.h b/src/trackview.h index 29d75d56..f5278ed1 100644 --- a/src/trackview.h +++ b/src/trackview.h @@ -34,6 +34,7 @@ public: void setMap(Map *map); void setUnits(enum Units units); + void setPOIOverlap(bool overlap); void plot(QPainter *painter, const QRectF &target); @@ -57,6 +58,7 @@ private: void rescale(qreal scale); void rescale(); void zoom(int z, const QPointF &pos); + void checkPOIOverlap(); void wheelEvent(QWheelEvent *event); void keyPressEvent(QKeyEvent *event); @@ -80,6 +82,7 @@ private: int _zoom; Units _units; + bool _overlap; bool _plot; }; diff --git a/src/waypointitem.cpp b/src/waypointitem.cpp index 02ee2034..7346da59 100644 --- a/src/waypointitem.cpp +++ b/src/waypointitem.cpp @@ -1,3 +1,4 @@ +#include #include #include "config.h" #include "ll.h" @@ -12,13 +13,17 @@ QString WaypointItem::toolTip() { ToolTip tt; - tt.insert("Coordinates", ::coordinates(_coordinates)); - if (!std::isnan(_elevation)) - tt.insert("Elevation", ::elevation(_elevation, _units)); - if (!_date.isNull()) - tt.insert("Date", _date.toString(Qt::SystemLocaleShortDate)); - if (!_description.isNull()) - tt.insert("Description", _description); + tt.insert(qApp->translate("WaypointItem", "Coordinates"), + ::coordinates(_waypoint.coordinates())); + if (!std::isnan(_waypoint.elevation())) + tt.insert(qApp->translate("WaypointItem", "Elevation"), + ::elevation(_waypoint.elevation() - _waypoint.geoidHeight(), _units)); + if (!_waypoint.timestamp().isNull()) + tt.insert(qApp->translate("WaypointItem", "Date"), + _waypoint.timestamp().toString(Qt::SystemLocaleShortDate)); + if (!_waypoint.description().isNull()) + tt.insert(qApp->translate("WaypointItem", "Description"), + _waypoint.description()); return tt.toString(); } @@ -28,19 +33,15 @@ WaypointItem::WaypointItem(const Waypoint &waypoint, QGraphicsItem *parent) { _units = Metric; - _label = waypoint.name(); + _waypoint = waypoint; _coordinates = ll2mercator(QPointF(waypoint.coordinates().x(), -waypoint.coordinates().y())); - _elevation = waypoint.elevation() - waypoint.geoidHeight(); - _description = waypoint.description(); - _date = waypoint.timestamp(); updateBoundingRect(); + setPos(_coordinates); setToolTip(toolTip()); setCursor(Qt::ArrowCursor); - - setPos(_coordinates); } void WaypointItem::updateBoundingRect() @@ -49,7 +50,7 @@ void WaypointItem::updateBoundingRect() font.setPixelSize(FONT_SIZE); font.setFamily(FONT_FAMILY); QFontMetrics fm(font); - QRect ts = fm.tightBoundingRect(_label); + QRect ts = fm.tightBoundingRect(_waypoint.name()); _boundingRect = QRectF(-POINT_SIZE/2, -POINT_SIZE/2, ts.width() + POINT_SIZE, ts.height() + fm.descent() + POINT_SIZE); @@ -64,11 +65,11 @@ void WaypointItem::paint(QPainter *painter, font.setPixelSize(FONT_SIZE); font.setFamily(FONT_FAMILY); QFontMetrics fm(font); - QRect ts = fm.tightBoundingRect(_label); + QRect ts = fm.tightBoundingRect(_waypoint.name()); painter->setFont(font); painter->drawText(POINT_SIZE/2 - qMax(ts.x(), 0), POINT_SIZE/2 + ts.height(), - _label); + _waypoint.name()); painter->setBrush(Qt::SolidPattern); painter->drawEllipse(-POINT_SIZE/2, -POINT_SIZE/2, POINT_SIZE, POINT_SIZE); diff --git a/src/waypointitem.h b/src/waypointitem.h index c666204c..d09dc9e2 100644 --- a/src/waypointitem.h +++ b/src/waypointitem.h @@ -9,27 +9,25 @@ class WaypointItem : public QGraphicsItem { public: WaypointItem(const Waypoint &waypoint, QGraphicsItem *parent = 0); - const QPointF &coordinates() {return _coordinates;} + + const Waypoint &waypoint() const {return _waypoint;} + const QPointF &coordinates() const {return _coordinates;} + + void setUnits(enum Units units); + void setScale(qreal scale); QRectF boundingRect() const {return _boundingRect;} void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget); - void setUnits(enum Units units); - void setScale(qreal scale); - private: void updateBoundingRect(); QString toolTip(); - QString _label; - QPointF _coordinates; QRectF _boundingRect; - + QPointF _coordinates; + Waypoint _waypoint; Units _units; - QDateTime _date; - QString _description; - qreal _elevation; }; #endif // WAYPOINTITEM_H