Commit 66dd9cc4 authored by Benjamin Jakimow's avatar Benjamin Jakimow

ui fixed

MapCanvas info text rendered with antialising
Signed-off-by: Benjamin Jakimow's avatarBenjamin Jakimow benjamin.jakimow@geo.hu-berlin.de <benjamin.jakimow@geo.hu-berlin.de>
parent 4937197c
......@@ -170,12 +170,12 @@ class EOTimeSeriesViewerUI(QMainWindow):
# self.dockAdvancedDigitizingDockWidget.setVisible(False)
area = Qt.BottomDockWidgetArea
#panel = SpectralLibraryPanel(self)
# panel = SpectralLibraryPanel(self)
#self.dockSpectralLibrary = self.addDockWidget(area, panel)
# self.dockSpectralLibrary = self.addDockWidget(area, panel)
#self.tabifyDockWidget(self.dockTimeSeries, self.dockSpectralLibrary)
#self.tabifyDockWidget(self.dockTimeSeries, self.dockProfiles)
# self.tabifyDockWidget(self.dockTimeSeries, self.dockSpectralLibrary)
# self.tabifyDockWidget(self.dockTimeSeries, self.dockProfiles)
# self.tabifyDockWidget(self.dockTimeSeries, self.dockLabeling)
area = Qt.RightDockWidgetArea
......@@ -483,7 +483,7 @@ class EOTimeSeriesViewer(QgisInterface, QObject):
QgsProject.instance().layersWillBeRemoved.connect(self.onLayersWillBeRemoved)
QgsApplication.instance().messageLog().messageReceived.connect(self.logMessage)
#self.mapLayerStore().addMapLayer(self.ui.dockSpectralLibrary.speclib())
# self.mapLayerStore().addMapLayer(self.ui.dockSpectralLibrary.speclib())
self.mPostDataLoadingArgs: dict = dict()
......@@ -600,7 +600,7 @@ class EOTimeSeriesViewer(QgisInterface, QObject):
# set default map tool
self.ui.actionPan.toggle()
self.ui.dockCursorLocation.sigLocationRequest.connect(self.ui.actionIdentifyCursorLocationValues.trigger)
#self.ui.dockCursorLocation.mLocationInfoModel.setNodeExpansion(CursorLocationInfoModel.ALWAYS_EXPAND)
# self.ui.dockCursorLocation.mLocationInfoModel.setNodeExpansion(CursorLocationInfoModel.ALWAYS_EXPAND)
self.ui.actionAddMapView.triggered.connect(mvd.createMapView)
self.ui.actionAddTSD.triggered.connect(lambda: self.addTimeSeriesImages(None))
self.ui.actionAddVectorData.triggered.connect(lambda: self.addVectorData())
......@@ -612,7 +612,8 @@ class EOTimeSeriesViewer(QgisInterface, QObject):
lambda: self.openAddSubdatasetsDialog(
title='Open Sentinel-2 Datasets', filter='MTD_MSIL*.xml'))
self.ui.actionRemoveTSD.triggered.connect(lambda: self.mTimeSeries.removeTSDs(tswidget.selectedTimeSeriesDates()))
self.ui.actionRemoveTSD.triggered.connect(
lambda: self.mTimeSeries.removeTSDs(tswidget.selectedTimeSeriesDates()))
self.ui.actionRefresh.triggered.connect(mw.refresh)
self.ui.actionLoadTS.triggered.connect(self.loadTimeSeriesDefinition)
self.ui.actionClearTS.triggered.connect(self.clearTimeSeries)
......@@ -631,7 +632,6 @@ class EOTimeSeriesViewer(QgisInterface, QObject):
self.profileDock.actionLoadProfileRequest.triggered.connect(self.activateIdentifyTemporalProfileMapTool)
# connect buttons with actions
self.ui.actionAbout.triggered.connect(lambda: AboutDialogUI(self.ui).exec_())
......@@ -640,15 +640,13 @@ class EOTimeSeriesViewer(QgisInterface, QObject):
from eotimeseriesviewer import DOCUMENTATION, SpectralLibrary, SpectralLibraryPanel, SpectralLibraryWidget
self.ui.actionShowOnlineHelp.triggered.connect(lambda: webbrowser.open(DOCUMENTATION))
#SLW: SpectralLibraryWidget = self.ui.dockSpectralLibrary.spectralLibraryWidget()
#assert isinstance(SLW, SpectralLibraryWidget)
#SLW.setVectorLayerTools(self.mVectorLayerTools)
# SLW: SpectralLibraryWidget = self.ui.dockSpectralLibrary.spectralLibraryWidget()
# assert isinstance(SLW, SpectralLibraryWidget)
# SLW.setVectorLayerTools(self.mVectorLayerTools)
# add time-specific fields
#sl = self.spectralLibrary()
# sl = self.spectralLibrary()
#self.mMapLayerStore.addMapLayer(sl)
# self.mMapLayerStore.addMapLayer(sl)
temporalProfileLayer = self.profileDock.temporalProfileLayer()
assert isinstance(temporalProfileLayer, QgsVectorLayer)
......@@ -727,7 +725,6 @@ class EOTimeSeriesViewer(QgisInterface, QObject):
for d in to_remove:
self.ui.removeDockWidget(d)
def onReadProject(self, doc: QDomDocument) -> bool:
"""
Reads images and visualization settings from a QgsProject QDomDocument
......@@ -741,9 +738,11 @@ class EOTimeSeriesViewer(QgisInterface, QObject):
node = root.firstChildElement('EOTSV')
if node.nodeName() == 'EOTSV':
self.timeSeries().clear()
mapviews = self.mapViews()
for mv in mapviews:
self.mapWidget().removeMapView(mv)
self.mapWidget().readXml(node)
mwNode = node.firstChildElement('MapWidget')
......@@ -769,7 +768,6 @@ class EOTimeSeriesViewer(QgisInterface, QObject):
self.timeSeries().sigLoadingTaskFinished.disconnect(self.onPostDataLoading)
def lockCentralWidgetSize(self, b: bool):
"""
Locks or release the current central widget size
......@@ -899,7 +897,6 @@ class EOTimeSeriesViewer(QgisInterface, QObject):
if len(self.mapViews()) == 1:
mapView.setMapInfoExpression("@map_date + '\n' + @map_sensor")
def temporalProfileLayer(self) -> TemporalProfileLayer:
"""
Returns the TemporalProfileLayer
......@@ -1008,7 +1005,7 @@ class EOTimeSeriesViewer(QgisInterface, QObject):
if date:
self.setCurrentDate(date)
def setCurrentDate(self, tsd: TimeSeriesDate, show_if_hidden: bool =True) :
def setCurrentDate(self, tsd: TimeSeriesDate, show_if_hidden: bool = True):
"""
Moves the viewport of the scroll window to a specific TimeSeriesDate
:param tsd: TimeSeriesDate or numpy.datetime64
......@@ -1188,7 +1185,7 @@ class EOTimeSeriesViewer(QgisInterface, QObject):
self.ui.mMapWidget.setMapTool(mapToolKey, *args)
kwds = {}
def setMapsPerMapView(self, cols: int, rows:int):
def setMapsPerMapView(self, cols: int, rows: int):
"""
Sets the number of map canvases that is shown per map view
:param n: int
......@@ -1289,7 +1286,6 @@ class EOTimeSeriesViewer(QgisInterface, QObject):
sensorLayers = [l for l in mapCanvas.layers() if isinstance(l, SensorProxyLayer)]
currentSpectra = []
for lyr in sensorLayers:
assert isinstance(lyr, SensorProxyLayer)
p = SpectralProfile.fromRasterLayer(lyr, spatialPoint)
......@@ -1637,7 +1633,7 @@ class EOTimeSeriesViewer(QgisInterface, QObject):
for d in vectorLayerDocks:
if isinstance(d, LabelDockWidget) and d.vectorLayer().id() == lyr.id() or \
isinstance(d, SpectralLibraryDockWidget) and d.speclib().id() == lyr.id():
isinstance(d, SpectralLibraryDockWidget) and d.speclib().id() == lyr.id():
d.show()
d.activateWindow()
d.raise_()
......@@ -1651,7 +1647,7 @@ class EOTimeSeriesViewer(QgisInterface, QObject):
dock.setVectorLayerTools(self.vectorLayerTools())
dock.SLW.actionSelectProfilesFromMap.setVisible(True)
dock.SLW.sigLoadFromMapRequest.connect(lambda *args: self.setMapTool(MapTools.SpectralProfile))
#dock.SLW.actionSelectProfilesFromMap.triggered.connect(self.activateIdentifySpectralProfileMapTool)
# dock.SLW.actionSelectProfilesFromMap.triggered.connect(self.activateIdentifySpectralProfileMapTool)
else:
dock = LabelDockWidget(lyr)
dock.mLabelWidget.sigMoveTo[QDateTime].connect(self.setCurrentDate)
......@@ -1665,7 +1661,6 @@ class EOTimeSeriesViewer(QgisInterface, QObject):
dock.activateWindow()
QTimer.singleShot(10, lambda d=dock: d.raise_())
def clearLayoutWidgets(self, L):
if L is not None:
while L.count():
......
......@@ -212,6 +212,7 @@ class MapCanvasInfoItem(QgsMapCanvasItem):
context.setMapToPixel(m2p)
context.setScaleFactor(QgsApplication.desktop().logicalDpiX() / 25.4)
context.setUseAdvancedEffects(True)
context.setCustomRenderingFlag('Antialiasing', True)
context.setPainter(painter)
# context.setExtent(self.mCanvas.extent())
# context.setExpressionContext(self.mCanvas.mapSettings().expressionContext())
......
......@@ -1100,8 +1100,8 @@ class MapWidget(QFrame):
self.setContentsMargins(1, 1, 1, 1)
self.mGridFrame: QFrame
self.mGrid: QGridLayout = None
self.initEmptyGrid()
self.mGrid: QGridLayout
assert isinstance(self.mGrid, QGridLayout)
self.mSyncLock = False
self.mSyncQGISMapCanvasCenter: bool = False
......@@ -1165,14 +1165,20 @@ class MapWidget(QFrame):
self.mTimeSlider.valueChanged.connect(self.onSliderValueChanged)
self.mTimeSlider.sliderMoved.connect(self.onSliderMoved)
def initEmptyGrid(self):
if isinstance(self.mGrid, QGridLayout):
self.mGrid.setParent(None)
self.mGrid = QGridLayout()
self.mGrid.setSpacing(0)
self.mGrid.setContentsMargins(0, 0, 0, 0)
self.mGridFrame.setLayout(self.mGrid)
def clearCanvasGrid(self):
"""
Cleans the MapCanvas Grid
:return:
:rtype:
"""
assert isinstance(self.mGrid, QGridLayout)
while self.mGrid.count() > 0:
item = self.mGrid.takeAt(0)
widget = item.widget()
if isinstance(widget, QWidget):
if isinstance(widget, MapCanvas):
self._disconnectCanvasSignals(widget)
widget.setParent(None)
def messageBar(self) -> QgsMessageBar:
"""
......@@ -1841,8 +1847,8 @@ class MapWidget(QFrame):
self.mSyncLock = False
def _createMapCanvas(self) -> MapCanvas:
mapCanvas = MapCanvas(parent=self.mGridFrame)
def _createMapCanvas(self, parent=None) -> MapCanvas:
mapCanvas = MapCanvas(parent=parent)
mapCanvas.setMapLayerStore(self.mMapLayerStore)
mapCanvas.mInfoItem.setTextFormat(self.mapTextFormat())
......@@ -1912,6 +1918,34 @@ class MapWidget(QFrame):
return self.mCrosshairPosition
def _updateGrid(self):
self.mMapRefreshTimer.stop()
for canvas in self.mGrid.findChildren(MapCanvas):
self._disconnectCanvasSignals(canvas)
self.clearCanvasGrid()
nc = self.mMapViewColumns
nr = len(self.mapViews()) * self.mMapViewRows
for iMV, mv in enumerate(self.mMapViews):
assert isinstance(mv, MapView)
self.mCanvases[mv] = []
for row in range(self.mMapViewRows):
for col in range(self.mMapViewColumns):
gridrow = (iMV * self.mMapViewRows) + row
gridcol = col
c: MapCanvas = self._createMapCanvas()
assert isinstance(c, MapCanvas)
# c.setFixedSize(self.mMapSize)
c.setTSD(None)
c.setMapView(mv)
self.mGrid.addWidget(c, gridrow, gridcol)
self.mCanvases[mv].append(c)
self._updateCanvasDates()
self.mMapRefreshTimer.start()
def _BAK_updateGrid(self):
import time
t0 = time.time()
self.mMapRefreshTimer.stop()
......@@ -1937,49 +1971,54 @@ class MapWidget(QFrame):
self.mGrid.removeWidget(w)
w.setParent(None)
w.setVisible(False)
# self.initEmptyGrid()
usedCanvases: typing.List[MapCanvas] = []
self.mCanvases.clear()
if self.mViewMode == MapWidget.ViewMode.MapViewByRows:
for iMV, mv in enumerate(self.mMapViews):
assert isinstance(mv, MapView)
reminder = self.mCanvases.get(mv, [])
self.mCanvases[mv] = []
for row in range(self.mMapViewRows):
for col in range(self.mMapViewColumns):
gridrow = (iMV * self.mMapViewRows) + row
gridcol = col
item = self.mGrid.itemAtPosition(gridrow, gridcol)
if isinstance(item, QLayoutItem) and isinstance(item.widget(), MapCanvas):
c = item.widget()
s = ""
else:
c = self._createMapCanvas()
self.mGrid.addWidget(c, gridrow, gridcol)
assert isinstance(c, MapCanvas)
# c.setFixedSize(self.mMapSize)
c.setTSD(None)
c.setMapView(mv)
usedCanvases.append(c)
self.mCanvases[mv].append(c)
s = ""
else:
raise NotImplementedError()
# self.initEmptyGrid()
usedCanvases: typing.List[MapCanvas] = []
self.mCanvases.clear()
if self.mViewMode == MapWidget.ViewMode.MapViewByRows:
for iMV, mv in enumerate(self.mMapViews):
assert isinstance(mv, MapView)
reminder = self.mCanvases.get(mv, [])
self.mCanvases[mv] = []
for row in range(self.mMapViewRows):
for col in range(self.mMapViewColumns):
gridrow = (iMV * self.mMapViewRows) + row
gridcol = col
item = self.mGrid.itemAtPosition(gridrow, gridcol)
if isinstance(item, QLayoutItem) and isinstance(item.widget(), MapCanvas):
c = item.widget()
s = ""
else:
if not (item is None):
s =""
c = self._createMapCanvas()
self.mGrid.addWidget(c, gridrow, gridcol)
assert isinstance(c, MapCanvas)
# c.setFixedSize(self.mMapSize)
c.setTSD(None)
c.setMapView(mv)
usedCanvases.append(c)
self.mCanvases[mv].append(c)
s = ""
else:
raise NotImplementedError()
t1 = time.time()
self._updateCanvasDates()
t2 = time.time()
self._updateWidgetSize()
t3 = time.time()
#t1 = time.time()
self._updateCanvasDates()
#t2 = time.time()
self._updateWidgetSize()
#t3 = time.time()
s = ""
# remove old canvases
for c in oldCanvases:
if c not in usedCanvases:
try:
c.setParent(None)
s = ""
self._disconnectCanvasSignals(c)
c.setParent(None)
except:
pass
......@@ -1988,7 +2027,7 @@ class MapWidget(QFrame):
def _updateWidgetSize(self):
self.mGrid.update()
# self.mGrid.update()
# self.resize(self.sizeHint())
# self.setMaximumSize(self.sizeHint())
# self.setFixedSize(self.sizeHint())
......
......@@ -6,8 +6,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>602</width>
<height>454</height>
<width>515</width>
<height>314</height>
</rect>
</property>
<property name="windowTitle">
......@@ -43,33 +43,111 @@
</widget>
</item>
<item>
<widget class="QFrame" name="mGridFrame">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<horstretch>2</horstretch>
<verstretch>2</verstretch>
</sizepolicy>
<layout class="QGridLayout" name="gridCenterLayout">
<property name="leftMargin">
<number>0</number>
</property>
<property name="frameShape">
<enum>QFrame::StyledPanel</enum>
</property>
<property name="frameShadow">
<enum>QFrame::Raised</enum>
<property name="topMargin">
<number>0</number>
</property>
</widget>
</item>
<item>
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
<property name="rightMargin">
<number>0</number>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>0</height>
</size>
<property name="spacing">
<number>1</number>
</property>
</spacer>
<item row="0" column="1">
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>0</height>
</size>
</property>
</spacer>
</item>
<item row="1" column="1">
<widget class="QFrame" name="mGridFrame">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>100</width>
<height>100</height>
</size>
</property>
<property name="frameShape">
<enum>QFrame::StyledPanel</enum>
</property>
<property name="frameShadow">
<enum>QFrame::Raised</enum>
</property>
<layout class="QGridLayout" name="mGrid">
<property name="leftMargin">
<number>0</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
<property name="spacing">
<number>1</number>
</property>
</layout>
</widget>
</item>
<item row="1" column="2">
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>0</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item row="1" column="0">
<spacer name="horizontalSpacer_2">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>0</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item row="2" column="1">
<spacer name="verticalSpacer_2">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>0</height>
</size>
</property>
</spacer>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout" stretch="0,0,0,0,0,0,0,0">
......
......@@ -66,8 +66,8 @@ class TestMain(EOTSVTestCase):
# save and read settings
path = self.createTestOutputDirectory() / 'test.qgz'
QgsProject.instance().write(path.as_posix())
self.assertTrue(QgsProject.instance().read(path.as_posix()))
TSV.onReloadProject()
#self.assertTrue(QgsProject.instance().read(path.as_posix()))
#TSV.onReloadProject()
self.showGui([TSV.ui])
......@@ -97,7 +97,7 @@ class TestMain(EOTSVTestCase):
TSV = EOTimeSeriesViewer()
paths = TestObjects.createMultiSourceTimeSeries()
TSV.addTimeSeriesImages(paths)
TSV.addTimeSeriesImages(paths, loadAsync=True)
self.showGui(TSV.ui)
......
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