Newer
Older
#register signals handled on (this) DV level
mapCanvas.renderStarting.connect(lambda: self.sigLoadingStarted.emit(mapView, self.TSD))
mapCanvas.mapCanvasRefreshed.connect(lambda: self.sigLoadingFinished.emit(mapView, self.TSD))
mapCanvas.sigShowProfiles.connect(lambda c, t : mapView.sigShowProfiles.emit(c,mapCanvas, t))
mapCanvas.sigChangeDVRequest.connect(self.onMapCanvasRequest)

benjamin.jakimow@geo.hu-berlin.de
committed
def onMapCanvasRequest(self, mapCanvas, key):
if key == 'hide_date':
self.TSD.setVisibility(False)
if key == 'copy_sensor':
QApplication.clipboard().setText(self.TSD.sensor.name())
if key == 'copy_date':
QApplication.clipboard().setText(str(self.TSD.date))
if key == 'copy_path':
QApplication.clipboard().setText(str(self.TSD.pathImg))

benjamin.jakimow@geo.hu-berlin.de
committed
def __lt__(self, other):
assert isinstance(other, DatumView)
return self.TSD < other.TSD

benjamin.jakimow@geo.hu-berlin.de
committed
def __eq__(self, other):
assert isinstance(other, DatumView)
return self.TSD == other.TSD

benjamin.jakimow@geo.hu-berlin.de
committed
class SpatialTemporalVisualization(QObject):
"""
"""
sigLoadingStarted = pyqtSignal(DatumView, MapView)
sigLoadingFinished = pyqtSignal(DatumView, MapView)
sigShowProfiles = pyqtSignal(SpatialPoint, MapCanvas, str)

benjamin.jakimow@geo.hu-berlin.de
committed
sigShowMapLayerInfo = pyqtSignal(dict)
sigSpatialExtentChanged = pyqtSignal(SpatialExtent)
sigCRSChanged = pyqtSignal(QgsCoordinateReferenceSystem)

benjamin.jakimow@geo.hu-berlin.de
committed
def __init__(self, timeSeriesViewer):
super(SpatialTemporalVisualization, self).__init__()

benjamin.jakimow@geo.hu-berlin.de
committed
#assert isinstance(timeSeriesViewer, TimeSeriesViewer), timeSeriesViewer
#default map settings
self.mSpatialExtent = SpatialExtent.world()
self.mCRS = self.mSpatialExtent.crs()
self.mSize = QSize(200,200)
self.mColor = Qt.black

benjamin.jakimow@geo.hu-berlin.de
committed
self.ui = timeSeriesViewer.ui
#map-tool handling
self.mMapToolActivator = None
self.mMapTools = []

benjamin.jakimow@geo.hu-berlin.de
committed
self.scrollArea = self.ui.scrollAreaSubsets
assert isinstance(self.scrollArea, MapViewScrollArea)
self.mRefreshTimer = QTimer(self)
self.mRefreshTimer.setInterval(1000)
self.mRefreshTimer.timeout.connect(self.refresh)
self.scrollArea.sigResized.connect(self.mRefreshTimer.start)
self.scrollArea.horizontalScrollBar().valueChanged.connect(self.mRefreshTimer.start)

benjamin.jakimow@geo.hu-berlin.de
committed
self.TSV = timeSeriesViewer
self.TS = timeSeriesViewer.TS
self.ui.dockMapViews.connectTimeSeries(self.TS)

benjamin.jakimow@geo.hu-berlin.de
committed
self.targetLayout = self.ui.scrollAreaSubsetContent.layout()
#self.MVC = MapViewCollection(self)
#self.MVC.sigShowProfiles.connect(self.sigShowProfiles.emit)
self.MVC = self.ui.dockMapViews
assert isinstance(self.MVC, MapViewCollectionDock)

