Skip to content
Permalink
Browse files

Batch processing in separate thread.

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
cpolymeris@gmail.com committed Jun 11, 2012
1 parent 977c794 commit 4bf3dc3c17c8327b59a883659fc4b6571a9f2454
Showing with 32 additions and 9 deletions.
  1. +31 −9 src/sextante/gui/BatchProcessingDialog.py
  2. +1 −0 src/sextante/gui/ParametersDialog.py
@@ -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:
@@ -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())
@@ -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

0 comments on commit 4bf3dc3

Please sign in to comment.
You can’t perform that action at this time.