Skip to content

Commit 3b7b2b4

Browse files
committed
Merge pull request #1134 from CS-SI/otb_processing_update
OTB processing update
2 parents e2d01e2 + 7abca16 commit 3b7b2b4

File tree

308 files changed

+11418
-4221
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

308 files changed

+11418
-4221
lines changed

python/plugins/processing/gui/AlgorithmExecutionDialog.py

+15
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,11 @@
66
---------------------
77
Date : August 2012
88
Copyright : (C) 2012 by Victor Olaya
9+
(C) 2013 by CS Systemes d'information (CS SI)
910
Email : volayaf at gmail dot com
11+
otb at c-s dot fr (CS SI)
12+
Contributors : Victor Olaya
13+
Alexia Mondot (CS SI) - managing the new parameter ParameterMultipleExternalInput
1014
***************************************************************************
1115
* *
1216
* This program is free software; you can redistribute it and/or modify *
@@ -50,6 +54,7 @@
5054
from processing.parameters.ParameterCrs import ParameterCrs
5155
from processing.parameters.ParameterExtent import ParameterExtent
5256
from processing.parameters.ParameterString import ParameterString
57+
from processing.parameters.ParameterMultipleExternalInput import ParameterMultipleExternalInput
5358
from processing.outputs.OutputRaster import OutputRaster
5459
from processing.outputs.OutputVector import OutputVector
5560
from processing.outputs.OutputTable import OutputTable
@@ -162,6 +167,13 @@ def setParamValues(self):
162167
return True
163168

