mirror of
https://github.com/tumic0/GPXSee.git
synced 2025-01-31 09:05:14 +01:00
Add Coordinates display option to position info
+ Data menu redesign Closes #343
This commit is contained in:
parent
60fb421f28
commit
e5de4dd5be
@ -84,23 +84,38 @@ QString Format::elevation(qreal value, Units units)
|
||||
+ qApp->translate("Format", "ft");
|
||||
}
|
||||
|
||||
QString Format::coordinates(const Coordinates &value, CoordinatesFormat type)
|
||||
|
||||
QString Format::lon(const Coordinates &c, CoordinatesFormat type)
|
||||
{
|
||||
QChar yH = (value.lat() < 0) ? 'S' : 'N';
|
||||
QChar xH = (value.lon() < 0) ? 'W' : 'E';
|
||||
QChar xH = (c.lon() < 0) ? 'W' : 'E';
|
||||
|
||||
switch (type) {
|
||||
case DegreesMinutes:
|
||||
return deg2DMM(qAbs(value.lat())) + yH + "," + QChar(0x00A0)
|
||||
+ deg2DMM(qAbs(value.lon())) + xH;
|
||||
break;
|
||||
return deg2DMM(qAbs(c.lon())) + xH;
|
||||
case DMS:
|
||||
return deg2DMS(qAbs(value.lat())) + yH + "," + QChar(0x00A0)
|
||||
+ deg2DMS(qAbs(value.lon())) + xH;
|
||||
break;
|
||||
return deg2DMS(qAbs(c.lon())) + xH;
|
||||
default:
|
||||
QLocale l(QLocale::system());
|
||||
return l.toString(qAbs(value.lat()), 'f', 5) + yH + ","
|
||||
+ QChar(0x00A0) + l.toString(qAbs(value.lon()), 'f', 5) + xH;
|
||||
return l.toString(qAbs(c.lon()), 'f', 5) + xH;
|
||||
}
|
||||
}
|
||||
|
||||
QString Format::lat(const Coordinates &c, CoordinatesFormat type)
|
||||
{
|
||||
QChar yH = (c.lat() < 0) ? 'S' : 'N';
|
||||
|
||||
switch (type) {
|
||||
case DegreesMinutes:
|
||||
return deg2DMM(qAbs(c.lat())) + yH;
|
||||
case DMS:
|
||||
return deg2DMS(qAbs(c.lat())) + yH;
|
||||
default:
|
||||
QLocale l(QLocale::system());
|
||||
return l.toString(qAbs(c.lat()), 'f', 5) + yH;
|
||||
}
|
||||
}
|
||||
|
||||
QString Format::coordinates(const Coordinates &c, CoordinatesFormat type)
|
||||
{
|
||||
return lat(c, type) + "," + QChar(0x00A0) + lon(c, type);
|
||||
}
|
||||
|
@ -17,7 +17,9 @@ namespace Format
|
||||
QString timeSpan(qreal time, bool full = true);
|
||||
QString distance(qreal value, Units units);
|
||||
QString elevation(qreal value, Units units);
|
||||
QString coordinates(const Coordinates &value, CoordinatesFormat type);
|
||||
QString coordinates(const Coordinates &c, CoordinatesFormat type);
|
||||
QString lon(const Coordinates &c, CoordinatesFormat type);
|
||||
QString lat(const Coordinates &c, CoordinatesFormat type);
|
||||
}
|
||||
|
||||
#endif // FORMAT_H
|
||||
|
103
src/GUI/gui.cpp
103
src/GUI/gui.cpp
@ -374,16 +374,25 @@ void GUI::createActions()
|
||||
_showTicksAction->setCheckable(true);
|
||||
connect(_showTicksAction, SIGNAL(triggered(bool)), _mapView,
|
||||
SLOT(showTicks(bool)));
|
||||
_showMarkersAction = new QAction(tr("Position markers"), this);
|
||||
QActionGroup *markerInfoGroup = new QActionGroup(this);
|
||||
connect(markerInfoGroup, SIGNAL(triggered(QAction*)), this,
|
||||
SLOT(showPathMarkerInfo(QAction*)));
|
||||
_hideMarkersAction = new QAction(tr("Do not show"), this);
|
||||
_hideMarkersAction->setMenuRole(QAction::NoRole);
|
||||
_hideMarkersAction->setCheckable(true);
|
||||
_hideMarkersAction->setActionGroup(markerInfoGroup);
|
||||
_showMarkersAction = new QAction(tr("Marker only"), this);
|
||||
_showMarkersAction->setMenuRole(QAction::NoRole);
|
||||
_showMarkersAction->setCheckable(true);
|
||||
connect(_showMarkersAction, SIGNAL(triggered(bool)), _mapView,
|
||||
SLOT(showMarkers(bool)));
|
||||
_showMarkerInfoAction = new QAction(tr("Position date/time"), this);
|
||||
_showMarkerInfoAction->setMenuRole(QAction::NoRole);
|
||||
_showMarkerInfoAction->setCheckable(true);
|
||||
connect(_showMarkerInfoAction, SIGNAL(triggered(bool)), _mapView,
|
||||
SLOT(showMarkerInfo(bool)));
|
||||
_showMarkersAction->setActionGroup(markerInfoGroup);
|
||||
_showMarkerDateAction = new QAction(tr("Date/time"), this);
|
||||
_showMarkerDateAction->setMenuRole(QAction::NoRole);
|
||||
_showMarkerDateAction->setCheckable(true);
|
||||
_showMarkerDateAction->setActionGroup(markerInfoGroup);
|
||||
_showMarkerCoordinatesAction = new QAction(tr("Coordinates"), this);
|
||||
_showMarkerCoordinatesAction->setMenuRole(QAction::NoRole);
|
||||
_showMarkerCoordinatesAction->setCheckable(true);
|
||||
_showMarkerCoordinatesAction->setActionGroup(markerInfoGroup);
|
||||
|
||||
// Graph actions
|
||||
_showGraphsAction = new QAction(QIcon(SHOW_GRAPHS_ICON), tr("Show graphs"),
|
||||
@ -564,12 +573,14 @@ void GUI::createMenus()
|
||||
poiMenu->addAction(_showPOIAction);
|
||||
|
||||
QMenu *dataMenu = menuBar()->addMenu(tr("&Data"));
|
||||
QMenu *displayMenu = dataMenu->addMenu(tr("Display"));
|
||||
displayMenu->addAction(_showWaypointLabelsAction);
|
||||
displayMenu->addAction(_showRouteWaypointsAction);
|
||||
displayMenu->addAction(_showTicksAction);
|
||||
displayMenu->addAction(_showMarkersAction);
|
||||
displayMenu->addAction(_showMarkerInfoAction);
|
||||
dataMenu->addAction(_showWaypointLabelsAction);
|
||||
dataMenu->addAction(_showRouteWaypointsAction);
|
||||
dataMenu->addAction(_showTicksAction);
|
||||
QMenu *markerMenu = dataMenu->addMenu(tr("Position info"));
|
||||
markerMenu->addAction(_hideMarkersAction);
|
||||
markerMenu->addAction(_showMarkersAction);
|
||||
markerMenu->addAction(_showMarkerDateAction);
|
||||
markerMenu->addAction(_showMarkerCoordinatesAction);
|
||||
dataMenu->addSeparator();
|
||||
dataMenu->addAction(_showTracksAction);
|
||||
dataMenu->addAction(_showRoutesAction);
|
||||
@ -728,7 +739,9 @@ void GUI::keys()
|
||||
+ tr("Toggle graph type") + "</td><td><i>"
|
||||
+ QKeySequence(TOGGLE_GRAPH_TYPE_KEY).toString() + "</i></td></tr><tr><td>"
|
||||
+ tr("Toggle time type") + "</td><td><i>"
|
||||
+ QKeySequence(TOGGLE_TIME_TYPE_KEY).toString()
|
||||
+ QKeySequence(TOGGLE_TIME_TYPE_KEY).toString() + "</i></td></tr><tr><td>"
|
||||
+ tr("Toggle position info") + "</td><td><i>"
|
||||
+ QKeySequence(TOGGLE_MARKER_INFO_KEY).toString() + "</i></td></tr>"
|
||||
+ "<tr><td></td><td></td></tr><tr><td>" + tr("Next map")
|
||||
+ "</td><td><i>" + NEXT_MAP_SHORTCUT.toString() + "</i></td></tr><tr><td>"
|
||||
+ tr("Previous map") + "</td><td><i>" + PREV_MAP_SHORTCUT.toString()
|
||||
@ -1026,7 +1039,6 @@ void GUI::openOptions()
|
||||
_mapView->setTimeZone(options.timeZone.zone());
|
||||
_dateRange.first = _dateRange.first.toTimeZone(options.timeZone.zone());
|
||||
_dateRange.second = _dateRange.second.toTimeZone(options.timeZone.zone());
|
||||
reload = true;
|
||||
}
|
||||
|
||||
if (reload)
|
||||
@ -1429,6 +1441,23 @@ void GUI::showGraphSliderInfo(bool show)
|
||||
_tabs.at(i)->showSliderInfo(show);
|
||||
}
|
||||
|
||||
void GUI::showPathMarkerInfo(QAction *action)
|
||||
{
|
||||
if (action == _showMarkersAction) {
|
||||
_mapView->showMarkers(true);
|
||||
_mapView->showMarkerInfo(MarkerInfoItem::None);
|
||||
} else if (action == _showMarkerDateAction) {
|
||||
_mapView->showMarkers(true);
|
||||
_mapView->showMarkerInfo(MarkerInfoItem::Date);
|
||||
} else if (action == _showMarkerCoordinatesAction) {
|
||||
_mapView->showMarkers(true);
|
||||
_mapView->showMarkerInfo(MarkerInfoItem::Position);
|
||||
} else {
|
||||
_mapView->showMarkers(false);
|
||||
_mapView->showMarkerInfo(MarkerInfoItem::None);
|
||||
}
|
||||
}
|
||||
|
||||
void GUI::loadMap()
|
||||
{
|
||||
QStringList files(QFileDialog::getOpenFileNames(this, tr("Open map file"),
|
||||
@ -1851,6 +1880,12 @@ void GUI::keyPressEvent(QKeyEvent *event)
|
||||
else
|
||||
_movingTimeAction->trigger();
|
||||
break;
|
||||
case TOGGLE_MARKER_INFO_KEY:
|
||||
if (_showMarkerDateAction->isChecked())
|
||||
_showMarkerCoordinatesAction->trigger();
|
||||
else if (_showMarkerCoordinatesAction->isChecked())
|
||||
_showMarkerDateAction->trigger();
|
||||
break;
|
||||
case Qt::Key_Escape:
|
||||
if (_fullscreenAction->isChecked()) {
|
||||
_fullscreenAction->setChecked(false);
|
||||
@ -2012,12 +2047,17 @@ void GUI::writeSettings()
|
||||
if (_showTicksAction->isChecked() != SHOW_TICKS_DEFAULT)
|
||||
settings.setValue(SHOW_TICKS_SETTING,
|
||||
_showTicksAction->isChecked());
|
||||
if (_showMarkersAction->isChecked() != SHOW_MARKERS_DEFAULT)
|
||||
settings.setValue(SHOW_MARKERS_SETTING,
|
||||
_showMarkersAction->isChecked());
|
||||
if (_showMarkerInfoAction->isChecked() != SHOW_MARKER_INFO_DEFAULT)
|
||||
settings.setValue(SHOW_MARKER_INFO_SETTING,
|
||||
_showMarkerInfoAction->isChecked());
|
||||
bool sm = _showMarkersAction->isChecked()
|
||||
| _showMarkerDateAction->isChecked()
|
||||
| _showMarkerCoordinatesAction->isChecked();
|
||||
if (sm != SHOW_MARKERS_DEFAULT)
|
||||
settings.setValue(SHOW_MARKERS_SETTING, sm);
|
||||
if (_showMarkerDateAction->isChecked()
|
||||
&& SHOW_MARKER_INFO_DEFAULT != MarkerInfoItem::Date)
|
||||
settings.setValue(SHOW_MARKER_INFO_SETTING, MarkerInfoItem::Date);
|
||||
else if (_showMarkerCoordinatesAction->isChecked()
|
||||
&& SHOW_MARKER_INFO_DEFAULT != MarkerInfoItem::Position)
|
||||
settings.setValue(SHOW_MARKER_INFO_SETTING, MarkerInfoItem::Position);
|
||||
settings.endGroup();
|
||||
|
||||
settings.beginGroup(PDF_EXPORT_SETTINGS_GROUP);
|
||||
@ -2311,15 +2351,18 @@ void GUI::readSettings()
|
||||
_mapView->showTicks(true);
|
||||
_showTicksAction->setChecked(true);
|
||||
}
|
||||
if (!settings.value(SHOW_MARKERS_SETTING, SHOW_MARKERS_DEFAULT).toBool())
|
||||
_mapView->showMarkers(false);
|
||||
if (settings.value(SHOW_MARKERS_SETTING, SHOW_MARKERS_DEFAULT).toBool()) {
|
||||
MarkerInfoItem::Type mt = static_cast<MarkerInfoItem::Type>
|
||||
(settings.value(SHOW_MARKER_INFO_SETTING,
|
||||
SHOW_MARKER_INFO_DEFAULT).toInt());
|
||||
if (mt == MarkerInfoItem::Position)
|
||||
_showMarkerCoordinatesAction->trigger();
|
||||
else if (mt == MarkerInfoItem::Date)
|
||||
_showMarkerDateAction->trigger();
|
||||
else
|
||||
_showMarkersAction->setChecked(true);
|
||||
if (settings.value(SHOW_MARKER_INFO_SETTING,
|
||||
SHOW_MARKER_INFO_DEFAULT).toBool()) {
|
||||
_mapView->showMarkerInfo(true);
|
||||
_showMarkerInfoAction->setChecked(true);
|
||||
}
|
||||
_showMarkersAction->trigger();
|
||||
} else
|
||||
_hideMarkersAction->trigger();
|
||||
settings.endGroup();
|
||||
|
||||
settings.beginGroup(PDF_EXPORT_SETTINGS_GROUP);
|
||||
|
@ -60,6 +60,7 @@ private slots:
|
||||
void showGraphs(bool show);
|
||||
void showGraphGrids(bool show);
|
||||
void showGraphSliderInfo(bool show);
|
||||
void showPathMarkerInfo(QAction *action);
|
||||
void showToolbars(bool show);
|
||||
void showFullscreen(bool show);
|
||||
void showTracks(bool show);
|
||||
@ -205,8 +206,10 @@ private:
|
||||
QAction *_showWaypointLabelsAction;
|
||||
QAction *_showAreasAction;
|
||||
QAction *_showRouteWaypointsAction;
|
||||
QAction *_hideMarkersAction;
|
||||
QAction *_showMarkersAction;
|
||||
QAction *_showMarkerInfoAction;
|
||||
QAction *_showMarkerDateAction;
|
||||
QAction *_showMarkerCoordinatesAction;
|
||||
QAction *_showTicksAction;
|
||||
QAction *_showCoordinatesAction;
|
||||
QAction *_openOptionsAction;
|
||||
|
@ -14,6 +14,7 @@
|
||||
#define ZOOM_OUT Qt::Key_Minus
|
||||
#define TOGGLE_GRAPH_TYPE_KEY Qt::Key_X
|
||||
#define TOGGLE_TIME_TYPE_KEY Qt::Key_T
|
||||
#define TOGGLE_MARKER_INFO_KEY Qt::Key_I
|
||||
|
||||
#define QUIT_SHORTCUT QKeySequence(QKeySequence::Quit)
|
||||
#define OPEN_SHORTCUT QKeySequence(QKeySequence::Open)
|
||||
|
@ -19,6 +19,7 @@
|
||||
#include "keys.h"
|
||||
#include "graphicsscene.h"
|
||||
#include "mapaction.h"
|
||||
#include "markerinfoitem.h"
|
||||
#include "mapview.h"
|
||||
|
||||
|
||||
@ -93,7 +94,7 @@ MapView::MapView(Map *map, POI *poi, QWidget *parent)
|
||||
_overlapPOIs = true;
|
||||
_showRouteWaypoints = true;
|
||||
_showMarkers = true;
|
||||
_showMarkerInfo = false;
|
||||
_markerInfoType = MarkerInfoItem::None;
|
||||
_showPathTicks = false;
|
||||
_trackWidth = 3;
|
||||
_routeWidth = 3;
|
||||
@ -142,7 +143,7 @@ PathItem *MapView::addTrack(const Track &track)
|
||||
ti->setDigitalZoom(_digitalZoom);
|
||||
ti->setMarkerColor(_markerColor);
|
||||
ti->showMarker(_showMarkers);
|
||||
ti->showMarkerInfo(_showMarkerInfo);
|
||||
ti->showMarkerInfo(_markerInfoType);
|
||||
ti->showTicks(_showPathTicks);
|
||||
_scene->addItem(ti);
|
||||
|
||||
@ -171,7 +172,7 @@ PathItem *MapView::addRoute(const Route &route)
|
||||
ri->setDigitalZoom(_digitalZoom);
|
||||
ri->setMarkerColor(_markerColor);
|
||||
ri->showMarker(_showMarkers);
|
||||
ri->showMarkerInfo(_showMarkerInfo);
|
||||
ri->showMarkerInfo(_markerInfoType);
|
||||
ri->showTicks(_showPathTicks);
|
||||
_scene->addItem(ri);
|
||||
|
||||
@ -484,6 +485,12 @@ void MapView::setUnits(Units units)
|
||||
void MapView::setCoordinatesFormat(CoordinatesFormat format)
|
||||
{
|
||||
WaypointItem::setCoordinatesFormat(format);
|
||||
PathItem::setCoordinatesFormat(format);
|
||||
|
||||
for (int i = 0; i < _tracks.count(); i++)
|
||||
_tracks[i]->updateMarkerInfo();
|
||||
for (int i = 0; i < _routes.count(); i++)
|
||||
_routes[i]->updateMarkerInfo();
|
||||
|
||||
_coordinates->setFormat(format);
|
||||
}
|
||||
@ -492,6 +499,11 @@ void MapView::setTimeZone(const QTimeZone &zone)
|
||||
{
|
||||
WaypointItem::setTimeZone(zone);
|
||||
PathItem::setTimeZone(zone);
|
||||
|
||||
for (int i = 0; i < _tracks.count(); i++)
|
||||
_tracks[i]->updateMarkerInfo();
|
||||
for (int i = 0; i < _routes.count(); i++)
|
||||
_routes[i]->updateMarkerInfo();
|
||||
}
|
||||
|
||||
void MapView::clearMapCache()
|
||||
@ -808,14 +820,14 @@ void MapView::showMarkers(bool show)
|
||||
_routes.at(i)->showMarker(show);
|
||||
}
|
||||
|
||||
void MapView::showMarkerInfo(bool show)
|
||||
void MapView::showMarkerInfo(MarkerInfoItem::Type type)
|
||||
{
|
||||
_showMarkerInfo = show;
|
||||
_markerInfoType = type;
|
||||
|
||||
for (int i = 0; i < _tracks.size(); i++)
|
||||
_tracks.at(i)->showMarkerInfo(show);
|
||||
_tracks.at(i)->showMarkerInfo(type);
|
||||
for (int i = 0; i < _routes.size(); i++)
|
||||
_routes.at(i)->showMarkerInfo(show);
|
||||
_routes.at(i)->showMarkerInfo(type);
|
||||
}
|
||||
|
||||
void MapView::showTicks(bool show)
|
||||
|
@ -14,6 +14,7 @@
|
||||
#include "searchpointer.h"
|
||||
#include "units.h"
|
||||
#include "format.h"
|
||||
#include "markerinfoitem.h"
|
||||
#include "palette.h"
|
||||
|
||||
|
||||
@ -95,7 +96,7 @@ public slots:
|
||||
void showCoordinates(bool show);
|
||||
void showTicks(bool show);
|
||||
void showMarkers(bool show);
|
||||
void showMarkerInfo(bool show);
|
||||
void showMarkerInfo(MarkerInfoItem::Type type);
|
||||
void showOverlappedPOIs(bool show);
|
||||
void showWaypointLabels(bool show);
|
||||
void showTracks(bool show);
|
||||
@ -162,7 +163,8 @@ private:
|
||||
|
||||
bool _showMap, _showTracks, _showRoutes, _showAreas, _showWaypoints,
|
||||
_showWaypointLabels, _showPOI, _showPOILabels, _showRouteWaypoints,
|
||||
_showMarkers, _showMarkerInfo, _showPathTicks;
|
||||
_showMarkers, _showPathTicks;
|
||||
MarkerInfoItem::Type _markerInfoType;
|
||||
bool _overlapPOIs;
|
||||
int _trackWidth, _routeWidth, _areaWidth;
|
||||
Qt::PenStyle _trackStyle, _routeStyle, _areaStyle;
|
||||
|
@ -1,12 +1,15 @@
|
||||
#include <QPainter>
|
||||
#include <QDateTime>
|
||||
#include <QLocale>
|
||||
#include "common/coordinates.h"
|
||||
#include "font.h"
|
||||
#include "markerinfoitem.h"
|
||||
|
||||
|
||||
#define OFFSET 7
|
||||
|
||||
CoordinatesFormat MarkerInfoItem::_format = DecimalDegrees;
|
||||
|
||||
MarkerInfoItem::MarkerInfoItem(QGraphicsItem *parent) : QGraphicsItem(parent)
|
||||
{
|
||||
_color = Qt::red;
|
||||
@ -20,8 +23,18 @@ void MarkerInfoItem::setDate(const QDateTime &date)
|
||||
prepareGeometryChange();
|
||||
|
||||
QLocale l;
|
||||
_date = l.toString(date.date(), QLocale::ShortFormat);
|
||||
_time = l.toString(date.time(), QLocale::ShortFormat);
|
||||
_s1 = l.toString(date.date(), QLocale::ShortFormat);
|
||||
_s2 = l.toString(date.time(), QLocale::ShortFormat);
|
||||
|
||||
updateBoundingRect();
|
||||
}
|
||||
|
||||
void MarkerInfoItem::setCoordinates(const Coordinates &c)
|
||||
{
|
||||
prepareGeometryChange();
|
||||
|
||||
_s1 = Format::lat(c, _format);
|
||||
_s2 = Format::lon(c, _format);
|
||||
|
||||
updateBoundingRect();
|
||||
}
|
||||
@ -30,8 +43,8 @@ void MarkerInfoItem::updateBoundingRect()
|
||||
{
|
||||
QFontMetrics fm(_font);
|
||||
|
||||
qreal width = qMax(fm.boundingRect(_date).width(),
|
||||
fm.boundingRect(_time).width());
|
||||
qreal width = qMax(fm.boundingRect(_s1).width(),
|
||||
fm.boundingRect(_s2).width());
|
||||
qreal height = 2 * fm.height() - 2*fm.descent();
|
||||
|
||||
_boundingRect = QRectF(-OFFSET/2, -height/2, width + 1.5*OFFSET, height);
|
||||
@ -44,24 +57,24 @@ void MarkerInfoItem::paint(QPainter *painter, const QStyleOptionGraphicsItem
|
||||
Q_UNUSED(widget);
|
||||
|
||||
QFontMetrics fm(_font);
|
||||
QRectF rd(OFFSET, -fm.height() + fm.descent(),
|
||||
fm.boundingRect(_date).width(), fm.height() - fm.descent());
|
||||
QRectF rt(OFFSET, 0, fm.boundingRect(_time).width(), fm.height()
|
||||
QRectF r1(OFFSET, -fm.height() + fm.descent(),
|
||||
fm.boundingRect(_s1).width(), fm.height() - fm.descent());
|
||||
QRectF r2(OFFSET, 0, fm.boundingRect(_s2).width(), fm.height()
|
||||
- fm.descent());
|
||||
|
||||
painter->setPen(Qt::NoPen);
|
||||
QColor bc(painter->background().color());
|
||||
bc.setAlpha(196);
|
||||
painter->setBrush(QBrush(bc));
|
||||
painter->drawRect(rt);
|
||||
painter->drawRect(rd);
|
||||
painter->drawRect(r2);
|
||||
painter->drawRect(r1);
|
||||
painter->setBrush(Qt::NoBrush);
|
||||
|
||||
painter->setFont(_font);
|
||||
painter->setPen(_color);
|
||||
|
||||
painter->drawText(OFFSET, -fm.descent()/2, _date);
|
||||
painter->drawText(OFFSET, fm.height() - fm.descent()*1.5, _time);
|
||||
painter->drawText(OFFSET, -fm.descent()/2, _s1);
|
||||
painter->drawText(OFFSET, fm.height() - fm.descent()*1.5, _s2);
|
||||
|
||||
//painter->drawRect(boundingRect());
|
||||
}
|
||||
|
@ -2,10 +2,19 @@
|
||||
#define MARKERINFOITEM_H
|
||||
|
||||
#include <QGraphicsItem>
|
||||
#include "format.h"
|
||||
|
||||
class Coordinates;
|
||||
|
||||
class MarkerInfoItem : public QGraphicsItem
|
||||
{
|
||||
public:
|
||||
enum Type {
|
||||
None,
|
||||
Date,
|
||||
Position
|
||||
};
|
||||
|
||||
MarkerInfoItem(QGraphicsItem *parent = 0);
|
||||
|
||||
QRectF boundingRect() const {return _boundingRect;}
|
||||
@ -13,15 +22,22 @@ public:
|
||||
QWidget *widget);
|
||||
|
||||
void setDate(const QDateTime &date);
|
||||
void setCoordinates(const Coordinates &c);
|
||||
|
||||
void setColor(const QColor &color);
|
||||
|
||||
static void setCoordinatesFormat(const CoordinatesFormat &format)
|
||||
{_format = format;}
|
||||
|
||||
private:
|
||||
void updateBoundingRect();
|
||||
|
||||
QString _date, _time;
|
||||
QString _s1, _s2;
|
||||
QRectF _boundingRect;
|
||||
QColor _color;
|
||||
QFont _font;
|
||||
|
||||
static CoordinatesFormat _format;
|
||||
};
|
||||
|
||||
#endif // MARKERINFOITEM_H
|
||||
|
@ -8,7 +8,6 @@
|
||||
#include "popup.h"
|
||||
#include "graphitem.h"
|
||||
#include "markeritem.h"
|
||||
#include "markerinfoitem.h"
|
||||
#include "pathitem.h"
|
||||
|
||||
|
||||
@ -44,6 +43,7 @@ PathItem::PathItem(const Path &path, Map *map, QGraphicsItem *parent)
|
||||
_pen = QPen(brush, _width);
|
||||
_showMarker = true;
|
||||
_showTicks = false;
|
||||
_markerInfoType = MarkerInfoItem::None;
|
||||
|
||||
updatePainterPath();
|
||||
updateShape();
|
||||
@ -288,13 +288,22 @@ void PathItem::setMarkerPosition(qreal pos)
|
||||
|
||||
void PathItem::setMarkerInfo(qreal pos)
|
||||
{
|
||||
if (_markerInfoType == MarkerInfoItem::Date) {
|
||||
qreal time = _graph
|
||||
? (_graph->graphType() == Time) ? pos : _graph->timeAtDistance(pos)
|
||||
: NAN;
|
||||
QDateTime d(date());
|
||||
|
||||
if (!std::isnan(time) && d.isValid())
|
||||
_markerInfo->setDate(d.addSecs(time).toTimeZone(_timeZone));
|
||||
} else if (_markerInfoType == MarkerInfoItem::Position)
|
||||
_markerInfo->setCoordinates(_map->xy2ll(_marker->pos()));
|
||||
}
|
||||
|
||||
void PathItem::updateMarkerInfo()
|
||||
{
|
||||
qreal pos = _graph ? (_graph->graphType() == Time)
|
||||
? _graph->distanceAtTime(_markerDistance) : _markerDistance : NAN;
|
||||
setMarkerInfo(pos);
|
||||
}
|
||||
|
||||
void PathItem::setMarkerColor(const QColor &color)
|
||||
@ -322,12 +331,18 @@ void PathItem::showMarker(bool show)
|
||||
return;
|
||||
|
||||
_showMarker = show;
|
||||
updateMarkerInfo();
|
||||
_marker->setVisible(show && isValid(position(_markerDistance)));
|
||||
}
|
||||
|
||||
void PathItem::showMarkerInfo(bool show)
|
||||
void PathItem::showMarkerInfo(MarkerInfoItem::Type type)
|
||||
{
|
||||
_markerInfo->setVisible(show);
|
||||
if (_markerInfoType == type)
|
||||
return;
|
||||
|
||||
_markerInfoType = type;
|
||||
updateMarkerInfo();
|
||||
_markerInfo->setVisible(type > MarkerInfoItem::None);
|
||||
}
|
||||
|
||||
qreal PathItem::xInM() const
|
||||
|
@ -6,13 +6,13 @@
|
||||
#include <QTimeZone>
|
||||
#include "data/path.h"
|
||||
#include "graphicsscene.h"
|
||||
#include "markerinfoitem.h"
|
||||
#include "units.h"
|
||||
|
||||
class Map;
|
||||
class PathTickItem;
|
||||
class GraphItem;
|
||||
class MarkerItem;
|
||||
class MarkerInfoItem;
|
||||
|
||||
class PathItem : public QObject, public GraphicsItem
|
||||
{
|
||||
@ -42,15 +42,18 @@ public:
|
||||
void setDigitalZoom(int zoom);
|
||||
void setMarkerColor(const QColor &color);
|
||||
void showMarker(bool show);
|
||||
void showMarkerInfo(bool show);
|
||||
void showMarkerInfo(MarkerInfoItem::Type type);
|
||||
void showTicks(bool show);
|
||||
|
||||
void setMarkerPosition(qreal pos);
|
||||
|
||||
void updateTicks();
|
||||
void updateMarkerInfo();
|
||||
|
||||
static void setUnits(Units units) {_units = units;}
|
||||
static void setTimeZone(const QTimeZone &zone) {_timeZone = zone;}
|
||||
static void setCoordinatesFormat(const CoordinatesFormat &format)
|
||||
{MarkerInfoItem::setCoordinatesFormat(format);}
|
||||
|
||||
public slots:
|
||||
void hover(bool hover);
|
||||
@ -90,6 +93,7 @@ private:
|
||||
QPainterPath _painterPath;
|
||||
bool _showMarker;
|
||||
bool _showTicks;
|
||||
MarkerInfoItem::Type _markerInfoType;
|
||||
|
||||
MarkerItem *_marker;
|
||||
MarkerInfoItem *_markerInfo;
|
||||
|
@ -66,7 +66,7 @@
|
||||
#define SHOW_MARKERS_SETTING "positionMarkers"
|
||||
#define SHOW_MARKERS_DEFAULT true
|
||||
#define SHOW_MARKER_INFO_SETTING "markerInfo"
|
||||
#define SHOW_MARKER_INFO_DEFAULT false
|
||||
#define SHOW_MARKER_INFO_DEFAULT MarkerInfoItem::None
|
||||
|
||||
#define PDF_EXPORT_SETTINGS_GROUP "Export"
|
||||
#define PAPER_ORIENTATION_SETTING "orientation"
|
||||
|
Loading…
x
Reference in New Issue
Block a user