benjamin.jakimow@geo.hu-berlin.de
committed
self.MVC.sigShowProfiles.connect(self.sigShowProfiles.emit)
self.vectorOverlay = None
self.DVC.sigResizeRequired.connect(self.adjustScrollArea)
self.DVC.sigLoadingStarted.connect(self.ui.dockRendering.addStartedWork)
self.DVC.sigLoadingFinished.connect(self.ui.dockRendering.addFinishedWork)
#self.timeSeriesDateViewCollection.sigSpatialExtentChanged.connect(self.setSpatialExtent)
self.TS.sigTimeSeriesDatesAdded.connect(self.DVC.addDates)
self.TS.sigTimeSeriesDatesRemoved.connect(self.DVC.removeDates)

benjamin.jakimow@geo.hu-berlin.de
committed
#add dates, if already existing

benjamin.jakimow@geo.hu-berlin.de
committed
if len(self.TS) > 0:
self.setSpatialExtent(self.TS.getMaxSpatialExtent())

benjamin.jakimow@geo.hu-berlin.de
committed

benjamin.jakimow@geo.hu-berlin.de
committed
def createMapView(self):
self.MVC.createMapView()
def registerMapCanvas(self, mapCanvas):
from timeseriesviewer.mapcanvas import MapCanvas
assert isinstance(mapCanvas, MapCanvas)
self.mMapCanvases.append(mapCanvas)
#set general canvas properties
mapCanvas.setFixedSize(self.mSize)
mapCanvas.setCrs(self.mCRS)
mapCanvas.setSpatialExtent(self.mSpatialExtent)
#register on map canvas signals
mapCanvas.sigSpatialExtentChanged.connect(lambda e: self.setSpatialExtent(e, mapCanvas))

benjamin.jakimow@geo.hu-berlin.de
committed
def setCrosshairStyle(self, crosshairStyle):
from timeseriesviewer.mapcanvas import MapCanvas
for mapCanvas in self.mMapCanvases:
assert isinstance(mapCanvas, MapCanvas)
mapCanvas.setCrosshairStyle(crosshairStyle)
#self.MVC.setCrosshairStyle(crosshairStyle)

benjamin.jakimow@geo.hu-berlin.de
committed
def setShowCrosshair(self, b):
self.MVC.setShowCrosshair(b)
def setVectorLayer(self, lyr):
self.MVC.setVectorLayer(lyr)

benjamin.jakimow@geo.hu-berlin.de
committed
assert isinstance(size, QSize)
from timeseriesviewer.mapcanvas import MapCanvas
for mapCanvas in self.mMapCanvases:
assert isinstance(mapCanvas, MapCanvas)
mapCanvas.setFixedSize(size)
self.sigMapSizeChanged.emit(self.mSize)

benjamin.jakimow@geo.hu-berlin.de
committed
self.adjustScrollArea()
def subsetSize(self):
return QSize(self.mSize)

benjamin.jakimow@geo.hu-berlin.de
committed
def refresh(self):

benjamin.jakimow@geo.hu-berlin.de
committed
tsdView.refresh()

benjamin.jakimow@geo.hu-berlin.de
committed
def adjustScrollArea(self):
#adjust scroll area widget to fit all visible widgets
m = self.targetLayout.contentsMargins()

benjamin.jakimow@geo.hu-berlin.de
committed
w = h = 0
s = QSize()
r = None
tsdViews = [v for v in self.DVC if v.ui.isVisible()]
mapViews = [v for v in self.MVC if v.isVisible()]
nX = len(tsdViews)
nY = len(mapViews)
spacing = self.targetLayout.spacing()
margins = self.targetLayout.contentsMargins()

benjamin.jakimow@geo.hu-berlin.de
committed
sizeX = 1
sizeY = 50
if nX > 0:
s = tsdViews[0].ui.sizeHint().width()
s = nX * (s + spacing) + margins.left() + margins.right()
sizeX = s
if nY > 0:
if nX > 0:
s = tsdViews[0].ui.sizeHint().height()
s = s + margins.top() + margins.bottom()
else:
s = 50
sizeY = s

benjamin.jakimow@geo.hu-berlin.de
committed
#s = tsdViews[0].ui.sizeHint()
#s = QSize(nX * (s.width() + spacing) + margins.left() + margins.right(),
# s.height() + margins.top() + margins.bottom())

