Skip to content

Commit 674fee7

Browse files
committedApr 17, 2014
Removed MultipleExternalInput parameter and made it a subtype of MultipleInput
1 parent 54ce9a0 commit 674fee7

10 files changed

+45
-161
lines changed
 

‎python/plugins/processing/gui/AlgorithmExecutionDialog.py

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,6 @@
5454
from processing.parameters.ParameterCrs import ParameterCrs
5555
from processing.parameters.ParameterExtent import ParameterExtent
5656
from processing.parameters.ParameterString import ParameterString
57-
from processing.parameters.ParameterMultipleExternalInput import ParameterMultipleExternalInput
5857
from processing.outputs.OutputRaster import OutputRaster
5958
from processing.outputs.OutputVector import OutputVector
6059
from processing.outputs.OutputTable import OutputTable
@@ -194,17 +193,14 @@ def setParamValue(self, param, widget):
194193
return param.setValue(None)
195194
return param.setValue(widget.currentText())
196195
elif isinstance(param, ParameterMultipleInput):
197-
if param.datatype == ParameterMultipleInput.TYPE_VECTOR_ANY:
198-
options = dataobjects.getVectorLayers()
199-
else:
200-
options = dataobjects.getRasterLayers()
201-
value = []
202-
for index in widget.selectedoptions:
203-
value.append(options[index])
204-
return param.setValue(value)
205-
elif isinstance(param, ParameterMultipleExternalInput):
206-
value = widget.selectedoptions
207-
return param.setValue(value)
196+
if param.datatype == ParameterMultipleInput.TYPE_FILE:
197+
return param.setValue(widget.selectedoptions)
198+
else:
199+
if param.datatype == ParameterMultipleInput.TYPE_VECTOR_ANY:
200+
options = dataobjects.getVectorLayers()
201+
else:
202+
options = dataobjects.getRasterLayers()
203+
return param.setValue([options[i] for i in widget.selectedoptions])
208204
elif isinstance(param, (ParameterNumber, ParameterFile, ParameterCrs,
209205
ParameterExtent)):
210206
return param.setValue(widget.getValue())

‎python/plugins/processing/gui/MultipleExternalInputDialog.py renamed to ‎python/plugins/processing/gui/MultipleFileInputDialog.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,8 @@
3030
from PyQt4 import QtCore, QtGui
3131
import os
3232

33-
class MultipleExternalInputDialog(QtGui.QDialog):
33+
class MultipleFileInputDialog(QtGui.QDialog):
34+
3435
def __init__(self, selectedoptions):
3536
self.selectedoptions = selectedoptions
3637
self.options=selectedoptions
@@ -68,7 +69,6 @@ def setupUi(self):
6869
QtCore.QMetaObject.connectSlotsByName(self)
6970

7071
def setTableContent(self):
71-
# "self.options :", ['/temp/confmat1-1.csv', '/temp/confmat2-1.csv']
7272
self.table.setRowCount(len(self.options))
7373
for i in range(len(self.options)):
7474
item = QtGui.QLabel()
@@ -78,7 +78,6 @@ def setTableContent(self):
7878
def okPressed(self):
7979
self.selectedoptions = []
8080
self.selectedoptions = self.options
81-
# "self.selectedoptions :", ['/temp/confmat1-1.csv', '/temp/confmat2-1.csv']
8281
self.close()
8382

8483
def cancelPressed(self):

‎python/plugins/processing/gui/MultipleExternalInputPanel.py renamed to ‎python/plugins/processing/gui/MultipleFileInputPanel.py

Lines changed: 6 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

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

30-
from PyQt4 import QtCore, QtGui
31-
from processing.gui.MultipleExternalInputDialog import MultipleExternalInputDialog
30+
from PyQt4 import QtGui
31+
from processing.gui.MultipleFileInputDialog import MultipleFileInputDialog
3232

33-
class MultipleExternalInputPanel(QtGui.QWidget):
33+
class MultipleFileInputPanel(QtGui.QWidget):
3434

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

5656
def showSelectionDialog(self):
57-
#=======================================================================
58-
# #If there is a datatype, we use it to create the list of options
59-
# if self.datatype is not None:
60-
# if self.datatype == ParameterMultipleInput.TYPE_RASTER:
61-
# options = QGisLayers.getRasterLayers()
62-
# elif self.datatype == ParameterMultipleInput.TYPE_VECTOR_ANY:
63-
# options = QGisLayers.getVectorLayers()
64-
# else:
65-
# options = QGisLayers.getVectorLayers(self.datatype)
66-
# opts = []
67-
# for opt in options:
68-
# opts.append(opt.name())
69-
# self.options = opts
70-
#=======================================================================
71-
dlg = MultipleExternalInputDialog(self.selectedoptions)
57+
dlg = MultipleFileInputDialog(self.selectedoptions)
7258
dlg.exec_()
7359
if dlg.selectedoptions != None:
7460
self.selectedoptions = dlg.selectedoptions

‎python/plugins/processing/gui/ParametersPanel.py

Lines changed: 14 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,7 @@
4646
from processing.gui.ExtentSelectionPanel import ExtentSelectionPanel
4747
from processing.gui.FileSelectionPanel import FileSelectionPanel
4848
from processing.gui.CrsSelectionPanel import CrsSelectionPanel
49-
from processing.gui.MultipleExternalInputPanel import MultipleExternalInputPanel
50-
49+
from processing.gui.MultipleFileInputPanel import MultipleFileInputPanel
5150
from processing.parameters.ParameterRaster import ParameterRaster
5251
from processing.parameters.ParameterVector import ParameterVector
5352
from processing.parameters.ParameterTable import ParameterTable
@@ -62,8 +61,6 @@
6261
from processing.parameters.ParameterFile import ParameterFile
6362
from processing.parameters.ParameterCrs import ParameterCrs
6463
from processing.parameters.ParameterString import ParameterString
65-
from processing.parameters.ParameterMultipleExternalInput import ParameterMultipleExternalInput
66-
6764
from processing.outputs.OutputRaster import OutputRaster
6865
from processing.outputs.OutputTable import OutputTable
6966
from processing.outputs.OutputVector import OutputVector
@@ -282,18 +279,19 @@ def getWidgetFromParameter(self, param):
282279
elif isinstance(param, ParameterFile):
283280
item = FileSelectionPanel(param.isFolder)
284281
elif isinstance(param, ParameterMultipleInput):
285-
if param.datatype == ParameterMultipleInput.TYPE_RASTER:
286-
options = dataobjects.getRasterLayers()
287-
elif param.datatype == ParameterMultipleInput.TYPE_VECTOR_ANY:
288-
options = dataobjects.getVectorLayers()
282+
if param.datatype == ParameterMultipleInput.TYPE_FILE:
283+
item = MultipleFileInputPanel()
289284
else:
290-
options = dataobjects.getVectorLayers([param.datatype])
291-
opts = []
292-
for opt in options:
293-
opts.append(self.getExtendedLayerName(opt))
294-
item = MultipleInputPanel(opts)
295-
elif isinstance(param, ParameterMultipleExternalInput):
296-
item = MultipleExternalInputPanel()
285+
if param.datatype == ParameterMultipleInput.TYPE_RASTER:
286+
options = dataobjects.getRasterLayers()
287+
elif param.datatype == ParameterMultipleInput.TYPE_VECTOR_ANY:
288+
options = dataobjects.getVectorLayers()
289+
else:
290+
options = dataobjects.getVectorLayers([param.datatype])
291+
opts = []
292+
for opt in options:
293+
opts.append(self.getExtendedLayerName(opt))
294+
item = MultipleInputPanel(opts)
297295
elif isinstance(param, ParameterNumber):
298296
item = NumberInputPanel(param.default, param.min, param.max,
299297
param.isInteger)
@@ -356,7 +354,7 @@ def somethingDependsOnThisParameter(self, parent):
356354
def setTableContent(self):
357355
params = [parm for parm in self.alg.parameters if not parm.hidden]
358356
outputs = [output for output in self.alg.outputs if not output.hidden]
359-
numParams = len(parms)
357+
numParams = len(params)
360358
numOutputs = len(outputs)
361359
self.tableWidget.setRowCount(numParams + numOutputs)
362360

‎python/plugins/processing/otb/OTBAlgorithm.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,8 @@ def adapt_list_to_string(self, c_list):
8888
if a_list[0] in ["ParameterVector", "ParameterMultipleInput"]:
8989
if c_list[0] == "ParameterType_InputImageList":
9090
a_list[3] = 3
91+
elif c_list[0] == "ParameterType_InputFilenameList":
92+
a_list[3] = 4
9193
else:
9294
a_list[3] = -1
9395

‎python/plugins/processing/otb/description/FusionOfClassifications-dempstershafer.xml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,11 @@
2525
<default>0</default>
2626
</parameter>
2727
<parameter>
28-
<parameter_type source_parameter_type="ParameterType_InputFilenameList">ParameterMultipleExternalInput</parameter_type>
28+
<parameter_type source_parameter_type="ParameterType_InputFilenameList">ParameterMultipleInput</parameter_type>
2929
<key>method.dempstershafer.cmfl</key>
3030
<name>Confusion Matrices</name>
3131
<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>
32+
<datatype />
3233
<optional>False</optional>
3334
</parameter>
3435
<parameter>

‎python/plugins/processing/otb/maintenance/OTBHelper.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@ def get_inverted_parameters():
146146
inverted_parameters_clone['ParameterType_RAM'] = 'ParameterNumber'
147147
inverted_parameters_clone['ParameterType_InputProcessXML'] = 'ParameterFile'
148148
inverted_parameters_clone['ParameterType_OutputProcessXML'] = 'ParameterFile'
149-
inverted_parameters_clone['ParameterType_InputFilenameList'] = 'ParameterMultipleExternalInput' # 'ParameterString'
149+
inverted_parameters_clone['ParameterType_InputFilenameList'] = 'ParameterMultipleInput' # 'ParameterString'
150150

151151
return inverted_parameters_clone
152152

‎python/plugins/processing/parameters/ParameterFactory.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,6 @@
4343
from processing.parameters.ParameterExtent import ParameterExtent
4444
from processing.parameters.ParameterFile import ParameterFile
4545
from processing.parameters.ParameterCrs import ParameterCrs
46-
from processing.parameters.ParameterMultipleExternalInput import ParameterMultipleExternalInput
47-
4846

4947
class ParameterFactory:
5048

@@ -68,8 +66,7 @@ def getFromString(s):
6866
ParameterFixedTable,
6967
ParameterExtent,
7068
ParameterFile,
71-
ParameterCrs,
72-
ParameterMultipleExternalInput
69+
ParameterCrs
7370
]
7471
for clazz in classes:
7572
if s.startswith(clazz().parameterName()):

‎python/plugins/processing/parameters/ParameterMultipleExternalInput.py

Lines changed: 0 additions & 104 deletions
This file was deleted.

‎python/plugins/processing/parameters/ParameterMultipleInput.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ class ParameterMultipleInput(ParameterDataObject):
4444
TYPE_VECTOR_LINE = 1
4545
TYPE_VECTOR_POLYGON = 2
4646
TYPE_RASTER = 3
47+
TYPE_FILE = 4
4748

4849
def __init__(self, name='', description='', datatype=-1, optional=False):
4950
ParameterDataObject.__init__(self, name, description)
@@ -120,6 +121,8 @@ def getSafeExportedLayers(self):
120121
filename = dataobjects.exportRasterLayer(layer)
121122
self.exported = self.exported.replace(layerfile, filename)
122123
return self.exported
124+
elif self.datatype == ParameterMultipleInput.TYPE_FILE:
125+
return self.value
123126
else:
124127
for layerfile in layers:
125128
layer = dataobjects.getObjectFromUri(layerfile, False)
@@ -139,6 +142,8 @@ def getAsString(self, value):
139142
if layer.name() == s:
140143
return unicode(layer.dataProvider().dataSourceUri())
141144
return s
145+
if self.datatype == ParameterMultipleInput.TYPE_FILE:
146+
return unicode(value)
142147
else:
143148
if isinstance(value, QgsVectorLayer):
144149
return unicode(value.source())
@@ -153,6 +158,8 @@ def getAsString(self, value):
153158
def getFileFilter(self):
154159
if self.datatype == ParameterMultipleInput.TYPE_RASTER:
155160
exts = dataobjects.getSupportedOutputRasterLayerExtensions()
161+
elif self.datatype == ParameterMultipleInput.TYPE_FILE:
162+
return "All files (*.*)"
156163
else:
157164
exts = dataobjects.getSupportedOutputVectorLayerExtensions()
158165
for i in range(len(exts)):
@@ -172,5 +179,7 @@ def deserialize(self, s):
172179
def getAsScriptCode(self):
173180
if self.datatype == ParameterMultipleInput.TYPE_RASTER:
174181
return '##' + self.name + '=multiple raster'
182+
if self.datatype == ParameterMultipleInput.TYPE_FILE:
183+
return '##' + self.name + '=multiple file'
175184
else:
176185
return '##' + self.name + '=multiple vector'

0 commit comments

Comments
 (0)
Please sign in to comment.