From 614cb3544353c1719bf004128b12df19214ff04e Mon Sep 17 00:00:00 2001 From: Renaud Barate Date: Thu, 30 Aug 2012 11:22:02 +0200 Subject: [PATCH] Replace Eficas by a custom GUI for the definition of execution parameters --- src/PARAMETRIC/PARAMETRIC.py | 7 +- .../{parametric/gui/eficas => }/__init__.py | 0 src/salome/parametric/gui/CMakeLists.txt | 2 +- src/salome/parametric/gui/definevalues.py | 2 + src/salome/parametric/gui/eficas/appli.py | 124 ---------- .../configuration_parametric_exec_params.py | 43 ---- .../gui/eficas/parametric_exec_params_cata.py | 39 ---- src/salome/parametric/gui/eficas/prefs.py | 18 -- .../eficas/prefs_parametric_exec_params.py | 21 -- src/salome/parametric/gui/execparams.py | 70 ++++++ src/salome/parametric/gui/execparams.ui | 213 ++++++++++++++++++ src/salome/parametric/gui/mainpanel.py | 8 +- src/salome/parametric/gui/wizard.py | 16 +- src/salome/parametric/gui/wizard.ui | 19 +- src/salome/parametric/study.py | 40 ++-- 15 files changed, 320 insertions(+), 302 deletions(-) rename src/salome/{parametric/gui/eficas => }/__init__.py (100%) delete mode 100644 src/salome/parametric/gui/eficas/appli.py delete mode 100644 src/salome/parametric/gui/eficas/configuration_parametric_exec_params.py delete mode 100644 src/salome/parametric/gui/eficas/parametric_exec_params_cata.py delete mode 100644 src/salome/parametric/gui/eficas/prefs.py delete mode 100644 src/salome/parametric/gui/eficas/prefs_parametric_exec_params.py create mode 100644 src/salome/parametric/gui/execparams.py create mode 100644 src/salome/parametric/gui/execparams.ui diff --git a/src/PARAMETRIC/PARAMETRIC.py b/src/PARAMETRIC/PARAMETRIC.py index 850164d..831ef4d 100644 --- a/src/PARAMETRIC/PARAMETRIC.py +++ b/src/PARAMETRIC/PARAMETRIC.py @@ -99,10 +99,10 @@ class PARAMETRIC(PARAMETRIC_ORB__POA.PARAMETRIC_Gen, SALOME_ComponentPy_i, SALOM if param_input_tc is None: raise Exception ("Internal error: No typecode found for type 'SALOME_TYPES/ParametricInput'") foreach = pilot.ForEachLoop("ForEach", param_input_tc) - foreach.edGetNbOfBranchesPort().edInit(param_study.get_exec_param("NUMBER_OF_PARALLEL_COMPUTATIONS")) + foreach.edGetNbOfBranchesPort().edInit(param_study.nb_parallel_computations) proc.edAddChild(foreach) - solver_code = param_study.get_exec_param("SOLVER_CODE") + solver_code = param_study.salome_component_name solver_compo_inst = proc.createComponentInstance(solver_code) solver_compo_def = self.session_catalog._componentMap[solver_code] @@ -113,7 +113,7 @@ class PARAMETRIC(PARAMETRIC_ORB__POA.PARAMETRIC_Gen, SALOME_ComponentPy_i, SALOM init_solver = solver_compo_def._serviceMap["Init"].clone(None) init_solver.setComponent(solver_compo_inst) init_solver.getInputPort("studyID").edInit(studyId) - entry = self._parse_entry(param_study.get_exec_param("DETERMINISTIC_CASE_ENTRY")) + entry = self._parse_entry(param_study.solver_case_entry) init_solver.getInputPort("detCaseEntry").edInit(entry) foreach.edSetInitNode(init_solver) @@ -174,7 +174,6 @@ class PARAMETRIC(PARAMETRIC_ORB__POA.PARAMETRIC_Gen, SALOME_ComponentPy_i, SALOM # Launch computation executor = pilot.ExecutorSwig() executor.RunPy(proc) - state = proc.getEffectiveState() if proc.getEffectiveState() != pilot.DONE: msg = proc.getErrorReport() if msg != "": diff --git a/src/salome/parametric/gui/eficas/__init__.py b/src/salome/__init__.py similarity index 100% rename from src/salome/parametric/gui/eficas/__init__.py rename to src/salome/__init__.py diff --git a/src/salome/parametric/gui/CMakeLists.txt b/src/salome/parametric/gui/CMakeLists.txt index 8fccb25..f1cf018 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) +SET(PYUIC_FILES wizard_ui.py varrange_ui.py execparams_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 5fd1166..43c1c72 100644 --- a/src/salome/parametric/gui/definevalues.py +++ b/src/salome/parametric/gui/definevalues.py @@ -49,6 +49,7 @@ class DefineValuesFrame(QtGui.QWidget): varrange.nameLabel.setText(var) self.varwidgets[var] = varrange self.layout().addWidget(varrange) + self.layout().addStretch() def set_ranges_from_param_study(self, param_study): for var in param_study.input_vars: @@ -59,3 +60,4 @@ class DefineValuesFrame(QtGui.QWidget): varrange.stepSpinBox.setValue(var.step) self.varwidgets[var.name] = varrange self.layout().addWidget(varrange) + self.layout().addStretch() diff --git a/src/salome/parametric/gui/eficas/appli.py b/src/salome/parametric/gui/eficas/appli.py deleted file mode 100644 index e9a03c0..0000000 --- a/src/salome/parametric/gui/eficas/appli.py +++ /dev/null @@ -1,124 +0,0 @@ -# -*- coding: utf-8 -*- -# -# Copyright (C) 2012 EDF -# -# This file is part of SALOME PARAMETRIC module. -# -# SALOME PARAMETRIC module is free software: you can redistribute it and/or modify -# it under the terms of the GNU Lesser General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# SALOME PARAMETRIC module is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU Lesser General Public License for more details. -# -# You should have received a copy of the GNU Lesser General Public License -# along with SALOME PARAMETRIC module. If not, see . - -import os -import sys -import re -import tempfile - -from PyQt4.QtGui import QMessageBox - -import salome -import SalomePyQt -sgPyQt = SalomePyQt.SalomePyQt() - -from salome.kernel.logger import Logger -from salome.kernel import termcolor -logger = Logger("salome.openturns.eficas_yacs_schema.appli", - color = termcolor.GREEN_FG) -from salome.kernel.studyedit import getStudyEditor - -import eficasSalome - - -class SalomeEntry: - - enable_salome_selection = True - help_message = u"Une entrée de l'arbre d'étude de Salome est attendue" - - def __init__(self, entryStr): - self._entry = entryStr - - @staticmethod - def __convert__(entryStr): - return SalomeEntry(entryStr) - - @staticmethod - def get_selected_value(selected_entry, study_editor): - sobj = study_editor.study.FindObjectID(selected_entry) - name = sobj.GetName() - return "%s (%s)" % (name, selected_entry) - -def parse_entry(selected_value): - """ - Find entry if selected_value is something like "name (entry)" - """ - entry = selected_value - match = re.search("\((.*)\)$", entry) - if match is not None: - entry = match.group(1) - return entry - -class EficasFrame(eficasSalome.MyEficas): - """ - This class launches Eficas for PARAMETRIC module. The messages in this class are in - french because they are displayed in Eficas interface. - - """ - def __init__(self, parent = None): - self.codedir = os.path.dirname(__file__) - sys.path[:0] = [self.codedir] - eficasSalome.MyEficas.__init__(self, parent, "parametric_exec_params") - self.editor = getStudyEditor() - - def selectGroupFromSalome(self, kwType = None, editor = None): - """ - Select an entry from Salome object browser - """ - nbEntries = salome.sg.SelectedCount() - if nbEntries < 1: - msg = u"Veuillez sélectionner une entrée de l'arbre d'étude de Salome" - QMessageBox.information(self, self.tr(u"Sélection depuis Salome"), self.tr(msg)) - return [], msg - elif nbEntries > 1: - msg = u"Une seule entrée doit être sélectionnée dans l'arbre d'étude de Salome" - QMessageBox.information(self, self.tr(u"Sélection depuis Salome"), self.tr(msg)) - return [], msg - else: - try: - value = kwType.get_selected_value(salome.sg.getSelected(0), self.editor) - msg = u"L'entrée de l'arbre d'étude de Salome a été sélectionnée" - return [value], msg - except Exception, e: - QMessageBox.information(self, self.tr(u"Sélection depuis Salome"), self.tr(unicode(e))) - return [], unicode(e) - - def get_text_jdc(self): - """ - Return the currently edited JDC as text - """ - editor_index = self.viewmanager.myQtab.currentIndex() - if editor_index < 0: - return None - eficas_editor = self.viewmanager.dict_editors[editor_index] - return eficas_editor.get_text_JDC(eficas_editor.format) - - def closeEvent(self, event): - while self.codedir in sys.path: - sys.path.remove(self.codedir) - eficasSalome.MyEficas.closeEvent(self, event) - - def set_exec_params_from_param_study(self, param_study): - # No clean way to load JDC directly in Eficas, use a temp file instead - (fd, filename) = tempfile.mkstemp() - os.close(fd) - f = open(filename, "w") - f.write(param_study.exec_params) - f.close() - self.viewmanager.handleOpen(filename) diff --git a/src/salome/parametric/gui/eficas/configuration_parametric_exec_params.py b/src/salome/parametric/gui/eficas/configuration_parametric_exec_params.py deleted file mode 100644 index d6768e9..0000000 --- a/src/salome/parametric/gui/eficas/configuration_parametric_exec_params.py +++ /dev/null @@ -1,43 +0,0 @@ -# Copyright (C) 2012 EDF -# -# This file is part of SALOME PARAMETRIC module. -# -# SALOME PARAMETRIC module is free software: you can redistribute it and/or modify -# it under the terms of the GNU Lesser General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# SALOME PARAMETRIC module is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU Lesser General Public License for more details. -# -# You should have received a copy of the GNU Lesser General Public License -# along with SALOME PARAMETRIC module. If not, see . - -import os - -from Editeur.catadesc import CatalogDescription -from InterfaceQT4.configuration import CONFIG_BASE - -class CONFIG(CONFIG_BASE): - - def __init__(self, appli, repIni): - """ - This class stores the configuration parameters for Eficas - """ - CONFIG_BASE.__init__(self, appli, repIni, '.parametric_exec_params') - - # Configuration parameters - self.savedir = os.getenv("HOME") - catapath = os.path.join(os.path.dirname(__file__), "parametric_exec_params_cata.py") - self.catalogues = (CatalogDescription("parametric_exec_params", catapath),) - - def save_params(self): - pass - -def make_config(appli, rep): - return CONFIG(appli, rep) - -def make_config_style(appli, rep): - return None diff --git a/src/salome/parametric/gui/eficas/parametric_exec_params_cata.py b/src/salome/parametric/gui/eficas/parametric_exec_params_cata.py deleted file mode 100644 index d63aa97..0000000 --- a/src/salome/parametric/gui/eficas/parametric_exec_params_cata.py +++ /dev/null @@ -1,39 +0,0 @@ -# -*- coding: utf-8 -*- -# -# Copyright (C) 2012 EDF -# -# This file is part of SALOME PARAMETRIC module. -# -# SALOME PARAMETRIC module is free software: you can redistribute it and/or modify -# it under the terms of the GNU Lesser General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# SALOME PARAMETRIC module is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU Lesser General Public License for more details. -# -# You should have received a copy of the GNU Lesser General Public License -# along with SALOME PARAMETRIC module. If not, see . - -from salome.parametric.gui.eficas.appli import SalomeEntry -from Accas import * - -JdC = JDC_CATA(regles = (UN_PARMI('EXECUTION_PARAMETERS',)), - ) - -EXECUTION_PARAMETERS = PROC( - nom = "EXECUTION_PARAMETERS", op = None, - fr = u"Paramètres d'exécution de l'étude paramétrique", - PARAMETRIC_STUDY_NAME = SIMP(statut = "o", typ = 'TXM', - defaut = "Parametric Study", - fr = u"Nom de l'étude paramétrique qui sera créée dans l'arbre d'étude de Salome"), - SOLVER_CODE = SIMP(statut = "o", typ = 'TXM', - defaut = "DEVIATION", - fr = u"Nom du composant de calcul"), - DETERMINISTIC_CASE_ENTRY = SIMP(statut = "o", typ = SalomeEntry, - fr = u"Cas déterministe dans l'arbre d'étude de Salome"), - NUMBER_OF_PARALLEL_COMPUTATIONS = SIMP(statut = "o", typ = 'I', defaut = 1, - fr = u"Nombre de branches de calcul parallèles"), -) diff --git a/src/salome/parametric/gui/eficas/prefs.py b/src/salome/parametric/gui/eficas/prefs.py deleted file mode 100644 index 95b5101..0000000 --- a/src/salome/parametric/gui/eficas/prefs.py +++ /dev/null @@ -1,18 +0,0 @@ -# Copyright (C) 2012 EDF -# -# This file is part of SALOME PARAMETRIC module. -# -# SALOME PARAMETRIC module is free software: you can redistribute it and/or modify -# it under the terms of the GNU Lesser General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# SALOME PARAMETRIC module is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU Lesser General Public License for more details. -# -# You should have received a copy of the GNU Lesser General Public License -# along with SALOME PARAMETRIC module. If not, see . - -code = "parametric_exec_params" diff --git a/src/salome/parametric/gui/eficas/prefs_parametric_exec_params.py b/src/salome/parametric/gui/eficas/prefs_parametric_exec_params.py deleted file mode 100644 index 07e2224..0000000 --- a/src/salome/parametric/gui/eficas/prefs_parametric_exec_params.py +++ /dev/null @@ -1,21 +0,0 @@ -# Copyright (C) 2012 EDF -# -# This file is part of SALOME PARAMETRIC module. -# -# SALOME PARAMETRIC module is free software: you can redistribute it and/or modify -# it under the terms of the GNU Lesser General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# SALOME PARAMETRIC module is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU Lesser General Public License for more details. -# -# You should have received a copy of the GNU Lesser General Public License -# along with SALOME PARAMETRIC module. If not, see . - -import os - -repIni = os.path.dirname(__file__) -INSTALLDIR = os.getenv("EFICAS_ROOT") diff --git a/src/salome/parametric/gui/execparams.py b/src/salome/parametric/gui/execparams.py new file mode 100644 index 0000000..84a8b55 --- /dev/null +++ b/src/salome/parametric/gui/execparams.py @@ -0,0 +1,70 @@ +# Copyright (C) 2012 EDF +# +# This file is part of SALOME PARAMETRIC module. +# +# SALOME PARAMETRIC module is free software: you can redistribute it and/or modify +# it under the terms of the GNU Lesser General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# SALOME PARAMETRIC module is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Lesser General Public License for more details. +# +# 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 + +import salome +from salome.kernel.studyedit import getStudyEditor + +from salome.parametric.study import ParametricStudy +from execparams_ui import Ui_ExecParams + + +class ExecParamsFrame(QtGui.QWidget, Ui_ExecParams): + + def __init__(self, parent = None): + QtGui.QWidget.__init__(self, parent) + self.setupUi(self) + self.connect(self.selectFromSalomeButton, QtCore.SIGNAL("clicked()"), self.select_from_salome) + self.case_entry = None + + def select_from_salome(self): + nb_entries = salome.sg.SelectedCount() + if nb_entries < 1: + QtGui.QMessageBox.information(self, self.tr("Select from Salome"), + self.tr("Please select an entry in Salome Object Browser")) + elif nb_entries > 1: + QtGui.QMessageBox.information(self, self.tr("Select from Salome"), + self.tr("Only one entry must be selected in Salome Object Browser")) + else: + self.set_case_entry(salome.sg.getSelected(0)) + + def set_case_entry(self, entry): + self.case_entry = entry + self.caseEntryLE.setText(getStudyEditor().study.FindObjectID(entry).GetName() + " (" + entry + ")") + + def gui_to_study(self, param_study): + if self.salomeComponentRB.isChecked(): + param_study.solver_code_type = ParametricStudy.SALOME_COMPONENT + param_study.salome_component_name = str(self.componentNameLE.text()) + param_study.solver_case_entry = self.case_entry + else: + param_study.solver_code_type = ParametricStudy.PYTHON_SCRIPT + param_study.python_script = str(self.pythonScriptTE.text()) + param_study.name = str(self.studyNameLE.text()) + param_study.nb_parallel_computations = self.nbParallelSB.value() + + def study_to_gui(self, param_study): + if param_study.solver_code_type == ParametricStudy.SALOME_COMPONENT: + self.salomeComponentRB.setChecked(True) + self.componentNameLE.setText(param_study.salome_component_name) + self.set_case_entry(param_study.solver_case_entry) + else: + self.pythonScriptRB.setChecked(True) + self.pythonScriptTE.setText(param_study.python_script) + self.studyNameLE.setText(param_study.name) + self.nbParallelSB.setValue(param_study.nb_parallel_computations) diff --git a/src/salome/parametric/gui/execparams.ui b/src/salome/parametric/gui/execparams.ui new file mode 100644 index 0000000..2270933 --- /dev/null +++ b/src/salome/parametric/gui/execparams.ui @@ -0,0 +1,213 @@ + + + ExecParams + + + + 0 + 0 + 765 + 720 + + + + Execution Parameters + + + + + + Solver Code + + + + + + SALOME Component + + + true + + + solverCodeTypeBG + + + + + + + + + Qt::Horizontal + + + QSizePolicy::Fixed + + + + 25 + 10 + + + + + + + + Component Name: + + + + + + + DEVIATION + + + + + + + Qt::Horizontal + + + QSizePolicy::Fixed + + + + 30 + 10 + + + + + + + + Case Entry: + + + + + + + true + + + + + + + Select + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + + false + + + Python Script + + + solverCodeTypeBG + + + + + + + + + Qt::Horizontal + + + QSizePolicy::Fixed + + + + 25 + 10 + + + + + + + + false + + + + + + + + + + + + Other Parameters + + + + + + Parametric Study + + + + + + + Number of Parallel Computations: + + + + + + + Parametric Study Name: + + + + + + + 1 + + + 1000000 + + + 1 + + + + + + + + + + + + + + diff --git a/src/salome/parametric/gui/mainpanel.py b/src/salome/parametric/gui/mainpanel.py index f34451a..07ce22f 100644 --- a/src/salome/parametric/gui/mainpanel.py +++ b/src/salome/parametric/gui/mainpanel.py @@ -24,11 +24,11 @@ class MainPanel(): def new_study(self): wizard = Wizard(sgPyQt.getDesktop()) - id = sgPyQt.createView("New Parametric Study", wizard) - wizard.view_id = id + view_id = sgPyQt.createView("New Parametric Study", wizard) + wizard.view_id = view_id def edit_study(self, param_study): wizard = Wizard(sgPyQt.getDesktop()) wizard.set_study(param_study) - id = sgPyQt.createView(param_study.get_exec_param("PARAMETRIC_STUDY_NAME"), wizard) - wizard.view_id = id + view_id = sgPyQt.createView(param_study.name, wizard) + wizard.view_id = view_id diff --git a/src/salome/parametric/gui/wizard.py b/src/salome/parametric/gui/wizard.py index 533a0ff..0dfffb0 100644 --- a/src/salome/parametric/gui/wizard.py +++ b/src/salome/parametric/gui/wizard.py @@ -24,7 +24,7 @@ sgPyQt = SalomePyQt.SalomePyQt() from wizard_ui import Ui_Wizard from selectvars import SelectVarsFrame from definevalues import DefineValuesFrame -from salome.parametric.gui.eficas.appli import EficasFrame +from execparams import ExecParamsFrame from salome.parametric.study import ParametricVariable, ParametricStudy, ParametricStudyEditor @@ -43,7 +43,7 @@ class Wizard(QtGui.QWidget, Ui_Wizard): self.stepLayout.addWidget(self.step_labels[i]) self.select_vars_frame = SelectVarsFrame(self) self.define_values_frame = DefineValuesFrame(self) - self.exec_params_frame = EficasFrame(self) + self.exec_params_frame = ExecParamsFrame(self) self.step_frames = [self.select_vars_frame, self.define_values_frame, self.exec_params_frame] @@ -91,18 +91,18 @@ class Wizard(QtGui.QWidget, Ui_Wizard): param_study = ParametricStudy() # Input variables for (name, range_widget) in self.define_values_frame.varwidgets.iteritems(): - min = range_widget.fromSpinBox.value() - max = range_widget.toSpinBox.value() + minval = range_widget.fromSpinBox.value() + maxval = range_widget.toSpinBox.value() step = range_widget.stepSpinBox.value() - var = ParametricVariable(name, min, max, step) + var = ParametricVariable(name, minval, maxval, step) param_study.add_input_variable(var) # Output variables exch_vars = self.select_vars_frame.getSelectedExchangeVariables() for outvar in exch_vars.outputVarList: param_study.add_output_variable(outvar.name) # Execution parameters - exec_params_comm = self.exec_params_frame.get_text_jdc() - param_study.set_exec_params(exec_params_comm) + self.exec_params_frame.gui_to_study(param_study) + # Save to Salome study ed = ParametricStudyEditor() if self.entry is not None: @@ -116,7 +116,7 @@ class Wizard(QtGui.QWidget, Ui_Wizard): self.entry = param_study.entry self.select_vars_frame.set_vars_from_param_study(param_study) self.define_values_frame.set_ranges_from_param_study(param_study) - self.exec_params_frame.set_exec_params_from_param_study(param_study) + self.exec_params_frame.study_to_gui(param_study) def close(self): QtGui.QWidget.close(self) diff --git a/src/salome/parametric/gui/wizard.ui b/src/salome/parametric/gui/wizard.ui index 627a7e3..b5fb487 100644 --- a/src/salome/parametric/gui/wizard.ui +++ b/src/salome/parametric/gui/wizard.ui @@ -19,6 +19,12 @@ + + + 0 + 0 + + QFrame::StyledPanel @@ -28,19 +34,6 @@ - - - - Qt::Vertical - - - - 20 - 198 - - - - diff --git a/src/salome/parametric/study.py b/src/salome/parametric/study.py index de68dd5..703f731 100644 --- a/src/salome/parametric/study.py +++ b/src/salome/parametric/study.py @@ -29,21 +29,6 @@ COMPONENT_ICON = "PARAMETRIC_small.png" PARAM_STUDY_ICON = "param_study.png" PARAM_STUDY_TYPE_ID = 1 -def jdc_to_dict(jdc, command_list): - """ - This tricky function transforms a JdC with a single command into a - dictionary that can be used more easily from a Python context (thanks to - M. Courtois and G. Boulant). - """ - context = {} - for command in command_list: - context[command] = _args_to_dict - exec "parameters = " + jdc.strip() in context - return context['parameters'] - -def _args_to_dict(**kwargs): - return kwargs - class ParametricStudyEditor: """ This class provides utility methods to edit the component "Parametric" in @@ -74,7 +59,7 @@ class ParametricStudyEditor: def _set_sobj(self, parametric_study, sobj): self.editor.setItem(sobj, - name = parametric_study.get_exec_param("PARAMETRIC_STUDY_NAME"), + name = parametric_study.name, comment = cPickle.dumps(parametric_study), icon = PARAM_STUDY_ICON, typeId = PARAM_STUDY_TYPE_ID) @@ -90,19 +75,27 @@ class ParametricStudyEditor: class ParametricVariable: - def __init__(self, name, min = None, max = None, step = None): + def __init__(self, name, minval = None, maxval = None, step = None): self.name = name - self.min = min - self.max = max + self.min = minval + self.max = maxval self.step = step class ParametricStudy: + + SALOME_COMPONENT = 0 + PYTHON_SCRIPT = 1 def __init__(self): self.input_vars = [] self.output_vars = [] - self.exec_params = None + self.solver_code_type = ParametricStudy.SALOME_COMPONENT + self.salome_component_name = None + self.solver_case_entry = None + self.python_script = None + self.name = None + self.nb_parallel_computations = 1 self.data = None self.datasize = 0 self._value_dict = None @@ -114,13 +107,6 @@ class ParametricStudy: def add_output_variable(self, varname): self.output_vars.append(varname) - def set_exec_params(self, params): - self.exec_params = params - - def get_exec_param(self, name): - param_dict = jdc_to_dict(self.exec_params, ["EXECUTION_PARAMETERS"]) - return param_dict[name] - def generate_data(self): self.data = {} self.datasize = 0 -- 2.39.2