Newer
Older
mapCanvas.setCenter(center)
mapCanvas.blockSignals(oldState)
self.mBlockCanvasSignals = False
self.sigSpatialExtentChanged.emit(self.mSpatialExtent)
def setSpatialExtent(self, extent, mapCanvas0=None):
if self.mBlockCanvasSignals:
return True
assert isinstance(extent, SpatialExtent)
extent = extent.toCrs(self.mCRS)
if not isinstance(extent, SpatialExtent) \
or extent.isEmpty() or not extent.isFinite() \
or extent.width() <= 0 \
or extent.height() <= 0 \
or extent == self.mSpatialExtent:
self.mBlockCanvasSignals = True
self.mSpatialExtent = extent
for mapCanvas in self.mMapCanvases:
if mapCanvas != mapCanvas0:
oldState = mapCanvas.blockSignals(True)
mapCanvas.setExtent(extent)
mapCanvas.blockSignals(oldState)
#for mapCanvas in self.mMapCanvases:
# mapCanvas.refresh()
self.sigSpatialExtentChanged.emit(extent)

benjamin.jakimow@geo.hu-berlin.de
committed
def setBackgroundColor(self, color):
assert isinstance(color, QColor)
self.mColor = color
def backgroundColor(self):
return self.mColor
def mapCanvasIterator(self):
return self.mMapCanvases[:]
def setCrs(self, crs):
assert isinstance(crs, QgsCoordinateReferenceSystem)
from timeseriesviewer.utils import saveTransform
if saveTransform(self.mSpatialExtent, self.mCRS, crs):
self.mCRS = crs
for mapCanvas in self.mapCanvasIterator():
#print(('STV set CRS {} {}', str(mapCanvas), self.mCRS.description()))
mapCanvas.setCrs(crs)
else:
pass
self.sigCRSChanged.emit(self.mCRS)

benjamin.jakimow@geo.hu-berlin.de
committed
def spatialExtent(self):
return self.mSpatialExtent

benjamin.jakimow@geo.hu-berlin.de
committed
def navigateToTSD(self, TSD):
assert isinstance(TSD, TimeSeriesDatum)
#get widget related to TSD

benjamin.jakimow@geo.hu-berlin.de
committed
assert isinstance(self.scrollArea, QScrollArea)
self.scrollArea.ensureWidgetVisible(tsdv.ui)

benjamin.jakimow@geo.hu-berlin.de
committed
def setMapViewVisibility(self, bandView, isVisible):
assert isinstance(bandView, MapView)
assert isinstance(isVisible, bool)
for tsdv in self.TSDViews:
tsdv.setMapViewVisibility(bandView, isVisible)

benjamin.jakimow@geo.hu-berlin.de
committed
sigResizeRequired = pyqtSignal()
sigLoadingStarted = pyqtSignal(MapView, TimeSeriesDatum)
sigLoadingFinished = pyqtSignal(MapView, TimeSeriesDatum)

benjamin.jakimow@geo.hu-berlin.de
committed
sigShowProfiles = pyqtSignal(SpatialPoint)
sigSpatialExtentChanged = pyqtSignal(SpatialExtent)

benjamin.jakimow@geo.hu-berlin.de
committed
def __init__(self, STViz):
assert isinstance(STViz, SpatialTemporalVisualization)
super(DateViewCollection, self).__init__()

benjamin.jakimow@geo.hu-berlin.de
committed
#self.tsv = tsv
#self.timeSeries = tsv.TS
self.views = list()
self.STV = STViz
self.ui = self.STV.targetLayout.parentWidget()

benjamin.jakimow@geo.hu-berlin.de
committed
self.scrollArea = self.ui.parentWidget().parentWidget()
#potentially there are many more dates than views.
#therefore we implement the addinng/removing of mapviews here
#we reduce the number of layout refresh calls by
#suspending signals, adding the new map view canvases, and sending sigResizeRequired
self.STV.MVC.sigMapViewAdded.connect(self.addMapView)
self.STV.MVC.sigMapViewRemoved.connect(self.removeMapView)

benjamin.jakimow@geo.hu-berlin.de
committed
self.setFocusView(None)

