Skip to content

Commit

Permalink
Batch processing in separate thread.
Browse files Browse the repository at this point in the history
git-svn-id: http://sextante.googlecode.com/svn/trunk/soft/bindings/qgis-plugin@235 881b9c09-3ef8-f3c2-ec3d-21d735c97f4d
  • Loading branch information
cpolymeris@gmail.com committed Jun 11, 2012
1 parent 977c794 commit 4bf3dc3
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 9 deletions.
40 changes: 31 additions & 9 deletions src/sextante/gui/BatchProcessingDialog.py
Expand Up @@ -95,19 +95,16 @@ def okPressed(self):
QMessageBox.critical(self, "Unable to execute batch process", "Wrong or missing parameter values")
self.algs = None
return
row+=1
#~ row+=1 ??? - why?
self.algs.append(alg)

QApplication.setOverrideCursor(QCursor(Qt.WaitCursor))
self.progress.setMaximum(len(self.algs))
for alg in self.algs:
algEx = AlgorithmExecutor(alg);
algEx.start()

QApplication.restoreOverrideCursor()
QMessageBox.information(self, "Batch processing", "Batch processing successfully completed!")
self.close()

self.progress.setValue(0)
self.nextAlg(0)

self.table.setEnabled(False)

def loadHTMLResults(self, alg, i):
for out in alg.outputs:
if out.hidden or not out.open:
Expand All @@ -119,6 +116,31 @@ def cancelPressed(self):
self.algs = None
self.close()

@pyqtSlot()
def finish(self, i):
i += 1
self.progress.setValue(i)
if len(self.algs) == i:
self.finishAll()
self.algEx = None
else:
self.nextAlg(i)

def nextAlg(self, i):
self.algEx = AlgorithmExecutor(self.algs[i]);
self.algEx.finished.connect(lambda: self.finish(i))
self.algEx.start()

def finishAll(self):
i = 0
for alg in self.algs:
self.loadHTMLResults(alg, i)
i = i + 1
QApplication.restoreOverrideCursor()
self.table.setEnabled(True)
QMessageBox.information(self, "Batch processing", "Batch processing successfully completed!")
self.close()

def setParameterValueFromWidget(self, param, widget):
if isinstance(param, (ParameterRaster, ParameterVector, ParameterTable, ParameterMultipleInput)):
return param.setValue(widget.getText())
Expand Down
1 change: 1 addition & 0 deletions src/sextante/gui/ParametersDialog.py
Expand Up @@ -219,6 +219,7 @@ def finish(self):
def cancel(self):
try:
self.algEx.finished.disconnect()
QApplication.restoreOverrideCursor()
self.buttonBox.button(QtGui.QDialogButtonBox.Cancel).setEnabled(False)
except:
pass
Expand Down

0 comments on commit 4bf3dc3

Please sign in to comment.