1 # Copyright (C) 2012 EDF
3 # This file is part of SALOME PARAMETRIC module.
5 # SALOME PARAMETRIC module is free software: you can redistribute it and/or modify
6 # it under the terms of the GNU Lesser General Public License as published by
7 # the Free Software Foundation, either version 3 of the License, or
8 # (at your option) any later version.
10 # SALOME PARAMETRIC module is distributed in the hope that it will be useful,
11 # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 # GNU Lesser General Public License for more details.
15 # You should have received a copy of the GNU Lesser General Public License
16 # along with SALOME PARAMETRIC module. If not, see <http://www.gnu.org/licenses/>.
18 from PyQt4 import QtGui, QtCore
21 from salome.kernel.studyedit import getStudyEditor
23 from salome.parametric.study import ParametricStudy
24 from execparams_ui import Ui_ExecParams
27 class ExecParamsFrame(QtGui.QWidget, Ui_ExecParams):
29 def __init__(self, parent = None):
30 QtGui.QWidget.__init__(self, parent)
32 self.connect(self.selectFromSalomeButton, QtCore.SIGNAL("clicked()"), self.select_from_salome)
33 self.case_entry = None
35 def select_from_salome(self):
36 nb_entries = salome.sg.SelectedCount()
38 QtGui.QMessageBox.information(self, self.tr("Select from Salome"),
39 self.tr("Please select an entry in Salome Object Browser"))
41 QtGui.QMessageBox.information(self, self.tr("Select from Salome"),
42 self.tr("Only one entry must be selected in Salome Object Browser"))
44 self.set_case_entry(salome.sg.getSelected(0))
46 def set_case_entry(self, entry):
47 self.case_entry = entry
48 self.caseEntryLE.setText(getStudyEditor().study.FindObjectID(entry).GetName() + " (" + entry + ")")
50 def gui_to_study(self, param_study):
51 if self.salomeComponentRB.isChecked():
52 param_study.solver_code_type = ParametricStudy.SALOME_COMPONENT
53 param_study.salome_component_name = str(self.componentNameLE.text())
54 param_study.solver_case_entry = self.case_entry
56 param_study.solver_code_type = ParametricStudy.PYTHON_SCRIPT
57 param_study.python_script = str(self.pythonScriptTE.text())
58 param_study.name = str(self.studyNameLE.text())
59 param_study.nb_parallel_computations = self.nbParallelSB.value()
61 def study_to_gui(self, param_study):
62 if param_study.solver_code_type == ParametricStudy.SALOME_COMPONENT:
63 self.salomeComponentRB.setChecked(True)
64 self.componentNameLE.setText(param_study.salome_component_name)
65 self.set_case_entry(param_study.solver_case_entry)
67 self.pythonScriptRB.setChecked(True)
68 self.pythonScriptTE.setText(param_study.python_script)
69 self.studyNameLE.setText(param_study.name)
70 self.nbParallelSB.setValue(param_study.nb_parallel_computations)