benjamin.jakimow@geo.hu-berlin.de
committed
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
def tsdView(self, tsd):
r = [v for v in self.views if v.TSD == tsd]
if len(r) == 1:
return r[0]
else:
raise Exception('TSD not in list')
def addMapView(self, mapView):
assert isinstance(mapView, MapView)
w = self.ui
w.setUpdatesEnabled(False)
for tsdv in self.views:
tsdv.ui.setUpdatesEnabled(False)
for tsdv in self.views:
tsdv.insertMapView(mapView)
for tsdv in self.views:
tsdv.ui.setUpdatesEnabled(True)
#mapView.sigSensorRendererChanged.connect(lambda *args : self.setRasterRenderer(mapView, *args))
w.setUpdatesEnabled(True)
self.sigResizeRequired.emit()
def removeMapView(self, mapView):
assert isinstance(mapView, MapView)
for tsdv in self.views:
tsdv.removeMapView(mapView)
self.sigResizeRequired.emit()
def setFocusView(self, tsd):
self.focusView = tsd
def orderedViews(self):
#returns the
if self.focusView is not None:
assert isinstance(self.focusView, DatumView)

benjamin.jakimow@geo.hu-berlin.de
committed
return sorted(self.views,key=lambda v: np.abs(v.TSD.date - self.focusView.TSD.date))
else:
return self.views

benjamin.jakimow@geo.hu-berlin.de
committed
def setSubsetSize(self, size):
assert isinstance(size, QSize)
self.subsetSize = size
for tsdView in self.orderedViews():
tsdView.blockSignals(True)
for tsdView in self.orderedViews():
tsdView.setSubsetSize(size)
for tsdView in self.orderedViews():
tsdView.blockSignals(False)

benjamin.jakimow@geo.hu-berlin.de
committed
def addDates(self, tsdList):
"""
Create a new TSDView
:param tsdList:
:return:
"""
for tsd in tsdList:
assert isinstance(tsd, TimeSeriesDatum)
#tsdView.setSubsetSize(self.subsetSize)
DV.sigLoadingStarted.connect(self.sigLoadingStarted.emit)
DV.sigLoadingFinished.connect(self.sigLoadingFinished.emit)
DV.sigVisibilityChanged.connect(lambda: self.STV.adjustScrollArea())

benjamin.jakimow@geo.hu-berlin.de
committed
for i, mapView in enumerate(self.STV.MVC):
DV.insertMapView(mapView)

benjamin.jakimow@geo.hu-berlin.de
committed
bisect.insort(self.views, DV)
i = self.views.index(DV)

benjamin.jakimow@geo.hu-berlin.de
committed
DV.ui.setParent(self.STV.targetLayout.parentWidget())
self.STV.targetLayout.insertWidget(i, DV.ui)
DV.ui.show()

benjamin.jakimow@geo.hu-berlin.de
committed
if len(tsdList) > 0:
self.sigResizeRequired.emit()
def removeDates(self, tsdList):
toRemove = [v for v in self.views if v.TSD in tsdList]
removedDates = []
for DV in toRemove:
self.views.remove(DV)

benjamin.jakimow@geo.hu-berlin.de
committed
for mapCanvas in DV.mapCanvases.values():
toRemove = mapCanvas.layers()
mapCanvas.setLayers([])
toRemove = [l for l in toRemove if isinstance(l, QgsRasterLayer)]
if len(toRemove) > 0:
QgsMapLayerRegistry.instance().removeMapLayers(toRemove)
DV.ui.parent().layout().removeWidget(DV.ui)
DV.ui.hide()
DV.ui.close()
removedDates.append(DV.TSD)
del DV

benjamin.jakimow@geo.hu-berlin.de
committed
if len(removedDates) > 0:
self.sigResizeRequired.emit()
def __len__(self):
return len(self.views)
def __iter__(self):
return iter(self.views)
def __getitem__(self, slice):
return self.views[slice]
def __delitem__(self, slice):
self.removeDates(self.views[slice])

benjamin.jakimow@geo.hu-berlin.de
committed
sigMapViewAdded = pyqtSignal(MapView)
sigMapViewRemoved = pyqtSignal(MapView)
sigSetMapViewVisibility = pyqtSignal(MapView, bool)

benjamin.jakimow@geo.hu-berlin.de
committed
sigShowProfiles = pyqtSignal(SpatialPoint)

