mirror of
https://github.com/tumic0/GPXSee.git
synced 2024-11-28 13:41:16 +01:00
parent
3f97d12a76
commit
c688b5fc09
@ -29,8 +29,8 @@ private:
|
|||||||
|
|
||||||
Ticks::Ticks(double minValue, double maxValue, int maxCount)
|
Ticks::Ticks(double minValue, double maxValue, int maxCount)
|
||||||
{
|
{
|
||||||
double range = niceNum(maxValue - minValue, 0);
|
double range = niceNum(maxValue - minValue, false);
|
||||||
_d = niceNum(range / maxCount, 1);
|
_d = niceNum(range / maxCount, true);
|
||||||
_min = ceil(minValue / _d) * _d;
|
_min = ceil(minValue / _d) * _d;
|
||||||
_max = floor(maxValue / _d) * _d;
|
_max = floor(maxValue / _d) * _d;
|
||||||
}
|
}
|
||||||
|
@ -349,6 +349,11 @@ void GUI::createActions()
|
|||||||
_showRouteWaypointsAction->setCheckable(true);
|
_showRouteWaypointsAction->setCheckable(true);
|
||||||
connect(_showRouteWaypointsAction, SIGNAL(triggered(bool)), _mapView,
|
connect(_showRouteWaypointsAction, SIGNAL(triggered(bool)), _mapView,
|
||||||
SLOT(showRouteWaypoints(bool)));
|
SLOT(showRouteWaypoints(bool)));
|
||||||
|
_showTicksAction = new QAction(tr("km/mi markers"), this);
|
||||||
|
_showTicksAction->setMenuRole(QAction::NoRole);
|
||||||
|
_showTicksAction->setCheckable(true);
|
||||||
|
connect(_showTicksAction, SIGNAL(triggered(bool)), _mapView,
|
||||||
|
SLOT(showTicks(bool)));
|
||||||
|
|
||||||
// Graph actions
|
// Graph actions
|
||||||
_showGraphsAction = new QAction(QIcon(SHOW_GRAPHS_ICON), tr("Show graphs"),
|
_showGraphsAction = new QAction(QIcon(SHOW_GRAPHS_ICON), tr("Show graphs"),
|
||||||
@ -536,6 +541,7 @@ void GUI::createMenus()
|
|||||||
QMenu *displayMenu = dataMenu->addMenu(tr("Display"));
|
QMenu *displayMenu = dataMenu->addMenu(tr("Display"));
|
||||||
displayMenu->addAction(_showWaypointLabelsAction);
|
displayMenu->addAction(_showWaypointLabelsAction);
|
||||||
displayMenu->addAction(_showRouteWaypointsAction);
|
displayMenu->addAction(_showRouteWaypointsAction);
|
||||||
|
displayMenu->addAction(_showTicksAction);
|
||||||
dataMenu->addSeparator();
|
dataMenu->addSeparator();
|
||||||
dataMenu->addAction(_showTracksAction);
|
dataMenu->addAction(_showTracksAction);
|
||||||
dataMenu->addAction(_showRoutesAction);
|
dataMenu->addAction(_showRoutesAction);
|
||||||
@ -1721,6 +1727,9 @@ void GUI::writeSettings()
|
|||||||
if (_showRouteWaypointsAction->isChecked() != SHOW_ROUTE_WAYPOINTS_DEFAULT)
|
if (_showRouteWaypointsAction->isChecked() != SHOW_ROUTE_WAYPOINTS_DEFAULT)
|
||||||
settings.setValue(SHOW_ROUTE_WAYPOINTS_SETTING,
|
settings.setValue(SHOW_ROUTE_WAYPOINTS_SETTING,
|
||||||
_showRouteWaypointsAction->isChecked());
|
_showRouteWaypointsAction->isChecked());
|
||||||
|
if (_showTicksAction->isChecked() != SHOW_TICKS_DEFAULT)
|
||||||
|
settings.setValue(SHOW_TICKS_SETTING,
|
||||||
|
_showTicksAction->isChecked());
|
||||||
settings.endGroup();
|
settings.endGroup();
|
||||||
|
|
||||||
settings.beginGroup(EXPORT_SETTINGS_GROUP);
|
settings.beginGroup(EXPORT_SETTINGS_GROUP);
|
||||||
@ -1984,6 +1993,10 @@ void GUI::readSettings()
|
|||||||
_mapView->showRouteWaypoints(false);
|
_mapView->showRouteWaypoints(false);
|
||||||
else
|
else
|
||||||
_showRouteWaypointsAction->setChecked(true);
|
_showRouteWaypointsAction->setChecked(true);
|
||||||
|
if (settings.value(SHOW_TICKS_SETTING, SHOW_TICKS_DEFAULT).toBool()) {
|
||||||
|
_mapView->showTicks(true);
|
||||||
|
_showTicksAction->setChecked(true);
|
||||||
|
}
|
||||||
settings.endGroup();
|
settings.endGroup();
|
||||||
|
|
||||||
settings.beginGroup(EXPORT_SETTINGS_GROUP);
|
settings.beginGroup(EXPORT_SETTINGS_GROUP);
|
||||||
|
@ -192,6 +192,7 @@ private:
|
|||||||
QAction *_showAreasAction;
|
QAction *_showAreasAction;
|
||||||
QAction *_showRouteWaypointsAction;
|
QAction *_showRouteWaypointsAction;
|
||||||
QAction *_showMarkersAction;
|
QAction *_showMarkersAction;
|
||||||
|
QAction *_showTicksAction;
|
||||||
QAction *_showCoordinatesAction;
|
QAction *_showCoordinatesAction;
|
||||||
QAction *_openOptionsAction;
|
QAction *_openOptionsAction;
|
||||||
QAction *_mapsEnd;
|
QAction *_mapsEnd;
|
||||||
|
@ -75,6 +75,7 @@ MapView::MapView(Map *map, POI *poi, QWidget *parent)
|
|||||||
_overlapPOIs = true;
|
_overlapPOIs = true;
|
||||||
_showRouteWaypoints = true;
|
_showRouteWaypoints = true;
|
||||||
_showMarkers = true;
|
_showMarkers = true;
|
||||||
|
_showPathTicks = false;
|
||||||
_trackWidth = 3;
|
_trackWidth = 3;
|
||||||
_routeWidth = 3;
|
_routeWidth = 3;
|
||||||
_trackStyle = Qt::SolidLine;
|
_trackStyle = Qt::SolidLine;
|
||||||
@ -125,6 +126,7 @@ PathItem *MapView::addTrack(const Track &track)
|
|||||||
ti->setDigitalZoom(_digitalZoom);
|
ti->setDigitalZoom(_digitalZoom);
|
||||||
ti->setMarkerColor(_markerColor);
|
ti->setMarkerColor(_markerColor);
|
||||||
ti->showMarker(_showMarkers);
|
ti->showMarker(_showMarkers);
|
||||||
|
ti->showTicks(_showPathTicks);
|
||||||
_scene->addItem(ti);
|
_scene->addItem(ti);
|
||||||
|
|
||||||
if (_showTracks)
|
if (_showTracks)
|
||||||
@ -154,6 +156,7 @@ PathItem *MapView::addRoute(const Route &route)
|
|||||||
ri->setDigitalZoom(_digitalZoom);
|
ri->setDigitalZoom(_digitalZoom);
|
||||||
ri->setMarkerColor(_markerColor);
|
ri->setMarkerColor(_markerColor);
|
||||||
ri->showMarker(_showMarkers);
|
ri->showMarker(_showMarkers);
|
||||||
|
ri->showTicks(_showPathTicks);
|
||||||
_scene->addItem(ri);
|
_scene->addItem(ri);
|
||||||
|
|
||||||
if (_showRoutes)
|
if (_showRoutes)
|
||||||
@ -724,6 +727,15 @@ void MapView::showMarkers(bool show)
|
|||||||
_routes.at(i)->showMarker(show);
|
_routes.at(i)->showMarker(show);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void MapView::showTicks(bool show)
|
||||||
|
{
|
||||||
|
_showPathTicks = show;
|
||||||
|
for (int i = 0; i < _tracks.size(); i++)
|
||||||
|
_tracks.at(i)->showTicks(show);
|
||||||
|
for (int i = 0; i < _routes.size(); i++)
|
||||||
|
_routes.at(i)->showTicks(show);
|
||||||
|
}
|
||||||
|
|
||||||
void MapView::showMap(bool show)
|
void MapView::showMap(bool show)
|
||||||
{
|
{
|
||||||
_showMap = show;
|
_showMap = show;
|
||||||
|
@ -79,6 +79,7 @@ public slots:
|
|||||||
void showRouteWaypoints(bool show);
|
void showRouteWaypoints(bool show);
|
||||||
void showMarkers(bool show);
|
void showMarkers(bool show);
|
||||||
void showCoordinates(bool show);
|
void showCoordinates(bool show);
|
||||||
|
void showTicks(bool show);
|
||||||
void clearMapCache();
|
void clearMapCache();
|
||||||
void setCoordinatesFormat(CoordinatesFormat format);
|
void setCoordinatesFormat(CoordinatesFormat format);
|
||||||
void setDevicePixelRatio(qreal deviceRatio, qreal mapRatio);
|
void setDevicePixelRatio(qreal deviceRatio, qreal mapRatio);
|
||||||
@ -139,7 +140,7 @@ private:
|
|||||||
|
|
||||||
bool _showMap, _showTracks, _showRoutes, _showAreas, _showWaypoints,
|
bool _showMap, _showTracks, _showRoutes, _showAreas, _showWaypoints,
|
||||||
_showWaypointLabels, _showPOI, _showPOILabels, _showRouteWaypoints,
|
_showWaypointLabels, _showPOI, _showPOILabels, _showRouteWaypoints,
|
||||||
_showMarkers;
|
_showMarkers, _showPathTicks;
|
||||||
bool _overlapPOIs;
|
bool _overlapPOIs;
|
||||||
int _trackWidth, _routeWidth, _areaWidth;
|
int _trackWidth, _routeWidth, _areaWidth;
|
||||||
Qt::PenStyle _trackStyle, _routeStyle, _areaStyle;
|
Qt::PenStyle _trackStyle, _routeStyle, _areaStyle;
|
||||||
|
@ -3,6 +3,7 @@
|
|||||||
#include <QPainter>
|
#include <QPainter>
|
||||||
#include "common/greatcircle.h"
|
#include "common/greatcircle.h"
|
||||||
#include "map/map.h"
|
#include "map/map.h"
|
||||||
|
#include "font.h"
|
||||||
#include "pathitem.h"
|
#include "pathitem.h"
|
||||||
|
|
||||||
|
|
||||||
@ -18,16 +19,30 @@ static inline unsigned segments(qreal distance)
|
|||||||
return ceil(distance / GEOGRAPHICAL_MILE);
|
return ceil(distance / GEOGRAPHICAL_MILE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static QFont font()
|
||||||
|
{
|
||||||
|
QFont font;
|
||||||
|
font.setPixelSize(10);
|
||||||
|
font.setFamily(FONT_FAMILY);
|
||||||
|
font.setBold(true);
|
||||||
|
|
||||||
|
return font;
|
||||||
|
}
|
||||||
|
|
||||||
|
QFont PathItem::_font = font();
|
||||||
|
|
||||||
PathItem::PathItem(const Path &path, Map *map, QGraphicsItem *parent)
|
PathItem::PathItem(const Path &path, Map *map, QGraphicsItem *parent)
|
||||||
: QGraphicsObject(parent), _path(path), _map(map)
|
: QGraphicsObject(parent), _path(path), _map(map)
|
||||||
{
|
{
|
||||||
Q_ASSERT(_path.isValid());
|
Q_ASSERT(_path.isValid());
|
||||||
|
|
||||||
|
_units = Metric;
|
||||||
_digitalZoom = 0;
|
_digitalZoom = 0;
|
||||||
_width = 3;
|
_width = 3;
|
||||||
QBrush brush(Qt::SolidPattern);
|
QBrush brush(Qt::SolidPattern);
|
||||||
_pen = QPen(brush, _width);
|
_pen = QPen(brush, _width);
|
||||||
_showMarker = true;
|
_showMarker = true;
|
||||||
|
_showTicks = false;
|
||||||
|
|
||||||
updatePainterPath();
|
updatePainterPath();
|
||||||
updateShape();
|
updateShape();
|
||||||
@ -38,6 +53,8 @@ PathItem::PathItem(const Path &path, Map *map, QGraphicsItem *parent)
|
|||||||
|
|
||||||
setCursor(Qt::ArrowCursor);
|
setCursor(Qt::ArrowCursor);
|
||||||
setAcceptHoverEvents(true);
|
setAcceptHoverEvents(true);
|
||||||
|
|
||||||
|
computeTickInfo();
|
||||||
}
|
}
|
||||||
|
|
||||||
void PathItem::updateShape()
|
void PathItem::updateShape()
|
||||||
@ -110,9 +127,29 @@ void PathItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *option,
|
|||||||
painter->setPen(_pen);
|
painter->setPen(_pen);
|
||||||
painter->drawPath(_painterPath);
|
painter->drawPath(_painterPath);
|
||||||
|
|
||||||
|
if (_showTicks) {
|
||||||
|
painter->setFont(_font);
|
||||||
|
painter->setRenderHint(QPainter::Antialiasing, false);
|
||||||
|
|
||||||
|
for (int i = 1; i < _tickCount; i++) {
|
||||||
|
QPointF pos(position(i * _tickSize * xInM()));
|
||||||
|
QPointF arrow[3] = {pos, QPointF(pos.x() + 3, pos.y() - 3),
|
||||||
|
QPointF(pos.x() - 3, pos.y() - 3)};
|
||||||
|
QString val(QString::number(i * _tickSize));
|
||||||
|
|
||||||
|
QRect br(_tickRect);
|
||||||
|
br.moveCenter(QPoint(pos.x(), pos.y() - br.height()/2 - 5));
|
||||||
|
painter->setPen(Qt::white);
|
||||||
|
painter->setBrush(_pen.color());
|
||||||
|
painter->drawPolygon(arrow, 3);
|
||||||
|
painter->drawRoundedRect(br, 2, 2);
|
||||||
|
painter->drawText(br, Qt::AlignCenter, val);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
QPen p = QPen(QBrush(Qt::red), 0);
|
painter->setBrush(Qt::NoBrush);
|
||||||
painter->setPen(p);
|
painter->setPen(Qt::red);
|
||||||
painter->drawRect(boundingRect());
|
painter->drawRect(boundingRect());
|
||||||
*/
|
*/
|
||||||
}
|
}
|
||||||
@ -284,6 +321,64 @@ void PathItem::showMarker(bool show)
|
|||||||
_marker->setVisible(show && isValid(position(_markerDistance)));
|
_marker->setVisible(show && isValid(position(_markerDistance)));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
qreal PathItem::xInM() const
|
||||||
|
{
|
||||||
|
return (_units == Nautical) ? NMIINM : (_units == Imperial) ? MIINM : KMINM;
|
||||||
|
}
|
||||||
|
|
||||||
|
unsigned PathItem::tickSize() const
|
||||||
|
{
|
||||||
|
qreal r = _path.last().last().distance() / xInM();
|
||||||
|
|
||||||
|
if (r < 1)
|
||||||
|
return 0;
|
||||||
|
else if (r < 10)
|
||||||
|
return 1;
|
||||||
|
else if (r < 50)
|
||||||
|
return 5;
|
||||||
|
else if (r < 100)
|
||||||
|
return 10;
|
||||||
|
else if (r < 500)
|
||||||
|
return 50;
|
||||||
|
else if (r < 1000)
|
||||||
|
return 100;
|
||||||
|
else if (r < 5000)
|
||||||
|
return 500;
|
||||||
|
else
|
||||||
|
return 1000;
|
||||||
|
}
|
||||||
|
|
||||||
|
void PathItem::computeTickInfo()
|
||||||
|
{
|
||||||
|
_tickSize = tickSize();
|
||||||
|
qreal f = xInM();
|
||||||
|
_tickCount = (int)_path.last().last().distance() / (_tickSize * f) + 1;
|
||||||
|
|
||||||
|
QFontMetrics fm(_font);
|
||||||
|
_tickRect = fm.boundingRect(QRect(), Qt::AlignCenter,
|
||||||
|
QString::number(qMax(_tickSize * (_tickCount - 1), 10)))
|
||||||
|
.adjusted(-2, 0, 2, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
void PathItem::showTicks(bool show)
|
||||||
|
{
|
||||||
|
if (_showTicks == show)
|
||||||
|
return;
|
||||||
|
|
||||||
|
prepareGeometryChange();
|
||||||
|
_showTicks = show;
|
||||||
|
}
|
||||||
|
|
||||||
|
void PathItem::setUnits(Units units)
|
||||||
|
{
|
||||||
|
if (_units == units)
|
||||||
|
return;
|
||||||
|
|
||||||
|
prepareGeometryChange();
|
||||||
|
_units = units;
|
||||||
|
computeTickInfo();
|
||||||
|
}
|
||||||
|
|
||||||
void PathItem::hoverEnterEvent(QGraphicsSceneHoverEvent *event)
|
void PathItem::hoverEnterEvent(QGraphicsSceneHoverEvent *event)
|
||||||
{
|
{
|
||||||
Q_UNUSED(event);
|
Q_UNUSED(event);
|
||||||
@ -305,3 +400,11 @@ void PathItem::hoverLeaveEvent(QGraphicsSceneHoverEvent *event)
|
|||||||
|
|
||||||
emit selected(false);
|
emit selected(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QRectF PathItem::boundingRect() const
|
||||||
|
{
|
||||||
|
return _showTicks
|
||||||
|
? _shape.boundingRect().adjusted(-_tickRect.width()/2,
|
||||||
|
-(_tickRect.height() + 4), _tickRect.width()/2, 0)
|
||||||
|
: _shape.boundingRect();
|
||||||
|
}
|
||||||
|
@ -5,6 +5,7 @@
|
|||||||
#include <QPen>
|
#include <QPen>
|
||||||
#include "data/path.h"
|
#include "data/path.h"
|
||||||
#include "markeritem.h"
|
#include "markeritem.h"
|
||||||
|
#include "units.h"
|
||||||
|
|
||||||
class Map;
|
class Map;
|
||||||
|
|
||||||
@ -16,7 +17,7 @@ public:
|
|||||||
PathItem(const Path &path, Map *map, QGraphicsItem *parent = 0);
|
PathItem(const Path &path, Map *map, QGraphicsItem *parent = 0);
|
||||||
|
|
||||||
QPainterPath shape() const {return _shape;}
|
QPainterPath shape() const {return _shape;}
|
||||||
QRectF boundingRect() const {return _shape.boundingRect();}
|
QRectF boundingRect() const;
|
||||||
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option,
|
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option,
|
||||||
QWidget *widget);
|
QWidget *widget);
|
||||||
|
|
||||||
@ -24,12 +25,16 @@ public:
|
|||||||
|
|
||||||
void setMap(Map *map);
|
void setMap(Map *map);
|
||||||
|
|
||||||
|
void setUnits(Units units);
|
||||||
void setColor(const QColor &color);
|
void setColor(const QColor &color);
|
||||||
void setWidth(qreal width);
|
void setWidth(qreal width);
|
||||||
void setStyle(Qt::PenStyle style);
|
void setStyle(Qt::PenStyle style);
|
||||||
void setDigitalZoom(int zoom);
|
void setDigitalZoom(int zoom);
|
||||||
void setMarkerColor(const QColor &color);
|
void setMarkerColor(const QColor &color);
|
||||||
void showMarker(bool show);
|
void showMarker(bool show);
|
||||||
|
void showTicks(bool show);
|
||||||
|
|
||||||
|
Units units() const {return _units;}
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
void moveMarker(qreal distance);
|
void moveMarker(qreal distance);
|
||||||
@ -49,6 +54,9 @@ private:
|
|||||||
void updateShape();
|
void updateShape();
|
||||||
void addSegment(const Coordinates &c1, const Coordinates &c2);
|
void addSegment(const Coordinates &c1, const Coordinates &c2);
|
||||||
|
|
||||||
|
qreal xInM() const;
|
||||||
|
unsigned tickSize() const;
|
||||||
|
void computeTickInfo();
|
||||||
|
|
||||||
void hoverEnterEvent(QGraphicsSceneHoverEvent *event);
|
void hoverEnterEvent(QGraphicsSceneHoverEvent *event);
|
||||||
void hoverLeaveEvent(QGraphicsSceneHoverEvent *event);
|
void hoverLeaveEvent(QGraphicsSceneHoverEvent *event);
|
||||||
@ -57,11 +65,17 @@ private:
|
|||||||
qreal _markerDistance;
|
qreal _markerDistance;
|
||||||
int _digitalZoom;
|
int _digitalZoom;
|
||||||
|
|
||||||
|
Units _units;
|
||||||
qreal _width;
|
qreal _width;
|
||||||
QPen _pen;
|
QPen _pen;
|
||||||
QPainterPath _shape;
|
QPainterPath _shape;
|
||||||
QPainterPath _painterPath;
|
QPainterPath _painterPath;
|
||||||
bool _showMarker;
|
bool _showMarker;
|
||||||
|
bool _showTicks;
|
||||||
|
QRect _tickRect;
|
||||||
|
int _tickSize, _tickCount;
|
||||||
|
|
||||||
|
static QFont _font;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // PATHITEM_H
|
#endif // PATHITEM_H
|
||||||
|
@ -31,7 +31,6 @@ RouteItem::RouteItem(const Route &route, Map *map, QGraphicsItem *parent)
|
|||||||
|
|
||||||
_name = route.name();
|
_name = route.name();
|
||||||
_desc = route.description();
|
_desc = route.description();
|
||||||
_units = Metric;
|
|
||||||
_coordinatesFormat = DecimalDegrees;
|
_coordinatesFormat = DecimalDegrees;
|
||||||
|
|
||||||
setToolTip(toolTip(Metric));
|
setToolTip(toolTip(Metric));
|
||||||
@ -50,20 +49,20 @@ void RouteItem::setMap(Map *map)
|
|||||||
PathItem::setMap(map);
|
PathItem::setMap(map);
|
||||||
}
|
}
|
||||||
|
|
||||||
void RouteItem::setUnits(Units units)
|
void RouteItem::setUnits(Units u)
|
||||||
{
|
{
|
||||||
if (_units == units)
|
if (units() == u)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
_units = units;
|
PathItem::setUnits(u);
|
||||||
|
|
||||||
setToolTip(toolTip(_units));
|
setToolTip(toolTip(units()));
|
||||||
|
|
||||||
QList<QGraphicsItem *> childs = childItems();
|
QList<QGraphicsItem *> childs = childItems();
|
||||||
for (int i = 0; i < childs.count(); i++) {
|
for (int i = 0; i < childs.count(); i++) {
|
||||||
if (childs.at(i) != _marker) {
|
if (childs.at(i) != _marker) {
|
||||||
WaypointItem *wi = static_cast<WaypointItem*>(childs.at(i));
|
WaypointItem *wi = static_cast<WaypointItem*>(childs.at(i));
|
||||||
wi->setToolTipFormat(_units, _coordinatesFormat);
|
wi->setToolTipFormat(units(), _coordinatesFormat);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -79,7 +78,7 @@ void RouteItem::setCoordinatesFormat(CoordinatesFormat format)
|
|||||||
for (int i = 0; i < childs.count(); i++) {
|
for (int i = 0; i < childs.count(); i++) {
|
||||||
if (childs.at(i) != _marker) {
|
if (childs.at(i) != _marker) {
|
||||||
WaypointItem *wi = static_cast<WaypointItem*>(childs.at(i));
|
WaypointItem *wi = static_cast<WaypointItem*>(childs.at(i));
|
||||||
wi->setToolTipFormat(_units, _coordinatesFormat);
|
wi->setToolTipFormat(units(), _coordinatesFormat);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -17,7 +17,7 @@ public:
|
|||||||
|
|
||||||
void setMap(Map *map);
|
void setMap(Map *map);
|
||||||
|
|
||||||
void setUnits(Units units);
|
void setUnits(Units u);
|
||||||
void setCoordinatesFormat(CoordinatesFormat format);
|
void setCoordinatesFormat(CoordinatesFormat format);
|
||||||
void showWaypoints(bool show);
|
void showWaypoints(bool show);
|
||||||
void showWaypointLabels(bool show);
|
void showWaypointLabels(bool show);
|
||||||
@ -27,7 +27,6 @@ private:
|
|||||||
|
|
||||||
QString _name;
|
QString _name;
|
||||||
QString _desc;
|
QString _desc;
|
||||||
Units _units;
|
|
||||||
CoordinatesFormat _coordinatesFormat;
|
CoordinatesFormat _coordinatesFormat;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -61,9 +61,9 @@ void ScaleItem::computeScale()
|
|||||||
qreal res = _res * pow(2, -_digitalZoom);
|
qreal res = _res * pow(2, -_digitalZoom);
|
||||||
|
|
||||||
if (_units == Imperial) {
|
if (_units == Imperial) {
|
||||||
_length = niceNum((res * M2FT * SCALE_WIDTH) / SEGMENTS, 1);
|
_length = niceNum((res * M2FT * SCALE_WIDTH) / SEGMENTS, true);
|
||||||
if (_length >= MIINFT) {
|
if (_length >= MIINFT) {
|
||||||
_length = niceNum((res * M2MI * SCALE_WIDTH) / SEGMENTS, 1);
|
_length = niceNum((res * M2MI * SCALE_WIDTH) / SEGMENTS, true);
|
||||||
_width = (_length / (res * M2MI));
|
_width = (_length / (res * M2MI));
|
||||||
_scale = true;
|
_scale = true;
|
||||||
} else {
|
} else {
|
||||||
@ -71,9 +71,9 @@ void ScaleItem::computeScale()
|
|||||||
_scale = false;
|
_scale = false;
|
||||||
}
|
}
|
||||||
} else if (_units == Nautical) {
|
} else if (_units == Nautical) {
|
||||||
_length = niceNum((res * M2FT * SCALE_WIDTH) / SEGMENTS, 1);
|
_length = niceNum((res * M2FT * SCALE_WIDTH) / SEGMENTS, true);
|
||||||
if (_length >= NMIINFT) {
|
if (_length >= NMIINFT) {
|
||||||
_length = niceNum((res * M2NMI * SCALE_WIDTH) / SEGMENTS, 1);
|
_length = niceNum((res * M2NMI * SCALE_WIDTH) / SEGMENTS, true);
|
||||||
_width = (_length / (res * M2NMI));
|
_width = (_length / (res * M2NMI));
|
||||||
_scale = true;
|
_scale = true;
|
||||||
} else {
|
} else {
|
||||||
@ -81,7 +81,7 @@ void ScaleItem::computeScale()
|
|||||||
_scale = false;
|
_scale = false;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
_length = niceNum((res * SCALE_WIDTH) / SEGMENTS, 1);
|
_length = niceNum((res * SCALE_WIDTH) / SEGMENTS, true);
|
||||||
if (_length >= KMINM) {
|
if (_length >= KMINM) {
|
||||||
_length *= M2KM;
|
_length *= M2KM;
|
||||||
_width = (_length / (res * M2KM));
|
_width = (_length / (res * M2KM));
|
||||||
|
@ -32,6 +32,8 @@
|
|||||||
#define SHOW_GRAPH_SLIDER_INFO_DEFAULT true
|
#define SHOW_GRAPH_SLIDER_INFO_DEFAULT true
|
||||||
#define SHOW_MARKERS_SETTING "pathMarkers"
|
#define SHOW_MARKERS_SETTING "pathMarkers"
|
||||||
#define SHOW_MARKERS_DEFAULT true
|
#define SHOW_MARKERS_DEFAULT true
|
||||||
|
#define SHOW_TICKS_SETTING "pathTicks"
|
||||||
|
#define SHOW_TICKS_DEFAULT false
|
||||||
|
|
||||||
#define MAP_SETTINGS_GROUP "Map"
|
#define MAP_SETTINGS_GROUP "Map"
|
||||||
#define CURRENT_MAP_SETTING "map"
|
#define CURRENT_MAP_SETTING "map"
|
||||||
|
@ -39,5 +39,6 @@ TrackItem::TrackItem(const Track &track, Map *map, QGraphicsItem *parent)
|
|||||||
|
|
||||||
void TrackItem::setUnits(Units units)
|
void TrackItem::setUnits(Units units)
|
||||||
{
|
{
|
||||||
|
PathItem::setUnits(units);
|
||||||
setToolTip(toolTip(units));
|
setToolTip(toolTip(units));
|
||||||
}
|
}
|
||||||
|
@ -17,7 +17,7 @@ int str2int(const char *str, int len)
|
|||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
double niceNum(double x, int round)
|
double niceNum(double x, bool round)
|
||||||
{
|
{
|
||||||
int expv;
|
int expv;
|
||||||
double f;
|
double f;
|
||||||
|
@ -2,6 +2,6 @@
|
|||||||
#define UTIL_H
|
#define UTIL_H
|
||||||
|
|
||||||
int str2int(const char *str, int len);
|
int str2int(const char *str, int len);
|
||||||
double niceNum(double x, int round);
|
double niceNum(double x, bool round);
|
||||||
|
|
||||||
#endif // UTIL_H
|
#endif // UTIL_H
|
||||||
|
Loading…
Reference in New Issue
Block a user