1
0
mirror of https://github.com/tumic0/GPXSee.git synced 2025-06-27 03:29:16 +02:00

Added hillshading to vector maps

This commit is contained in:
2024-02-21 08:49:09 +01:00
parent f21a155f79
commit cf86fb7557
27 changed files with 438 additions and 81 deletions

View File

@ -461,6 +461,11 @@ void GUI::createActions()
_showDEMTilesAction = new QAction(tr("Show local DEM tiles"), this);
_showDEMTilesAction->setMenuRole(QAction::NoRole);
connect(_showDEMTilesAction, &QAction::triggered, this, &GUI::showDEMTiles);
_drawHillShadingAction = new QAction(tr("Show hillshading"), this);
_drawHillShadingAction->setMenuRole(QAction::NoRole);
_drawHillShadingAction->setCheckable(true);
connect(_drawHillShadingAction, &QAction::triggered, _mapView,
&MapView::drawHillShading);
// Graph actions
_showGraphsAction = new QAction(QIcon::fromTheme(SHOW_GRAPHS_NAME,
@ -711,6 +716,8 @@ void GUI::createMenus()
QMenu *demMenu = menuBar()->addMenu(tr("DEM"));
demMenu->addAction(_showDEMTilesAction);
demMenu->addAction(_downloadDEMAction);
demMenu->addSeparator();
demMenu->addAction(_drawHillShadingAction);
QMenu *positionMenu = menuBar()->addMenu(tr("Position"));
positionMenu->addAction(_showPositionCoordinatesAction);
@ -2499,6 +2506,11 @@ void GUI::writeSettings()
WRITE(useStyles, _useStylesAction->isChecked());
settings.endGroup();
/* DEM */
settings.beginGroup(SETTINGS_DEM);
WRITE(drawHillShading, _drawHillShadingAction->isChecked());
settings.endGroup();
/* Position */
settings.beginGroup(SETTINGS_POSITION);
WRITE(showPosition, _showPositionAction->isChecked());
@ -2781,6 +2793,14 @@ void GUI::readSettings(QString &activeMap, QStringList &disabledPOIs,
_hideMarkersAction->setChecked(true);
settings.endGroup();
/* DEM */
settings.beginGroup(SETTINGS_DEM);
if (READ(drawHillShading).toBool()) {
_drawHillShadingAction->setChecked(true);
_mapView->drawHillShading(true);
}
settings.endGroup();
/* Position */
settings.beginGroup(SETTINGS_POSITION);
if (READ(showPosition).toBool()) {

View File

@ -291,6 +291,7 @@ private:
QAction *_openOptionsAction;
QAction *_downloadDEMAction;
QAction *_showDEMTilesAction;
QAction *_drawHillShadingAction;
QAction *_mapsEnd;
QAction *_poisEnd;
#ifndef Q_OS_ANDROID

View File

@ -64,6 +64,7 @@ MapView::MapView(Map *map, POI *poi, QWidget *parent) : QGraphicsView(parent)
_outputProjection = PCS::pcs(3857);
_inputProjection = GCS::gcs(4326);
_hidpi = true;
_hillShading = false;
_map = map;
_map->load(_inputProjection, _outputProjection, _deviceRatio, _hidpi);
connect(_map, &Map::tilesLoaded, this, &MapView::reloadMap);
@ -1114,6 +1115,8 @@ void MapView::drawBackground(QPainter *painter, const QRectF &rect)
flags = Map::Block;
else if (_opengl)
flags = Map::OpenGL;
if (_hillShading)
flags |= Map::HillShading;
_map->draw(painter, ir, flags);
}
@ -1178,7 +1181,9 @@ void MapView::mouseMoveEvent(QMouseEvent *event)
{
if (_cursorCoordinates->isVisible()) {
Coordinates c(_map->xy2ll(mapToScene(event->pos())));
DEM::lock();
_cursorCoordinates->setCoordinates(c, DEM::elevation(c));
DEM::unlock();
}
QGraphicsView::mouseMoveEvent(event);
@ -1244,6 +1249,13 @@ void MapView::useAntiAliasing(bool use)
setRenderHint(QPainter::Antialiasing, use);
}
void MapView::drawHillShading(bool draw)
{
_hillShading = draw;
setMap(_map);
}
void MapView::useStyles(bool use)
{
GraphicsItem::useStyle(use);

View File

@ -128,6 +128,7 @@ public slots:
void followPosition(bool follow);
void showMotionInfo(bool show);
void useStyles(bool use);
void drawHillShading(bool draw);
private slots:
void updatePOI();
@ -206,6 +207,8 @@ private:
qreal _areaOpacity;
bool _infoBackground;
bool _hillShading;
int _digitalZoom;
bool _plot;
QCursor _cursor;

View File

@ -173,6 +173,9 @@ SETTING(positionMarkers, "positionMarkers", true );
SETTING(markerInfo, "markerInfo", MarkerInfoItem::None );
SETTING(useStyles, "styles", true );
/* DEM */
SETTING(drawHillShading, "hillshading", true );
/* Position */
SETTING(showPosition, "show", false );
SETTING(followPosition, "follow", true );

View File

@ -12,6 +12,7 @@
#define SETTINGS_GRAPH "Graph"
#define SETTINGS_POI "POI"
#define SETTINGS_DATA "Data"
#define SETTINGS_DEM "DEM"
#define SETTINGS_POSITION "Position"
#define SETTINGS_PDF_EXPORT "Export"
#define SETTINGS_PNG_EXPORT "PNGExport"
@ -124,6 +125,9 @@ public:
static const Setting markerInfo;
static const Setting useStyles;
/* DEM */
static const Setting drawHillShading;
/* Position */
static const Setting showPosition;
static const Setting followPosition;

View File

@ -25,11 +25,11 @@ ToolTip WaypointItem::info() const
tt.insert(qApp->translate("WaypointItem", "Name"), _waypoint.name());
tt.insert(qApp->translate("WaypointItem", "Coordinates"),
Format::coordinates(_waypoint.coordinates(), _format));
if (!std::isnan(_waypoint.elevations().first)) {
QString val = Format::elevation(_waypoint.elevations().first, _units);
if (!std::isnan(_waypoint.elevations().second))
val += " (" + Format::elevation(_waypoint.elevations().second,
_units) + ")";
QPair<qreal, qreal> elevations(_waypoint.elevations());
if (!std::isnan(elevations.first)) {
QString val = Format::elevation(elevations.first, _units);
if (!std::isnan(elevations.second))
val += " (" + Format::elevation(elevations.second, _units) + ")";
tt.insert(qApp->translate("WaypointItem", "Elevation"), val);
}
if (_waypoint.timestamp().isValid())