Skip to content

Commit

Permalink
added r histogram script
Browse files Browse the repository at this point in the history
fixed bug in r script editor
fixed bug in modeler when using lagorithms with optional raster layers

git-svn-id: http://sextante.googlecode.com/svn/trunk/soft/bindings/qgis-plugin@178 881b9c09-3ef8-f3c2-ec3d-21d735c97f4d
  • Loading branch information
volayaf committed May 9, 2012
1 parent 6d6331d commit a8651bc
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 6 deletions.
3 changes: 1 addition & 2 deletions src/sextante/modeler/ModelerAlgorithm.py
Expand Up @@ -281,8 +281,7 @@ def getAsPythonCode(self):
aap = self.algParameters[i][param.name]
if aap == None:
runline += ", None"

if isinstance(param, ParameterMultipleInput):
elif isinstance(param, ParameterMultipleInput):
value = self.paramValues[aap.param]
tokens = value.split(";")
layerslist = []
Expand Down
8 changes: 5 additions & 3 deletions src/sextante/r/EditRScriptDialog.py
Expand Up @@ -12,9 +12,11 @@ def __init__(self, alg):
self.setModal(True)
self.setupUi()
self.update = False
self.help = None

def setupUi(self):
self.setWindowTitle("Edit script")
self.resize(600, 350)
layout = QVBoxLayout()
self.text = QtGui.QTextEdit()
self.text.setObjectName("text")
Expand Down Expand Up @@ -48,20 +50,20 @@ def saveAlgorithm(self):
filename = QtGui.QFileDialog.getSaveFileName(self, "Save Script", RUtils.RScriptsFolder(), "R-SEXTANTE scripts (*.rsx)")

if filename:
self.alg.descriptionFile = filename
#self.alg.descriptionFile = filename
text = self.text.toPlainText()
fout = open(filename, "w")
fout.write(text)
fout.close()
self.update = True
#if help strings were defined before saving the model for the first time, we do it here
if self.help:
f = open(self.alg.descriptionFile + ".help", "wb")
f = open(filename + ".help", "wb")
pickle.dump(self.help, f)
f.close()
self.help = None
QtGui.QMessageBox.information(self, "Script saving", "Script was correctly saved.")
#self.close()
self.close()

def cancelPressed(self):
self.update = False
Expand Down
2 changes: 1 addition & 1 deletion src/sextante/r/RAlgorithm.py
Expand Up @@ -213,7 +213,7 @@ def getImportCommands(self):
if isinstance(param, ParameterRaster):
value = param.value
value = value.replace("\\", "/")
commands.append(param.name + " = " + "readGDAL(\"" + value + "\"")
commands.append(param.name + " = " + "readGDAL(\"" + value + "\")")
if isinstance(param, ParameterVector):
value = param.getSafeExportedLayer()
value = value.replace("\\", "/")
Expand Down
3 changes: 3 additions & 0 deletions src/sextante/r/scripts/Raster_histogram.rsx
@@ -0,0 +1,3 @@
##layer = raster
##showplots
hist(as.matrix(layer))

0 comments on commit a8651bc

Please sign in to comment.