Skip to content

Commit

Permalink
[sextante] added ParameterFile in modeler
Browse files Browse the repository at this point in the history
  • Loading branch information
volaya committed Mar 10, 2013
1 parent 1ff5e27 commit bd50bf0
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
* *
***************************************************************************
"""
from sextante.parameters.ParameterFile import ParameterFile

__author__ = 'Victor Olaya'
__date__ = 'August 2012'
Expand Down Expand Up @@ -48,12 +49,13 @@ class ModelerParameterDefinitionDialog(QtGui.QDialog):
PARAMETER_BOOLEAN="Boolean"
PARAMETER_TABLE_FIELD="Table field"
PARAMETER_EXTENT="Extent"
PARAMETER_FILE="File"
#TO ADD
PARAMETER_MULTIPLE="Multiple input"
PARAMETER_FIXED_TABLE="Fixed table"

paramTypes = [PARAMETER_BOOLEAN,PARAMETER_NUMBER, PARAMETER_RASTER, PARAMETER_EXTENT,
PARAMETER_STRING, PARAMETER_VECTOR, PARAMETER_TABLE, PARAMETER_TABLE_FIELD]
paramTypes = [PARAMETER_BOOLEAN, PARAMETER_EXTENT, PARAMETER_FILE, PARAMETER_NUMBER, PARAMETER_RASTER,
PARAMETER_STRING, PARAMETER_TABLE, PARAMETER_TABLE_FIELD, PARAMETER_VECTOR]

def __init__(self, alg, paramType = None, param = None):
self.alg = alg;
Expand Down Expand Up @@ -194,10 +196,17 @@ def setupUi(self):
self.defaultTextBox = QtGui.QLineEdit()
if self.param is not None:
self.defaultTextBox.setText(self.param.default)
self.minTextBox.setText(self.param.min if self.param.min is not None else "")
self.maxTextBox.setText(self.param.max if self.param.max is not None else "")
self.horizontalLayout2.addWidget(self.defaultTextBox)
self.verticalLayout.addLayout(self.horizontalLayout2)
elif self.paramType == ModelerParameterDefinitionDialog.PARAMETER_FILE \
or isinstance(self.param, ParameterFile):
self.horizontalLayout2.addWidget(QtGui.QLabel("Type"))
self.fileFolderCombo = QtGui.QComboBox()
self.fileFolderCombo.addItem("File")
self.fileFolderCombo.addItem("Folder")
self.horizontalLayout2.addWidget(self.fileFolderCombo)
if self.param is not None:
self.fileFolderCombo.setCurrentIndex(1 if self.param.isFolder else 0)

self.buttonBox = QtGui.QDialogButtonBox(self)
self.buttonBox.setOrientation(QtCore.Qt.Horizontal)
Expand Down Expand Up @@ -251,12 +260,14 @@ def okPressed(self):
vmax = float(vmax)
self.param = ParameterNumber(name, description, vmin, vmax, float(str(self.defaultTextBox.text())))
except:
QMessageBox.critical(self, "Unable to define parameter", "Wrong or missing parameter values")
return
QMessageBox.critical(self, "Unable to define parameter", "Wrong or missing parameter values")
return
elif self.paramType == ModelerParameterDefinitionDialog.PARAMETER_STRING or isinstance(self.param, ParameterString):
self.param = ParameterString(name, description, str(self.defaultTextBox.text()))
elif self.paramType == ModelerParameterDefinitionDialog.PARAMETER_EXTENT or isinstance(self.param, ParameterExtent):
self.param = ParameterExtent(name, description)
elif self.paramType == ModelerParameterDefinitionDialog.PARAMETER_FILE or isinstance(self.param, ParameterFile):
self.param = ParameterFile(name, description)
self.close()

def cancelPressed(self):
Expand Down
12 changes: 4 additions & 8 deletions python/plugins/sextante/modeler/ModelerParametersDialog.py
Original file line number Diff line number Diff line change
Expand Up @@ -615,7 +615,7 @@ def setParamValues(self):
selectedOptions = self.dependenciesPanel.selectedoptions
#this index are based on the list of available dependencies.
#we translate them into indices based on the whole set of algorithm in the model
#We just take the values in the begining of the string representing the algorithm
#We just take the values in the beginning of the string representing the algorithm
availableDependencies = self.getAvailableDependencies()
self.dependencies = []
for selected in selectedOptions:
Expand All @@ -627,17 +627,13 @@ def setParamValues(self):


def setParamValueLayerOrTable(self, param, widget):
idx = widget.findText(widget.currentText())
idx = widget.currentIndex()
if idx < 0:
name = self.getSafeNameForHarcodedParameter(param)
value = AlgorithmAndParameter(AlgorithmAndParameter.PARENT_MODEL_ALGORITHM, name)
self.params[param.name] = value
s = str(widget.currentText())
self.values[name] = s
return False
else:
value = widget.itemData(widget.currentIndex()).toPyObject()
self.params[param.name] = value
return True
return True

def setParamBooleanValue(self, param, widget):
if widget.currentIndex() < 2:
Expand Down

0 comments on commit bd50bf0

Please sign in to comment.