Skip to content
Permalink
Browse files
[sextante] improved handling of ParameterCrs
  • Loading branch information
volaya committed Feb 24, 2013
1 parent 7e1f58f commit 10999cfa0e6af0be2a53b7322471f41bc4dcd216
@@ -29,7 +29,7 @@
class CrsSelectionPanel(QtGui.QWidget):

def __init__(self, default):
super(CrsSelectionPanel, self).__init__(None)
super(CrsSelectionPanel, self).__init__(None)
self.authid = default
self.horizontalLayout = QtGui.QHBoxLayout(self)
self.horizontalLayout.setSpacing(2)
@@ -44,6 +44,10 @@ def __init__(self, default):
self.horizontalLayout.addWidget(self.pushButton)
self.setLayout(self.horizontalLayout)
self.setText()

def setAuthid(self, authid):
self.authid = authid
self.setText()

def showSelectionDialog(self):
dialog = CrsSelectionDialog()
@@ -53,7 +57,8 @@ def showSelectionDialog(self):
self.setText()

def setText(self):
self.text.setText(str(self.authid))
if self.authid is not None:
self.text.setText(str(self.authid))

def getValue(self):
return self.authid
@@ -128,7 +128,6 @@ def openModel(self, filename):
elif line.startswith("VALUE:"):
valueLine = line[len("VALUE:"):]
tokens = valueLine.split("===")

self.paramValues[tokens[0]] = tokens[1].replace(ModelerAlgorithm.LINE_BREAK_STRING, '\n')
elif line.startswith("NAME:"):
self.name = line[len("NAME:"):]
@@ -221,7 +220,7 @@ def removeAlgorithm(self, index):
for paramValues in self.algParameters:
index += 1
newValues = []
for name, value in paramValues:
for name, value in paramValues[index]:
if value:
if value.alg > index:
newValues[name] = AlgorithmAndParameter(value.alg - 1, value.param, value.algName, value.paramName)
@@ -16,7 +16,7 @@
* *
***************************************************************************
"""
from sextante.modeler.MultilineTextPanel import MultilineTextPanel

__author__ = 'Victor Olaya'
__date__ = 'August 2012'
__copyright__ = '(C) 2012, Victor Olaya'
@@ -26,6 +26,8 @@
from PyQt4.QtCore import *
from PyQt4.QtGui import *
from PyQt4 import QtCore, QtGui, QtWebKit
from sextante.modeler.MultilineTextPanel import MultilineTextPanel
from sextante.gui.CrsSelectionPanel import CrsSelectionPanel
from sextante.parameters.ParameterCrs import ParameterCrs
from sextante.outputs.OutputString import OutputString
from sextante.parameters.ParameterRaster import ParameterRaster
@@ -437,6 +439,8 @@ def getWidgetFromParameter(self, param):
for n in numbers:
item.addItem(n.name(), n)
item.setEditText(str(param.default))
elif isinstance(param, ParameterCrs):
item = CrsSelectionPanel(param.default)
elif isinstance(param, ParameterExtent):
item = QtGui.QComboBox()
item.setEditable(True)
@@ -548,7 +552,7 @@ def setPreviousValues(self):
self.setComboBoxValue(widget, value, param)
elif isinstance(param, ParameterCrs):
value = self.model.getValueFromAlgorithmAndParameter(value)
widget.setText(unicode(value))
widget.setAuthid(value)
elif isinstance(param, ParameterFixedTable):
pass
elif isinstance(param, ParameterMultipleInput):
@@ -766,6 +770,16 @@ def setParamValue(self, param, widget):
self.params[param.name] = value
self.values[name] = str(widget.getValue())
return True
elif isinstance(param, ParameterCrs):
authid = widget.getValue()
if authid is None:
self.params[param.name] = None
else:
name = self.getSafeNameForHarcodedParameter(param)
value = AlgorithmAndParameter(AlgorithmAndParameter.PARENT_MODEL_ALGORITHM, name)
self.params[param.name] = value
self.values[name] = authid
return True
elif isinstance(param, ParameterFixedTable):
name = self.getSafeNameForHarcodedParameter(param)
value = AlgorithmAndParameter(AlgorithmAndParameter.PARENT_MODEL_ALGORITHM, name)
@@ -37,6 +37,7 @@ def setValue(self, value):
if value is None:
self.value = self.default
return True
#TODO: check it is a valid authid
self.value = str(value)
return True

@@ -48,7 +49,9 @@ def serialize(self):
"|" + str(self.default)

def deserialize(self, s):
tokens = s.split("|")
tokens = s.split("|")
if tokens[2]==str(None):
tokens[2] = None
return ParameterCrs(tokens[0], tokens[1], tokens[2])

def getAsScriptCode(self):

0 comments on commit 10999cf

Please sign in to comment.