From 00943d1a17aed7bfd6f2451b43a3b7efc8045a72 Mon Sep 17 00:00:00 2001 From: Renaud Barate Date: Wed, 27 Feb 2013 18:32:31 +0100 Subject: [PATCH] Add GUI for different methods to define input sample --- src/salome/parametric/gui/CMakeLists.txt | 2 +- src/salome/parametric/gui/definevalues.py | 14 +- src/salome/parametric/gui/definevalues.ui | 204 ++++++++++++++++++++++ src/salome/parametric/gui/wizard.py | 4 +- 4 files changed, 214 insertions(+), 10 deletions(-) create mode 100644 src/salome/parametric/gui/definevalues.ui diff --git a/src/salome/parametric/gui/CMakeLists.txt b/src/salome/parametric/gui/CMakeLists.txt index 0bf08b1..1766c66 100644 --- a/src/salome/parametric/gui/CMakeLists.txt +++ b/src/salome/parametric/gui/CMakeLists.txt @@ -15,7 +15,7 @@ # You should have received a copy of the GNU Lesser General Public License # along with SALOME PARAMETRIC module. If not, see . -SET(PYUIC_FILES wizard_ui.py varrange_ui.py execparams_ui.py genjob_ui.py) +SET(PYUIC_FILES wizard_ui.py varrange_ui.py execparams_ui.py genjob_ui.py definevalues_ui.py) SET(INSTALL_DIR ${PYTHONDIR}/salome/parametric/gui) FOREACH(OUTPUT ${PYUIC_FILES}) diff --git a/src/salome/parametric/gui/definevalues.py b/src/salome/parametric/gui/definevalues.py index 4d9ee27..4b322f7 100644 --- a/src/salome/parametric/gui/definevalues.py +++ b/src/salome/parametric/gui/definevalues.py @@ -15,10 +15,11 @@ # You should have received a copy of the GNU Lesser General Public License # along with SALOME PARAMETRIC module. If not, see . -from PyQt4 import QtGui, QtCore +from PyQt4 import QtGui from PyQt4.QtCore import Qt from varrange_ui import Ui_VariableRange +from definevalues_ui import Ui_SampleDefinition class VariableRange(QtGui.QWidget, Ui_VariableRange): @@ -29,13 +30,12 @@ class VariableRange(QtGui.QWidget, Ui_VariableRange): self.setupUi(self) -class DefineValuesFrame(QtGui.QWidget): +class DefineValuesFrame(QtGui.QWidget, Ui_SampleDefinition): def __init__(self, parent = None): QtGui.QWidget.__init__(self, parent) - self.setLayout(QtGui.QVBoxLayout(self)) + self.setupUi(self) self.varwidgets = {} - self.layout().addStretch() def set_variables(self, varlist): previous_set = set(self.varwidgets.keys()) @@ -43,14 +43,14 @@ class DefineValuesFrame(QtGui.QWidget): var_to_remove = previous_set - new_set var_to_add = new_set - previous_set for var in var_to_remove: - self.layout().removeWidget(self.varwidgets[var]) + self.variablesRangesWidget.layout().removeWidget(self.varwidgets[var]) self.varwidgets[var].close() del self.varwidgets[var] for var in var_to_add: varrange = VariableRange(self) varrange.nameLabel.setText(var) self.varwidgets[var] = varrange - self.layout().insertWidget(self.layout().count()-1, varrange) + self.variablesRangesWidget.layout().addWidget(varrange) def set_ranges_from_param_study(self, param_study): for var in param_study.input_vars: @@ -60,7 +60,7 @@ class DefineValuesFrame(QtGui.QWidget): varrange.toSpinBox.setValue(var.max) varrange.stepSpinBox.setValue(var.step) self.varwidgets[var.name] = varrange - self.layout().insertWidget(self.layout().count()-1, varrange) + self.variablesRangesWidget.layout().addWidget(varrange) def check_values(self): return True diff --git a/src/salome/parametric/gui/definevalues.ui b/src/salome/parametric/gui/definevalues.ui new file mode 100644 index 0000000..4e138ab --- /dev/null +++ b/src/salome/parametric/gui/definevalues.ui @@ -0,0 +1,204 @@ + + + SampleDefinition + + + + 0 + 0 + 765 + 720 + + + + Sample Definition + + + + + + Choose a method to define the input sample: + + + + + + + Define variable(s) range(s) + + + true + + + sampleDefinitionMethodBG + + + + + + + + + Qt::Horizontal + + + QSizePolicy::Fixed + + + + 25 + 10 + + + + + + + + + 0 + 0 + + + + true + + + + + + + + + + + + false + + + Define sample with a Python script + + + sampleDefinitionMethodBG + + + + + + + + + Qt::Horizontal + + + QSizePolicy::Fixed + + + + 25 + 13 + + + + + + + + + + false + + + + true + + + + This script must create a NumPy array of dimension (m,n) named <b>sample</b><br>- where m is the number of points in the sample<br>- where n is the number of input variables + + + + + + + false + + + + DejaVu Sans Mono + + + + + + + + + + + + false + + + Load sample from a CSV file + + + sampleDefinitionMethodBG + + + + + + + + + Qt::Horizontal + + + QSizePolicy::Fixed + + + + 25 + 10 + + + + + + + + false + + + CSV File: + + + + + + + false + + + + + + + false + + + Choose File... + + + + + + + + + + + + + diff --git a/src/salome/parametric/gui/wizard.py b/src/salome/parametric/gui/wizard.py index 0fa04d3..4aa49b4 100644 --- a/src/salome/parametric/gui/wizard.py +++ b/src/salome/parametric/gui/wizard.py @@ -65,6 +65,8 @@ class Wizard(QtGui.QWidget, Ui_Wizard): self.step() def step(self): + if self.step_methods[self.curstep] is not None: + self.step_methods[self.curstep](self) for i in range(len(self.step_texts)): if i == self.curstep: self.step_labels[i].setText("" + self.tr(self.step_texts[i]) + "") @@ -82,8 +84,6 @@ class Wizard(QtGui.QWidget, Ui_Wizard): else: self.nextButton.show() self.OKButton.hide() - if self.step_methods[self.curstep] is not None: - self.step_methods[self.curstep](self) def define_values(self): exchange_vars = self.select_vars_frame.getSelectedExchangeVariables() -- 2.39.2