Newer
Older

benjamin.jakimow@geo.hu-berlin.de
committed
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
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
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)
DV = DatumView(tsd, self, self.STV.MVC, parent=self.ui)
#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)
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
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
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])
class MapViewCollection(QObject):
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.btnList = spatialTemporalVisualization.dockMapViews.BVButtonList
self.scrollArea = spatialTemporalVisualization.dockMapViews.scrollAreaMapViews
self.scrollAreaContent = spatialTemporalVisualization.dockMapViews.scrollAreaMapsViewDockContent

benjamin.jakimow@geo.hu-berlin.de
committed
1139
1140
1141
1142
1143
1144
1145
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
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
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
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
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
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
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()
class MapViewDockUI(TsvDockWidgetBase, loadUi('mapviewdock.ui')):

benjamin.jakimow@geo.hu-berlin.de
committed
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
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)
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)