Python package tree simplification.
logger = Logger("PARAMETRIC", color = termcolor.BLUE)
logger.setLevel(logging.DEBUG)
-from salome.parametric.study import ParametricStudyEditor
+from salome.parametric import ParametricStudyEditor
class PARAMETRIC(PARAMETRIC_ORB__POA.PARAMETRIC_Gen, SALOME_ComponentPy_i, SALOME_DriverPy_i):
# You should have received a copy of the GNU Lesser General Public License
# along with SALOME PARAMETRIC module. If not, see <http://www.gnu.org/licenses/>.
-import os
import logging
from PyQt4 import QtGui, QtCore
from salome.kernel import termcolor
logger = Logger("PARAMETRICGUI", color = termcolor.GREEN_FG)
#logger.setLevel(logging.ERROR)
-from salome.kernel.parametric import study_exchange_vars
import PARAMETRIC
-from salome.parametric.gui.mainpanel import MainPanel
-from salome.parametric.study import ParametricStudyEditor
+from salome.parametric.gui import MainPanel
+from salome.parametric import ParametricStudyEditor
################################################
# GUI context class
+# 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 <http://www.gnu.org/licenses/>.
+
+import study
+
+ParametricStudy = study.ParametricStudy
+ParametricVariable = study.ParametricVariable
+ParametricStudyEditor = study.ParametricStudyEditor
+# 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 <http://www.gnu.org/licenses/>.
+
+import mainpanel
+
+MainPanel = mainpanel.MainPanel
varrange.stepSpinBox.setValue(var.step)
self.varwidgets[var.name] = varrange
self.layout().insertWidget(self.layout().count()-1, varrange)
+
+ def check_values(self):
+ return True
import salome
from salome.kernel.studyedit import getStudyEditor
-from salome.parametric.study import ParametricStudy
+from salome.parametric import ParametricStudy
from execparams_ui import Ui_ExecParams
self.connect(self.selectFromSalomeButton, QtCore.SIGNAL("clicked()"), self.select_from_salome)
self.case_entry = None
+ def set_pyscript_label_from_vars(self, exchange_vars):
+ text = ""
+ input_var_names = [var.name for var in exchange_vars.inputVarList]
+ text += "This script can use variable"
+ if len(input_var_names) > 1:
+ text += "s"
+ for i, var in enumerate(input_var_names):
+ if len(input_var_names) > 1 and i == len(input_var_names) - 1:
+ text += " and"
+ elif i != 0:
+ text += ","
+ text += " <b>" + var + "</b>"
+ text += "."
+ output_var_names = [var.name for var in exchange_vars.outputVarList]
+ if len(output_var_names) > 0:
+ text += "<br>It must create variable"
+ if len(output_var_names) > 1:
+ text += "s"
+ for i, var in enumerate(output_var_names):
+ if len(output_var_names) > 1 and i == len(output_var_names) - 1:
+ text += " and"
+ elif i != 0:
+ text += ","
+ text += " <b>" + var + "</b>"
+ text += "."
+ self.pyscriptLabel.setText(text)
+
def select_from_salome(self):
nb_entries = salome.sg.SelectedCount()
if nb_entries < 1:
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.python_script = str(self.pythonScriptTE.toPlainText())
param_study.name = str(self.studyNameLE.text())
param_study.nb_parallel_computations = self.nbParallelSB.value()
self.pythonScriptTE.setText(param_study.python_script)
self.studyNameLE.setText(param_study.name)
self.nbParallelSB.setValue(param_study.nb_parallel_computations)
+
+ def check_values(self):
+ return True
<property name="title">
<string>Solver Code</string>
</property>
- <layout class="QVBoxLayout" name="verticalLayout_2">
+ <layout class="QVBoxLayout" name="verticalLayout_3">
<item>
<widget class="QRadioButton" name="salomeComponentRB">
<property name="text">
</item>
<item>
<widget class="QRadioButton" name="pythonScriptRB">
- <property name="enabled">
- <bool>false</bool>
- </property>
<property name="text">
<string>Python Script</string>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>25</width>
- <height>10</height>
+ <height>13</height>
</size>
</property>
</spacer>
</item>
<item>
- <widget class="QTextEdit" name="pythonScriptTE">
- <property name="enabled">
- <bool>false</bool>
- </property>
- </widget>
+ <layout class="QVBoxLayout" name="verticalLayout_2">
+ <item>
+ <widget class="QLabel" name="pyscriptLabel">
+ <property name="font">
+ <font>
+ <italic>true</italic>
+ </font>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QTextEdit" name="pythonScriptTE"/>
+ </item>
+ </layout>
</item>
</layout>
</item>
output_var_list = [study_exchange_vars.Variable(varname) for varname in param_study.output_vars]
exchange_vars = study_exchange_vars.ExchangeVariables(input_var_list, output_var_list)
self.setExchangeVariables(exchange_vars)
+
+ def check_values(self):
+ if self.selectedInputVarListWidget.count() == 0:
+ QtGui.QMessageBox.critical(self, self.tr("Error"),
+ self.tr("There must be at least one selected input variable"))
+ return False
+ else:
+ return True
from selectvars import SelectVarsFrame
from definevalues import DefineValuesFrame
from execparams import ExecParamsFrame
-from salome.parametric.study import ParametricVariable, ParametricStudy, ParametricStudyEditor
+from salome.parametric import ParametricVariable, ParametricStudy, ParametricStudyEditor
class Wizard(QtGui.QWidget, Ui_Wizard):
self.view_id = None
def next_step(self):
- self.curstep += 1
- self.step()
+ if self.step_frames[self.curstep].check_values():
+ self.curstep += 1
+ self.step()
def previous_step(self):
- self.curstep -= 1
- self.step()
+ if self.step_frames[self.curstep].check_values():
+ self.curstep -= 1
+ self.step()
def step(self):
for i in range(len(self.step_texts)):
exchange_vars = self.select_vars_frame.getSelectedExchangeVariables()
self.define_values_frame.set_variables(exchange_vars.inputVarList)
+ def set_pyscript_label(self):
+ exchange_vars = self.select_vars_frame.getSelectedExchangeVariables()
+ self.exec_params_frame.set_pyscript_label_from_vars(exchange_vars)
+
def validate(self):
+ if not self.step_frames[self.curstep].check_values():
+ return
param_study = ParametricStudy()
# Input variables
for (name, range_widget) in self.define_values_frame.varwidgets.iteritems():
step_methods = [None,
define_values,
- None]
+ set_pyscript_label]