2 changes: 1 addition & 1 deletion python/plugins/processing/core/GeoAlgorithm.py
Original file line number Diff line number Diff line change
Expand Up @@ -322,7 +322,7 @@ def setParameterValue(self, paramName, value):
def setOutputValue(self, outputName, value):
for out in self.outputs:
if out.name == outputName:
out.value = value
out.setValue(value)

def getVisibleOutputsCount(self):
'''returns the number of non-hidden outputs'''
Expand Down
1 change: 0 additions & 1 deletion python/plugins/processing/core/LayerExporter.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@
from qgis.core import *
from PyQt4.QtCore import *
from PyQt4.QtGui import *
from processing.gdal.GdalUtils import GdalUtils

class LayerExporter():

Expand Down
6 changes: 1 addition & 5 deletions python/plugins/processing/core/ProcessingUtils.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,11 +61,7 @@ def tempFolder():
@staticmethod
def setTempOutput(out, alg):
ext = out.getDefaultFileExtension(alg)
validChars = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"
safeCmdName = ''.join(c for c in alg.commandLineName() if c in validChars)
uniqueSufix = str(uuid.uuid4()).replace("-","")
filename = ProcessingUtils.tempFolder() + os.sep + safeCmdName + uniqueSufix + "." + ext
out.value = filename
out.value = ProcessingUtils.getTempFilenameInTempFolder(out.name + "." + ext)

@staticmethod
def getTempFilename(ext):
Expand Down
20 changes: 14 additions & 6 deletions python/plugins/processing/gui/HelpEditionDialog.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
import pickle
from PyQt4.QtCore import *
from PyQt4.QtGui import *

from qgis.core import *
from processing.ui.ui_DlgHelpEdition import Ui_DlgHelpEdition

class HelpEditionDialog(QDialog, Ui_DlgHelpEdition):
Expand All @@ -38,8 +38,9 @@ class HelpEditionDialog(QDialog, Ui_DlgHelpEdition):

def __init__(self, alg):
QDialog.__init__(self)
self.setupUi(self)


self.setupUi(self)

self.alg = alg
self.descriptions = {}
if self.alg.descriptionFile is not None:
Expand All @@ -62,9 +63,16 @@ def reject(self):
def accept(self):
self.descriptions[self.currentName] = unicode(self.text.toPlainText())
if self.alg.descriptionFile is not None:
f = open(self.alg.descriptionFile + ".help", "wb")
pickle.dump(self.descriptions, f)
f.close()
try:
f = open(self.alg.descriptionFile + ".help", "wb")
pickle.dump(self.descriptions, f)
f.close()
except Exception, e:
QMessageBox.warning(self, "Error saving help file",
"Help file could not be saved."
"\nCheck that you have permission to modify the help file.\n"
"You might not have permission if you are editing an example\n"
"model or script, since they are stored on the installation folder")
QDialog.accept(self)

def getHtml(self):
Expand Down
1 change: 0 additions & 1 deletion python/plugins/processing/modeler/ModelerDialog.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@
from processing.core.ProcessingConfig import ProcessingConfig
from processing.core.GeoAlgorithm import GeoAlgorithm
from processing.gui.AlgorithmClassification import AlgorithmDecorator
#from processing.gui.ProcessingToolbox import ProcessingToolbox
from processing.modeler.ModelerParameterDefinitionDialog import ModelerParameterDefinitionDialog
from processing.modeler.ModelerAlgorithm import ModelerAlgorithm
from processing.modeler.ModelerParametersDialog import ModelerParametersDialog
Expand Down
19 changes: 18 additions & 1 deletion python/plugins/processing/modeler/ModelerParametersDialog.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
* *
***************************************************************************
"""
from processing.outputs.OutputExtent import OutputExtent

__author__ = 'Victor Olaya'
__date__ = 'August 2012'
Expand Down Expand Up @@ -282,7 +283,23 @@ def getExtents(self):
params = self.model.parameters
for param in params:
if isinstance(param, ParameterExtent):
extents.append(AlgorithmAndParameter(AlgorithmAndParameter.PARENT_MODEL_ALGORITHM, param.name, "", param.description))
extents.append(AlgorithmAndParameter(AlgorithmAndParameter.PARENT_MODEL_ALGORITHM, param.name, "", param.description))


if self.algIndex is None:
dependent = []
else:
dependent = self.model.getDependentAlgorithms(self.algIndex)
#dependent.append(self.algIndex)

i=0
for alg in self.model.algs:
if i not in dependent:
for out in alg.outputs:
if isinstance(out, OutputExtent):
extents.append(AlgorithmAndParameter(i, out.name, alg.name, out.description))
i+=1

return extents

def getNumbers(self):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
* *
***************************************************************************
"""
from processing.outputs.OutputExtent import OutputExtent
__author__ = 'Victor Olaya'
__date__ = 'January 2013'
__copyright__ = '(C) 2012, Victor Olaya'
Expand All @@ -34,6 +35,7 @@ class VectorLayerBoundsAlgorithm(GeoAlgorithm):
XMAX = "XMAX"
YMIN = "YMIN"
YMAX = "YMAX"
EXTENT = "EXTENT"

