Skip to content
Permalink
Browse files
added "advanced parameters" button in parameters panel
git-svn-id: http://sextante.googlecode.com/svn/trunk/soft/bindings/qgis-plugin@158 881b9c09-3ef8-f3c2-ec3d-21d735c97f4d
  • Loading branch information
volayaf committed Apr 26, 2012
1 parent ce5b309 commit 4e62f7c32e68a6f0f94bdcab76325a98895a8dae
@@ -43,7 +43,7 @@ def processAlgorithm(self, progress):
else:
if not crsA != crsB:
SextanteLog.addToLog(SextanteLog.LOG_WARNING, "Union. Non-matching CRSs. Results might be unexpected")
fields = ftools_utils.combineVectorFields( self.vlayerA, self.vlayerB )
fields = ftools_utils.combineVectorFields(vlayerA, vlayerB )
longNames = ftools_utils.checkFieldNameLength( fields )
if not longNames.isEmpty():
raise GeoAlgorithmExecutionException("Following field names are longer than 10 characters:\n" + longNames.join('\n') )
@@ -79,6 +79,10 @@ def defineCharacteristicsFromFile(self):
line = line.strip("\n").strip()
if line.startswith("Parameter"):
self.addParameter(ParameterFactory.getFromString(line))
elif line.startswith("*Parameter"):
param = ParameterFactory.getFromString(line[1:])
param.isAdvanced = True
self.addParameter(param)
else:
self.addOutput(OutputFactory.getFromString(line))
line = lines.readline().strip("\n").strip()
@@ -34,9 +34,11 @@ def __init__(self, alg, paramDialog):
self.alg = alg;
self.paramDialog = paramDialog
self.valueItems = {}
self.labels = {}
self.widgets = {}
self.dependentItems = {}
self.iterateButtons = {}

self.showAdvanced = False
self.initGUI()

def initGUI(self):
@@ -63,11 +65,20 @@ def initGUI(self):
self.verticalLayout = QtGui.QVBoxLayout()
self.verticalLayout.setSpacing(5)
self.verticalLayout.setMargin(20)
for param in self.alg.parameters:
if param.isAdvanced:
self.advancedButton = QtGui.QPushButton()
self.advancedButton.setText("Show advanced parameters")
self.advancedButton.setMaximumWidth(150)
QtCore.QObject.connect(self.advancedButton, QtCore.SIGNAL("clicked()"), self.showAdvancedParametersClicked)
self.verticalLayout.addWidget(self.advancedButton)
break
for param in self.alg.parameters:
desc = param.description
if isinstance(param, ParameterExtent):
desc += "(xmin, xmax, ymin, ymax)"
label = QtGui.QLabel(desc)
self.labels[param.name] = label
widget = self.getWidgetFromParameter(param)
self.valueItems[param.name] = widget
if isinstance(param, ParameterVector):
@@ -93,6 +104,10 @@ def initGUI(self):
tooltip = param.description
label.setToolTip(tooltip)
widget.setToolTip(tooltip)
if param.isAdvanced:
label.setVisible(self.showAdvanced)
widget.setVisible(self.showAdvanced)
self.widgets[param.name] = widget
self.verticalLayout.addWidget(label)
self.verticalLayout.addWidget(widget)

@@ -108,6 +123,17 @@ def initGUI(self):
self.verticalLayout.addStretch(1000)
self.setLayout(self.verticalLayout)

def showAdvancedParametersClicked(self):
self.showAdvanced = not self.showAdvanced
if self.showAdvanced:
self.advancedButton.setText("Hide advanced parameters")
else:
self.advancedButton.setText("Show advanced parameters")
for param in self.alg.parameters:
if param.isAdvanced:
self.labels[param.name].setVisible(self.showAdvanced)
self.widgets[param.name].setVisible(self.showAdvanced)

def buttonToggled(self, value):
if value:
sender = self.sender()
@@ -6,6 +6,9 @@ def __init__(self, name="", description=""):
self.description = description
self.value = None

#this is not used yet
self.isAdvanced = False


