Newer
Older

benjamin.jakimow@geo.hu-berlin.de
committed
if r:
if isinstance(self.targetLayout, QHBoxLayout):
s = QSize(s.width(), r.height())
else:
s = QSize(r.width(), s.height())
s = s + QSize(m.left() + m.right(), m.top() + m.bottom())
self.targetLayout.parentWidget().setFixedSize(s)
def setMaxTSDViews(self, n=-1):
self.nMaxTSDViews = n
#todo: remove views
def setSpatialCenter(self, center, mapCanvas0=None):
if self.mBlockCanvasSignals:
return True
assert isinstance(center, SpatialPoint)
center = center.toCrs(self.mCRS)
if not isinstance(center, SpatialPoint):
return
self.mBlockCanvasSignals = True
self.mSpatialExtent.setCenter(center)
for mapCanvas in self.mMapCanvases:
if mapCanvas != mapCanvas0:
oldState = mapCanvas.blockSignals(True)
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
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
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()

benjamin.jakimow@geo.hu-berlin.de
committed
def highlightDate(self, tsd):
"""
Highlights a time series data for a specific time our
:param tsd:
:return:
"""
tsdView = self.tsdView(tsd)
if isinstance(tsdView, DatumView):
tsdView.setHighlight(True)

benjamin.jakimow@geo.hu-berlin.de
committed
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
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
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
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
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
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
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()
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
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
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
"""
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)
self.btnRefresh.setDefaultAction(self.actionApplyStyles)

benjamin.jakimow@geo.hu-berlin.de
committed
self.btnHighlightMapView.setDefaultAction(self.actionHighlightMapView)
self.actionAddMapView.triggered.connect(self.createMapView)
self.actionRemoveMapView.triggered.connect(lambda : self.removeMapView(self.currentMapView()))

benjamin.jakimow@geo.hu-berlin.de
committed
self.actionHighlightMapView.triggered.connect(lambda : self.currentMapView().setHighlighted(True))
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
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)
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
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
1760
1761
1762
1763
1764
1765
1766
1767
1768
1769
1770
1771
1772
1773
1774
1775
1776
1777
1778
1779
1780
1781
1782
1783
1784
1785
1786
1787
1788
1789
1790
1791
1792
1793
1794
1795
1796
1797
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)