Skip to content
Permalink
Browse files

Updated model parameters window

fixed #6417
  • Loading branch information
volaya committed Oct 12, 2012
1 parent 6369196 commit 0e2f92fa76d7d56cabc64a5b37926f6e789c59d7
@@ -29,6 +29,7 @@
from sextante.outputs.OutputRaster import OutputRaster
from sextante.outputs.OutputTable import OutputTable
from sextante.outputs.OutputVector import OutputVector
from sextante.outputs.OutputNumber import OutputNumber
from sextante.parameters.ParameterString import ParameterString

class ParametersPanel(QtGui.QWidget):
@@ -20,6 +20,7 @@
from sextante.parameters.ParameterRange import ParameterRange
from sextante.gui.RangePanel import RangePanel
from sextante.outputs.OutputNumber import OutputNumber
from sextante.outputs.OutputHTML import OutputHTML
from sextante.parameters.ParameterFile import ParameterFile
from sextante.outputs.OutputFile import OutputFile
from sextante.core.WrongHelpFileException import WrongHelpFileException
@@ -41,30 +42,108 @@ def __init__(self, alg, model, algIndex = None):


def setupUi(self):
self.labels = {}
self.widgets = {}
self.checkBoxes = {}
self.showAdvanced = False
self.valueItems = {}
self.dependentItems = {}
self.resize(650, 450)
self.buttonBox = QtGui.QDialogButtonBox()
self.buttonBox.setOrientation(QtCore.Qt.Horizontal)
self.buttonBox.setStandardButtons(QtGui.QDialogButtonBox.Cancel|QtGui.QDialogButtonBox.Ok)
self.tableWidget = QtGui.QTableWidget()
self.tableWidget.setSelectionMode(QtGui.QAbstractItemView.NoSelection)
self.tableWidget.setColumnCount(2)
self.tableWidget.setColumnWidth(0,300)
self.tableWidget.setColumnWidth(1,300)
self.tableWidget.setHorizontalHeaderItem(0, QtGui.QTableWidgetItem("Parameter"))
self.tableWidget.setHorizontalHeaderItem(1, QtGui.QTableWidgetItem("Value"))
self.tableWidget.verticalHeader().setVisible(False)
self.tableWidget.horizontalHeader().setResizeMode(QtGui.QHeaderView.Stretch)
self.setTableContent()
#=======================================================================
# self.tableWidget = QtGui.QTableWidget()
# self.tableWidget.setSelectionMode(QtGui.QAbstractItemView.NoSelection)
# self.tableWidget.setColumnCount(2)
# self.tableWidget.setColumnWidth(0,300)
# self.tableWidget.setColumnWidth(1,300)
# self.tableWidget.setHorizontalHeaderItem(0, QtGui.QTableWidgetItem("Parameter"))
# self.tableWidget.setHorizontalHeaderItem(1, QtGui.QTableWidgetItem("Value"))
# self.tableWidget.verticalHeader().setVisible(False)
# self.tableWidget.horizontalHeader().setResizeMode(QtGui.QHeaderView.Stretch)
# self.setTableContent()
#=======================================================================


tooltips = self.alg.getParameterDescriptions()
self.setSizePolicy(QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Expanding)
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:
if param.hidden:
continue
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):
layout = QtGui.QHBoxLayout()
layout.setSpacing(2)
layout.setMargin(0)
layout.addWidget(widget)
button = QtGui.QToolButton()
icon = QtGui.QIcon(os.path.dirname(__file__) + "/../images/iterate.png")
button.setIcon(icon)
button.setToolTip("Iterate over this layer")
button.setCheckable(True)
button.setMaximumWidth(30)
button.setMaximumHeight(30)
layout.addWidget(button)
self.iterateButtons[param.name] = button
QtCore.QObject.connect(button, QtCore.SIGNAL("toggled(bool)"), self.buttonToggled)
widget = QtGui.QWidget()
widget.setLayout(layout)
if param.name in tooltips.keys():
tooltip = tooltips[param.name]
else:
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)

for output in self.alg.outputs:
if output.hidden:
continue
if isinstance(output, (OutputRaster, OutputVector, OutputTable, OutputHTML)):
label = QtGui.QLabel(output.description + "<" + output.__module__.split(".")[-1] + ">")
item = QLineEdit()
if hasattr(item, 'setPlaceholderText'):
item.setPlaceholderText(ModelerParametersDialog.ENTER_NAME)
self.verticalLayout.addWidget(label)
self.verticalLayout.addWidget(item)
self.valueItems[output.name] = item

