]> SALOME platform Git repositories - modules/gui.git/commitdiff
Salome HOME
Add PyQt widget to select variables in variables lists
authorbarate <barate>
Mon, 31 Jan 2011 14:21:06 +0000 (14:21 +0000)
committerbarate <barate>
Mon, 31 Jan 2011 14:21:06 +0000 (14:21 +0000)
configure.ac
src/GUI_PY/Makefile.am [new file with mode: 0644]
src/GUI_PY/SelectVarsDialog.ui [new file with mode: 0644]
src/GUI_PY/__init__.py [new file with mode: 0644]
src/GUI_PY/selectvars.py [new file with mode: 0644]
src/Makefile.am

index 737fc007528ebaa9fbc5523c825decc962a736b2..e1df3e3bf02cbc80bdd1eb15c59cc36bb55a52b0 100644 (file)
@@ -676,6 +676,7 @@ AC_OUTPUT([ \
   src/SALOME_PYQT/SALOME_PYQT_GUI/Makefile \
   src/SALOME_PYQT/SALOME_PYQT_GUILight/Makefile \
   src/SALOME_PYQT/SalomePyQt/Makefile \
+  src/GUI_PY/Makefile \
   resources/Makefile \
   idl/Makefile \
   Makefile
diff --git a/src/GUI_PY/Makefile.am b/src/GUI_PY/Makefile.am
new file mode 100644 (file)
index 0000000..fd0aaa0
--- /dev/null
@@ -0,0 +1,36 @@
+#  Copyright (C) 2007-2010  CEA/DEN, EDF R&D, OPEN CASCADE
+#
+#  Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
+#  CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
+#
+#  This library 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 2.1 of the License.
+#
+#  This library 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 this library; if not, write to the Free Software
+#  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
+#
+#  See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+#
+
+include $(top_srcdir)/adm_local/unix/make_common_starter.am
+
+mypkgpythondir = $(salomepythondir)/salome/gui
+
+# Python modules to be installed
+mypkgpython_PYTHON = __init__.py \
+                     selectvars.py
+
+nodist_mypkgpython_PYTHON = SelectVarsDialog.py
+CLEANFILES  = $(nodist_mypkgpython_PYTHON)
+EXTRA_DIST += SelectVarsDialog.ui
+
+%.py:%.ui
+       $(PYUIC) $< -o $@
diff --git a/src/GUI_PY/SelectVarsDialog.ui b/src/GUI_PY/SelectVarsDialog.ui
new file mode 100644 (file)
index 0000000..504f32e
--- /dev/null
@@ -0,0 +1,310 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<ui version="4.0">
+ <class>SelectVarsDialog</class>
+ <widget class="QDialog" name="SelectVarsDialog">
+  <property name="geometry">
+   <rect>
+    <x>0</x>
+    <y>0</y>
+    <width>503</width>
+    <height>676</height>
+   </rect>
+  </property>
+  <property name="windowTitle">
+   <string>Select Variables of Interest</string>
+  </property>
+  <layout class="QVBoxLayout" name="verticalLayout">
+   <item>
+    <layout class="QHBoxLayout" name="horizontalLayout_2">
+     <item>
+      <spacer name="horizontalSpacer_4">
+       <property name="orientation">
+        <enum>Qt::Horizontal</enum>
+       </property>
+       <property name="sizeHint" stdset="0">
+        <size>
+         <width>40</width>
+         <height>20</height>
+        </size>
+       </property>
+      </spacer>
+     </item>
+     <item>
+      <widget class="QLabel" name="label">
+       <property name="text">
+        <string>Variables List</string>
+       </property>
+      </widget>
+     </item>
+     <item>
+      <widget class="QLineEdit" name="varListObjLineEdit">
+       <property name="readOnly">
+        <bool>true</bool>
+       </property>
+      </widget>
+     </item>
+     <item>
+      <widget class="QPushButton" name="selectButton">
+       <property name="text">
+        <string>Select</string>
+       </property>
+      </widget>
+     </item>
+     <item>
+      <spacer name="horizontalSpacer_3">
+       <property name="orientation">
+        <enum>Qt::Horizontal</enum>
+       </property>
+       <property name="sizeHint" stdset="0">
+        <size>
+         <width>40</width>
+         <height>20</height>
+        </size>
+       </property>
+      </spacer>
+     </item>
+    </layout>
+   </item>
+   <item>
+    <layout class="QHBoxLayout" name="horizontalLayout_4">
+     <item>
+      <layout class="QVBoxLayout" name="verticalLayout_5">
+       <item>
+        <widget class="QLabel" name="label_4">
+         <property name="text">
+          <string>All Input Variables</string>
+         </property>
+         <property name="alignment">
+          <set>Qt::AlignCenter</set>
+         </property>
+        </widget>
+       </item>
+       <item>
+        <widget class="QListWidget" name="allInputVarListWidget">
+         <property name="selectionMode">
+          <enum>QAbstractItemView::MultiSelection</enum>
+         </property>
+        </widget>
+       </item>
+      </layout>
+     </item>
+     <item>
+      <layout class="QVBoxLayout" name="verticalLayout_6">
+       <item>
+        <spacer name="verticalSpacer_3">
+         <property name="orientation">
+          <enum>Qt::Vertical</enum>
+         </property>
+         <property name="sizeHint" stdset="0">
+          <size>
+           <width>20</width>
+           <height>40</height>
+          </size>
+         </property>
+        </spacer>
+       </item>
+       <item>
+        <widget class="QPushButton" name="addInputVarButton">
+         <property name="text">
+          <string>Add</string>
+         </property>
+        </widget>
+       </item>
+       <item>
+        <widget class="QPushButton" name="removeInputVarButton">
+         <property name="text">
+          <string>Remove</string>
+         </property>
+        </widget>
+       </item>
+       <item>
+        <widget class="QPushButton" name="pushButton_8">
+         <property name="text">
+          <string>New...</string>
+         </property>
+        </widget>
+       </item>
+       <item>
+        <spacer name="verticalSpacer_4">
+         <property name="orientation">
+          <enum>Qt::Vertical</enum>
+         </property>
+         <property name="sizeHint" stdset="0">
+          <size>
+           <width>20</width>
+           <height>40</height>
+          </size>
+         </property>
+        </spacer>
+       </item>
+      </layout>
+     </item>
+     <item>
+      <layout class="QVBoxLayout" name="verticalLayout_7">
+       <item>
+        <widget class="QLabel" name="label_5">
+         <property name="text">
+          <string>Selected Input Variables</string>
+         </property>
+         <property name="alignment">
+          <set>Qt::AlignCenter</set>
+         </property>
+        </widget>
+       </item>
+       <item>
+        <widget class="QListWidget" name="selectedInputVarListWidget">
+         <property name="selectionMode">
+          <enum>QAbstractItemView::MultiSelection</enum>
+         </property>
+        </widget>
+       </item>
+      </layout>
+     </item>
+    </layout>
+   </item>
+   <item>
+    <layout class="QHBoxLayout" name="horizontalLayout_3">
+     <item>
+      <layout class="QVBoxLayout" name="verticalLayout_3">
+       <item>
+        <widget class="QLabel" name="label_2">
+         <property name="text">
+          <string>All Output Variables</string>
+         </property>
+         <property name="alignment">
+          <set>Qt::AlignCenter</set>
+         </property>
+        </widget>
+       </item>
+       <item>
+        <widget class="QListWidget" name="allOutputVarListWidget">
+         <property name="selectionMode">
+          <enum>QAbstractItemView::MultiSelection</enum>
+         </property>
+        </widget>
+       </item>
+      </layout>
+     </item>
+     <item>
+      <layout class="QVBoxLayout" name="verticalLayout_2">
+       <item>
+        <spacer name="verticalSpacer_2">
+         <property name="orientation">
+          <enum>Qt::Vertical</enum>
+         </property>
+         <property name="sizeHint" stdset="0">
+          <size>
+           <width>20</width>
+           <height>40</height>
+          </size>
+         </property>
+        </spacer>
+       </item>
+       <item>
+        <widget class="QPushButton" name="addOutputVarButton">
+         <property name="text">
+          <string>Add</string>
+         </property>
+        </widget>
+       </item>
+       <item>
+        <widget class="QPushButton" name="removeOutputVarButton">
+         <property name="text">
+          <string>Remove</string>
+         </property>
+        </widget>
+       </item>
+       <item>
+        <widget class="QPushButton" name="pushButton_4">
+         <property name="text">
+          <string>New...</string>
+         </property>
+        </widget>
+       </item>
+       <item>
+        <spacer name="verticalSpacer">
+         <property name="orientation">
+          <enum>Qt::Vertical</enum>
+         </property>
+         <property name="sizeHint" stdset="0">
+          <size>
+           <width>20</width>
+           <height>40</height>
+          </size>
+         </property>
+        </spacer>
+       </item>
+      </layout>
+     </item>
+     <item>
+      <layout class="QVBoxLayout" name="verticalLayout_4">
+       <item>
+        <widget class="QLabel" name="label_3">
+         <property name="text">
+          <string>Selected Output Variables</string>
+         </property>
+         <property name="alignment">
+          <set>Qt::AlignCenter</set>
+         </property>
+        </widget>
+       </item>
+       <item>
+        <widget class="QListWidget" name="selectedOutputVarListWidget">
+         <property name="selectionMode">
+          <enum>QAbstractItemView::MultiSelection</enum>
+         </property>
+        </widget>
+       </item>
+      </layout>
+     </item>
+    </layout>
+   </item>
+   <item>
+    <layout class="QHBoxLayout" name="horizontalLayout">
+     <item>
+      <spacer name="horizontalSpacer">
+       <property name="orientation">
+        <enum>Qt::Horizontal</enum>
+       </property>
+       <property name="sizeHint" stdset="0">
+        <size>
+         <width>40</width>
+         <height>20</height>
+        </size>
+       </property>
+      </spacer>
+     </item>
+     <item>
+      <widget class="QPushButton" name="OKButton">
+       <property name="text">
+        <string>OK</string>
+       </property>
+      </widget>
+     </item>
+     <item>
+      <widget class="QPushButton" name="cancelButton">
+       <property name="text">
+        <string>Cancel</string>
+       </property>
+      </widget>
+     </item>
+     <item>
+      <spacer name="horizontalSpacer_2">
+       <property name="orientation">
+        <enum>Qt::Horizontal</enum>
+       </property>
+       <property name="sizeHint" stdset="0">
+        <size>
+         <width>40</width>
+         <height>20</height>
+        </size>
+       </property>
+      </spacer>
+     </item>
+    </layout>
+   </item>
+  </layout>
+ </widget>
+ <resources/>
+ <connections/>
+</ui>
diff --git a/src/GUI_PY/__init__.py b/src/GUI_PY/__init__.py
new file mode 100644 (file)
index 0000000..e69de29
diff --git a/src/GUI_PY/selectvars.py b/src/GUI_PY/selectvars.py
new file mode 100644 (file)
index 0000000..5900192
--- /dev/null
@@ -0,0 +1,93 @@
+#  Copyright (C) 2007-2010  CEA/DEN, EDF R&D, OPEN CASCADE
+#
+#  Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
+#  CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
+#
+#  This library 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 2.1 of the License.
+#
+#  This library 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 this library; if not, write to the Free Software
+#  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
+#
+#  See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+#
+
+from PyQt4 import QtGui, QtCore
+
+import salome
+from salome.kernel.studyedit import getStudyEditor
+
+# ---------------------------------- #
+# Dialog box for variables selection #
+# ---------------------------------- #
+
+from SelectVarsDialog import Ui_SelectVarsDialog
+
+class MySelectVarsDialog(Ui_SelectVarsDialog, QtGui.QDialog):
+
+    def __init__(self, parent = None, modal = 0):
+        QtGui.QDialog.__init__(self, parent)
+        Ui_SelectVarsDialog.__init__(self)
+        self.setupUi(self)
+        self.connect(self.cancelButton, QtCore.SIGNAL("clicked()"), self.close)
+        self.connect(self.OKButton, QtCore.SIGNAL("clicked()"), self.accept)
+        self.connect(self.selectButton, QtCore.SIGNAL("clicked()"), self.initSelectedVarList)
+        self.connect(self.addInputVarButton, QtCore.SIGNAL("clicked()"), self.addSelectedInputVar)
+        self.connect(self.removeInputVarButton, QtCore.SIGNAL("clicked()"), self.removeSelectedInputVar)
+        self.connect(self.addOutputVarButton, QtCore.SIGNAL("clicked()"), self.addSelectedOutputVar)
+        self.connect(self.removeOutputVarButton, QtCore.SIGNAL("clicked()"), self.removeSelectedOutputVar)
+    
+    def initSelectedVarList(self):
+        entries = salome.sg.getAllSelected()
+        if len(entries) != 1 :
+            QtGui.QMessageBox.warning(self, self.tr("Error"),
+                                      self.tr("One item must be selected in the object browser"))
+            return
+        selectedEntry = entries[0]
+        sobj = getStudyEditor().study.FindObjectID(selectedEntry)
+        from salome.kernel import varlist
+        (inputVarList, outputVarList) = varlist.getVarList(sobj)
+        if inputVarList is None and outputVarList is None:
+            QtGui.QMessageBox.warning(self, self.tr("Error"),
+                                      self.tr('Selected item is not a valid "Variable List" object'))
+            return
+        self.varListObjLineEdit.setText(sobj.GetName())
+        self.allInputVarListWidget.clear()
+        self.allOutputVarListWidget.clear()
+        if inputVarList is not None:
+            self.allInputVarListWidget.addItems(inputVarList)
+        if outputVarList is not None:
+            self.allOutputVarListWidget.addItems(outputVarList)
+
+    def addSelectedInputVar(self):
+        for item in self.allInputVarListWidget.selectedItems():
+            self.selectedInputVarListWidget.addItem(QtGui.QListWidgetItem(item))
+
+    def removeSelectedInputVar(self):
+        for item in self.selectedInputVarListWidget.selectedItems():
+            self.selectedInputVarListWidget.takeItem(self.selectedInputVarListWidget.row(item))
+
+    def addSelectedOutputVar(self):
+        for item in self.allOutputVarListWidget.selectedItems():
+            self.selectedOutputVarListWidget.addItem(QtGui.QListWidgetItem(item))
+
+    def removeSelectedOutputVar(self):
+        for item in self.selectedOutputVarListWidget.selectedItems():
+            self.selectedOutputVarListWidget.takeItem(self.selectedOutputVarListWidget.row(item))
+
+    def getSelectedVarLists(self):
+        inputVarList = []
+        outputVarList = []
+        for row in range(self.selectedInputVarListWidget.count()):
+            inputVarList.append(str(self.selectedInputVarListWidget.item(row).text()))
+        for row in range(self.selectedOutputVarListWidget.count()):
+            outputVarList.append(str(self.selectedOutputVarListWidget.item(row).text()))
+        return (inputVarList, outputVarList)
index 7d4de20d23a97789ba92be777a3c7f18ea2f2842..2f70288dae3e57cc10a0772e40f5176ec439ef72 100755 (executable)
@@ -26,7 +26,7 @@
 ##
 # Common packages
 ##
-SUBDIRS_COMMON = CASCatch Qtx Style DDS QDS ObjBrowser SUIT SUITApp STD CAF CAM LogWindow Prs Event OpenGLUtils
+SUBDIRS_COMMON = CASCatch Qtx Style DDS QDS ObjBrowser SUIT SUITApp STD CAF CAM LogWindow Prs Event OpenGLUtils GUI_PY
 
 ##
 # SALOME object
@@ -122,4 +122,5 @@ SUBDIRS = $(SUBDIRS_COMMON) $(SUBDIRS_OBJECT) $(SUBDIRS_VIEWERTOOLS) $(SUBDIRS_G
 
 DIST_SUBDIRS = CASCatch Qtx Style DDS QDS ObjBrowser SUIT SUITApp STD CAF CAM LogWindow Prs Event OpenGLUtils \
                OBJECT ViewerTools GLViewer VTKViewer SVTK OCCViewer SOCC Plot2d SPlot2d SUPERVGraph QxGraph QxScene \
-               PyInterp PyConsole LightApp ResExporter TOOLSGUI Session SalomeApp SALOME_SWIG SALOME_PY SALOME_PYQT
+               PyInterp PyConsole LightApp ResExporter TOOLSGUI Session SalomeApp SALOME_SWIG SALOME_PY SALOME_PYQT \
+               GUI_PY