Skip to content
Permalink
Browse files
Added diferentiation between int and float values
extent selector more or less working now
changed version to 1.0.3

git-svn-id: http://sextante.googlecode.com/svn/trunk/soft/bindings/qgis-plugin@86 881b9c09-3ef8-f3c2-ec3d-21d735c97f4d
  • Loading branch information
volayaf@gmail.com committed Apr 13, 2012
1 parent 8c83e7f commit 00c4ba3d892fbb6c10815b47a8a05f224590c575
@@ -5,7 +5,7 @@ def name():
def description():
return "SEXTANTE Geoprocessing platform for QGIS"
def version():
return "Version 1.0.2"
return "Version 1.0.3"
def icon():
return "icon.png"
def qgisMinimumVersion():
@@ -19,8 +19,8 @@ def getIcon(self):
return QtGui.QIcon(filepath)

def defineCharacteristics(self):
self.name = "rgb2pct"
self.group = "Conversion"
self.name = "merge"
self.group = "Miscellaneous"
self.addParameter(ParameterMultipleInput(merge.INPUT, "Input layers", ParameterMultipleInput.TYPE_RASTER))
self.addParameter(ParameterBoolean(merge.PCT, "Grab pseudocolor table from first layer", False))
self.addParameter(ParameterBoolean(merge.SEPARATE, "Layer stack", False))
@@ -42,7 +42,17 @@ def buttonPushed(self):
popupmenu.exec_(QtGui.QCursor.pos())

def useLayerExtent(self):
pass
extentsDict = {}
extentsDict["[Canvas]"] = QGisLayers.iface.mapCanvas().extent()
extents = ["[Canvas]"]
layers = QGisLayers.getAllLayers()
for layer in layers:
extents.append(layer.name())
extentsDict[str(layer.name())] = layer.extent()
item, ok = QtGui.QInputDialog.getItem(self, "Select extent", "Use extent from", extents, False)
if ok:
item = str(item)
self.setValueFromRect(extentsDict[item])

def selectOnCanvas(self):
canvas = QGisLayers.iface.mapCanvas()
@@ -51,6 +61,9 @@ def selectOnCanvas(self):

def fillCoords(self):
r = self.tool.rectangle()
self.setValueFromRect(r)

def setValueFromRect(self,r):
s = str(r.xMinimum()) + "," + str(r.xMaximum()) + "," + str(r.yMinimum()) + "," + str(r.yMaximum())
self.text.setText(s)
self.tool.reset()
@@ -3,24 +3,33 @@

class NumberInputPanel(QtGui.QWidget):

def __init__(self, number, parent = None):
super(NumberInputPanel, self).__init__(parent)
def __init__(self, number, isInteger):
super(NumberInputPanel, self).__init__(None)
self.setObjectName("NIPanel")
self.horizontalLayout = QtGui.QHBoxLayout(self)
self.horizontalLayout.setSpacing(2)
self.horizontalLayout.setMargin(0)
self.horizontalLayout.setObjectName("hLayout")
self.text = QtGui.QLineEdit()
self.text.setObjectName("linedit")
self.text.setText(str(number))
self.text.setSizePolicy(QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Expanding)
self.horizontalLayout.addWidget(self.text)
self.pushButton = QtGui.QPushButton()
self.pushButton.setObjectName("pushButton")
self.pushButton.setText("...")
self.pushButton.clicked.connect(self.showNumberInputDialog)
self.horizontalLayout.addWidget(self.pushButton)
self.setLayout(self.horizontalLayout)
self.isInteger = isInteger
if isInteger:
self.spin = QtGui.QSpinBox()
self.spin.setValue(number)
self.spin.setMaximum(100000)
self.spin.setMinimum(-100000)
self.horizontalLayout.addWidget(self.spin)
self.setLayout(self.horizontalLayout)
else:
self.text = QtGui.QLineEdit()
self.text.setObjectName("linedit")
self.text.setText(str(number))
self.text.setSizePolicy(QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Expanding)
self.horizontalLayout.addWidget(self.text)
self.pushButton = QtGui.QPushButton()
self.pushButton.setObjectName("pushButton")
self.pushButton.setText("...")
self.pushButton.clicked.connect(self.showNumberInputDialog)
self.horizontalLayout.addWidget(self.pushButton)
self.setLayout(self.horizontalLayout)

def showNumberInputDialog(self):
pass
@@ -30,4 +39,7 @@ def showNumberInputDialog(self):
self.text.setText(str(dlg.value))

def getValue(self):
return self.text.text()
if self.isInteger:
return self.spin.value()
else:
return self.text.text()
@@ -186,7 +186,7 @@ def getWidgetFromParameter(self, param):
opts.append(opt.name())
item = MultipleInputPanel(opts)
elif isinstance(param, ParameterNumber):
item = NumberInputPanel(param.default)
item = NumberInputPanel(param.default, param.isInteger)
elif isinstance(param, ParameterExtent):
item = ExtentSelectionPanel(self.dialog, param.default)
else:
@@ -8,7 +8,7 @@
[general]
name=SEXTANTE
description=SEXTANTE for QGIS
version=1.0.2
version=1.0.3
qgisMinimumVersion=1.0
class_name=SextantePlugin
website=www.sextantegis.com
@@ -6,7 +6,14 @@ class ParameterNumber(Parameter):
def __init__(self, name="", description="", minValue = None, maxValue = None, default = 0):
self.name = name
self.description = description
self.default = default
'''if the passed value is an int or looks like one, then we assume that float values
are not allowed'''
try:
self.default = int(str(default))
self.isInteger = True
except:
self.default = default
self.isInteger = False
self.min = minValue
self.max = maxValue
self.value = None
@@ -34,12 +41,18 @@ def serialize(self):

def deserialize(self, s):
tokens = s.split("|")
for i in range (2,5):
for i in range (2,4):
if tokens[i] == str(None):
tokens[i] = None
else:
tokens[i] = float(tokens[i])
return ParameterNumber(tokens[0], tokens[1], tokens[2], tokens[3], tokens[4])
'''we force the default to int if possible, since that indicates if it is restricted
to ints or not'''
try:
val = int(tokens[4])
except:
val = float(tokens[4])
return ParameterNumber(tokens[0], tokens[1], tokens[2], tokens[3], val)

def getAsScriptCode(self):
return "##" + self.name + "=number " + str(self.default)

0 comments on commit 00c4ba3

Please sign in to comment.