Newer
Older
self.ui.pixelLoader.sigLoadingStarted.connect(self.clear)
self.ui.pixelLoader.sigLoadingFinished.connect(lambda : self.plot2D.enableAutoRange('x', False))
# self.VIEW.setItemDelegateForColumn(3, PointStyleDelegate(self.VIEW))
self.plotData2D = dict()
self.plotData3D = dict()
self.setData()

benjamin.jakimow@geo.hu-berlin.de
committed
def updatePersistantWidgets(self):
model = self.TV.model()
if model:
colExpression = model.columnames.index('y-value')
colStyle = model.columnames.index('style')
for row in range(model.rowCount()):
idxExpr = model.createIndex(row, colExpression)
idxStyle = model.createIndex(row, colStyle)
#self.TV.closePersistentEditor(idxExpr)
#self.TV.closePersistentEditor(idxStyle)
self.TV.openPersistentEditor(idxExpr)
self.TV.openPersistentEditor(idxStyle)
#self.TV.openPersistentEditor(model.createIndex(start, colStyle))
s = ""
def onRowsInserted(self, parent, start, end):
model = self.TV.model()
if model:
colExpression = model.columnames.index('y-value')
colStyle = model.columnames.index('style')
while start <= end:
idxExpr = model.createIndex(start, colExpression)
idxStyle = model.createIndex(start, colStyle)

benjamin.jakimow@geo.hu-berlin.de
committed
#self.TV.openPersistentEditor(idxExpr)
#self.TV.openPersistentEditor(idxStyle)
start += 1
#self.TV.openPersistentEditor(model.createIndex(start, colStyle))
s = ""
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
def onObservationClicked(self, plotDataItem, points):
for p in points:
tsd = p.data()
print(tsd)
s =""
def clear(self):
#first remove from pixelCollection
self.pxCollection.clearPixels()
self.plotData2D.clear()
self.plotData3D.clear()
pi = self.plot2D.getPlotItem()
plotItems = pi.listDataItems()
for p in plotItems:
p.clear()
p.update()
if len(self.ui.TS) > 0:
rng = [self.ui.TS[0].date, self.ui.TS[-1].date]
rng = [date2num(d) for d in rng]
self.plot2D.getPlotItem().setRange(xRange=rng)
QApplication.processEvents()
if self.plot3D:
pass
def setVisibility(self, sensorView):
assert isinstance(sensorView, SensorPlotSettings)
self.setVisibility2D(sensorView)
def setVisibility2D(self, sensorView):
assert isinstance(sensorView, SensorPlotSettings)
p = self.plotData2D[sensorView.sensor]
p.setData(symbol='o', symbolBrush=sensorView.color, symbolPen='w', symbolSize=8)
p.setVisible(sensorView.isVisible)
p.update()
self.plot2D.update()
s =""
def setData(self, sensorView = None):
if sensorView is None:
for sv in self.plotSettingsModel.items:
self.setData(sv)
else:
assert isinstance(sensorView, SensorPlotSettings)
self.setData2D(sensorView)
pass
def setData2D(self, sensorView):
assert isinstance(sensorView, SensorPlotSettings)
if sensorView.sensor not in self.plotData2D.keys():

benjamin.jakimow@geo.hu-berlin.de
committed
plotDataItem = SensorPoints(name=sensorView.sensor.name(), pen=None, symbol='o', symbolPen=None)
plotDataItem = pg.ScatterPlotItem(name=sensorView.sensor.name(), pen= {'color': 'w', 'width': 2},brush=QColor('green'), symbol='o')
#self.plot2D.addItem(plotDataItem)

benjamin.jakimow@geo.hu-berlin.de
committed
plotDataItem = self.plot2D.plot(name=sensorView.sensor.name(), pen=None, symbol='o', symbolPen=None)
#plotDataItem.curve.setClickable(True)
plotDataItem.sigPointsClicked.connect(self.onObservationClicked)
#self.plot2D.scene().addItem(plotDataItem)
#self.plot2D.setMenuEnabled(True)
#self.plot2D.addItem(plotDataItem)
self.plotData2D[sensorView.sensor] = plotDataItem
self.setVisibility2D(sensorView)
plotDataItem = self.plotData2D[sensorView.sensor]