benjamin.jakimow@geo.hu-berlin.de
committed
def __init__(self, spatialTemporalVisualization):
assert isinstance(spatialTemporalVisualization, SpatialTemporalVisualization)

benjamin.jakimow@geo.hu-berlin.de
committed
super(MapViewCollection, self).__init__()
self.STV = spatialTemporalVisualization
self.STV.dockMapViews.actionApplyStyles.triggered.connect(self.applyStyles)
self.STV.TS.sigSensorAdded.connect(self.addSensor)
self.STV.TS.sigSensorRemoved.connect(self.removeSensor)
self.ui = spatialTemporalVisualization.dockMapViews
self.uiV2 = spatialTemporalVisualization.dockMapViewsV2
self.btnList = spatialTemporalVisualization.dockMapViews.BVButtonList
self.scrollArea = spatialTemporalVisualization.dockMapViews.scrollAreaMapViews
self.scrollAreaContent = spatialTemporalVisualization.dockMapViews.scrollAreaMapsViewDockContent

benjamin.jakimow@geo.hu-berlin.de
committed
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
self.mapViewsDefinitions = []
self.mapViewButtons = dict()
self.adjustScrollArea()
def applyStyles(self):
for mapView in self.mapViewsDefinitions:
mapView.applyStyles()
def setCrosshairStyle(self, crosshairStyle):
for mapView in self.mapViewsDefinitions:
mapView.setCrosshairStyle(crosshairStyle)
def setShowCrosshair(self, b):
for mapView in self.mapViewsDefinitions:
mapView.setShowCrosshair(b)
def index(self, mapView):
assert isinstance(mapView, MapView)
return self.mapViewsDefinitions.index(mapView)
def adjustScrollArea(self):
#adjust scroll area widget to fit all visible widgets
l = self.scrollAreaContent.layout()
from timeseriesviewer.ui.widgets import maxWidgetSizes
newSize = maxWidgetSizes(l)
#print(newSize)
#newSize = self.scrollAreaContent.sizeHint()
self.scrollAreaContent.setFixedSize(newSize)
def setVectorLayer(self, lyr):
for mapView in self.mapViewsDefinitions:
assert isinstance(mapView, MapView)
mapView.setVectorLayer(lyr)
def addSensor(self, sensor):
for mapView in self.mapViewsDefinitions:
mapView.addSensor(sensor)
self.adjustScrollArea()
def removeSensor(self, sensor):
for mapView in self.mapViewsDefinitions:
mapView.removeSensor(sensor)
def createMapView(self):
btn = QToolButton(self.btnList)
self.btnList.layout().insertWidget(self.btnList.layout().count() - 1, btn)
mapView = MapView(self, parent=self.scrollArea)
mapView.sigRemoveMapView.connect(self.removeMapView)
mapView.sigShowProfiles.connect(self.sigShowProfiles.emit)

benjamin.jakimow@geo.hu-berlin.de
committed
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
mapView.addSensor(sensor)
self.mapViewButtons[mapView] = btn
self.mapViewsDefinitions.append(mapView)
btn.clicked.connect(lambda : self.showMapViewDefinition(mapView))
self.refreshMapViewTitles()
if len(self) == 1:
self.showMapViewDefinition(mapView)
self.sigMapViewAdded.emit(mapView)
self.adjustScrollArea()
def removeMapView(self, mapView):
assert isinstance(mapView, MapView)
btn = self.mapViewButtons[mapView]
idx = self.mapViewsDefinitions.index(mapView)
self.mapViewsDefinitions.remove(mapView)
self.mapViewButtons.pop(mapView)
mapView.ui.setVisible(False)
btn.setVisible(False)
self.btnList.layout().removeWidget(btn)
l = self.scrollAreaContent.layout()
for d in self.recentMapViewDefinitions():
d.ui.setVisible(False)
l.removeWidget(d.ui)
l.removeWidget(mapView.ui)
mapView.ui.close()
btn.close()
self.refreshMapViewTitles()
self.sigMapViewRemoved.emit(mapView)
if len(self) > 0:
#show previous mapViewDefinition
idxNext = max([idx-1, 0])
self.showMapViewDefinition(self.mapViewsDefinitions[idxNext])
def refreshMapViewTitles(self):
for i, mapView in enumerate(self.mapViewsDefinitions):
number = i+1
title = '#{}'.format(number)
mapView.setTitle(title)
btn = self.mapViewButtons[mapView]
btn.setText('{}'.format(number))
btn.setToolTip('Show definition for map view {}'.format(number))
btn.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Fixed)
def showMapViewDefinition(self, mapViewDefinition):
assert mapViewDefinition in self.mapViewsDefinitions
assert isinstance(mapViewDefinition, MapView)
l = self.scrollAreaContent.layout()
for d in self.recentMapViewDefinitions():
d.ui.setVisible(False)
l.removeWidget(d.ui)
l.insertWidget(l.count() - 1, mapViewDefinition.ui)
mapViewDefinition.ui.setVisible(True)
self.ui.setWindowTitle(self.ui.baseTitle + '|'+mapViewDefinition.title())
def recentMapViewDefinitions(self):
parent = self.scrollAreaContent
return [ui.mapViewDefinition() for ui in parent.findChildren(MapViewDefinitionUI)]
def setMapViewVisibility(self, bandView, isVisible):
assert isinstance(bandView, MapView)
assert isinstance(isVisible, bool)
def __len__(self):
return len(self.mapViewsDefinitions)
def __iter__(self):
return iter(self.mapViewsDefinitions)
def __getitem__(self, key):
return self.mapViewsDefinitions[key]
def __contains__(self, mapView):
return mapView in self.mapViewsDefinitions

