Skip to content

Commit

Permalink
[sextante] added autofilling on double-click in batch processing dialog
Browse files Browse the repository at this point in the history
Other minor changes
  • Loading branch information
volaya committed Feb 24, 2013
1 parent e394fc1 commit 724506d
Show file tree
Hide file tree
Showing 6 changed files with 55 additions and 7 deletions.
Expand Up @@ -41,7 +41,13 @@ def __init__(self):
AlgorithmProvider.__init__(self)
self.alglist = [ImportVectorIntoGeoServer(), ImportRasterIntoGeoServer(),
CreateWorkspace(), DeleteWorkspace(), DeleteDatastore(),
CreateStyleGeoServer(), ImportIntoPostGIS(), PostGISExecuteSQL()]#, TruncateSeedGWC()]
CreateStyleGeoServer()]

try:
self.alglist.append(ImportIntoPostGIS())
self.alglist.append(PostGISExecuteSQL())
except:
pass

def initializeSettings(self):
AlgorithmProvider.initializeSettings(self)
Expand Down
1 change: 0 additions & 1 deletion python/plugins/sextante/algs/PointsLayerFromTable.py
Expand Up @@ -18,7 +18,6 @@
"""
from sextante.parameters.ParameterTable import ParameterTable
from sextante.parameters.ParameterTableField import ParameterTableField
from sextante.core.SextanteLog import SextanteLog

__author__ = 'Victor Olaya'
__date__ = 'August 2013'
Expand Down
4 changes: 2 additions & 2 deletions python/plugins/sextante/core/Sextante.py
Expand Up @@ -270,14 +270,14 @@ def runAlgorithm(algOrName, onFinish, *args):
for param in alg.parameters:
if not param.hidden:
if not param.setValue(args[i]):
print ("Error: Wrong parameter value: " + args[i])
print ("Error: Wrong parameter value: " + unicode(args[i]))
return
i = i +1

for output in alg.outputs:
if not output.hidden:
if not output.setValue(args[i]):
print ("Error: Wrong output value: " + args[i])
print ("Error: Wrong output value: " + unicode(args[i]))
return
i = i +1

Expand Down
14 changes: 12 additions & 2 deletions python/plugins/sextante/gdal/warp.py
Expand Up @@ -23,15 +23,17 @@
# This will get replaced with a git SHA1 when you do a git archive
__revision__ = '$Format:%H$'

import os
from qgis.core import *
from PyQt4 import QtGui
from sextante.core.GeoAlgorithm import GeoAlgorithm
from sextante.parameters.ParameterRaster import ParameterRaster
from sextante.outputs.OutputRaster import OutputRaster
import os
from qgis.core import *
from sextante.parameters.ParameterSelection import ParameterSelection
from sextante.parameters.ParameterCrs import ParameterCrs
from sextante.gdal.GdalUtils import GdalUtils
from sextante.parameters.ParameterNumber import ParameterNumber
from sextante.parameters.ParameterString import ParameterString

class warp(GeoAlgorithm):

Expand All @@ -41,6 +43,8 @@ class warp(GeoAlgorithm):
DEST_SRS = "DEST_SRS "
METHOD = "METHOD"
METHOD_OPTIONS = ["near", "bilinear", "cubic", "cubicspline", "lanczos"]
TR = "TR"
EXTRA = "EXTRA"

def getIcon(self):
filepath = os.path.dirname(__file__) + "/icons/warp.png"
Expand All @@ -52,7 +56,9 @@ def defineCharacteristics(self):
self.addParameter(ParameterRaster(warp.INPUT, "Input layer", False))
self.addParameter(ParameterCrs(warp.SOURCE_SRS, "Source SRS (EPSG Code)", "EPSG:4326"))
self.addParameter(ParameterCrs(warp.DEST_SRS, "Destination SRS (EPSG Code)", "EPSG:4326"))
self.addParameter(ParameterNumber(warp.TR, "Output file resolution in target georeferenced units (leave 0 for no change)", 0.0, None, 0.0))
self.addParameter(ParameterSelection(warp.METHOD, "Resampling method", warp.METHOD_OPTIONS))
self.addParameter(ParameterString(warp.EXTRA, "Additional creation parameters", " "))
self.addOutput(OutputRaster(warp.OUTPUT, "Output layer"))

def processAlgorithm(self, progress):
Expand All @@ -68,6 +74,10 @@ def processAlgorithm(self, progress):
commands.append("-of")
out = self.getOutputValue(warp.OUTPUT)
commands.append(GdalUtils.getFormatShortNameFromFilename(out))
if self.getParameterValue(warp.TR) != 0:
trStr = "-tr "+str(self.getParameterValue(warp.TR))+" "+str(self.getParameterValue(warp.TR))
commands.append(trStr)
commands.append(str(self.getParameterValue(warp.EXTRA)))
commands.append(self.getParameterValue(warp.INPUT))
commands.append(out)

Expand Down
31 changes: 31 additions & 0 deletions python/plugins/sextante/gui/BatchProcessingDialog.py
Expand Up @@ -86,6 +86,37 @@ def __init__(self, alg):
self.table.setSizePolicy(QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Expanding)
self.addRowButton.clicked.connect(self.addRow)
self.deleteRowButton.clicked.connect(self.deleteRow)
self.table.horizontalHeader().sectionDoubleClicked.connect(self.headerDoubleClicked)


def headerDoubleClicked(self, col):
widget = self.table.cellWidget(0, col)
if isinstance(widget, QtGui.QComboBox):
widgetValue = widget.currentIndex()
for row in range(1, self.table.rowCount()):
self.table.cellWidget(row, col).setCurrentIndex(widgetValue)

elif isinstance(widget, ExtentSelectionPanel):
widgetValue = widget.getValue()
for row in range(1, self.table.rowCount()):
if widgetValue != None:
self.table.cellWidget(row, col).text.setText(widgetValue)
else:
self.table.cellWidget(row, col).text.setText("")

elif isinstance(widget, CrsSelectionPanel):
widgetValue = widget.getValue()
for row in range(1, self.table.rowCount()):
self.table.cellWidget(row, col).epsg = widgetValue
self.table.cellWidget(row, col).setText()

elif isinstance(widget, QtGui.QLineEdit):
widgetValue = widget.text()
for row in range(1, self.table.rowCount()):
self.table.cellWidget(row, col).setText(widgetValue)
else:
pass


def setTableContent(self):
i = 0
Expand Down
4 changes: 3 additions & 1 deletion python/plugins/sextante/r/RAlgorithm.py
Expand Up @@ -267,7 +267,9 @@ def getImportCommands(self):
# just use US mirror
commands.append('options("repos"="http://cran.us.r-project.org")')
rLibDir = "%s/rlibs" % SextanteUtils.userFolder().replace("\\","/")
if not os.path.isdir(rLibDir): os.mkdir(rLibDir)
if not os.path.isdir(rLibDir):
os.mkdir(rLibDir)
commands.append('.libPaths("%s")' % rLibDir )
commands.append(
'tryCatch(find.package("rgdal"), error=function(e) install.packages("rgdal", lib="%s"))' % rLibDir)
commands.append("library(\"rgdal\")");
Expand Down

0 comments on commit 724506d

Please sign in to comment.