benjamin.jakimow@geo.hu-berlin.de
committed
plotDataItem.setToolTip('Values {}'.format(sensorView.sensor.name()))
#https://github.com/pyqtgraph/pyqtgraph/blob/5195d9dd6308caee87e043e859e7e553b9887453/examples/customPlot.py
tsds, values = self.pxCollection.dateValues(sensorView.sensor, sensorView.expression)
if len(tsds) > 0:
dates = np.asarray([date2num(tsd.date) for tsd in tsds])
values = np.asarray(values)
#spots = []
#for i, tsd in enumerate(tsds):
# spots.append({'pos':(dates[i], values[i])})
#plotDataItem.setPoints(spots)
#plotDataItem.invalidate()
#self.plot2D.invalidate()
#self.setVisibility2D()
#plotDataItem.setPoints(x=dates, y=values, data=tsds)
plotDataItem.setData(x=dates, y=values, data=tsds)
#plotDataItem.scatter.addPoints(x=dates, y=values, data=tsds)
def setData3D(self, *arg):
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
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
1258
1259
1260
1261
1262
1263
1264
1265
1266
pass
def testPixelLoader():
# prepare QGIS environment
if sys.platform == 'darwin':
PATH_QGS = r'/Applications/QGIS.app/Contents/MacOS'
os.environ['GDAL_DATA'] = r'/usr/local/Cellar/gdal/1.11.3_1/share'
else:
# assume OSGeo4W startup
PATH_QGS = os.environ['QGIS_PREFIX_PATH']
assert os.path.exists(PATH_QGS)
qgsApp = QgsApplication([], True)
QApplication.addLibraryPath(r'/Applications/QGIS.app/Contents/PlugIns')
QApplication.addLibraryPath(r'/Applications/QGIS.app/Contents/PlugIns/qgis')
qgsApp.setPrefixPath(PATH_QGS, True)
qgsApp.initQgis()
gb = QGroupBox()
gb.setTitle('Sandbox')
PL = PixelLoader()
PL.setNumberOfThreads(1)
if False:
files = ['observationcloud/testdata/2014-07-26_LC82270652014207LGN00_BOA.bsq',
'observationcloud/testdata/2014-08-03_LE72270652014215CUB00_BOA.bsq'
]
else:
from utils import file_search
searchDir = r'H:\LandsatData\Landsat_NovoProgresso'
files = file_search(searchDir, '*227065*band4.img', recursive=True)
#files = files[0:3]
lyr = QgsRasterLayer(files[0])
coord = lyr.extent().center()
crs = lyr.crs()
l = QVBoxLayout()
btnStart = QPushButton()
btnStop = QPushButton()
prog = QProgressBar()
tboxResults = QPlainTextEdit()
tboxResults.setMaximumHeight(300)
tboxThreads = QPlainTextEdit()
tboxThreads.setMaximumHeight(200)
label = QLabel()
label.setText('Progress')
def showProgress(n,m,md):
prog.setMinimum(0)
prog.setMaximum(m)
prog.setValue(n)
info = []
for k, v in md.items():
info.append('{} = {}'.format(k,str(v)))
tboxResults.setPlainText('\n'.join(info))
#tboxThreads.setPlainText(PL.threadInfo())
qgsApp.processEvents()
PL.sigPixelLoaded.connect(showProgress)
btnStart.setText('Start loading')
btnStart.clicked.connect(lambda : PL.startLoading(files, coord, crs))
btnStop.setText('Cancel')
btnStop.clicked.connect(lambda: PL.cancelLoading())
lh = QHBoxLayout()
lh.addWidget(btnStart)
lh.addWidget(btnStop)
l.addLayout(lh)
l.addWidget(prog)
l.addWidget(tboxThreads)
l.addWidget(tboxResults)
gb.setLayout(l)
gb.show()
#rs.setBackgroundStyle('background: qlineargradient(x1:0, y1:0, x2:0, y2:1, stop:0 #222, stop:1 #333);')
#rs.handle.setStyleSheet('background: qlineargradient(x1:0, y1:0, x2:0, y2:1, stop:0 #282, stop:1 #393);')
qgsApp.exec_()
qgsApp.exitQgis()
if __name__ == '__main__':
import site, sys
#add site-packages to sys.path as done by enmapboxplugin.py
from timeseriesviewer import DIR_SITE_PACKAGES
site.addsitedir(DIR_SITE_PACKAGES)
#prepare QGIS environment
if sys.platform == 'darwin':
PATH_QGS = r'/Applications/QGIS.app/Contents/MacOS'
os.environ['GDAL_DATA'] = r'/usr/local/Cellar/gdal/1.11.3_1/share'
else:
# assume OSGeo4W startup
PATH_QGS = os.environ['QGIS_PREFIX_PATH']
assert os.path.exists(PATH_QGS)
qgsApp = QgsApplication([], True)
QApplication.addLibraryPath(r'/Applications/QGIS.app/Contents/PlugIns')
QApplication.addLibraryPath(r'/Applications/QGIS.app/Contents/PlugIns/qgis')
qgsApp.setPrefixPath(PATH_QGS, True)
qgsApp.initQgis()
#run tests
#d = AboutDialogUI()
#d.show()
from timeseriesviewer.tests import *
TS = TestObjects.TimeSeries(100)
ext = TS.getMaxSpatialExtent()
d = ProfileViewDockUI()
d.connectTimeSeries(TS)
d.show()
d.loadCoordinate(ext.center(), ext.crs())
#close QGIS
try:
qgsApp.exec_()
qgsApp.exitQgis()
except:
s = ""