benjamin.jakimow@geo.hu-berlin.de
committed
self.targetLayout.parentWidget().setFixedSize(QSize(sizeX, sizeY))

benjamin.jakimow@geo.hu-berlin.de
committed
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
def setMapTool(self, mapToolKey, *args, **kwds):
# filter map tools
self.mMapToolActivator = self.sender()
del self.mMapTools[:]
from timeseriesviewer.mapcanvas import MapTools, CursorLocationMapTool, SpectralProfileMapTool, TemporalProfileMapTool
for canvas in self.mMapCanvases:
mt = None
if mapToolKey in MapTools.mapToolKeys():
mt = MapTools.create(mapToolKey, canvas, *args, **kwds)
if isinstance(mapToolKey, QgsMapTool):
mt = MapTools.copy(mapToolKey, canvas, *args, **kwds)
if isinstance(mt, QgsMapTool):
canvas.setMapTool(mt)
self.mMapTools.append(mt)
#if required, link map-tool with specific EnMAP-Box slots
if isinstance(mt, CursorLocationMapTool):
mt.sigLocationRequest[SpatialPoint, QgsMapCanvas].connect(lambda c, m : self.sigShowProfiles.emit(c,m, mapToolKey))
return self.mMapTools

benjamin.jakimow@geo.hu-berlin.de
committed
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
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
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
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))
mapView.sigMapViewVisibility.connect(lambda: self.sigResizeRequired.emit())
mapView.sigShowProfiles.connect(self.sigShowProfiles.emit)

benjamin.jakimow@geo.hu-berlin.de
committed
w.setUpdatesEnabled(True)

benjamin.jakimow@geo.hu-berlin.de
committed
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])
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
1555
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 __getitem__(self, slice):
return self.mMapViewList[slice]
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('mapviewdock.ui')):
sigMapViewAdded = pyqtSignal(MapView)
sigMapViewRemoved = pyqtSignal(MapView)
sigShowProfiles = pyqtSignal(SpatialPoint, MapCanvas, str)
def connectTimeSeries(self, timeSeries):
assert isinstance(timeSeries, TimeSeries)
self.TS = timeSeries
self.TS.sigSensorAdded.connect(self.addSensor)
self.TS.sigSensorRemoved.connect(self.removeSensor)
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))
self.actionApplyStyles.triggered.connect(lambda : self.currentMapView().refreshMapView())
self.mMapViews = MapViewListModel()
self.mMapViews.sigMapViewsRemoved.connect(self.onMapViewsRemoved)
self.mMapViews.sigMapViewsAdded.connect(self.onMapViewsAdded)
self.mMapViews.sigMapViewsAdded.connect(self.updateButtons)
self.mMapViews.sigMapViewsRemoved.connect(self.updateButtons)
self.cbMapView.currentIndexChanged[int].connect(lambda i : None if i < 0 else self.setCurrentMapView(self.mMapViews.idx2MapView(i)) )
self.TS = None
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 = ""
self.actionRemoveMapView.setEnabled(len(self.mMapViews) > 0)
def onMapViewsAdded(self, mapViews):
nextShown = None
for mapView in mapViews:
self.stackedWidget.addWidget(mapView.ui)
if nextShown is None:
nextShown = mapView
contents = mapView.ui.scrollAreaWidgetContents
size = contents.size()
hint = contents.sizeHint()
#mapView.ui.scrollArea.update()
s = ""
#setMinimumSize(mapView.ui.scrollAreaWidgetContents.sizeHint())
#hint = contents.sizeHint()
#contents.setMinimumSize(hint)
if isinstance(nextShown, MapView):
self.setCurrentMapView(nextShown)
def updateButtons(self, *args):
b = len(self.mMapViews) > 0
self.actionRemoveMapView.setEnabled(b)
self.actionApplyStyles.setEnabled(b)
self.actionHighlightMapView.setEnabled(b)
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)
mapView.sigShowProfiles.connect(self.sigShowProfiles)
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 __getitem__(self, slice):
return self.mMapViews[slice]
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)
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
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
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
1798
1799
1800
1801
1802
1803
1804
1805
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)