164169
def setParamValue(self, param, widget):
170+
"""
171+
set the .value of the parameter according to the given widget
172+
the way to get the value is different for each value,
173+
so there is a code for each kind of parameter
174+
175+
param : -il <ParameterMultipleInput> or -method <ParameterSelection> ...
176+
"""
165177
if isinstance(param, ParameterRaster):
166178
return param.setValue(widget.getValue())
167179
elif isinstance(param, (ParameterVector, ParameterTable)):
@@ -188,6 +200,9 @@ def setParamValue(self, param, widget):
188200
for index in widget.selectedoptions:
189201
value.append(options[index])
190202
return param.setValue(value)
203+
elif isinstance(param, ParameterMultipleExternalInput):
204+
value = widget.selectedoptions
205+
return param.setValue(value)
191206
elif isinstance(param, (ParameterNumber, ParameterFile, ParameterCrs,
192207
ParameterExtent)):
193208
return param.setValue(widget.getValue())
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,111 @@
1+
# -*- coding: utf-8 -*-
2+
3+
"""
4+
***************************************************************************
5+
MultipleExternalInputDialog.py
6+
---------------------
7+
Date : August 2012
8+
Copyright : (C) 2012 by Victor Olaya
9+
(C) 2013 by CS Systemes d'information (CS SI)
10+
Email : volayaf at gmail dot com
11+
otb at c-s dot fr (CS SI)
12+
Contributors : Victor Olaya - basis from MultipleInputDialog
13+
Alexia Mondot (CS SI) - new parameter
14+
***************************************************************************
15+
* *
16+
* This program is free software; you can redistribute it and/or modify *
17+
* it under the terms of the GNU General Public License as published by *
18+
* the Free Software Foundation; either version 2 of the License, or *
19+
* (at your option) any later version. *
20+
* *
21+
***************************************************************************
22+
"""
23+
24+
__author__ = 'Victor Olaya'
25+
__date__ = 'August 2012'
26+
__copyright__ = '(C) 2012, Victor Olaya'
27+
# This will get replaced with a git SHA1 when you do a git archive
28+
__revision__ = '$Format:%H$'
29+
30+
from PyQt4 import QtCore, QtGui
31+
import os
32+
33+
class MultipleExternalInputDialog(QtGui.QDialog):
34+
def __init__(self, selectedoptions):
35+
self.selectedoptions = selectedoptions
36+
self.options=selectedoptions
37+
QtGui.QDialog.__init__(self)
38+
self.setModal(True)
39+
self.setupUi()
40+
self.selectedoptions = None
41+
42+
def setupUi(self):
43+
self.resize(381, 320)
44+
self.setWindowTitle("Multiple selection")
45+
self.horizontalLayout = QtGui.QHBoxLayout(self)
46+
self.horizontalLayout.setSpacing(2)
47+
self.horizontalLayout.setMargin(0)
48+
self.buttonBox = QtGui.QDialogButtonBox()
49+
self.buttonBox.setOrientation(QtCore.Qt.Vertical)
50+
self.buttonBox.setStandardButtons(QtGui.QDialogButtonBox.Cancel|QtGui.QDialogButtonBox.Ok)
51+
self.buttonPlus = QtGui.QPushButton("+")
52+
self.buttonBox.addButton(self.buttonPlus, QtGui.QDialogButtonBox.ActionRole)
53+
self.buttonMoins = QtGui.QPushButton("-")
54+
self.buttonBox.addButton(self.buttonMoins, QtGui.QDialogButtonBox.ActionRole)
55+
self.table = QtGui.QTableWidget()
56+
self.table.setColumnCount(1)
57+
self.table.setColumnWidth(0,270)
58+
self.table.verticalHeader().setVisible(False)
59+
self.table.horizontalHeader().setVisible(False)
60+
self.table.horizontalHeader().setResizeMode(QtGui.QHeaderView.Stretch)
61+
self.horizontalLayout.addWidget(self.table)
62+
self.horizontalLayout.addWidget(self.buttonBox)
63+
self.setLayout(self.horizontalLayout)
64+
QtCore.QObject.connect(self.buttonBox, QtCore.SIGNAL("accepted()"), self.okPressed)
65+
QtCore.QObject.connect(self.buttonBox, QtCore.SIGNAL("rejected()"), self.cancelPressed)
66+
QtCore.QObject.connect(self.buttonPlus, QtCore.SIGNAL("clicked()"), self.addFile)
67+
QtCore.QObject.connect(self.buttonMoins, QtCore.SIGNAL("clicked()"), self.removeFile)
68+
QtCore.QMetaObject.connectSlotsByName(self)
69+
70+
def setTableContent(self):
71+
# "self.options :", ['/temp/confmat1-1.csv', '/temp/confmat2-1.csv']
72+
self.table.setRowCount(len(self.options))
73+
for i in range(len(self.options)):
74+
item = QtGui.QLabel()
75+
item.setText(self.options[i])
76+
self.table.setCellWidget(i,0, item)
77+
78+
def okPressed(self):
79+
self.selectedoptions = []
80+
self.selectedoptions = self.options
81+
# "self.selectedoptions :", ['/temp/confmat1-1.csv', '/temp/confmat2-1.csv']
82+
self.close()
83+
84+
def cancelPressed(self):
85+
self.selectedoptions = None
86+
self.close()
87+
88+
def addFile(self):
89+
settings = QtCore.QSettings()
90+
lastfolder = settings.value("processingFilesLastFolder")
91+
if lastfolder :
92+
path = lastfolder
93+
else :
94+
path = QtCore.QDir.currentPath()
95+
96+
filesOpened = QtGui.QFileDialog.getOpenFileNames( None, "Select the file(s) to use", path, "All files (*.*)" )
97+
98+
lastfile = ""
99+
for item in filesOpened:
100+
self.options.append( str(item) )
101+
lastfile=item
102+
103+
self.setTableContent()
104+
folder = os.path.dirname( str( lastfile ) )
105+
settings.setValue("processingFilesLastFolder", folder)
106+
107+
def removeFile(self):
108+
indexRow = self.table.currentRow()
109+
itemToRemove = self.options[indexRow]
110+
self.options.remove(itemToRemove)
111+
self.setTableContent()
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
# -*- coding: utf-8 -*-
2+
3+
"""
4+
***************************************************************************
5+
MultipleExternalInputPanel.py
6+
---------------------
7+
Date : August 2012
8+
Copyright : (C) 2012 by Victor Olaya
9+
(C) 2013 by CS Systemes d'information (CS SI)
10+
Email : volayaf at gmail dot com
11+
otb at c-s dot fr (CS SI)
12+
Contributors : Victor Olaya - basis from MultipleInputPanel
13+
Alexia Mondot (CS SI) - adapt for a new parameter
14+
***************************************************************************
15+
* *
16+
* This program is free software; you can redistribute it and/or modify *
17+
* it under the terms of the GNU General Public License as published by *
18+
* the Free Software Foundation; either version 2 of the License, or *
19+
* (at your option) any later version. *
20+
* *
21+
***************************************************************************
22+
"""
23+
24+
__author__ = 'Victor Olaya'
25+
__date__ = 'August 2012'
26+
__copyright__ = '(C) 2012, Victor Olaya'
27+
# This will get replaced with a git SHA1 when you do a git archive
28+
__revision__ = '$Format:%H$'
29+
30+
from PyQt4 import QtCore, QtGui
31+
from processing.gui.MultipleExternalInputDialog import MultipleExternalInputDialog
32+
33+
class MultipleExternalInputPanel(QtGui.QWidget):
34+
35+
def __init__(self, parent = None):
36+
super(MultipleExternalInputPanel, self).__init__(parent)
37+
self.selectedoptions = []
38+
self.horizontalLayout = QtGui.QHBoxLayout(self)
39+
self.horizontalLayout.setSpacing(2)
40+
self.horizontalLayout.setMargin(0)
41+
self.label = QtGui.QLabel()
42+
self.label.setText("0 elements selected")
43+
self.label.setSizePolicy(QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Expanding)
44+
self.horizontalLayout.addWidget(self.label)
45+
self.pushButton = QtGui.QPushButton()
46+
self.pushButton.setText("...")
47+
self.pushButton.clicked.connect(self.showSelectionDialog)
48+
self.horizontalLayout.addWidget(self.pushButton)
49+
self.setLayout(self.horizontalLayout)
50+
51+
def setSelectedItems(self, selected):
52+
#no checking is performed!
53+
self.selectedoptions = selected
54+
self.label.setText(str(len(self.selectedoptions)) + " elements selected")
55+
56+
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)
72+
dlg.exec_()
73+
if dlg.selectedoptions != None:
74+
self.selectedoptions = dlg.selectedoptions
75+
self.label.setText(str(len(self.selectedoptions)) + " elements selected")

python/plugins/processing/gui/ParametersPanel.py

+8
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,11 @@
66
---------------------
77
Date : August 2012
88
Copyright : (C) 2012 by Victor Olaya
9+
(C) 2013 by CS Systemes d'information (CS SI)
910
Email : volayaf at gmail dot com
11+
otb at c-s dot fr (CS SI)
12+
Contributors : Victor Olaya
13+
Alexia Mondot (CS SI) - managing the new parameter ParameterMultipleExternalInput
1014
***************************************************************************
1115
* *
1216
* This program is free software; you can redistribute it and/or modify *
@@ -42,6 +46,7 @@
4246
from processing.gui.ExtentSelectionPanel import ExtentSelectionPanel
4347
from processing.gui.FileSelectionPanel import FileSelectionPanel
4448
from processing.gui.CrsSelectionPanel import CrsSelectionPanel
49+
from processing.gui.MultipleExternalInputPanel import MultipleExternalInputPanel
4550

4651
from processing.parameters.ParameterRaster import ParameterRaster
4752
from processing.parameters.ParameterVector import ParameterVector
@@ -57,6 +62,7 @@
5762
from processing.parameters.ParameterFile import ParameterFile
5863
from processing.parameters.ParameterCrs import ParameterCrs
5964
from processing.parameters.ParameterString import ParameterString
65+
from processing.parameters.ParameterMultipleExternalInput import ParameterMultipleExternalInput
6066

6167
from processing.outputs.OutputRaster import OutputRaster
6268
from processing.outputs.OutputTable import OutputTable
@@ -284,6 +290,8 @@ def getWidgetFromParameter(self, param):
284290
for opt in options:
285291
opts.append(self.getExtendedLayerName(opt))
286292
item = MultipleInputPanel(opts)
293+
elif isinstance(param, ParameterMultipleExternalInput):
294+
item = MultipleExternalInputPanel()
287295
elif isinstance(param, ParameterNumber):
288296
item = NumberInputPanel(param.default, param.min, param.max,
289297
param.isInteger)

python/plugins/processing/otb/CMakeLists.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
FILE(GLOB PY_FILES *.py)
2-
FILE(GLOB DESCR_FILES description/*.txt)
2+
FILE(GLOB DESCR_FILES description/*.xml)
33
FILE(GLOB HELPER_FILES helper/*.py)
44
FiLE(GLOB HELP_FILES description/doc/*.html)
55

0 commit comments

Comments
 (0)