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

Improved DEM downloads handling logic

This commit is contained in:
2021-09-01 13:08:34 +02:00
parent 133aac3bd4
commit 7f6ac2e4c3
9 changed files with 79 additions and 28 deletions

View File

@ -363,13 +363,12 @@ void GUI::createActions(TreeNode<MapAction*> &mapActions,
_showWaypointsAction = new QAction(tr("Show waypoints"), this);
_showWaypointsAction->setMenuRole(QAction::NoRole);
_showWaypointsAction->setCheckable(true);
connect(_showWaypointsAction, &QAction::triggered, _mapView,
&MapView::showWaypoints);
connect(_showWaypointsAction, &QAction::triggered, this,
&GUI::showWaypoints);
_showAreasAction = new QAction(tr("Show areas"), this);
_showAreasAction->setMenuRole(QAction::NoRole);
_showAreasAction->setCheckable(true);
connect(_showAreasAction, &QAction::triggered, _mapView,
&MapView::showAreas);
connect(_showAreasAction, &QAction::triggered, this, &GUI::showAreas);
_showWaypointLabelsAction = new QAction(tr("Waypoint labels"), this);
_showWaypointLabelsAction->setMenuRole(QAction::NoRole);
_showWaypointLabelsAction->setCheckable(true);
@ -867,6 +866,7 @@ bool GUI::loadFile(const QString &fileName, bool silent)
updateStatusBarInfo();
updateWindowTitle();
updateGraphTabs();
updateDEMDownloadAction();
QString error = tr("Error loading data file:") + "\n\n"
+ fileName + "\n\n" + data.errorString();
@ -932,6 +932,8 @@ void GUI::loadData(const Data &data)
pi->setMarkerPosition(gt->sliderPosition());
}
}
updateDEMDownloadAction();
}
void GUI::openPOIFile()
@ -1073,7 +1075,6 @@ void GUI::openOptions()
_dem->setAuthorization(options.demAuthorization
? Authorization(options.demUsername, options.demPassword)
: Authorization());
_downloadDEMAction->setEnabled(!options.demURL.isEmpty());
if (options.pixmapCache != _options.pixmapCache)
QPixmapCache::setCacheLimit(options.pixmapCache * 1024);
@ -1094,6 +1095,8 @@ void GUI::openOptions()
reloadFiles();
_options = options;
updateDEMDownloadAction();
}
void GUI::printFile()
@ -1387,6 +1390,7 @@ void GUI::reloadFiles()
_fileActionGroup->setEnabled(false);
else
_browser->setCurrent(_files.last());
updateDEMDownloadAction();
}
void GUI::closeFiles()
@ -1419,6 +1423,7 @@ void GUI::closeAll()
updateStatusBarInfo();
updateWindowTitle();
updateGraphTabs();
updateDEMDownloadAction();
}
void GUI::showGraphs(bool show)
@ -1478,6 +1483,7 @@ void GUI::showTracks(bool show)
updateStatusBarInfo();
updateGraphTabs();
updateDEMDownloadAction();
}
void GUI::showRoutes(bool show)
@ -1489,6 +1495,19 @@ void GUI::showRoutes(bool show)
updateStatusBarInfo();
updateGraphTabs();
updateDEMDownloadAction();
}
void GUI::showWaypoints(bool show)
{
_mapView->showWaypoints(show);
updateDEMDownloadAction();
}
void GUI::showAreas(bool show)
{
_mapView->showAreas(show);
updateDEMDownloadAction();
}
void GUI::showGraphGrids(bool show)
@ -1713,22 +1732,26 @@ void GUI::clearMapCache()
void GUI::downloadDEM()
{
_demRect = _mapView->boundingRect();
RectC br(_mapView->boundingRect());
_demRects.append(br);
if (_dem->loadTiles(_demRect))
_downloadDEMAction->setEnabled(false);
else
if (!_dem->loadTiles(br) && _demRects.size() == 1)
demLoaded();
}
void GUI::demLoaded()
{
if (!_dem->checkTiles(_demRect))
QMessageBox::warning(this, APP_NAME,
tr("Could not download all required DEM files."));
for (int i = 0; i < _demRects.size(); i++) {
if (!_dem->checkTiles(_demRects.at(i))) {
QMessageBox::warning(this, APP_NAME,
tr("Could not download all required DEM files."));
break;
}
}
DEM::clearCache();
_demRects.clear();
reloadFiles();
_downloadDEMAction->setEnabled(!_options.demURL.isEmpty());
}
void GUI::updateStatusBarInfo()
@ -1886,6 +1909,12 @@ bool GUI::updateGraphTabs()
return (hidden != _graphTabWidget->isHidden());
}
void GUI::updateDEMDownloadAction()
{
_downloadDEMAction->setEnabled(!_options.demURL.isEmpty()
&& !_dem->checkTiles(_mapView->boundingRect()));
}
void GUI::setTimeType(TimeType type)
{
for (int i = 0; i <_tabs.count(); i++)
@ -2703,8 +2732,6 @@ void GUI::readSettings()
if (_options.demAuthorization)
_dem->setAuthorization(Authorization(_options.demUsername,
_options.demPassword));
if (!_options.demURL.isEmpty())
_downloadDEMAction->setEnabled(true);
QPixmapCache::setCacheLimit(_options.pixmapCache * 1024);

View File

@ -67,6 +67,8 @@ private slots:
void showFullscreen(bool show);
void showTracks(bool show);
void showRoutes(bool show);
void showAreas(bool show);
void showWaypoints(bool show);
void loadMap();
void loadMapDir();
void nextMap();
@ -143,6 +145,7 @@ private:
void updateStatusBarInfo();
void updateWindowTitle();
bool updateGraphTabs();
void updateDEMDownloadAction();
TimeType timeType() const;
Units units() const;
@ -268,7 +271,7 @@ private:
Units _units;
RectC _demRect;
QList<RectC> _demRects;
};
#endif // GUI_H

View File

@ -1147,3 +1147,19 @@ void MapView::fitContentToSize()
centerOn(contentCenter());
}
RectC MapView::boundingRect() const
{
RectC rect;
if (_showTracks)
rect |= _tr;
if (_showRoutes)
rect |= _rr;
if (_showWaypoints)
rect |= _wr;
if (_showAreas)
rect |= _ar;
return rect;
}

View File

@ -88,7 +88,7 @@ public:
void clearMapCache();
void fitContentToSize();
RectC boundingRect() const {return _tr | _rr | _wr | _ar;}
RectC boundingRect() const;
public slots:
void showMap(bool show);

View File

@ -559,6 +559,7 @@ QWidget *OptionsDialog::createDEMPage()
InfoLabel *info = new InfoLabel(
tr("Use $lat and $lon for NYY/SYY and EXXX/WXXX in the URL."));
info->setMinimumWidth(_demURL->minimumWidth());
#ifdef Q_OS_MAC
QFormLayout *sourceLayout = new QFormLayout();