Commit 392e6d1f authored by Benjamin Jakimow's avatar Benjamin Jakimow

added onClose routines to EOTimeSeriesViewer and MapWidget

Signed-off-by: Benjamin Jakimow's avatarBenjamin Jakimow benjamin.jakimow@geo.hu-berlin.de <benjamin.jakimow@geo.hu-berlin.de>
parent 404c3a1d
......@@ -475,7 +475,7 @@ class EOTimeSeriesViewer(QgisInterface, QObject):
assert isinstance(mw, MapWidget)
assert isinstance(tswidget, TimeSeriesWidget)
self.ui.sigAboutToBeClosed.connect(self.onClosing)
self.ui.sigAboutToBeClosed.connect(self.onClose)
import qgis.utils
assert isinstance(qgis.utils.iface, QgisInterface)
......@@ -670,13 +670,10 @@ class EOTimeSeriesViewer(QgisInterface, QObject):
if eotsvSettings.value(SettingKeys.StartupRestoreProjectSettings, False):
self.onReloadProject()
def onClosing(self):
def onClose(self):
debugLog(f'Close EOTSV')
EOTimeSeriesViewer._instance = None
while len(self.mapViews()) > 0:
mv = self.mapViews()[0]
debugLog(f'Remove map view {mv}')
self.mapWidget().removeMapView()
self.mapWidget().onClose()
def onWriteProject(self, dom: QDomDocument):
......
......@@ -62,7 +62,7 @@ from .externals.qps.maptools import MapTools
from .mapcanvas import MapCanvas, MapCanvasInfoItem, KEY_LAST_CLICKED
from .timeseries import SensorInstrument, TimeSeriesDate, TimeSeries, SensorProxyLayer
from .utils import loadUi, SpatialPoint, SpatialExtent, datetime64
from eotimeseriesviewer import DIR_UI
from eotimeseriesviewer import DIR_UI, debugLog
from eotimeseriesviewer.utils import fixMenuButtons
KEY_LOCKED_LAYER = 'eotsv/locked'
......@@ -1275,9 +1275,12 @@ class MapWidget(QFrame):
return self.mMessageBar
def refresh(self):
debugLog()
for c in self.mapCanvases():
b = c.blockSignals(True)
assert isinstance(c, MapCanvas)
c.timedRefresh()
c.blockSignals(b)
def setMapTextFormat(self, textFormat: QgsTextFormat) -> QgsTextFormat:
......@@ -1347,6 +1350,7 @@ class MapWidget(QFrame):
if isinstance(ext, SpatialExtent) and ext != self.spatialExtent():
self.mSpatialExtent = ext
debugLog(f'new extent: {self.mSpatialExtent}')
for c in self.mapCanvases():
assert isinstance(c, MapCanvas)
c.addToRefreshPipeLine(self.mSpatialExtent)
......@@ -1366,6 +1370,7 @@ class MapWidget(QFrame):
if centerNew != centerOld and isinstance(centerNew, SpatialPoint):
extent = extent.__copy__()
extent.setCenter(centerNew)
debugLog()
self.setSpatialExtent(extent)
def spatialCenter(self) -> SpatialPoint:
......@@ -1404,12 +1409,14 @@ class MapWidget(QFrame):
for c in self.mapCanvases():
assert isinstance(c, MapCanvas)
b = c.blockSignals(True)
c.timedRefresh()
c.blockSignals(b)
for mapView in self.mapViews():
# test for initial raster stretches
for sensor in self.timeSeries().sensors():
if mapView.mLayerStyleInitialized.get(sensor, False) == False:
if not mapView.mLayerStyleInitialized.get(sensor, False):
for c in self.mapViewCanvases(mapView):
# find the first map canvas that contains layer data of this sensor
# in its extent
......@@ -1497,6 +1504,7 @@ class MapWidget(QFrame):
def readXml(self, node: QDomNode):
from .settings import setValue, Keys
debugLog()
if not node.nodeName() == 'MapWidget':
node = node.firstChildElement('MapWidget')
if node.isNull():
......@@ -2043,6 +2051,20 @@ class MapWidget(QFrame):
# mapCanvas.mapTools().mtCursorLocation.sigLocationRequest.disconnect(
# self.sigCurrentLocationChanged)
def onClose(self):
"""
Removes all remaining mapviews and canvases etc.
"""
for c in self.mapCanvases():
c.blockSignals(True)
while len(self.mapViews()) > 0:
mapView: MapView = self.mapViews()[0]
debugLog(f'Remove map view {mapView}')
self.mMapViews.remove(mapView)
mapView.setMapWidget(None)
def onCanvasLocationRequest(self, canvas: QgsMapCanvas, crs: QgsCoordinateReferenceSystem, pt: QgsPointXY):
self.sigCurrentLocationChanged[QgsCoordinateReferenceSystem, QgsPointXY].emit(crs, pt)
self.sigCurrentLocationChanged[QgsCoordinateReferenceSystem, QgsPointXY, QgsMapCanvas].emit(crs, pt, canvas)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment