Skip to content
Permalink
Browse files

Removed MultipleExternalInput parameter and made it a subtype of Mult…

…ipleInput
  • Loading branch information
volaya committed Apr 17, 2014
1 parent 54ce9a0 commit 674fee73b1bb0ffb27bb16940637627dd9435ac0
@@ -54,7 +54,6 @@
from processing.parameters.ParameterCrs import ParameterCrs
from processing.parameters.ParameterExtent import ParameterExtent
from processing.parameters.ParameterString import ParameterString
from processing.parameters.ParameterMultipleExternalInput import ParameterMultipleExternalInput
from processing.outputs.OutputRaster import OutputRaster
from processing.outputs.OutputVector import OutputVector
from processing.outputs.OutputTable import OutputTable
@@ -194,17 +193,14 @@ def setParamValue(self, param, widget):
return param.setValue(None)
return param.setValue(widget.currentText())
elif isinstance(param, ParameterMultipleInput):
if param.datatype == ParameterMultipleInput.TYPE_VECTOR_ANY:
options = dataobjects.getVectorLayers()
else:
options = dataobjects.getRasterLayers()
value = []
for index in widget.selectedoptions:
value.append(options[index])
return param.setValue(value)
elif isinstance(param, ParameterMultipleExternalInput):
value = widget.selectedoptions
return param.setValue(value)
if param.datatype == ParameterMultipleInput.TYPE_FILE:
return param.setValue(widget.selectedoptions)
else:
if param.datatype == ParameterMultipleInput.TYPE_VECTOR_ANY:
options = dataobjects.getVectorLayers()
else:
options = dataobjects.getRasterLayers()
return param.setValue([options[i] for i in widget.selectedoptions])
elif isinstance(param, (ParameterNumber, ParameterFile, ParameterCrs,
ParameterExtent)):
return param.setValue(widget.getValue())
@@ -30,7 +30,8 @@
from PyQt4 import QtCore, QtGui
import os

class MultipleExternalInputDialog(QtGui.QDialog):
class MultipleFileInputDialog(QtGui.QDialog):

def __init__(self, selectedoptions):
self.selectedoptions = selectedoptions
self.options=selectedoptions
@@ -68,7 +69,6 @@ def setupUi(self):
QtCore.QMetaObject.connectSlotsByName(self)

def setTableContent(self):
# "self.options :", ['/temp/confmat1-1.csv', '/temp/confmat2-1.csv']
self.table.setRowCount(len(self.options))
for i in range(len(self.options)):
item = QtGui.QLabel()
@@ -78,7 +78,6 @@ def setTableContent(self):
def okPressed(self):
self.selectedoptions = []
self.selectedoptions = self.options
# "self.selectedoptions :", ['/temp/confmat1-1.csv', '/temp/confmat2-1.csv']
self.close()

def cancelPressed(self):
@@ -2,7 +2,7 @@