def defineCharacteristics(self):
self.showInModeler = True
Expand All @@ -45,6 +47,7 @@ def defineCharacteristics(self):
self.addOutput(OutputNumber(self.XMAX, "max X"))
self.addOutput(OutputNumber(self.YMIN, "min Y"))
self.addOutput(OutputNumber(self.YMAX, "max Y"))
self.addOutput(OutputExtent(self.EXTENT, "Extent"))

def processAlgorithm(self, progress):
uri = self.getParameterValue(self.LAYER)
Expand All @@ -53,4 +56,6 @@ def processAlgorithm(self, progress):
self.setOutputValue(self.XMAX, layer.extent().xMaximum())
self.setOutputValue(self.YMIN, layer.extent().yMinimum())
self.setOutputValue(self.YMAX, layer.extent().yMaximum())
self.setOutputValue(self.EXTENT,
(layer.extent().xMinimum(), layer.extent().xMaximum(), layer.extent().yMinimum(), layer.extent().yMaximum()))

44 changes: 44 additions & 0 deletions python/plugins/processing/outputs/OutputExtent.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
# -*- coding: utf-8 -*-

"""
***************************************************************************
OutputNumber.py
---------------------
Date : August 2012
Copyright : (C) 2012 by Victor Olaya
Email : volayaf at gmail dot com
***************************************************************************
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
***************************************************************************
"""

__author__ = 'Victor Olaya'
__date__ = 'August 2012'
__copyright__ = '(C) 2012, Victor Olaya'
# This will get replaced with a git SHA1 when you do a git archive
__revision__ = '$Format:%H$'

from processing.outputs.Output import Output

class OutputExtent(Output):

def __init__(self, name="", description=""):
self.name = name
self.description = description
self.value = None
self.hidden = True

def setValue(self, value):
try:
if value != None and isinstance(value, basestring):
value = value.strip()
else:
self.value = ",".join([str(v) for v in value])
return True
except:
return False
2 changes: 1 addition & 1 deletion python/plugins/processing/outputs/OutputRaster.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,6 @@ def getCompatibleFileName(self, alg):
return self.value
else:
if self.compatible is None:
self.compatible = ProcessingUtils.getTempFilename(self.getDefaultFileExtension(alg))
self.compatible = ProcessingUtils.getTempFilenameInTempFolder(self.name + "." + self.getDefaultFileExtension(alg))
return self.compatible;

2 changes: 1 addition & 1 deletion python/plugins/processing/outputs/OutputTable.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ def getCompatibleFileName(self, alg):
return self.value
else:
if self.compatible is None:
self.compatible = ProcessingUtils.getTempFilename(self.getDefaultFileExtension(alg))
self.compatible = ProcessingUtils.getTempFilenameInTempFolder(self.name + "." + self.getDefaultFileExtension(alg))
return self.compatible;

