Skip to content
Permalink
Browse files
[sextante]Improvements in batch processing interface and in the simpl…
…ified toolbox organization
  • Loading branch information
volaya committed Feb 24, 2013
1 parent 630745b commit cd0253af7cf82347bcf452827cde9c16863a6b91
@@ -59,6 +59,7 @@ def __init__(self):
#change any of the following if your algorithm should not appear in the toolbox or modeler
self.showInToolbox = True
self.showInModeler = True
self.canRunInBatchMode = True
#to be set by the provider when it loads the algorithm
self.provider = None

@@ -37,7 +37,10 @@ def loadClassification():
while line != "":
tokens = line.split(",")
subtokens = tokens[2].split("/")
AlgorithmDecorator.classification[tokens[0]] = (subtokens[0], subtokens[1], tokens[1]);
try:
AlgorithmDecorator.classification[tokens[0]] = (subtokens[0], subtokens[1], tokens[1]);
except:
raise Exception(line);
line = lines.readline().strip("\n")
lines.close()

@@ -55,7 +58,7 @@ def getGroupsAndName(alg):
name = alg.name
return (group, subgroup, name)
else:
return (None,None,alg.commandLineName())
return (None,None, alg.name)



@@ -68,7 +68,8 @@ def showSelectionDialog(self):
if dlg.mode != None:
try:
if dlg.mode == AutofillDialog.DO_NOT_AUTOFILL:
self.text.setValue(filename)
#self.text.setValue(filename)
self.table.cellWidget(self.row, self.col).setValue(filename)
elif dlg.mode == AutofillDialog.FILL_WITH_NUMBERS:
n = self.table.rowCount() - self.row
for i in range(n):
@@ -16,6 +16,8 @@
* *
***************************************************************************
"""
from sextante.gui.SextantePostprocessing import SextantePostprocessing

__author__ = 'Victor Olaya'
__date__ = 'August 2012'
__copyright__ = '(C) 2012, Victor Olaya'
@@ -25,6 +27,7 @@
from PyQt4 import QtCore, QtGui
from PyQt4.QtCore import *
from PyQt4.QtGui import *
from sextante.core.QGisLayers import QGisLayers
from sextante.parameters.ParameterRaster import ParameterRaster
from sextante.parameters.ParameterTable import ParameterTable
from sextante.parameters.ParameterVector import ParameterVector
@@ -34,13 +37,9 @@
from sextante.outputs.OutputNumber import OutputNumber
from sextante.outputs.OutputString import OutputString
from sextante.core.SextanteUtils import SextanteUtils

from sextante.parameters.ParameterExtent import ParameterExtent
from sextante.parameters.ParameterNumber import ParameterNumber
from sextante.parameters.ParameterFile import ParameterFile
from sextante.parameters.ParameterCrs import ParameterCrs
from sextante.gui.ExtentSelectionPanel import ExtentSelectionPanel

from sextante.parameters.ParameterBoolean import ParameterBoolean
from sextante.parameters.ParameterSelection import ParameterSelection
from sextante.parameters.ParameterFixedTable import ParameterFixedTable
@@ -80,7 +79,7 @@ def __init__(self, alg):
self.buttonBox.addButton(self.addRowButton, QtGui.QDialogButtonBox.ActionRole)
self.buttonBox.addButton(self.deleteRowButton, QtGui.QDialogButtonBox.ActionRole)

self.table.setColumnCount(self.alg.getVisibleParametersCount() + self.alg.getVisibleOutputsCount())
self.table.setColumnCount(self.alg.getVisibleParametersCount() + self.alg.getVisibleOutputsCount() + 1)
self.setTableContent()
self.table.horizontalHeader().setStretchLastSection(True)
self.table.verticalHeader().setVisible(False)
@@ -100,12 +99,17 @@ def setTableContent(self):
self.table.setColumnWidth(i,250)
self.table.setHorizontalHeaderItem(i, QtGui.QTableWidgetItem(out.description))
i+=1


self.table.setColumnWidth(i, 200)
self.table.setHorizontalHeaderItem(i, QtGui.QTableWidgetItem("Load in QGIS"))

for i in range(3):
self.addRow()


def accept(self):
self.algs = []
self.load = []
for row in range(self.table.rowCount()):
alg = self.alg.getCopy()#copy.deepcopy(self.alg)
col = 0
@@ -131,26 +135,30 @@ def accept(self):
self.algs = None
return
self.algs.append(alg)
widget = self.table.cellWidget(row, col)
self.load.append(widget.currentIndex() == 0)

QApplication.setOverrideCursor(QCursor(Qt.WaitCursor))
self.table.setEnabled(False)
if SextanteConfig.getSetting(SextanteConfig.USE_THREADS):
self.nextAlg(0)
else:
i=1
i=0
self.progress.setMaximum(len(self.algs))
for alg in self.algs:
self.setBaseText("Processing algorithm " + str(i) + "/" + str(len(self.algs)) + "...")
self.setBaseText("Processing algorithm " + str(i+1) + "/" + str(len(self.algs)) + "...")
if UnthreadedAlgorithmExecutor.runalg(alg, self):#SilentProgress()):
#self.progress.setValue(i)
#self.loadHTMLResults(alg, i)
if self.load[i]:
SextantePostprocessing.handleAlgorithmResults(alg, self, False)
i+=1
else:
QApplication.restoreOverrideCursor()
return

self.finishAll()

def loadHTMLResults(self, alg, i):
for out in alg.outputs:
if out.hidden or not out.open:
@@ -166,8 +174,10 @@ def cancel(self):

@pyqtSlot()
def finish(self, i):
if self.load[i]:
SextantePostprocessing.handleAlgorithmResults(self.algs[i], self, False)
i += 1
self.progress.setValue(i)
#self.progress.setValue(i)
if len(self.algs) == i:
self.finishAll()
self.algEx = None
@@ -282,6 +292,12 @@ def addRow(self):
for out in self.alg.outputs:
self.table.setCellWidget(self.table.rowCount()-1,i, BatchOutputSelectionPanel(out, self.alg, self.table.rowCount()-1, i, self))
i+=1

item = QtGui.QComboBox()
item.addItem("Yes")
item.addItem("No")
item.setCurrentIndex(0)
self.table.setCellWidget(self.table.rowCount()-1, i, item)

def showAdvancedParametersClicked(self):
self.showAdvanced = not self.showAdvanced
@@ -79,9 +79,10 @@ def showPopupMenu(self,point):
executeAction = QAction(self.tr("Execute"), self.algorithmTree)
executeAction.triggered.connect(self.executeAlgorithm)
popupmenu.addAction(executeAction)
executeBatchAction = QAction(self.tr("Execute as batch process"), self.algorithmTree)
executeBatchAction.triggered.connect(self.executeAlgorithmAsBatchProcess)
popupmenu.addAction(executeBatchAction)
if alg.canRunInBatchMode:
executeBatchAction = QAction(self.tr("Execute as batch process"), self.algorithmTree)
executeBatchAction.triggered.connect(self.executeAlgorithmAsBatchProcess)
popupmenu.addAction(executeBatchAction)
editRenderingStylesAction = QAction(self.tr("Edit rendering styles for outputs"), self.algorithmTree)
editRenderingStylesAction.triggered.connect(self.editRenderingStyles)
popupmenu.addAction(editRenderingStylesAction)
@@ -202,7 +203,7 @@ def fillTreeUsingCategories(self):
mainItem = QTreeWidgetItem()
mainItem.setText(0, "Geoalgorithms")
mainItem.setIcon(0, GeoAlgorithm.getDefaultIcon())
mainItem.setToolTip(0, mainItem.text(0))
mainItem.setToolTip(0, mainItem.text(0))
for groupname, group in groups.items():
groupItem = QTreeWidgetItem()
groupItem.setText(0, groupname)
@@ -217,11 +218,9 @@ def fillTreeUsingCategories(self):
groupItem.addChild(subgroupItem)
for alg in subgroup:
algItem = TreeAlgorithmItem(alg)
subgroupItem.addChild(algItem)
subgroupItem.setExpanded(text!="")
groupItem.setExpanded(text!="")
self.algorithmTree.addTopLevelItem(mainItem)
mainItem.setExpanded(text!="")
subgroupItem.addChild(algItem)

self.algorithmTree.addTopLevelItem(mainItem)

for providerName in Sextante.algs.keys():
groups = {}
@@ -267,11 +266,10 @@ def fillTreeUsingCategories(self):
for groupItem in groups.values():
providerItem.addChild(groupItem)
self.algorithmTree.addTopLevelItem(providerItem)
providerItem.setExpanded(text!="")
for groupItem in groups.values():
if text != "":
groupItem.setExpanded(True)


if (text != ""):
self.algorithmTree.expandAll()

def fillTreeUsingProviders(self):
self.algorithmTree.clear()
text = unicode(self.searchBox.text())
@@ -319,9 +317,8 @@ def fillTreeUsingProviders(self):
providerItem.addChild(groupItem)
self.algorithmTree.addTopLevelItem(providerItem)
providerItem.setExpanded(text!="")
for groupItem in groups.values():
if text != "":
groupItem.setExpanded(True)
for groupItem in groups.values():
groupItem.setExpanded(text != "")



@@ -330,15 +327,15 @@ class TreeAlgorithmItem(QTreeWidgetItem):
def __init__(self, alg):
useCategories = SextanteConfig.getSetting(SextanteConfig.USE_CATEGORIES)
QTreeWidgetItem.__init__(self)
self.alg = alg
self.setText(0, alg.name)
self.alg = alg
icon = alg.getIcon()
name = alg.name
if useCategories:
icon = GeoAlgorithm.getDefaultIcon()
group, subgroup, name = AlgorithmDecorator.getGroupsAndName(alg)
self.setIcon(0, icon)
self.setToolTip(0, name)
self.setText(0, name)

class TreeActionItem(QTreeWidgetItem):

Loading

0 comments on commit cd0253a

Please sign in to comment.