benjamin.jakimow@geo.hu-berlin.de
committed
class MapViewDefinitionUI(QGroupBox, loadUi('mapviewdefinition.ui')):

benjamin.jakimow@geo.hu-berlin.de
committed
sigHideMapView = pyqtSignal()
sigShowMapView = pyqtSignal()
sigVectorVisibility = pyqtSignal(bool)
def __init__(self, mapViewDefinition,parent=None):
super(MapViewDefinitionUI, self).__init__(parent)
self.setupUi(self)
self.mMapViewDefinition = mapViewDefinition
self.btnRemoveMapView.setDefaultAction(self.actionRemoveMapView)
self.btnMapViewVisibility.setDefaultAction(self.actionToggleVisibility)
self.btnApplyStyles.setDefaultAction(self.actionApplyStyles)
self.btnVectorOverlayVisibility.setDefaultAction(self.actionToggleVectorVisibility)
self.btnShowCrosshair.setDefaultAction(self.actionShowCrosshair)
self.actionToggleVisibility.toggled.connect(lambda: self.setVisibility(not self.actionToggleVisibility.isChecked()))
self.actionToggleVectorVisibility.toggled.connect(lambda : self.sigVectorVisibility.emit(self.actionToggleVectorVisibility.isChecked()))
def DEPRsizeHint(self):

benjamin.jakimow@geo.hu-berlin.de
committed
#m = self.layout().contentsMargins()
#sl = maxWidgetSizes(self.sensorList)
#sm = self.buttonList.size()
#w = sl.width() + m.left()+ m.right() + sm.width()
#h = sl.height() + m.top() + m.bottom() + sm.height()
return maxWidgetSizes(self.sensorList.layout())