def getTableWriter(self, fields):
Expand Down
2 changes: 1 addition & 1 deletion python/plugins/processing/outputs/OutputVector.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ def getCompatibleFileName(self, alg):
return self.value
else:
if self.compatible is None:
self.compatible = ProcessingUtils.getTempFilename(self.getDefaultFileExtension(alg))
self.compatible = ProcessingUtils.getTempFilenameInTempFolder(self.name + "." + self.getDefaultFileExtension(alg))
return self.compatible;


Expand Down
51 changes: 40 additions & 11 deletions python/plugins/processing/r/EditRScriptDialog.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,22 +16,20 @@
* *
***************************************************************************
"""
from processing.gui.ParametersDialog import ParametersDialog
from processing.core.QGisLayers import QGisLayers
from processing.modeler.Providers import Providers

__author__ = 'Victor Olaya'
__date__ = 'August 2012'
__copyright__ = '(C) 2012, Victor Olaya'
# This will get replaced with a git SHA1 when you do a git archive
__revision__ = '$Format:%H$'

import sys

from PyQt4 import QtCore, QtGui
from PyQt4.QtCore import *
from PyQt4.QtGui import *
from processing.gui.HelpEditionDialog import HelpEditionDialog
from processing.gui.ParametersDialog import ParametersDialog
from processing.core.QGisLayers import QGisLayers
from processing.modeler.Providers import Providers
import pickle
from processing.r.RAlgorithm import RAlgorithm
from processing.r.RUtils import RUtils
Expand All @@ -51,11 +49,11 @@ def __init__(self, alg):

def setupUi(self):
self.resize(600,400)
self.setWindowFlags(self.windowFlags() | Qt.WindowSystemMenuHint |
Qt.WindowMinMaxButtonsHint)
self.setWindowTitle("Edit script")
layout = QVBoxLayout()
self.text = QtGui.QTextEdit()
self.text.setObjectName("text")
self.text.setEnabled(True)
self.text = ScriptEditorWidget(self.alg.script if self.alg is not None else "")
self.buttonBox = QtGui.QDialogButtonBox()
self.buttonBox.setOrientation(QtCore.Qt.Horizontal)
if self.alg != None:
Expand Down Expand Up @@ -83,7 +81,7 @@ def setupUi(self):

def editHelp(self):
if self.alg is None:
alg = RAlgorithm(None, unicode(self.text.toPlainText()))
alg = RAlgorithm(None, unicode(self.text.text()))
else:
alg = self.alg
dlg = HelpEditionDialog(alg)
Expand All @@ -94,7 +92,7 @@ def editHelp(self):
self.help = dlg.descriptions

def runAlgorithm(self):
alg = RAlgorithm(None, unicode(self.text.toPlainText()))
alg = RAlgorithm(None, unicode(self.text.text()))
alg.provider = Providers.providers['r']
dlg = alg.getCustomParametersDialog()
if not dlg:
Expand All @@ -117,7 +115,7 @@ def saveAlgorithm(self):
if self.filename:
if not self.filename.endswith(".rsx"):
self.filename += ".rsx"
text = str(self.text.toPlainText())
text = str(self.text.text())
if self.alg is not None:
self.alg.script = text
try:
Expand All @@ -144,3 +142,34 @@ def saveAlgorithm(self):
def cancelPressed(self):
#self.update = False
self.close()

from PyQt4.Qsci import QsciScintilla

class ScriptEditorWidget(QsciScintilla):
ARROW_MARKER_NUM = 8

def __init__(self, text, parent=None):
super(ScriptEditorWidget, self).__init__(parent)

font = QFont()
font.setFamily('Courier')
font.setFixedPitch(True)
font.setPointSize(10)
self.setFont(font)
self.setMarginsFont(font)

fontmetrics = QFontMetrics(font)
self.setMarginsFont(font)
self.setMarginWidth(0, fontmetrics.width("00000") + 6)
self.setMarginLineNumbers(0, True)
self.setMarginsBackgroundColor(QColor("#cccccc"))

self.setBraceMatching(QsciScintilla.SloppyBraceMatch)

self.setCaretLineVisible(True)
self.setCaretLineBackgroundColor(QColor("#ffe4e4"))

self.SendScintilla(QsciScintilla.SCI_STYLESETFONT, 1, 'Courier')

self.setText(text)

23 changes: 17 additions & 6 deletions python/plugins/processing/saga/SagaAlgorithm.py
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,7 @@ def processAlgorithm(self, progress):
filename = LayerExporter.exportVectorLayer(layer)
self.exportedLayers[param.value]=filename
elif not param.value.endswith("shp"):
raise GeoAlgorithmExecutionException("Unsupported file format")
raise GeoAlgorithmExecutionException("Unsupported file format")
if isinstance(param, ParameterTable):
if param.value == None:
continue
Expand Down Expand Up @@ -378,14 +378,25 @@ def resampleRasterLayer(self,layer):
return s


def exportRasterLayer(self, layer):
destFilename = ProcessingUtils.getTempFilenameInTempFolder(os.path.basename(layer)[0:5] + ".sgrd")
self.exportedLayers[layer]= destFilename
def exportRasterLayer(self, source):
layer = QGisLayers.getObjectFromUri(source, False)
if layer:
filename = str(layer.name())
else:
filename = source.rstrip(".sgrd")
validChars = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789:"
filename = ''.join(c for c in filename if c in validChars)
if len(filename) == 0:
filename = "layer"
destFilename = ProcessingUtils.getTempFilenameInTempFolder(filename + ".sgrd")
self.exportedLayers[source]= destFilename
saga208 = ProcessingConfig.getSetting(SagaUtils.SAGA_208)
if ProcessingUtils.isWindows() or ProcessingUtils.isMac() or not saga208:
return "io_gdal 0 -GRIDS \"" + destFilename + "\" -FILES \"" + layer+"\""
return "io_gdal 0 -GRIDS \"" + destFilename + "\" -FILES \"" + source+"\""
else:
return "libio_gdal 0 -GRIDS \"" + destFilename + "\" -FILES \"" + layer + "\""
return "libio_gdal 0 -GRIDS \"" + destFilename + "\" -FILES \"" + source + "\""




def checkBeforeOpeningParametersDialog(self):
Expand Down
4 changes: 2 additions & 2 deletions python/plugins/processing/saga/SagaUtils.py
Original file line number Diff line number Diff line change
Expand Up @@ -149,8 +149,8 @@ def checkSagaIsInstalled(ignoreRegistrySettings=False):

try:
from processing import runalg
result = runalg("saga:thiessenpolygons", points(), None)
if not os.path.exists(result['POLYGONS']):
result = runalg("saga:polygoncentroids", points(), False, None)
if result is None or not os.path.exists(result['CENTROIDS']):
return "It seems that SAGA is not correctly installed in your system.\nPlease install it before running SAGA algorithms."
except:
s = traceback.format_exc()
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
Inverse Distance Weighted
grid_gridding
ParameterVector|SHAPES|Points|0|False
ParameterTableField|FIELD|Attribute|SHAPES|-1|False
ParameterSelection|TARGET|Target Grid|[0] user defined
ParameterSelection|WEIGHTING|Distance Weighting|[0] inverse distance to a power;[1] linearly decreasing within search radius;[2] exponential weighting scheme;[3] gaussian weighting scheme
ParameterNumber|WEIGHT_POWER|Inverse Distance Power|0.0|None|2
ParameterNumber|WEIGHT_BANDWIDTH|Exponential and Gaussian Weighting Bandwidth|0.0|None|1
ParameterSelection|SEARCH_RANGE|Search Range|[0] search radius (local);[1] no search radius (global)
ParameterNumber|SEARCH_RADIUS|Search Radius|None|None|100.0
ParameterSelection|SEARCH_DIRECTION|Search Mode|[0] all directions;[1] quadrants
ParameterSelection|SEARCH_POINTS_ALL|Number of Points|[0] maximum number of nearest points;[1] all points
ParameterNumber|SEARCH_POINTS_MAX|Maximum Number of Points|None|None|10
Extent USER_XMIN USER_XMAX USER_YMIN USER_YMAX
ParameterNumber|USER_SIZE|Cellsize|None|None|100.0
OutputRaster|USER_GRID|Grid
Loading