Skip to content

Commit ce52bb5

Browse files
author
volayaf
committed
fixed grass algorithms
fixed bug when using multiple layers in saga (#5652) git-svn-id: http://sextante.googlecode.com/svn/trunk/soft/bindings/qgis-plugin@198 881b9c09-3ef8-f3c2-ec3d-21d735c97f4d
1 parent d2c7008 commit ce52bb5

8 files changed

+108
-25
lines changed

src/sextante/grass/DefineGrassRegionAction.py

+3-1
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,10 @@ def fillCoords(self):
3232
SextanteConfig.setSettingValue(GrassUtils.GRASS_REGION_YMIN, r.yMinimum())
3333
SextanteConfig.setSettingValue(GrassUtils.GRASS_REGION_XMAX, r.xMaximum())
3434
SextanteConfig.setSettingValue(GrassUtils.GRASS_REGION_YMAX, r.yMaximum())
35+
SextanteConfig.setSettingValue(GrassUtils.GRASS_AUTO_REGION, False)
3536
s = str(r.xMinimum()) + "," + str(r.xMaximum()) + "," + str(r.yMinimum()) + "," + str(r.yMaximum())
3637
self.tool.reset()
3738
canvas = QGisLayers.iface.mapCanvas()
3839
canvas.setMapTool(self.prevMapTool)
39-
QtGui.QMessageBox.information(None, "GRASS Region", "GRASS region set to:\n" + s)
40+
QtGui.QMessageBox.information(None, "GRASS Region", "GRASS region set to:\n" + s + \
41+
"\nTo set the cellsize or set back the autoregion option,\ngo to the SEXTANTE configuration.")
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
v.to.rast
2+
v.to.rast.attribute
3+
Vector (v.*)
4+
ParameterVector|input|input|-1|False
5+
ParameterSelection|use|use|attr
6+
ParameterTableField|column|column|input
7+
OutputRaster|output|output

src/sextante/grass/description/v.to.rast.txt

-8
This file was deleted.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
v.to.rast
2+
v.to.rast.value
3+
Vector (v.*)
4+
ParameterVector|input|input|-1|False
5+
ParameterSelection|use|use|val
6+
ParameterNumber|value|value|None|None|1
7+
OutputRaster|output|output

src/sextante/gui/ConfigDialog.py

+10-7
Original file line numberDiff line numberDiff line change
@@ -41,11 +41,13 @@ def setupUi(self):
4141
self.buttonBox = QtGui.QDialogButtonBox()
4242
self.buttonBox.setOrientation(QtCore.Qt.Horizontal)
4343
self.buttonBox.setStandardButtons(QtGui.QDialogButtonBox.Cancel|QtGui.QDialogButtonBox.Ok)
44-
if SextanteUtils.isWindows():
45-
self.externalAppsButton = QtGui.QPushButton()
46-
self.externalAppsButton.setText("Configure external apps")
47-
self.horizontalLayout.addWidget(self.externalAppsButton)
48-
QtCore.QObject.connect(self.buttonBox, QtCore.SIGNAL("clicked()"), self.configureExternalApps)
44+
#=======================================================================
45+
# if SextanteUtils.isWindows():
46+
# self.externalAppsButton = QtGui.QPushButton()
47+
# self.externalAppsButton.setText("Configure external apps")
48+
# self.horizontalLayout.addWidget(self.externalAppsButton)
49+
# QtCore.QObject.connect(self.externalAppsButton, QtCore.SIGNAL("clicked()"), self.configureExternalApps)
50+
#=======================================================================
4951
self.horizontalLayout.addSpacing(100)
5052
self.horizontalLayout.addWidget(self.buttonBox)
5153
self.verticalLayout.addLayout(self.horizontalLayout)
@@ -55,8 +57,9 @@ def setupUi(self):
5557
QtCore.QMetaObject.connectSlotsByName(self)
5658

5759
def configureExternalApps(self):
58-
ExternalAppsConfigurer.configure()
59-
#TODO find a way to automate
60+
configurer = ExternalAppsConfigurer()
61+
configurer.configure()
62+
6063

6164
def fillTree(self):
6265
self.items = {}
+33-5
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,38 @@
1+
import os
2+
from sextante.gui.InteractiveHTMLViewerDialog import InteractiveHTMLViewerDialog
13
class ExternalAppsConfigurer():
24

3-
@staticmethod
4-
def configure():
5+
def configure(self):
56
#TODO find a way of automating this, not having to add each provider here manually
7+
settings = {}
8+
folders = self.findFolder("c:\\","saga")
9+
settings["SAGA binaries folder"] = folders
10+
folders['SAGA'] = settings
611

7-
pass
12+
html = ""
13+
for key in settings.keys():
14+
html += self.createHTMLSection(settings[key], key)
815

9-
def folderFinder(self, s):
10-
pass
16+
dialog = InteractiveHTMLViewerDialog(html, self)
17+
dialog.exec_()
18+
19+
def findFolder(self, head, name):
20+
name = name.upper()
21+
found = []
22+
for root, dirs, files in os.walk(head):
23+
for d in dirs:
24+
if d.upper().endswith(name):
25+
found.append(os.path.join(root, d))
26+
return found
27+
28+
def createHTMLSection(self, settings, name):
29+
html = "<h2>" + name.upper() + "</h2>\n"
30+
html += "<ul>\n"
31+
for key, setting in settings.items():
32+
html += "<li>" + key + " : " + setting[0] + "</li>\n"
33+
if len(setting) > 1:
34+
html += "<ul>\n"
35+
for i in range(1, len(setting)):
36+
html += "<li><a href=\"" + key + "|" + str(i) + ">" + setting[i] + "</a></li>\n"
37+
html += "<ul>\n"
38+
html += "<ul>\n"
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
from PyQt4 import QtCore, QtGui, QtWebKit
2+
from PyQt4.QtCore import *
3+
from PyQt4.QtGui import *
4+
5+
class InteractiveHTMLViewerDialog(QtGui.QDialog):
6+
7+
def __init__(self, html, linkHandler):
8+
QtGui.QDialog.__init__(self)
9+
self.html = html
10+
self.linkHandler = linkHandler
11+
self.setModal(True)
12+
self.setupUi()
13+
14+
def setupUi(self):
15+
self.resize(600, 500)
16+
self.webView = QtWebKit.QWebView()
17+
self.webView.page().setLinkDelegationPolicy(QtWebKit.QWebPage.DelegateAllLinks)
18+
self.setWindowTitle("Help")
19+
self.closeButton = QtGui.QPushButton()
20+
self.closeButton.setText("Close")
21+
self.closeButton.setMaximumWidth(150)
22+
self.horizontalLayout= QtGui.QHBoxLayout()
23+
self.horizontalLayout.setSpacing(2)
24+
self.horizontalLayout.setMargin(0)
25+
self.horizontalLayout.addStretch(1000)
26+
self.horizontalLayout.addWidget(self.closeButton)
27+
self.verticalLayout= QtGui.QVBoxLayout()
28+
self.verticalLayout.setSpacing(2)
29+
self.verticalLayout.setMargin(0)
30+
self.verticalLayout.addWidget(self.webView)
31+
self.verticalLayout.addLayout(self.horizontalLayout)
32+
self.setLayout(self.verticalLayout)
33+
QObject.connect(self.closeButton, QtCore.SIGNAL("clicked()"), self.closeWindow)
34+
QObject.connect(self.webView, SIGNAL("linkClicked(const QUrl&)"), self.linkClicked)
35+
try:
36+
url = QtCore.QUrl(self.filename)
37+
self.webView.load(url)
38+
except:
39+
pass
40+
41+
def linkClicked(self, url):
42+
pass
43+
44+
45+
def closeWindow(self):
46+
self.close()

src/sextante/saga/SagaAlgorithm.py

+2-4
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
from sextante.core.LayerExporter import LayerExporter
2626
import subprocess
2727
from sextante.parameters.ParameterExtent import ParameterExtent
28+
from PyQt4 import QtGui
2829

2930
class SagaAlgorithm(GeoAlgorithm):
3031

@@ -192,7 +193,7 @@ def processAlgorithm(self, progress):
192193
layer = QGisLayers.getObjectFromUri(layerfile, False)
193194
if layer:
194195
filename = LayerExporter.exportVectorLayer(layer)
195-
self.exportedLayers[param.value]=filename
196+
self.exportedLayers[layerfile]=filename
196197
elif (not value.endswith("shp")):
197198
raise GeoAlgorithmExecutionException("Unsupported file format")
198199

@@ -228,9 +229,6 @@ def processAlgorithm(self, progress):
228229
else:
229230
command+=(" -" + param.name + " \"" + str(param.value) + "\"");
230231

231-
232-
233-
234232
for out in self.outputs:
235233
if isinstance(out, OutputRaster):
236234
filename = out.value

0 commit comments

Comments
 (0)