Skip to content

Commit 3765365

Browse files
author
volayaf
committed
added default value for ParameterSelection
git-svn-id: http://sextante.googlecode.com/svn/trunk/soft/bindings/qgis-plugin@114 881b9c09-3ef8-f3c2-ec3d-21d735c97f4d
1 parent 84add0a commit 3765365

File tree

6 files changed

+16
-9
lines changed

6 files changed

+16
-9
lines changed

src/sextante/grass/GrassUtils.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ def grassPath():
5454
def grassHelpPath():
5555
folder = SextanteConfig.getSetting(GrassUtils.GRASS_HELP_FOLDER)
5656
if folder == None:
57-
folder =""
57+
folder = os.path.join(GrassUtils.grassPath(), "docs", "html")
5858

5959
return folder
6060

src/sextante/gui/ParametersDialog.py

+1
Original file line numberDiff line numberDiff line change
@@ -171,6 +171,7 @@ def getWidgetFromParameter(self, param):
171171
elif isinstance(param, ParameterSelection):
172172
item = QtGui.QComboBox()
173173
item.addItems(param.options)
174+
item.setCurrentIndex(param.default)
174175
elif isinstance(param, ParameterFixedTable):
175176
item = FixedTablePanel(param)
176177
elif isinstance(param, ParameterRange):

src/sextante/parameters/ParameterSelection.py

+6-2
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,12 @@
22

33
class ParameterSelection(Parameter):
44

5-
def __init__(self, name="", description="", options=[]):
5+
def __init__(self, name="", description="", options=[], default = 0):
66
self.name = name
77
self.description = description
88
self.options = options
99
self.value = None
10+
self.default = default
1011

1112
def setValue(self, n):
1213
try:
@@ -21,7 +22,10 @@ def getAsScriptCode(self):
2122

2223
def deserialize(self, s):
2324
tokens = s.split("|")
24-
return ParameterSelection(tokens[0], tokens[1], tokens[2].split(";"))
25+
if len(tokens) == 4:
26+
return ParameterSelection(tokens[0], tokens[1], tokens[2].split(";"), int(tokens[3]))
27+
else:
28+
return ParameterSelection(tokens[0], tokens[1], tokens[2].split(";"))
2529

2630
def serialize(self):
2731
return self.__module__.split(".")[-1] + "|" + self.name + "|" + self.description +\

src/sextante/saga/description/Slope,Aspect,Curvature.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
Slope, Aspect, Curvature
22
ta_morphometry
33
ParameterRaster|ELEVATION|Elevation|False
4-
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)
4+
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
55
OutputRaster|SLOPE|Slope
66
OutputRaster|ASPECT|Aspect
77
OutputRaster|CURV|Curvature

src/sextante/script/DeleteScriptAction.py

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
from sextante.script.ScriptAlgorithm import ScriptAlgorithm
22
from sextante.gui.ContextAction import ContextAction
3+
import os
34

45
class DeleteScriptAction(ContextAction):
56

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

1213
def execute(self, alg):
13-
pass
14+
os.remove(self.alg.descriptionFile)
15+
self.toolbox.updateTree()

src/sextante/script/ScriptAlgorithm.py

+4-4
Original file line numberDiff line numberDiff line change
@@ -104,10 +104,10 @@ def processParameterLine(self,line):
104104
out = OutputTable()
105105
elif tokens[1].lower().strip().startswith("output html"):
106106
out = OutputHTML()
107-
elif tokens[1].lower().strip().startswith("output number"):
108-
out = OutputNumber()
109-
110-
107+
#=======================================================================
108+
# elif tokens[1].lower().strip().startswith("output number"):
109+
# out = OutputNumber()
110+
#=======================================================================
111111

112112
if param != None:
113113
self.addParameter(param)

0 commit comments

Comments
 (0)