def setValue(self, obj):
'''sets the value of the parameter.
@@ -3,8 +3,7 @@
class ParameterBoolean(Parameter):

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

@@ -4,8 +4,7 @@ class ParameterCrs(Parameter):

def __init__(self, name="", description="", default = "4326"):
'''The values is the EPSG code of the CRS'''
self.name = name
self.description = description
Parameter.__init__(self, name, description)
self.value = None
self.default = default

@@ -1,9 +1,9 @@
from sextante.parameters.Parameter import Parameter

class ParameterExtent(Parameter):

def __init__(self, name="", description="", default="0,1,0,1"):
self.name = name
self.description = description
Parameter.__init__(self, name, description)
self.default = default
self.value = None #The value is a string in the form "xmin, xmax, ymin, y max"

@@ -3,8 +3,7 @@
class ParameterFile(Parameter):

def __init__(self, name="", description="", isFolder = False):
self.name = name
self.description = description
Parameter.__init__(self, name, description)
self.value = None
self.isFolder = isFolder

@@ -1,14 +1,12 @@
from sextante.parameters.Parameter import Parameter
from PyQt4 import QtGui

class ParameterFixedTable(Parameter):

def __init__(self, name="", description="", cols=["value"], numRows=3, fixedNumOfRows = False):
Parameter.__init__(self, name, description)
self.cols = cols
self.numRows = numRows
self.fixedNumOfRows = fixedNumOfRows
self.name = name
self.description = description
self.value = None

def setValue(self, obj):
@@ -18,8 +18,7 @@ class ParameterMultipleInput(ParameterDataObject):
TYPE_RASTER = 3

def __init__(self, name="", description="", datatype=-1, optional = False):
self.name = name
self.description = description
ParameterDataObject.__init__(self, name, description)
self.datatype = datatype
self.optional = optional
self.value = None
@@ -4,8 +4,7 @@
class ParameterNumber(Parameter):

def __init__(self, name="", description="", minValue = None, maxValue = None, default = 0):
self.name = name
self.description = description
Parameter.__init__(self, name, description)
'''if the passed value is an int or looks like one, then we assume that float values
are not allowed'''
try:
@@ -3,8 +3,7 @@
class ParameterRange(Parameter):

def __init__(self, name="", description="", default="0,1"):
self.name = name
self.description = description
Parameter.__init__(self, name, description)
self.default = default
self.value = None

@@ -6,8 +6,7 @@
class ParameterRaster(ParameterDataObject):

def __init__(self, name="", description="", optional=False):
self.name = name
self.description = description
ParameterDataObject.__init__(self, name, description)
self.optional = optional
self.value = None
self.exported = None
@@ -3,8 +3,7 @@
class ParameterSelection(Parameter):

def __init__(self, name="", description="", options=[], default = 0):
self.name = name
self.description = description
Parameter.__init__(self, name, description)
self.options = options
self.value = None
self.default = default
@@ -3,8 +3,7 @@
class ParameterString(Parameter):

def __init__(self, name="", description="", default=""):
self.name = name
self.description = description
Parameter.__init__(self, name, description)
self.default = default
self.value = None

@@ -5,8 +5,7 @@
class ParameterTable(ParameterDataObject):

def __init__(self, name="", description="", optional=False):
self.name = name
self.description = description
ParameterDataObject.__init__(self, name, description)
self.optional = optional
self.value = None

@@ -3,8 +3,7 @@
class ParameterTableField(Parameter):

def __init__(self, name="", description="", parent=None):
self.name = name
self.description = description
Parameter.__init__(self, name, description)
self.parent = parent
self.value = None

@@ -11,8 +11,7 @@ class ParameterVector(ParameterDataObject):
VECTOR_TYPE_ANY = -1

def __init__(self, name="", description="", shapetype=-1, optional=False):
self.name = name
self.description = description
ParameterDataObject.__init__(self, name, description)
self.optional = optional
self.shapetype = shapetype
self.value = None

0 comments on commit 4e62f7c

Please sign in to comment.