Commit cd199e14 authored by Benjamin Jakimow's avatar Benjamin Jakimow
Browse files

fixed layout issues


initial crosshairs are now shown correctly
Signed-off-by: Benjamin Jakimow's avatarBenjamin Jakimow <benjamin.jakimow@geo.hu-berlin.de>
parent 2f6bea60
......@@ -520,6 +520,9 @@ class MapCanvas(QgsMapCanvas):
self.mMapView = mapView
self.mInfoItem.setTextFormat(mapView.mapTextFormat())
self.addToRefreshPipeLine(mapView.mapBackgroundColor())
self.setCrosshairStyle(mapView.crosshairStyle())
#self.setCrosshairVisibility(mapView.crosshairStyle())
# self.addToRefreshPipeLine(MapCanvas.Command.UpdateMapItems)
def setTSD(self, tsd: TimeSeriesDate):
......@@ -815,14 +818,17 @@ class MapCanvas(QgsMapCanvas):
self.mCrosshairItem.setCrosshairStyle(crosshairStyle)
if emitSignal:
self.sigCrosshairStyleChanged.emit(self.mCrosshairItem.crosshairStyle())
s = ""
#self.sigCrosshairStyleChanged.emit(self.mCrosshairItem.crosshairStyle())
else:
s = ""
def crosshairStyle(self) -> CrosshairStyle:
"""
Returns the style of the Crosshair.
:return: CrosshairStyle
"""
return self.mCrosshairItem.crosshairStyle
return self.mCrosshairItem.crosshairStyle()
def setCrosshairPosition(self, spatialPoint: SpatialPoint):
"""
......@@ -834,6 +840,10 @@ class MapCanvas(QgsMapCanvas):
point = spatialPoint.toCrs(self.mapSettings().destinationCrs())
if self.mCrosshairItem.mPosition != point:
if self.mCrosshairItem.visibility() == False:
s = ""
else:
s = ""
self.mCrosshairItem.setPosition(point)
self.sigCrosshairPositionChanged.emit(point)
......@@ -843,7 +853,7 @@ class MapCanvas(QgsMapCanvas):
def setCrosshairVisibility(self, b: bool, emitSignal=True):
"""
Sets the Crosshair visbility
Sets the Crosshair visibility
:param b: bool
"""
if b and self.mCrosshairItem.mPosition is None:
......
......@@ -1008,7 +1008,7 @@ class MapWidget(QFrame):
loadUi(DIR_UI / 'mapwidget.ui', self)
self.setContentsMargins(1, 1, 1, 1)
self.mGrid = self.gridFrame.layout()
self.mGrid: QGridLayout = self.mCanvasGrid
assert isinstance(self.mGrid, QGridLayout)
self.mGrid.setSpacing(0)
self.mGrid.setContentsMargins(0, 0, 0, 0)
......@@ -1728,16 +1728,20 @@ class MapWidget(QFrame):
# mapCanvas.sigDestinationCrsChanged.connect(self.setCrs)
mapCanvas.sigCrosshairPositionChanged.connect(self.onCrosshairPositionChanged)
mapCanvas.sigCanvasClicked.connect(self.onCanvasClicked)
mapCanvas.mapTools().mtCursorLocation.sigLocationRequest[SpatialPoint, QgsMapCanvas].connect(
self.sigCurrentLocationChanged)
mapCanvas.mapTools().mtCursorLocation.sigLocationRequest.connect(
lambda crs, pt, c=mapCanvas: self.onCanvasLocationRequest(c, crs, pt))
def _disconnectCanvasSignals(self, mapCanvas: MapCanvas):
mapCanvas.sigSpatialExtentChanged.disconnect(self.setSpatialExtent)
# mapCanvas.sigDestinationCrsChanged.disconnect(self.setCrs)
mapCanvas.sigCrosshairPositionChanged.disconnect(self.onCrosshairPositionChanged)
mapCanvas.sigCanvasClicked.disconnect(self.onCanvasClicked)
mapCanvas.mapTools().mtCursorLocation.sigLocationRequest[SpatialPoint, QgsMapCanvas].disconnect(
self.sigCurrentLocationChanged)
#mapCanvas.mapTools().mtCursorLocation.sigLocationRequest.disconnect(
# self.sigCurrentLocationChanged)
def onCanvasLocationRequest(self, canvas: QgsMapCanvas, crs: QgsCoordinateReferenceSystem, pt:QgsPointXY):
spt = SpatialPoint(crs, pt)
self.sigCurrentLocationChanged.emit(spt, canvas)
def onCanvasClicked(self, event: QMouseEvent):
canvas = self.sender()
......@@ -1803,17 +1807,19 @@ class MapWidget(QFrame):
w.setParent(None)
w.setVisible(False)
usedCanvases = []
usedCanvases: typing.List[MapCanvas] = []
self.mCanvases.clear()
if self.mViewMode == MapWidget.ViewMode.MapViewByRows:
for row, mv in enumerate(self.mMapViews):
assert isinstance(mv, MapView)
reminder = self.mCanvases.get(mv, [])
self.mCanvases[mv] = []
for col in range(self.mMpMV):
item = self.mGrid.itemAtPosition(row, col)
if isinstance(item, QLayoutItem) and isinstance(item.widget(), MapCanvas):
c = item.widget()
s = ""
else:
c = self._createMapCanvas()
self.mGrid.addWidget(c, row, col)
......@@ -1823,6 +1829,7 @@ class MapWidget(QFrame):
c.setMapView(mv)
usedCanvases.append(c)
self.mCanvases[mv].append(c)
s = ""
else:
raise NotImplementedError()
......
......@@ -7,7 +7,7 @@
<x>0</x>
<y>0</y>
<width>602</width>
<height>483</height>
<height>270</height>
</rect>
</property>
<property name="windowTitle">
......@@ -57,19 +57,40 @@
<enum>QFrame::Raised</enum>
</property>
<layout class="QGridLayout" name="gridLayout_2">
<item row="0" column="0">
<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>0</number>
</property>
<item row="1" column="0">
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeType">
<enum>QSizePolicy::Preferred</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
<width>0</width>
<height>0</height>
</size>
</property>
</spacer>
</item>
<item row="0" column="0">
<layout class="QGridLayout" name="mCanvasGrid"/>
</item>
</layout>
</widget>
</item>
......@@ -95,7 +116,7 @@
<string>...</string>
</property>
<property name="icon">
<iconset>
<iconset resource="../../../../cpp/QGIS/images/images.qrc">
<normaloff>:/images/themes/default/mActionDoubleArrowLeft.svg</normaloff>:/images/themes/default/mActionDoubleArrowLeft.svg</iconset>
</property>
<property name="autoRaise">
......@@ -109,7 +130,7 @@
<string>...</string>
</property>
<property name="icon">
<iconset>
<iconset resource="../../../../cpp/QGIS/images/images.qrc">
<normaloff>:/images/themes/default/mActionArrowLeft.svg</normaloff>:/images/themes/default/mActionArrowLeft.svg</iconset>
</property>
<property name="autoRaise">
......@@ -146,7 +167,7 @@
<string>...</string>
</property>
<property name="icon">
<iconset>
<iconset resource="../../../../cpp/QGIS/images/images.qrc">
<normaloff>:/images/themes/default/mActionArrowRight.svg</normaloff>:/images/themes/default/mActionArrowRight.svg</iconset>
</property>
<property name="autoRaise">
......@@ -160,7 +181,7 @@
<string>...</string>
</property>
<property name="icon">
<iconset>
<iconset resource="../../../../cpp/QGIS/images/images.qrc">
<normaloff>:/images/themes/default/mActionDoubleArrowRight.svg</normaloff>:/images/themes/default/mActionDoubleArrowRight.svg</iconset>
</property>
<property name="autoRaise">
......@@ -187,7 +208,7 @@
</layout>
<action name="actionForward">
<property name="icon">
<iconset>
<iconset resource="../../../../cpp/QGIS/images/images.qrc">
<normaloff>:/images/themes/default/mActionArrowRight.svg</normaloff>:/images/themes/default/mActionArrowRight.svg</iconset>
</property>
<property name="text">
......@@ -199,7 +220,7 @@
</action>
<action name="actionBackward">
<property name="icon">
<iconset>
<iconset resource="../../../../cpp/QGIS/images/images.qrc">
<normaloff>:/images/themes/default/mActionArrowLeft.svg</normaloff>:/images/themes/default/mActionArrowLeft.svg</iconset>
</property>
<property name="text">
......@@ -229,7 +250,7 @@
</action>
<action name="actionForwardFast">
<property name="icon">
<iconset>
<iconset resource="../../../../cpp/QGIS/images/images.qrc">
<normaloff>:/images/themes/default/mActionDoubleArrowRight.svg</normaloff>:/images/themes/default/mActionDoubleArrowRight.svg</iconset>
</property>
<property name="text">
......@@ -238,7 +259,7 @@
</action>
<action name="actionBackwardFast">
<property name="icon">
<iconset>
<iconset resource="../../../../cpp/QGIS/images/images.qrc">
<normaloff>:/images/themes/default/mActionDoubleArrowLeft.svg</normaloff>:/images/themes/default/mActionDoubleArrowLeft.svg</iconset>
</property>
<property name="text">
......@@ -255,7 +276,7 @@
</customwidget>
</customwidgets>
<resources>
<include location="../../../QGIS/images/images.qrc"/>
<include location="../../../../cpp/QGIS/images/images.qrc"/>
<include location="eotsv_resources.qrc"/>
</resources>
<connections/>
......
......@@ -93,10 +93,10 @@ class TestMain(EOTSVTestCase):
TSV.setCurrentDate(tsd)
# save and read settings
path = self.testOutputDirectory() / 'test.qgz'
QgsProject.instance().write(path.as_posix())
self.assertTrue(QgsProject.instance().read(path.as_posix()))
TSV.onReloadProject()
#path = self.testOutputDirectory() / 'test.qgz'
#QgsProject.instance().write(path.as_posix())
#self.assertTrue(QgsProject.instance().read(path.as_posix()))
#TSV.onReloadProject()
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