From: barate Date: Mon, 31 Jan 2011 14:21:06 +0000 (+0000) Subject: Add PyQt widget to select variables in variables lists X-Git-Tag: V6_3_0a1~74 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=032164f0d8830c069e299425b35a659600dcbb60;p=modules%2Fgui.git Add PyQt widget to select variables in variables lists --- diff --git a/configure.ac b/configure.ac index 737fc0075..e1df3e3bf 100644 --- a/configure.ac +++ b/configure.ac @@ -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 index 000000000..fd0aaa00c --- /dev/null +++ b/src/GUI_PY/Makefile.am @@ -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 index 000000000..504f32ebe --- /dev/null +++ b/src/GUI_PY/SelectVarsDialog.ui @@ -0,0 +1,310 @@ + + + SelectVarsDialog + + + + 0 + 0 + 503 + 676 + + + + Select Variables of Interest + + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + Variables List + + + + + + + true + + + + + + + Select + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + + + + + + All Input Variables + + + Qt::AlignCenter + + + + + + + QAbstractItemView::MultiSelection + + + + + + + + + + + Qt::Vertical + + + + 20 + 40 + + + + + + + + Add + + + + + + + Remove + + + + + + + New... + + + + + + + Qt::Vertical + + + + 20 + 40 + + + + + + + + + + + + Selected Input Variables + + + Qt::AlignCenter + + + + + + + QAbstractItemView::MultiSelection + + + + + + + + + + + + + + + All Output Variables + + + Qt::AlignCenter + + + + + + + QAbstractItemView::MultiSelection + + + + + + + + + + + Qt::Vertical + + + + 20 + 40 + + + + + + + + Add + + + + + + + Remove + + + + + + + New... + + + + + + + Qt::Vertical + + + + 20 + 40 + + + + + + + + + + + + Selected Output Variables + + + Qt::AlignCenter + + + + + + + QAbstractItemView::MultiSelection + + + + + + + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + OK + + + + + + + Cancel + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + + + diff --git a/src/GUI_PY/__init__.py b/src/GUI_PY/__init__.py new file mode 100644 index 000000000..e69de29bb diff --git a/src/GUI_PY/selectvars.py b/src/GUI_PY/selectvars.py new file mode 100644 index 000000000..5900192e7 --- /dev/null +++ b/src/GUI_PY/selectvars.py @@ -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) diff --git a/src/Makefile.am b/src/Makefile.am index 7d4de20d2..2f70288da 100755 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -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