]> SALOME platform Git repositories - modules/parametric.git/commitdiff
Salome HOME
Add GUI for different methods to define input sample
authorRenaud Barate <renaud.barate@edf.fr>
Wed, 27 Feb 2013 17:32:31 +0000 (18:32 +0100)
committerRenaud Barate <renaud.barate@edf.fr>
Wed, 27 Feb 2013 17:32:31 +0000 (18:32 +0100)
src/salome/parametric/gui/CMakeLists.txt
src/salome/parametric/gui/definevalues.py
src/salome/parametric/gui/definevalues.ui [new file with mode: 0644]
src/salome/parametric/gui/wizard.py

index 0bf08b17e2f4882c807648132f0c1544264db8b6..1766c66b3a46ccbc250fde2c0e134387ba9a137f 100644 (file)
@@ -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 <http://www.gnu.org/licenses/>.
 
-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})
index 4d9ee27c30f6bd57deb1babf1e292f7b44690f65..4b322f758eb947453701bf671aca13971bbf2a00 100644 (file)
 # 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/>.
 
-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 (file)
index 0000000..4e138ab
--- /dev/null
@@ -0,0 +1,204 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<ui version="4.0">
+ <class>SampleDefinition</class>
+ <widget class="QWidget" name="SampleDefinition">
+  <property name="geometry">
+   <rect>
+    <x>0</x>
+    <y>0</y>
+    <width>765</width>
+    <height>720</height>
+   </rect>
+  </property>
+  <property name="windowTitle">
+   <string>Sample Definition</string>
+  </property>
+  <layout class="QVBoxLayout" name="verticalLayout">
+   <item>
+    <widget class="QLabel" name="label_3">
+     <property name="text">
+      <string>Choose a method to define the input sample:</string>
+     </property>
+    </widget>
+   </item>
+   <item>
+    <widget class="QRadioButton" name="variableRangeRB">
+     <property name="text">
+      <string>Define variable(s) range(s)</string>
+     </property>
+     <property name="checked">
+      <bool>true</bool>
+     </property>
+     <attribute name="buttonGroup">
+      <string notr="true">sampleDefinitionMethodBG</string>
+     </attribute>
+    </widget>
+   </item>
+   <item>
+    <layout class="QHBoxLayout" name="horizontalLayout">
+     <item>
+      <spacer name="horizontalSpacer_2">
+       <property name="orientation">
+        <enum>Qt::Horizontal</enum>
+       </property>
+       <property name="sizeType">
+        <enum>QSizePolicy::Fixed</enum>
+       </property>
+       <property name="sizeHint" stdset="0">
+        <size>
+         <width>25</width>
+         <height>10</height>
+        </size>
+       </property>
+      </spacer>
+     </item>
+     <item>
+      <widget class="QScrollArea" name="variablesRangesSA">
+       <property name="sizePolicy">
+        <sizepolicy hsizetype="Expanding" vsizetype="Minimum">
+         <horstretch>0</horstretch>
+         <verstretch>0</verstretch>
+        </sizepolicy>
+       </property>
+       <property name="widgetResizable">
+        <bool>true</bool>
+       </property>
+       <widget class="QWidget" name="variablesRangesWidget">
+        <layout class="QVBoxLayout" name="verticalLayout_3"/>
+       </widget>
+      </widget>
+     </item>
+    </layout>
+   </item>
+   <item>
+    <widget class="QRadioButton" name="pythonScriptRB">
+     <property name="enabled">
+      <bool>false</bool>
+     </property>
+     <property name="text">
+      <string>Define sample with a Python script</string>
+     </property>
+     <attribute name="buttonGroup">
+      <string notr="true">sampleDefinitionMethodBG</string>
+     </attribute>
+    </widget>
+   </item>
+   <item>
+    <layout class="QHBoxLayout" name="horizontalLayout_2">
+     <item>
+      <spacer name="horizontalSpacer_3">
+       <property name="orientation">
+        <enum>Qt::Horizontal</enum>
+       </property>
+       <property name="sizeType">
+        <enum>QSizePolicy::Fixed</enum>
+       </property>
+       <property name="sizeHint" stdset="0">
+        <size>
+         <width>25</width>
+         <height>13</height>
+        </size>
+       </property>
+      </spacer>
+     </item>
+     <item>
+      <layout class="QVBoxLayout" name="verticalLayout_2">
+       <item>
+        <widget class="QLabel" name="pyscriptLabel">
+         <property name="enabled">
+          <bool>false</bool>
+         </property>
+         <property name="font">
+          <font>
+           <italic>true</italic>
+          </font>
+         </property>
+         <property name="text">
+          <string>This script must create a NumPy array of dimension (m,n) named &lt;b&gt;sample&lt;/b&gt;&lt;br&gt;- where m is the number of points in the sample&lt;br&gt;- where n is the number of input variables</string>
+         </property>
+        </widget>
+       </item>
+       <item>
+        <widget class="QTextEdit" name="pythonScriptTE">
+         <property name="enabled">
+          <bool>false</bool>
+         </property>
+         <property name="font">
+          <font>
+           <family>DejaVu Sans Mono</family>
+          </font>
+         </property>
+        </widget>
+       </item>
+      </layout>
+     </item>
+    </layout>
+   </item>
+   <item>
+    <widget class="QRadioButton" name="loadSampleRB">
+     <property name="enabled">
+      <bool>false</bool>
+     </property>
+     <property name="text">
+      <string>Load sample from a CSV file</string>
+     </property>
+     <attribute name="buttonGroup">
+      <string notr="true">sampleDefinitionMethodBG</string>
+     </attribute>
+    </widget>
+   </item>
+   <item>
+    <layout class="QHBoxLayout" name="horizontalLayout_3">
+     <item>
+      <spacer name="horizontalSpacer_4">
+       <property name="orientation">
+        <enum>Qt::Horizontal</enum>
+       </property>
+       <property name="sizeType">
+        <enum>QSizePolicy::Fixed</enum>
+       </property>
+       <property name="sizeHint" stdset="0">
+        <size>
+         <width>25</width>
+         <height>10</height>
+        </size>
+       </property>
+      </spacer>
+     </item>
+     <item>
+      <widget class="QLabel" name="label">
+       <property name="enabled">
+        <bool>false</bool>
+       </property>
+       <property name="text">
+        <string>CSV File:</string>
+       </property>
+      </widget>
+     </item>
+     <item>
+      <widget class="QLineEdit" name="lineEdit">
+       <property name="enabled">
+        <bool>false</bool>
+       </property>
+      </widget>
+     </item>
+     <item>
+      <widget class="QPushButton" name="pushButton">
+       <property name="enabled">
+        <bool>false</bool>
+       </property>
+       <property name="text">
+        <string>Choose File...</string>
+       </property>
+      </widget>
+     </item>
+    </layout>
+   </item>
+  </layout>
+ </widget>
+ <resources/>
+ <connections/>
+ <buttongroups>
+  <buttongroup name="sampleDefinitionMethodBG"/>
+ </buttongroups>
+</ui>
index 0fa04d325fcb134bdbea56a352f620dfd8b57c1c..4aa49b49aea8f575e336d38aa2c9eca779766843 100644 (file)
@@ -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("<b>" + self.tr(self.step_texts[i]) + "</b>")
@@ -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()