self.verticalLayout.addStretch(1000)
self.setLayout(self.verticalLayout)

self.setPreviousValues()
self.setWindowTitle(self.alg.name)
self.verticalLayout = QtGui.QVBoxLayout()
self.verticalLayout.setSpacing(2)
self.verticalLayout.setMargin(0)
self.verticalLayout2 = QtGui.QVBoxLayout()
self.verticalLayout2.setSpacing(2)
self.verticalLayout2.setMargin(0)
self.tabWidget = QtGui.QTabWidget()
self.tabWidget.setMinimumWidth(300)
self.tabWidget.addTab(self.tableWidget, "Parameters")
self.paramPanel = QtGui.QWidget()
self.paramPanel.setLayout(self.verticalLayout)
self.tabWidget.addTab(self.paramPanel, "Parameters")
self.webView = QtWebKit.QWebView()
html = None
try:
@@ -84,9 +163,9 @@ def setupUi(self):
except:
self.webView.setHtml("<h2>Could not open help file :-( </h2>")
self.tabWidget.addTab(self.webView, "Help")
self.verticalLayout.addWidget(self.tabWidget)
self.verticalLayout.addWidget(self.buttonBox)
self.setLayout(self.verticalLayout)
self.verticalLayout2.addWidget(self.tabWidget)
self.verticalLayout2.addWidget(self.buttonBox)
self.setLayout(self.verticalLayout2)
QtCore.QObject.connect(self.buttonBox, QtCore.SIGNAL("accepted()"), self.okPressed)
QtCore.QObject.connect(self.buttonBox, QtCore.SIGNAL("rejected()"), self.cancelPressed)
QtCore.QMetaObject.connectSlotsByName(self)
@@ -162,7 +162,8 @@ def processAlgorithm(self, progress):
loglines.append("OTB execution command")
for line in commands:
loglines.append(line)
progress.setCommand(line)

SextanteLog.addToLog(SextanteLog.LOG_INFO, loglines)
progress.setCommand(loglines)

OTBUtils.executeOtb(commands, progress)
@@ -67,6 +67,12 @@ def defineCharacteristicsFromFile(self):
lines = open(self.descriptionFile)
line = lines.readline().strip("\n").strip()
self.name = line
if "|" in self.name:
tokens = self.name.split("|")
self.name = tokens[0]
self.cmdname = tokens[1]
else:
self.cmdname = self.name
line = lines.readline().strip("\n").strip()
self.undecoratedGroup = line
self.group = SagaGroupNameDecorator.getDecoratedName(self.undecoratedGroup)
@@ -201,9 +207,9 @@ def processAlgorithm(self, progress):

#2: set parameters and outputs
if SextanteUtils.isWindows():
command = self.undecoratedGroup + " \"" + self.name + "\""
command = self.undecoratedGroup + " \"" + self.cmdname + "\""
else:
command = "lib" + self.undecoratedGroup + " \"" + self.name + "\""
command = "lib" + self.undecoratedGroup + " \"" + self.cmdname + "\""

for param in self.parameters:
if param.value is None:
@@ -6,9 +6,9 @@ ParameterRaster|INIT_GRID|Initiation Grid|False
ParameterSelection|INIT_METHOD|Initiation Type|[0] Less than;[1] Equals;[2] Greater than
ParameterNumber|INIT_VALUE|Initiation Threshold|None|None|0.0
ParameterRaster|DIV_GRID|Divergence|True
ParameterNumber|DIV_CELLS|Tracing: Max. Divergence|None|None|10.0
ParameterNumber|DIV_CELLS|Tracing: Max. Divergence|None|None|10
ParameterRaster|TRACE_WEIGHT|Tracing: Weight|True
ParameterNumber|MINLEN|Min. Segment Length|0.0|None|10.0
ParameterNumber|MINLEN|Min. Segment Length|0.0|None|10
OutputRaster|CHNLNTWRK|Channel Network
OutputRaster|CHNLROUTE|Channel Direction
OutputVector|SHAPES|Channel Network
@@ -1,4 +1,4 @@
Upslope Area
Upslope Area|4
ta_hydrology
ParameterRaster|TARGET|Target Area|True
ParameterNumber|TARGET_PT_X|Target X coordinate|None|None|0.0

0 comments on commit 0e2f92f

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