Skip to content

Commit

Permalink
added default value for ParameterSelection
Browse files Browse the repository at this point in the history
git-svn-id: http://sextante.googlecode.com/svn/trunk/soft/bindings/qgis-plugin@114 881b9c09-3ef8-f3c2-ec3d-21d735c97f4d
  • Loading branch information
volayaf committed Apr 17, 2012
1 parent 84add0a commit 3765365
Show file tree
Hide file tree
Showing 6 changed files with 16 additions and 9 deletions.
2 changes: 1 addition & 1 deletion src/sextante/grass/GrassUtils.py
Expand Up @@ -54,7 +54,7 @@ def grassPath():
def grassHelpPath():
folder = SextanteConfig.getSetting(GrassUtils.GRASS_HELP_FOLDER)
if folder == None:
folder =""
folder = os.path.join(GrassUtils.grassPath(), "docs", "html")

return folder

Expand Down
1 change: 1 addition & 0 deletions src/sextante/gui/ParametersDialog.py
Expand Up @@ -171,6 +171,7 @@ def getWidgetFromParameter(self, param):
elif isinstance(param, ParameterSelection):
item = QtGui.QComboBox()
item.addItems(param.options)
item.setCurrentIndex(param.default)
elif isinstance(param, ParameterFixedTable):
item = FixedTablePanel(param)
elif isinstance(param, ParameterRange):
Expand Down
8 changes: 6 additions & 2 deletions src/sextante/parameters/ParameterSelection.py
Expand Up @@ -2,11 +2,12 @@

class ParameterSelection(Parameter):

def __init__(self, name="", description="", options=[]):
def __init__(self, name="", description="", options=[], default = 0):
self.name = name
self.description = description
self.options = options
self.value = None
self.default = default

def setValue(self, n):
try:
Expand All @@ -21,7 +22,10 @@ def getAsScriptCode(self):

def deserialize(self, s):
tokens = s.split("|")
return ParameterSelection(tokens[0], tokens[1], tokens[2].split(";"))
if len(tokens) == 4:
return ParameterSelection(tokens[0], tokens[1], tokens[2].split(";"), int(tokens[3]))
else:
return ParameterSelection(tokens[0], tokens[1], tokens[2].split(";"))

def serialize(self):
return self.__module__.split(".")[-1] + "|" + self.name + "|" + self.description +\
Expand Down
2 changes: 1 addition & 1 deletion src/sextante/saga/description/Slope,Aspect,Curvature.txt
@@ -1,7 +1,7 @@
Slope, Aspect, Curvature
ta_morphometry
ParameterRaster|ELEVATION|Elevation|False
ParameterSelection|METHOD|Method|[0] Maximum Slope (Travis et al. 1975);[1] Maximum Triangle Slope (Tarboton 1997);[2] Least Squares Fitted Plane (Horn 1981, Costa-Cabral & Burgess 1996);[3] Fit 2.Degree Polynom (Bauer, Rohdenburg, Bork 1985);[4] Fit 2.Degree Polynom (Heerdegen & Beran 1982);[5] Fit 2.Degree Polynom (Zevenbergen & Thorne 1987);[6] Fit 3.Degree Polynom (Haralick 1983)
ParameterSelection|METHOD|Method|[0] Maximum Slope (Travis et al. 1975);[1] Maximum Triangle Slope (Tarboton 1997);[2] Least Squares Fitted Plane (Horn 1981, Costa-Cabral & Burgess 1996);[3] Fit 2.Degree Polynom (Bauer, Rohdenburg, Bork 1985);[4] Fit 2.Degree Polynom (Heerdegen & Beran 1982);[5] Fit 2.Degree Polynom (Zevenbergen & Thorne 1987);[6] Fit 3.Degree Polynom (Haralick 1983)|5
OutputRaster|SLOPE|Slope
OutputRaster|ASPECT|Aspect
OutputRaster|CURV|Curvature
Expand Down
4 changes: 3 additions & 1 deletion src/sextante/script/DeleteScriptAction.py
@@ -1,5 +1,6 @@
from sextante.script.ScriptAlgorithm import ScriptAlgorithm
from sextante.gui.ContextAction import ContextAction
import os

class DeleteScriptAction(ContextAction):

Expand All @@ -10,4 +11,5 @@ def isEnabled(self):
return isinstance(self.alg, ScriptAlgorithm)

def execute(self, alg):
pass
os.remove(self.alg.descriptionFile)
self.toolbox.updateTree()
8 changes: 4 additions & 4 deletions src/sextante/script/ScriptAlgorithm.py
Expand Up @@ -104,10 +104,10 @@ def processParameterLine(self,line):
out = OutputTable()
elif tokens[1].lower().strip().startswith("output html"):
out = OutputHTML()
elif tokens[1].lower().strip().startswith("output number"):
out = OutputNumber()


#=======================================================================
# elif tokens[1].lower().strip().startswith("output number"):
# out = OutputNumber()
#=======================================================================

if param != None:
self.addParameter(param)
Expand Down

0 comments on commit 3765365

Please sign in to comment.