Newer
Older

benjamin.jakimow@geo.hu-berlin.de
committed
#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
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
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
1112
1113
1114
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
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
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
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
1191
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
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
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
class MapViewDefinitionUI(QGroupBox, load('mapviewdefinition.ui')):
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
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
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
1350
1351
1352
1353
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, load('mapviewdock.ui')):
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)