benjamin.jakimow@geo.hu-berlin.de
committed
def mapViewDefinition(self):
return self.mMapViewDefinition
def setVisibility(self, isVisible):
if isVisible != self.actionToggleVisibility.isChecked():
self.btnMapViewVisibility.setChecked(isVisible)
if isVisible:
self.sigShowMapView.emit()
else:
self.sigHideMapView.emit()
def visibility(self):
return self.actionToggleVisibility.isChecked()
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
"""
class MapViewListModel(QAbstractListModel):
"""
A model to keep a list of map views.
"""
sigMapViewsAdded = pyqtSignal(list)
sigMapViewsRemoved = pyqtSignal(list)
def __init__(self, parent=None):
super(MapViewListModel, self).__init__(parent)
self.mMapViewList = []
def addMapView(self, mapView):
i = len(self.mMapViewList)
self.insertMapView(i, mapView)
def insertMapView(self, i, mapView):
self.insertMapViews(i, [mapView])
def insertMapViews(self, i, mapViews):
assert isinstance(mapViews, list)
assert i >= 0 and i <= len(self.mMapViewList)
self.beginInsertRows(QModelIndex(), i, i + len(mapViews) - 1)
for j in range(len(mapViews)):
mapView = mapViews[j]
assert isinstance(mapView, MapView)
mapView.sigTitleChanged.connect(
lambda : self.doRefresh([mapView])
)
self.mMapViewList.insert(i + j, mapView)
self.endInsertRows()
self.sigMapViewsAdded.emit(mapViews)
def doRefresh(self, mapViews):
for mapView in mapViews:
idx = self.mapView2idx(mapView)
self.dataChanged.emit(idx, idx)
def removeMapView(self, mapView):
self.removeMapViews([mapView])
def removeMapViews(self, mapViews):
assert isinstance(mapViews, list)
for mv in mapViews:
assert mv in self.mMapViewList
idx = self.mapView2idx(mv)
self.beginRemoveRows(idx.parent(), idx.row(), idx.row())
self.mMapViewList.remove(mv)
self.endRemoveRows()
self.sigMapViewsRemoved.emit(mapViews)
def rowCount(self, parent=None, *args, **kwargs):
return len(self.mMapViewList)
def columnCount(self, QModelIndex_parent=None, *args, **kwargs):
return 1
def idx2MapView(self, index):
if isinstance(index, QModelIndex):
if index.isValid():
index = index.row()
else:
return None
assert index >= 0 and index < len(self.mMapViewList)
return self.mMapViewList[index]
def mapView2idx(self, mapView):
assert isinstance(mapView, MapView)
row = self.mMapViewList.index(mapView)
return self.createIndex(row, 0, mapView)
def __len__(self):
return len(self.mMapViewList)
def __iter__(self):
return iter(self.mMapViewList)
def data(self, index, role=Qt.DisplayRole):
if not index.isValid():
return None
if (index.row() >= len(self.mMapViewList)) or (index.row() < 0):
return None
mapView = self.idx2MapView(index)
assert isinstance(mapView, MapView)
value = None
if role == Qt.DisplayRole:
value = '{} {}'.format(index.row() +1 , mapView.title())
#if role == Qt.DecorationRole:
#value = classInfo.icon(QSize(20,20))
if role == Qt.UserRole:
value = mapView
return value

benjamin.jakimow@geo.hu-berlin.de
committed
class MapViewCollectionDock(QgsDockWidget, loadUi('mapviewdockV2.ui')):
sigMapViewAdded = pyqtSignal(MapView)
sigMapViewRemoved = pyqtSignal(MapView)
sigSetMapViewVisibility = pyqtSignal(MapView, bool)
sigShowProfiles = pyqtSignal(SpatialPoint)
self.setupUi(self)
self.baseTitle = self.windowTitle()
self.btnAddMapView.setDefaultAction(self.actionAddMapView)
self.btnRemoveMapView.setDefaultAction(self.actionRemoveMapView)
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
self.btnRefresh.setDefaultAction(self.actionApplyStyles)
self.actionAddMapView.triggered.connect(self.createMapView)
self.actionRemoveMapView.triggered.connect(lambda : self.removeMapView(self.currentMapView()))
self.mMapViews = MapViewListModel()
self.mMapViews.sigMapViewsRemoved.connect(self.onMapViewsRemoved)
self.mMapViews.sigMapViewsAdded.connect(self.onMapViewsAdded)
self.cbMapView.setModel(self.mMapViews)
self.cbMapView.currentIndexChanged[int].connect(lambda i : self.setCurrentMapView(self.mMapViews.idx2MapView(i)) )
self.TS = None
def connectTimeSeries(self, timeSeries):
assert isinstance(timeSeries, TimeSeries)
self.TS = timeSeries
self.TS.sigSensorAdded.connect(self.addSensor)
self.TS.sigSensorRemoved.connect(self.removeSensor)
def onMapViewsRemoved(self, mapViews):
for mapView in mapViews:
idx = self.stackedWidget.indexOf(mapView.ui)
if idx >= 0:
self.stackedWidget.removeWidget(mapView.ui)
mapView.ui.close()
else:
s = ""
def onMapViewsAdded(self, mapViews):
nextShown = None
for mapView in mapViews:
self.stackedWidget.addWidget(mapView.ui)
if nextShown is None:
nextShown = mapView
if isinstance(nextShown, MapView):
self.setCurrentMapView(nextShown)
def createMapView(self):
#todo: add entry to combobox + stacked widget
n = len(self.mMapViews) + 1
title = 'Map View {}'.format(n)
while title in [m.title() for m in self.mMapViews]:
n += 1
title = 'Map View {}'.format(n)
mapView.setTitle(title)
def updateFromMapView(self, mapView):
assert isinstance(mapView, MapView)
self.btnToggleMapViewVisibility.setChecked(mapView)
def removeMapView(self, mapView):
assert isinstance(mapView, MapView)
assert mapView in self.mMapViews
i = self.mMapViews.mapView2idx(mapView)
if not i == self.stackedWidget.indexOf(mapView.ui):
s = ""
self.sigMapViewRemoved.emit(mapView)
def __len__(self):
return len(self.mMapViews)
def __contains__(self, mapView):
return mapView in self.mMapViews
def index(self, mapView):
assert isinstance(mapView, MapView)
return self.mMapViews.index(mapView)
def setVectorLayer(self, lyr):
for mapView in self.mMapViews:
assert isinstance(mapView, MapView)
mapView.setVectorLayer(lyr)
def addSensor(self, sensor):
for mapView in self.mMapViews:
mapView.addSensor(sensor)
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
def removeSensor(self, sensor):
for mapView in self.mMapViews:
mapView.removeSensor(sensor)
def applyStyles(self):
for mapView in self.mMapViews:
mapView.applyStyles()
def setCrosshairStyle(self, crosshairStyle):
for mapView in self.mMapViews:
mapView.setCrosshairStyle(crosshairStyle)
def setShowCrosshair(self, b):
for mapView in self.mMapViews:
mapView.setShowCrosshair(b)
def index(self, mapView):
assert isinstance(mapView, MapView)
return self.mapViewsDefinitions.index(mapView)
def setCurrentMapView(self, mapView):
assert isinstance(mapView, MapView) and mapView in self.mMapViews
idx = self.stackedWidget.indexOf(mapView.ui)
if idx >= 0:
self.stackedWidget.setCurrentIndex(idx)
self.cbMapView.setCurrentIndex(self.mMapViews.mapView2idx(mapView).row())
def currentMapView(self):
if len(self.mMapViews) == None:
return None
else:
i = self.cbMapView.currentIndex()
return self.mMapViews.idx2MapView(i)

benjamin.jakimow@geo.hu-berlin.de
committed
class MapViewDockUI(TsvDockWidgetBase, loadUi('mapviewdock.ui')):

benjamin.jakimow@geo.hu-berlin.de
committed
def __init__(self, parent=None):
super(MapViewDockUI, self).__init__(parent)
self.setupUi(self)
self.baseTitle = self.windowTitle()
self.btnApplyStyles.setDefaultAction(self.actionApplyStyles)
#self.dockLocationChanged.connect(self.adjustLayouts)

benjamin.jakimow@geo.hu-berlin.de
committed
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
1739
1740
1741
1742
1743
1744
1745
1746
1747
1748
1749
1750
1751
1752
1753
1754
def toggleLayout(self, p):
newLayout = None
l = p.layout()
print('toggle layout {}'.format(str(p.objectName())))
tmp = QWidget()
tmp.setLayout(l)
sMax = p.maximumSize()
sMax.transpose()
sMin = p.minimumSize()
sMin.transpose()
p.setMaximumSize(sMax)
p.setMinimumSize(sMin)
if isinstance(l, QVBoxLayout):
newLayout = QHBoxLayout()
else:
newLayout = QVBoxLayout()
print(l, '->', newLayout)
while l.count() > 0:
item = l.itemAt(0)
l.removeItem(item)
newLayout.addItem(item)
p.setLayout(newLayout)
return newLayout
def adjustLayouts(self, area):
return
lOld = self.scrollAreaMapsViewDockContent.layout()
if area in [Qt.LeftDockWidgetArea, Qt.RightDockWidgetArea] \
and isinstance(lOld, QVBoxLayout) or \
area in [Qt.TopDockWidgetArea, Qt.BottomDockWidgetArea] \
and isinstance(lOld, QHBoxLayout):
#self.toogleLayout(self.scrollAreaMapsViewDockContent)
self.toggleLayout(self.BVButtonList)