"""
***************************************************************************
MultipleExternalInputPanel.py
MultipleFileInputPanel.py
---------------------
Date : August 2012
Copyright : (C) 2012 by Victor Olaya
@@ -27,13 +27,13 @@
# This will get replaced with a git SHA1 when you do a git archive
__revision__ = '$Format:%H$'

from PyQt4 import QtCore, QtGui
from processing.gui.MultipleExternalInputDialog import MultipleExternalInputDialog
from PyQt4 import QtGui
from processing.gui.MultipleFileInputDialog import MultipleFileInputDialog

class MultipleExternalInputPanel(QtGui.QWidget):
class MultipleFileInputPanel(QtGui.QWidget):

def __init__(self, parent = None):
super(MultipleExternalInputPanel, self).__init__(parent)
super(MultipleFileInputPanel, self).__init__(parent)
self.selectedoptions = []
self.horizontalLayout = QtGui.QHBoxLayout(self)
self.horizontalLayout.setSpacing(2)
@@ -54,21 +54,7 @@ def setSelectedItems(self, selected):
self.label.setText(str(len(self.selectedoptions)) + " elements selected")

def showSelectionDialog(self):
#=======================================================================
# #If there is a datatype, we use it to create the list of options
# if self.datatype is not None:
# if self.datatype == ParameterMultipleInput.TYPE_RASTER:
# options = QGisLayers.getRasterLayers()
# elif self.datatype == ParameterMultipleInput.TYPE_VECTOR_ANY:
# options = QGisLayers.getVectorLayers()
# else:
# options = QGisLayers.getVectorLayers(self.datatype)
# opts = []
# for opt in options:
# opts.append(opt.name())
# self.options = opts
#=======================================================================
dlg = MultipleExternalInputDialog(self.selectedoptions)
dlg = MultipleFileInputDialog(self.selectedoptions)
dlg.exec_()
if dlg.selectedoptions != None:
self.selectedoptions = dlg.selectedoptions
@@ -46,8 +46,7 @@
from processing.gui.ExtentSelectionPanel import ExtentSelectionPanel
from processing.gui.FileSelectionPanel import FileSelectionPanel
from processing.gui.CrsSelectionPanel import CrsSelectionPanel
from processing.gui.MultipleExternalInputPanel import MultipleExternalInputPanel

from processing.gui.MultipleFileInputPanel import MultipleFileInputPanel
from processing.parameters.ParameterRaster import ParameterRaster
from processing.parameters.ParameterVector import ParameterVector
from processing.parameters.ParameterTable import ParameterTable
@@ -62,8 +61,6 @@
from processing.parameters.ParameterFile import ParameterFile
from processing.parameters.ParameterCrs import ParameterCrs
from processing.parameters.ParameterString import ParameterString
from processing.parameters.ParameterMultipleExternalInput import ParameterMultipleExternalInput

from processing.outputs.OutputRaster import OutputRaster
from processing.outputs.OutputTable import OutputTable
from processing.outputs.OutputVector import OutputVector
@@ -282,18 +279,19 @@ def getWidgetFromParameter(self, param):
elif isinstance(param, ParameterFile):
item = FileSelectionPanel(param.isFolder)
elif isinstance(param, ParameterMultipleInput):
if param.datatype == ParameterMultipleInput.TYPE_RASTER:
options = dataobjects.getRasterLayers()
elif param.datatype == ParameterMultipleInput.TYPE_VECTOR_ANY:
options = dataobjects.getVectorLayers()
if param.datatype == ParameterMultipleInput.TYPE_FILE:
item = MultipleFileInputPanel()
else:
options = dataobjects.getVectorLayers([param.datatype])
opts = []
for opt in options:
opts.append(self.getExtendedLayerName(opt))
item = MultipleInputPanel(opts)
elif isinstance(param, ParameterMultipleExternalInput):
item = MultipleExternalInputPanel()
if param.datatype == ParameterMultipleInput.TYPE_RASTER:
options = dataobjects.getRasterLayers()
elif param.datatype == ParameterMultipleInput.TYPE_VECTOR_ANY:
options = dataobjects.getVectorLayers()
else:
options = dataobjects.getVectorLayers([param.datatype])
opts = []
for opt in options:
opts.append(self.getExtendedLayerName(opt))
item = MultipleInputPanel(opts)
elif isinstance(param, ParameterNumber):
item = NumberInputPanel(param.default, param.min, param.max,
param.isInteger)
@@ -356,7 +354,7 @@ def somethingDependsOnThisParameter(self, parent):
def setTableContent(self):
params = [parm for parm in self.alg.parameters if not parm.hidden]
outputs = [output for output in self.alg.outputs if not output.hidden]
numParams = len(parms)
numParams = len(params)
numOutputs = len(outputs)
self.tableWidget.setRowCount(numParams + numOutputs)

@@ -88,6 +88,8 @@ def adapt_list_to_string(self, c_list):
if a_list[0] in ["ParameterVector", "ParameterMultipleInput"]:
if c_list[0] == "ParameterType_InputImageList":
a_list[3] = 3
elif c_list[0] == "ParameterType_InputFilenameList":
a_list[3] = 4
else:
a_list[3] = -1

@@ -25,10 +25,11 @@
<default>0</default>
</parameter>
<parameter>
<parameter_type source_parameter_type="ParameterType_InputFilenameList">ParameterMultipleExternalInput</parameter_type>
<parameter_type source_parameter_type="ParameterType_InputFilenameList">ParameterMultipleInput</parameter_type>
<key>method.dempstershafer.cmfl</key>
<name>Confusion Matrices</name>
<description>A list of confusion matrix files (*.CSV format) to define the masses of belief and the class labels. Each file should be formatted the following way: the first line, beginning with a '#' symbol, should be a list of the class labels present in the corresponding input classification image, organized in the same order as the confusion matrix rows/columns.</description>
<datatype />
<optional>False</optional>
</parameter>
<parameter>
@@ -146,7 +146,7 @@ def get_inverted_parameters():
inverted_parameters_clone['ParameterType_RAM'] = 'ParameterNumber'
inverted_parameters_clone['ParameterType_InputProcessXML'] = 'ParameterFile'
inverted_parameters_clone['ParameterType_OutputProcessXML'] = 'ParameterFile'
inverted_parameters_clone['ParameterType_InputFilenameList'] = 'ParameterMultipleExternalInput' # 'ParameterString'
inverted_parameters_clone['ParameterType_InputFilenameList'] = 'ParameterMultipleInput' # 'ParameterString'

return inverted_parameters_clone

@@ -43,8 +43,6 @@
from processing.parameters.ParameterExtent import ParameterExtent
from processing.parameters.ParameterFile import ParameterFile
from processing.parameters.ParameterCrs import ParameterCrs
from processing.parameters.ParameterMultipleExternalInput import ParameterMultipleExternalInput


class ParameterFactory:

@@ -68,8 +66,7 @@ def getFromString(s):
ParameterFixedTable,
ParameterExtent,
ParameterFile,
ParameterCrs,
ParameterMultipleExternalInput
ParameterCrs
]
for clazz in classes:
if s.startswith(clazz().parameterName()):

This file was deleted.

@@ -44,6 +44,7 @@ class ParameterMultipleInput(ParameterDataObject):
TYPE_VECTOR_LINE = 1
TYPE_VECTOR_POLYGON = 2
TYPE_RASTER = 3
TYPE_FILE = 4

def __init__(self, name='', description='', datatype=-1, optional=False):
ParameterDataObject.__init__(self, name, description)
@@ -120,6 +121,8 @@ def getSafeExportedLayers(self):
filename = dataobjects.exportRasterLayer(layer)
self.exported = self.exported.replace(layerfile, filename)
return self.exported
elif self.datatype == ParameterMultipleInput.TYPE_FILE:
return self.value
else:
for layerfile in layers:
layer = dataobjects.getObjectFromUri(layerfile, False)
@@ -139,6 +142,8 @@ def getAsString(self, value):
if layer.name() == s:
return unicode(layer.dataProvider().dataSourceUri())
return s
if self.datatype == ParameterMultipleInput.TYPE_FILE:
return unicode(value)
else:
if isinstance(value, QgsVectorLayer):
return unicode(value.source())
@@ -153,6 +158,8 @@ def getAsString(self, value):
def getFileFilter(self):
if self.datatype == ParameterMultipleInput.TYPE_RASTER:
exts = dataobjects.getSupportedOutputRasterLayerExtensions()
elif self.datatype == ParameterMultipleInput.TYPE_FILE:
return "All files (*.*)"
else:
exts = dataobjects.getSupportedOutputVectorLayerExtensions()
for i in range(len(exts)):
@@ -172,5 +179,7 @@ def deserialize(self, s):
def getAsScriptCode(self):
if self.datatype == ParameterMultipleInput.TYPE_RASTER:
return '##' + self.name + '=multiple raster'
if self.datatype == ParameterMultipleInput.TYPE_FILE:
return '##' + self.name + '=multiple file'
else:
return '##' + self.name + '=multiple vector'

0 comments on commit 674fee7

Please sign in to comment.
You can’t perform that action at this time.