From 101fd10f1e736daa5d7f0f0ee5499b951460832a Mon Sep 17 00:00:00 2001 From: jfa Date: Mon, 13 Mar 2006 13:47:41 +0000 Subject: [PATCH] Join modifications from branch OCC_development_for_3_2_0a2 --- Makefile.in | 8 +- adm_local/Makefile.in | 43 ++ adm_local/unix/config_files/check_GLViewer.m4 | 25 + adm_local/unix/config_files/check_GUI.m4 | 53 ++ .../unix/config_files/check_OCCViewer.m4 | 25 + .../unix/config_files/check_Plot2dViewer.m4 | 25 + .../unix/config_files/check_PyConsole.m4 | 25 + .../unix/config_files/check_SalomeObject.m4 | 25 + .../config_files/check_SupervGraphViewer.m4 | 25 + .../unix/config_files/check_VTKViewer.m4 | 25 + .../unix/config_files/check_corba_in_GUI.m4 | 55 ++ .../unix/config_files/check_disable_Corba.m4 | 27 + adm_local/unix/config_files/check_msg2qm.m4 | 57 ++ adm_local/unix/config_files/check_opengl.m4 | 143 ++++ adm_local/unix/config_files/check_pyqt.m4 | 307 +++++++++ adm_local/unix/config_files/check_qt.m4 | 175 +++++ adm_local/unix/config_files/check_qwt.m4 | 151 +++++ adm_local/unix/config_files/check_sip.m4 | 168 +++++ adm_local/unix/config_files/check_vtk.m4 | 148 +++++ adm_local/unix/make_commence.in | 23 +- adm_local/unix/make_conclude.in | 425 ++++++++++++ build_configure | 4 +- configure.in.base | 200 +++++- idl/SALOME_Session.idl | 5 +- src/CAM/CAM_Module.cxx | 44 +- src/CAM/CAM_Module.h | 10 +- src/DDS/DDS_DicGroup.cxx | 10 +- src/DDS/DDS_DicItem.cxx | 15 +- src/GLViewer/GLViewer_ViewFrame.cxx | 34 + src/GLViewer/GLViewer_ViewFrame.h | 3 + src/LightApp/LightApp_Application.cxx | 313 +++++++-- src/LightApp/LightApp_Application.h | 49 +- src/LightApp/LightApp_DataOwner.cxx | 10 + src/LightApp/LightApp_DataOwner.h | 13 +- src/LightApp/LightApp_Displayer.cxx | 13 +- src/LightApp/LightApp_GLSelector.cxx | 27 +- src/LightApp/LightApp_GLSelector.h | 20 + src/LightApp/LightApp_HDFDriver.cxx | 347 ++++++++++ src/LightApp/LightApp_HDFDriver.h | 23 + src/LightApp/LightApp_Module.cxx | 115 +++- src/LightApp/LightApp_Module.h | 3 + src/LightApp/LightApp_NameDlg.cxx | 256 ++++---- src/LightApp/LightApp_OBSelector.cxx | 4 + src/LightApp/LightApp_OCCSelector.cxx | 16 +- src/LightApp/LightApp_Selection.cxx | 7 +- src/LightApp/LightApp_SelectionMgr.cxx | 50 +- src/LightApp/LightApp_SelectionMgr.h | 23 +- src/LightApp/LightApp_ShowHideOp.cxx | 38 +- src/LightApp/LightApp_Study.cxx | 13 +- src/LightApp/LightApp_Study.h | 148 ++--- src/LightApp/LightApp_VTKSelector.cxx | 32 +- src/LightApp/LightApp_VTKSelector.h | 33 +- src/LightApp/Makefile.in | 122 +++- src/LightApp/resources/LightApp.xml | 10 +- src/LightApp/resources/LightApp_msg_en.po | 6 + src/Makefile.in | 51 +- src/OBJECT/Makefile.in | 6 +- src/OCCViewer/OCCViewer_VService.cxx | 5 +- src/OCCViewer/OCCViewer_VService.h | 3 +- src/OCCViewer/OCCViewer_ViewWindow.cxx | 108 ++- src/OCCViewer/OCCViewer_ViewWindow.h | 5 + src/OCCViewer/resources/OCCViewer_msg_en.po | 2 +- src/ObjBrowser/OB_Browser.cxx | 77 ++- src/Plot2d/Plot2d_ViewFrame.cxx | 40 ++ src/Plot2d/Plot2d_ViewFrame.h | 3 + src/Plot2d/Plot2d_ViewWindow.cxx | 14 + src/Plot2d/Plot2d_ViewWindow.h | 3 + src/PyInterp/PyInterp_base.cxx | 6 +- src/Qtx/Makefile.in | 3 +- src/Qtx/QtxActionMenuMgr.cxx | 210 ++++-- src/Qtx/QtxActionMenuMgr.h | 27 +- src/Qtx/QtxActionToolMgr.cxx | 14 + src/Qtx/QtxActionToolMgr.h | 2 + src/Qtx/QtxColorScale.h | 4 +- src/Qtx/QtxDirListEditor.cxx | 33 +- src/Qtx/QtxDirListEditor.h | 2 +- src/Qtx/QtxDockAction.cxx | 44 +- src/Qtx/QtxDockAction.h | 2 + src/Qtx/QtxListResourceEdit.cxx | 4 + src/Qtx/QtxWorkstack.cxx | 262 ++++++++ src/Qtx/QtxWorkstack.h | 9 +- .../SALOME_PYQT_GUI/SALOME_PYQT_Module.cxx | 616 +++++++++++++----- .../SALOME_PYQT_GUI/SALOME_PYQT_Module.h | 66 +- src/SALOME_PYQT/SalomePyQt/Makefile.in | 2 +- src/SALOME_PYQT/SalomePyQt/SalomePyQt.cxx | 67 +- src/SALOME_PYQT/SalomePyQt/SalomePyQt.h | 9 +- src/SALOME_PYQT/SalomePyQt/SalomePyQt.sip | 11 +- src/SALOME_PYQT/SalomePyQt/SalomePyQt_v4.sip | 16 +- src/SALOME_SWIG/SALOMEGUI_shared_modules.py | 3 + src/SPlot2d/Makefile.in | 4 +- src/STD/STD_Application.cxx | 36 +- src/STD/STD_Application.h | 16 +- src/STD/STD_MDIDesktop.cxx | 2 +- src/STD/STD_MDIDesktop.h | 1 + src/STD/STD_TabDesktop.cxx | 2 +- src/STD/STD_TabDesktop.h | 1 + src/SUIT/SUIT_Accel.cxx | 110 +++- src/SUIT/SUIT_Accel.h | 24 +- src/SUIT/SUIT_Application.cxx | 81 ++- src/SUIT/SUIT_Application.h | 3 +- src/SUIT/SUIT_DataObject.cxx | 4 +- src/SUIT/SUIT_ExceptionHandler.cxx | 5 +- src/SUIT/SUIT_Session.cxx | 2 +- src/SUIT/SUIT_Study.cxx | 15 + src/SUIT/SUIT_Study.h | 3 + src/SUIT/SUIT_TreeSync.h | 6 +- src/SUIT/SUIT_ViewWindow.cxx | 9 + src/SUIT/SUIT_ViewWindow.h | 3 + src/SUPERVGraph/Makefile.in | 2 +- src/SVTK/SVTK_CubeAxesDlg.cxx | 46 +- src/SVTK/SVTK_CubeAxesDlg.h | 10 +- src/SVTK/SVTK_MainWindow.cxx | 4 +- src/SVTK/SVTK_MainWindow.h | 2 +- src/SVTK/SVTK_RenderWindowInteractor.cxx | 2 +- src/SVTK/SVTK_Renderer.cxx | 23 +- src/SVTK/SVTK_Renderer.h | 9 +- src/SVTK/SVTK_ViewModel.cxx | 56 +- src/SVTK/SVTK_ViewModel.h | 6 +- src/SVTK/SVTK_ViewWindow.cxx | 100 ++- src/SVTK/SVTK_ViewWindow.h | 20 +- src/SalomeApp/Makefile.in | 8 +- src/SalomeApp/SalomeApp_Application.cxx | 290 ++++++++- src/SalomeApp/SalomeApp_Application.h | 15 +- src/SalomeApp/SalomeApp_DataModel.cxx | 32 +- src/SalomeApp/SalomeApp_DataModel.h | 5 +- src/SalomeApp/SalomeApp_DataObject.cxx | 49 ++ src/SalomeApp/SalomeApp_DataObject.h | 40 +- src/SalomeApp/SalomeApp_ExceptionHandler.cxx | 30 +- src/SalomeApp/SalomeApp_Module.cxx | 34 + src/SalomeApp/SalomeApp_Module.h | 5 +- src/SalomeApp/SalomeApp_Study.cxx | 125 +++- src/SalomeApp/SalomeApp_Study.h | 10 + src/SalomeApp/SalomeApp_TypeFilter.cxx | 2 - src/SalomeApp/SalomeApp_VisualState.cxx | 295 +++++++++ .../SalomeApp_VisualState.h} | 36 +- src/SalomeApp/Test/Makefile.in | 65 ++ src/SalomeApp/Test/SalomeAppTest.cxx | 56 ++ src/SalomeApp/Test/SalomeAppTest.hxx | 39 ++ .../Test/TestSalomeApp.cxx} | 27 +- src/SalomeApp/Test/TestSalomeApp.py | 29 + src/SalomeApp/resources/SalomeApp.xml | 14 +- src/SalomeApp/resources/SalomeApp_msg_en.po | 42 ++ src/Session/Makefile.in | 3 +- src/Session/SALOME_Session_Server.cxx | 2 - src/Session/Session_ServerThread.cxx | 13 +- src/Session/Session_Session_i.cxx | 24 + src/Session/Session_Session_i.hxx | 3 + src/Session/Session_SignalsHandler.cxx | 45 -- src/VTKViewer/VTKViewer_Actor.cxx | 7 +- src/VTKViewer/VTKViewer_AppendFilter.cxx | 300 ++++----- src/VTKViewer/VTKViewer_AppendFilter.h | 41 +- src/VTKViewer/VTKViewer_Utilities.cxx | 84 ++- src/VTKViewer/VTKViewer_ViewWindow.cxx | 51 ++ src/VTKViewer/VTKViewer_ViewWindow.h | 3 + src/VTKViewer/resources/VTKViewerM_msg_en.po | 1 - 155 files changed, 6763 insertions(+), 1372 deletions(-) create mode 100644 adm_local/Makefile.in create mode 100644 adm_local/unix/config_files/check_GLViewer.m4 create mode 100755 adm_local/unix/config_files/check_GUI.m4 create mode 100644 adm_local/unix/config_files/check_OCCViewer.m4 create mode 100644 adm_local/unix/config_files/check_Plot2dViewer.m4 create mode 100644 adm_local/unix/config_files/check_PyConsole.m4 create mode 100644 adm_local/unix/config_files/check_SalomeObject.m4 create mode 100644 adm_local/unix/config_files/check_SupervGraphViewer.m4 create mode 100644 adm_local/unix/config_files/check_VTKViewer.m4 create mode 100755 adm_local/unix/config_files/check_corba_in_GUI.m4 create mode 100644 adm_local/unix/config_files/check_disable_Corba.m4 create mode 100755 adm_local/unix/config_files/check_msg2qm.m4 create mode 100644 adm_local/unix/config_files/check_opengl.m4 create mode 100644 adm_local/unix/config_files/check_pyqt.m4 create mode 100644 adm_local/unix/config_files/check_qt.m4 create mode 100644 adm_local/unix/config_files/check_qwt.m4 create mode 100644 adm_local/unix/config_files/check_sip.m4 create mode 100644 adm_local/unix/config_files/check_vtk.m4 create mode 100644 adm_local/unix/make_conclude.in create mode 100644 src/LightApp/LightApp_HDFDriver.cxx create mode 100644 src/LightApp/LightApp_HDFDriver.h create mode 100644 src/SalomeApp/SalomeApp_VisualState.cxx rename src/{OBJECT/SALOME_GLOwner.h => SalomeApp/SalomeApp_VisualState.h} (63%) create mode 100644 src/SalomeApp/Test/Makefile.in create mode 100644 src/SalomeApp/Test/SalomeAppTest.cxx create mode 100644 src/SalomeApp/Test/SalomeAppTest.hxx rename src/{OBJECT/SALOME_GLOwner.cxx => SalomeApp/Test/TestSalomeApp.cxx} (65%) create mode 100644 src/SalomeApp/Test/TestSalomeApp.py delete mode 100755 src/Session/Session_SignalsHandler.cxx diff --git a/Makefile.in b/Makefile.in index 989c6a476..c1bc6bff4 100644 --- a/Makefile.in +++ b/Makefile.in @@ -14,7 +14,13 @@ VPATH=.:@srcdir@:@top_srcdir@/bin:./bin/salome:@top_srcdir@/resources:./bin:@top @COMMENCE@ -SUBDIRS = idl src doc +SUBDIRS = src + +ifeq ($(GUI_DISABLE_CORBA),no) + SUBDIRS+= idl +endif + +SUBDIRS+= doc adm_local RESOURCES_FILES = \ back.xpm \ diff --git a/adm_local/Makefile.in b/adm_local/Makefile.in new file mode 100644 index 000000000..0c4f46081 --- /dev/null +++ b/adm_local/Makefile.in @@ -0,0 +1,43 @@ +# source path +top_srcdir=@top_srcdir@ +top_builddir=.. +srcdir=@srcdir@ +VPATH=.:$(srcdir)/adm_local + + +all: resources + +install: + cp -rf @top_srcdir@/adm_local @prefix@ + +bin: + +resources : + cp -rf @top_srcdir@/adm_local $(top_builddir) + +inc: + +lib: + +depend: + +depend_idl: + +install-end: + +install-include: + +install-bin: + +uninstall: + +uninstall-idl: + +distclean: + +clean: + +tests: + +distclean-other: + diff --git a/adm_local/unix/config_files/check_GLViewer.m4 b/adm_local/unix/config_files/check_GLViewer.m4 new file mode 100644 index 000000000..90a304173 --- /dev/null +++ b/adm_local/unix/config_files/check_GLViewer.m4 @@ -0,0 +1,25 @@ +# +# Check configure option --disable-glViewer=[yes|no|DIR] taking into account that +# DISABLE_GLVIEWER may be already set during build_configure, +# Set DISABLE_GLVIEWER to yes|no +# +# Author : Edawrd AGAPOV (OCC, 2005) +# + +AC_DEFUN([CHECK_GLVIEWER],[ + +AC_ARG_WITH(glViewer, + [ --disable-glViewer default=no ], + disable_glViewer="$withval",disable_glViewer="${DISABLE_GLVIEWER}") + +case $disable_glViewer in + yes) +# AC_MSG_RESULT(************************************************) +# AC_MSG_RESULT(******* DISABLE GLViewer configuration *****) +# AC_MSG_RESULT(************************************************) + DISABLE_GLVIEWER="yes" + AC_SUBST(DISABLE_GLVIEWER) +esac + + +])dnl diff --git a/adm_local/unix/config_files/check_GUI.m4 b/adm_local/unix/config_files/check_GUI.m4 new file mode 100755 index 000000000..ad022e400 --- /dev/null +++ b/adm_local/unix/config_files/check_GUI.m4 @@ -0,0 +1,53 @@ +# Check availability of Salome binary distribution +# +# Author : Marc Tajchman (CEA, 2002) +#------------------------------------------------------------ + +AC_DEFUN([CHECK_SALOME_GUI],[ + +AC_CHECKING(for SalomeGUI) + +SalomeGUI_ok=no + +AC_ARG_WITH(gui, + --with-salome_gui=DIR root directory path of SALOME GUI installation, + SALOME_GUI_DIR="$withval",SALOME_GUI_DIR="") + +if test "x$SALOME_GUI_DIR" = "x" ; then + +# no --with-gui-dir option used + + if test "x$GUI_ROOT_DIR" != "x" ; then + + # SALOME_ROOT_DIR environment variable defined + SALOME_GUI_DIR=$GUI_ROOT_DIR + + else + + # search Salome binaries in PATH variable + AC_PATH_PROG(TEMP, libLightApp.so) + if test "x$TEMP" != "x" ; then + SALOME_BIN_DIR=`dirname $TEMP` + SALOME_GUI_DIR=`dirname $SALOME_BIN_DIR` + fi + + fi +# +fi + +if test -f ${SALOME_GUI_DIR}/lib/salome/libLightApp.so ; then + SalomeGUI_ok=yes + AC_MSG_RESULT(Using SALOME GUI distribution in ${SALOME_GUI_DIR}) + + if test "x$GUI_ROOT_DIR" == "x" ; then + GUI_ROOT_DIR=${SALOME_GUI_DIR} + fi + AC_SUBST(GUI_ROOT_DIR) +else + AC_MSG_WARN("Cannot find compiled SALOME GUI distribution") +fi + +AC_MSG_RESULT(for SALOME GUI: $SalomeGUI_ok) + +])dnl + diff --git a/adm_local/unix/config_files/check_OCCViewer.m4 b/adm_local/unix/config_files/check_OCCViewer.m4 new file mode 100644 index 000000000..cae33b971 --- /dev/null +++ b/adm_local/unix/config_files/check_OCCViewer.m4 @@ -0,0 +1,25 @@ +# +# Check configure option --disable-occViewer=[yes|no|DIR] taking into account that +# DISABLE_OCCVIEWER may be already set during build_configure, +# Set DISABLE_OCCVIEWER to yes|no +# +# Author : Edawrd AGAPOV (OCC, 2005) +# + +AC_DEFUN([CHECK_OCCVIEWER],[ + +AC_ARG_WITH(occViewer, + [ --disable-occViewer default=no ], + disable_occViewer="$withval",disable_occViewer="${DISABLE_OCCVIEWER}") + +case $disable_occViewer in + yes) +# AC_MSG_RESULT(************************************************) +# AC_MSG_RESULT(***** DISABLE OCCViewer configuration ******) +# AC_MSG_RESULT(************************************************) + DISABLE_OCCVIEWER="yes" + AC_SUBST(DISABLE_OCCVIEWER) +esac + + +])dnl diff --git a/adm_local/unix/config_files/check_Plot2dViewer.m4 b/adm_local/unix/config_files/check_Plot2dViewer.m4 new file mode 100644 index 000000000..a8fb1ad85 --- /dev/null +++ b/adm_local/unix/config_files/check_Plot2dViewer.m4 @@ -0,0 +1,25 @@ +# +# Check configure option --disable-plot2dViewer=[yes|no|DIR] taking into account that +# DISABLE_PLOT2DVIEWER may be already set during build_configure, +# Set DISABLE_PLOT2DVIEWER to yes|no +# +# Author : Edawrd AGAPOV (OCC, 2005) +# + +AC_DEFUN([CHECK_PLOT2DVIEWER],[ + +AC_ARG_WITH(plot2dViewer, + [ --disable-plot2dViewer default=no ], + disable_plot2dViewer="$withval",disable_plot2dViewer="${DISABLE_PLOT2DVIEWER}") + +case $disable_plot2dViewer in + yes) +# AC_MSG_RESULT(************************************************) +# AC_MSG_RESULT(*** DISABLE Plot2dViewer configuration *****) +# AC_MSG_RESULT(************************************************) + DISABLE_PLOT2DVIEWER="yes" + AC_SUBST(DISABLE_PLOT2DVIEWER) +esac + + +])dnl diff --git a/adm_local/unix/config_files/check_PyConsole.m4 b/adm_local/unix/config_files/check_PyConsole.m4 new file mode 100644 index 000000000..503646f84 --- /dev/null +++ b/adm_local/unix/config_files/check_PyConsole.m4 @@ -0,0 +1,25 @@ +# +# Check configure option --disable-pyConsole=[yes|no|DIR] taking into account that +# DISABLE_PYCONSOLE may be already set during build_configure, +# Set DISABLE_PYCONSOLE to yes|no +# +# Author : Edawrd AGAPOV (OCC, 2005) +# + +AC_DEFUN([CHECK_PYCONSOLE],[ + +AC_ARG_WITH(pyConsole, + [ --disable-pyConsole default=no ], + disable_pyConsole="$withval",disable_pyConsole="${DISABLE_PYCONSOLE}") + +case $disable_pyConsole in + yes) +# AC_MSG_RESULT(************************************************) +# AC_MSG_RESULT(***** DISABLE PyConsole configuration ******) +# AC_MSG_RESULT(************************************************) + DISABLE_PYCONSOLE="yes" + AC_SUBST(DISABLE_PYCONSOLE) +esac + + +])dnl diff --git a/adm_local/unix/config_files/check_SalomeObject.m4 b/adm_local/unix/config_files/check_SalomeObject.m4 new file mode 100644 index 000000000..453dbd7ab --- /dev/null +++ b/adm_local/unix/config_files/check_SalomeObject.m4 @@ -0,0 +1,25 @@ +# +# Check configure option --disable-salomeObject=[yes|no|DIR] taking into account that +# DISABLE_SALOMEOBJECT may be already set during build_configure, +# Set DISABLE_SALOMEOBJECT to yes|no +# +# Author : Edawrd AGAPOV (OCC, 2005) +# + +AC_DEFUN([CHECK_SALOMEOBJECT],[ + +AC_ARG_WITH(salomeObject, + [ --disable-salomeObject default=no ], + disable_salomeObject="$withval",disable_salomeObject="${DISABLE_SALOMEOBJECT}") + +case $disable_salomeObject in + yes) +# AC_MSG_RESULT(************************************************) +# AC_MSG_RESULT(*** DISABLE Salome object configuration ****) +# AC_MSG_RESULT(************************************************) + DISABLE_SALOMEOBJECT="yes" + AC_SUBST(DISABLE_SALOMEOBJECT) +esac + + +])dnl diff --git a/adm_local/unix/config_files/check_SupervGraphViewer.m4 b/adm_local/unix/config_files/check_SupervGraphViewer.m4 new file mode 100644 index 000000000..455f02136 --- /dev/null +++ b/adm_local/unix/config_files/check_SupervGraphViewer.m4 @@ -0,0 +1,25 @@ +# +# Check configure option --disable-supervGraphViewer=[yes|no|DIR] taking into account that +# DISABLE_SUPERVGRAPHVIEWER may be already set during build_configure, +# Set DISABLE_SUPERVGRAPHVIEWER to yes|no +# +# Author : Edawrd AGAPOV (OCC, 2005) +# + +AC_DEFUN([CHECK_SUPERVGRAPHVIEWER],[ + +AC_ARG_WITH(supervGraphViewer, + [ --disable-supervGraphViewer default=no ], + disable_supervGraphViewer="$withval",disable_supervGraphViewer="${DISABLE_SUPERVGRAPHVIEWER}") + +case $disable_supervGraphViewer in + yes) +# AC_MSG_RESULT(************************************************) +# AC_MSG_RESULT(******* DISABLE SupervGraphViewer configuration ********) +# AC_MSG_RESULT(************************************************) + DISABLE_SUPERVGRAPHVIEWER="yes" + AC_SUBST(DISABLE_SUPERVGRAPHVIEWER) +esac + + +])dnl diff --git a/adm_local/unix/config_files/check_VTKViewer.m4 b/adm_local/unix/config_files/check_VTKViewer.m4 new file mode 100644 index 000000000..c2adb23b9 --- /dev/null +++ b/adm_local/unix/config_files/check_VTKViewer.m4 @@ -0,0 +1,25 @@ +# +# Check configure option --disable-vtkViewer=[yes|no|DIR] taking into account that +# DISABLE_VTKVIEWER may be already set during build_configure, +# Set DISABLE_VTKVIEWER to yes|no +# +# Author : Edawrd AGAPOV (OCC, 2005) +# + +AC_DEFUN([CHECK_VTKVIEWER],[ + +AC_ARG_WITH(vtkViewer, + [ --disable-vtkViewer default=no ], + disable_vtkViewer="$withval",disable_vtkViewer="${DISABLE_VTKVIEWER}") + +case $disable_vtkViewer in + yes) +# AC_MSG_RESULT(************************************************) +# AC_MSG_RESULT(***** DISABLE VTK Viewer configuration *****) +# AC_MSG_RESULT(************************************************) + DISABLE_VTKVIEWER="yes" + AC_SUBST(DISABLE_VTKVIEWER) +esac + + +])dnl diff --git a/adm_local/unix/config_files/check_corba_in_GUI.m4 b/adm_local/unix/config_files/check_corba_in_GUI.m4 new file mode 100755 index 000000000..007dfc6c5 --- /dev/null +++ b/adm_local/unix/config_files/check_corba_in_GUI.m4 @@ -0,0 +1,55 @@ +# Check availability of full Salome binary distribution +# +# Author : Marc Tajchman (CEA, 2002) +#------------------------------------------------------------ + +AC_DEFUN([CHECK_CORBA_IN_GUI],[ + +AC_CHECKING(for full SalomeGUI) + +SalomeGUI_ok=no +CORBA_IN_GUI="no" + +AC_ARG_WITH(gui, + --with-salome_gui=DIR root directory path of full SALOME GUI installation, + SALOME_GUI_DIR="$withval",SALOME_GUI_DIR="") + +if test "x$SALOME_GUI_DIR" = "x" ; then + +# no --with-gui-dir option used + + if test "x$GUI_ROOT_DIR" != "x" ; then + + # SALOME_ROOT_DIR environment variable defined + SALOME_GUI_DIR=$GUI_ROOT_DIR + + else + + # search Salome binaries in PATH variable + AC_PATH_PROG(TEMP, libSalomeApp.so) + if test "x$TEMP" != "x" ; then + SALOME_BIN_DIR=`dirname $TEMP` + SALOME_GUI_DIR=`dirname $SALOME_BIN_DIR` + fi + + fi +# +fi + +if test -f ${SALOME_GUI_DIR}/lib/salome/libSalomeApp.so ; then + SalomeGUI_ok=yes + CORBA_IN_GUI=yes + AC_MSG_RESULT(Using SALOME GUI distribution in ${SALOME_GUI_DIR}) + + if test "x$GUI_ROOT_DIR" == "x" ; then + GUI_ROOT_DIR=${SALOME_GUI_DIR} + fi +else + AC_MSG_WARN("Cannot find compiled full SALOME GUI distribution") +fi +AC_SUBST(CORBA_IN_GUI) + +AC_MSG_RESULT(for full SALOME GUI: $SalomeGUI_ok) + +])dnl + diff --git a/adm_local/unix/config_files/check_disable_Corba.m4 b/adm_local/unix/config_files/check_disable_Corba.m4 new file mode 100644 index 000000000..c7b73cb7e --- /dev/null +++ b/adm_local/unix/config_files/check_disable_Corba.m4 @@ -0,0 +1,27 @@ +# +# Check configure option --disable-corba=[yes|no|DIR] taking into account that +# GUI_DISABLE_CORBA may be already set during build_configure, +# Set GUI_DISABLE_CORBA to yes|no +# +# Author : Edawrd AGAPOV (OCC, 2005) +# + +AC_DEFUN([CHECK_DISABLE_CORBA],[ + +AC_ARG_WITH(corba, + [ --disable-corba default=no ], + disable_corba="$withval",disable_corba="${GUI_DISABLE_CORBA}") + +case $disable_corba in + yes) +# AC_MSG_RESULT(************************************************) +# AC_MSG_RESULT(******* DISABLE CORBA configuration ********) +# AC_MSG_RESULT(************************************************) + GUI_DISABLE_CORBA="yes";; + *) + GUI_DISABLE_CORBA="no" +esac + +AC_SUBST(GUI_DISABLE_CORBA) + +])dnl diff --git a/adm_local/unix/config_files/check_msg2qm.m4 b/adm_local/unix/config_files/check_msg2qm.m4 new file mode 100755 index 000000000..8d0c5474f --- /dev/null +++ b/adm_local/unix/config_files/check_msg2qm.m4 @@ -0,0 +1,57 @@ +# Check availability of Qt's msg2qm tool binary distribution +# +# Author : Jerome Roy (CEA, 2003) +# + +AC_DEFUN([CHECK_MSG2QM],[ + +AC_CHECKING(for msg2qm) + +msg2qm_ok=no + +AC_ARG_WITH(msg2qm, + [ --with-msg2qm=DIR root directory path of MSG2QM installation], + MSG2QM_DIR="$withval",MSG2QM_DIR="") + +if test "x$MSG2QM_DIR" == "x" ; then + +# no --with-MSG2QM-dir option used + + if test "x$MSG2QM_ROOT" != "x" ; then + + # MSG2QM_ROOT environment variable defined + MSG2QM_DIR=$MSG2QM_ROOT + + else + + # search MSG2QM binaries in PATH variable + AC_PATH_PROG(TEMP, msg2qm) + if test "x$TEMP" != "x" ; then + MSG2QM_DIR=`dirname $TEMP` + fi + + fi +# +fi + +# look for msg2qm in ${MSG2QM_DIR} directory +if test -f ${MSG2QM_DIR}/msg2qm ; then + msg2qm_ok=yes + MSG2QM="${MSG2QM_DIR}/msg2qm" + AC_MSG_RESULT(Using MSG2QM executable in ${MSG2QM_DIR}) +else + # if not found, look for msg2qm in ${MSG2QM_DIR}/bin directory + if test -f ${MSG2QM_DIR}/bin/msg2qm ; then + msg2qm_ok=yes + MSG2QM="${MSG2QM_DIR}/bin/msg2qm" + AC_MSG_RESULT(Using MSG2QM executable in ${MSG2QM_DIR}/bin) + else + AC_MSG_WARN("Cannot find MSG2QM executable") + fi +fi + +AC_SUBST(MSG2QM) +AC_MSG_RESULT(for MSG2QM: $msg2qm_ok) + +])dnl + diff --git a/adm_local/unix/config_files/check_opengl.m4 b/adm_local/unix/config_files/check_opengl.m4 new file mode 100644 index 000000000..dd43d25a0 --- /dev/null +++ b/adm_local/unix/config_files/check_opengl.m4 @@ -0,0 +1,143 @@ +dnl Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, +dnl CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +dnl +dnl This library is free software; you can redistribute it and/or +dnl modify it under the terms of the GNU Lesser General Public +dnl License as published by the Free Software Foundation; either +dnl version 2.1 of the License. +dnl +dnl This library is distributed in the hope that it will be useful, +dnl but WITHOUT ANY WARRANTY; without even the implied warranty of +dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +dnl Lesser General Public License for more details. +dnl +dnl You should have received a copy of the GNU Lesser General Public +dnl License along with this library; if not, write to the Free Software +dnl Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +dnl +dnl See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org +dnl +dnl +dnl +AC_DEFUN([CHECK_OPENGL],[ +AC_REQUIRE([AC_PROG_CC])dnl +AC_REQUIRE([AC_PROG_CPP])dnl +AC_ARG_WITH(opengl, + [ --with-opengl=DIR root directory path of OpenGL installation ], + [ + opengl_dir="$withval" + local_opengl=yes + ], [ + dirs="/usr/lib /usr/local/lib /opt/graphics/OpenGL/lib /usr/openwin/lib /usr/X11R6/lib" + ])dnl + +AC_CHECKING(for OpenGL) + +AC_SUBST(OGL_INCLUDES) +AC_SUBST(OGL_LIBS) + +OGL_INCLUDES="" +OGL_LIBS="" + +OpenGL_ok=no + +dnl openGL headers + +# by default + +if test "x$local_opengl" = "xyes" ; then + if test -f "${opengl_dir}/include/GL/gl.h" ; then + OpenGL_ok=yes + OGL_INCLUDES="-I${opengl_dir}/include" + if test "x${opengl_dir}" = "x/usr" + then + OGL_LIBS="" + else + OGL_LIBS="-L${opengl_dir}/lib" + fi + AC_MSG_RESULT(select OpenGL distribution in ${opengl_dir}) + else + AC_MSG_RESULT(no gl.h header file in ${opengl_dir}/include/GL) + fi +fi + +if test "x$OpenGL_ok" = "xno" +then + AC_CHECK_HEADERS(GL/gl.h, [OpenGL_ok=yes]) +fi + +if test "x$OpenGL_ok" = "xno" +then +# under SunOS ? + AC_CHECK_HEADERS(/usr/openwin/share/include/GL/glxmd.h, + [OpenGL_ok=yes] + OGL_INCLUDES="-I/usr/openwin/share/include/") +fi + +if test "x$OpenGL_ok" = "xno" +then +# under IRIX ? + AC_CHECK_HEADERS(/opt/graphics/OpenGL/include/GL/glxmd.h, + [OpenGL_ok=yes] + OGL_INCLUDES="-I/opt/graphics/OpenGL/include") +fi +if test "x$OpenGL_ok" = "xno" +then +# some linux OpenGL servers hide the includes in /usr/X11R6/include/GL + AC_CHECK_HEADERS(/usr/X11R6/include/GL/gl.h, + [OpenGL_ok=yes] + OGL_INCLUDES="-I/usr/X11R6/include") +fi + +if test "x$OpenGL_ok" = "xyes" +then + AC_CHECKING(for OpenGL library) + OpenGL_ok=no + for i in $dirs; do + if test -r "$i/libGL.so"; then +dnl AC_MSG_RESULT(in $i) + if test "x$i" = "x/usr/lib" + then + OGL_LIBS="" + else + OGL_LIBS="-L$i" + fi + break + fi +# under IRIX ? + if test -r "$i/libGL.sl"; then +dnl AC_MSG_RESULT(in $i) + if test "x$i" = "x/usr/lib" + then + OGL_LIBS="" + else + OGL_LIBS="-L$i" + fi + break + fi + done + LDFLAGS_old="$LDFLAGS" + LDFLAGS="$LDFLAGS $OGL_LIBS" + AC_CHECK_LIB(GL,glBegin,OpenGL_ok=yes,OpenGL_ok=no) + LDFLAGS="$LDFLAGS_old" +fi + +if test "x$OpenGL_ok" = "xyes" ; then + OGL_LIBS="$OGL_LIBS -lGL" +fi + + +OpenGLU_ok=no +LDFLAGS_old="$LDFLAGS" +LDFLAGS="$LDFLAGS $OGL_LIBS" +AC_CHECK_LIB(GLU,gluBeginSurface,OpenGLU_ok=yes,OpenGLU_ok=no) +LDFLAGS="$LDFLAGS_old" + +if test "x$OpenGLU_ok" = "xyes" ; then + OGL_LIBS="$OGL_LIBS -lGLU" +fi + +# Save cache +AC_CACHE_SAVE + +])dnl diff --git a/adm_local/unix/config_files/check_pyqt.m4 b/adm_local/unix/config_files/check_pyqt.m4 new file mode 100644 index 000000000..ee024efaf --- /dev/null +++ b/adm_local/unix/config_files/check_pyqt.m4 @@ -0,0 +1,307 @@ +dnl Copyright (C) 2003 CEA/DEN, EDF R&D + +AC_DEFUN([CHECK_PYQT],[ +AC_REQUIRE([CHECK_PYTHON])dnl +AC_REQUIRE([CHECK_QT])dnl +AC_REQUIRE([CHECK_SIP])dnl + +AC_LANG_SAVE +AC_LANG_CPLUSPLUS + +AC_ARG_WITH(pyqt, + [ --with-pyqt=DIR root directory path to PyQt installation ], + [PYQTDIR="$withval" + AC_MSG_RESULT("select $withval as path to PyQt") + ]) + +AC_ARG_WITH(pyqt_sips, + [ --with-pyqt_sips=DIR a directory path to PyQt sips installation ], + [PYQT_SIPS="$withval" + AC_MSG_RESULT("select $withval as path to PyQt sips") + ]) + + +AC_ARG_WITH(pyuic, + [ --with-pyuic=EXEC pyuic executable ], + [PYUIC="$withval" + AC_MSG_RESULT("select $withval as pyqt executable") + ]) + +AC_CHECKING(for pyqt) + +pyqt_ok=yes + +dnl look for pyuic +pyqt_uic_ok=no +if test "x$PYUIC" != x; then + dnl try withval value + AC_CHECK_FILE($PYUIC,pyqt_uic_ok=yes,pyqt_uic_ok=no) +fi +if test "x$pyqt_uic_ok" == "xno"; then + dnl try ${PYQTDIR} + if test "x${PYQTDIR}" != "x"; then + if test -d ${PYQTDIR} ; then + AC_CHECK_FILE(${PYQTDIR}/pyuic,pyqt_uic_ok=yes,pyqt_uic_ok=no) + if test "x$pyqt_uic_ok" == "xyes"; then + PYUIC="${PYQTDIR}/pyuic" + fi + fi + fi +fi +if test "x$pyqt_uic_ok" == "xno"; then + dnl try ${SIPDIR} + if test "x${SIPDIR}" != "x"; then + if test -d ${SIPDIR} ; then + AC_CHECK_FILE(${SIPDIR}/pyuic,pyqt_uic_ok=yes,pyqt_uic_ok=no) + if test "x$pyqt_uic_ok" == "xyes"; then + PYUIC="${SIPDIR}/pyuic" + fi + fi + fi +fi +if test "x$pyqt_uic_ok" == "xno"; then + dnl try ${PYTHONHOME}/bin + if test "x${PYTHONHOME}" != "x"; then + if test -d ${PYTHONHOME}/bin ; then + AC_CHECK_FILE(${PYTHONHOME}/bin/pyuic,pyqt_uic_ok=yes,pyqt_uic_ok=no) + if test "x$pyqt_uic_ok" == "xyes"; then + PYUIC="${PYTHONHOME}/bin/pyuic" + fi + fi + fi +fi +if test "x$pyqt_uic_ok" == "xno"; then + dnl try /usr/bin + AC_CHECK_FILE(/usr/bin/pyuic,pyqt_uic_ok=yes,pyqt_uic_ok=no) + if test "x$pyqt_uic_ok" == "xyes"; then + PYUIC="/usr/bin/pyuic" + fi +fi +if test "x$pyqt_uic_ok" == "xno"; then + pyqt_ok=no +fi + +dnl look for PyQt libs +pyqt_lib_ok=no +if test "x${PYQTDIR}" != "x"; then + dnl try {PYQTDIR} + AC_CHECK_FILE(${PYQTDIR}/libqtcmodule.so,pyqt_lib_ok=yes,pyqt_lib_ok=no) + if test "x$pyqt_lib_ok" == "xyes"; then + if test "x${PYQTDIR}" = "x/usr/lib" + then + PYQT_LIBS="-lqtcmodule" + else + PYQT_LIBS="-L${PYQTDIR} -lqtcmodule" + fi + else + AC_CHECK_FILE(${PYQTDIR}/qt.so,pyqt_lib_ok=yes,pyqt_lib_ok=no) + if test "x$pyqt_lib_ok" == "xyes"; then + if test "x${PYQTDIR}" = "x/usr/lib" + then + PYQT_LIBS="" + else + PYQT_LIBS="-L${PYQTDIR}" + fi + fi + fi + if test "x$pyqt_lib_ok" == "xno"; then + dnl try {PYQTDIR}/lib + if test -d {PYQTDIR}/lib; then + AC_CHECK_FILE(${PYQTDIR}/lib/libqtcmodule.so,pyqt_lib_ok=yes,pyqt_lib_ok=no) + if test "x$pyqt_lib_ok" == "xyes"; then + PYQT_LIBS="-L${PYQTDIR}/lib -lqtcmodule" + else + AC_CHECK_FILE(${PYQTDIR}/lib/qt.so,pyqt_lib_ok=yes,pyqt_lib_ok=no) + if test "x$pyqt_lib_ok" == "xyes"; then + PYQT_LIBS="-L${PYQTDIR}/lib" + fi + fi + fi + fi + if test "x$pyqt_lib_ok" == "xno"; then + dnl try {PYQTDIR}/lib/python${PYTHON_VERSION}/site-packages + if test -d {PYQTDIR}/lib/python${PYTHON_VERSION}/site-packages; then + AC_CHECK_FILE(${PYQTDIR}/lib/python${PYTHON_VERSION}/site-packages/libqtcmodule.so,pyqt_lib_ok=yes,pyqt_lib_ok=no) + if test "x$pyqt_lib_ok" == "xyes"; then + PYQT_LIBS="-L${PYQTDIR}/lib/python${PYTHON_VERSION}/site-packages -lqtcmodule" + else + AC_CHECK_FILE(${PYQTDIR}/lib/python${PYTHON_VERSION}/site-packages/qt.so,pyqt_lib_ok=yes,pyqt_lib_ok=no) + if test "x$pyqt_lib_ok" == "xyes"; then + PYQT_LIBS="-L${PYQTDIR}/lib/python${PYTHON_VERSION}/site-packages" + fi + fi + fi + fi +fi +if test "x$pyqt_lib_ok" == "xno"; then + dnl try ${SIPDIR} + if test "x${SIPDIR}" != "x"; then + if test -d ${SIPDIR} ; then + AC_CHECK_FILE(${SIPDIR}/libqtcmodule.so,pyqt_lib_ok=yes,pyqt_lib_ok=no) + if test "x$pyqt_lib_ok" == "xyes"; then + if test "x${SIPDIR}" = "x/usr/lib" + then + PYQT_LIBS="-lqtcmodule" + else + PYQT_LIBS="-L${SIPDIR} -lqtcmodule" + fi + else + AC_CHECK_FILE(${SIPDIR}/qt.so,pyqt_lib_ok=yes,pyqt_lib_ok=no) + if test "x$pyqt_lib_ok" == "xyes"; then + if test "x${SIPDIR}" = "x/usr/lib" + then + PYQT_LIBS="" + else + PYQT_LIBS="-L${SIPDIR}" + fi + fi + fi + fi + fi +fi +if test "x$pyqt_lib_ok" == "xno"; then + dnl try ${PYTHONHOME}/lib/python${PYTHON_VERSION}/site-packages + if test "x${PYTHONHOME}" != "x"; then + if test -d ${PYTHONHOME}/lib/python${PYTHON_VERSION}/site-packages ; then + AC_CHECK_FILE(${PYTHONHOME}/lib/python${PYTHON_VERSION}/site-packages/libqtcmodule.so,pyqt_lib_ok=yes,pyqt_lib_ok=no) + if test "x$pyqt_lib_ok" == "xyes"; then + PYQT_LIBS="-L${PYTHONHOME}/lib/python${PYTHON_VERSION}/site-packages -lqtcmodule" + else + AC_CHECK_FILE(${PYTHONHOME}/lib/python${PYTHON_VERSION}/site-packages/qt.so,pyqt_lib_ok=yes,pyqt_lib_ok=no) + if test "x$pyqt_lib_ok" == "xyes"; then + PYQT_LIBS="-L${PYTHONHOME}/lib/python${PYTHON_VERSION}/site-packages" + fi + fi + fi + fi +fi +if test "x$pyqt_lib_ok" == "xno"; then + dnl try /usr/lib/python${PYTHON_VERSION}/site-packages + AC_CHECK_FILE(/usr/lib/python${PYTHON_VERSION}/site-packages/libqtcmodule.so,pyqt_lib_ok=yes,pyqt_lib_ok=no) + if test "x$pyqt_lib_ok" == "xyes"; then + PYQT_LIBS="-L/usr/lib/python${PYTHON_VERSION}/site-packages -lqtcmodule" + else + AC_CHECK_FILE(/usr/lib/python${PYTHON_VERSION}/site-packages/qt.so,pyqt_lib_ok=yes,pyqt_lib_ok=no) + if test "x$pyqt_lib_ok" == "xyes"; then + PYQT_LIBS="-L/usr/lib/python${PYTHON_VERSION}/site-packages" + fi + fi +fi +if test "x$pyqt_lib_ok" == "xno"; then + pyqt_ok=no +fi + +dnl look for PyQt sips +pyqt_sips_ok=no +dnl try ${PYQT_SIPS} or ${PYQT_SIPS}/qt +if test "x${PYQT_SIPS}" != "x"; then + AC_CHECK_FILE(${PYQT_SIPS}/qglobal.sip,pyqt_sips_ok=yes,pyqt_sips_ok=no) + if test "x$pyqt_sips_ok" == "xno"; then + AC_CHECK_FILE(${PYQT_SIPS}/qt/qglobal.sip,pyqt_sips_ok=yes,pyqt_sips_ok=no) + if test "x$pyqt_sips_ok" == "xyes"; then + PYQT_SIPS="${PYQT_SIPS}/qt" + fi + fi +fi +if test "x$pyqt_sips_ok" == "xno"; then + dnl try ${PYQTDIR}/sip + if test "x${PYQTDIR}" != "x"; then + if test -d ${PYQTDIR}/sip ; then + AC_CHECK_FILE(${PYQTDIR}/sip/qglobal.sip,pyqt_sips_ok=yes,pyqt_sips_ok=no) + if test "x$pyqt_sips_ok" == "xyes"; then + PYQT_SIPS="${PYQTDIR}/sip" + else + AC_CHECK_FILE(${PYQTDIR}/sip/qt/qglobal.sip,pyqt_sips_ok=yes,pyqt_sips_ok=no) + if test "x$pyqt_sips_ok" == "xyes"; then + PYQT_SIPS="${PYQTDIR}/sip/qt" + fi + fi + fi + fi +fi +if test "x$pyqt_sips_ok" == "xno"; then + dnl try ${SIPDIR}/sip + if test "x${SIPDIR}" != "x"; then + if test -d ${SIPDIR}/sip ; then + AC_CHECK_FILE(${SIPDIR}/sip/qglobal.sip,pyqt_sips_ok=yes,pyqt_sips_ok=no) + if test "x$pyqt_sips_ok" == "xyes"; then + PYQT_SIPS="${SIPDIR}/sip" + else + AC_CHECK_FILE(${SIPDIR}/sip/qt/qglobal.sip,pyqt_sips_ok=yes,pyqt_sips_ok=no) + if test "x$pyqt_sips_ok" == "xyes"; then + PYQT_SIPS="${SIPDIR}/sip/qt" + fi + fi + fi + fi +fi +if test "x$pyqt_sips_ok" == "xno"; then + dnl try /usr/share/sip + if test -d /usr/share/sip ; then + AC_CHECK_FILE(/usr/share/sip/qglobal.sip,pyqt_sips_ok=yes,pyqt_sips_ok=no) + if test "x$pyqt_sips_ok" == "xyes"; then + PYQT_SIPS="/usr/share/sip" + else + AC_CHECK_FILE(/usr/share/sip/qt/qglobal.sip,pyqt_sips_ok=yes,pyqt_sips_ok=no) + if test "x$pyqt_sips_ok" == "xyes"; then + PYQT_SIPS="/usr/share/sip/qt" + fi + fi + fi +fi +if test "x$pyqt_sips_ok" == "xno"; then + pyqt_ok=no +else + PYQT_INCLUDES="-I$PYQT_SIPS" + + dnl Additional sip flags required for correct wrappers compilation + AC_MSG_CHECKING(which qt classes should be excluded) + + PYQT_SIPFLAGS="" + + CXXFLAGS_old=$CXXFLAGS + CXXFLAGS="$CXXFLAGS $QT_INCLUDES" + LIBS_old=$LIBS + LIBS="$LIBS $QT_LIBS" + + AC_TRY_COMPILE([#include ], + [new QCDEStyle();],,PYQT_SIPFLAGS="$PYQT_SIPFLAGS -x Qt_STYLE_CDE") + AC_TRY_COMPILE([#include ], + [new QInterlaceStyle();],,PYQT_SIPFLAGS="$PYQT_SIPFLAGS -x Qt_STYLE_INTERLACE") + AC_TRY_COMPILE([#include ], + [new QMotifStyle();],,PYQT_SIPFLAGS="$PYQT_SIPFLAGS -x Qt_STYLE_MOTIF") + AC_TRY_COMPILE([#include ], + [new QMotifPlusStyle();],,PYQT_SIPFLAGS="$PYQT_SIPFLAGS -x Qt_STYLE_MOTIFPLUS") + AC_TRY_COMPILE([#include ], + [new QPlatinumStyle();],,PYQT_SIPFLAGS="$PYQT_SIPFLAGS -x Qt_STYLE_PLATINUM") + AC_TRY_COMPILE([#include ], + [new QSGIStyle();],,PYQT_SIPFLAGS="$PYQT_SIPFLAGS -x Qt_STYLE_SGI") + AC_TRY_COMPILE([#include ], + [new QWindowsStyle();],,PYQT_SIPFLAGS="$PYQT_SIPFLAGS -x Qt_STYLE_WINDOWS") + AC_TRY_COMPILE([#include ], + [new QWindowsXPStyle();],,PYQT_SIPFLAGS="$PYQT_SIPFLAGS -x Qt_STYLE_WINDOWSXP") + + LIBS="$LIBS -lqassistantclient" + AC_TRY_LINK([#include ], + [new QAssistantClient("foo");],,PYQT_SIPFLAGS="$PYQT_SIPFLAGS -x Qt_ASSISTANTCLIENT") + + AC_MSG_RESULT(done) + + CXXFLAGS=$CXXFLAGS_old + LIBS=$LIBS_old +fi + +AC_SUBST(PYQT_INCLUDES) +AC_SUBST(PYQT_LIBS) +AC_SUBST(PYQT_SIPS) +AC_SUBST(PYUIC) +AC_SUBST(PYQT_SIPFLAGS) + +AC_LANG_RESTORE + +AC_MSG_RESULT(for pyqt: $pyqt_ok) + +])dnl +dnl + + diff --git a/adm_local/unix/config_files/check_qt.m4 b/adm_local/unix/config_files/check_qt.m4 new file mode 100644 index 000000000..ab2869c21 --- /dev/null +++ b/adm_local/unix/config_files/check_qt.m4 @@ -0,0 +1,175 @@ +dnl Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, +dnl CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +dnl +dnl This library is free software; you can redistribute it and/or +dnl modify it under the terms of the GNU Lesser General Public +dnl License as published by the Free Software Foundation; either +dnl version 2.1 of the License. +dnl +dnl This library is distributed in the hope that it will be useful, +dnl but WITHOUT ANY WARRANTY; without even the implied warranty of +dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +dnl Lesser General Public License for more details. +dnl +dnl You should have received a copy of the GNU Lesser General Public +dnl License along with this library; if not, write to the Free Software +dnl Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +dnl +dnl See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org +dnl +dnl +dnl + +AC_DEFUN([CHECK_QT],[ +AC_REQUIRE([AC_PROG_CC])dnl +AC_REQUIRE([AC_PROG_CXX])dnl +AC_REQUIRE([AC_PROG_CPP])dnl +AC_REQUIRE([AC_PROG_CXXCPP])dnl +AC_REQUIRE([CHECK_OPENGL])dnl + +AC_CHECKING(for QT) +qt_ok=yes + +AC_LANG_SAVE +AC_LANG_CPLUSPLUS + +if test "x$QTDIR" = "x" +then + AC_MSG_RESULT(please define QTDIR variable) + qt_ok=no +else + AC_MSG_RESULT(QTDIR is $QTDIR) + qt_inc_ok=no + QTINC="" + AC_CHECK_FILE(${QTDIR}/include/qt3/qglobal.h,QTINC="/qt3",QTINC="") + QT_VERS=`grep "QT_VERSION_STR" ${QTDIR}/include${QTINC}/qglobal.h | sed -e 's%^#define QT_VERSION_STR\([[:space:]]*\)%%g' -e 's%\"%%g'` + AC_MSG_RESULT(Qt version is $QT_VERS) + QT_VERS="Qt_"`echo $QT_VERS | sed -e 's%\"%%g' -e 's%\.%_%g'` +fi + +if test "x$qt_ok" = "xyes" +then + if test -f ${QTDIR}/bin/moc + then + MOC=${QTDIR}/bin/moc + else + AC_PATH_PROG(MOC, moc) + fi + if test "x$MOC" = "x" + then + qt_ok=no + AC_MSG_RESULT(moc qt-compiler not in PATH variable) + else + qt_ok=yes + AC_MSG_RESULT(moc found) + fi +fi + +if test "x$qt_ok" = "xyes" +then + if test -f ${QTDIR}/bin/uic + then + UIC=${QTDIR}/bin/uic + else + AC_PATH_PROG(UIC, uic) + fi + if test "x$UIC" = "x" + then + qt_ok=no + AC_MSG_RESULT(uic qt-interface compiler not in PATH variable) + else + qt_ok=yes + AC_MSG_RESULT(uic found) + fi +fi + +AC_SUBST(QTDIR) +QT_ROOT=$QTDIR + +if test "x$qt_ok" = "xyes" +then + CPPFLAGS_old=$CPPFLAGS + CPPFLAGS="$CPPFLAGS -I$QTDIR/include${QTINC}" + + AC_LANG_CPLUSPLUS + AC_CHECK_HEADER(qaction.h,qt_ok=yes ,qt_ok=no) + + CPPFLAGS=$CPPFLAGS_old + + AC_MSG_CHECKING(include of qt headers) + + if test "x$qt_ok" = "xno" + then + AC_MSG_RESULT(qt headers not found, or too old qt version, in $QTDIR/include) + AC_MSG_RESULT(QTDIR environment variable may be wrong) + else + AC_MSG_RESULT(yes) + QT_INCLUDES="-I${QT_ROOT}/include${QTINC} -DQT_THREAD_SUPPORT -DQT_CLEAN_NAMESPACE" + QT_MT_INCLUDES="-I${QT_ROOT}/include${QTINC} -DQT_THREAD_SUPPORT -DQT_CLEAN_NAMESPACE" + fi +fi + +if test "x$qt_ok" = "xyes" +then + AC_MSG_CHECKING(linking qt library) + LIBS_old=$LIBS + if test "x$QTDIR" = "x/usr" + then + LIBS="$LIBS -lqt-mt $OGL_LIBS" + else + LIBS="$LIBS -L$QTDIR/lib -lqt-mt $OGL_LIBS" + fi + + CXXFLAGS_old=$CXXFLAGS + CXXFLAGS="$CXXFLAGS $QT_INCLUDES" + + AC_CACHE_VAL(salome_cv_lib_qt,[ + AC_TRY_LINK( +#include +, int n; + char **s; + QApplication a(n, s); + a.exec();, + eval "salome_cv_lib_qt=yes",eval "salome_cv_lib_qt=no") + ]) + qt_ok="$salome_cv_lib_qt" + + if test "x$qt_ok" = "xno" + then + AC_MSG_RESULT(unable to link with qt library) + AC_MSG_RESULT(QTDIR environment variable may be wrong) + else + AC_MSG_RESULT(yes) + if test "x$QTDIR" = "x/usr" + then + QT_LIBS=" -lqt-mt" + QT_MT_LIBS=" -lqt-mt" + else + QT_LIBS="-L$QTDIR/lib -lqt-mt" + QT_MT_LIBS="-L$QTDIR/lib -lqt-mt" + fi + fi + + LIBS=$LIBS_old + CXXFLAGS=$CXXFLAGS_old + +fi + +AC_SUBST(MOC) +AC_SUBST(UIC) + +AC_SUBST(QT_ROOT) +AC_SUBST(QT_INCLUDES) +AC_SUBST(QT_LIBS) +AC_SUBST(QT_MT_LIBS) +AC_SUBST(QT_VERS) + +AC_LANG_RESTORE + +AC_MSG_RESULT(for qt: $qt_ok) + +# Save cache +AC_CACHE_SAVE + +])dnl +dnl diff --git a/adm_local/unix/config_files/check_qwt.m4 b/adm_local/unix/config_files/check_qwt.m4 new file mode 100644 index 000000000..13bf90914 --- /dev/null +++ b/adm_local/unix/config_files/check_qwt.m4 @@ -0,0 +1,151 @@ +dnl Copyright (C) 2003 CEA/DEN, EDF R&D + +AC_DEFUN([CHECK_QWT],[ +AC_REQUIRE([CHECK_QT])dnl + +AC_CHECKING(for qwt) + +qwt_ok=yes + +dnl were is qwt ? + +AC_ARG_WITH(qwt, + [ --with-qwt=DIR directory path to QWT installation ], + [QWTHOME="$withval" + AC_MSG_RESULT("select $withval as path to QWT") + ]) + +AC_ARG_WITH(qwt_inc, + [ --with-qwt_inc=DIR directory path to QWT includes ], + [QWT_INCLUDES="$withval" + AC_MSG_RESULT("select $withval as path to QWT includes") + ]) + +if test -z $QWTHOME; then + AC_MSG_RESULT(QWTHOME not defined) + exits_ok=no + if test "x$exits_ok" = "xno"; then + for d in /usr/local /usr ; do + AC_CHECK_FILE(${d}/lib/libqwt.so,exits_ok=yes,exits_ok=no) + if test "x$exits_ok" = "xyes"; then + QWTHOME=$d + AC_MSG_RESULT(libqwt.so detected in $d/lib) + fi + done + fi + if test "x$exits_ok" = "xno"; then + for d in `echo $LD_LIBRARY_PATH | sed -e "s/:/ /g"` ; do + if test -f $d/libqwt.so ; then + AC_MSG_RESULT(libqwt.so detected in $d) + QWTHOME=$d + QWTHOME=`echo ${QWTHOME} | sed -e "s,[[^/]]*$,,;s,/$,,;s,^$,.,"` + exits_ok=yes + break + fi + done + fi + if test "x$exits_ok" = "xyes"; then + if test -z $QWT_INCLUDES; then + QWT_INCLUDES=$QWTHOME"/include/qwt" + if test ! -f $QWT_INCLUDES/qwt.h ; then + QWT_INCLUDES=$QWTHOME"/include" + fi + if test ! -f $QWT_INCLUDES/qwt.h ; then + QWT_INCLUDES=/usr/lib/qt3/include/qwt + fi + fi + fi +else + if test -z $QWT_INCLUDES; then + QWT_INCLUDES="$QWTHOME/include" + fi +fi + +if test "x$qwt_ok" = xno -o ! -d "$QWTHOME" ; then + AC_MSG_RESULT(no) + AC_MSG_WARN(qwt not found) + qwt_ok=no +else + AC_LANG_SAVE + AC_LANG_CPLUSPLUS + CPPFLAGS_old=$CPPFLAGS + CPPFLAGS="$CPPFLAGS -I$QWT_INCLUDES" + CPPFLAGS="$CPPFLAGS $QT_INCLUDES" + + AC_CHECK_HEADER(qwt.h,qwt_ok=yes,qwt_ok=no) + + CPPFLAGS=$CPPFLAGS_old + + if test "x$qwt_ok" = xno ; then + AC_MSG_RESULT(no) + AC_MSG_WARN(qwt not found) + else + qwt_ok=yes + fi + +if test "x$qwt_ok" = "xyes" +then + AC_MSG_CHECKING(linking qwt library) + LIBS_old=$LIBS + if test "x$QTDIR" = "x/usr" + then + LIBS="$LIBS -lqt-mt" + else + LIBS="$LIBS -L$QTDIR/lib -lqt-mt" + fi + if test "x$QWTHOME" = "x/usr" + then + LIBS="$LIBS -lqwt" + else + LIBS="$LIBS -L$QWTHOME/lib -lqwt" + fi + + CXXFLAGS_old=$CXXFLAGS + CXXFLAGS="$CXXFLAGS $QT_INCLUDES -I$QWT_INCLUDES" + + AC_CACHE_VAL(salome_cv_lib_qwt,[ + AC_TRY_LINK( +#include +#include +, int n; + char **s; + QApplication a(n, s); + QwtPlot* p; + a.setMainWidget(p); + a.exec();, + eval "salome_cv_lib_qwt=yes",eval "salome_cv_lib_qwt=no") + ]) + qwt_ok="$salome_cv_lib_qwt" + + if test "x$qwt_ok" = "xno" + then + AC_MSG_RESULT(unable to link with qwt library) + AC_MSG_RESULT(QWTHOME environment variable may be wrong) + else + QWT_INCLUDES="-I$QWT_INCLUDES" + if test "x$QWTHOME" = "x/usr" + then + QWT_LIBS=" -lqwt" + else + QWT_LIBS="-L$QWTHOME/lib -lqwt" + fi + + AC_SUBST(QWT_INCLUDES) + AC_SUBST(QWT_LIBS) + + AC_MSG_RESULT(yes) + fi + + LIBS=$LIBS_old + CXXFLAGS=$CXXFLAGS_old + +fi + + + AC_LANG_RESTORE + +fi + + +])dnl +dnl diff --git a/adm_local/unix/config_files/check_sip.m4 b/adm_local/unix/config_files/check_sip.m4 new file mode 100644 index 000000000..245f2382e --- /dev/null +++ b/adm_local/unix/config_files/check_sip.m4 @@ -0,0 +1,168 @@ +dnl Copyright (C) 2003 CEA/DEN, EDF R&D + +AC_DEFUN([CHECK_SIP],[ +AC_REQUIRE([CHECK_PYTHON])dnl +AC_REQUIRE([CHECK_QT])dnl + +sip_ok=yes + +AC_ARG_WITH(sip, + [ --with-sip=EXEC sip executable ], + [SIP="$withval" + AC_MSG_RESULT("select $withval as sip executable") + ], [ + AC_PATH_PROG(SIP, sip) + ]) + +if test "x$SIP" = "x" ; then + sip_ok=no + AC_MSG_RESULT(sip not in PATH variable) +else + version=`$SIP -V` + AC_MSG_RESULT(sip version is $version) + case "$version" in + 3.2*) + SIP_VERS=v3_old ;; + 3.3*) + SIP_VERS=v3_old ;; + 3.4*) + SIP_VERS=v3_old ;; + 3.5*) + SIP_VERS=v3_old ;; + 3.6*) + SIP_VERS=v3_old ;; + 3.7*) + SIP_VERS=v3_old ;; + 3.8*) + SIP_VERS=v3_old ;; + 3.9*) + SIP_VERS=v3_old ;; + 3.10*) + SIP_VERS=v3_new ;; + 4.1*) + SIP_VERS=v4_old ;; + 4.2*) + SIP_VERS=v4_new ;; + *) + AC_MSG_RESULT(sip version $version not supported) + SIP_VERS=unsupported ;; + esac + + sip_ok=no + dnl Search sip.h file + if test "x$SIPDIR" != "x" ; then + dnl look for sip.h in ${SIPDIR} + AC_CHECK_FILE(${SIPDIR}/sip.h,sip_ok=yes,sip_ok=no) + if test "x$sip_ok" == "xyes" ; then + SIP_INCLUDES="-I${SIPDIR}" + fi + if test "x$sip_ok" == "xno" ; then + dnl look for sip.h in ${SIPDIR}/include/python${PYTHON_VERSION} + if test -d ${SIPDIR}/include/python${PYTHON_VERSION} ; then + AC_CHECK_FILE(${SIPDIR}/include/python${PYTHON_VERSION}/sip.h,sip_ok=yes,sip_ok=no) + if test "x$sip_ok" == "xyes" ; then + SIP_INCLUDES="-I${SIPDIR}/include/python${PYTHON_VERSION}" + fi + fi + fi + fi + if test "x$sip_ok" == "xno" ; then + dnl look for sip.h in ${PYTHON_PREFIX}/include/python${PYTHON_VERSION} + if test -d ${PYTHON_PREFIX}/include/python${PYTHON_VERSION} ; then + AC_CHECK_FILE(${PYTHON_PREFIX}/include/python${PYTHON_VERSION}/sip.h,sip_ok=yes,sip_ok=no) + if test "x$sip_ok" == "xyes" ; then + SIP_INCLUDES="${PYTHON_INCLUDES}" + fi + fi + fi + if test "x$sip_ok" == "xno" ; then + dnl look for sip.h in /usr/include/python${PYTHON_VERSION} + if test -d /usr/include/python${PYTHON_VERSION} ; then + AC_CHECK_FILE(/usr/include/python${PYTHON_VERSION}/sip.h,sip_ok=yes,sip_ok=no) + if test "x$sip_ok" == "xyes" ; then + SIP_INCLUDES="/usr/include/python${PYTHON_VERSION}" + fi + fi + fi + + dnl Search (lib)sip.so file + sip_lib_ok=no + if test "x$SIPDIR" != "x" ; then + dnl look for (lib)sip.so in ${SIPDIR} + AC_CHECK_FILE(${SIPDIR}/libsip.so,sip_lib_ok=yes,sip_lib_ok=no) + if test "x$sip_lib_ok" == "xyes" ; then + if test "x${SIPDIR}" = "x/usr/lib" + then + SIP_LIBS="-lsip" + else + SIP_LIBS="-L${SIPDIR} -lsip" + fi + else + AC_CHECK_FILE(${SIPDIR}/sip.so,sip_lib_ok=yes,sip_lib_ok=no) + if test "x$sip_lib_ok" == "xyes" ; then + if test "x${SIPDIR}" = "x/usr/lib" + then + SIP_LIBS="" + else + SIP_LIBS="-L${SIPDIR}" + fi + fi + fi + + if test "x$sip_lib_ok" == "xno" ; then + dnl look for (lib)sip.so in ${SIPDIR}/lib/python${PYTHON_VERSION}/site-packages + if test -d ${SIPDIR}/lib/python${PYTHON_VERSION}/site-packages ; then + AC_CHECK_FILE(${SIPDIR}/lib/python${PYTHON_VERSION}/site-packages/libsip.so,sip_lib_ok=yes,sip_lib_ok=no) + if test "x$sip_lib_ok" == "xyes" ; then + SIP_LIBS="-L${SIPDIR}/lib/python${PYTHON_VERSION}/site-packages -lsip" + else + AC_CHECK_FILE(${SIPDIR}/lib/python${PYTHON_VERSION}/site-packages/sip.so,sip_lib_ok=yes,sip_lib_ok=no) + if test "x$sip_lib_ok" == "xyes" ; then + SIP_LIBS="-L${SIPDIR}/lib/python${PYTHON_VERSION}/site-packages" + fi + fi + fi + fi + fi + if test "x$sip_lib_ok" == "xno" ; then + dnl look for (lib)sip.so in ${PYTHON_PREFIX}/lib/python${PYTHON_VERSION}/site-packages + if test -d ${PYTHON_PREFIX}/lib/python${PYTHON_VERSION}/site-packages ; then + AC_CHECK_FILE(${PYTHON_PREFIX}/lib/python${PYTHON_VERSION}/site-packages/libsip.so,sip_lib_ok=yes,sip_lib_ok=no) + if test "x$sip_lib_ok" == "xyes" ; then + SIP_LIBS="-L${PYTHON_PREFIX}/lib/python${PYTHON_VERSION}/site-packages -lsip" + else + AC_CHECK_FILE(${PYTHON_PREFIX}/lib/python${PYTHON_VERSION}/site-packages/sip.so,sip_lib_ok=yes,sip_lib_ok=no) + if test "x$sip_lib_ok" == "xyes" ; then + SIP_LIBS="-L${PYTHON_PREFIX}/lib/python${PYTHON_VERSION}/site-packages" + fi + fi + fi + fi + if test "x$sip_lib_ok" == "xno" ; then + dnl look for (lib)sip.so in /usr/lib/python${PYTHON_VERSION}/site-packages + if test -d /usr/lib/python${PYTHON_VERSION}/site-packages ; then + AC_CHECK_FILE(/usr/lib/python${PYTHON_VERSION}/site-packages/libsip.so,sip_lib_ok=yes,sip_lib_ok=no) + if test "x$sip_lib_ok" == "xyes" ; then + SIP_LIBS="-L$/usr/lib/python${PYTHON_VERSION}/site-packages -lsip" + else + AC_CHECK_FILE(/usr/lib/python${PYTHON_VERSION}/site-packages/sip.so,sip_lib_ok=yes,sip_lib_ok=no) + if test "x$sip_lib_ok" == "xyes" ; then + SIP_LIBS="-L/usr/lib/python${PYTHON_VERSION}/site-packages" + fi + fi + fi + fi + if test "x$sip_lib_ok" == "xno" ; then + sip_ok=no + fi +fi + +AC_SUBST(SIP) +AC_SUBST(SIP_INCLUDES) +AC_SUBST(SIP_LIBS) +AC_SUBST(SIP_VERS) + +AC_MSG_RESULT(for sip: $sip_ok) + +])dnl +dnl diff --git a/adm_local/unix/config_files/check_vtk.m4 b/adm_local/unix/config_files/check_vtk.m4 new file mode 100644 index 000000000..df9245b5d --- /dev/null +++ b/adm_local/unix/config_files/check_vtk.m4 @@ -0,0 +1,148 @@ +dnl Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, +dnl CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +dnl +dnl This library is free software; you can redistribute it and/or +dnl modify it under the terms of the GNU Lesser General Public +dnl License as published by the Free Software Foundation; either +dnl version 2.1 of the License. +dnl +dnl This library is distributed in the hope that it will be useful, +dnl but WITHOUT ANY WARRANTY; without even the implied warranty of +dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +dnl Lesser General Public License for more details. +dnl +dnl You should have received a copy of the GNU Lesser General Public +dnl License along with this library; if not, write to the Free Software +dnl Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +dnl +dnl See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org +dnl +dnl +dnl + +AC_DEFUN([CHECK_VTK],[ +AC_REQUIRE([AC_PROG_CC])dnl +AC_REQUIRE([AC_PROG_CXX])dnl +AC_REQUIRE([AC_PROG_CPP])dnl +AC_REQUIRE([AC_PROG_CXXCPP])dnl + +AC_CHECKING(for VTK) + +AC_LANG_SAVE +AC_LANG_CPLUSPLUS + +AC_SUBST(VTK_INCLUDES) +AC_SUBST(VTK_LIBS) +AC_SUBST(VTKPY_MODULES) + +VTK_INCLUDES="" +VTK_LIBS="" +VTKPY_MODULES="" + +vtk_ok=no + +AC_PATH_X + +if test "x$OpenGL_ok" != "xyes" +then + AC_MSG_WARN(vtk needs OpenGL correct configuration, check configure output) +fi + +if test "x$x_libraries" != "x" +then + LXLIB="-L$x_libraries" +else + LXLIB="" +fi + +if test "x$x_libraries" = "x/usr/lib" +then + LXLIB="" +fi + +if test "x$x_libraries" = "x/usr/lib" +then + LXLIB="" +fi + +if test "x$x_libraries" = "x/usr/lib" +then + LXLIB="" +fi + +LOCAL_INCLUDES="$OGL_INCLUDES" +LOCAL_LIBS="-lvtkCommon -lvtkGraphics -lvtkImaging -lvtkFiltering -lvtkIO -lvtkRendering -lvtkHybrid $OGL_LIBS $LXLIB -lX11 -lXt" +TRY_LINK_LIBS="-lvtkCommon $OGL_LIBS $LXLIB -lX11 -lXt" + +if test -z $VTKHOME +then + AC_MSG_WARN(undefined VTKHOME variable which specify where vtk was compiled) + if test -f /usr/include/vtk/vtkPlane.h ; then + AC_MSG_RESULT(trying /usr) + VTKHOME="/usr" + fi +fi + +if test ! -z $VTKHOME +then + LOCAL_INCLUDES="-I$VTKHOME/include/vtk $LOCAL_INCLUDES" + LOCAL_LIBS="-L$VTKHOME/lib/vtk $LOCAL_LIBS" + TRY_LINK_LIBS="-L$VTKHOME/lib/vtk $TRY_LINK_LIBS" +fi + +dnl vtk headers +CPPFLAGS_old="$CPPFLAGS" +CPPFLAGS="$CPPFLAGS $LOCAL_INCLUDES" + +AC_CHECK_HEADER(vtkPlane.h,vtk_ok="yes",vtk_ok="no") + + CPPFLAGS="$CPPFLAGS_old" + + if test "x$vtk_ok" = "xyes" + then + VTK_INCLUDES="$LOCAL_INCLUDES" + + dnl vtk libraries + + AC_MSG_CHECKING(linking VTK library) + + LIBS_old="$LIBS" +# LIBS="$LIBS $TRY_LINK_LIBS" + LIBS="$LIBS $LOCAL_LIBS" + CPPFLAGS_old="$CPPFLAGS" + CPPFLAGS="$CPPFLAGS $VTK_INCLUDES" + + dnl VTKPY_MODULES="$VTKHOME/python" + + AC_CACHE_VAL(salome_cv_lib_vtk,[ + AC_TRY_LINK( +#include "vtkPlane.h" +, vtkPlane *p = vtkPlane::New();, + eval "salome_cv_lib_vtk=yes",eval "salome_cv_lib_vtk=no") + ]) + vtk_ok="$salome_cv_lib_vtk" + LIBS="$LIBS_old" + CPPFLAGS="$CPPFLAGS_old" + +fi + +if test "x$vtk_ok" = "xno" +then + AC_MSG_RESULT("no") + AC_MSG_WARN(unable to link with vtk library) +else + AC_MSG_RESULT("yes") + VTK_LIBS="$LOCAL_LIBS" + VTK_MT_LIBS="$LOCAL_LIBS" +fi + +AC_MSG_RESULT("for vtk: $vtk_ok") + +AC_LANG_RESTORE + +# Save cache +AC_CACHE_SAVE + +])dnl + + diff --git a/adm_local/unix/make_commence.in b/adm_local/unix/make_commence.in index cb1d7e470..78506b08c 100644 --- a/adm_local/unix/make_commence.in +++ b/adm_local/unix/make_commence.in @@ -1,6 +1,14 @@ # common directories to put headerfiles inc_builddir=$(top_builddir)/include/salome +GUI_DISABLE_CORBA=@GUI_DISABLE_CORBA@ +DISABLE_GLVIEWER=@DISABLE_GLVIEWER@ +DISABLE_PYCONSOLE=@DISABLE_PYCONSOLE@ +DISABLE_PLOT2DVIEWER=@DISABLE_PLOT2DVIEWER@ +DISABLE_SUPERVGRAPHVIEWER=@DISABLE_SUPERVGRAPHVIEWER@ +DISABLE_OCCVIEWER=@DISABLE_OCCVIEWER@ +DISABLE_VTKVIEWER=@DISABLE_VTKVIEWER@ +DISABLE_SALOMEOBJECT=@DISABLE_SALOMEOBJECT@ @SET_MAKE@ SHELL=/bin/sh @@ -254,14 +262,9 @@ $(top_srcdir)/configure.in: $(top_srcdir)/configure.in.base ACLOCAL_SRC = \ -ac_cxx_bool.m4 check_corba.m4 check_vtk.m4 \ -ac_cxx_depend_flag.m4 check_hdf5.m4 enable_pthreads.m4 \ -ac_cxx_mutable.m4 check_mico.m4 libtool.m4 \ -ac_cxx_namespaces.m4 check_omniorb.m4 pyembed.m4 \ -ac_cxx_partial_specialization.m4 check_opengl.m4 python.m4 \ -ac_cxx_typename.m4 check_pthreads.m4 check_cas.m4 \ -ac_cc_warnings.m4 check_qt.m4 check_swig.m4 \ -check_boost.m4 check_msg2qm.m4 - -$(top_srcdir)/aclocal.m4: $(ACLOCAL_SRC:%=@KERNEL_ROOT_DIR@/salome_adm/unix/config_files/%) +check_qt.m4 check_vtk.m4 check_qwt.m4 \ +check_sip.m4 check_msg2qm.m4 check_pyqt.m4 \ +check_opengl.m4 + +$(top_srcdir)/aclocal.m4: $(ACLOCAL_SRC:%=$(top_srcdir)/adm_local/unix/config_files/%) cd $(top_srcdir) ; aclocal --acdir=adm_local/unix/config_files -I @KERNEL_ROOT_DIR@/salome_adm/unix/config_files diff --git a/adm_local/unix/make_conclude.in b/adm_local/unix/make_conclude.in new file mode 100644 index 000000000..c79350747 --- /dev/null +++ b/adm_local/unix/make_conclude.in @@ -0,0 +1,425 @@ +#======================================================================= +# This section of this makefile comes from the file +# 'adm/unix/make_conclude' which was generated with config.status +# from file adm/unix/make_conclude.in +#======================================================================= +# -* Makefile *- +# +# Authors : Patrick GOLDBRONN (CEA) - Marc Tajchman (CEA) +# Date : 6/07/2001 +# $Header$ +# + +ifneq ($(GUI_DISABLE_CORBA),yes) +# ORB Specifics rules + +@CORBA@ + +# transform idl reference in appropriate obj file +LIB_CLIENT_SRC = $(LIB_CLIENT_IDL:%.idl=%$(IDL_CLN_CXX)) +LIB_SERVER_SRC = $(LIB_SERVER_IDL:%.idl=%$(IDL_SRV_CXX)) +LIB_SWIG_SRC = $(SWIG_DEF:%.i=%_wrap.cxx) +else +LIB_CLIENT_SRC = +LIB_SERVER_SRC = +LIB_SWIG_SRC = +endif + +LIB_MOC_SRC = $(LIB_MOC:%.h=%_moc.cxx) +LIB_SRC+=$(LIB_MOC_SRC) +LIB_DEP= $(LIB_SRC) $(LIB_CLIENT_SRC) $(LIB_SERVER_SRC) $(LIB_SWIG_SRC) + +ifneq ($(GUI_DISABLE_CORBA),yes) +LIB_CLIENT_OBJ = $(LIB_CLIENT_IDL:%.idl=%$(IDL_CLN_OBJ)) +LIB_SERVER_OBJ = $(LIB_SERVER_IDL:%.idl=%$(IDL_SRV_OBJ)) +LIB_SWIG_OBJ = $(LIB_SWIG_SRC:%.cxx=%.lo) +else +LIB_CLIENT_OBJ = +LIB_SERVER_OBJ = +LIB_SWIG_OBJ = +endif + +# transform c file in appropriate libtool obj file (.c, .cc and .cxx) +LIB_OBJ_C = $(patsubst %.c, %.lo, $(filter %.c, $(LIB_SRC))) +LIB_OBJ_CC = $(patsubst %.cc, %.lo, $(filter %.cc, $(LIB_SRC))) +LIB_OBJ_CXX = $(patsubst %.cxx, %.lo, $(filter %.cxx, $(LIB_SRC))) +LIB_OBJ_F = $(patsubst %.f, %.lo, $(filter %.f, $(LIB_SRC))) + +# all libtool obj file in library +LIB_OBJ = $(LIB_OBJ_CXX) $(LIB_OBJ_CC) $(LIB_OBJ_C) $(LIB_CLIENT_OBJ:%.o=%.lo) $(LIB_SERVER_OBJ:%.o=%.lo) $(LIB_SWIG_OBJ) $(LIB_OBJ_F) + +# LIB_BUILD = $(LIB:%.la=$(top_builddir)/lib/salome/%.la) +LIB_BUILD = $(patsubst %.la, $(top_builddir)/lib/salome/%.la, $(filter %.la, $(LIB))) +LIB_BUILD_A = $(patsubst %.a, $(top_builddir)/lib/salome/%.a, $(filter %.a, $(LIB))) +LIB_BUILD_SO = $(patsubst %.so, $(top_builddir)/lib/salome/%.so, $(filter %.so, $(LIB))) + +ifneq ($(findstring cmodule.la,$(filter %.la, $(LIB))),) +ifneq ($(GUI_DISABLE_CORBA),yes) +LIB_SWIG = $(patsubst %cmodule.la,%.so, $(filter %.la, $(LIB))) +else +LIB_SWIG = +endif +else +LIB_SWIG = +endif + +lib: $(LIB_BUILD) $(LIB_BUILD_SO) $(LIB_CLIENT_PY) +# we don't build static library ! + +$(LIB_BUILD): $(top_builddir)/lib/salome/%.la: %.la + -$(RM) $@ + -$(RM) $(patsubst %.la, %.so, $@) + -$(RM) $(patsubst %.la, %.a, $@) + ln -sf $(CURDIR)/$< $@ || true + ln -sf $(patsubst %.la, %.so, $(CURDIR)/.libs/$<) \ + $(patsubst %.la, %.so, $@) || true + ln -sf $(patsubst %.la, %.so, $(CURDIR)/.libs/$<).0 \ + $(patsubst %.la, %.so, $@).0 || true + + if ! test -z $(LIB_SWIG) ; then \ + ln -sf $(patsubst %.la,%.so, $(CURDIR)/.libs/$<) $(top_builddir)/lib/salome/_$(LIB_SWIG) || true;\ + fi; + +$(LIB_BUILD_A): $(top_builddir)/lib/salome/%.a: %.a + -$(RM) $@ + ln -sf $(CURDIR)/$< $@ || true + +$(LIB_BUILD_SO): $(top_builddir)/lib/salome/%.so: %.so + -$(RM) $@ + ln -sf $(CURDIR)/$< $@ || true + +$(LIB): $(LIB_OBJ) + @$(LT) --mode=link $(CXX) -shared -rpath $(libdir) -o $@ $(CXXFLAGS) $(LIB_OBJ) $(LDFLAGS) $(LIBS) + +# transform idl reference in appropriate obj file +ifneq ($(GUI_DISABLE_CORBA),yes) +BIN_CLIENT_SRC = $(BIN_CLIENT_IDL:%.idl=%$(IDL_CLN_CXX)) +BIN_SERVER_SRC = $(BIN_SERVER_IDL:%.idl=%$(IDL_SRV_CXX)) +else +BIN_CLIENT_SRC = +BIN_SERVER_SRC = +endif +BIN_MOC_SRC = $(BIN_MOC:%.h=%_moc.cxx) +BIN_SRC+=$(BIN_MOC_SRC) +BIN_DEP=$(BIN:%=%.cxx) $(BIN_SRC) $(BIN_CLIENT_SRC) $(BIN_SERVER_SRC) + +ifneq ($(GUI_DISABLE_CORBA),yes) +BIN_CLIENT_OBJ = $(BIN_CLIENT_IDL:%.idl=%$(IDL_CLN_OBJ)) +BIN_SERVER_OBJ = $(BIN_SERVER_IDL:%.idl=%$(IDL_SRV_OBJ)) +else +BIN_CLIENT_OBJ = +BIN_SERVER_OBJ = +endif +# transform c file in appropriate libtool obj file (.c) +BIN_OBJ_C = $(patsubst %.c, %.o, $(filter %.c, $(BIN_SRC))) +# transform c++ file in appropriate libtool obj file (.cc and .cxx) +BIN_OBJ_CC = $(patsubst %.cc, %.o, $(filter %.cc, $(BIN_SRC))) +BIN_OBJ_CXX = $(patsubst %.cxx, %.o, $(filter %.cxx, $(BIN_SRC))) +# all obj file in bin target +BIN_OBJ = $(BIN_OBJ_CC) $(BIN_OBJ_CXX) $(BIN_OBJ_C) $(BIN_CLIENT_OBJ) $(BIN_SERVER_OBJ) + +bin: $(BIN:%=$(top_builddir)/bin/salome/%) $(BIN) $(LIB) pyscripts sharedpyscripts + +BIN_LIB=$(LIB:lib%.la=-l%) + +$(BIN:%=$(top_builddir)/bin/salome/%) $(TEST_PROGS:%=$(top_builddir)/bin/salome/%): $(top_builddir)/bin/salome/%: % + -$(RM) $@ + ln -sf $(CURDIR)/$< $@ + +$(BIN) $(TEST_PROGS): %: %.lo $(BIN_OBJ) + $(CXX) $(CPPFLAGS) $(CXXFLAGS) -o $@ $^ $(BIN_LIB) $(LDFLAGSFORBIN) $(LIBSFORBIN) + +# copy python scripts in $(top_builddir)/bin/salome +# + +UI_FILES = $(notdir $(wildcard $(srcdir)/*.ui)) +UI_PY_FILES_PY = $(patsubst %.ui, %.py, $(UI_FILES)) +UI_PY_FILES = $(filter-out $(EXPORT_PYSCRIPTS) ,$(UI_PY_FILES_PY)) + +DEST_PYSCRIPTS = $(EXPORT_PYSCRIPTS:%=$(top_builddir)/bin/salome/%) +DEST_UI_PY_FILES = $(UI_PY_FILES:%=$(top_builddir)/bin/salome/%) +pyscripts: $(DEST_PYSCRIPTS) $(UI_PY_FILES) $(DEST_UI_PY_FILES) +$(DEST_PYSCRIPTS): $(top_builddir)/bin/salome/%: % + cp -f $< $@ + +# generate generic python scripts from *.ui files +# +$(UI_PY_FILES): %.py: %.ui + $(PYUIC) $< -o $@ + +# copy ui-generated python scripts in $(top_builddir)/bin +# +$(DEST_UI_PY_FILES): $(top_builddir)/bin/salome/%: % + cp -f $< $@ + +# copy pyqt files in $(PYTHON_SHARED_SITE) +# +PYTHON_SHARED_SITE=$(top_builddir)/lib/python$(PYTHON_VERSION)/site-packages/salome/shared_modules + +$(PYTHON_SHARED_SITE): + $(INSTALL) -d $@ + +DEST_SHAREDPYSCRIPTS = $(EXPORT_SHAREDPYSCRIPTS:%=$(PYTHON_SHARED_SITE)/%) +sharedpyscripts: $(PYTHON_SHARED_SITE) $(DEST_SHAREDPYSCRIPTS) +$(DEST_SHAREDPYSCRIPTS): $(PYTHON_SHARED_SITE)/%: % + cp -f $< $@ + +check: test + +tests: unittest + +test: $(LIB) $(TEST_PROGS:%=$(top_builddir)/bin/salome/%) + +unittest: + @if test "x$(UNIT_TEST_PROG)" != "x"; then \ + $(top_builddir)/bin/salome/$(UNIT_TEST_PROG); \ + fi; + +# copy header file in $(inc_builddir) +# +DEST_HEADERS = $(EXPORT_HEADERS:%=$(inc_builddir)/%) +inc: $(DEST_HEADERS) +$(DEST_HEADERS): $(inc_builddir)/%: % + cp -f $< $@ + +# build resources file (icons and messages) : .qm file from .po file +RESOURCES_FILES_ALL := $(notdir $(wildcard $(srcdir)/resources/*)) +RESOURCES_FILES_ALL := $(filter-out CVS, $(RESOURCES_FILES_ALL)) +RESOURCES_FILES_ALL := $(filter-out %.po, $(RESOURCES_FILES_ALL)) +RESOURCES_FILES ?= $(RESOURCES_FILES_ALL) + +resources: resources-po resources-cp + +resources-po: $(PO_FILES:%.po=$(top_builddir)/share/salome/resources/%.qm) + +resources-cp: $(RESOURCES_FILES:%=$(top_builddir)/share/salome/resources/%) + +$(RESOURCES_FILES:%=$(top_builddir)/share/salome/resources/%): $(top_builddir)/share/salome/resources/% : % + cp -fr $< $@; + +# Make installation directories if they don't exist. +$(libdir) $(includedir) $(bindir) $(datadir) $(idldir) $(sharedpydir): + $(INSTALL) -d $@ && chmod 755 $@ + +# Install the library, the public header files, and programs. +install: $(LIB) $(BIN) $(TEST_PROGS) $(libdir) $(includedir) $(bindir) $(datadir) $(idldir) install-python install-sharedpyqt install-qm install-res + @for f in X $(LIB); do \ + if test $$f != X; then \ + ($(LT_INSTALL_LIB) $$f $(libdir)/. || exit 1); \ + fi; \ + done + @if ! test -z $(LIB_SWIG) ; then \ + (cd $(libdir); ln -sf $(patsubst %.so, %cmodule.so, $(LIB_SWIG)) _$(LIB_SWIG) || true); \ + fi; + @for f in X $(BIN); do \ + if test $$f != X; then \ + ($(LT_INSTALL_PROG) $$f $(bindir)/. || exit 1); \ + fi; \ + done +# Install tests programmes in bindir + @for f in X $(TEST_PROGS); do \ + if test $$f != X; then \ + ($(LT_INSTALL_PROG) $$f $(bindir)/. || exit 1); \ + fi; \ + done +# Install exported includes in includedir + @for f in X $(EXPORT_HEADERS:%=$(srcdir)/%); do \ + if test $$f != X; then \ + (cp -p -f $$f $(includedir) || exit 1); \ + fi; \ + done + +# Install python script in $(bindir) +install-python: $(bindir) $(EXPORT_PYSCRIPTS:%=install-%) $(UI_PY_FILES:%=install-%) + +$(UI_PY_FILES:%=install-%): install-%: % + $(INSTALL_PROGRAM) $< $(bindir)/. + +$(EXPORT_PYSCRIPTS:%=install-%): install-%: % + $(INSTALL_PROGRAM) $< $(bindir)/. + +#install-python: $(bindir) $(EXPORT_PYSCRIPTS) +# @for f in X $(EXPORT_PYSCRIPTS); do \ +# if test $$f != X; then \ +# ($(INSTALL_PROGRAM) $$f $(bindir)/. || exit 1); \ +# fi; \ +# done + +# Install pyqt script in $(install-sharedpyqt) +install-sharedpyqt: $(sharedpydir) $(EXPORT_SHAREDPYSCRIPTS:%=install-%) + +$(EXPORT_SHAREDPYSCRIPTS:%=install-%): install-%: % + $(INSTALL_PROGRAM) $< $(sharedpydir)/. + + +# generic rule to install .qm files : +install-qm: resources + $(INSTALL) -d $(datadir)/resources + @for f in X $(PO_FILES:%.po=$(top_builddir)/share/salome/resources/%.qm); do \ + if test $$f != X; then \ + ($(INSTALL_DATA) $$f $(datadir)/resources/. || exit 1); \ + fi; \ + done + +# generic rule to install resources files (png, ini ...): +install-res: resources + $(INSTALL) -d $(datadir)/resources + @for f in X $(RESOURCES_FILES:%=$(top_builddir)/share/salome/resources/%); do \ + if test $$f != X; then \ + ($(INSTALL_DATA) $$f $(datadir)/resources/. || exit 1); \ + fi; \ + done + +# Removes those things that `make install' (would have) installed. +uninstall: + @if test "X$(LIB)" != X; then \ + for f in $(LIB); do \ + $(LT_UNINSTALL) $(libdir)/$$f; \ + done; \ + fi + @if test "X$(BIN)" != X; then \ + for f in $(BIN); do \ + $(LT_UNINSTALL) $(bindir)/$$f; \ + done; \ + fi + @for f in X $(TEST_PROGS); do \ + if test $$f != X; then \ + $(LT_UNINSTALL) $(bindir)/$$f; \ + fi; \ + done +# Uninstall exported includes in includedir + @for f in X $(EXPORT_HEADERS); do \ + if test $$f != X; then \ + $(LT_UNINSTALL) $(includedir)/$$f; \ + fi; \ + done +# Uninstall python script in $(bindir) + @for f in X $(EXPORT_PYSCRIPTS); do \ + if test $$f != X; then \ + $(LT_UNINSTALL) $(bindir)/$$f ; \ + fi; \ + done + +# Uninstall python script in $(bindir) + @for f in X $(UI_PY_FILES); do \ + if test $$f != X; then \ + $(LT_UNINSTALL) $(bindir)/$$f ; \ + fi; \ + done + +# Uninstall pyqt script in $(sharedpydir) + @for f in X $(EXPORT_SHAREDPYSCRIPTS); do \ + if test $$f != X; then \ + $(LT_UNINSTALL) $(sharedpydir)/$$f ; \ + fi; \ + done + +# Uninstall qm files + @for f in X $(PO_FILES:%.po=%.qm); do \ + if test $$f != X; then \ + $(LT_UNINSTALL) $(datadir)/resources/$$f ; \ + fi; \ + done + +# remove all dependencies files +# +cleandep: + -$(RM) .dep* + +# Removes temporary files without removing the final target files. That is, +# remove things like object files but not libraries or executables. +# +mostlyclean: cleandep + -$(RM) $(LIB_OBJ) $(LIB_OBJ:.lo=.o) + -$(RM) $(BIN_OBJ) $(BIN:%=%.o) + -$(RM) $(TEST_OBJ) $(TEST_OBJ:.lo=.o) + -$(RM) $(PROG_OBJ) $(PROG_OBJ:.lo=.o) $(MOSTLYCLEAN) + +# Like `mostlyclean' except it also removes the final targets: things like +# libraries and executables. This target doesn't remove any file that +# is part of the SALOME distribution. +# +clean: mostlyclean + -$(RM) $(LIB) $(TEST_PROGS) $(BIN) $(CLEAN) + -$(RM) TAGS *~ *# core *.core + -$(RM) -r .libs + -$(RM) $(top_builddir)/lib/salome/$(LIB) + -$(RM) $(patsubst %,$(top_builddir)/bin/salome/%, $(BIN)) + -$(RM) $(patsubst %.la, %.so, $(top_builddir)/lib/salome/$(LIB)) + -$(RM) $(patsubst %.la, %.a, $(top_builddir)/lib/salome/$(LIB)) +# remove idl generated files (sources) + -$(RM) $(LIB_CLIENT_SRC) $(LIB_SERVER_SRC) $(BIN_CLIENT_SRC) $(BIN_SERVER_SRC) +# remove idl generated files (headers) + -$(RM) $(LIB_CLIENT_IDL:%.idl=%$(IDL_CLN_H)) $(LIB_SERVER_IDL:%.idl=%$(IDL_SRV_H)) + -$(RM) $(BIN_CLIENT_IDL:%.idl=%$(IDL_CLN_H)) $(BIN_SERVER_IDL:%.idl=%$(IDL_SRV_H)) + -$(RM) $(LIB_MOC_SRC) $(BIN_MOC_SRC) + -$(RM) $(LIB_SWIG_SRC) + +# Like `clean' except it also removes files that were created by running +# configure. If you've unpacked the source and built without creating +# any other files, then `make distclean' will leave only the files that were +# in the distribution. +# +distclean: clean + #remove qm file ! + -$(RM) $(PO_FILES:%.po=%.qm) $(PO_FILES:%.po=$(top_builddir)/share/salome/resources/%.qm) + #remove include files + -$(RM) $(DEST_HEADERS) + -$(RM) $(DISTCLEAN) *.bak *.old *.new .dep* + @if test -f $(srcdir)/Makefile.in; then \ + (@SETX@; $(RM) Makefile); \ + fi + + +#implicits rules +.cc.o: + $(CXX) $(CXXFLAGS) $(CPPFLAGS) -c $< + +.cc.lo: + $(LT) --mode=compile $(CXX) $(CXXFLAGS) $(CPPFLAGS) -c $< + +.cxx.o: + $(CXX) $(CXXFLAGS) $(CPPFLAGS) -c $< + +.cxx.lo: + $(LT) --mode=compile $(CXX) $(CXXFLAGS) $(CPPFLAGS) -c $< + +.c.o: + $(CC) $(CFLAGS) $(CPPFLAGS) -c $< + +.c.lo: + $(LT_COMPILE) $(CFLAGS) $(CPPFLAGS) -c $< + +.f.o: + $(FC) $(FFLAGS) -c $< -o $@ + +.f.lo: + $(LT) --mode=compile $(FC) $(FFLAGS) -c $< + +.ui.h: + $(UIC) -o $@ $< + +.ui.cxx: + $(UIC) -o $@ -i $*.h $< + +#pattern rules +%_moc.cxx : %.h + $(MOC) $< -o $@ + +%_wrap.cxx : %.i + $(SWIG) $(SWIG_FLAGS) -o $@ $< + +$(top_builddir)/share/salome/resources/%.qm: %.po + $(MSG2QM) $< $@ ; \ + +#------------------------------------------------------------------------------ +# The following section of this makefile contains dependencies between the +# source files and the header files. If GNU make and GCC are being used then +# the dependencies are in the form of rules that cause the information to +# be kept updated automatically. Otherwise the dependencies are listed +# explicitly and come from the `.distdep' files in the various directories. +# These files are part of the distribution and are generated automatically on +# GNU/GCC systems. +#------------------------------------------------------------------------------ + +@DEPEND@ diff --git a/build_configure b/build_configure index ec5cce644..fad9468f8 100755 --- a/build_configure +++ b/build_configure @@ -127,7 +127,7 @@ echo " ./salome_adm/unix/depend \\" >> configure.in_tmp1 echo " ./adm_local/unix/make_omniorb \\" >> configure.in_tmp1 echo " ./salome_adm/unix/envScript \\" >> configure.in_tmp1 echo " ./adm_local/unix/make_commence \\" >> configure.in_tmp1 -echo " ./salome_adm/unix/make_conclude \\" >> configure.in_tmp1 +echo " ./adm_local/unix/make_conclude \\" >> configure.in_tmp1 echo " ./salome_adm/unix/make_module \\" >> configure.in_tmp1 \rm -f configure.in_tmp2 configure.in_tmp3 @@ -202,7 +202,7 @@ else echo -n "Creating 'configure' script ... " fi -aclocal --acdir=adm_local/unix/config_files -I ${KERNEL_ROOT_DIR}/salome_adm/unix/config_files +aclocal -I adm_local/unix/config_files -I ${KERNEL_ROOT_DIR}/salome_adm/unix/config_files if autoconf then echo "done" diff --git a/configure.in.base b/configure.in.base index e6be9b20d..f593bc607 100644 --- a/configure.in.base +++ b/configure.in.base @@ -26,6 +26,41 @@ AC_SUBST(PACKAGE) VERSION=0.0.1 AC_SUBST(VERSION) +######################################################################## +# Check --disable-corba option + +GUI_DISABLE_CORBA="no" +DISABLE_PYCONSOLE="no" +DISABLE_GLVIEWER="no" +DISABLE_PLOT2DVIEWER="no" +DISABLE_SUPERVGRAPHVIEWER="no" +DISABLE_OCCVIEWER="no" +DISABLE_VTKVIEWER="no" +DISABLE_SALOMEOBJECT="no" + +for option +do + case $option in + -disable-corba=yes | --disable-corba=yes | -disable-corba | --disable-corba) + GUI_DISABLE_CORBA="yes";; + -disable-pyConsole=yes | --disable-pyConsole=yes | -disable-pyConsole | --disable-pyConsole) + DISABLE_PYCONSOLE="yes";; + -disable-glViewer=yes | --disable-glViewer=yes | -disable-glViewer | --disable-glViewer) + DISABLE_GLVIEWER="yes";; + -disable-plot2dViewer=yes | --disable-plot2dViewer=yes | -disable-plot2dViewer | --disable-plot2dViewer) + DISABLE_PLOT2DVIEWER="yes";; + -disable-supervGraphViewer=yes | --disable-supervGraphViewer=yes | \ + -disable-supervGraphViewer | --disable-supervGraphViewer) + DISABLE_SUPERVGRAPHVIEWER="yes";; + -disable-occViewer=yes | --disable-occViewer=yes | -disable-occViewer | --disable-occViewer) + DISABLE_OCCVIEWER="yes";; + -disable-vtkViewer=yes | --disable-vtkViewer=yes | -disable-vtkViewer | --disable-vtkViewer) + DISABLE_VTKVIEWER="yes";; + -disable-salomeObject=yes | --disable-salomeObject=yes | -disable-salomeObject | --disable-salomeObject) + DISABLE_SALOMEOBJECT="yes";; + esac +done + dnl dnl Initialize source and build root directories dnl @@ -151,6 +186,17 @@ dnl echo dnl CHECK_JAVA +echo +echo --------------------------------------------- +echo Testing Disable Corba +echo --------------------------------------------- +echo + +CHECK_DISABLE_CORBA +echo "GUI_DISABLE_CORBA = "$GUI_DISABLE_CORBA + +if test "x${GUI_DISABLE_CORBA}" != "xyes" ; then + echo echo --------------------------------------------- echo testing swig @@ -158,6 +204,7 @@ echo --------------------------------------------- echo CHECK_SWIG +fi echo echo --------------------------------------------- @@ -167,6 +214,7 @@ echo ENABLE_PTHREADS +if test "x${GUI_DISABLE_CORBA}" != "xyes" ; then echo echo --------------------------------------------- echo testing omniORB @@ -190,12 +238,20 @@ echo --------------------------------------------- echo DEFAULT_ORB=omniORB + +echo +echo --------------------------------------------- +echo testing Corba +echo --------------------------------------------- +echo + CHECK_CORBA AC_SUBST_FILE(CORBA) corba=make_$ORB CORBA=adm_local/unix/$corba +fi echo echo --------------------------------------------- echo testing openGL @@ -276,6 +332,100 @@ echo CHECK_QWT +echo +echo --------------------------------------------- +echo Testing PyConsole +echo --------------------------------------------- +echo + +CHECK_PYCONSOLE +echo "DISABLE_PYCONSOLE = "$DISABLE_PYCONSOLE + +echo +echo --------------------------------------------- +echo Testing GlViewer +echo --------------------------------------------- +echo + +CHECK_GLVIEWER +echo "DISABLE_GLVIEWER = "$DISABLE_GLVIEWER + +echo +echo --------------------------------------------- +echo Testing Plot2dViewer +echo --------------------------------------------- +echo + +CHECK_PLOT2DVIEWER +echo "DISABLE_PLOT2DVIEWER = "$DISABLE_PLOT2DVIEWER + +echo +echo --------------------------------------------- +echo Testing SupervGraphViewer +echo --------------------------------------------- +echo + +CHECK_SUPERVGRAPHVIEWER +echo "DISABLE_SUPERVGRAPHVIEWER = "$DISABLE_SUPERVGRAPHVIEWER + +echo +echo --------------------------------------------- +echo Testing OCCViewer +echo --------------------------------------------- +echo + +CHECK_OCCVIEWER +echo "DISABLE_OCCVIEWER = "$DISABLE_OCCVIEWER + +echo +echo --------------------------------------------- +echo Testing VTKViewer +echo --------------------------------------------- +echo + +CHECK_VTKVIEWER +echo "DISABLE_VTKVIEWER = "$DISABLE_VTKVIEWER + +echo +echo --------------------------------------------- +echo Testing SalomeObject +echo --------------------------------------------- +echo + +CHECK_SALOMEOBJECT +echo "DISABLE_SALOMEOBJECT = "$DISABLE_SALOMEOBJECT + +if test "x${GUI_DISABLE_CORBA}" != "xyes" ; then + if test "x${DISABLE_PYCONSOLE}" == "xyes" ; then + echo "failed : for full configuration of GUI module necessary enable PyConsole !" + exit + fi + if test "x${DISABLE_GLVIEWER}" == "xyes" ; then + echo "failed : for full configuration of GUI module necessary enable GlViewer !" + exit + fi + if test "x${DISABLE_PLOT2DVIEWER}" == "xyes" ; then + echo "failed : for full configuration of GUI module necessary enable Plot2dViewer !" + exit + fi + if test "x${DISABLE_SUPERVGRAPHVIEWER}" == "xyes" ; then + echo "failed : for full configuration of GUI module necessary enable SupervGraphViewer !" + exit + fi + if test "x${DISABLE_OCCVIEWER}" == "xyes" ; then + echo "failed : for full configuration of GUI module necessary enable OCCViewer !" + exit + fi + if test "x${DISABLE_VTKVIEWER}" == "xyes" ; then + echo "failed : for full configuration of GUI module necessary enable VTKViewer !" + exit + fi + if test "x${DISABLE_SALOMEOBJECT}" == "xyes" ; then + echo "failed : for full configuration of GUI module necessary enable SalomeObject !" + exit + fi +fi + echo echo --------------------------------------------- echo Testing html generators @@ -284,13 +434,22 @@ echo CHECK_HTML_GENERATORS +if test "$GUI_DISABLE_CORBA" == "no"; then + echo + echo --------------------------------------------- + echo Testing Kernel + echo --------------------------------------------- + echo + CHECK_KERNEL +fi + echo echo --------------------------------------------- -echo Testing Kernel +echo Testing CPPUNIT only required for unit testing echo --------------------------------------------- echo -CHECK_KERNEL +CHECK_CPPUNIT echo echo --------------------------------------------- @@ -298,8 +457,18 @@ echo Summary echo --------------------------------------------- echo -echo Configure +if test "$GUI_DISABLE_CORBA" == "yes"; then + echo "Configure (without Corba)" +else + echo Configure +fi + + +if test "$GUI_DISABLE_CORBA" != "yes"; then variables="cc_ok lex_yacc_ok python_ok swig_ok threads_ok OpenGL_ok qt_ok msg2qm_ok vtk_ok hdf5_ok omniORB_ok boost_ok occ_ok sip_ok pyqt_ok qwt_ok doxygen_ok graphviz_ok Kernel_ok" +else +variables="cc_ok lex_yacc_ok python_ok threads_ok OpenGL_ok qt_ok msg2qm_ok vtk_ok hdf5_ok boost_ok occ_ok sip_ok pyqt_ok qwt_ok doxygen_ok graphviz_ok Kernel_ok" +fi for var in $variables do @@ -307,14 +476,27 @@ do eval echo \$$var done +echo "---Optional:" +variables="cppunit_ok" + +for var in $variables +do + eval toto=\$$var + if test x$toto != "x"; then + printf " %10s : " `echo \$var | sed -e "s,_ok,,"` + eval echo \$$var + fi +done + +if test "$GUI_DISABLE_CORBA" != "yes"; then echo echo "Default ORB : $DEFAULT_ORB" echo - +fi dnl generals files which could be included in every makefile AC_SUBST_FILE(COMMENCE) COMMENCE=adm_local/unix/make_commence -AC_SUBST_FILE(CONCLUDE) CONCLUDE=salome_adm/unix/make_conclude +AC_SUBST_FILE(CONCLUDE) CONCLUDE=adm_local/unix/make_conclude AC_SUBST_FILE(MODULE) MODULE=salome_adm/unix/make_module dnl les dependences @@ -329,7 +511,13 @@ else fi # make other build directories -for rep in salome_adm adm_local doc bin/salome include/salome lib/salome share/salome/resources idl +if test "$GUI_DISABLE_CORBA" == "yes"; then +dir_variables="salome_adm adm_local doc bin/salome include/salome lib/salome share/salome/resources idl" +else +dir_variables="salome_adm adm_local doc bin/salome include/salome lib/salome share/salome/resources" +fi + +for rep in $dir_variables do # if test ! -d $rep ; then # eval mkdir $rep diff --git a/idl/SALOME_Session.idl b/idl/SALOME_Session.idl index 3086194ee..f067b753a 100644 --- a/idl/SALOME_Session.idl +++ b/idl/SALOME_Session.idl @@ -105,6 +105,9 @@ module SALOME Get Active study ID */ long GetActiveStudyId(); +/*! + Restores a state of the study at theSavePoint +*/ + boolean restoreVisualState(in long theSavePoint); } ; - } ; diff --git a/src/CAM/CAM_Module.cxx b/src/CAM/CAM_Module.cxx index 885f6e05d..264054bdf 100755 --- a/src/CAM/CAM_Module.cxx +++ b/src/CAM/CAM_Module.cxx @@ -299,12 +299,13 @@ int CAM_Module::createTool( const int id, const QString& tBar, const int idx ) *\retval Return -1 if something wrong. */ int CAM_Module::createMenu( const QString& subMenu, const int menu, - const int id, const int group, const int index ) + const int id, const int group, const int index, + const bool enableEmpty ) { if ( !menuMgr() ) return -1; - return menuMgr()->insert( subMenu, menu, group, index ); + return menuMgr()->insert( subMenu, menu, group, id, index, enableEmpty ); } /*! Create menu. @@ -318,12 +319,13 @@ int CAM_Module::createMenu( const QString& subMenu, const int menu, *\retval Return -1 if something wrong. */ int CAM_Module::createMenu( const QString& subMenu, const QString& menu, - const int id, const int group, const int index ) + const int id, const int group, const int index, + const bool enableEmpty ) { if ( !menuMgr() ) return -1; - return menuMgr()->insert( subMenu, menu, group, index ); + return menuMgr()->insert( subMenu, menu, group, id, index, enableEmpty ); } @@ -572,6 +574,40 @@ int CAM_Module::registerAction( const int id, QAction* a ) return ident; } +/*! Unregister an action. + * \param id - id for action. + * \retval true if succeded, false if action is used + */ +bool CAM_Module::unregisterAction( const int id ) +{ + return unregisterAction( action( id ) ); +} + +/*! Unregister an action. + * \param a - action + * \retval true if succeded, false if action is used + */ +bool CAM_Module::unregisterAction( QAction* a ) +{ + if ( !a ) + return false; + if ( menuMgr() ) { + int id = menuMgr()->actionId( a ); + if ( id != -1 && menuMgr()->containsMenu( id, -1 ) ) + return false; + } + if ( toolMgr() ) { + int id = toolMgr()->actionId( a ); + if ( id != -1 && toolMgr()->containsAction( id ) ) + return false; + } + if ( menuMgr() ) + menuMgr()->unRegisterAction( menuMgr()->actionId( a ) ); + if ( toolMgr() ) + toolMgr()->unRegisterAction( toolMgr()->actionId( a ) ); + return true; +} + /*! Return qt action manager separator.*/ QAction* CAM_Module::separator() { diff --git a/src/CAM/CAM_Module.h b/src/CAM/CAM_Module.h index 7b525996c..8896eb23b 100755 --- a/src/CAM/CAM_Module.h +++ b/src/CAM/CAM_Module.h @@ -65,14 +65,14 @@ public: /** @name Set Menu Shown*/ //@{ - void setMenuShown( const bool ); + virtual void setMenuShown( const bool ); void setMenuShown( QAction*, const bool ); void setMenuShown( const int, const bool ); //@} /** @name Set Tool Shown*/ //@{ - void setToolShown( const bool ); + virtual void setToolShown( const bool ); void setToolShown( QAction*, const bool ); void setToolShown( const int, const bool ); //@} @@ -106,8 +106,8 @@ protected: /** @name Create menu methods.*/ //@{ - int createMenu( const QString&, const int, const int = -1, const int = -1, const int = -1 ); - int createMenu( const QString&, const QString&, const int = -1, const int = -1, const int = -1 ); + int createMenu( const QString&, const int, const int = -1, const int = -1, const int = -1, const bool = false ); + int createMenu( const QString&, const QString&, const int = -1, const int = -1, const int = -1, const bool = false ); int createMenu( const int, const int, const int = -1, const int = -1 ); int createMenu( const int, const QString&, const int = -1, const int = -1 ); int createMenu( QAction*, const int, const int = -1, const int = -1, const int = -1 ); @@ -123,6 +123,8 @@ protected: //@} int registerAction( const int, QAction* ); + bool unregisterAction( const int ); + bool unregisterAction( QAction* ); QAction* createAction( const int, const QString&, const QIconSet&, const QString&, const QString&, const int, QObject* = 0, const bool = false, QObject* = 0, const char* = 0 ); diff --git a/src/DDS/DDS_DicGroup.cxx b/src/DDS/DDS_DicGroup.cxx index ac7f4ad6b..6655e4fb7 100644 --- a/src/DDS/DDS_DicGroup.cxx +++ b/src/DDS/DDS_DicGroup.cxx @@ -76,7 +76,10 @@ void DDS_DicGroup::FillDataMap( const LDOM_Element& theComponentData, const LDOM LDOM_NodeList systemList = systems.getElementsByTagName( DDS_Dictionary::KeyWord( "UNIT_SYSTEM" ) ); for ( Standard_Integer i = 0; i < systemList.getLength(); i++ ) { - LDOM_Element aSystem = (const LDOM_Element &)systemList.item( i ); + //const LDOM_Element& aSystem = (const LDOM_Element &)systemList.item( i ); + LDOM_Node aNode = systemList.item( i ); + const LDOM_Element& anElem = (const LDOM_Element&) aNode; + LDOM_Element aSystem(anElem); TCollection_AsciiString aName = aSystem.getAttribute( DDS_Dictionary::KeyWord( "UNIT_SYSTEM_NAME" ) ); TCollection_ExtendedString aLabel = aSystem.getAttribute( DDS_Dictionary::KeyWord( "UNIT_SYSTEM_LABEL" ) ); @@ -103,7 +106,10 @@ void DDS_DicGroup::FillDataMap( const LDOM_Element& theComponentData, const LDOM for ( Standard_Integer i = 0; i < aData.getLength(); i++ ) { - LDOM_Element aQuantity = (const LDOM_Element&)aData.item( i ); + //LDOM_Element aQuantity = (const LDOM_Element&)aData.item( i ); + LDOM_Node aNode = aData.item( i ); + const LDOM_Element& anElem = (const LDOM_Element&) aNode; + LDOM_Element aQuantity(anElem); // 1. Attributes (id,label,units?,format?,required?) TCollection_AsciiString anID = aQuantity.getAttribute( DDS_Dictionary::KeyWord( "DATUM_ID" ) ); diff --git a/src/DDS/DDS_DicItem.cxx b/src/DDS/DDS_DicItem.cxx index 0c8b01c6d..d20408b4c 100644 --- a/src/DDS/DDS_DicItem.cxx +++ b/src/DDS/DDS_DicItem.cxx @@ -506,7 +506,10 @@ void DDS_DicItem::FillDataMap( TCollection_AsciiString theID, const LDOM_Element if ( aListValueID.IsIntegerValue() ) { // Read the text in the element "value" - LDOM_Text aListItemTxt = (const LDOM_Text&)aListItemValue.getFirstChild(); + //LDOM_Text aListItemTxt = (const LDOM_Text&)aListItemValue.getFirstChild(); + LDOM_Node aNode = aListItemValue.getFirstChild(); + const LDOM_Text& aText = (const LDOM_Text&) aNode; + LDOM_Text aListItemTxt(aText); if ( !aListItemTxt.isNull() ) { // adding ID and text value to sequence @@ -533,7 +536,10 @@ void DDS_DicItem::FillDataMap( TCollection_AsciiString theID, const LDOM_Element if ( !aShDescr.isNull() ) { // text is always a sub-node of element, containing it - LDOM_Text aShDescrTxt = (const LDOM_Text&)aShDescr.getFirstChild(); + //LDOM_Text aShDescrTxt = (const LDOM_Text&)aShDescr.getFirstChild(); + LDOM_Node aNode = aShDescr.getFirstChild(); + const LDOM_Text& aText = (const LDOM_Text&) aNode; + LDOM_Text aShDescrTxt(aText); if ( !aShDescrTxt.isNull() ) aShortD = aShDescrTxt.getData(); } @@ -543,7 +549,10 @@ void DDS_DicItem::FillDataMap( TCollection_AsciiString theID, const LDOM_Element if ( !aLDescr.isNull() ) { // text is always a sub-node of element, containing it - LDOM_Text aLDescrTxt = (const LDOM_Text&)aLDescr.getFirstChild(); + //LDOM_Text aLDescrTxt = (const LDOM_Text&)aLDescr.getFirstChild(); + LDOM_Node aNode = aLDescr.getFirstChild(); + const LDOM_Text& aText = (const LDOM_Text&) aNode; + LDOM_Text aLDescrTxt(aText); if ( !aLDescrTxt.isNull() ) aLongD = aLDescrTxt.getData(); } diff --git a/src/GLViewer/GLViewer_ViewFrame.cxx b/src/GLViewer/GLViewer_ViewFrame.cxx index 6600bb35f..a466d7b2f 100644 --- a/src/GLViewer/GLViewer_ViewFrame.cxx +++ b/src/GLViewer/GLViewer_ViewFrame.cxx @@ -547,3 +547,37 @@ void GLViewer_ViewFrame::wheelEvent( QWheelEvent* e ) break; } } + +/*! The method returns the visual parameters of this view as a formated string + */ +QString GLViewer_ViewFrame::getVisualParameters() +{ + QString retStr; + if ( myVP && myVP->inherits( "GLViewer_ViewPort2d" ) ) { + GLViewer_ViewPort2d* vp2d = (GLViewer_ViewPort2d*)myVP; + GLfloat xSc, ySc, xPan, yPan; + vp2d->getScale( xSc, ySc ); + vp2d->getPan( xPan, yPan ); + retStr.sprintf( "%.12e*%.12e*%.12e*%.12e", xSc, ySc, xPan, yPan ); + } + return retStr; +} + +/* The method restors visual parameters of this view from a formated string + */ +void GLViewer_ViewFrame::setVisualParameters( const QString& parameters ) +{ + QStringList paramsLst = QStringList::split( '*', parameters, true ); + if ( myVP && myVP->inherits( "GLViewer_ViewPort2d" ) && paramsLst.size() == 4) { + GLViewer_ViewPort2d* vp2d = (GLViewer_ViewPort2d*)myVP; + + GLfloat xSc, ySc, xPan, yPan; + xSc = paramsLst[0].toDouble(); + ySc = paramsLst[1].toDouble(); + xPan = paramsLst[2].toDouble(); + yPan = paramsLst[3].toDouble(); + + vp2d->getGLWidget()->setScale( xSc, ySc, 1. ); + vp2d->getGLWidget()->setPan( xPan, yPan, 0. ); + } +} diff --git a/src/GLViewer/GLViewer_ViewFrame.h b/src/GLViewer/GLViewer_ViewFrame.h index d90dfd3f5..8b9267a42 100644 --- a/src/GLViewer/GLViewer_ViewFrame.h +++ b/src/GLViewer/GLViewer_ViewFrame.h @@ -72,6 +72,9 @@ public: QSize sizeHint() const; virtual void onUpdate( int ); + + virtual QString getVisualParameters(); + virtual void setVisualParameters( const QString& parameters ); signals: void vfDrawExternal( QPainter* ); diff --git a/src/LightApp/LightApp_Application.cxx b/src/LightApp/LightApp_Application.cxx index ca93892ff..051b1c314 100644 --- a/src/LightApp/LightApp_Application.cxx +++ b/src/LightApp/LightApp_Application.cxx @@ -3,7 +3,10 @@ // Author: Natalia Donis // Copyright (C) CEA 2005 -#include "PythonConsole_PyInterp.h" // WARNING! This include must be the first! +#ifndef DISABLE_PYCONSOLE + #include "PythonConsole_PyInterp.h" // WARNING! This include must be the first! + #include +#endif #include "LightApp_Application.h" #include "LightApp_WidgetContainer.h" @@ -17,10 +20,7 @@ #include "LightApp_OBFilter.h" -#include "LightApp_GLSelector.h" #include "LightApp_OBSelector.h" -#include "LightApp_OCCSelector.h" -#include "LightApp_VTKSelector.h" #include "LightApp_SelectionMgr.h" #include @@ -42,25 +42,50 @@ #include #include #include -#include -#include -#include +#ifndef DISABLE_GLVIEWER + #include + #include + #include "LightApp_GLSelector.h" +#endif -#include -#include -#include +#ifndef DISABLE_PLOT2DVIEWER + #include + #include +#ifndef DISABLE_SALOMEOBJECT + #include +#else + #include +#endif +#endif -#include -#include +#ifndef DISABLE_OCCVIEWER + #include +#ifndef DISABLE_SALOMEOBJECT + #include +#else + #include +#endif + #include "LightApp_OCCSelector.h" +#endif -#include -#include -#include +#ifndef DISABLE_VTKVIEWER +#ifndef DISABLE_SALOMEOBJECT + #include + #include + #include "LightApp_VTKSelector.h" +#else + #include + #include +#endif + #include +#endif -#include -#include -#include +#ifndef DISABLE_SUPERVGRAPHVIEWER + #include + #include + #include +#endif #include @@ -81,8 +106,10 @@ #define FIRST_HELP_ID 1000000 -#include "SALOME_InteractiveObject.hxx" -#include "SALOME_ListIO.hxx" +#ifndef DISABLE_SALOMEOBJECT + #include "SALOME_InteractiveObject.hxx" + #include "SALOME_ListIO.hxx" +#endif static const char* imageEmptyIcon[] = { "20 20 1 1", @@ -108,6 +135,13 @@ static const char* imageEmptyIcon[] = { "....................", "...................."}; +int LightApp_Application::lastStudyId = 0; + +int LightApp_Application::studyId() +{ + return LightApp_Application::lastStudyId; +} + /*!Create new instance of LightApp_Application.*/ extern "C" LIGHTAPP_EXPORT SUIT_Application* createApplication() { @@ -146,7 +180,9 @@ myPrefs( 0 ) mySelMgr = new LightApp_SelectionMgr( this ); - myAccel = new SUIT_Accel( desktop() ); + myAccel = SUIT_Accel::getAccel(); + +#ifndef DISABLE_OCCVIEWER myAccel->setActionKey( SUIT_Accel::PanLeft, CTRL+Key_Left, OCCViewer_Viewer::Type() ); myAccel->setActionKey( SUIT_Accel::PanRight, CTRL+Key_Right, OCCViewer_Viewer::Type() ); myAccel->setActionKey( SUIT_Accel::PanUp, CTRL+Key_Up, OCCViewer_Viewer::Type() ); @@ -158,6 +194,8 @@ myPrefs( 0 ) myAccel->setActionKey( SUIT_Accel::RotateRight, ALT+Key_Right, OCCViewer_Viewer::Type() ); myAccel->setActionKey( SUIT_Accel::RotateUp, ALT+Key_Up, OCCViewer_Viewer::Type() ); myAccel->setActionKey( SUIT_Accel::RotateDown, ALT+Key_Down, OCCViewer_Viewer::Type() ); +#endif +#ifndef DISABLE_VTKVIEWER myAccel->setActionKey( SUIT_Accel::PanLeft, CTRL+Key_Left, VTKViewer_Viewer::Type() ); myAccel->setActionKey( SUIT_Accel::PanRight, CTRL+Key_Right, VTKViewer_Viewer::Type() ); myAccel->setActionKey( SUIT_Accel::PanUp, CTRL+Key_Up, VTKViewer_Viewer::Type() ); @@ -169,6 +207,7 @@ myPrefs( 0 ) myAccel->setActionKey( SUIT_Accel::RotateRight, ALT+Key_Right, VTKViewer_Viewer::Type() ); myAccel->setActionKey( SUIT_Accel::RotateUp, ALT+Key_Up, VTKViewer_Viewer::Type() ); myAccel->setActionKey( SUIT_Accel::RotateDown, ALT+Key_Down, VTKViewer_Viewer::Type() ); +#endif connect( mySelMgr, SIGNAL( selectionChanged() ), this, SLOT( onSelection() ) ); } @@ -181,14 +220,6 @@ myPrefs( 0 ) */ LightApp_Application::~LightApp_Application() { - saveWindowsGeometry(); - - if ( resourceMgr() ) - { - if ( desktop() ) - desktop()->saveGeometry( resourceMgr(), "desktop" ); - resourceMgr()->save(); - } delete mySelMgr; } @@ -320,6 +351,19 @@ LightApp_SelectionMgr* LightApp_Application::selectionMgr() const return mySelMgr; } +/*!Creat action "New window" for certain type of viewer:*/ +void LightApp_Application::createActionForViewer( const int id, + const int parentId, + const QString& suffix, + const int accel ) +{ + QAction* a = createAction( id, tr( QString( "NEW_WINDOW_%1" ).arg( suffix ) ), QIconSet(), + tr( QString( "NEW_WINDOW_%1" ).arg( suffix ) ), + tr( QString( "NEW_WINDOW_%1" ).arg( suffix ) ), + accel, desktop(), false, this, SLOT( onNewWindow() ) ); + createMenu( a, parentId, -1 ); +} + /*!Create actions:*/ void LightApp_Application::createActions() { @@ -434,7 +478,7 @@ void LightApp_Application::createActions() for ( it = modList.begin(); it != modList.end(); ++it ) { - if ( (*it).isEmpty() ) + if ( !isLibExists( *it ) ) continue; QString iconName; @@ -459,24 +503,24 @@ void LightApp_Application::createActions() SUIT_Tools::simplifySeparators( modTBar ); // New window - int windowMenu = createMenu( tr( "MEN_DESK_WINDOW" ), -1, 100 ); + int windowMenu = createMenu( tr( "MEN_DESK_WINDOW" ), -1, MenuWindowId, 100 ); int newWinMenu = createMenu( tr( "MEN_DESK_NEWWINDOW" ), windowMenu, -1, 0 ); createMenu( separator(), windowMenu, -1, 1 ); - QMap accelMap; - accelMap[NewGLViewId] = ALT+Key_G; - accelMap[NewPlot2dId] = ALT+Key_P; - accelMap[NewOCCViewId] = ALT+Key_O; - accelMap[NewVTKViewId] = ALT+Key_K; - for ( id = NewGLViewId; id <= NewVTKViewId; id++ ) - { - QAction* a = createAction( id, tr( QString( "NEW_WINDOW_%1" ).arg( id - NewGLViewId ) ), QIconSet(), - tr( QString( "NEW_WINDOW_%1" ).arg( id - NewGLViewId ) ), - tr( QString( "NEW_WINDOW_%1" ).arg( id - NewGLViewId ) ), - accelMap.contains( id ) ? accelMap[id] : 0, desk, false, this, SLOT( onNewWindow() ) ); - createMenu( a, newWinMenu, -1 ); - } +#ifndef DISABLE_GLVIEWER + createActionForViewer( NewGLViewId, newWinMenu, QString::number( 0 ), ALT+Key_G ); +#endif +#ifndef DISABLE_PLOT2DVIEWER + createActionForViewer( NewPlot2dId, newWinMenu, QString::number( 1 ), ALT+Key_P ); +#endif +#ifndef DISABLE_OCCVIEWER + createActionForViewer( NewOCCViewId, newWinMenu, QString::number( 2 ), ALT+Key_O ); +#endif +#ifndef DISABLE_VTKVIEWER + createActionForViewer( NewVTKViewId, newWinMenu, QString::number( 3 ), ALT+Key_K ); +#endif + createAction( RenameId, tr( "TOT_RENAME" ), QIconSet(), tr( "MEN_DESK_RENAME" ), tr( "PRP_RENAME" ), SHIFT+Key_R, desk, false, this, SLOT( onRenameWindow() ) ); @@ -560,18 +604,26 @@ void LightApp_Application::onNewWindow() int id = actionId( (QAction*)obj ); switch ( id ) { +#ifndef DISABLE_GLVIEWER case NewGLViewId: type = GLViewer_Viewer::Type(); break; +#endif +#ifndef DISABLE_PLOT2DVIEWER case NewPlot2dId: type = Plot2d_Viewer::Type(); break; +#endif +#ifndef DISABLE_OCCVIEWER case NewOCCViewId: type = OCCViewer_Viewer::Type(); break; +#endif +#ifndef DISABLE_VTKVIEWER case NewVTKViewId: type = VTKViewer_Viewer::Type(); break; +#endif } if ( !type.isEmpty() ) @@ -737,13 +789,31 @@ void LightApp_Application::setActiveStudy( SUIT_Study* study ) void LightApp_Application::updateCommandsStatus() { CAM_Application::updateCommandsStatus(); + QAction* a = 0; - for ( int id = NewGLViewId; id <= NewVTKViewId; id++ ) - { - QAction* a = action( id ); - if ( a ) - a->setEnabled( activeStudy() ); - } +#ifndef DISABLE_GLVIEWER + a = action( NewGLViewId ); + if( a ) + a->setEnabled( activeStudy() ); +#endif + +#ifndef DISABLE_PLOT2DVIEWER + a = action( NewPlot2dId ); + if( a ) + a->setEnabled( activeStudy() ); +#endif + +#ifndef DISABLE_OCCVIEWER + a = action( NewOCCViewId ); + if( a ) + a->setEnabled( activeStudy() ); +#endif + +#ifndef DISABLE_VTKVIEWER + a = action( NewVTKViewId ); + if( a ) + a->setEnabled( activeStudy() ); +#endif } // Helps to execute command @@ -889,6 +959,7 @@ void LightApp_Application::addWindow( QWidget* wid, const int flag, const int st } QFont f; +#ifndef DISABLE_PYCONSOLE if( wid->inherits( "PythonConsole" ) ) { if( resourceMgr()->hasValue( "PyConsole", "font" ) ) @@ -900,6 +971,7 @@ void LightApp_Application::addWindow( QWidget* wid, const int flag, const int st } } else +#endif f = wid->font(); myWindows[flag]->insert( sId, wid ); @@ -994,6 +1066,7 @@ LogWindow* LightApp_Application::logWindow() return lw; } +#ifndef DISABLE_PYCONSOLE /*!Get "PythonConsole"*/ PythonConsole* LightApp_Application::pythonConsole() { @@ -1003,6 +1076,7 @@ PythonConsole* LightApp_Application::pythonConsole() console = (PythonConsole*)wid; return console; } +#endif /*!Update obect browser*/ void LightApp_Application::updateObjectBrowser( const bool updateModels ) @@ -1062,15 +1136,23 @@ SUIT_ViewManager* LightApp_Application::createViewManager( const QString& vmType SUIT_ResourceMgr* resMgr = resourceMgr(); SUIT_ViewManager* viewMgr = 0; +#ifndef DISABLE_GLVIEWER if( vmType == GLViewer_Viewer::Type() ) { viewMgr = new GLViewer_ViewManager( activeStudy(), desktop() ); new LightApp_GLSelector( (GLViewer_Viewer2d*)viewMgr->getViewModel(), mySelMgr ); } - else if( vmType == Plot2d_Viewer::Type() ) +#endif +#ifndef DISABLE_PLOT2DVIEWER + if( vmType == Plot2d_Viewer::Type() ) { viewMgr = new Plot2d_ViewManager( activeStudy(), desktop() ); - SPlot2d_Viewer* vm = new SPlot2d_Viewer(); + Plot2d_Viewer* vm; +#ifndef DISABLE_SALOMEOBJECT + vm = new SPlot2d_Viewer(); +#else + vm = new Plot2d_Viewer(); +#endif viewMgr->setViewModel( vm );// custom view model, which extends SALOME_View interface Plot2d_ViewWindow* wnd = dynamic_cast( viewMgr->getActiveView() ); if( wnd ) @@ -1079,7 +1161,9 @@ SUIT_ViewManager* LightApp_Application::createViewManager( const QString& vmType frame->setBackgroundColor( resMgr->colorValue( "Plot2d", "Background", frame->backgroundColor() ) ); } } - else if( vmType == SUPERVGraph_Viewer::Type() ) +#endif +#ifndef DISABLE_SUPERVGRAPHVIEWER + if( vmType == SUPERVGraph_Viewer::Type() ) { viewMgr = new SUPERVGraph_ViewManager( activeStudy(), desktop() ); SUPERVGraph_Viewer* vm = new SUPERVGraph_Viewer(); @@ -1087,10 +1171,17 @@ SUIT_ViewManager* LightApp_Application::createViewManager( const QString& vmType if( view ) view->setBackgroundColor( resMgr->colorValue( "SUPERVGraph", "Background", view->backgroundColor() ) ); } - else if( vmType == OCCViewer_Viewer::Type() ) +#endif +#ifndef DISABLE_OCCVIEWER + if( vmType == OCCViewer_Viewer::Type() ) { viewMgr = new OCCViewer_ViewManager( activeStudy(), desktop() ); - SOCC_Viewer* vm = new SOCC_Viewer(); + OCCViewer_Viewer* vm; +#ifndef DISABLE_SALOMEOBJECT + vm = new SOCC_Viewer(); +#else + vm = new OCCViewer_Viewer(); +#endif vm->setBackgroundColor( resMgr->colorValue( "OCCViewer", "background", vm->backgroundColor() ) ); vm->setTrihedronSize( resMgr->integerValue( "OCCViewer", "trihedron_size", vm->trihedronSize() ) ); int u( 1 ), v( 1 ); @@ -1101,17 +1192,32 @@ SUIT_ViewManager* LightApp_Application::createViewManager( const QString& vmType viewMgr->setViewModel( vm );// custom view model, which extends SALOME_View interface new LightApp_OCCSelector( (OCCViewer_Viewer*)viewMgr->getViewModel(), mySelMgr ); } - else if ( vmType == SVTK_Viewer::Type() ) +#endif +#ifndef DISABLE_VTKVIEWER +#ifndef DISABLE_SALOMEOBJECT + if ( vmType == SVTK_Viewer::Type() ) +#else + if ( vmType == VTKViewer_Viewer::Type() ) +#endif { +#ifndef DISABLE_SALOMEOBJECT viewMgr = new SVTK_ViewManager( activeStudy(), desktop() ); SVTK_Viewer* vm = dynamic_cast( viewMgr->getViewModel() ); if( vm ) { vm->setBackgroundColor( resMgr->colorValue( "VTKViewer", "background", vm->backgroundColor() ) ); - vm->setTrihedronSize( resMgr->integerValue( "VTKViewer", "trihedron_size", vm->trihedronSize() ) ); + vm->setTrihedronSize( resMgr->integerValue( "VTKViewer", "trihedron_size", vm->trihedronSize() ), + resMgr->booleanValue( "VTKViewer", "relative_size", vm->trihedronRelative() ) ); new LightApp_VTKSelector( vm, mySelMgr ); } +#else + viewMgr = new VTKViewer_ViewManager( activeStudy(), desktop() ); + VTKViewer_Viewer* vm = dynamic_cast( viewMgr->getViewModel() ); + if ( vm ) + vm->setBackgroundColor( resMgr->colorValue( "VTKViewer", "background", vm->backgroundColor() ) ); +#endif } +#endif if ( !viewMgr ) return 0; @@ -1209,9 +1315,9 @@ void LightApp_Application::onDesktopActivated() */ QString LightApp_Application::getFileFilter() const { - return "(*.bin)"; - // HDF persistence not yet completed - to be uncommented later - //return "(*.hdf)"; + //return "(*.bin)"; + // HDF persistence + return "(*.hdf)"; } /*! Gets file name*/ @@ -1310,6 +1416,8 @@ void LightApp_Application::updateActions() //======================================================================= SUIT_Study* LightApp_Application::createNewStudy() { + LightApp_Application::lastStudyId++; + LightApp_Study* aStudy = new LightApp_Study( this ); // Set up processing of major study-related events @@ -1329,7 +1437,7 @@ QWidget* LightApp_Application::createWindow( const int flag ) { OB_Browser* ob = new OB_Browser( desktop() ); ob->setAutoUpdate( true ); - ob->setAutoOpenLevel( 1 ); + //ob->setAutoOpenLevel( 1 ); // commented by ASV as a fix to bug IPAL10107 ob->setCaption( tr( "OBJECT_BROWSER" ) ); OB_ListView* ob_list = dynamic_cast( const_cast( ob->listView() ) ); @@ -1346,6 +1454,7 @@ QWidget* LightApp_Application::createWindow( const int flag ) ob->connectPopupRequest( this, SLOT( onConnectPopupRequest( SUIT_PopupClient*, QContextMenuEvent* ) ) ); } +#ifndef DISABLE_PYCONSOLE else if ( flag == WT_PyConsole ) { PythonConsole* pyCons = new PythonConsole( desktop() ); @@ -1353,6 +1462,7 @@ QWidget* LightApp_Application::createWindow( const int flag ) wid = pyCons; // pyCons->connectPopupRequest( this, SLOT( onConnectPopupRequest( SUIT_PopupClient*, QContextMenuEvent* ) ) ); } +#endif else if ( flag == WT_LogWindow ) { LogWindow* logWin = new LogWindow( desktop() ); @@ -1369,7 +1479,9 @@ QWidget* LightApp_Application::createWindow( const int flag ) void LightApp_Application::defaultWindows( QMap& aMap ) const { aMap.insert( WT_ObjectBrowser, Qt::DockLeft ); +#ifndef DISABLE_PYCONSOLE aMap.insert( WT_PyConsole, Qt::DockBottom ); +#endif // aMap.insert( WT_LogWindow, Qt::DockBottom ); } @@ -1621,6 +1733,7 @@ void LightApp_Application::preferencesChanged( const QString& sec, const QString if ( !resMgr ) return; +#ifndef DISABLE_OCCVIEWER if ( sec == QString( "OCCViewer" ) && param == QString( "trihedron_size" ) ) { int sz = resMgr->integerValue( sec, param, -1 ); @@ -1637,11 +1750,15 @@ void LightApp_Application::preferencesChanged( const QString& sec, const QString occVM->getAISContext()->UpdateCurrentViewer(); } } +#endif +#ifndef DISABLE_VTKVIEWER if ( sec == QString( "VTKViewer" ) && (param == QString( "trihedron_size" ) || param == QString( "relative_size" )) ) { int sz = resMgr->integerValue( "VTKViewer", "trihedron_size", -1 ); + bool isRelative = resMgr->booleanValue( "VTKViewer", "relative_size", true ); QPtrList lst; +#ifndef DISABLE_SALOMEOBJECT viewManagers( SVTK_Viewer::Type(), lst ); for ( QPtrListIterator it( lst ); it.current() && sz >= 0; ++it ) { @@ -1652,12 +1769,15 @@ void LightApp_Application::preferencesChanged( const QString& sec, const QString SVTK_Viewer* vtkVM = dynamic_cast( vm ); if( vtkVM ) { - vtkVM->setTrihedronSize( sz ); + vtkVM->setTrihedronSize( sz, isRelative ); vtkVM->Repaint(); } } +#endif } +#endif +#ifndef DISABLE_OCCVIEWER if ( sec == QString( "OCCViewer" ) && ( param == QString( "iso_number_u" ) || param == QString( "iso_number_v" ) ) ) { QPtrList lst; @@ -1671,6 +1791,7 @@ void LightApp_Application::preferencesChanged( const QString& sec, const QString mgr->getOCCViewer()->setIsos( u, v ); } } +#endif if( sec=="ObjectBrowser" ) { @@ -1694,12 +1815,27 @@ void LightApp_Application::preferencesChanged( const QString& sec, const QString updateWindows(); } +#ifndef DISABLE_PYCONSOLE if( sec=="PyConsole" ) { if( param=="font" ) if( pythonConsole() ) pythonConsole()->setFont( resMgr->fontValue( "PyConsole", "font" ) ); } +#endif +} + +/*!Save preferences */ +void LightApp_Application::savePreferences() +{ + saveWindowsGeometry(); + + if ( resourceMgr() ) + { + if ( desktop() ) + desktop()->saveGeometry( resourceMgr(), "desktop" ); + resourceMgr()->save(); + } } /*!Update desktop title.*/ @@ -1709,6 +1845,11 @@ void LightApp_Application::updateDesktopTitle() { if ( !aVer.isEmpty() ) aTitle += QString( " " ) + aVer; + if ( activeStudy() ) { + QString sName = SUIT_Tools::file( activeStudy()->studyName().stripWhiteSpace(), false ); + aTitle += QString( " - [%1]" ).arg( sName ); + } + desktop()->setCaption( aTitle ); } @@ -1767,11 +1908,15 @@ void LightApp_Application::updateWindows() QMap winMap; currentWindows( winMap ); - for ( QMap::ConstIterator it = winMap.begin(); it != winMap.end(); ++it ) - getWindow( it.key() ); + if ( activeStudy() ) { + for ( QMap::ConstIterator it = winMap.begin(); it != winMap.end(); ++it ) + getWindow( it.key() ); - loadWindowsGeometry(); + loadWindowsGeometry(); + } + // setWindowShown should be done even if no study is active (open). in this case all open windows + // will be hidden, which is neccessary in this case. for ( WindowMap::ConstIterator itr = myWindows.begin(); itr != myWindows.end(); ++itr ) setWindowShown( itr.key(), !itr.data()->isEmpty() && winMap.contains( itr.key() ) ); } @@ -1955,3 +2100,41 @@ void LightApp_Application::onRenameWindow() if( ok && !name.isEmpty() ) w->setCaption( name ); } + +bool LightApp_Application::isLibExists( const QString& moduleTitle ) const +{ + if( moduleTitle.isEmpty() ) + return false; + + QString lib = moduleLibrary( moduleTitle ); + QStringList paths; +#ifdef WIN32 + paths = QStringList::split( ";", ::getenv( "PATH" ) ); +#else + paths = QStringList::split( ":", ::getenv( "LD_LIBRARY_PATH" ) ); +#endif + + QStringList::const_iterator anIt = paths.begin(), aLast = paths.end(); + for( ; anIt!=aLast; anIt++ ) + { + QFileInfo inf( Qtx::addSlash( *anIt ) + lib ); + if( inf.exists() ) + return true; + } + return false; +} + +/*! default name for an active study */ +void LightApp_Application::setDefaultStudyName( const QString& theName ) +{ + QStringList anInfoList; + modules( anInfoList, false ); + + LightApp_Study* aStudy = (LightApp_Study*)activeStudy(); + if( anInfoList.count() == 1 && // to avoid a conflict between different modules + !aStudy->isSaved() ) + { + aStudy->setStudyName( theName ); + updateDesktopTitle(); + } +} diff --git a/src/LightApp/LightApp_Application.h b/src/LightApp/LightApp_Application.h index 14d2e4c23..c435188a4 100644 --- a/src/LightApp/LightApp_Application.h +++ b/src/LightApp/LightApp_Application.h @@ -15,7 +15,9 @@ class LogWindow; class OB_Browser; -class PythonConsole; +#ifndef DISABLE_PYCONSOLE + class PythonConsole; +#endif class STD_Application; class LightApp_WidgetContainer; class LightApp_Preferences; @@ -42,10 +44,35 @@ class LIGHTAPP_EXPORT LightApp_Application : public CAM_Application Q_OBJECT public: - typedef enum { WT_ObjectBrowser, WT_PyConsole, WT_LogWindow, WT_User } WindowTypes; + typedef enum { WT_ObjectBrowser, +#ifndef DISABLE_PYCONSOLE + WT_PyConsole, +#endif + WT_LogWindow, + WT_User } + WindowTypes; + + enum { MenuWindowId = 6 }; + + enum { RenameId = CAM_Application::UserID, + +#ifndef DISABLE_GLVIEWER + NewGLViewId , +#endif + +#ifndef DISABLE_PLOT2DVIEWER + NewPlot2dId, +#endif - enum { NewGLViewId = CAM_Application::UserID, NewPlot2dId, NewOCCViewId, NewVTKViewId, - PreferencesId, MRUId, RenameId, UserID }; +#ifndef DISABLE_OCCVIEWER + NewOCCViewId, +#endif + +#ifndef DISABLE_VTKVIEWER + NewVTKViewId, +#endif + + PreferencesId, MRUId, UserID }; public: LightApp_Application(); virtual ~LightApp_Application(); @@ -62,7 +89,9 @@ public: LogWindow* logWindow(); OB_Browser* objectBrowser(); +#ifndef DISABLE_PYCONSOLE PythonConsole* pythonConsole(); +#endif virtual void updateObjectBrowser( const bool = true ); @@ -96,6 +125,10 @@ public: SUIT_Accel* accel() const; + void setDefaultStudyName( const QString& theName ); + + static int studyId(); + signals: void studyOpened(); void studySaved(); @@ -111,6 +144,10 @@ public slots: protected: virtual void createActions(); + virtual void createActionForViewer( const int id, + const int parentId, + const QString& suffix, + const int accel ); virtual SUIT_Study* createNewStudy(); virtual QWidget* createWindow( const int ); virtual void defaultWindows( QMap& ) const; @@ -128,6 +165,7 @@ protected: LightApp_Preferences* preferences( const bool ) const; virtual void createPreferences( LightApp_Preferences* ); virtual void preferencesChanged( const QString&, const QString& ); + virtual void savePreferences(); virtual void updateDesktopTitle(); protected slots: @@ -169,6 +207,7 @@ protected: void moduleIconNames( QMap& ) const; void activateWindows(); + bool isLibExists( const QString& ) const; protected: typedef QMap ActionMap; @@ -183,6 +222,8 @@ protected: SUIT_Accel* myAccel; static LightApp_Preferences* _prefs_; + + static int lastStudyId; }; #ifdef WIN32 diff --git a/src/LightApp/LightApp_DataOwner.cxx b/src/LightApp/LightApp_DataOwner.cxx index add34d91f..62d0977d1 100644 --- a/src/LightApp/LightApp_DataOwner.cxx +++ b/src/LightApp/LightApp_DataOwner.cxx @@ -37,6 +37,7 @@ LightApp_DataOwner { } +#ifndef DISABLE_SALOMEOBJECT /*!Constructor. Initialize by \a SALOME_InteractiveObject.*/ LightApp_DataOwner ::LightApp_DataOwner( const Handle(SALOME_InteractiveObject)& theIO ): @@ -44,6 +45,7 @@ LightApp_DataOwner myIO(theIO) { } +#endif /*!Destructor. Do nothing.*/ LightApp_DataOwner @@ -61,6 +63,12 @@ LightApp_DataOwner return other && entry() == other->entry(); } +bool LightApp_DataOwner::operator<( const SUIT_DataOwner& obj ) const +{ + const LightApp_DataOwner* other = dynamic_cast( &obj ); + return entry() < other->entry(); +} + /*!Gets entry.*/ QString LightApp_DataOwner @@ -69,6 +77,7 @@ LightApp_DataOwner return myEntry; } +#ifndef DISABLE_SALOMEOBJECT /*!Gets SALOME_InteractiveObject.*/ const Handle(SALOME_InteractiveObject)& LightApp_DataOwner @@ -76,3 +85,4 @@ LightApp_DataOwner { return myIO; } +#endif diff --git a/src/LightApp/LightApp_DataOwner.h b/src/LightApp/LightApp_DataOwner.h index d76e6d411..849840bab 100644 --- a/src/LightApp/LightApp_DataOwner.h +++ b/src/LightApp/LightApp_DataOwner.h @@ -22,7 +22,10 @@ #include "LightApp.h" #include "SUIT_DataOwner.h" -#include "SALOME_InteractiveObject.hxx" + +#ifndef DISABLE_SALOMEOBJECT + #include "SALOME_InteractiveObject.hxx" +#endif /*! This class provide data owner objects. @@ -30,17 +33,25 @@ class LIGHTAPP_EXPORT LightApp_DataOwner : public SUIT_DataOwner { public: +#ifndef DISABLE_SALOMEOBJECT LightApp_DataOwner( const Handle(SALOME_InteractiveObject)& theIO ); +#endif LightApp_DataOwner( const QString& ); virtual ~LightApp_DataOwner(); virtual bool isEqual( const SUIT_DataOwner& ) const; + virtual bool operator<( const SUIT_DataOwner& ) const; + +#ifndef DISABLE_SALOMEOBJECT const Handle(SALOME_InteractiveObject)& IO() const; +#endif QString entry() const; private: QString myEntry; +#ifndef DISABLE_SALOMEOBJECT Handle(SALOME_InteractiveObject) myIO; +#endif }; typedef SMART(LightApp_DataOwner) LightApp_DataOwnerPtr; diff --git a/src/LightApp/LightApp_Displayer.cxx b/src/LightApp/LightApp_Displayer.cxx index 65ce0fa3c..f06c8c10b 100644 --- a/src/LightApp/LightApp_Displayer.cxx +++ b/src/LightApp/LightApp_Displayer.cxx @@ -23,8 +23,6 @@ #include -#include - #include #include #include @@ -32,6 +30,9 @@ #include #include +#ifndef DISABLE_SALOMEOBJECT + #include "SALOME_InteractiveObject.hxx" +#endif LightApp_Displayer::LightApp_Displayer() { @@ -122,14 +123,16 @@ void LightApp_Displayer::EraseAll( const bool forced, const bool updateViewer, S bool LightApp_Displayer::IsDisplayed( const QString& entry, SALOME_View* theViewFrame ) const { SALOME_View* vf = theViewFrame ? theViewFrame : GetActiveView(); + bool res = false; if( vf ) { +#ifndef DISABLE_SALOMEOBJECT Handle( SALOME_InteractiveObject ) temp = new SALOME_InteractiveObject(); temp->setEntry( entry.latin1() ); - return vf->isVisible( temp ); + res = vf->isVisible( temp ); +#endif } - else - return false; + return res; } void LightApp_Displayer::UpdateViewer() const diff --git a/src/LightApp/LightApp_GLSelector.cxx b/src/LightApp/LightApp_GLSelector.cxx index 7913b4edf..c9415eb41 100644 --- a/src/LightApp/LightApp_GLSelector.cxx +++ b/src/LightApp/LightApp_GLSelector.cxx @@ -20,8 +20,6 @@ #include "LightApp_DataOwner.h" -#include - #include /*!Constructor. Initialize by GLViewer_Viewer2d and SUIT_SelectionMgr.*/ @@ -66,7 +64,7 @@ void LightApp_GLSelector::getSelection( SUIT_DataOwnerPtrList& aList ) const GLViewer_Object* obj = cont->SelectedObject(); if ( obj ) { - SALOME_GLOwner* owner = dynamic_cast< SALOME_GLOwner* >( obj->owner() ); + LightApp_GLOwner* owner = dynamic_cast< LightApp_GLOwner* >( obj->owner() ); if( owner ) aList.append( SUIT_DataOwnerPtr( new LightApp_DataOwner( owner->entry() ) ) ); } @@ -90,7 +88,7 @@ void LightApp_GLSelector::setSelection( const SUIT_DataOwnerPtrList& aList ) GLViewer_Object* obj = *it; if ( obj && obj->getVisible() ) { - SALOME_GLOwner* owner = dynamic_cast< SALOME_GLOwner* >( obj->owner() ); + LightApp_GLOwner* owner = dynamic_cast< LightApp_GLOwner* >( obj->owner() ); if ( owner ) aDisplayed.insert( owner->entry(), obj ); } @@ -115,3 +113,24 @@ void LightApp_GLSelector::setSelection( const SUIT_DataOwnerPtrList& aList ) if ( Nb > 0 ) myViewer->updateAll(); } + + +LightApp_GLOwner::LightApp_GLOwner( const char* entry ) +: GLViewer_Owner() +{ + setEntry( entry ); +} + +LightApp_GLOwner::~LightApp_GLOwner() +{ +} + +const char* LightApp_GLOwner::entry() const +{ + return myEntry.c_str(); +} + +void LightApp_GLOwner::setEntry( const char* entry ) +{ + myEntry = entry; +} diff --git a/src/LightApp/LightApp_GLSelector.h b/src/LightApp/LightApp_GLSelector.h index 069669a87..f58bb761a 100644 --- a/src/LightApp/LightApp_GLSelector.h +++ b/src/LightApp/LightApp_GLSelector.h @@ -25,6 +25,9 @@ #include +#include +#include + class LIGHTAPP_EXPORT LightApp_GLSelector : public SUIT_Selector { Q_OBJECT @@ -48,4 +51,21 @@ private: GLViewer_Viewer2d* myViewer; }; + +/*! + This class provide data owner objects for GLViewer. +*/ +class LIGHTAPP_EXPORT LightApp_GLOwner : public GLViewer_Owner +{ +public: + LightApp_GLOwner( const char* ); + ~LightApp_GLOwner(); + + const char* entry() const; + void setEntry( const char* ); + +private: + std::string myEntry; +}; + #endif diff --git a/src/LightApp/LightApp_HDFDriver.cxx b/src/LightApp/LightApp_HDFDriver.cxx new file mode 100644 index 000000000..bf003ae44 --- /dev/null +++ b/src/LightApp/LightApp_HDFDriver.cxx @@ -0,0 +1,347 @@ +// Copyright (C) 2005 OPEN CASCADE, CEA/DEN, EDF R&D, PRINCIPIA R&D +// +// 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/ +// +#include "LightApp_HDFDriver.h" + +#include "HDFexplorer.hxx" +#include "HDFOI.hxx" + +// OCCT Includes +#include + +/*! Constructor.*/ +LightApp_HDFDriver::LightApp_HDFDriver() +{ +} + +/*! Destructor.*/ +LightApp_HDFDriver::~LightApp_HDFDriver() +{ +} + +using namespace std; + +//================================================================ +// Function : SaveDatasInFile +/*! Purpose : save in file 'theFileName' datas from this driver*/ +//================================================================ +bool LightApp_HDFDriver::SaveDatasInFile( const char* theFileName, bool isMultiFile ) +{ + bool isASCII = false; + bool isError = false; + + HDFfile *hdf_file = 0; + HDFgroup *hdf_group_datacomponent = 0; + HDFgroup *hdf_group_study_structure = 0; + HDFgroup *hdf_sco_group = 0; + HDFgroup *hdf_sco_group2 = 0; + HDFdataset *hdf_dataset = 0; + hdf_size aHDFSize[1]; + + try { + hdf_file = new HDFfile ((char*)theFileName); + hdf_file->CreateOnDisk(); + + //----------------------------------------------------------------------- + // 1 - Create a groupe for each SComponent and Update the PersistanceRef + //----------------------------------------------------------------------- + hdf_group_datacomponent = new HDFgroup ("DATACOMPONENT", hdf_file); + hdf_group_datacomponent->CreateOnDisk(); + + std::map mapNameEntry; + + int tag = 1; + std::map::const_iterator it; + for (it = myMap.begin(); it != myMap.end(); ++it, ++tag) { + std::string aName (it->first); + char* aModuleName = const_cast(aName.c_str()); + unsigned char* aBuffer; + long aBufferSize; + PutFilesToStream(aName, aBuffer, aBufferSize, isMultiFile); + + //Handle(SALOMEDSImpl_SComponent) sco = itcomponent.Value(); + //TCollection_AsciiString scoid = sco->GetID(); + //hdf_sco_group = new HDFgroup(scoid.ToCString(), hdf_group_datacomponent); + + TCollection_AsciiString entry ("0:1:"); + entry += TCollection_AsciiString(tag); + mapNameEntry[aModuleName] = entry.ToCString(); + + //hdf_sco_group = new HDFgroup (aModuleName, hdf_group_datacomponent); + hdf_sco_group = new HDFgroup (entry.ToCString(), hdf_group_datacomponent); + hdf_sco_group->CreateOnDisk(); + + aHDFSize[0] = aBufferSize; + + hdf_dataset = new HDFdataset ("FILE_STREAM", hdf_sco_group, HDF_STRING, aHDFSize, 1); + hdf_dataset->CreateOnDisk(); + hdf_dataset->WriteOnDisk(aBuffer); //Save the stream in the HDF file + hdf_dataset->CloseOnDisk(); + hdf_dataset = 0; //will be deleted by hdf_sco_group destructor + + // store multifile state + aHDFSize[0] = 2; + hdf_dataset = new HDFdataset("MULTIFILE_STATE", hdf_sco_group, HDF_STRING, aHDFSize, 1); + hdf_dataset->CreateOnDisk(); + hdf_dataset->WriteOnDisk((void*)(isMultiFile ? "M" : "S")); // save: multi or single + hdf_dataset->CloseOnDisk(); + hdf_dataset = 0; //will be deleted by hdf_sco_group destructor + + // store ASCII state + aHDFSize[0] = 2; + hdf_dataset = new HDFdataset("ASCII_STATE", hdf_sco_group, HDF_STRING, aHDFSize, 1); + hdf_dataset->CreateOnDisk(); + hdf_dataset->WriteOnDisk((void*)(isASCII ? "A" : "B")); // save: ASCII or BINARY + hdf_dataset->CloseOnDisk(); + hdf_dataset = 0; //will be deleted by hdf_sco_group destructor + + hdf_sco_group->CloseOnDisk(); + hdf_sco_group = 0; // will be deleted by hdf_group_datacomponent destructor + + delete [] aBuffer; + } + + hdf_group_datacomponent->CloseOnDisk(); + hdf_group_datacomponent = 0; // will be deleted by hdf_file destructor + + //----------------------------------------------------------------------- + // 3 - Write the Study Structure + //----------------------------------------------------------------------- + hdf_group_study_structure = new HDFgroup ("STUDY_STRUCTURE", hdf_file); + hdf_group_study_structure->CreateOnDisk(); + + for (it = myMap.begin(); it != myMap.end(); ++it) { + std::string aName (it->first); + char* aModuleName = const_cast(aName.c_str()); + + //hdf_sco_group2 = new HDFgroup(scid.ToCString(), hdf_group_study_structure); + char* entry = (char*)(mapNameEntry[aModuleName].c_str()); + hdf_sco_group2 = new HDFgroup (entry, hdf_group_study_structure); + hdf_sco_group2->CreateOnDisk(); + + // ComponentDataType treatment + hdf_int32 name_len = (hdf_int32)strlen(aModuleName); + aHDFSize[0] = name_len + 1; + hdf_dataset = new HDFdataset ("COMPONENTDATATYPE", hdf_sco_group2, HDF_STRING, aHDFSize, 1); + hdf_dataset->CreateOnDisk(); + hdf_dataset->WriteOnDisk(aModuleName); + hdf_dataset->CloseOnDisk(); + hdf_dataset = 0; //will be deleted by hdf_sco_group2 destructor + + hdf_sco_group2->CloseOnDisk(); + hdf_sco_group2 = 0; // will be deleted by hdf_group_study_structure destructor + } + + hdf_group_study_structure->CloseOnDisk(); + hdf_group_study_structure = 0; // will be deleted by hdf_file destructor + + hdf_file->CloseOnDisk(); + delete hdf_file; // recursively deletes all hdf objects... + + } catch (HDFexception) { + isError = true; + } + if (isASCII && !isError) { // save file in ASCII format + HDFascii::ConvertFromHDFToASCII(theFileName, true); + } + + return !isError; +} + +//======================================================================= +// Function : ReadDatasFromFile +/*! Purpose : filling current driver from file 'theFileName'*/ +//======================================================================= +bool LightApp_HDFDriver::ReadDatasFromFile( const char* theFileName, bool isMultiFile ) +{ + bool isASCII = false; + bool isError = false; + TCollection_AsciiString aHDFUrl; + + HDFfile *hdf_file = 0; + HDFgroup *hdf_group_datacomponent = 0; + HDFgroup *hdf_group_study_structure = 0; + HDFgroup *hdf_sco_group = 0; + HDFgroup *hdf_sco_group2 = 0; + + std::map mapEntryName; + + if (HDFascii::isASCII(theFileName)) { + isASCII = true; + char* aResultPath = HDFascii::ConvertFromASCIIToHDF(theFileName); + aHDFUrl = aResultPath; + aHDFUrl += "hdf_from_ascii.hdf"; + delete(aResultPath); + } else { + aHDFUrl = (char*)theFileName; + } + + hdf_file = new HDFfile((char*)aHDFUrl.ToCString()); + + char aMultifileState[2]; + char ASCIIfileState[2]; + + try { + hdf_file->OpenOnDisk(HDF_RDONLY); + + } catch (HDFexception) { + //char *eStr = new char[strlen(aUrl.ToCString()) + 17]; + //sprintf(eStr,"Can't open file %s", aUrl.ToCString()); + //_errorCode = TCollection_AsciiString(eStr); + //delete [] eStr; + return false; + } + + try { + if (!hdf_file->ExistInternalObject("STUDY_STRUCTURE")) { + //_errorCode = "Study is empty"; + isError = true; + } else { + hdf_group_study_structure = new HDFgroup ("STUDY_STRUCTURE", hdf_file); + hdf_group_study_structure->OpenOnDisk(); + + char name[HDF_NAME_MAX_LEN + 1]; + Standard_Integer nbsons = hdf_group_study_structure->nInternalObjects(); + for (Standard_Integer i = 0; i < nbsons; i++) { + hdf_group_study_structure->InternalObjectIndentify(i, name); + if (strncmp(name, "INTERNAL_COMPLEX", 16) == 0) continue; + hdf_object_type type = hdf_group_study_structure->InternalObjectType(name); + if (type == HDF_GROUP) { + hdf_sco_group2 = new HDFgroup (name, hdf_group_study_structure); + hdf_sco_group2->OpenOnDisk(); + + // Read component data + char* aCompDataType = NULL; + int aDataSize = 0; + + if (hdf_sco_group2->ExistInternalObject("COMPONENTDATATYPE")) { + HDFdataset *hdf_dataset = new HDFdataset("COMPONENTDATATYPE", hdf_sco_group2); + hdf_dataset->OpenOnDisk(); + aDataSize = hdf_dataset->GetSize(); + aCompDataType = new char[aDataSize]; + if (aCompDataType == NULL) { + isError = true; + } else { + hdf_dataset->ReadFromDisk(aCompDataType); + + mapEntryName[name] = aCompDataType; + + delete [] aCompDataType; + } + + hdf_dataset->CloseOnDisk(); + hdf_dataset = 0; + } + + hdf_sco_group2->CloseOnDisk(); + } + } + + hdf_group_study_structure->CloseOnDisk(); + } + + if (!hdf_file->ExistInternalObject("DATACOMPONENT")) { + //_errorCode = "No components stored"; + isError = true; + } else { + hdf_group_datacomponent = new HDFgroup ("DATACOMPONENT", hdf_file); + hdf_group_datacomponent->OpenOnDisk(); + + char name[HDF_NAME_MAX_LEN + 1]; + Standard_Integer nbsons = hdf_group_datacomponent->nInternalObjects(); + for (Standard_Integer i = 0; i < nbsons; i++) { + hdf_group_datacomponent->InternalObjectIndentify(i, name); + if (strncmp(name, "INTERNAL_COMPLEX", 16) == 0) continue; + hdf_object_type type = hdf_group_datacomponent->InternalObjectType(name); + if (type == HDF_GROUP) { + hdf_sco_group = new HDFgroup (name, hdf_group_datacomponent); + hdf_sco_group->OpenOnDisk(); + + // Read component data + unsigned char* aStreamFile = NULL; + int aStreamSize = 0; + + if (hdf_sco_group->ExistInternalObject("FILE_STREAM")) { + HDFdataset *hdf_dataset = new HDFdataset("FILE_STREAM", hdf_sco_group); + hdf_dataset->OpenOnDisk(); + aStreamSize = hdf_dataset->GetSize(); + aStreamFile = new unsigned char[aStreamSize]; + if (aStreamFile == NULL) { + isError = true; + } else { + hdf_dataset->ReadFromDisk(aStreamFile); + } + + hdf_dataset->CloseOnDisk(); + hdf_dataset = 0; + } + + HDFdataset *multifile_hdf_dataset = new HDFdataset("MULTIFILE_STATE", hdf_sco_group); + multifile_hdf_dataset->OpenOnDisk(); + multifile_hdf_dataset->ReadFromDisk(aMultifileState); + multifile_hdf_dataset->CloseOnDisk(); + multifile_hdf_dataset = 0; + + HDFdataset *ascii_hdf_dataset = new HDFdataset("ASCII_STATE", hdf_sco_group); + ascii_hdf_dataset->OpenOnDisk(); + ascii_hdf_dataset->ReadFromDisk(ASCIIfileState); + ascii_hdf_dataset->CloseOnDisk(); + ascii_hdf_dataset = 0; + + isASCII = (ASCIIfileState[0] == 'A') ? true : false; + + if (aStreamFile != NULL) { + // Put buffer to aListOfFiles and set to myMap + ListOfFiles aListOfFiles = PutStreamToFiles(aStreamFile, aStreamSize, isMultiFile); + char* aCompDataType = (char*)(mapEntryName[name].c_str()); + SetListOfFiles(aCompDataType, aListOfFiles); + + delete [] aStreamFile; + } + + hdf_sco_group->CloseOnDisk(); + } + } + + hdf_group_datacomponent->CloseOnDisk(); + } + } catch (HDFexception) { + isError = true; + + //Handle(TColStd_HSequenceOfAsciiString) aFilesToRemove = new TColStd_HSequenceOfAsciiString; + //aFilesToRemove->Append(aHDFUrl); + //RemoveFiles(aFilesToRemove, true); + } + + hdf_file->CloseOnDisk(); + delete hdf_file; // all related hdf objects will be deleted + + if (isASCII && !isError) { + //Handle(TColStd_HSequenceOfAsciiString) aFilesToRemove = new TColStd_HSequenceOfAsciiString; + //aFilesToRemove->Append(aHDFUrl); + //RemoveFiles(aFilesToRemove, true); + } + + //std::map::const_iterator it; + //for (it = mapEntryName.begin(); it != mapEntryName.end(); ++it) { + // cout << "Read Component: entry = " << it->first + // << ", Component data type = " << it->second << endl; + //} + + return !isError; +} diff --git a/src/LightApp/LightApp_HDFDriver.h b/src/LightApp/LightApp_HDFDriver.h new file mode 100644 index 000000000..5a978eacf --- /dev/null +++ b/src/LightApp/LightApp_HDFDriver.h @@ -0,0 +1,23 @@ +#ifndef LIGHTAPP_HDFDRIVER_H +#define LIGHTAPP_HDFDRIVER_H + +#include +#include + +#ifdef WIN32 +#pragma warning( disable:4251 ) +#endif + +/*!Description : Driver can save to file and read from file list of files for light modules*/ + +class LIGHTAPP_EXPORT LightApp_HDFDriver : public LightApp_Driver +{ +public: + LightApp_HDFDriver(); + virtual ~LightApp_HDFDriver(); + + virtual bool SaveDatasInFile (const char* theFileName, bool isMultiFile); + virtual bool ReadDatasFromFile (const char* theFileName, bool isMultiFile); +}; + +#endif diff --git a/src/LightApp/LightApp_Module.cxx b/src/LightApp/LightApp_Module.cxx index 6b4de40b6..691d68b98 100644 --- a/src/LightApp/LightApp_Module.cxx +++ b/src/LightApp/LightApp_Module.cxx @@ -23,16 +23,37 @@ #include #include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include +#ifndef DISABLE_VTKVIEWER +#ifndef DISABLE_SALOMEOBJECT + #include + #include +#else + #include +#endif + #include +#endif +#ifndef DISABLE_OCCVIEWER + #include + #include +#ifndef DISABLE_SALOMEOBJECT + #include +#else + #include +#endif +#endif +#ifndef DISABLE_GLVIEWER + #include + #include +#endif +#ifndef DISABLE_PLOT2DVIEWER + #include + #include +#ifndef DISABLE_SALOMEOBJECT + #include +#else + #include +#endif +#endif #include @@ -129,6 +150,11 @@ bool LightApp_Module::activateModule( SUIT_Study* study ) if ( res && application() && application()->resourceMgr() ) application()->resourceMgr()->raiseTranslators( name() ); + connect( application(), SIGNAL( viewManagerAdded( SUIT_ViewManager* ) ), + this, SLOT( onViewManagerAdded( SUIT_ViewManager* ) ) ); + connect( application(), SIGNAL( viewManagerRemoved( SUIT_ViewManager* ) ), + this, SLOT( onViewManagerRemoved( SUIT_ViewManager* ) ) ); + if ( mySwitchOp == 0 ) mySwitchOp = new LightApp_SwitchOp( this ); @@ -141,6 +167,11 @@ bool LightApp_Module::deactivateModule( SUIT_Study* study ) delete mySwitchOp; mySwitchOp = 0; + disconnect( application(), SIGNAL( viewManagerAdded( SUIT_ViewManager* ) ), + this, SLOT( onViewManagerAdded( SUIT_ViewManager* ) ) ); + disconnect( application(), SIGNAL( viewManagerRemoved( SUIT_ViewManager* ) ), + this, SLOT( onViewManagerRemoved( SUIT_ViewManager* ) ) ); + // abort all operations MapOfOperation::const_iterator anIt; for( anIt = myOperations.begin(); anIt != myOperations.end(); anIt++ ) { @@ -196,14 +227,27 @@ void LightApp_Module::update( const int theFlags ) if ( SUIT_ViewManager* viewMgr = getApp()->activeViewManager() ) if ( SUIT_ViewWindow* viewWnd = viewMgr->getActiveView() ) { +#ifndef DISABLE_VTKVIEWER +#ifndef DISABLE_SALOMEOBJECT if ( viewWnd->inherits( "SVTK_ViewWindow" ) ) ( (SVTK_ViewWindow*)viewWnd )->Repaint(); - else if ( viewWnd->inherits( "OCCViewer_ViewWindow" ) ) +#else + if ( viewWnd->inherits( "VTKViewer_ViewWindow" ) ) + ( (VTKViewer_ViewWindow*)viewWnd )->Repaint(); +#endif +#endif +#ifndef DISABLE_OCCVIEWER + if ( viewWnd->inherits( "OCCViewer_ViewWindow" ) ) ( (OCCViewer_ViewWindow*)viewWnd )->getViewPort()->onUpdate(); - else if ( viewWnd->inherits( "Plot2d_ViewWindow" ) ) +#endif +#ifndef DISABLE_PLOT2DVIEWER + if ( viewWnd->inherits( "Plot2d_ViewWindow" ) ) ( (Plot2d_ViewWindow*)viewWnd )->getViewFrame()->Repaint(); - else if ( viewWnd->inherits( "GLViewer_ViewFrame" ) ) +#endif +#ifndef DISABLE_GLVIEWER + if ( viewWnd->inherits( "GLViewer_ViewFrame" ) ) ( (GLViewer_ViewFrame*)viewWnd )->getViewPort()->onUpdate(); +#endif } } } @@ -280,9 +324,40 @@ QtxPopupMgr* LightApp_Module::popupMgr() myPopupMgr->setRule( disp, /*QString( "( not isVisible ) and " ) + */ uniform, true ); myPopupMgr->setRule( erase, /*QString( "( isVisible ) and " ) + */ uniform, true ); myPopupMgr->setRule( dispOnly, uniform, true ); - QString viewers = "{ '%1' '%2' '%3' }"; - viewers = viewers.arg( SOCC_Viewer::Type() ).arg( SVTK_Viewer::Type() ).arg( SPlot2d_Viewer::Type() ); - myPopupMgr->setRule( eraseAll, QString( "client in %1" ).arg( viewers ), true ); + + QStringList viewers; + +#ifndef DISABLE_OCCVIEWER +#ifndef DISABLE_SALOMEOBJECT + viewers.append( SOCC_Viewer::Type() ); +#else + viewers.append( OCCViewer_Viewer::Type() ); +#endif +#endif +#ifndef DISABLE_VTKVIEWER +#ifndef DISABLE_SALOMEOBJECT + viewers.append( SVTK_Viewer::Type() ); +#else + viewers.append( VTKViewer_Viewer::Type() ); +#endif +#endif +#ifndef DISABLE_PLOT2DVIEWER +#ifndef DISABLE_SALOMEOBJECT + viewers.append( SPlot2d_Viewer::Type() ); +#else + viewers.append( Plot2d_Viewer::Type() ); +#endif +#endif + + if( !viewers.isEmpty() ) + { + QString strViewers = "{ ", temp = "'%1' "; + QStringList::const_iterator anIt = viewers.begin(), aLast = viewers.end(); + for( ; anIt!=aLast; anIt++ ) + strViewers+=temp.arg( *anIt ); + strViewers+="}"; + myPopupMgr->setRule( eraseAll, QString( "client in %1" ).arg( strViewers ), true ); + } } return myPopupMgr; } @@ -449,3 +524,11 @@ void LightApp_Module::onShowHide() if( id!=-1 ) startOperation( id ); } + +void LightApp_Module::onViewManagerAdded( SUIT_ViewManager* ) +{ +} + +void LightApp_Module::onViewManagerRemoved( SUIT_ViewManager* ) +{ +} diff --git a/src/LightApp/LightApp_Module.h b/src/LightApp/LightApp_Module.h index 2df7aab61..afe552d12 100644 --- a/src/LightApp/LightApp_Module.h +++ b/src/LightApp/LightApp_Module.h @@ -20,6 +20,7 @@ class LightApp_Displayer; class SUIT_Study; class SUIT_DataObject; class SUIT_Operation; +class SUIT_ViewManager; class CAM_Application; class QtxPopupMgr; @@ -80,6 +81,8 @@ protected slots: virtual void onOperationStopped( SUIT_Operation* ); virtual void onOperationDestroyed(); virtual void onShowHide(); + virtual void onViewManagerAdded( SUIT_ViewManager* ); + virtual void onViewManagerRemoved( SUIT_ViewManager* ); protected: virtual QtxPopupMgr* popupMgr(); diff --git a/src/LightApp/LightApp_NameDlg.cxx b/src/LightApp/LightApp_NameDlg.cxx index 3af8513c9..609927305 100644 --- a/src/LightApp/LightApp_NameDlg.cxx +++ b/src/LightApp/LightApp_NameDlg.cxx @@ -16,131 +16,131 @@ // // See http://www.salome-platform.org/ // -// File : LightApp_NameDlg.cxx -// Author : Vadim SANDLER -// $Header$ - -#include -#include -#include -#include - -#include -#include -#include -#include -#include - -#ifndef WIN32 -using namespace std; -#endif - -/*! - Constructor -*/ -LightApp_NameDlg::LightApp_NameDlg( QWidget* parent ) -: QDialog( parent ? parent : NULL,//application()->desktop(), -"LightApp_NameDlg", -true, -WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu ) -{ - setCaption( tr("TLT_RENAME") ); - setSizeGripEnabled( TRUE ); - - QVBoxLayout* topLayout = new QVBoxLayout( this ); - topLayout->setMargin( 11 ); topLayout->setSpacing( 6 ); - - /***************************************************************/ - QGroupBox* GroupC1 = new QGroupBox( this, "GroupC1" ); - GroupC1->setColumnLayout(0, Qt::Vertical ); - GroupC1->layout()->setMargin( 0 ); GroupC1->layout()->setSpacing( 0 ); - QHBoxLayout* GroupC1Layout = new QHBoxLayout( GroupC1->layout() ); - GroupC1Layout->setAlignment( Qt::AlignTop ); - GroupC1Layout->setMargin( 11 ); GroupC1Layout->setSpacing( 6 ); - - QLabel* TextLabel = new QLabel( GroupC1, "TextLabel1" ); - TextLabel->setText( tr( "NAME_LBL" ) ); - GroupC1Layout->addWidget( TextLabel ); - - myLineEdit = new QLineEdit( GroupC1, "LineEdit1" ); - myLineEdit->setMinimumSize( 250, 0 ); - GroupC1Layout->addWidget( myLineEdit ); - - /***************************************************************/ - QGroupBox* GroupButtons = new QGroupBox( this, "GroupButtons" ); - GroupButtons->setColumnLayout(0, Qt::Vertical ); - GroupButtons->layout()->setMargin( 0 ); GroupButtons->layout()->setSpacing( 0 ); - QHBoxLayout* GroupButtonsLayout = new QHBoxLayout( GroupButtons->layout() ); - GroupButtonsLayout->setAlignment( Qt::AlignTop ); - GroupButtonsLayout->setMargin( 11 ); GroupButtonsLayout->setSpacing( 6 ); - - myButtonOk = new QPushButton( GroupButtons, "buttonOk" ); - myButtonOk->setText( tr( "BUT_OK" ) ); - myButtonOk->setAutoDefault( TRUE ); myButtonOk->setDefault( TRUE ); - GroupButtonsLayout->addWidget( myButtonOk ); - - GroupButtonsLayout->addStretch(); - - myButtonCancel = new QPushButton( GroupButtons, "buttonCancel" ); - myButtonCancel->setText( tr( "BUT_CANCEL" ) ); - myButtonCancel->setAutoDefault( TRUE ); - GroupButtonsLayout->addWidget( myButtonCancel ); - /***************************************************************/ - - topLayout->addWidget( GroupC1 ); - topLayout->addWidget( GroupButtons ); - - // signals and slots connections - connect( myButtonOk, SIGNAL( clicked() ), this, SLOT( accept() ) ); - connect( myButtonCancel, SIGNAL( clicked() ), this, SLOT( reject() ) ); - - /* Move widget on the botton right corner of main widget */ - SUIT_Tools::centerWidget( this, parent ); -} - -/*! - Destructor -*/ -LightApp_NameDlg::~LightApp_NameDlg() -{ -} - -/*! - Sets name -*/ -void LightApp_NameDlg::setName( const QString& name ) -{ - myLineEdit->setText( name ); - myLineEdit->end(false); - myLineEdit->home(true); -} - -/*! - Returns name entered by user -*/ -QString LightApp_NameDlg::name() -{ - return myLineEdit->text(); -} - -void LightApp_NameDlg::accept() -{ - if ( name().stripWhiteSpace().isEmpty() ) - return; - QDialog::accept(); -} - -/*! - Creates modal dialog and returns name entered [ static ] -*/ -QString LightApp_NameDlg::getName( QWidget* parent, const QString& oldName ) -{ - QString n; - LightApp_NameDlg* dlg = new LightApp_NameDlg( parent ); - if ( !oldName.isNull() ) - dlg->setName( oldName ); - if ( dlg->exec() == QDialog::Accepted ) - n = dlg->name(); - delete dlg; - return n; -} +// File : LightApp_NameDlg.cxx +// Author : Vadim SANDLER +// $Header$ + +#include +#include +#include +#include + +#include +#include +#include +#include +#include + +#ifndef WIN32 +using namespace std; +#endif + +/*! + Constructor +*/ +LightApp_NameDlg::LightApp_NameDlg( QWidget* parent ) +: QDialog( parent ? parent : NULL,//application()->desktop(), +"LightApp_NameDlg", +true, +WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu ) +{ + setCaption( tr("TLT_RENAME") ); + setSizeGripEnabled( TRUE ); + + QVBoxLayout* topLayout = new QVBoxLayout( this ); + topLayout->setMargin( 11 ); topLayout->setSpacing( 6 ); + + /***************************************************************/ + QGroupBox* GroupC1 = new QGroupBox( this, "GroupC1" ); + GroupC1->setColumnLayout(0, Qt::Vertical ); + GroupC1->layout()->setMargin( 0 ); GroupC1->layout()->setSpacing( 0 ); + QHBoxLayout* GroupC1Layout = new QHBoxLayout( GroupC1->layout() ); + GroupC1Layout->setAlignment( Qt::AlignTop ); + GroupC1Layout->setMargin( 11 ); GroupC1Layout->setSpacing( 6 ); + + QLabel* TextLabel = new QLabel( GroupC1, "TextLabel1" ); + TextLabel->setText( tr( "NAME_LBL" ) ); + GroupC1Layout->addWidget( TextLabel ); + + myLineEdit = new QLineEdit( GroupC1, "LineEdit1" ); + myLineEdit->setMinimumSize( 250, 0 ); + GroupC1Layout->addWidget( myLineEdit ); + + /***************************************************************/ + QGroupBox* GroupButtons = new QGroupBox( this, "GroupButtons" ); + GroupButtons->setColumnLayout(0, Qt::Vertical ); + GroupButtons->layout()->setMargin( 0 ); GroupButtons->layout()->setSpacing( 0 ); + QHBoxLayout* GroupButtonsLayout = new QHBoxLayout( GroupButtons->layout() ); + GroupButtonsLayout->setAlignment( Qt::AlignTop ); + GroupButtonsLayout->setMargin( 11 ); GroupButtonsLayout->setSpacing( 6 ); + + myButtonOk = new QPushButton( GroupButtons, "buttonOk" ); + myButtonOk->setText( tr( "BUT_OK" ) ); + myButtonOk->setAutoDefault( TRUE ); myButtonOk->setDefault( TRUE ); + GroupButtonsLayout->addWidget( myButtonOk ); + + GroupButtonsLayout->addStretch(); + + myButtonCancel = new QPushButton( GroupButtons, "buttonCancel" ); + myButtonCancel->setText( tr( "BUT_CANCEL" ) ); + myButtonCancel->setAutoDefault( TRUE ); + GroupButtonsLayout->addWidget( myButtonCancel ); + /***************************************************************/ + + topLayout->addWidget( GroupC1 ); + topLayout->addWidget( GroupButtons ); + + // signals and slots connections + connect( myButtonOk, SIGNAL( clicked() ), this, SLOT( accept() ) ); + connect( myButtonCancel, SIGNAL( clicked() ), this, SLOT( reject() ) ); + + /* Move widget on the botton right corner of main widget */ + SUIT_Tools::centerWidget( this, parent ); +} + +/*! + Destructor +*/ +LightApp_NameDlg::~LightApp_NameDlg() +{ +} + +/*! + Sets name +*/ +void LightApp_NameDlg::setName( const QString& name ) +{ + myLineEdit->setText( name ); + myLineEdit->end(false); + myLineEdit->home(true); +} + +/*! + Returns name entered by user +*/ +QString LightApp_NameDlg::name() +{ + return myLineEdit->text(); +} + +void LightApp_NameDlg::accept() +{ + if ( name().stripWhiteSpace().isEmpty() ) + return; + QDialog::accept(); +} + +/*! + Creates modal dialog and returns name entered [ static ] +*/ +QString LightApp_NameDlg::getName( QWidget* parent, const QString& oldName ) +{ + QString n; + LightApp_NameDlg* dlg = new LightApp_NameDlg( parent ); + if ( !oldName.isNull() ) + dlg->setName( oldName ); + if ( dlg->exec() == QDialog::Accepted ) + n = dlg->name(); + delete dlg; + return n; +} diff --git a/src/LightApp/LightApp_OBSelector.cxx b/src/LightApp/LightApp_OBSelector.cxx index ebe8571b4..22867b5f6 100644 --- a/src/LightApp/LightApp_OBSelector.cxx +++ b/src/LightApp/LightApp_OBSelector.cxx @@ -71,9 +71,13 @@ void LightApp_OBSelector::getSelection( SUIT_DataOwnerPtrList& theList ) const LightApp_DataObject* obj = dynamic_cast( it.current() ); if ( obj ) { +#ifndef DISABLE_SALOMEOBJECT Handle(SALOME_InteractiveObject) aSObj = new SALOME_InteractiveObject ( obj->entry(), obj->componentDataType(), obj->name() ); LightApp_DataOwner* owner = new LightApp_DataOwner( aSObj ); +#else + LightApp_DataOwner* owner = new LightApp_DataOwner( obj->entry() ); +#endif that->mySelectedList.append( SUIT_DataOwnerPtr( owner ) ); } } diff --git a/src/LightApp/LightApp_OCCSelector.cxx b/src/LightApp/LightApp_OCCSelector.cxx index d0b07bb7b..abd30415a 100644 --- a/src/LightApp/LightApp_OCCSelector.cxx +++ b/src/LightApp/LightApp_OCCSelector.cxx @@ -20,8 +20,9 @@ #include "LightApp_DataOwner.h" #include "LightApp_OCCSelector.h" -#include - +#ifndef DISABLE_SALOMEOBJECT + #include +#endif #include #include @@ -68,9 +69,13 @@ void LightApp_OCCSelector::getSelection( SUIT_DataOwnerPtrList& aList ) const for ( AIS_ListIteratorOfListOfInteractive anIt( aSelList ); anIt.More(); anIt.Next() ) if ( !anIt.Value().IsNull() ) { +#ifndef DISABLE_SALOMEOBJECT Handle(SALOME_InteractiveObject) anObj = Handle(SALOME_InteractiveObject)::DownCast(anIt.Value()->GetOwner()); if( !anObj.IsNull() ) aList.append( SUIT_DataOwnerPtr( new LightApp_DataOwner( anObj ) ) ); +#else + aList.append( SUIT_DataOwnerPtr( new LightApp_DataOwner( entry( anIt.Value() ) ) ) ); +#endif } } @@ -112,10 +117,13 @@ QString LightApp_OCCSelector::entry( const Handle(AIS_InteractiveObject)& anAIS if ( anAIS.IsNull() || !anAIS->HasOwner() ) return QString::null; - Handle(SALOME_InteractiveObject) anObj = Handle(SALOME_InteractiveObject)::DownCast(anAIS->GetOwner()); - QString res; + +#ifndef DISABLE_SALOMEOBJECT + Handle(SALOME_InteractiveObject) anObj = Handle(SALOME_InteractiveObject)::DownCast(anAIS->GetOwner()); if ( !anObj.IsNull() ) res = QString( anObj->getEntry() ); +#endif + return res; } diff --git a/src/LightApp/LightApp_Selection.cxx b/src/LightApp/LightApp_Selection.cxx index bca35cfec..454ee5320 100644 --- a/src/LightApp/LightApp_Selection.cxx +++ b/src/LightApp/LightApp_Selection.cxx @@ -153,7 +153,12 @@ QtxValue LightApp_Selection::param( const int ind, const QString& p ) const LightApp_Displayer* d = LightApp_Displayer::FindDisplayer( mod_name, false ); // false in last parameter means that now we doesn't load module, if it isn't loaded - return QtxValue( d ? d->canBeDisplayed( myEntries[ ind ] ) : true, 0 ); + if ( d ) + return d->canBeDisplayed( myEntries[ ind ] ); + else if ( myEntries[ ind ].startsWith( QObject::tr( "SAVE_POINT_DEF_NAME" ) ) ) // object is a Save Point object + return false; + + return true; //now if displayer is null, it means, that according module isn't loaded, so that we allow to all display/erase //operations under object } diff --git a/src/LightApp/LightApp_SelectionMgr.cxx b/src/LightApp/LightApp_SelectionMgr.cxx index ab7a4f8b1..a46e906c0 100644 --- a/src/LightApp/LightApp_SelectionMgr.cxx +++ b/src/LightApp/LightApp_SelectionMgr.cxx @@ -25,13 +25,15 @@ #include -#include -#include +#ifndef DISABLE_SALOMEOBJECT + #include + #include -// Open CASCADE Include -#include -#include -#include + // Open CASCADE Include + #include + #include + #include +#endif /*! Constructor. @@ -57,6 +59,7 @@ LightApp_Application* LightApp_SelectionMgr::application() const return myApp; } +#ifndef DISABLE_SALOMEOBJECT /*! Get all selected objects from selection manager */ @@ -117,6 +120,37 @@ void LightApp_SelectionMgr::setSelectedObjects( const SALOME_ListIO& lst, const setSelected( owners, append ); } +#else +/*! + Get all selected objects from selection manager +*/ +void LightApp_SelectionMgr::selectedObjects( QStringList& theList, const QString& theType, + const bool convertReferences ) const +{ + theList.clear(); + + SUIT_DataOwnerPtrList aList; + selected( aList, theType ); + + QString entry; + for ( SUIT_DataOwnerPtrList::const_iterator itr = aList.begin(); itr != aList.end(); ++itr ) + { + const LightApp_DataOwner* owner = dynamic_cast( (*itr).operator->() ); + if( !owner ) + continue; + + LightApp_Study* study = dynamic_cast( application()->activeStudy() ); + if ( !study ) + return; + + entry = owner->entry(); + if( !theList.contains( entry ) ) + theList.append( entry ); + } +} + +#endif + /*! Emit current selection changed. */ @@ -127,6 +161,8 @@ void LightApp_SelectionMgr::selectionChanged( SUIT_Selector* theSel ) emit currentSelectionChanged(); } +#ifndef DISABLE_SALOMEOBJECT + /*! get map of indexes for the given SALOME_InteractiveObject */ @@ -287,3 +323,5 @@ void LightApp_SelectionMgr::selectedSubOwners( MapEntryOfMapOfInteger& theMap ) } } } + +#endif diff --git a/src/LightApp/LightApp_SelectionMgr.h b/src/LightApp/LightApp_SelectionMgr.h index c063b82be..8546dadfe 100644 --- a/src/LightApp/LightApp_SelectionMgr.h +++ b/src/LightApp/LightApp_SelectionMgr.h @@ -22,14 +22,19 @@ #include "LightApp.h" #include -#include -#include +#ifndef DISABLE_SALOMEOBJECT + #include + #include + + class SALOME_ListIO; + class TColStd_IndexedMapOfInteger; + class TColStd_MapOfInteger; +#else +#include +#endif -class SALOME_ListIO; class LightApp_Application; -class TColStd_IndexedMapOfInteger; -class TColStd_MapOfInteger; class LIGHTAPP_EXPORT LightApp_SelectionMgr : public SUIT_SelectionMgr { @@ -39,11 +44,12 @@ public: LightApp_SelectionMgr( LightApp_Application*, const bool = true ); virtual ~LightApp_SelectionMgr(); + LightApp_Application* application() const; + +#ifndef DISABLE_SALOMEOBJECT typedef QMap< Handle(SALOME_InteractiveObject), TColStd_IndexedMapOfInteger > MapIOOfMapOfInteger; typedef QMap< QString, TColStd_IndexedMapOfInteger > MapEntryOfMapOfInteger; - LightApp_Application* application() const; - void selectedObjects( SALOME_ListIO&, const QString& = QString::null, const bool = true ) const; void setSelectedObjects( const SALOME_ListIO&, const bool = false ); @@ -61,6 +67,9 @@ public: void selectObjects( MapIOOfMapOfInteger theMapIO, bool append ); void selectedSubOwners( MapEntryOfMapOfInteger& theMap ); +#else + void selectedObjects( QStringList&, const QString& = QString::null, const bool = true ) const; +#endif signals: void currentSelectionChanged(); diff --git a/src/LightApp/LightApp_ShowHideOp.cxx b/src/LightApp/LightApp_ShowHideOp.cxx index 52f16266f..76827c053 100644 --- a/src/LightApp/LightApp_ShowHideOp.cxx +++ b/src/LightApp/LightApp_ShowHideOp.cxx @@ -28,8 +28,10 @@ #include "LightApp_SelectionMgr.h" #include "LightApp_Selection.h" -#include -#include +#ifndef DISABLE_SALOMEOBJECT + #include + #include +#endif LightApp_ShowHideOp::LightApp_ShowHideOp( ActionType type ) : LightApp_Operation(), @@ -95,21 +97,33 @@ void LightApp_ShowHideOp::startOperation() } } + QStringList entries; + +#ifndef DISABLE_SALOMEOBJECT SALOME_ListIO selObjs; mgr->selectedObjects( selObjs ); - - QStringList entries; SALOME_ListIteratorOfListIO anIt( selObjs ); for( ; anIt.More(); anIt.Next() ) - { - if( anIt.Value().IsNull() ) - continue; + if( !anIt.Value().IsNull() ) +#else + QStringList selObjs; + mgr->selectedObjects( selObjs ); + QStringList::const_iterator anIt = selObjs.begin(), aLast = selObjs.end(); + for( ; ; anIt!=aLast ) +#endif + { + QString entry = +#ifndef DISABLE_SALOMEOBJECT + anIt.Value()->getEntry(); +#else + *anIt; +#endif - if( study->isComponent( anIt.Value()->getEntry() ) ) - study->children( anIt.Value()->getEntry(), entries ); - else - entries.append( anIt.Value()->getEntry() ); - } + if( study->isComponent( entry ) ) + study->children( entry, entries ); + else + entries.append( entry ); + } for( QStringList::const_iterator it = entries.begin(), last = entries.end(); it!=last; it++ ) { diff --git a/src/LightApp/LightApp_Study.cxx b/src/LightApp/LightApp_Study.cxx index a2e5e4ba9..0b8b9005e 100644 --- a/src/LightApp/LightApp_Study.cxx +++ b/src/LightApp/LightApp_Study.cxx @@ -23,8 +23,7 @@ #include "LightApp_DataModel.h" #include "LightApp_DataObject.h" #include "LightApp_RootObject.h" -// HDF persistence not yet completed -//#include "LightApp_HDFDriver.h" +#include "LightApp_HDFDriver.h" #include "SUIT_ResourceMgr.h" #include "SUIT_DataObjectIterator.h" @@ -51,11 +50,11 @@ LightApp_Study::LightApp_Study( SUIT_Application* app ) : CAM_Study( app ) { - // HDF persistence not yet completed - //myDriver = new LightApp_HDFDriver(); - myDriver = new LightApp_Driver(); + // HDF persistence + myDriver = new LightApp_HDFDriver(); + //myDriver = new LightApp_Driver(); } - + /*! Destructor. */ @@ -68,6 +67,8 @@ LightApp_Study::~LightApp_Study() */ void LightApp_Study::createDocument() { + setStudyName( QString( "Study%1" ).arg( LightApp_Application::studyId() ) ); + // create myRoot setRoot( new LightApp_RootObject( this ) ); diff --git a/src/LightApp/LightApp_Study.h b/src/LightApp/LightApp_Study.h index 1280fd99a..2e0ac3226 100644 --- a/src/LightApp/LightApp_Study.h +++ b/src/LightApp/LightApp_Study.h @@ -16,76 +16,78 @@ // // See http://www.salome-platform.org/ // -#ifndef LIGHTAPP_STUDY_H -#define LIGHTAPP_STUDY_H - -#include -#include - -#include -#include -#include - -#include "string" -#include "vector" - -class SUIT_Application; -class CAM_DataModel; - -class LIGHTAPP_EXPORT LightApp_Study : public CAM_Study -{ - Q_OBJECT - -public: - LightApp_Study( SUIT_Application* ); - virtual ~LightApp_Study(); - - virtual void createDocument(); - virtual bool openDocument( const QString& ); - virtual bool loadDocument( const QString& ); - - virtual bool saveDocument(); - virtual bool saveDocumentAs( const QString& ); - - virtual void closeDocument(bool permanently = true); - - virtual bool isSaved() const; - virtual bool isModified() const; - - virtual void addComponent ( const CAM_DataModel* dm); - - virtual std::string GetTmpDir ( const char* theURL, const bool isMultiFile ); - - virtual QString componentDataType( const QString& ) const; - virtual QString referencedToEntry( const QString& ) const; - virtual bool isComponent( const QString& ) const; - virtual void children( const QString&, QStringList& ) const; - virtual void components( QStringList& ) const; - -protected: - virtual void saveModuleData ( QString theModuleName, QStringList theListOfFiles ); - virtual void openModuleData ( QString theModuleName, QStringList& theListOfFiles ); - virtual bool saveStudyData ( const QString& theFileName ); - virtual bool openStudyData ( const QString& theFileName ); - - virtual std::vector GetListOfFiles ( const char* theModuleName ) const; - virtual void SetListOfFiles ( const char* theModuleName, - const std::vector theListOfFiles ); - - virtual void RemoveTemporaryFiles ( const char* theModuleName, const bool isMultiFile ) const; - -protected: - virtual bool openDataModel ( const QString&, CAM_DataModel* ); - -signals: - void saved ( SUIT_Study* ); - void opened ( SUIT_Study* ); - void closed ( SUIT_Study* ); - void created( SUIT_Study* ); - - -private: - LightApp_Driver* myDriver; -}; - -#endif +#ifndef LIGHTAPP_STUDY_H +#define LIGHTAPP_STUDY_H + +#include +#include + +#include +#include +#include + +#include "string" +#include "vector" + +class SUIT_Application; +class CAM_DataModel; + +class LIGHTAPP_EXPORT LightApp_Study : public CAM_Study +{ + Q_OBJECT + +public: + LightApp_Study( SUIT_Application* ); + virtual ~LightApp_Study(); + + virtual void createDocument(); + virtual bool openDocument( const QString& ); + virtual bool loadDocument( const QString& ); + + virtual bool saveDocument(); + virtual bool saveDocumentAs( const QString& ); + + virtual void closeDocument(bool permanently = true); + + virtual bool isSaved() const; + virtual bool isModified() const; + + virtual void addComponent ( const CAM_DataModel* dm); + + virtual std::string GetTmpDir ( const char* theURL, const bool isMultiFile ); + + virtual QString componentDataType( const QString& ) const; + virtual QString referencedToEntry( const QString& ) const; + virtual bool isComponent( const QString& ) const; + virtual void children( const QString&, QStringList& ) const; + virtual void components( QStringList& ) const; + +protected: + virtual void saveModuleData ( QString theModuleName, QStringList theListOfFiles ); + virtual void openModuleData ( QString theModuleName, QStringList& theListOfFiles ); + virtual bool saveStudyData ( const QString& theFileName ); + virtual bool openStudyData ( const QString& theFileName ); + + virtual std::vector GetListOfFiles ( const char* theModuleName ) const; + virtual void SetListOfFiles ( const char* theModuleName, + const std::vector theListOfFiles ); + + virtual void RemoveTemporaryFiles ( const char* theModuleName, const bool isMultiFile ) const; + +protected: + virtual bool openDataModel ( const QString&, CAM_DataModel* ); + +signals: + void saved ( SUIT_Study* ); + void opened ( SUIT_Study* ); + void closed ( SUIT_Study* ); + void created( SUIT_Study* ); + + +private: + LightApp_Driver* myDriver; + + friend class LightApp_Application; +}; + +#endif diff --git a/src/LightApp/LightApp_VTKSelector.cxx b/src/LightApp/LightApp_VTKSelector.cxx index b393b3043..a81891b59 100644 --- a/src/LightApp/LightApp_VTKSelector.cxx +++ b/src/LightApp/LightApp_VTKSelector.cxx @@ -19,18 +19,24 @@ #include "LightApp_VTKSelector.h" #include "LightApp_DataOwner.h" -#include "SVTK_ViewModelBase.h" -#include "SVTK_Selector.h" -#include "SVTK_ViewWindow.h" -#include "SVTK_Functor.h" +#ifndef DISABLE_VTKVIEWER + #include "SVTK_ViewModelBase.h" + #include "SVTK_Selector.h" + #include "SVTK_ViewWindow.h" + #include "SVTK_Functor.h" + #include "VTKViewer_Algorithm.h" + #include +#endif -#include "SALOME_Actor.h" -#include "SALOME_ListIteratorOfListIO.hxx" +#ifndef DISABLE_SALOMEOBJECT + #include "SALOME_Actor.h" + #include "SALOME_ListIteratorOfListIO.hxx" +#endif -#include "VTKViewer_Algorithm.h" -#include +#ifndef DISABLE_VTKVIEWER +#ifndef DISABLE_SALOMEOBJECT /*! Constructor. */ @@ -45,6 +51,7 @@ LightApp_SVTKDataOwner { myIds = theIds; // workaround - there is no constructor copy for the container } +#endif /*! Destuctor. @@ -64,6 +71,10 @@ LightApp_SVTKDataOwner return myActor.GetPointer(); } +#endif + + +#ifndef DISABLE_VTKVIEWER /*! Constructor. */ @@ -105,6 +116,7 @@ LightApp_VTKSelector return myViewer->getType(); } +#endif /*! On selection changed. */ @@ -115,6 +127,8 @@ LightApp_VTKSelector selectionChanged(); } +#ifndef DISABLE_VTKVIEWER + /*! Gets list of selected data owners.(output \a aList). */ @@ -204,3 +218,5 @@ LightApp_VTKSelector } } } + +#endif diff --git a/src/LightApp/LightApp_VTKSelector.h b/src/LightApp/LightApp_VTKSelector.h index 14c6523ce..7c5dca73f 100644 --- a/src/LightApp/LightApp_VTKSelector.h +++ b/src/LightApp/LightApp_VTKSelector.h @@ -19,20 +19,20 @@ #ifndef LIGHTAPP_VTKSELECTOR_H #define LIGHTAPP_VTKSELECTOR_H -#include - -#include - #include "SUIT_Selector.h" - #include "LightApp.h" #include "LightApp_DataOwner.h" -#include "SVTK_Selection.h" -#include "SALOME_InteractiveObject.hxx" - -class SALOME_Actor; -class SVTK_ViewModelBase; +#ifndef DISABLE_VTKVIEWER + #include + #include + #include "SVTK_Selection.h" +#ifndef DISABLE_SALOMEOBJECT + #include "SALOME_InteractiveObject.hxx" +#endif + class SALOME_Actor; + class SVTK_ViewModelBase; +#endif /*! Provide salome vtk data owner list. @@ -40,10 +40,13 @@ class SVTK_ViewModelBase; class LIGHTAPP_EXPORT LightApp_SVTKDataOwner : public LightApp_DataOwner { public: +#ifndef DISABLE_VTKVIEWER + #ifndef DISABLE_SALOMEOBJECT LightApp_SVTKDataOwner( const Handle(SALOME_InteractiveObject)& theIO, const TColStd_IndexedMapOfInteger& theIds, Selection_Mode theMode = ActorSelection, SALOME_Actor* theActor = NULL); + #endif virtual ~LightApp_SVTKDataOwner(); /*!Gets dataowners ids list.*/ @@ -64,6 +67,9 @@ class LIGHTAPP_EXPORT LightApp_SVTKDataOwner : public LightApp_DataOwner TColStd_IndexedMapOfInteger myIds; Selection_Mode mySelectionMode; vtkSmartPointer myActor; +#else + LightApp_SVTKDataOwner( const QString& ); +#endif }; @@ -75,22 +81,29 @@ class LIGHTAPP_EXPORT LightApp_VTKSelector : public SUIT_Selector Q_OBJECT; public: +#ifndef DISABLE_VTKVIEWER LightApp_VTKSelector( SVTK_ViewModelBase*, SUIT_SelectionMgr* ); virtual ~LightApp_VTKSelector(); SVTK_ViewModelBase* viewer() const; virtual QString type() const; +#else + LightApp_VTKSelector( SUIT_SelectionMgr* ); +#endif private slots: void onSelectionChanged(); +#ifndef DISABLE_VTKVIEWER protected: virtual void getSelection( SUIT_DataOwnerPtrList& ) const; virtual void setSelection( const SUIT_DataOwnerPtrList& ); private: SVTK_ViewModelBase* myViewer; + +#endif }; #endif diff --git a/src/LightApp/Makefile.in b/src/LightApp/Makefile.in index 3ffef0449..c26adb882 100755 --- a/src/LightApp/Makefile.in +++ b/src/LightApp/Makefile.in @@ -22,13 +22,12 @@ EXPORT_HEADERS= LightApp.h \ LightApp_Dialog.h \ LightApp_Displayer.h \ LightApp_Driver.h \ - LightApp_GLSelector.h \ + LightApp_HDFDriver.h \ LightApp_Module.h \ LightApp_ModuleDlg.h \ LightApp_NameDlg.h \ LightApp_OBFilter.h \ LightApp_OBSelector.h \ - LightApp_OCCSelector.h \ LightApp_Operation.h \ LightApp_Selection.h \ LightApp_SelectionMgr.h \ @@ -39,9 +38,19 @@ EXPORT_HEADERS= LightApp.h \ LightApp_PreferencesDlg.h \ LightApp_RootObject.h \ LightApp_UpdateFlags.h \ - LightApp_VTKSelector.h \ LightApp_WidgetContainer.h -# LightApp_HDFDriver.h \ + +ifneq ($(DISABLE_VTKVIEWER),yes) +ifneq ($(DISABLE_SALOMEOBJECT),yes) + EXPORT_HEADERS+= LightApp_VTKSelector.h +endif +endif +ifneq ($(DISABLE_OCCVIEWER),yes) + EXPORT_HEADERS+= LightApp_OCCSelector.h +endif +ifneq ($(DISABLE_GLVIEWER),yes) + EXPORT_HEADERS+= LightApp_GLSelector.h +endif # .po files to transform in .qm PO_FILES = LightApp_images.po \ @@ -59,13 +68,12 @@ LIB_SRC= LightApp_AboutDlg.cxx \ LightApp_Dialog.cxx \ LightApp_Displayer.cxx \ LightApp_Driver.cxx \ - LightApp_GLSelector.cxx \ + LightApp_HDFDriver.cxx \ LightApp_Module.cxx \ LightApp_ModuleDlg.cxx \ LightApp_NameDlg.cxx \ LightApp_OBFilter.cxx \ LightApp_OBSelector.cxx \ - LightApp_OCCSelector.cxx \ LightApp_Operation.cxx \ LightApp_Selection.cxx \ LightApp_SelectionMgr.cxx \ @@ -74,17 +82,25 @@ LIB_SRC= LightApp_AboutDlg.cxx \ LightApp_SwitchOp.cxx \ LightApp_Preferences.cxx \ LightApp_PreferencesDlg.cxx \ - LightApp_VTKSelector.cxx \ LightApp_WidgetContainer.cxx -# LightApp_HDFDriver.cxx \ + +ifneq ($(DISABLE_VTKVIEWER),yes) +ifneq ($(DISABLE_SALOMEOBJECT),yes) + LIB_SRC+= LightApp_VTKSelector.cxx +endif +endif +ifneq ($(DISABLE_OCCVIEWER),yes) + LIB_SRC+= LightApp_OCCSelector.cxx +endif +ifneq ($(DISABLE_GLVIEWER),yes) + LIB_SRC+= LightApp_GLSelector.cxx +endif LIB_MOC = LightApp_AboutDlg.h \ LightApp_Application.h \ LightApp_DataModel.h \ LightApp_Dialog.h \ - LightApp_GLSelector.h \ LightApp_OBSelector.h \ - LightApp_OCCSelector.h \ LightApp_Operation.h \ LightApp_Module.h \ LightApp_ModuleDlg.h \ @@ -95,9 +111,20 @@ LIB_MOC = LightApp_AboutDlg.h \ LightApp_SwitchOp.h \ LightApp_Preferences.h \ LightApp_PreferencesDlg.h \ - LightApp_VTKSelector.h \ LightApp_WidgetContainer.h +ifneq ($(DISABLE_VTKVIEWER),yes) +ifneq ($(DISABLE_SALOMEOBJECT),yes) + LIB_MOC+= LightApp_VTKSelector.h +endif +endif +ifneq ($(DISABLE_OCCVIEWER),yes) + LIB_MOC+= LightApp_OCCSelector.h +endif +ifneq ($(DISABLE_GLVIEWER),yes) + LIB_MOC+= LightApp_GLSelector.h +endif + RESOURCES_FILES = icon_about.png \ icon_applogo.png \ icon_default.png \ @@ -107,11 +134,74 @@ RESOURCES_FILES = icon_about.png \ LightApp.ini \ LightApp.xml -CPPFLAGS+=$(PYTHON_INCLUDES) $(QT_INCLUDES) $(QWT_INCLUDES) $(OCC_INCLUDES) $(VTK_INCLUDES) - #$(HDF5_INCLUDES) +CPPFLAGS+=$(PYTHON_INCLUDES) $(QT_INCLUDES) $(OCC_INCLUDES) \ + $(HDF5_INCLUDES) -I${KERNEL_ROOT_DIR}/include/salome + +ifneq ($(DISABLE_VTKVIEWER),yes) + CPPFLAGS+= $(VTK_INCLUDES) +else + CPPFLAGS+= -DDISABLE_VTKVIEWER +endif +ifneq ($(DISABLE_PLOT2DVIEWER),yes) + CPPFLAGS+= $(QWT_INCLUDES) +else + CPPFLAGS+= -DDISABLE_PLOT2DVIEWER +endif +ifeq ($(DISABLE_OCCVIEWER),yes) + CPPFLAGS+= -DDISABLE_OCCVIEWER +endif +ifneq ($(DISABLE_PYCONSOLE),yes) + CPPFLAGS+= $(PYTHON_INCLUDES) +else + CPPFLAGS+= -DDISABLE_PYCONSOLE +endif +ifeq ($(DISABLE_GLVIEWER),yes) + CPPFLAGS+= -DDISABLE_GLVIEWER +endif +ifeq ($(DISABLE_SUPERVGRAPHVIEWER),yes) + CPPFLAGS+= -DDISABLE_SUPERVGRAPHVIEWER +endif +ifeq ($(DISABLE_SALOMEOBJECT),yes) + CPPFLAGS+= -DDISABLE_SALOMEOBJECT +endif + +LDFLAGS+=$(QT_MT_LIBS) +ifneq ($(DISABLE_PYCONSOLE),yes) + LDFLAGS+= $(PYTHON_LIBS) +endif + +LIBS+= -lsuit -lstd -lCAM -lObjBrowser -lLogWindow $(CAS_KERNEL) -lSalomePrs \ + $(HDF5_LIBS) -L$(KERNEL_ROOT_DIR)/lib/salome -lSalomeHDFPersist -LDFLAGS+=$(PYTHON_LIBS) $(QT_MT_LIBS) -LIBS+= -lsuit -lstd -lCAM -lObjBrowser -lLogWindow $(CAS_KERNEL) -lGLViewer -lOCCViewer -lVTKViewer -lSalomeObject -lSOCC -lSVTK -lSPlot2d -lSUPERVGraph -lPyInterp -lPythonConsole - #$(HDF5_LIBS) -lSalomeHDFPersistCopy +ifneq ($(DISABLE_SALOMEOBJECT),yes) + LIBS+= -lSalomeObject +endif +ifneq ($(DISABLE_VTKVIEWER),yes) + LIBS+= -lVTKViewer +ifneq ($(DISABLE_SALOMEOBJECT),yes) + LIBS+= -lSVTK +endif +endif +ifneq ($(DISABLE_OCCVIEWER),yes) + LIBS+= -lOCCViewer +ifneq ($(DISABLE_SALOMEOBJECT),yes) + LIBS+= -lSOCC +endif +endif +ifneq ($(DISABLE_GLVIEWER),yes) + LIBS+= -lGLViewer +endif +ifneq ($(DISABLE_PLOT2DVIEWER),yes) + LIBS+= -lPlot2d +ifneq ($(DISABLE_SALOMEOBJECT),yes) + LIBS+= -lSPlot2d +endif +endif +ifneq ($(DISABLE_PYCONSOLE),yes) + LIBS+= -lPyInterp -lPythonConsole +endif +ifneq ($(DISABLE_SUPERVGRAPHVIEWER),yes) + LIBS+= -lSUPERVGraph +endif @CONCLUDE@ diff --git a/src/LightApp/resources/LightApp.xml b/src/LightApp/resources/LightApp.xml index 2a4932e04..cab85581e 100644 --- a/src/LightApp/resources/LightApp.xml +++ b/src/LightApp/resources/LightApp.xml @@ -1,10 +1,10 @@
- - - - - + + + + +
diff --git a/src/LightApp/resources/LightApp_msg_en.po b/src/LightApp/resources/LightApp_msg_en.po index c5b364d56..09f901332 100644 --- a/src/LightApp/resources/LightApp_msg_en.po +++ b/src/LightApp/resources/LightApp_msg_en.po @@ -322,3 +322,9 @@ msgstr "&Cancel" msgid "LightApp_ModuleDlg::ActivateComponent_DESCRIPTION" msgstr "Create, open or load study." + +msgid "LightApp_NameDlg::TLT_RENAME" +msgstr "Rename" + +msgid "LightApp_NameDlg::NAME_LBL" +msgstr "Name: " diff --git a/src/Makefile.in b/src/Makefile.in index 332907b5c..fe29018cc 100755 --- a/src/Makefile.in +++ b/src/Makefile.in @@ -32,9 +32,52 @@ VPATH=.:@srcdir@ @COMMENCE@ -SUBDIRS = Qtx DDS QDS SUIT STD CAF CAM SUITApp VTKViewer OCCViewer GLViewer \ - LogWindow Event OBJECT Prs PyInterp PythonConsole ObjBrowser \ - RegistryDisplay Plot2d TOOLSGUI SOCC SVTK SPlot2d SUPERVGraph \ - LightApp Session SalomeApp SALOME_SWIG SALOME_PY SALOME_PYQT Style ResExporter +SUBDIRS = Qtx DDS QDS SUIT STD CAF CAM SUITApp LogWindow ObjBrowser Prs + +ifneq ($(DISABLE_SALOMEOBJECT),yes) + SUBDIRS += OBJECT +endif + +ifneq ($(DISABLE_GLVIEWER),yes) + SUBDIRS += GLViewer +endif + +ifneq ($(DISABLE_VTKVIEWER),yes) + SUBDIRS += VTKViewer +ifneq ($(DISABLE_SALOMEOBJECT),yes) + SUBDIRS += SVTK +endif +endif +ifneq ($(DISABLE_OCCVIEWER),yes) + SUBDIRS += OCCViewer +ifneq ($(DISABLE_SALOMEOBJECT),yes) + SUBDIRS += SOCC +endif +endif +ifneq ($(DISABLE_PYCONSOLE),yes) + SUBDIRS += PyInterp PythonConsole +endif +ifneq ($(DISABLE_PLOT2DVIEWER),yes) + SUBDIRS += Plot2d +ifneq ($(DISABLE_SALOMEOBJECT),yes) + SUBDIRS += SPlot2d +endif +endif +ifneq ($(DISABLE_SUPERVGRAPHVIEWER),yes) + SUBDIRS += SUPERVGraph +endif +SUBDIRS += LightApp Style ResExporter + +ifneq ($(GUI_DISABLE_CORBA),yes) + SUBDIRS += RegistryDisplay TOOLSGUI \ + Event Session SalomeApp SALOME_SWIG SALOME_PY SALOME_PYQT +endif + +ifeq (@cppunit_ok@,yes) +ifneq ($(GUI_DISABLE_CORBA),yes) + SUBDIRS+= \ + SalomeApp/Test +endif +endif @MODULE@ diff --git a/src/OBJECT/Makefile.in b/src/OBJECT/Makefile.in index 0fb5e50a7..9171c05f6 100755 --- a/src/OBJECT/Makefile.in +++ b/src/OBJECT/Makefile.in @@ -9,7 +9,6 @@ VPATH=.:@srcdir@:@top_srcdir@/idl EXPORT_HEADERS = SALOME_InteractiveObject.hxx \ Handle_SALOME_InteractiveObject.hxx \ - SALOME_GLOwner.h \ SALOME_AISShape.hxx \ Handle_SALOME_AISShape.hxx \ SALOME_AISObject.hxx \ @@ -32,7 +31,6 @@ EXPORT_HEADERS = SALOME_InteractiveObject.hxx \ LIB = libSalomeObject.la LIB_SRC = SALOME_InteractiveObject.cxx \ - SALOME_GLOwner.cxx \ SALOME_AISShape.cxx\ SALOME_AISObject.cxx\ SALOME_ListIO_0.cxx \ @@ -50,8 +48,8 @@ LIB_CLIENT_IDL = BIN = BIN_SRC = -CPPFLAGS+=$(PYTHON_INCLUDES) $(OCC_INCLUDES) $(VTK_INCLUDES) $(QT_INCLUDES) $(OGL_INCLUDES) -LDFLAGS+= $(PYTHON_LIBS) $(VTK_LIBS) $(QT_LIBS) $(OGL_LIBS) $(CAS_LDPATH) -lTKV3d -lVTKViewer -lsuit +CPPFLAGS+=$(QT_INCLUDES) $(OCC_INCLUDES) +LDFLAGS+= $(QT_LIBS) $(CAS_LDPATH) -lTKV3d @CONCLUDE@ diff --git a/src/OCCViewer/OCCViewer_VService.cxx b/src/OCCViewer/OCCViewer_VService.cxx index 662356c70..0c3deacf2 100755 --- a/src/OCCViewer/OCCViewer_VService.cxx +++ b/src/OCCViewer/OCCViewer_VService.cxx @@ -58,7 +58,7 @@ #include #include #include -#include +//#include #include #endif @@ -280,6 +280,7 @@ Handle(Aspect_WindowDriver) OCCViewer_VService::WindowDriver( const Standard_CSt Creates Xdps window driver [ static ] On Win32 the same as OCCViewer_VService::WindowDriver() */ +/* Handle(Aspect_WindowDriver) OCCViewer_VService::XdpsDriver( const Standard_CString aDisplay, const Standard_Integer ahiwin, const Standard_Integer alowin, @@ -298,7 +299,7 @@ Handle(Aspect_WindowDriver) OCCViewer_VService::XdpsDriver( const Standard_CStri return new Xdps_Driver( W ); #endif } - +*/ /*! Creates Xw window driver [ static ] On Win32 the same as OCCViewer_VService::WindowDriver() diff --git a/src/OCCViewer/OCCViewer_VService.h b/src/OCCViewer/OCCViewer_VService.h index 5de36371d..bef33f12a 100755 --- a/src/OCCViewer/OCCViewer_VService.h +++ b/src/OCCViewer/OCCViewer_VService.h @@ -115,11 +115,12 @@ public: const Standard_Integer hiwin, const Standard_Integer lowin, const Quantity_NameOfColor color = Quantity_NOC_GRAY69 ); - static Handle_Aspect_WindowDriver + /*static Handle_Aspect_WindowDriver XdpsDriver( const Standard_CString display, const Standard_Integer hiwin, const Standard_Integer lowin, const Quantity_NameOfColor color = Quantity_NOC_GRAY69 ); + */ static Handle_Aspect_WindowDriver ImageDriver( const Standard_CString display, const Standard_Integer hiwin, diff --git a/src/OCCViewer/OCCViewer_ViewWindow.cxx b/src/OCCViewer/OCCViewer_ViewWindow.cxx index 4900fd9de..dbd2618b6 100755 --- a/src/OCCViewer/OCCViewer_ViewWindow.cxx +++ b/src/OCCViewer/OCCViewer_ViewWindow.cxx @@ -851,37 +851,7 @@ void OCCViewer_ViewWindow::onClipping( bool on ) //**************************************************************** void OCCViewer_ViewWindow::onMemorizeView() { - double centerX, centerY, projX, projY, projZ, twist; - double atX, atY, atZ, eyeX, eyeY, eyeZ; - - Handle(V3d_View) aView3d = myViewPort->getView(); - - aView3d->Center( centerX, centerY ); - aView3d->Proj( projX, projY, projZ ); - aView3d->At( atX, atY, atZ ); - aView3d->Eye( eyeX, eyeY, eyeZ ); - twist = aView3d->Twist(); - - viewAspect params; - QString aName = QTime::currentTime().toString() + QString::fromLatin1( " h:m:s" ); - - params.scale = aView3d->Scale(); - params.centerX = centerX; - params.centerY = centerY; - params.projX = projX; - params.projY = projY; - params.projZ = projZ; - params.twist = twist; - params.atX = atX; - params.atY = atY; - params.atZ = atZ; - params.eyeX = eyeX; - params.eyeY = eyeY; - params.eyeZ = eyeZ; - params.name = aName; - - myModel->appendViewAspect( params ); - + myModel->appendViewAspect( getViewParams() ); } //**************************************************************** @@ -904,11 +874,11 @@ void OCCViewer_ViewWindow::performRestoring( const viewAspect& anItem ) Standard_Boolean prev = aView3d->SetImmediateUpdate( Standard_False ); aView3d->SetScale( anItem.scale ); aView3d->SetCenter( anItem.centerX, anItem.centerY ); - aView3d->SetProj( anItem.projX, anItem.projY, anItem.projZ ); aView3d->SetTwist( anItem.twist ); aView3d->SetAt( anItem.atX, anItem.atY, anItem.atZ ); aView3d->SetImmediateUpdate( prev ); aView3d->SetEye( anItem.eyeX, anItem.eyeY, anItem.eyeZ ); + aView3d->SetProj( anItem.projX, anItem.projY, anItem.projZ ); myRestoreFlag = 0; } @@ -980,3 +950,77 @@ void OCCViewer_ViewWindow::setCuttingPlane( bool on, const double x, const dou v->Update(); v->Redraw(); } + +/*! The method returns the visual parameters of this view as a viewAspect object + */ +viewAspect OCCViewer_ViewWindow::getViewParams() const +{ + double centerX, centerY, projX, projY, projZ, twist; + double atX, atY, atZ, eyeX, eyeY, eyeZ; + + Handle(V3d_View) aView3d = myViewPort->getView(); + + aView3d->Center( centerX, centerY ); + aView3d->Proj( projX, projY, projZ ); + aView3d->At( atX, atY, atZ ); + aView3d->Eye( eyeX, eyeY, eyeZ ); + twist = aView3d->Twist(); + + QString aName = QTime::currentTime().toString() + QString::fromLatin1( " h:m:s" ); + + viewAspect params; + params.scale = aView3d->Scale(); + params.centerX = centerX; + params.centerY = centerY; + params.projX = projX; + params.projY = projY; + params.projZ = projZ; + params.twist = twist; + params.atX = atX; + params.atY = atY; + params.atZ = atZ; + params.eyeX = eyeX; + params.eyeY = eyeY; + params.eyeZ = eyeZ; + params.name = aName; + + return params; +} + + +/*! The method returns the visual parameters of this view as a formated string + */ +QString OCCViewer_ViewWindow::getVisualParameters() +{ + viewAspect params = getViewParams(); + QString retStr; + retStr.sprintf( "%.12e*%.12e*%.12e*%.12e*%.12e*%.12e*%.12e*%.12e*%.12e*%.12e*%.12e*%.12e*%.12e", params.scale, + params.centerX, params.centerY, params.projX, params.projY, params.projZ, params.twist, + params.atX, params.atY, params.atZ, params.eyeX, params.eyeY, params.eyeZ ); + return retStr; +} + +/* The method restors visual parameters of this view from a formated string + */ +void OCCViewer_ViewWindow::setVisualParameters( const QString& parameters ) +{ + QStringList paramsLst = QStringList::split( '*', parameters, true ); + if ( paramsLst.size() == 13 ) { + viewAspect params; + params.scale = paramsLst[0].toDouble(); + params.centerX = paramsLst[1].toDouble(); + params.centerY = paramsLst[2].toDouble(); + params.projX = paramsLst[3].toDouble(); + params.projY = paramsLst[4].toDouble(); + params.projZ = paramsLst[5].toDouble(); + params.twist = paramsLst[6].toDouble(); + params.atX = paramsLst[7].toDouble(); + params.atY = paramsLst[8].toDouble(); + params.atZ = paramsLst[9].toDouble(); + params.eyeX = paramsLst[10].toDouble(); + params.eyeY = paramsLst[11].toDouble(); + params.eyeZ = paramsLst[12].toDouble(); + + performRestoring( params ); + } +} diff --git a/src/OCCViewer/OCCViewer_ViewWindow.h b/src/OCCViewer/OCCViewer_ViewWindow.h index b4f2bc8db..b6bda965a 100755 --- a/src/OCCViewer/OCCViewer_ViewWindow.h +++ b/src/OCCViewer/OCCViewer_ViewWindow.h @@ -62,6 +62,9 @@ public: void setCuttingPlane( bool on, const double x = 0 , const double y = 0 , const double z = 0, const double dx = 0, const double dy = 0, const double dz = 1); + + virtual QString getVisualParameters(); + virtual void setVisualParameters( const QString& parameters ); public slots: void onFrontView(); @@ -119,6 +122,8 @@ protected: virtual OperationType getButtonState(QMouseEvent* theEvent); + viewAspect getViewParams() const; + OperationType myOperation; OCCViewer_Viewer* myModel; OCCViewer_ViewPort3d* myViewPort; diff --git a/src/OCCViewer/resources/OCCViewer_msg_en.po b/src/OCCViewer/resources/OCCViewer_msg_en.po index ceab129bf..b856572ac 100755 --- a/src/OCCViewer/resources/OCCViewer_msg_en.po +++ b/src/OCCViewer/resources/OCCViewer_msg_en.po @@ -123,7 +123,7 @@ msgid "MNU_DUMP_VIEW" msgstr "Dump view" msgid "DSC_CLIPPING" -msgstr "Define clipping plane" +msgstr "Set clipping plane" msgid "MNU_CLIPPING" msgstr "Clipping" diff --git a/src/ObjBrowser/OB_Browser.cxx b/src/ObjBrowser/OB_Browser.cxx index 5b4bc28e3..dd6012af0 100755 --- a/src/ObjBrowser/OB_Browser.cxx +++ b/src/ObjBrowser/OB_Browser.cxx @@ -157,9 +157,9 @@ void OB_BrowserSync::updateItem( const ItemPtr& p ) const ItemPtr OB_BrowserSync::createItem( const ObjPtr& src, const ItemPtr& parent, const ItemPtr& after, - const bool asFirst ) const + const bool prepend ) const { - ItemPtr i = myBrowser ? dynamic_cast( myBrowser->createItem( src, parent, after, asFirst ) ) : 0; + ItemPtr i = myBrowser ? dynamic_cast( myBrowser->createItem( src, parent, after, prepend ) ) : 0; if( i ) i->setOpen( src->isOpen() ); return i; @@ -728,7 +728,7 @@ void OB_Browser::updateView( SUIT_DataObject* startObj ) if ( !startObj || startObj->root() != getRootObject() ) return; - if( startObj==myRoot ) + if ( startObj == myRoot ) { DataObjectList ch; myRoot->children( ch ); @@ -746,40 +746,32 @@ void OB_Browser::updateView( SUIT_DataObject* startObj ) { OB_BrowserSync sync( this ); OB_ListItem* local_item = dynamic_cast( listViewItem( local_root ) ); - - // QString srcName = ( local_root && !local_root->name().isNull() ) ? local_root->name() : ""; - // QString trgName = ( local_item && !local_item->text(0).isNull() ) ? local_item->text(0) : ""; - // printf( "--- OB_Browser::updateView() calls synchronize()_1: src = %s, trg = %s ---\n", srcName.latin1(), trgName.latin1() ); - synchronize( local_root, local_item, sync ); exist[local_root] = 0; } ItemMap::const_iterator anIt = exist.begin(), aLast = exist.end(); for( ; anIt!=aLast; anIt++ ) - if( anIt.data() ) + { + if( anIt.data() ) // exist[local_root]==1 -> this local root was NOT in data model, should be removed { removeReferences( anIt.data() ); OB_ListItem* item = dynamic_cast( anIt.data() ); if( item && myItems.contains( item->dataObject() ) ) delete anIt.data(); } + } } else { OB_BrowserSync sync( this ); OB_ListItem* startItem = dynamic_cast( listViewItem( startObj ) ); - - // QString srcName = ( startObj && !startObj->name().isNull() ) ? startObj->name() : ""; - // QString trgName = ( startItem && !startItem->text(0).isNull() ) ? startItem->text(0) : ""; - // printf( "--- OB_Browser::updateView() calls synchronize()_2: src = %s, trg = %s ---\n", srcName.latin1(), trgName.latin1() ); - synchronize( startObj, startItem, sync ); } } QListViewItem* OB_Browser::createItem( const SUIT_DataObject* o, QListViewItem* parent, - QListViewItem* after, const bool asFirstChild ) + QListViewItem* after, const bool prepend ) { QListView* lv = listView(); @@ -803,34 +795,57 @@ QListViewItem* OB_Browser::createItem( const SUIT_DataObject* o, QListViewItem* if ( parent ) { - if ( parent->childCount() && !after ) + if ( after ) { - after = parent->firstChild(); - while ( after->nextSibling() ) - after = after->nextSibling(); + if ( type == -1 ) + item = new OB_ListItem( obj, parent, after ); + else + item = new OB_CheckListItem( obj, parent, after, (QCheckListItem::Type)type ); } - - if ( after && !asFirstChild ) + else if ( prepend ) { if ( type == -1 ) - item = new OB_ListItem( obj, parent, after ); + item = new OB_ListItem( obj, parent ); else - item = new OB_CheckListItem( obj, parent, after, (QCheckListItem::Type)type ); + item = new OB_CheckListItem( obj, parent, (QCheckListItem::Type)type ); } - else + else // append { + after = parent->firstChild(); + while ( after && after->nextSibling() ) + after = after->nextSibling(); if ( type == -1 ) - item = new OB_ListItem( obj, parent ); + item = new OB_ListItem( obj, parent, after ); else - item = new OB_CheckListItem( obj, parent, (QCheckListItem::Type)type ); + item = new OB_CheckListItem( obj, parent, after, (QCheckListItem::Type)type ); } } - else // ROOT item + else { - if ( type == -1 ) - item = new OB_ListItem( obj, lv ); - else - item = new OB_CheckListItem( obj, lv, (QCheckListItem::Type)type ); + if ( after ) + { + if ( type == -1 ) + item = new OB_ListItem( obj, lv, after ); + else + item = new OB_CheckListItem( obj, lv, after, (QCheckListItem::Type)type ); + } + else if ( prepend ) + { + if ( type == -1 ) + item = new OB_ListItem( obj, lv ); + else + item = new OB_CheckListItem( obj, lv, (QCheckListItem::Type)type ); + } + else // append + { + after = lv->firstChild(); + while ( after && after->nextSibling() ) + after = after->nextSibling(); + if ( type == -1 ) + item = new OB_ListItem( obj, lv, after ); + else + item = new OB_CheckListItem( obj, lv, after, (QCheckListItem::Type)type ); + } } myItems.insert( obj, item ); diff --git a/src/Plot2d/Plot2d_ViewFrame.cxx b/src/Plot2d/Plot2d_ViewFrame.cxx index 30a25e808..35f4b5888 100755 --- a/src/Plot2d/Plot2d_ViewFrame.cxx +++ b/src/Plot2d/Plot2d_ViewFrame.cxx @@ -1918,3 +1918,43 @@ bool Plot2d_ViewFrame::print( const QString& file, const QString& format ) const return res; #endif } + +QString Plot2d_ViewFrame::getVisualParameters() +{ + double xmin, xmax, ymin, ymax, y2min, y2max; + getFitRanges( xmin, xmax, ymin, ymax, y2min, y2max ); + QString retStr; + retStr.sprintf( "%d*%d*%d*%.12e*%.12e*%.12e*%.12e*%.12e*%.12e", myXMode, + myYMode, mySecondY, xmin, xmax, ymin, ymax, y2min, y2max ); + return retStr; +} + +void Plot2d_ViewFrame::setVisualParameters( const QString& parameters ) +{ + QStringList paramsLst = QStringList::split( '*', parameters, true ); + if ( paramsLst.size() == 9 ) { + double xmin, xmax, ymin, ymax, y2min, y2max; + myXMode = paramsLst[0].toInt(); + myYMode = paramsLst[1].toInt(); + mySecondY = (bool)paramsLst[2].toInt(); + xmin = paramsLst[3].toDouble(); + xmax = paramsLst[4].toDouble(); + ymin = paramsLst[5].toDouble(); + ymax = paramsLst[6].toDouble(); + y2min = paramsLst[7].toDouble(); + y2max = paramsLst[8].toDouble(); + + if (mySecondY) + setTitle( myY2TitleEnabled, myY2Title, Y2Title, false ); + setHorScaleMode( myXMode, /*update=*/false ); + setVerScaleMode( myYMode, /*update=*/false ); + + if (mySecondY) { + QwtDiMap yMap2 = myPlot->canvasMap( QwtPlot::yRight ); + myYDistance2 = yMap2.d2() - yMap2.d1(); + } + + fitData( 0, xmin, xmax, ymin, ymax, y2min, y2max ); + fitData( 0, xmin, xmax, ymin, ymax, y2min, y2max ); + } +} diff --git a/src/Plot2d/Plot2d_ViewFrame.h b/src/Plot2d/Plot2d_ViewFrame.h index 51faa0898..5d1faccb5 100755 --- a/src/Plot2d/Plot2d_ViewFrame.h +++ b/src/Plot2d/Plot2d_ViewFrame.h @@ -118,6 +118,9 @@ public: virtual bool print( const QString& file, const QString& format ) const; + QString getVisualParameters(); + void setVisualParameters( const QString& parameters ); + protected: int testOperation( const QMouseEvent& ); void readPreferences(); diff --git a/src/Plot2d/Plot2d_ViewWindow.cxx b/src/Plot2d/Plot2d_ViewWindow.cxx index 5c558ea0f..017e8fada 100755 --- a/src/Plot2d/Plot2d_ViewWindow.cxx +++ b/src/Plot2d/Plot2d_ViewWindow.cxx @@ -465,3 +465,17 @@ QString Plot2d_ViewWindow::filter() const { return SUIT_ViewWindow::filter() + ";;" + tr( "POSTSCRIPT_FILES" ); } + +/*! The method returns the visual parameters of this view as a formated string + */ +QString Plot2d_ViewWindow::getVisualParameters() +{ + return myViewFrame->getVisualParameters(); +} + +/* The method restors visual parameters of this view from a formated string + */ +void Plot2d_ViewWindow::setVisualParameters( const QString& parameters ) +{ + myViewFrame->setVisualParameters( parameters ); +} diff --git a/src/Plot2d/Plot2d_ViewWindow.h b/src/Plot2d/Plot2d_ViewWindow.h index 571d692bf..ec0e5bf64 100755 --- a/src/Plot2d/Plot2d_ViewWindow.h +++ b/src/Plot2d/Plot2d_ViewWindow.h @@ -46,6 +46,9 @@ public: QToolBar* getToolBar() { return myToolBar; }; void contextMenuPopup( QPopupMenu* thePopup ); + virtual QString getVisualParameters(); + virtual void setVisualParameters( const QString& parameters ); + protected: virtual QImage dumpView(); virtual QString filter() const; diff --git a/src/PyInterp/PyInterp_base.cxx b/src/PyInterp/PyInterp_base.cxx index 69ccefc9d..0e0a5622c 100644 --- a/src/PyInterp/PyInterp_base.cxx +++ b/src/PyInterp/PyInterp_base.cxx @@ -112,8 +112,10 @@ void PyInterp_base::initialize() // Create cStringIO to capture stdout and stderr PycString_IMPORT; - _vout = PycStringIO->NewOutput(128); - _verr = PycStringIO->NewOutput(128); + if (PycStringIO) { // CTH11627 : additional check + _vout = PycStringIO->NewOutput(128); + _verr = PycStringIO->NewOutput(128); + } // All the initRun outputs are redirected to the standard output (console) initRun(); diff --git a/src/Qtx/Makefile.in b/src/Qtx/Makefile.in index aa682b59d..02f58984b 100755 --- a/src/Qtx/Makefile.in +++ b/src/Qtx/Makefile.in @@ -1,4 +1,5 @@ -# File : Makefile.in # Author : Vladimir Klyachin (OCN) +# File : Makefile.in +# Author : Vladimir Klyachin (OCN) # Module : suit # $Header$ diff --git a/src/Qtx/QtxActionMenuMgr.cxx b/src/Qtx/QtxActionMenuMgr.cxx index 7782a7b57..2d09b2d09 100644 --- a/src/Qtx/QtxActionMenuMgr.cxx +++ b/src/Qtx/QtxActionMenuMgr.cxx @@ -40,7 +40,7 @@ class QtxActionMenuMgr::MenuAction : public QtxAction { public: - MenuAction( const QString&, const QString&, QObject* ); + MenuAction( const QString&, const QString&, QObject*, const bool = false ); virtual ~MenuAction(); virtual bool addTo( QWidget* ); @@ -52,12 +52,17 @@ public: private: int myId; QPopupMenu* myPopup; + bool myEmptyEnabled; }; -QtxActionMenuMgr::MenuAction::MenuAction( const QString& text, const QString& menuText, QObject* parent ) +QtxActionMenuMgr::MenuAction::MenuAction( const QString& text, + const QString& menuText, + QObject* parent, + const bool allowEmpty ) : QtxAction( text, menuText, 0, parent ), -myId( -1 ), -myPopup( 0 ) + myId( -1 ), + myPopup( 0 ), + myEmptyEnabled( allowEmpty ) { myPopup = new QPopupMenu(); } @@ -75,6 +80,12 @@ bool QtxActionMenuMgr::MenuAction::addTo( QWidget* w ) if ( !w->inherits( "QPopupMenu" ) && !w->inherits( "QMenuBar" ) ) return false; + if ( !myPopup ) + return false; + + if ( !myEmptyEnabled && !myPopup->count() ) + return false; + if ( w->inherits( "QPopupMenu" ) && QAction::addTo( w ) ) { QPopupMenu* pm = (QPopupMenu*)w; @@ -126,8 +137,11 @@ myMenu( p ? p->menuBar() : 0 ) myRoot.id = -1; myRoot.group = -1; - if ( myMenu ) + if ( myMenu ) { connect( myMenu, SIGNAL( destroyed( QObject* ) ), this, SLOT( onDestroyed( QObject* ) ) ); + if ( myMenu->inherits( "QMenuBar" ) ) + connect( myMenu, SIGNAL( highlighted( int ) ), this, SLOT( onHighlighted( int ) ) ); + } } QtxActionMenuMgr::QtxActionMenuMgr( QWidget* mw, QObject* p ) @@ -209,12 +223,10 @@ int QtxActionMenuMgr::insert( const int id, const int pId, const int group, cons MenuNode* node = new MenuNode( pNode ); node->id = id; + node->idx = idx; node->group = group; - if ( idx < 0 || idx >= (int)pNode->children.count() ) - pNode->children.append( node ); - else - pNode->children.insert( idx, node ); + pNode->children.append( node ); updateMenu( pNode, false ); @@ -226,53 +238,54 @@ int QtxActionMenuMgr::insert( QAction* a, const int pId, const int group, const return insert( registerAction( a ), pId, group, idx ); } -int QtxActionMenuMgr::insert( const QString& title, const int pId, const int group, const int idx ) +int QtxActionMenuMgr::insert( const QString& title, const int pId, const int group, const int id, const int idx, const bool allowEmpty ) { MenuNode* pNode = pId == -1 ? &myRoot : find( pId ); if ( !pNode ) return -1; - int id = -1; - for ( NodeListIterator it( pNode->children ); it.current() && id == -1; ++it ) + MenuNode* eNode = id == -1 ? 0 : find( id ); + + int fid = -1; + for ( NodeListIterator it( pNode->children ); it.current() && fid == -1; ++it ) { if ( myMenus.contains( it.current()->id ) && clearTitle( myMenus[it.current()->id]->menuText() ) == clearTitle( title ) ) - id = it.current()->id; + fid = it.current()->id; } - if ( id != -1 ) - return id; + if ( fid != -1 ) + return fid; - MenuAction* ma = new MenuAction( clearTitle( title ), title, this ); + MenuAction* ma = new MenuAction( clearTitle( title ), title, this, allowEmpty ); + connect( ma->popup(), SIGNAL( highlighted( int ) ), this, SLOT( onHighlighted( int ) ) ); MenuNode* node = new MenuNode( pNode ); node->group = group; - node->id = myMenus.insert( generateId(), ma ).key(); + node->idx = idx; + node->id = myMenus.insert( (id == -1 || eNode ) ? generateId() : id, ma ).key(); - if ( idx < 0 || idx >= (int)pNode->children.count() ) - pNode->children.append( node ); - else - pNode->children.insert( idx, node ); + pNode->children.append( node ); updateMenu( pNode, false ); return node->id; } -int QtxActionMenuMgr::insert( const QString& title, const QString& menus, const int group, const int idx ) +int QtxActionMenuMgr::insert( const QString& title, const QString& menus, const int group, const int id, const int idx, const bool allowEmpty ) { - return insert( title, QStringList::split( "|", menus ), group, idx ); + return insert( title, QStringList::split( "|", menus ), group, id, idx, allowEmpty ); } -int QtxActionMenuMgr::insert( const QString& title, const QStringList& menus, const int group, const int idx ) +int QtxActionMenuMgr::insert( const QString& title, const QStringList& menus, const int group, const int id, const int idx, const bool allowEmpty ) { int pId = createMenu( menus, -1 ); - return insert( title, pId, group, idx ); + return insert( title, pId, group, id, idx, allowEmpty ); } -int QtxActionMenuMgr::append( const QString& title, const int pId, const int group ) +int QtxActionMenuMgr::append( const QString& title, const int pId, const int group, const int id, const bool allowEmpty ) { - return insert( title, pId, group ); + return insert( title, pId, group, id, allowEmpty ); } int QtxActionMenuMgr::append( const int id, const int pId, const int group ) @@ -285,9 +298,9 @@ int QtxActionMenuMgr::append( QAction* a, const int pId, const int group ) return insert( a, pId, group ); } -int QtxActionMenuMgr::prepend( const QString& title, const int pId, const int group ) +int QtxActionMenuMgr::prepend( const QString& title, const int pId, const int group, const int id, const bool allowEmpty ) { - return insert( title, pId, group, 0 ); + return insert( title, pId, group, id, 0, allowEmpty ); } int QtxActionMenuMgr::prepend( const int id, const int pId, const int group ) @@ -308,7 +321,7 @@ void QtxActionMenuMgr::remove( const int id ) void QtxActionMenuMgr::remove( const int id, const int pId, const int group ) { - MenuNode* pNode = find( pId ); + MenuNode* pNode = pId == -1 ? &myRoot : find( pId ); if ( !pNode ) return; @@ -369,6 +382,30 @@ void QtxActionMenuMgr::onDestroyed( QObject* obj ) myMenu = 0; } +void QtxActionMenuMgr::onHighlighted( int id ) +{ + const QObject* snd = sender(); + int pid = 0, realId; + if ( myMenu && snd == myMenu ) + pid = -1; + else { + for ( MenuMap::Iterator itr = myMenus.begin(); itr != myMenus.end(); ++itr ) { + if ( itr.data()->popup() && itr.data()->popup() == snd ) + pid = itr.key(); + } + } + if ( pid ) { + realId = findId( id, pid ); + if ( realId != -1 ) { + bool updatesEnabled = isUpdatesEnabled(); + setUpdatesEnabled( false ); + emit menuHighlighted( pid, realId ); + setUpdatesEnabled( updatesEnabled ); + updateMenu( find( realId ) ); + } + } +} + void QtxActionMenuMgr::setWidget( QWidget* mw ) { if ( myMenu == mw ) @@ -383,12 +420,12 @@ void QtxActionMenuMgr::setWidget( QWidget* mw ) connect( myMenu, SIGNAL( destroyed( QObject* ) ), this, SLOT( onDestroyed( QObject* ) ) ); } -QtxActionMenuMgr::MenuNode* QtxActionMenuMgr::find( const int actId, const int pId ) const +QtxActionMenuMgr::MenuNode* QtxActionMenuMgr::find( const int actId, const int pId, const bool rec ) const { - return find( actId, find( pId ) ); + return find( actId, find( pId ), rec ); } -QtxActionMenuMgr::MenuNode* QtxActionMenuMgr::find( const int id, MenuNode* startNode ) const +QtxActionMenuMgr::MenuNode* QtxActionMenuMgr::find( const int id, MenuNode* startNode, const bool rec ) const { MenuNode* node = 0; MenuNode* start = startNode ? startNode : (MenuNode*)&myRoot; @@ -396,8 +433,8 @@ QtxActionMenuMgr::MenuNode* QtxActionMenuMgr::find( const int id, MenuNode* star { if ( it.current()->id == id ) node = it.current(); - else - node = find( id, it.current() ); + else if ( rec ) + node = find( id, it.current(), rec ); } return node; } @@ -415,6 +452,55 @@ bool QtxActionMenuMgr::find( const int id, NodeList& lst, MenuNode* startNode ) return !lst.isEmpty(); } +QtxActionMenuMgr::MenuNode* QtxActionMenuMgr::find( const QString& title, const int pId, const bool rec ) const +{ + return find( title, find( pId ), rec ); +} + +bool QtxActionMenuMgr::find( const QString& title, NodeList& lst, MenuNode* startNode ) const +{ + MenuNode* start = startNode ? startNode : (MenuNode*)&myRoot; + for ( NodeListIterator it( start->children ); it.current(); ++it ) + { + QAction* a = itemAction( it.current()->id ); + if ( !a ) + a = menuAction( it.current()->id ); + if ( a && clearTitle( a->menuText() ) == clearTitle( title ) ) + lst.prepend( it.current() ); + + find( title, lst, it.current() ); + } + return !lst.isEmpty(); +} + +QtxActionMenuMgr::MenuNode* QtxActionMenuMgr::find( const QString& title, MenuNode* startNode, const bool rec ) const +{ + MenuNode* node = 0; + MenuNode* start = startNode ? startNode : (MenuNode*)&myRoot; + for ( NodeListIterator it( start->children ); it.current() && !node; ++it ) + { + QAction* a = itemAction( it.current()->id ); + if ( !a ) + a = menuAction( it.current()->id ); + if ( a && clearTitle( a->menuText() ) == clearTitle( title ) ) + node = it.current(); + if ( !node && rec ) + node = find( title, it.current(), rec ); + } + return node; +} + +int QtxActionMenuMgr::findId( const int id, const int pid ) const +{ + MenuNode* start = pid != -1 ? find( pid ) : (MenuNode*)&myRoot; + if ( start ) { + for ( NodeListIterator it( start->children ); it.current(); ++it ) { + if ( it.current()->id == id ) return id; + } + } + return -1; +} + void QtxActionMenuMgr::removeMenu( const int id, MenuNode* startNode ) { MenuNode* start = startNode ? startNode : &myRoot; @@ -465,23 +551,20 @@ void QtxActionMenuMgr::updateMenu( MenuNode* startNode, const bool rec, const bo a->removeFrom( mw ); } - if ( node != &myRoot ) - { - if ( mw->inherits( "QMenuBar" ) ) - ((QMenuBar*)mw)->clear(); - else if ( mw->inherits( "QPopupMenu" ) ) - ((QPopupMenu*)mw)->clear(); - } + if ( mw->inherits( "QMenuBar" ) ) + ((QMenuBar*)mw)->clear(); + else if ( mw->inherits( "QPopupMenu" ) ) + ((QPopupMenu*)mw)->clear(); QMap idMap; for ( NodeListIterator it2( node->children ); it2.current(); ++it2 ) { - MenuNode* par = it2.current()->parent; - if ( isVisible( it2.current()->id, par ? par->id : -1 ) ) - { - NodeList& lst = idMap[it2.current()->group]; + NodeList& lst = idMap[it2.current()->group]; + int idx = it2.current()->idx; + if ( idx < 0 || idx >= lst.count() ) lst.append( it2.current() ); - } + else + lst.insert( idx, it2.current() ); } QIntList groups = idMap.keys(); @@ -498,17 +581,27 @@ void QtxActionMenuMgr::updateMenu( MenuNode* startNode, const bool rec, const bo const NodeList& lst = idMap[*gIt]; for ( NodeListIterator iter( lst ); iter.current(); ++iter ) { + MenuNode* par = iter.current()->parent; + if ( !isVisible( iter.current()->id, par ? par->id : -1 ) ) + continue; + if ( rec ) updateMenu( iter.current(), rec, false ); QAction* a = itemAction( iter.current()->id ); - if ( a ) - a->addTo( mw ); - else - { - MenuAction* ma = menuAction( iter.current()->id ); - if ( ma && ma->popup() && ma->popup()->count() ) - ma->addTo( mw ); + if ( !a ) + a = menuAction( iter.current()->id ); + if ( a ) { + QMenuData* md = dynamic_cast( mw ); + int cnt = 0; + if ( md ) cnt = md->count(); + a->addTo( mw ); + if ( md && md->count() - cnt == 1 ) { //&& iter.current()->id > 0 + int lid = md->idAt( cnt ); + QMenuItem* mi = md->findItem( lid ); + if ( mi && !mi->isSeparator() ) + md->setId( cnt, iter.current()->id ); + } } } } @@ -590,6 +683,15 @@ bool QtxActionMenuMgr::load( const QString& fname, QtxActionMgr::Reader& r ) return r.read( fname, cr ); } +bool QtxActionMenuMgr::containsMenu( const QString& title, const int pid ) const +{ + return (bool)find( title, pid, false ); +} + +bool QtxActionMenuMgr::containsMenu( const int id, const int pid ) const +{ + return (bool)find( id, pid, false ); +} /*! Class: QtxActionMenuMgr::MenuCreator diff --git a/src/Qtx/QtxActionMenuMgr.h b/src/Qtx/QtxActionMenuMgr.h index 89b81aa89..f06ff9d3b 100644 --- a/src/Qtx/QtxActionMenuMgr.h +++ b/src/Qtx/QtxActionMenuMgr.h @@ -51,6 +51,7 @@ class QTX_EXPORT QtxActionMenuMgr : public QtxActionMgr MenuNode( MenuNode* p ) : parent( p ), visible( true ) { children.setAutoDelete( true ); }; int id; + int idx; int group; MenuNode* parent; bool visible; @@ -79,17 +80,17 @@ public: virtual int insert( const int, const int, const int, const int = -1 ); int insert( QAction*, const int, const int, const int = -1 ); - int insert( const QString&, const QString&, const int, const int = -1 ); - int insert( const QString&, const QStringList&, const int, const int = -1 ); - virtual int insert( const QString&, const int, const int, const int = -1 ); + int insert( const QString&, const QString&, const int, const int = -1, const int = -1, const bool = false ); + int insert( const QString&, const QStringList&, const int, const int = -1, const int = -1, const bool = false ); + virtual int insert( const QString&, const int, const int, const int = -1, const int = -1, const bool = false ); int append( const int, const int, const int ); int append( QAction*, const int, const int ); - int append( const QString&, const int, const int ); + int append( const QString&, const int, const int, const int = -1, const bool = false ); int prepend( const int, const int, const int ); int prepend( QAction*, const int, const int ); - int prepend( const QString&, const int, const int ); + int prepend( const QString&, const int, const int, const int = -1, const bool = false ); void remove( const int ); void remove( const int, const int, const int = -1 ); @@ -102,14 +103,26 @@ public: virtual bool load( const QString&, QtxActionMgr::Reader& ); + bool containsMenu( const QString&, const int ) const; + bool containsMenu( const int, const int ) const; + + private slots: void onDestroyed( QObject* ); + void onHighlighted( int ); + +signals: + void menuHighlighted( int, int ); protected: void setWidget( QWidget* ); - MenuNode* find( const int, const int ) const; - MenuNode* find( const int, MenuNode* = 0 ) const; + MenuNode* find( const int, const int, const bool = true ) const; + MenuNode* find( const int, MenuNode* = 0, const bool = true ) const; bool find( const int, NodeList&, MenuNode* = 0 ) const; + MenuNode* find( const QString&, const int, const bool = true ) const; + MenuNode* find( const QString&, MenuNode* = 0, const bool = true ) const; + bool find( const QString&, NodeList&, MenuNode* = 0 ) const; + int findId( const int, const int = -1 ) const; void removeMenu( const int, MenuNode* ); diff --git a/src/Qtx/QtxActionToolMgr.cxx b/src/Qtx/QtxActionToolMgr.cxx index f797306f0..b9ff56c8f 100644 --- a/src/Qtx/QtxActionToolMgr.cxx +++ b/src/Qtx/QtxActionToolMgr.cxx @@ -227,6 +227,20 @@ bool QtxActionToolMgr::hasToolBar( const QString& tname ) const return find( tname ) != -1; } +bool QtxActionToolMgr::containsAction( const int id, const int tid ) const +{ + for ( ToolBarMap::ConstIterator it = myToolBars.begin(); it != myToolBars.end(); ++it ) + { + if ( tid == -1 || it.key() == tid ) { + const NodeList& list = it.data().nodes; + for ( NodeList::const_iterator nit = list.begin(); nit != list.end(); ++nit ) + if ( (*nit).id == id ) + return true; + } + } + return false; +} + void QtxActionToolMgr::onToolBarDestroyed() { myToolBars.remove( find( (QToolBar*)sender() ) ); diff --git a/src/Qtx/QtxActionToolMgr.h b/src/Qtx/QtxActionToolMgr.h index 31c02209d..48a722785 100644 --- a/src/Qtx/QtxActionToolMgr.h +++ b/src/Qtx/QtxActionToolMgr.h @@ -95,6 +95,8 @@ public: bool hasToolBar( const int ) const; bool hasToolBar( const QString& ) const; + bool containsAction( const int, const int = -1 ) const; + virtual bool load( const QString&, QtxActionMgr::Reader& ); protected slots: diff --git a/src/Qtx/QtxColorScale.h b/src/Qtx/QtxColorScale.h index 1037fd621..fa81c0d1a 100755 --- a/src/Qtx/QtxColorScale.h +++ b/src/Qtx/QtxColorScale.h @@ -152,7 +152,9 @@ private: QSize calculateSize( const bool, const int, const bool, const bool, const bool ) const; - friend class Dock; +#if QT_VER == 3 + friend class QtxColorScale::Dock; +#endif private: double myMin; diff --git a/src/Qtx/QtxDirListEditor.cxx b/src/Qtx/QtxDirListEditor.cxx index 0532cd77f..9ddfd7c3d 100644 --- a/src/Qtx/QtxDirListEditor.cxx +++ b/src/Qtx/QtxDirListEditor.cxx @@ -206,6 +206,18 @@ QtxDirListEditor::~QtxDirListEditor() */ void QtxDirListEditor::getPathList(QStringList& list) { + // Finish the path editing + if (myEdit) { + validate(true); + + myEdit->deleteLater(); + myBtn->deleteLater(); + myEdit = 0; + myBtn = 0; + myEdited = false; + myDirList->setFocus(); + } + list.clear(); for (unsigned i = 0; i < myDirList->count()-1; i++) list.append(myDirList->text(i)); @@ -224,11 +236,11 @@ void QtxDirListEditor::setPathList(const QStringList& list) { /*! Validates entered path, returns true if OK */ -bool QtxDirListEditor::validate() +bool QtxDirListEditor::validate( const bool quietMode ) { if ( myEdited ) { - QString dirPath = QFileInfo( myEdit->text().stripWhiteSpace() ).absFilePath(); + QString dirPath = QFileInfo( myEdit->text().stripWhiteSpace() ).filePath(); /* #ifndef WNT if ( dirPath.startsWith( "~") ) { @@ -285,20 +297,21 @@ bool QtxDirListEditor::validate() if (found) { if (found != myLastSelected) { // it is forbidden to add directory more then once - QMessageBox::critical(this, - tr("Error"), - tr("Directory already specified."), - tr("Ok")); + if ( !quietMode ) + QMessageBox::critical(this, + tr("Error"), + tr("Directory already specified."), + tr("Ok")); myEdit->setFocus(); return false; } } else { if (!dir.exists()) { - if ( QMessageBox::information(this, - tr("Warning"), - tr("%1\n\nThe directory doesn't exist.\nAdd directory anyway?").arg(dir.absPath()), - tr("Yes"), tr("No"), QString::null, 1, 1) == 1) { + if ( !quietMode && QMessageBox::information(this, + tr("Warning"), + tr("%1\n\nThe directory doesn't exist.\nAdd directory anyway?").arg(dir.absPath()), + tr("Yes"), tr("No"), QString::null, 1, 1) == 1) { myEdit->setFocus(); return false; } diff --git a/src/Qtx/QtxDirListEditor.h b/src/Qtx/QtxDirListEditor.h index 95e84228e..7851fc83a 100644 --- a/src/Qtx/QtxDirListEditor.h +++ b/src/Qtx/QtxDirListEditor.h @@ -74,7 +74,7 @@ protected: * \brief Validates entered path * \retval bool - returns status (true if OK) */ - bool validate(); + bool validate( const bool quietMode = false ); /*! * \brief Appends/changes path diff --git a/src/Qtx/QtxDockAction.cxx b/src/Qtx/QtxDockAction.cxx index 89e72344c..0a0295559 100755 --- a/src/Qtx/QtxDockAction.cxx +++ b/src/Qtx/QtxDockAction.cxx @@ -28,6 +28,7 @@ #include #include #include +#include #include /*! @@ -707,7 +708,36 @@ void QtxDockAction::dockWindows( QPtrList& lst, QMainWindow* main ) if ( !mw ) return; - lst = mw->dockWindows(); + QObjectList* objs = mw->queryList( "QDockWindow" ); + if ( objs ) + { + for ( QObjectListIt it( *objs ); it.current(); ++it ) + { + QDockWindow* dockWin = ::qt_cast( it.current() ); + if ( dockWin && dockMainWindow( mw, dockWin ) ) + lst.append( dockWin ); + } + } + delete objs; +} + +bool QtxDockAction::dockMainWindow( QMainWindow* mw, QObject* win ) const +{ + if ( !mw || !win ) + return false; + + while ( win ) + { + if ( win->parent() && win->parent() == mw ) + return true; + + if ( ::qt_cast( win->parent() ) ) + return false; + + win = win->parent(); + } + + return false; } /*! @@ -772,6 +802,14 @@ void QtxDockAction::loadPlaceInfo( QDockWindow* dw ) const if ( !myInfo.contains( dw ) ) return; + QMainWindow* mw = mainWindow(); + if ( !mw ) + return; + + QObject* p = dw->parent(); + if ( !( !p || p == mw || ( p->parent() && p->parent() == mw ) ) ) + return; + QString winName = myInfo[dw].name; if ( winName.isEmpty() || !myGeom.contains( winName ) ) return; @@ -807,6 +845,10 @@ void QtxDockAction::loadPlaceInfo() const QMap nameMap; for ( QPtrListIterator itr( lst ); itr.current(); ++itr ) { + QObject* p = itr.current()->parent(); + if ( !( !p || p == mw || ( p->parent() && p->parent() == mw ) ) ) + continue; + QString name; if ( myInfo.contains( itr.current() ) ) name = myInfo[itr.current()].name; diff --git a/src/Qtx/QtxDockAction.h b/src/Qtx/QtxDockAction.h index 4583bebda..5e3ae2de8 100755 --- a/src/Qtx/QtxDockAction.h +++ b/src/Qtx/QtxDockAction.h @@ -121,6 +121,8 @@ private: void updateMenus(); + bool dockMainWindow( QMainWindow*, QObject* ) const; + private: enum { AutoAdd = QEvent::User, LoadArea }; diff --git a/src/Qtx/QtxListResourceEdit.cxx b/src/Qtx/QtxListResourceEdit.cxx index 60a5fbe4c..038e189b7 100644 --- a/src/Qtx/QtxListResourceEdit.cxx +++ b/src/Qtx/QtxListResourceEdit.cxx @@ -39,6 +39,7 @@ #include #include #include +#include #include "QtxIntSpinBox.h" #include "QtxDblSpinBox.h" @@ -1130,6 +1131,9 @@ void QtxListResourceEdit::FontItem::setFamily( const QString& f ) if( deffam.canCast( QVariant::String ) ) curtext = deffam.toString(); } + + if ( curtext.isEmpty() ) + curtext = (QApplication::font()).family(); int idx = -1; for ( int i = 0; i < (int)myFamilies->count() && idx < 0; i++ ) diff --git a/src/Qtx/QtxWorkstack.cxx b/src/Qtx/QtxWorkstack.cxx index c267236f2..5e01f08e8 100644 --- a/src/Qtx/QtxWorkstack.cxx +++ b/src/Qtx/QtxWorkstack.cxx @@ -36,8 +36,10 @@ #include #include #include +#include #define DARK_COLOR_LIGHT 250 + /*! Class: QtxWorkstack [Public] Descr: @@ -1131,6 +1133,266 @@ void QtxWorkstack::updateState( QSplitter* split ) split->hide(); } +void QtxWorkstack::splitterInfo( QSplitter* split, QString& info ) const +{ + if ( !split ) + return; + + const QObjectList* objs = split->children(); + if ( objs ) + { + // make up a sizes string: integer values are separated by ':' char + QValueList sizes = split->sizes(); + QString sizesStr; + for ( QValueList::Iterator sIt = sizes.begin(); sIt != sizes.end(); ++sIt ) { + if ( *sIt > 1 ) // size 1 pixel usually means empty Workstack area, which will NOT be re-created, + sizesStr += QString( ":%1" ).arg( *sIt ); // so we don't need to store its size + } + if ( !sizesStr.isEmpty() ) // cut the first ':' + sizesStr = sizesStr.right( sizesStr.length()-1 ); + + // count all QSplitter-s and QtxWorkstackArea-s + // int nChilds( 0 ); + // QObjectListIt it( *objs ); + // for ( ; it.current(); ++it ) + // { + // if ( it.current()->inherits( "QSplitter" ) || + // it.current()->inherits( "QtxWorkstackArea" ) ) + // nChilds++; + // } + + info += QString( "(splitter orientation=%1 sizes=%3 " ).arg( split->orientation() ).arg( sizesStr ); + + for ( QObjectListIt it( *objs ); it.current(); ++it ) + { + if ( it.current()->inherits( "QSplitter" ) ) + splitterInfo( (QSplitter*)it.current(), info ); + else if ( it.current()->inherits( "QtxWorkstackArea" ) ) { + QtxWorkstackArea* area = (QtxWorkstackArea*)it.current(); + if ( area->isEmpty() ) + continue; + info += QString( "(views active='%1'" ).arg( area->activeWidget()->name() ); + QWidgetList views = area->widgetList(); + for ( QWidgetListIt wIt( views ); wIt.current(); ++wIt ) + info += QString( " '%1'" ).arg( wIt.current()->name() ); + info += ')'; + } + } + } + info += ')'; +} + + +// cuts starting '(' symbol and ending '(' symbol +void cutBrackets( QString& parameters ) +{ + if ( !parameters.isEmpty() && parameters[0] == '(' && parameters[parameters.length()-1] == ')' ) + parameters = parameters.mid( 1, parameters.length()-2 ); +} + +// for strings like "(splitter orientation=0 children=2 sizes=332:478" returns values of +// parameters. For example, getValue( example, "children" ) returns "2" +// getValue( example, "sizes" ) returns "332:478" +QString getValue( const QString& str, const QString& valName ) +{ + int i = str.find( valName ); + if ( i != -1 ) { + int equal_i = str.find( '=', i ); + if ( equal_i != -1 ) { + int space_i = str.find( ' ', ++equal_i ); + if ( space_i != -1 ) + return str.mid( equal_i, space_i-equal_i ); + } + } + return QString( "" ); +} + +// checks format of splitter parameters string +bool checkFormat( const QString& parameters ) +{ + QString params( parameters ); + // 1. begins and ends with brackets + bool ok = ( params[0] == '(' && params[params.length()-1] == ')' ); + if ( !ok ) return ok; + ::cutBrackets( params ); + // 2. has splitter word + ok = ( params.left( 8 ) == "splitter" ); + if ( !ok ) return ok; + // 3. has children? = '(' is found + int i = params.find( '(' ); + ok = i != -1; + if ( !ok ) return ok; + params = params.left( i ); // cut all children, they will be checked later + // 4. has orientation word and correct value + ::getValue( params, "orientation" ).toInt( &ok ); + if ( !ok ) return ok; + // 5. has sizes word and values + ok = ! ::getValue( params, "sizes" ).isEmpty(); + if ( !ok ) return ok; + // 6. check children -> number of '(' == number of ')' in original string + ok = ( parameters.contains( '(' ) == parameters.contains( ')' ) ); + return ok; +} + +// returns children of splitter in a list. Children are separated by '(' and ')' symbols +QStringList getChildren( const QString& str ) +{ + QStringList lst; + if ( !str.startsWith( "(" ) ) + return lst; + + int i = 1, + nOpen = 1, // count brackets: '(' increments nOpen, ')' decrements + start = 0; + while ( i < str.length() ) { + if ( str[i] == '(' ) { + nOpen++; + if ( nOpen == 1 ) + start = i; + } + else if ( str[i] == ')' ) { + nOpen--; + if ( nOpen == 0 ) + lst.append( str.mid( start, i-start+1 ) ); + } + i++; + } + + return lst; +} + +// for a string like "views active='AnotherView' 'GLView' 'AnotherView'" +// getViewName( example, 0 ) returns "GLView", +// getViewName( example, 1 ) -> "AnotherView", etc. +QString getViewName( const QString& str, int i ) +{ + QRegExp exp( "\\s'\\w+'" ); + int start = 0; // start index of view name in the string + int num = 0 ; // index of found match + while ( ( start = exp.search( str, start ) ) != -1 && num < i ) { + start += exp.matchedLength(); + num ++; + } + if ( start != -1 ) // +2 and -3 avoid starting space and starting and ending ' symbols + return str.mid( start+2, exp.matchedLength()-3 ); + + return QString( "" ); +} + +// returns widget with given name +QWidget* getView( const QWidget* parent, const QString& aName ) +{ + QWidget* view = 0; + QObjectList *l = parent->topLevelWidget()->queryList( "QWidget", aName, false, true ); + if ( !l->isEmpty() ) + view = dynamic_cast( l->first() ); + delete l; + return view; +} + +// installs a splitter described by given parameters string +void QtxWorkstack::setSplitter( QSplitter* splitter, const QString& parameters, QMap< QSplitter*, QValueList >& sMap ) +{ + if ( !::checkFormat( parameters ) ) { + printf( "\nInvalid format of workstack parameters. Positions of viewers can not be restored.\n" ); + return; + } + + QString params( parameters ); + ::cutBrackets( params ); + + // get splitter sizes and store it in the map for future setting + QValueList sizes; + QStringList sizesLst = QStringList::split( ':', ::getValue( params, "sizes" ) ); + for ( QStringList::Iterator it = sizesLst.begin(); it != sizesLst.end(); ++it ) + sizes.append( (*it).toInt() ); + sMap[ splitter ] = sizes; + + // set orientation of splitter + int orient = ::getValue( params, "orientation" ).toInt(); + splitter->setOrientation( (Qt::Orientation)orient ); + + // get children + QString options = params.left( params.find( '(' ) ); + QString childrenStr = params.right( params.length()-options.length() ); + QStringList children = ::getChildren( childrenStr ); + + // debug output.. + // printf (" splitter orient=%d, sizes_count=%d, children=%d\n", orient, sizes.count(), children.count() ); + // for ( QStringList::Iterator tit = children.begin(); tit != children.end(); ++tit ) + // printf (" |-> child = [%s]\n", (*tit).latin1() ); + + for ( QStringList::Iterator it = children.begin(); it != children.end(); ++it ) { + if ( (*it).startsWith( "(splitter" ) ) { + QSplitter* newSplitter = new QSplitter( splitter ); + setSplitter( newSplitter, *it, sMap ); + } + else if ( (*it).startsWith( "(views" ) ) { + QtxWorkstackArea* newArea = createArea( splitter ); + QString activeViewName = ::getValue( *it, "active" ); + QWidget* activeView( 0 ); + activeViewName = activeViewName.mid( 1, activeViewName.length()-2 ); // chop off ' symbols + int i = 0; + QString viewName = ::getViewName( *it, i ); + while ( !viewName.isEmpty() ) { + if ( QWidget* view = ::getView( splitter, viewName ) ) { + newArea->insertWidget( view ); + if ( activeViewName == view->name() ) + activeView = view; + } + viewName = ::getViewName( *it, ++i ); + } + if ( activeView ) + newArea->setActiveWidget( activeView ); + } + } +} + +// Restore workstack's configuration stored in 'parameters' string +QtxWorkstack& QtxWorkstack::operator<<( const QString& parameters ) +{ + // clear the main splitter - remove all child splitters and empty areas from it + QPtrList splitList; + QPtrList areaList; + splitters( mySplit, splitList, false ); + areas( mySplit, areaList, false ); + for ( QPtrListIterator iter( splitList ); iter.current(); ++iter ) + delete iter.current(); + for ( QPtrListIterator it( areaList ); it.current(); ++it ) + if ( it.current()->isEmpty() ) + delete it.current(); + + // restore splitter recursively + QMap< QSplitter*, QValueList > sMap; + setSplitter( mySplit, parameters, sMap ); + + // now mySplit may contains empty area (where all views were located before restoring) + // in order setSize to work correctly we have to exclude this area + areaList.clear(); + areas( mySplit, areaList, false ); + for ( QPtrListIterator delIt( areaList ); delIt.current(); ++delIt ) + if ( delIt.current()->isEmpty() ) + delete delIt.current(); + + qApp->processEvents(); + + // restore splitters' sizes (map of sizes is filled in setSplitters) + for ( QMap< QSplitter*, QValueList >::Iterator it = sMap.begin(); it != sMap.end(); ++it ) + it.key()->setSizes( it.data() ); + + return (*this); +} + +// Example of string produced by operator>> : +// "(splitter orientation=0 sizes=186:624 (views active='OCCViewer_0_0' 'OCCViewer_0_0') +// (views active='VTKViewer_0_0' 'VTKViewer_0_0'))" +QtxWorkstack& QtxWorkstack::operator>>( QString& outParameters ) +{ + splitterInfo( mySplit, outParameters ); + return (*this); +} + + /*! Class: QtxWorkstackArea [Internal] Descr: diff --git a/src/Qtx/QtxWorkstack.h b/src/Qtx/QtxWorkstack.h index 8157a2a81..36b4382bd 100644 --- a/src/Qtx/QtxWorkstack.h +++ b/src/Qtx/QtxWorkstack.h @@ -81,6 +81,10 @@ public: void SetRelativePosition( QWidget* wid, const Qt::Orientation o, const double pos ); void SetRelativePositionInSplitter( QWidget* wid, const double pos ); + // asv: Store/Restore visual parameters - geometry of inner windows + QtxWorkstack& operator<<( const QString& ); + QtxWorkstack& operator>>( QString& ); + signals: void windowActivated( QWidget* ); @@ -125,7 +129,10 @@ private: void distributeSpace( QSplitter* ) const; int setPosition( QWidget* wid, QSplitter* split, const Qt::Orientation o, const int need_pos, const int splitter_pos ); - + + void splitterInfo( QSplitter*, QString& ) const; + void setSplitter( QSplitter*, const QString&, QMap< QSplitter*,QValueList >& ); + private: QWidget* myWin; QtxWorkstackArea* myArea; diff --git a/src/SALOME_PYQT/SALOME_PYQT_GUI/SALOME_PYQT_Module.cxx b/src/SALOME_PYQT/SALOME_PYQT_GUI/SALOME_PYQT_Module.cxx index 3cb6cbbda..0593d7784 100644 --- a/src/SALOME_PYQT/SALOME_PYQT_GUI/SALOME_PYQT_Module.cxx +++ b/src/SALOME_PYQT/SALOME_PYQT_GUI/SALOME_PYQT_Module.cxx @@ -1,17 +1,17 @@ // Copyright (C) 2005 OPEN CASCADE, CEA/DEN, EDF R&D, PRINCIPIA R&D -// +// // 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 +// 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 +// +// 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 +// 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/ @@ -35,6 +35,8 @@ #include "SalomeApp_Study.h" #include "QtxWorkstack.h" +#include "QtxActionMenuMgr.h" +#include "QtxActionToolMgr.h" #include #include @@ -59,15 +61,19 @@ using namespace std; /////////////////////////////////////////////////////////////////////////////// // Default name of the module, replaced at the moment of module creation -#define __DEFAULT_NAME__ "SALOME_PYQT_Module" +const char* __DEFAULT_NAME__ = "SALOME_PYQT_Module"; /////////////////////////////////////////////////////////////////////////////// -// If __CALL_OLD_METHODS__ macro is not defined the invoking of obsolete Python +// Default menu group number +const int __DEFAULT_GROUP__ = 40; + +/////////////////////////////////////////////////////////////////////////////// +// If __CALL_OLD_METHODS__ macro is not defined the invoking of obsolete Python // module's methods like setSetting(), definePopup(), etc. is blocked. // This macro is defined by default (in Makefile) #ifdef __CALL_OLD_METHODS__ const bool IsCallOldMethods = true; -#else +#else const bool IsCallOldMethods = false; #endif @@ -88,17 +94,17 @@ class SALOME_PYQT_XmlHandler public: SALOME_PYQT_XmlHandler( SALOME_PYQT_Module* module, const QString& fileName ); void createActions(); - void createPopup ( QPopupMenu* menu, - const QString& context, - const QString& parent, + void createPopup ( QPopupMenu* menu, + const QString& context, + const QString& parent, const QString& object ); protected: void createToolBar ( QDomNode& parentNode ); - void createMenu ( QDomNode& parentNode, + void createMenu ( QDomNode& parentNode, const int parentMenuId = -1 ); - void insertPopupItems( QDomNode& parentNode, + void insertPopupItems( QDomNode& parentNode, QPopupMenu* menu ); private: @@ -114,10 +120,16 @@ private: // While the SalomePyQtGUI library is not imported in Python it's initialization function // should be called manually (and only once) in order to initialize global sip data // and to get C API from sip : sipBuildResult for example +#if defined(SIP_VERS_v4_old) || defined(SIP_VERS_v4_new) +#define INIT_FUNCTION initSalomePyQtGUI #if defined(SIP_STATIC_MODULE) -extern "C" void initSalomePyQtGUI(); +extern "C" void INIT_FUNCTION(); +#else +PyMODINIT_FUNC INIT_FUNCTION(); +#endif #else -PyMODINIT_FUNC initSalomePyQtGUI(); +#define INIT_FUNCTION initlibSalomePyQtGUIc +extern "C" void INIT_FUNCTION(); #endif /*! @@ -130,7 +142,7 @@ extern "C" { if ( !alreadyInitialized ) { // call only once (see above) ! PyEval_RestoreThread( KERNEL_PYTHON::_gtstate ); - initSalomePyQtGUI(); + INIT_FUNCTION(); PyEval_ReleaseThread( KERNEL_PYTHON::_gtstate ); alreadyInitialized = !alreadyInitialized; } @@ -138,7 +150,7 @@ extern "C" { } } -/*! +/*! * Static variables definition */ SALOME_PYQT_Module::InterpMap SALOME_PYQT_Module::myInterpMap; @@ -148,9 +160,9 @@ SALOME_PYQT_Module* SALOME_PYQT_Module::myInitModule = 0; * Little trick : provide an access to being activated Python module from outside; * needed by the SalomePyQt library :( */ -SALOME_PYQT_Module* SALOME_PYQT_Module::getInitModule() -{ - return myInitModule; +SALOME_PYQT_Module* SALOME_PYQT_Module::getInitModule() +{ + return myInitModule; } /*! @@ -159,9 +171,6 @@ SALOME_PYQT_Module* SALOME_PYQT_Module::getInitModule() SALOME_PYQT_Module::SALOME_PYQT_Module() : SalomeApp_Module( __DEFAULT_NAME__ ), myModule( 0 ), myXmlHandler ( 0 ) { - myMenuActionList.setAutoDelete( false ); - myPopupActionList.setAutoDelete( false ); - myToolbarActionList.setAutoDelete( false ); } /*! @@ -169,9 +178,6 @@ SALOME_PYQT_Module::SALOME_PYQT_Module() : */ SALOME_PYQT_Module::~SALOME_PYQT_Module() { - myMenuActionList.clear(); - myPopupActionList.clear(); - myToolbarActionList.clear(); if ( myXmlHandler ) delete myXmlHandler; } @@ -182,7 +188,7 @@ SALOME_PYQT_Module::~SALOME_PYQT_Module() * * This method is used for creation of the menus, toolbars and other staff. * There are two ways: - * - for obsolete modules this method first tries to read _.xml + * - for obsolete modules this method first tries to read _.xml * resource file which contains a menu, toolbars and popup menus description. * - new modules can create menus by by calling the corresponding methods of SalomePyQt * Python API in the Python module's initialize() method which is called from here. @@ -200,7 +206,7 @@ void SALOME_PYQT_Module::initialize( CAM_Application* app ) QString aName = name( "" ); QString aFileName = aName + "_" + aLang + ".xml"; aFileName = aResMgr->path( "resources", aName, aFileName ); - + // parse XML file if it is found and create actions if ( !myXmlHandler && !aFileName.isEmpty() ) { myXmlHandler = new SALOME_PYQT_XmlHandler( this, aFileName ); @@ -213,11 +219,11 @@ void SALOME_PYQT_Module::initialize( CAM_Application* app ) { public: InitializeReq( CAM_Application* _app, - SALOME_PYQT_Module* _obj ) + SALOME_PYQT_Module* _obj ) : PyInterp_Request( 0, true ), // this request should be processed synchronously (sync == true) myApp( _app ), myObj( _obj ) {} - + protected: virtual void execute() { @@ -242,7 +248,7 @@ bool SALOME_PYQT_Module::activateModule( SUIT_Study* theStudy ) MESSAGE( "SALOME_PYQT_Module::activateModule" ); bool res = SalomeApp_Module::activateModule( theStudy ); - + if ( !res ) return res; @@ -250,12 +256,12 @@ bool SALOME_PYQT_Module::activateModule( SUIT_Study* theStudy ) class ActivateReq : public PyInterp_Request { public: - ActivateReq( SUIT_Study* _study, - SALOME_PYQT_Module* _obj ) + ActivateReq( SUIT_Study* _study, + SALOME_PYQT_Module* _obj ) : PyInterp_Request( 0, true ), // this request should be processed synchronously (sync == true) myStudy ( _study ), myObj ( _obj ) {} - + protected: virtual void execute() { @@ -274,6 +280,10 @@ bool SALOME_PYQT_Module::activateModule( SUIT_Study* theStudy ) setMenuShown( true ); setToolShown( true ); + if ( menuMgr() ) + connect( menuMgr(), SIGNAL( menuHighlighted( int, int ) ), + this, SLOT( onMenuHighlighted( int, int ) ) ); + return true; } @@ -285,6 +295,10 @@ bool SALOME_PYQT_Module::deactivateModule( SUIT_Study* theStudy ) { MESSAGE( "SALOME_PYQT_Module::deactivateModule" ); + if ( menuMgr() ) + disconnect( menuMgr(), SIGNAL( menuHighlighted( int, int ) ), + this, SLOT( onMenuHighlighted( int, int ) ) ); + bool res = SalomeApp_Module::deactivateModule( theStudy ); // deactivate menus, toolbars, etc @@ -295,13 +309,13 @@ bool SALOME_PYQT_Module::deactivateModule( SUIT_Study* theStudy ) class DeactivateReq : public PyInterp_LockRequest { public: - DeactivateReq( PyInterp_base* _py_interp, - SUIT_Study* _study, - SALOME_PYQT_Module* _obj ) + DeactivateReq( PyInterp_base* _py_interp, + SUIT_Study* _study, + SALOME_PYQT_Module* _obj ) : PyInterp_LockRequest( _py_interp, 0, true ), // this request should be processed synchronously (sync == true) myStudy ( _study ), myObj ( _obj ) {} - + protected: virtual void execute() { @@ -338,13 +352,13 @@ void SALOME_PYQT_Module::onGUIEvent() class GUIEvent : public PyInterp_LockRequest { public: - GUIEvent( PyInterp_base* _py_interp, + GUIEvent( PyInterp_base* _py_interp, SALOME_PYQT_Module* _obj, - int _id ) + int _id ) : PyInterp_LockRequest( _py_interp, 0, true ), // this request should be processed synchronously (sync == true) myId ( _id ), myObj ( _obj ) {} - + protected: virtual void execute() { @@ -363,19 +377,19 @@ void SALOME_PYQT_Module::onGUIEvent() /*! * Processes GUI action (from context popup menu, only for XML-based actions!) */ -void SALOME_PYQT_Module::onGUIEvent( int id ) +void SALOME_PYQT_Module::onGUIEvent( int id ) { // perform synchronous request to Python event dispatcher class GUIEvent : public PyInterp_LockRequest { public: - GUIEvent( PyInterp_base* _py_interp, + GUIEvent( PyInterp_base* _py_interp, SALOME_PYQT_Module* _obj, - int _id ) + int _id ) : PyInterp_LockRequest( _py_interp, 0, true ), // this request should be processed synchronously (sync == true) myId ( _id ), myObj ( _obj ) {} - + protected: virtual void execute() { @@ -391,7 +405,43 @@ void SALOME_PYQT_Module::onGUIEvent( int id ) PyInterp_Dispatcher::Get()->Exec( new GUIEvent( myInterp, this, id ) ); } -/*! +/*! + * Menu highlight processing + */ +void SALOME_PYQT_Module::onMenuHighlighted( int menu, int submenu ) +{ + if ( !action( menu ) && registered( menu, submenu ) ) { + // perform synchronous request to Python event dispatcher + class MenuHighlightEvent : public PyInterp_LockRequest + { + public: + MenuHighlightEvent( PyInterp_base* _py_interp, + SALOME_PYQT_Module* _obj, + int _menu, + int _submenu ) + : PyInterp_LockRequest( _py_interp, 0, true ), // this request should be processed synchronously (sync == true) + myMenu ( _menu ), + mySubMenu( _submenu ), + myObj ( _obj ) {} + + protected: + virtual void execute() + { + myObj->menuHighlight( myMenu, mySubMenu ); + } + + private: + int myMenu; + int mySubMenu; + SALOME_PYQT_Module* myObj; + }; + + // Posting the request + PyInterp_Dispatcher::Get()->Exec( new MenuHighlightEvent( myInterp, this, menu, submenu ) ); + } +} + +/*! Context popup menu request. Called when user activates popup menu in some window (view, object browser, etc). */ @@ -402,15 +452,15 @@ void SALOME_PYQT_Module::contextMenuPopup( const QString& theContext, QPopupMenu class PopupMenuEvent : public PyInterp_LockRequest { public: - PopupMenuEvent( PyInterp_base* _py_interp, + PopupMenuEvent( PyInterp_base* _py_interp, SALOME_PYQT_Module* _obj, - const QString& _context, - QPopupMenu* _popup ) + const QString& _context, + QPopupMenu* _popup ) : PyInterp_LockRequest( _py_interp, 0, true ), // this request should be processed synchronously (sync == true) - myContext( _context ), + myContext( _context ), myPopup ( _popup ), myObj ( _obj ) {} - + protected: virtual void execute() { @@ -431,13 +481,13 @@ void SALOME_PYQT_Module::contextMenuPopup( const QString& theContext, QPopupMenu /*! * Defines the dockable window associated with the module. - * To fill the list of windows the correspondind Python module's windows() + * To fill the list of windows the correspondind Python module's windows() * method is called from SALOME_PYQT_Module::init() method. * By default, ObjectBrowser, PythonConsole and LogWindow are provided. */ void SALOME_PYQT_Module::windows( QMap& mappa ) const { - // First clear the output parameters + // First clear the output parameters QMap::ConstIterator it; for ( it = myWindowsMap.begin(); it != myWindowsMap.end(); ++it ) { mappa[ it.key() ] = it.data(); @@ -446,7 +496,7 @@ void SALOME_PYQT_Module::windows( QMap& mappa ) const /*! * Defines the compatible views which should be opened on module activation. - * To fill the list of views the correspondind Python module's views() + * To fill the list of views the correspondind Python module's views() * method is called from SALOME_PYQT_Module::init() method. * By default, the list is empty. */ @@ -483,14 +533,14 @@ void SALOME_PYQT_Module::init( CAM_Application* app ) // initialize Python subinterpreter (on per study) and put it in variable initInterp( aStudyId ); - if ( !myInterp ) - return; // Error + if ( !myInterp ) + return; // Error // import Python GUI module importModule(); if ( !myModule ) - return; // Error - + return; // Error + myInitModule = this; if ( IsCallOldMethods ) { // __CALL_OLD_METHODS__ @@ -509,7 +559,7 @@ void SALOME_PYQT_Module::init( CAM_Application* app ) PyErr_Print(); } } - + // get the windows list from the Python module by calling windows() method // ... first put default values myWindowsMap.insert( SalomeApp_Application::WT_ObjectBrowser, Qt::DockLeft ); @@ -569,7 +619,7 @@ void SALOME_PYQT_Module::init( CAM_Application* app ) } /*! - * Performs internal activation: + * Performs internal activation: * - initializes/gets the Python interpreter (one per study) * - imports the Python GUI module * - calls Python module's setSettings() method (obsolete function, used for compatibility with old code) @@ -583,14 +633,14 @@ void SALOME_PYQT_Module::activate( SUIT_Study* theStudy ) // initialize Python subinterpreter (on per study) and put it in variable initInterp( aStudyId ); - if ( !myInterp ) - return; // Error + if ( !myInterp ) + return; // Error // import Python GUI module importModule(); if ( !myModule ) - return; // Error - + return; // Error + // get python lock PyLockWrapper aLock = myInterp->GetLockWrapper(); @@ -614,7 +664,7 @@ void SALOME_PYQT_Module::activate( SUIT_Study* theStudy ) } /*! - * Performs internal deactivation: + * Performs internal deactivation: * - calls Python module's deactivate() method */ void SALOME_PYQT_Module::deactivate( SUIT_Study* theStudy ) @@ -647,14 +697,14 @@ void SALOME_PYQT_Module::studyChanged( SUIT_Study* theStudy ) // initialize Python subinterpreter (on per study) and put it in variable initInterp( aStudyId ); - if ( !myInterp ) - return; // Error + if ( !myInterp ) + return; // Error // import Python GUI module importModule(); if ( !myModule ) - return; // Error - + return; // Error + // get python lock PyLockWrapper aLock = myInterp->GetLockWrapper(); @@ -692,7 +742,7 @@ QString SALOME_PYQT_Module::engineIOR() const return QString( "" ); } -/*! +/*! * Called when study desktop is activated. * Used for notifying about changing of the active study. */ @@ -702,12 +752,12 @@ void SALOME_PYQT_Module::studyActivated() class StudyChangedReq : public PyInterp_Request { public: - StudyChangedReq( SUIT_Study* _study, - SALOME_PYQT_Module* _obj ) + StudyChangedReq( SUIT_Study* _study, + SALOME_PYQT_Module* _obj ) : PyInterp_Request( 0, true ), // this request should be processed synchronously (sync == true) myStudy ( _study ), myObj ( _obj ) {} - + protected: virtual void execute() { @@ -739,17 +789,17 @@ void SALOME_PYQT_Module::contextMenu( const QString& theContext, QPopupMenu* the // import first if ( !myInterp || !myModule ) return; - + QString aContext( theContext ), aObject( "" ), aParent( "" ); - + if ( IsCallOldMethods && PyObject_HasAttrString(myModule , "definePopup") ) { //__CALL_OLD_METHODS__ // call definePopup() Python module's function // this is obsolete function, used only for compatibility reasons - PyObjWrapper res(PyObject_CallMethod( myModule, - "definePopup", + PyObjWrapper res(PyObject_CallMethod( myModule, + "definePopup", "sss", - aContext.latin1(), - aObject.latin1(), + aContext.latin1(), + aObject.latin1(), aParent.latin1() ) ); if( !res ) { PyErr_Print(); @@ -773,7 +823,7 @@ void SALOME_PYQT_Module::contextMenu( const QString& theContext, QPopupMenu* the PyObjWrapper sipPopup( sipBuildResult( 0, "M", thePopupMenu, sipClass_QPopupMenu ) ); // then call Python module's createPopupMenu() method (for new modules) - if ( PyObject_HasAttrString(myModule , "createPopupMenu") ) { + if ( PyObject_HasAttrString(myModule , "createPopupMenu") ) { PyObjWrapper res1( PyObject_CallMethod( myModule, "createPopupMenu", "Os", @@ -791,8 +841,8 @@ void SALOME_PYQT_Module::contextMenu( const QString& theContext, QPopupMenu* the "customPopup", "Osss", sipPopup.get(), - aContext.latin1(), - aObject.latin1(), + aContext.latin1(), + aObject.latin1(), aParent.latin1() ) ); if( !res2 ) { PyErr_Print(); @@ -803,15 +853,15 @@ void SALOME_PYQT_Module::contextMenu( const QString& theContext, QPopupMenu* the /*! * Processes GUI event * - calls Python module's OnGUIEvent() method - */ + */ void SALOME_PYQT_Module::guiEvent( const int theId ) { // Python interpreter should be initialized and Python module should be // import first if ( !myInterp || !myModule ) return; - - if ( PyObject_HasAttrString(myModule , "OnGUIEvent") ) { + + if ( PyObject_HasAttrString(myModule , "OnGUIEvent") ) { PyObjWrapper res( PyObject_CallMethod( myModule, "OnGUIEvent", "i", theId ) ); if( !res ) { PyErr_Print(); @@ -819,6 +869,25 @@ void SALOME_PYQT_Module::guiEvent( const int theId ) } } +/*! + * Menu highlight processing + * - calls Python module's menuActivated(int,int) method + */ +void SALOME_PYQT_Module::menuHighlight( const int menu, const int submenu ) +{ + // Python interpreter should be initialized and Python module should be + // import first + if ( !myInterp || !myModule ) + return; + + if ( PyObject_HasAttrString(myModule , "menuHighlight") ) { + PyObjWrapper res( PyObject_CallMethod( myModule, "menuHighlight", "ii", menu, submenu ) ); + if( !res ) { + PyErr_Print(); + } + } +} + /*! * Initialises python subinterpreter (one per study) */ @@ -838,13 +907,13 @@ void SALOME_PYQT_Module::initInterp( int theStudyId ) } // not found - create a new one! /////////////////////////////////////////////////////////////////// - // Attention: the creation of Python interpretor must be protected + // Attention: the creation of Python interpretor must be protected // by a C++ Lock because of C threads /////////////////////////////////////////////////////////////////// myInterp = new SALOME_PYQT_PyInterp(); myInterp->initialize(); myInterpMap[ theStudyId ] = myInterp; - + // import 'salome' module and call 'salome_init' method; // do it only once on interpreter creation // ... first get python lock @@ -913,7 +982,7 @@ void SALOME_PYQT_Module::setWorkSpace() // Error! PyErr_Print(); return; - } + } if ( IsCallOldMethods ) { //__CALL_OLD_METHODS__ // ... then get workspace object @@ -930,7 +999,7 @@ void SALOME_PYQT_Module::setWorkSpace() } PyObjWrapper pyws( sipBuildResult( 0, "M", aWorkspace, sipClass_QWidget ) ); // ... and finally call Python module's setWorkspace() method (obsolete) - if ( PyObject_HasAttrString(myModule , "setWorkSpace") ) { + if ( PyObject_HasAttrString(myModule , "setWorkSpace") ) { PyObjWrapper res( PyObject_CallMethod( myModule, "setWorkSpace", "O", pyws.get() ) ); if( !res ) { PyErr_Print(); @@ -940,28 +1009,19 @@ void SALOME_PYQT_Module::setWorkSpace() } /*! - * Adds an action into private action list [internal usage] + * Returns default menu group */ -void SALOME_PYQT_Module::addAction( const PyQtGUIAction type, QAction* action ) +int SALOME_PYQT_Module::defaultMenuGroup() { - switch ( type ) { - case PYQT_ACTION_MENU: - myMenuActionList.append( action ); - break; - case PYQT_ACTION_TOOLBAL: - myToolbarActionList.append( action ); - break; - case PYQT_ACTION_POPUP: - myPopupActionList.append( action ); - break; - } + return __DEFAULT_GROUP__; } - /*! - * The next methods just call the parent implementation. + * The next methods call the parent implementation. * This is done to open protected methods from CAM_Module class. -*/ + * Also these methods are used to register created from outside menus + * in order to enable dynamic menus handling. + */ int SALOME_PYQT_Module::createTool( const QString& name ) { return SalomeApp_Module::createTool( name ); @@ -982,29 +1042,63 @@ int SALOME_PYQT_Module::createTool( QAction* a, const QString& tBar, const int i { return SalomeApp_Module::createTool( a, tBar, id, idx ); } -int SALOME_PYQT_Module::createMenu( const QString& subMenu, const int menu, const int id, const int group, const int idx ) +int SALOME_PYQT_Module::createMenu( const QString& subMenu, const int menu, const int id, const int group, const int idx, const bool constantMenu ) { - return SalomeApp_Module::createMenu( subMenu, menu, id, group, idx ); + bool exists = hasMenu( subMenu, menu ); + int regId = SalomeApp_Module::createMenu( subMenu, menu, id, group, idx, true ); + if ( !exists ) + registerMenu( regId, menu, constantMenu ); + return regId; } -int SALOME_PYQT_Module::createMenu( const QString& subMenu, const QString& menu, const int id, const int group, const int idx ) +int SALOME_PYQT_Module::createMenu( const QString& subMenu, const QString& menu, const int id, const int group, const int idx, const bool constantMenu ) { - return SalomeApp_Module::createMenu( subMenu, menu, id, group, idx ); + QStringList menus = QStringList::split( "|", menu, false ); + int pid = -1; + for (int i = 0; i < menus.count(); i++ ) { + pid = createMenu( menus[i], pid, -1, -1, -1, constantMenu ); + if ( pid == -1 ) break; + } + if ( pid != -1 ) + pid = createMenu( subMenu, pid, id, group, idx, constantMenu ); + return pid; } -int SALOME_PYQT_Module::createMenu( const int id, const int menu, const int group, const int idx ) +int SALOME_PYQT_Module::createMenu( const int id, const int menu, const int group, const int idx, const bool constantMenu ) { - return SalomeApp_Module::createMenu( id, menu, group, idx ); + int regId = SalomeApp_Module::createMenu( id, menu, group, idx ); + if ( regId != -1 ) + registerMenu( regId, menu, constantMenu ); + return regId; } -int SALOME_PYQT_Module::createMenu( const int id, const QString& menu, const int group, const int idx ) +int SALOME_PYQT_Module::createMenu( const int id, const QString& menu, const int group, const int idx, const bool constantMenu ) { - return SalomeApp_Module::createMenu( id, menu, group, idx ); + QStringList menus = QStringList::split( "|", menu, false ); + int pid = -1; + for (int i = 0; i < menus.count(); i++ ) { + pid = createMenu( menus[i], pid, -1, -1, -1, constantMenu ); + if ( pid == -1 ) break; + } + if ( pid != -1 ) + pid = createMenu( id, pid, group, idx, constantMenu ); + return pid; } -int SALOME_PYQT_Module::createMenu( QAction* a, const int menu, const int id, const int group, const int idx ) +int SALOME_PYQT_Module::createMenu( QAction* a, const int menu, const int id, const int group, const int idx, const bool constantMenu ) { - return SalomeApp_Module::createMenu( a, menu, id, group, idx ); + int regId = SalomeApp_Module::createMenu( a, menu, id, group, idx ); + if ( regId != -1 ) + registerMenu( regId, menu, constantMenu ); + return regId; } -int SALOME_PYQT_Module::createMenu( QAction* a, const QString& menu, const int id, const int group, const int idx ) +int SALOME_PYQT_Module::createMenu( QAction* a, const QString& menu, const int id, const int group, const int idx, const bool constantMenu ) { - return SalomeApp_Module::createMenu( a, menu, id, group, idx ); + QStringList menus = QStringList::split( "|", menu, false ); + int pid = -1; + for (int i = 0; i < menus.count(); i++ ) { + pid = createMenu( menus[i], pid, -1, -1, -1, constantMenu ); + if ( pid == -1 ) break; + } + if ( pid != -1 ) + pid = createMenu( a, pid, id, group, idx, constantMenu ); + return pid; } QAction* SALOME_PYQT_Module::createSeparator() { @@ -1012,27 +1106,13 @@ QAction* SALOME_PYQT_Module::createSeparator() } QAction* SALOME_PYQT_Module::action( const int id ) const { - QAction* a = SalomeApp_Module::action( id ); - if ( !a ) // try own action map for menu items - a = SalomeApp_Module::action( id + PYQT_ACTION_MENU ); - if ( !a ) // try own action map for toolbar items - a = SalomeApp_Module::action( id + PYQT_ACTION_TOOLBAL ); - if ( !a ) // try own action map for popup items - a = SalomeApp_Module::action( id + PYQT_ACTION_POPUP ); - return a; + return SalomeApp_Module::action( id ); } int SALOME_PYQT_Module::actionId( const QAction* a ) const { - int id = SalomeApp_Module::actionId( a ); - if ( myMenuActionList.contains( a ) ) // check own action map for menu items - id -= PYQT_ACTION_MENU; - if ( myToolbarActionList.contains( a ) ) // check own action map for toolbar items - id -= PYQT_ACTION_TOOLBAL; - if ( myPopupActionList.contains( a ) ) // check own action map for popup items - id -= PYQT_ACTION_POPUP; - return id; + return SalomeApp_Module::actionId( a ); } -QAction* SALOME_PYQT_Module::createAction( const int id, const QString& text, const QString& icon, +QAction* SALOME_PYQT_Module::createAction( const int id, const QString& text, const QString& icon, const QString& menu, const QString& tip, const int key, const bool toggle ) { @@ -1042,9 +1122,201 @@ QAction* SALOME_PYQT_Module::createAction( const int id, const QString& text, co if ( !pixmap.isNull() ) anIcon = QIconSet( pixmap ); } - return SalomeApp_Module::createAction( id, text, anIcon, menu, tip, key, getApp()->desktop(), toggle, this, SLOT( onGUIEvent() ) ); + QAction* a = action( id ); + if ( a ) { + if ( a->text().isEmpty() && !text.isEmpty() ) a->setText( text ); + if ( a->menuText().isEmpty() && !menu.isEmpty() ) a->setMenuText( menu ); + if ( a->iconSet().isNull() && !anIcon.isNull() ) a->setIconSet( anIcon ); + if ( a->statusTip().isEmpty() && !tip.isNull() ) a->setStatusTip( tip ); + if ( a->accel().isEmpty() && key ) a->setAccel( key ); + if ( a->isToggleAction() != toggle ) a->setToggleAction( toggle ); + disconnect( a, SIGNAL( activated() ), this, SLOT( onGUIEvent() ) ); + connect( a, SIGNAL( activated() ), this, SLOT( onGUIEvent() ) ); + } + else { + a = SalomeApp_Module::createAction( id, text, anIcon, menu, tip, key, getApp()->desktop(), toggle, this, SLOT( onGUIEvent() ) ); + } + return a; +} + +/*! + * Returns TRUE if menu already exists + */ +bool SALOME_PYQT_Module::hasMenu( const QString& subMenu, const int menu ) +{ + return menuMgr() && menuMgr()->containsMenu( subMenu, menu ); +} + +/*! + * Register the menu + */ +void SALOME_PYQT_Module::registerMenu( const int id, const int menu, const bool constantMenu ) +{ + QAction* a = action( id ); + QAction* s = separator(); + if ( a && a == s ) + return; + if ( !registered( id, menu ) ) + myMenus[menu].append( MenuId( id, constantMenu ) ); +} + +/*! + * Unregister the menu + */ +void SALOME_PYQT_Module::unregisterMenu( const int id, const int menu ) +{ + if ( myMenus.find( menu ) != myMenus.end() ) { + MenuIdList::iterator lit; + for ( lit = myMenus[menu].begin(); lit != myMenus[menu].end(); ++lit ) { + if ( (*lit).id == id ) { + myMenus[menu].remove( lit ); + return; + } + } + } +} + +/*! + * Returns TRUE if the menu is registered + */ +bool SALOME_PYQT_Module::registered( const int id, const int menu ) +{ + MenuMap::iterator mit; + for ( mit = myMenus.begin(); mit != myMenus.end(); ++mit ) { + MenuIdList::iterator lit; + for ( lit = mit.data().begin(); lit != mit.data().end(); ++lit ) { + if ( (*lit).id == id && ( menu == 0 || mit.key() == menu ) ) + return true; + } + } + return false; +} + +/*! + * Returns TRUE if the menu is constant (not removed by clearMenu()). + * This concerns the menus which are created from XML files. + */ +bool SALOME_PYQT_Module::isConstantMenu( const int id, const int menu ) +{ + if ( myMenus.find( menu ) != myMenus.end() ) { + MenuIdList& l = myMenus[ menu ]; + MenuIdList::iterator lit; + for ( lit = l.begin(); lit != l.end(); ++lit ) { + if ( (*lit).id == id && (*lit).constantMenu ) + return true; + } + } + return false; +} + +/*! + * Displays/hides the module's menus. + */ +void SALOME_PYQT_Module::setMenuShown( const bool show ) +{ + QtxActionMenuMgr* mMgr = menuMgr(); + if ( !mMgr ) + return; + + bool upd = mMgr->isUpdatesEnabled(); + mMgr->setUpdatesEnabled( false ); + + SalomeApp_Module::setMenuShown( show ); + + for ( MenuMap::iterator mit = myMenus.begin(); mit != myMenus.end(); ++mit ) { + MenuIdList::iterator lit; + for ( lit = mit.data().begin(); lit != mit.data().end(); ++lit ) + if ( !action( (*lit).id ) ) + mMgr->setShown( (*lit).id, show ); + } + + mMgr->setUpdatesEnabled( upd ); + if ( upd ) + mMgr->update(); +} + +/*! + * Displays/hides the module's toolbars. + */ +void SALOME_PYQT_Module::setToolShown( const bool show ) +{ + SalomeApp_Module::setToolShown( show ); } +/*! + * Clears the given menu. + * If = 0 : clear all items in the menu + * If = 0 : clear all menus recursively starting from top-level. + * If = 0 : also unregister all removed actions (not delete!). + */ +bool SALOME_PYQT_Module::clearMenu( const int id, const int menu, const bool removeActions ) +{ + QAction* a = action( id ); + QAction* s = separator(); + typedef QValueList IntList; + if ( a && a != s ) { + // action + IntList menus; + if ( menu != 0 ) { + if ( registered( id, menu ) ) menus.append( menu ); + } + else { + MenuMap::iterator mit; + for ( mit = myMenus.begin(); mit != myMenus.end(); ++mit ) + if ( registered( id, mit.key() ) ) menus.append( mit.key() ); + } + for ( int i = 0; i < menus.count(); i++ ) { + if ( !isConstantMenu( id, menus[i] ) ) { + menuMgr()->remove( menuMgr()->actionId( a ), menus[ i ] ); + unregisterMenu( id, menus[i] ); + } + } + if ( !registered( id ) && removeActions ) + unregisterAction( id ); + } + else { + // menu + if ( id == 0 ) { + if ( menu == 0 ) { + // clear all menus recursively starting from top-level (main menu) + IntList l = myMenus.keys(); + IntList::iterator lit; + for ( lit = l.begin(); lit != l.end(); ++lit ) + clearMenu( 0, *lit, removeActions ); + } + else { + if ( myMenus.find( menu ) != myMenus.end() ) { + // remove all items in the parent menu + IntList l; + MenuIdList::iterator lit; + for ( lit = myMenus[menu].begin(); lit != myMenus[menu].end(); ++lit ) + l.append( (*lit).id ); + for ( int i = 0; i < l.count(); i++ ) + clearMenu( l[i], menu, removeActions ); + if ( myMenus[menu].empty() ) + myMenus.remove( menu ); + } + } + } + else { + MenuMap::iterator mit; + for ( mit = myMenus.begin(); mit != myMenus.end(); ++mit ) { + MenuIdList::iterator lit; + for ( lit = mit.data().begin(); lit != mit.data().end(); ++lit ) { + if ( (*lit).id == id && ( menu == 0 || mit.key() == menu ) ) { + clearMenu( 0, id, removeActions ); // first remove all sub-menus + if ( !isConstantMenu( id, mit.key() ) ) { + menuMgr()->remove( id, mit.key() ); + mit.data().remove( lit ); + break; + } + } + } + } + } + } + return false; +} //============================================================================= // SALOME_PYQT_XmlHandler class implementation @@ -1053,7 +1325,7 @@ QAction* SALOME_PYQT_Module::createAction( const int id, const QString& text, co // gets an tag name for the dom element [ static ] // returns an empty string if the element does not have tag name static QString tagName( const QDomElement& element ) { - return element.tagName().stripWhiteSpace(); + return element.tagName().stripWhiteSpace(); } // gets an attribute by it's name for the dom element [ static ] @@ -1070,15 +1342,15 @@ static bool checkBool( const QString& value ) { // checks the given value for the integer value [ static ] // returns -1 if item is empty or presents and invalid number -static int checkInt( const QString& value ) +static int checkInt( const QString& value, const int def = -1 ) { - return value.isEmpty() ? -1 : value.toInt(); + return value.isEmpty() ? def : value.toInt(); } /*! * Constructor */ -SALOME_PYQT_XmlHandler::SALOME_PYQT_XmlHandler( SALOME_PYQT_Module* module, const QString& fileName ) +SALOME_PYQT_XmlHandler::SALOME_PYQT_XmlHandler( SALOME_PYQT_Module* module, const QString& fileName ) : myModule( module ) { QFile aFile( fileName ); @@ -1092,7 +1364,7 @@ SALOME_PYQT_XmlHandler::SALOME_PYQT_XmlHandler( SALOME_PYQT_Module* module, cons } /*! - Called by SALOME_PYQT_Module::initialize() in order to create actions + Called by SALOME_PYQT_Module::initialize() in order to create actions (menus, toolbars, popup menus) */ void SALOME_PYQT_XmlHandler::createActions() @@ -1118,9 +1390,9 @@ void SALOME_PYQT_XmlHandler::createActions() /*! * Creates popup menu */ -void SALOME_PYQT_XmlHandler::createPopup( QPopupMenu* menu, - const QString& context, - const QString& parent, +void SALOME_PYQT_XmlHandler::createPopup( QPopupMenu* menu, + const QString& context, + const QString& parent, const QString& object ) { // get document element @@ -1151,22 +1423,25 @@ void SALOME_PYQT_XmlHandler::createMenu( QDomNode& parentNode, const int parentM { if ( !myModule ) return; - + if ( parentNode.isNull() ) return; - QDomElement parentElement = parentNode.toElement(); + QDomElement parentElement = parentNode.toElement(); if ( !parentElement.isNull() ) { QString plabel = attribute( parentElement, "label-id" ); int pid = checkInt( attribute( parentElement, "item-id" ) ); int ppos = checkInt( attribute( parentElement, "pos-id" ) ); + int group = checkInt( attribute( parentElement, "group-id" ), + myModule->defaultMenuGroup() ); if ( !plabel.isEmpty() ) { // create menu int menuId = myModule->createMenu( plabel, // label parentMenuId, // parent menu ID, should be -1 for main menu pid, // ID - 80, // group ID - ppos ); // position + group, // group ID + ppos, // position + true ); // create constant menu (not removed by clearMenu()) QDomNode node = parentNode.firstChild(); while ( !node.isNull() ) { if ( node.isElement() ) { @@ -1175,6 +1450,8 @@ void SALOME_PYQT_XmlHandler::createMenu( QDomNode& parentNode, const int parentM if ( aTagName == "popup-item" ) { int id = checkInt( attribute( elem, "item-id" ) ); int pos = checkInt( attribute( elem, "pos-id" ) ); + int group = checkInt( attribute( elem, "group-id" ), + myModule->defaultMenuGroup() ); QString label = attribute( elem, "label-id" ); QString icon = attribute( elem, "icon-id" ); QString tooltip = attribute( elem, "tooltip-id" ); @@ -1184,9 +1461,7 @@ void SALOME_PYQT_XmlHandler::createMenu( QDomNode& parentNode, const int parentM // -1 action ID is not allowed : it means that attribute is missed in the XML file! // also check if the action with given ID is already created - if ( id != -1 && !myModule->action( SALOME_PYQT_Module::PYQT_ACTION_MENU + id ) ) { - // little trick to have several actions with same ID for menus and toolbars - id = SALOME_PYQT_Module::PYQT_ACTION_MENU + id; + if ( id != -1 ) { // create menu action QAction* action = myModule->createAction( id, // ID tooltip, // tooltip @@ -1195,8 +1470,12 @@ void SALOME_PYQT_XmlHandler::createMenu( QDomNode& parentNode, const int parentM tooltip, // status-bar text QKeySequence( accel ), // keyboard accelerator toggle ); // toogled action - myModule->addAction( SALOME_PYQT_Module::PYQT_ACTION_MENU, action ); - myModule->createMenu( action, menuId, -1, 80, pos ); + myModule->createMenu( action, // action + menuId, // parent menu ID + id, // ID (same as for createAction()) + group, // group ID + pos, // position + true ); // create constant menu (not removed by clearMenu()) } } else if ( aTagName == "submenu" ) { @@ -1205,9 +1484,17 @@ void SALOME_PYQT_XmlHandler::createMenu( QDomNode& parentNode, const int parentM } else if ( aTagName == "separator" ) { // create menu separator - int pos = checkInt( attribute( elem, "pos-id" ) ); + int id = checkInt( attribute( elem, "item-id" ) ); // separator can have ID + int pos = checkInt( attribute( elem, "pos-id" ) ); + int group = checkInt( attribute( elem, "group-id" ), + myModule->defaultMenuGroup() ); QAction* action = myModule->createSeparator(); - myModule->createMenu( action, menuId, -1, 80, pos ); + myModule->createMenu( action, // separator action + menuId, // parent menu ID + id, // ID + group, // group ID + pos, // position + true ); // create constant menu (not removed by clearMenu()) } } node = node.nextSibling(); @@ -1223,11 +1510,11 @@ void SALOME_PYQT_XmlHandler::createToolBar( QDomNode& parentNode ) { if ( !myModule ) return; - + if ( parentNode.isNull() ) return; - QDomElement parentElement = parentNode.toElement(); + QDomElement parentElement = parentNode.toElement(); if ( !parentElement.isNull() ) { QString aLabel = attribute( parentElement, "label-id" ); if ( !aLabel.isEmpty() ) { @@ -1250,9 +1537,7 @@ void SALOME_PYQT_XmlHandler::createToolBar( QDomNode& parentNode ) // -1 action ID is not allowed : it means that attribute is missed in the XML file! // also check if the action with given ID is already created - if ( id != -1 && !myModule->action( SALOME_PYQT_Module::PYQT_ACTION_TOOLBAL + id ) ) { - // little trick to have several actions with same ID for menus and toolbars - id = SALOME_PYQT_Module::PYQT_ACTION_TOOLBAL + id; + if ( id != -1 ) { // create toolbar action QAction* action = myModule->createAction( id, // ID tooltip, // tooltip @@ -1261,7 +1546,6 @@ void SALOME_PYQT_XmlHandler::createToolBar( QDomNode& parentNode ) tooltip, // status-bar text QKeySequence( accel ), // keyboard accelerator toggle ); // toogled action - myModule->addAction( SALOME_PYQT_Module::PYQT_ACTION_TOOLBAL, action ); myModule->createTool( action, tbId, -1, pos ); } } @@ -1275,14 +1559,14 @@ void SALOME_PYQT_XmlHandler::createToolBar( QDomNode& parentNode ) node = node.nextSibling(); } } - } + } } void SALOME_PYQT_XmlHandler::insertPopupItems( QDomNode& parentNode, QPopupMenu* menu ) { if ( !myModule ) return; - + if ( parentNode.isNull() ) return; @@ -1309,7 +1593,7 @@ void SALOME_PYQT_XmlHandler::insertPopupItems( QDomNode& parentNode, QPopupMenu* if ( !pixmap.isNull() ) anIcon = QIconSet( pixmap ); } - + // -1 action ID is not allowed : it means that attribute is missed in the XML file! // also check if the action with given ID is already created if ( id != -1 ) { diff --git a/src/SALOME_PYQT/SALOME_PYQT_GUI/SALOME_PYQT_Module.h b/src/SALOME_PYQT/SALOME_PYQT_GUI/SALOME_PYQT_Module.h index 2582ee59e..57fa50cce 100644 --- a/src/SALOME_PYQT/SALOME_PYQT_GUI/SALOME_PYQT_Module.h +++ b/src/SALOME_PYQT/SALOME_PYQT_GUI/SALOME_PYQT_Module.h @@ -60,20 +60,22 @@ private: SALOME_PYQT_PyInterp* myInterp; /* Python GUI module loaded */ PyObjWrapper myModule; - /* Pytho GUI being initialized (not zero only during the initialization)*/ - static SALOME_PYQT_Module* myInitModule; - - typedef QPtrList ActionList; - - /* own actions list */ - ActionList myMenuActionList; - ActionList myPopupActionList; - ActionList myToolbarActionList; + /* Python GUI being initialized (not zero only during the initialization)*/ + static SALOME_PYQT_Module* myInitModule; + + /* own menus list */ + struct MenuId + { + int id; + bool constantMenu; + MenuId() : id( -1 ), constantMenu( false ) {} + MenuId( const int _id, const bool _constantMenu ) + : id( _id ), constantMenu( _constantMenu ) {} + }; + typedef QValueList MenuIdList; + typedef QMap MenuMap; + MenuMap myMenus; - enum PyQtGUIAction { PYQT_ACTION_MENU = 10000000, - PYQT_ACTION_TOOLBAL = 20000000, - PYQT_ACTION_POPUP = 30000000 }; - /* XML resource file parser */ SALOME_PYQT_XmlHandler* myXmlHandler; /* windows map*/ @@ -121,6 +123,9 @@ public: /* called when study desktop is activated */ virtual void studyActivated(); + /* returns default menu group */ + static int defaultMenuGroup(); + /* working with toolbars : open protected methods */ int createTool( const QString& ); int createTool( const int, const int, const int = -1 ); @@ -129,12 +134,15 @@ public: int createTool( QAction*, const QString&, const int = -1, const int = -1 ); /* working with menus : open protected methods */ - int createMenu( const QString&, const int, const int = -1, const int = -1, const int = -1 ); - int createMenu( const QString&, const QString&, const int = -1, const int = -1, const int = -1 ); - int createMenu( const int, const int, const int = -1, const int = -1 ); - int createMenu( const int, const QString&, const int = -1, const int = -1 ); - int createMenu( QAction*, const int, const int = -1, const int = -1, const int = -1 ); - int createMenu( QAction*, const QString&, const int = -1, const int = -1, const int = -1 ); + int createMenu( const QString&, const int, const int = -1, const int = -1, const int = -1, const bool = false ); + int createMenu( const QString&, const QString&, const int = -1, const int = -1, const int = -1, const bool = false ); + int createMenu( const int, const int, const int = -1, const int = -1, const bool = false ); + int createMenu( const int, const QString&, const int = -1, const int = -1, const bool = false ); + int createMenu( QAction*, const int, const int = -1, const int = -1, const int = -1, const bool = false ); + int createMenu( QAction*, const QString&, const int = -1, const int = -1, const int = -1, const bool = false ); + + /* clear given menu */ + bool clearMenu( const int = 0, const int = 0, const bool = true ); /* create separator : open protected method */ QAction* createSeparator(); @@ -145,6 +153,10 @@ public: QAction* createAction( const int, const QString&, const QString&, const QString&, const QString&, const int, const bool = false ); + /* Show/hide menus/toolbars */ + void setMenuShown( const bool ); + void setToolShown( const bool ); + public slots: /* activation */ virtual bool activateModule( SUIT_Study* ); @@ -160,6 +172,17 @@ public slots: void onGUIEvent(); void onGUIEvent( int ); +protected: + /* Menu processing */ + bool hasMenu( const QString&, const int ); + void registerMenu( const int, const int, const bool = false ); + void unregisterMenu( const int, const int ); + bool registered( const int, const int = 0 ); + bool isConstantMenu( const int, const int ); + +protected slots: + void onMenuHighlighted( int, int ); + private: /* internal initizalition */ void init ( CAM_Application* ); @@ -173,9 +196,8 @@ private: void contextMenu( const QString&, QPopupMenu* ); /* GUI event processing */ void guiEvent( const int ); - - /* add action to the private action map */ - void addAction ( const PyQtGUIAction, QAction* ); + /* Menu highlight processing */ + void menuHighlight( const int, const int ); /* initialize a Python subinterpreter */ void initInterp ( int ); diff --git a/src/SALOME_PYQT/SalomePyQt/Makefile.in b/src/SALOME_PYQT/SalomePyQt/Makefile.in index 79ac12b9e..ac2aeab56 100644 --- a/src/SALOME_PYQT/SalomePyQt/Makefile.in +++ b/src/SALOME_PYQT/SalomePyQt/Makefile.in @@ -103,7 +103,7 @@ LIB_CLIENT_IDL = SALOME_Exception.idl SALOME_GenericObj.idl # Compilation/linkage flags CPPFLAGS += $(QT_INCLUDES) $(SIP_INCLUDES) $(PYTHON_INCLUDES) $(OCC_INCLUDES) $(VTK_INCLUDES) $(OGL_INCLUDES) $(BOOST_CPPFLAGS) -DHAVE_CONFIG_H -I${KERNEL_ROOT_DIR}/include/salome LIBS += $(PYTHON_LIBS) $(SIP_LIBS) $(PYQT_LIBS) $(VTK_LIBS) $(OGL_LIBS) -LDFLAGS += -lsuit -lCAM -lstd -lqtx -lSalomeApp -lSalomeSession -lEvent -lLogWindow -lVTKViewer -lToolsGUI -L${KERNEL_ROOT_DIR}/lib/salome -lSalomeDS -lSalomePyQtGUI +LDFLAGS += -lsuit -lCAM -lstd -lqtx -lSalomeApp -lSalomeSession -lEvent -lLogWindow -lVTKViewer -lToolsGUI -lSalomePyQtGUI # Custom build step: generate C++ wrapping according to $(SIP_FILES) diff --git a/src/SALOME_PYQT/SalomePyQt/SalomePyQt.cxx b/src/SALOME_PYQT/SalomePyQt/SalomePyQt.cxx index d7b887fe6..67f222687 100644 --- a/src/SALOME_PYQT/SalomePyQt/SalomePyQt.cxx +++ b/src/SALOME_PYQT/SalomePyQt/SalomePyQt.cxx @@ -939,6 +939,24 @@ bool SalomePyQt::dumpView( const QString& filename ) return ProcessEvent( new TDumpViewEvent( filename ) ); } +/*! + SalomePyQt::defaultMenuGroup + Returns default menu group +*/ +class TDefMenuGroupEvent: public SALOME_Event { +public: + typedef int TResult; + TResult myResult; + TDefMenuGroupEvent() : myResult( -1 ) {} + virtual void Execute() { + myResult = SALOME_PYQT_Module::defaultMenuGroup(); + } +}; +int SalomePyQt::defaultMenuGroup() +{ + return ProcessEvent( new TDefMenuGroupEvent() ); +} + /*! SalomePyQt::createTool These methods allow operating with the toolbars: @@ -1045,10 +1063,10 @@ int SalomePyQt::createTool( QtxAction* a, const QString& tBar, const int id, con class CrMenu { public: - CrMenu( const QString& subMenu, const int menu, const int group, const int idx ) - : myCase( 0 ), mySubMenuName( subMenu ), myMenuId( menu ), myGroup( group ), myIndex( idx ) {} - CrMenu( const QString& subMenu, const QString& menu, const int group, const int idx ) - : myCase( 1 ), mySubMenuName( subMenu ), myMenuName( menu ), myGroup( group ), myIndex( idx ) {} + CrMenu( const QString& subMenu, const int menu, const int id, const int group, const int idx ) + : myCase( 0 ), mySubMenuName( subMenu ), myMenuId( menu ), myId( id ), myGroup( group ), myIndex( idx ) {} + CrMenu( const QString& subMenu, const QString& menu, const int id, const int group, const int idx ) + : myCase( 1 ), mySubMenuName( subMenu ), myMenuName( menu ), myId( id ), myGroup( group ), myIndex( idx ) {} CrMenu( const int id, const int menu, const int group, const int idx ) : myCase( 2 ), myId( id ), myMenuId( menu ), myGroup( group ), myIndex( idx ) {} CrMenu( const int id, const QString& menu, const int group, const int idx ) @@ -1063,9 +1081,9 @@ public: if ( module ) { switch ( myCase ) { case 0: - return module->createMenu( mySubMenuName, myMenuId, -1, myGroup, myIndex ); + return module->createMenu( mySubMenuName, myMenuId, myId, myGroup, myIndex ); case 1: - return module->createMenu( mySubMenuName, myMenuName, -1, myGroup, myIndex ); + return module->createMenu( mySubMenuName, myMenuName, myId, myGroup, myIndex ); case 2: return module->createMenu( myId, myMenuId, myGroup, myIndex ); case 3: @@ -1104,14 +1122,14 @@ public: } } }; -int SalomePyQt::createMenu( const QString& subMenu, const int menu, const int group, const int idx ) +int SalomePyQt::createMenu( const QString& subMenu, const int menu, const int id, const int group, const int idx ) { - return ProcessEvent( new TCreateMenuEvent( CrMenu( subMenu, menu, group, idx ) ) ); + return ProcessEvent( new TCreateMenuEvent( CrMenu( subMenu, menu, id, group, idx ) ) ); } -int SalomePyQt::createMenu( const QString& subMenu, const QString& menu, const int group, const int idx ) +int SalomePyQt::createMenu( const QString& subMenu, const QString& menu, const int id, const int group, const int idx ) { - return ProcessEvent( new TCreateMenuEvent( CrMenu( subMenu, menu, group, idx ) ) ); + return ProcessEvent( new TCreateMenuEvent( CrMenu( subMenu, menu, id, group, idx ) ) ); } int SalomePyQt::createMenu( const int id, const int menu, const int group, const int idx ) @@ -1253,3 +1271,32 @@ int SalomePyQt::actionId( const QtxAction* a ) { return ProcessEvent( new TActionIdEvent( a ) ); } + +/*! + SalomePyQt::clearMenu + Clears given menu (recursively if necessary) +*/ +class TClearMenuEvent: public SALOME_Event { +public: + typedef bool TResult; + TResult myResult; + int myId; + int myMenu; + bool myRemoveActions; + TClearMenuEvent( const int id, const int menu, const bool removeActions ) + : myResult( false ), myId( id ), myMenu( menu ), myRemoveActions( removeActions ) {} + virtual void Execute() { + if ( SalomeApp_Application* anApp = getApplication() ) { + SALOME_PYQT_Module* module = SALOME_PYQT_Module::getInitModule(); + if ( !module ) + module = dynamic_cast( anApp->activeModule() ); + if ( module ) + myResult = module->clearMenu( myId, myMenu, myRemoveActions ); + } + } +}; +bool SalomePyQt::clearMenu( const int id, const int menu, const bool removeActions ) +{ + return ProcessEvent( new TClearMenuEvent( id, menu, removeActions ) ); +} + diff --git a/src/SALOME_PYQT/SalomePyQt/SalomePyQt.h b/src/SALOME_PYQT/SalomePyQt/SalomePyQt.h index 51f245f23..a3022cb2a 100644 --- a/src/SALOME_PYQT/SalomePyQt/SalomePyQt.h +++ b/src/SALOME_PYQT/SalomePyQt/SalomePyQt.h @@ -102,6 +102,8 @@ public: static bool dumpView( const QString& ); + static int defaultMenuGroup(); + static int createTool( const QString& ); static int createTool( const int, const int, const int = -1 ); static int createTool( const int, const QString&, const int = -1 ); @@ -109,9 +111,9 @@ public: static int createTool( QtxAction*, const QString&, const int = -1, const int = -1 ); static int createMenu( const QString&, const int = -1, - const int = -1, const int = -1 ); + const int = -1, const int = -1, const int = -1 ); static int createMenu( const QString&, const QString& = QString::null, - const int = -1, const int = -1 ); + const int = -1, const int = -1, const int = -1 ); static int createMenu( const int, const int = -1, const int = -1, const int = -1 ); static int createMenu( const int, const QString& = QString::null, @@ -130,6 +132,9 @@ public: static QtxAction* action( const int ); static int actionId( const QtxAction* ); + static bool clearMenu( const int = 0, const int = 0, + const bool = true ); + static void addSetting ( const QString&, const QString&, const double ); static void addSetting ( const QString&, const QString&, const int ); static void addSetting ( const QString&, const QString&, const QString& ); diff --git a/src/SALOME_PYQT/SalomePyQt/SalomePyQt.sip b/src/SALOME_PYQT/SalomePyQt/SalomePyQt.sip index 3824647dd..813a9d710 100644 --- a/src/SALOME_PYQT/SalomePyQt/SalomePyQt.sip +++ b/src/SALOME_PYQT/SalomePyQt/SalomePyQt.sip @@ -81,6 +81,8 @@ public: static bool dumpView( const QString& ); + static int defaultMenuGroup(); + static int createTool( const QString& ); static int createTool( const int, const int, int = -1 ); static int createTool( const int, const QString&, int = -1 ); @@ -88,9 +90,9 @@ public: static int createTool( QtxAction*, const QString&, int = -1, int = -1 ); static int createMenu( const QString&, const int, - int = -1, int = -1 ); + int = -1, int = -1, int = -1 ); static int createMenu( const QString&, const QString&, - int = -1, int = -1 ); + int = -1, int = -1, int = -1 ); static int createMenu( const int, const int, int = -1, int = -1 ); static int createMenu( const int, const QString&, @@ -109,13 +111,16 @@ public: static QtxAction* action( const int ); static int actionId( const QtxAction* ); + static bool clearMenu( int = 0, int = 0, + bool = true ); + static void addSetting ( const QString&, const QString&, const double ); static void addSetting ( const QString&, const QString&, const int /Constrained/ ); static void addSetting ( const QString&, const QString&, const QString& ); static void addSetting ( const QString&, const QString&, const QColor& ); static int integerSetting( const QString&, const QString&, int = 0 ); static double doubleSetting ( const QString&, const QString&, int = 0 ); - static bool boolSetting ( const QString&, const QString&, bool = 0 ); + static bool boolSetting ( const QString&, const QString&, bool = false ); static QString stringSetting ( const QString&, const QString&, const QString& = QString("") ); static QColor colorSetting ( const QString&, const QString&, const QColor& = QColor() ); static void removeSetting ( const QString&, const QString& ); diff --git a/src/SALOME_PYQT/SalomePyQt/SalomePyQt_v4.sip b/src/SALOME_PYQT/SalomePyQt/SalomePyQt_v4.sip index f306399b1..c7371eb24 100644 --- a/src/SALOME_PYQT/SalomePyQt/SalomePyQt_v4.sip +++ b/src/SALOME_PYQT/SalomePyQt/SalomePyQt_v4.sip @@ -74,13 +74,15 @@ public: static void updateObjBrowser( const int = 0, bool = true ); static QString getFileName ( QWidget*, const QString&, const QStringList&, const QString&, bool ) /ReleaseGIL/ ; - static QStringList getOpenFileNames ( QWidget*, const QString&, const QStringList&, const QString& ); - static QString getExistingDirectory( QWidget*, const QString&, const QString& ); + static QStringList getOpenFileNames ( QWidget*, const QString&, const QStringList&, const QString& ) /ReleaseGIL/ ; + static QString getExistingDirectory( QWidget*, const QString&, const QString& ) /ReleaseGIL/ ; static void helpContext( const QString&, const QString& ); static bool dumpView( const QString& ); + static int defaultMenuGroup(); + static int createTool( const QString& ); static int createTool( const int, const int, const int = -1 ); static int createTool( const int, const QString&, const int = -1 ); @@ -88,9 +90,9 @@ public: static int createTool( QtxAction*, const QString&, const int = -1, const int = -1 ); static int createMenu( const QString&, const int, - const int = -1, const int = -1 ); + const int = -1, const int = -1, const int = -1 ); static int createMenu( const QString&, const QString&, - const int = -1, const int = -1 ); + const int = -1, const int = -1, const int = -1 ); static int createMenu( const int, const int, const int = -1, const int = -1 ); static int createMenu( const int, const QString&, @@ -99,7 +101,6 @@ public: const int = -1, const int = -1 ); static int createMenu( QtxAction*, const QString&, const int = -1, const int = -1, const int = -1 ); - static QtxAction* createSeparator(); static QtxAction* createAction( const int, const QString&, @@ -109,13 +110,16 @@ public: static QtxAction* action( const int ); static int actionId( const QtxAction* ); + static bool clearMenu( const int = 0, const int = 0, + const bool = true ); + static void addSetting ( const QString&, const QString&, const double ); static void addSetting ( const QString&, const QString&, const int /Constrained/ ); static void addSetting ( const QString&, const QString&, const QString& ); static void addSetting ( const QString&, const QString&, const QColor& ); static int integerSetting( const QString&, const QString&, const int = 0 ); static double doubleSetting ( const QString&, const QString&, const int = 0 ); - static bool boolSetting ( const QString&, const QString&, const bool = 0 ); + static bool boolSetting ( const QString&, const QString&, const bool = false ); static QString stringSetting ( const QString&, const QString&, const QString& = QString("") ); static QColor colorSetting ( const QString&, const QString&, const QColor& = QColor() ); static void removeSetting ( const QString&, const QString& ); diff --git a/src/SALOME_SWIG/SALOMEGUI_shared_modules.py b/src/SALOME_SWIG/SALOMEGUI_shared_modules.py index 086d5e7fe..cd849085d 100755 --- a/src/SALOME_SWIG/SALOMEGUI_shared_modules.py +++ b/src/SALOME_SWIG/SALOMEGUI_shared_modules.py @@ -4,6 +4,9 @@ import SALOME_Session_idl +from import_hook import register_name +register_name("SalomePyQt") + # this function is required def init_shared_modules(): diff --git a/src/SPlot2d/Makefile.in b/src/SPlot2d/Makefile.in index d0a8d1604..44334e80b 100644 --- a/src/SPlot2d/Makefile.in +++ b/src/SPlot2d/Makefile.in @@ -39,8 +39,8 @@ LIB_MOC = \ # SALOME_GenericObj.idl #CPPFLAGS+=$(QT_INCLUDES) $(OCC_INCLUDES) $(OGL_INCLUDES) $(PYTHON_INCLUDES) $(QWT_INCLUDES) $(BOOST_CPPFLAGS) -I$(KERNEL_ROOT_DIR)/include/salome -CPPFLAGS+=$(QT_INCLUDES) $(OCC_INCLUDES) $(QWT_INCLUDES) $(BOOST_CPPFLAGS) -I$(KERNEL_ROOT_DIR)/include/salome -LDFLAGS+=$(QT_MT_LIBS) $(QWT_LIBS) -L$(KERNEL_ROOT_DIR)/lib/salome -lsuit -lPlot2d -lSalomePrs +CPPFLAGS+=$(QT_INCLUDES) $(OCC_INCLUDES) $(QWT_INCLUDES) $(BOOST_CPPFLAGS) +LDFLAGS+=$(QT_MT_LIBS) $(QWT_LIBS) -lsuit -lPlot2d -lSalomePrs @CONCLUDE@ diff --git a/src/STD/STD_Application.cxx b/src/STD/STD_Application.cxx index a3ab1739e..68b7b1a06 100755 --- a/src/STD/STD_Application.cxx +++ b/src/STD/STD_Application.cxx @@ -199,32 +199,32 @@ void STD_Application::createActions() // Create menus - int fileMenu = createMenu( tr( "MEN_DESK_FILE" ), -1, -1, 0 ); - int editMenu = createMenu( tr( "MEN_DESK_EDIT" ), -1, -1, 10 ); - int viewMenu = createMenu( tr( "MEN_DESK_VIEW" ), -1, -1, 10 ); - int helpMenu = createMenu( tr( "MEN_DESK_HELP" ), -1, -1, 1000 ); + int fileMenu = createMenu( tr( "MEN_DESK_FILE" ), -1, MenuFileId, 0 ); + int editMenu = createMenu( tr( "MEN_DESK_EDIT" ), -1, MenuEditId, 10 ); + int viewMenu = createMenu( tr( "MEN_DESK_VIEW" ), -1, MenuViewId, 10 ); + int helpMenu = createMenu( tr( "MEN_DESK_HELP" ), -1, MenuHelpId, 1000 ); // Create menu items - createMenu( FileNewId, fileMenu, 0 ); - createMenu( FileOpenId, fileMenu, 0 ); - createMenu( FileLoadId, fileMenu, 0 ); //SRN: BugID IPAL9021, add a menu item "Load" - createMenu( FileCloseId, fileMenu, 0 ); - createMenu( separator(), fileMenu, -1, 0 ); - createMenu( FileSaveId, fileMenu, 0 ); + createMenu( FileNewId, fileMenu, 0 ); + createMenu( FileOpenId, fileMenu, 0 ); + createMenu( FileLoadId, fileMenu, 0 ); //SRN: BugID IPAL9021, add a menu item "Load" + createMenu( FileCloseId, fileMenu, 0 ); + createMenu( separator(), fileMenu, -1, 0 ); + createMenu( FileSaveId, fileMenu, 0 ); createMenu( FileSaveAsId, fileMenu, 0 ); - createMenu( separator(), fileMenu, -1, 0 ); + createMenu( separator(), fileMenu, -1, 0 ); - createMenu( separator(), fileMenu ); - createMenu( FileExitId, fileMenu ); + createMenu( separator(), fileMenu ); + createMenu( FileExitId, fileMenu ); - createMenu( EditCopyId, editMenu ); + createMenu( EditCopyId, editMenu ); createMenu( EditPasteId, editMenu ); createMenu( separator(), editMenu ); - createMenu( ViewWindowsId, viewMenu ); + createMenu( ViewWindowsId, viewMenu ); createMenu( ViewStatusBarId, viewMenu ); - createMenu( separator(), viewMenu ); + createMenu( separator(), viewMenu ); createMenu( HelpAboutId, helpMenu ); createMenu( separator(), helpMenu ); @@ -547,8 +547,8 @@ void STD_Application::setEditEnabled( bool theEnable ) for ( int i = EditCopyId; i <= EditPasteId; i++ ) { - mMgr->setShown( i, myEditEnabled ); - tMgr->setShown( i, myEditEnabled ); + mMgr->setShown( mMgr->actionId(action(i)), myEditEnabled ); + tMgr->setShown( tMgr->actionId(action(i)), myEditEnabled ); } } diff --git a/src/STD/STD_Application.h b/src/STD/STD_Application.h index c8e3b4ad5..cd63268bd 100755 --- a/src/STD/STD_Application.h +++ b/src/STD/STD_Application.h @@ -120,9 +120,19 @@ private slots: virtual void onViewManagerActivated( SUIT_ViewManager* ); protected: - enum { FileNewId, FileOpenId, FileCloseId, FileSaveId, FileSaveAsId, - FileExitId, EditCutId, EditCopyId, EditPasteId, ViewStatusBarId, - NewWindowId, HelpAboutId, ViewWindowsId, FileLoadId, UserID }; + enum { MenuFileId = 1, + MenuViewId = 2, + MenuEditId = 3, + MenuHelpId = 7 + }; + + enum { FileNewId, FileOpenId, FileLoadId, FileCloseId, + FileSaveId, FileSaveAsId, FileExitId, + ViewStatusBarId, ViewWindowsId, NewWindowId, + EditCutId, EditCopyId, EditPasteId, + HelpAboutId, + UserID + }; protected: virtual void createActions(); diff --git a/src/STD/STD_MDIDesktop.cxx b/src/STD/STD_MDIDesktop.cxx index aec25bb59..214e8a767 100755 --- a/src/STD/STD_MDIDesktop.cxx +++ b/src/STD/STD_MDIDesktop.cxx @@ -183,7 +183,7 @@ void STD_MDIDesktop::createActions() if ( !mMgr ) return; - int winMenuId = mMgr->insert( tr( "MEN_DESK_WINDOW" ), -1, 100 ); + int winMenuId = mMgr->insert( tr( "MEN_DESK_WINDOW" ), -1, 100, MenuWindowId ); mMgr->insert( myWorkspaceAction, winMenuId, -1 ); mMgr->insert( QtxActionMenuMgr::separator(), winMenuId, -1 ); } diff --git a/src/STD/STD_MDIDesktop.h b/src/STD/STD_MDIDesktop.h index 25ec9cb08..e61f5c3d5 100755 --- a/src/STD/STD_MDIDesktop.h +++ b/src/STD/STD_MDIDesktop.h @@ -37,6 +37,7 @@ class STD_EXPORT STD_MDIDesktop: public SUIT_Desktop Q_OBJECT public: + enum { MenuWindowId = 6 }; enum { Cascade, Tile, HTile, VTile }; public: diff --git a/src/STD/STD_TabDesktop.cxx b/src/STD/STD_TabDesktop.cxx index 24dfd5ccf..5fdfce584 100644 --- a/src/STD/STD_TabDesktop.cxx +++ b/src/STD/STD_TabDesktop.cxx @@ -177,7 +177,7 @@ void STD_TabDesktop::createActions() if ( !mMgr ) return; - int winMenuId = mMgr->insert( tr( "MEN_DESK_WINDOW" ), -1, 100 ); + int winMenuId = mMgr->insert( tr( "MEN_DESK_WINDOW" ), -1, 100, MenuWindowId ); mMgr->insert( myWorkstackAction, winMenuId, -1 ); mMgr->insert( QtxActionMenuMgr::separator(), winMenuId, -1 ); } diff --git a/src/STD/STD_TabDesktop.h b/src/STD/STD_TabDesktop.h index f3b1d1282..c91b6e08e 100644 --- a/src/STD/STD_TabDesktop.h +++ b/src/STD/STD_TabDesktop.h @@ -38,6 +38,7 @@ class STD_EXPORT STD_TabDesktop: public SUIT_Desktop Q_OBJECT public: + enum { MenuWindowId = 6 }; enum { VSplit, HSplit }; public: diff --git a/src/SUIT/SUIT_Accel.cxx b/src/SUIT/SUIT_Accel.cxx index a72a317e1..887b98bca 100644 --- a/src/SUIT/SUIT_Accel.cxx +++ b/src/SUIT/SUIT_Accel.cxx @@ -21,60 +21,116 @@ ////////////////////////////////////////////////////////////////////// #include "SUIT_Accel.h" -#include "SUIT_Desktop.h" -#include "SUIT_ViewManager.h" #include "SUIT_ViewWindow.h" +#include "SUIT_ViewManager.h" #include "SUIT_ViewModel.h" -#include +#include +#include +#include + /*!\class SUIT_Accel * Class handles keyboard accelerator bindings. */ +SUIT_Accel* SUIT_Accel::myself = 0; -/*! Constructor.*/ -SUIT_Accel::SUIT_Accel(SUIT_Desktop* theDesktop) - : QObject( theDesktop, "SUIT_Accel" ), - myDesktop( theDesktop ) +/*! Constructor [private].*/ +SUIT_Accel::SUIT_Accel() + : QObject( qApp, "SUIT_Accel" ) { - myAccel = new QAccel( theDesktop, "SUIT_Accel_interal_qaccel" ); - connect( myAccel, SIGNAL( activated( int ) ), this, SLOT( onActivated( int ) ) ); + qApp->installEventFilter( this ); } -/*! Destructor.*/ -SUIT_Accel::~SUIT_Accel() +/*! getAccel() : public interface for SUIT_Accel object. Only one instance is created and returned. */ +SUIT_Accel* SUIT_Accel::getAccel() { + if ( !myself ) + myself = new SUIT_Accel(); + return myself; } -/*! setActionKey assign a ceratain action for a key accelerator */ +/*! setActionKey() : assign a ceratain action for a key accelerator */ void SUIT_Accel::setActionKey( const int action, const int key, const QString& type ) -{ - // 1. get or generate interal "id" of action - int id = myAccel->findKey( key ); - if ( id == -1 ) - id = myAccel->insertItem( key ); - +{ IdActionMap idActionMap; if ( myMap.contains( type ) ) idActionMap = myMap[type]; - idActionMap[id] = action; + idActionMap[key] = action; myMap[type] = idActionMap; + + myOptMap[key] = true; } -/*! onActivated slot called when a registered key accelerator was activated */ -void SUIT_Accel::onActivated( int id ) +/*! unsetActionKey() : unregister a certain key accelerator */ +void SUIT_Accel::unsetActionKey( const int key, const QString& type ) { - if ( myDesktop ) { - if ( SUIT_ViewWindow* vw = myDesktop->activeWindow() ) { + if ( myMap.contains( type ) ) { + IdActionMap idActionMap = myMap[type]; + if ( idActionMap.contains( key ) ) { + idActionMap.erase( key ); + myMap[type] = idActionMap; + } + } +} + +/*! getParentViewWindow() : returns given object or any of its parents-grandparents-.. if it is a SUIT_ViewWindow */ +SUIT_ViewWindow* getParentViewWindow( const QObject* obj ) +{ + if ( obj ) { + if ( obj->inherits( "SUIT_ViewWindow" ) ) + return (SUIT_ViewWindow*)obj; + else + return getParentViewWindow( obj->parent() ); + } + return 0; +} + +/*! getKey() : returns integer key code (with modifiers) made of key pressed 'inside' given event */ +int getKey( QKeyEvent *keyEvent ) +{ + int key = keyEvent->key(), + state = keyEvent->state(); + if ( state & Qt::ShiftButton ) + key += Qt::SHIFT; + if ( state & Qt::ControlButton ) + key += Qt::CTRL; + if ( state & Qt::AltButton ) + key += Qt::ALT; + if ( state & Qt::MetaButton ) + key += Qt::META; + return key; +} + +/*! getAccelKey() : returns key pressed if 1) event was KeyPress 2) pressed key is a registered accelerator */ +int SUIT_Accel::getAccelKey( QEvent *event ) +{ + if ( event && event->type() == QEvent::KeyPress ) { + int key = ::getKey( (QKeyEvent*)event ); + if ( myOptMap.contains( key ) ) + return key; + } + return 0; +} + +/*! eventFilter() : filtering ALL events of QApplication. */ +bool SUIT_Accel::eventFilter( QObject *obj, QEvent *event ) +{ + const int key = getAccelKey( event ); + if ( key ) { + SUIT_ViewWindow* vw = ::getParentViewWindow( obj ); + if ( vw ) { QString type = vw->getViewManager()->getViewModel()->getType(); - if ( myMap.contains( type ) ) { + if ( myMap.contains( type ) ) { IdActionMap idActionMap = myMap[type]; - if ( idActionMap.contains( id ) ) { - vw->onAccelAction( idActionMap[id] ); + if ( idActionMap.contains( key ) ) { + vw->onAccelAction( idActionMap[key] ); + return true; } } } } + return false; } - + diff --git a/src/SUIT/SUIT_Accel.h b/src/SUIT/SUIT_Accel.h index 78c9bff30..ee3e96cf6 100644 --- a/src/SUIT/SUIT_Accel.h +++ b/src/SUIT/SUIT_Accel.h @@ -29,9 +29,6 @@ #include #include -class QAccel; -class SUIT_Desktop; - class SUIT_EXPORT SUIT_Accel: public QObject { Q_OBJECT @@ -53,21 +50,28 @@ public: }; public: - SUIT_Accel( SUIT_Desktop* theDesktop ); - virtual ~SUIT_Accel(); + static SUIT_Accel* getAccel(); void setActionKey( const int action, const int key, const QString& type ); + void unsetActionKey( const int key, const QString& type ); -protected slots: - void onActivated( int ); +protected: + bool eventFilter( QObject *, QEvent * ); private: - QAccel* myAccel; - SUIT_Desktop* myDesktop; + SUIT_Accel(); + + int getAccelKey( QEvent* ); // returns key pressed if 1) event was KeyPress + // 2) pressed key is a registered accelerator - typedef QMap IdActionMap; // internal_id - to - action map + typedef QMap IdActionMap; // key - to - action_id map typedef QMap ViewerTypeIdActionMap; // viewer_type - to - IdActionMap ViewerTypeIdActionMap myMap; + + QMap myOptMap; // key - to - map, used for optimazation. all registered keys (accelerators) + // are stored in this map. + + static SUIT_Accel* myself; }; #endif diff --git a/src/SUIT/SUIT_Application.cxx b/src/SUIT/SUIT_Application.cxx index f187bfabd..bf0daebe6 100755 --- a/src/SUIT/SUIT_Application.cxx +++ b/src/SUIT/SUIT_Application.cxx @@ -186,8 +186,9 @@ int SUIT_Application::createTool( QAction* a, const int tBar, const int id, cons if ( !desktop() || !desktop()->toolMgr() ) return -1; - int regId = desktop()->toolMgr()->registerAction( a, id ); - return desktop()->toolMgr()->insert( regId, tBar, idx ); + int regId = registerAction( id, a ); + int intId = desktop()->toolMgr()->insert( a, tBar, idx ); + return intId != -1 ? regId : -1; } int SUIT_Application::createTool( QAction* a, const QString& tBar, const int id, const int idx ) @@ -195,7 +196,9 @@ int SUIT_Application::createTool( QAction* a, const QString& tBar, const int id, if ( !desktop() || !desktop()->toolMgr() ) return -1; - return desktop()->toolMgr()->insert( a, tBar, idx ); + int regId = registerAction( id, a ); + int intId = desktop()->toolMgr()->insert( a, tBar, idx ); + return intId != -1 ? regId : -1; } int SUIT_Application::createTool( const int id, const int tBar, const int idx ) @@ -203,7 +206,8 @@ int SUIT_Application::createTool( const int id, const int tBar, const int idx ) if ( !desktop() || !desktop()->toolMgr() ) return -1; - return desktop()->toolMgr()->insert( id, tBar, idx ); + int intId = desktop()->toolMgr()->insert( action( id ), tBar, idx ); + return intId != -1 ? id : -1; } int SUIT_Application::createTool( const int id, const QString& tBar, const int idx ) @@ -211,7 +215,8 @@ int SUIT_Application::createTool( const int id, const QString& tBar, const int i if ( !desktop() || !desktop()->toolMgr() ) return -1; - return desktop()->toolMgr()->insert( id, tBar, idx ); + int intId = desktop()->toolMgr()->insert( action( id ), tBar, idx ); + return intId != -1 ? id : -1; } int SUIT_Application::createMenu( const QString& subMenu, const int menu, @@ -220,7 +225,7 @@ int SUIT_Application::createMenu( const QString& subMenu, const int menu, if ( !desktop() || !desktop()->menuMgr() ) return -1; - return desktop()->menuMgr()->insert( subMenu, menu, group, index ); + return desktop()->menuMgr()->insert( subMenu, menu, group, id, index ); } int SUIT_Application::createMenu( const QString& subMenu, const QString& menu, @@ -229,7 +234,7 @@ int SUIT_Application::createMenu( const QString& subMenu, const QString& menu, if ( !desktop() || !desktop()->menuMgr() ) return -1; - return desktop()->menuMgr()->insert( subMenu, menu, group, index ); + return desktop()->menuMgr()->insert( subMenu, menu, group, id, index ); } int SUIT_Application::createMenu( QAction* a, const int menu, const int id, const int group, const int index ) @@ -237,8 +242,9 @@ int SUIT_Application::createMenu( QAction* a, const int menu, const int id, cons if ( !a || !desktop() || !desktop()->menuMgr() ) return -1; - int regId = desktop()->menuMgr()->registerAction( a, id ); - return desktop()->menuMgr()->insert( regId, menu, group, index ); + int regId = registerAction( id, a ); + int intId = desktop()->menuMgr()->insert( a, menu, group, index ); + return intId != -1 ? regId : -1; } int SUIT_Application::createMenu( QAction* a, const QString& menu, const int id, const int group, const int index ) @@ -246,8 +252,9 @@ int SUIT_Application::createMenu( QAction* a, const QString& menu, const int id, if ( !a || !desktop() || !desktop()->menuMgr() ) return -1; - int regId = desktop()->menuMgr()->registerAction( a, id ); - return desktop()->menuMgr()->insert( regId, menu, group, index ); + int regId = registerAction( id, a ); + int intId = desktop()->menuMgr()->insert( a, menu, group, index ); + return intId != -1 ? regId : -1; } int SUIT_Application::createMenu( const int id, const int menu, const int group, const int index ) @@ -255,7 +262,8 @@ int SUIT_Application::createMenu( const int id, const int menu, const int group, if ( !desktop() || !desktop()->menuMgr() ) return -1; - return desktop()->menuMgr()->insert( id, menu, group, index ); + int intId = desktop()->menuMgr()->insert( action( id ), menu, group, index ); + return intId != -1 ? id : -1; } int SUIT_Application::createMenu( const int id, const QString& menu, const int group, const int index ) @@ -263,7 +271,8 @@ int SUIT_Application::createMenu( const int id, const QString& menu, const int g if ( !desktop() || !desktop()->menuMgr() ) return -1; - return desktop()->menuMgr()->insert( id, menu, group, index ); + int intId = desktop()->menuMgr()->insert( action( id ), menu, group, index ); + return intId != -1 ? id : -1; } void SUIT_Application::setMenuShown( QAction* a, const bool on ) @@ -302,31 +311,21 @@ void SUIT_Application::setActionShown( const int id, const bool on ) QAction* SUIT_Application::action( const int id ) const { - SUIT_Application* that = (SUIT_Application*)this; - SUIT_Desktop* desk = that->desktop(); - if ( !desk ) - return 0; - QAction* a = 0; - if ( desk->menuMgr() ) - a = desk->menuMgr()->action( id ); - if ( !a && desk->toolMgr() ) - a = desk->toolMgr()->action( id ); + if ( myActionMap.contains( id ) ) + a = myActionMap[id]; return a; } int SUIT_Application::actionId( const QAction* a ) const { - SUIT_Application* that = (SUIT_Application*)this; - SUIT_Desktop* desk = that->desktop(); - if ( !desk ) - return 0; - int id = -1; - if ( desk->menuMgr() ) - id = desk->menuMgr()->actionId( a ); - if ( id == -1 && desk->toolMgr() ) - id = desk->toolMgr()->actionId( a ); + for ( QMap::ConstIterator it = myActionMap.begin(); + it != myActionMap.end() && id == -1; + ++it ) { + if ( it.data() == a ) + id = it.key(); + } return id; } @@ -345,13 +344,27 @@ QAction* SUIT_Application::createAction( const int id, const QString& text, cons return a; } -void SUIT_Application::registerAction( const int id, QAction* a ) +int SUIT_Application::registerAction( const int id, QAction* a ) { + int ident = actionId( a ); + if ( ident != -1 ) + return ident; + + static int generatedId = -1; + ident = id == -1 ? --generatedId : id; + + if ( action( ident ) ) + qWarning( "Action registration id is already in use: %d", ident ); + + myActionMap.insert( ident, a ); + if ( desktop() && desktop()->menuMgr() ) - desktop()->menuMgr()->registerAction( a, id ); + desktop()->menuMgr()->registerAction( a ); if ( desktop() && desktop()->toolMgr() ) - desktop()->toolMgr()->registerAction( a, id ); + desktop()->toolMgr()->registerAction( a ); + + return ident; } QAction* SUIT_Application::separator() diff --git a/src/SUIT/SUIT_Application.h b/src/SUIT/SUIT_Application.h index b630177e6..5bab83a14 100755 --- a/src/SUIT/SUIT_Application.h +++ b/src/SUIT/SUIT_Application.h @@ -146,7 +146,7 @@ protected: static QAction* separator(); QAction* action( const int ) const; int actionId( const QAction* ) const; - void registerAction( const int, QAction* ); + int registerAction( const int, QAction* ); QAction* createAction( const int, const QString&, const QIconSet&, const QString&, const QString&, const int, QObject* = 0, const bool = false, QObject* = 0, const char* = 0 ); @@ -157,6 +157,7 @@ protected slots: private: SUIT_Study* myStudy; SUIT_Desktop* myDesktop; + QMap myActionMap; QLabel* myStatusLabel; }; diff --git a/src/SUIT/SUIT_DataObject.cxx b/src/SUIT/SUIT_DataObject.cxx index afc3446f3..ddb393817 100755 --- a/src/SUIT/SUIT_DataObject.cxx +++ b/src/SUIT/SUIT_DataObject.cxx @@ -22,8 +22,6 @@ #include "SUIT_DataObjectKey.h" -#include // for cout in dump() - /*! Constructor */ @@ -491,7 +489,7 @@ SUIT_DataObjectKey* SUIT_DataObject::key() const void SUIT_DataObject::dump( const int indent ) const { QString strIndent = QString().fill( ' ', indent ); // indentation string - std::cout << strIndent << name() << std::endl; // dump to cout + printf( "%s%s\n", strIndent.latin1(), name().latin1() ); for ( DataObjectListIterator it( myChildren ); it.current(); ++it ) // iterate all children it.current()->dump( indent + 2 ); // dump every child with indent + 2 spaces } diff --git a/src/SUIT/SUIT_ExceptionHandler.cxx b/src/SUIT/SUIT_ExceptionHandler.cxx index 391093418..851291d4e 100755 --- a/src/SUIT/SUIT_ExceptionHandler.cxx +++ b/src/SUIT/SUIT_ExceptionHandler.cxx @@ -49,6 +49,9 @@ void SUIT_ExceptionHandler::showMessage( const QString& title, const QString& ms { if ( !qApp ) return; - + + while ( QApplication::overrideCursor() ) + QApplication::restoreOverrideCursor(); + SUIT_MessageBox::error1( qApp->mainWidget(), title, msg, "OK" ); } diff --git a/src/SUIT/SUIT_Session.cxx b/src/SUIT/SUIT_Session.cxx index 03f32ee74..7eca7329a 100755 --- a/src/SUIT/SUIT_Session.cxx +++ b/src/SUIT/SUIT_Session.cxx @@ -290,7 +290,7 @@ SUIT_Session::AppLib SUIT_Session::loadLibrary( const QString& name, QString& li #ifdef WIN32 lib = ::LoadLibrary( (char*)libFile.latin1() ); #else - lib = dlopen( (char*)libFile.latin1(), RTLD_LAZY ); + lib = dlopen( (char*)libFile.latin1(), RTLD_LAZY /*| RTLD_GLOBAL */ ); #endif return lib; } diff --git a/src/SUIT/SUIT_Study.cxx b/src/SUIT/SUIT_Study.cxx index 2f83179c4..995aede9e 100755 --- a/src/SUIT/SUIT_Study.cxx +++ b/src/SUIT/SUIT_Study.cxx @@ -510,3 +510,18 @@ bool SUIT_Study::hasTransaction() const { return false; } + +/*! + * \brief Stores the study state +*/ +int SUIT_Study::storeState() +{ + return -1; +} + +/*! + * \brief Restores the study state +*/ +void SUIT_Study::restoreState(int savePoint) +{ +} diff --git a/src/SUIT/SUIT_Study.h b/src/SUIT/SUIT_Study.h index c1163cc6c..da090c8a0 100755 --- a/src/SUIT/SUIT_Study.h +++ b/src/SUIT/SUIT_Study.h @@ -75,6 +75,9 @@ public: bool suspend( SUIT_Operation* ); bool resume( SUIT_Operation* ); + virtual int storeState(); + virtual void restoreState(int savePoint); + signals: void studyModified( SUIT_Study* ); diff --git a/src/SUIT/SUIT_TreeSync.h b/src/SUIT/SUIT_TreeSync.h index d38f6fcdf..19bdf4edd 100644 --- a/src/SUIT/SUIT_TreeSync.h +++ b/src/SUIT/SUIT_TreeSync.h @@ -38,10 +38,12 @@ const typename QValueList::const_iterator findEqual( const QValueList TrgItem synchronize( const SrcItem& r1, const TrgItem& r2, const TreeData& td ) { - // printf( "--- synchronize : %d ---\n", ++gSync ); - if( td.isEqual( r1, r2 ) ) { + // update items themselves + td.updateItem( r2 ); + + // iterate 'siblings' (direct children) QValueList< DiffItem< SrcItem, TrgItem > > d; diffSiblings( r1, r2, d, td ); diff --git a/src/SUIT/SUIT_ViewWindow.cxx b/src/SUIT/SUIT_ViewWindow.cxx index bd4c32e69..3b013f679 100755 --- a/src/SUIT/SUIT_ViewWindow.cxx +++ b/src/SUIT/SUIT_ViewWindow.cxx @@ -158,3 +158,12 @@ void SUIT_ViewWindow::onAccelAction( int _action ) void SUIT_ViewWindow::action( const int ) { } + +QString SUIT_ViewWindow::getVisualParameters() +{ + return "empty"; +} + +void SUIT_ViewWindow::setVisualParameters( const QString& parameters ) +{ +} diff --git a/src/SUIT/SUIT_ViewWindow.h b/src/SUIT/SUIT_ViewWindow.h index 1ac79a504..200deb1c4 100755 --- a/src/SUIT/SUIT_ViewWindow.h +++ b/src/SUIT/SUIT_ViewWindow.h @@ -52,6 +52,9 @@ public: void onAccelAction( int ); + virtual QString getVisualParameters(); + virtual void setVisualParameters( const QString& parameters ); + public slots: virtual void onDumpView(); diff --git a/src/SUPERVGraph/Makefile.in b/src/SUPERVGraph/Makefile.in index 149feb93f..8772d041e 100755 --- a/src/SUPERVGraph/Makefile.in +++ b/src/SUPERVGraph/Makefile.in @@ -35,7 +35,7 @@ RESOURCES_FILES = view_pan.png \ LIB_CLIENT_IDL = CPPFLAGS+=$(QT_INCLUDES) $(OCC_INCLUDES) $(PYTHON_INCLUDES) $(BOOST_CPPFLAGS) -I${KERNEL_ROOT_DIR}/include/salome -LDFLAGS+=$(QT_MT_LIBS) -L$(top_builddir)/lib +LDFLAGS+=$(QT_MT_LIBS) -L$(top_builddir)/lib -lsuit @CONCLUDE@ diff --git a/src/SVTK/SVTK_CubeAxesDlg.cxx b/src/SVTK/SVTK_CubeAxesDlg.cxx index daed6845e..57c9e5694 100644 --- a/src/SVTK/SVTK_CubeAxesDlg.cxx +++ b/src/SVTK/SVTK_CubeAxesDlg.cxx @@ -33,6 +33,7 @@ #include "SVTK_CubeAxesActor2D.h" #include "QtxAction.h" +#include "QtxIntSpinBox.h" #include #include @@ -88,15 +89,13 @@ SVTK_AxisWidget::SVTK_AxisWidget (QWidget* theParent) aHBox = new QHBox(myLabelsGrp); aHBox->setSpacing(5); aLabel = new QLabel(tr("NUMBER"), aHBox); - myLabelNumber = new QLineEdit(aHBox); - myLabelNumber->setValidator(new QIntValidator(0, 25, this)); - myLabelNumber->installEventFilter(this); + myLabelNumber = new QtxIntSpinBox(0,25,1,aHBox,"SpinBoxLabelNumber"); aLabels.append(aLabel); aHBox = new QHBox(myLabelsGrp); aHBox->setSpacing(5); aLabel = new QLabel(tr("OFFSET"), aHBox); - myLabelOffset = new QLineEdit(aHBox); + myLabelOffset = new QtxIntSpinBox(0,100,1,aHBox,"SpinBoxLabellOffset"); aLabels.append(aLabel); aHBox = new QHBox(myLabelsGrp); @@ -113,7 +112,8 @@ SVTK_AxisWidget::SVTK_AxisWidget (QWidget* theParent) aHBox = new QHBox(myTicksGrp); aHBox->setSpacing(5); aLabel = new QLabel(tr("LENGTH"), aHBox); - myTickLength = new QLineEdit(aHBox); + myTickLength = new QtxIntSpinBox(0,100,1,aHBox,"SpinBoxTickLength"); + aLabels.append(aLabel); // Layout @@ -154,16 +154,6 @@ void SVTK_AxisWidget::updateControlState() onTicksChecked(); } -bool SVTK_AxisWidget::eventFilter(QObject* o, QEvent* e) -{ - if (e->type() == QEvent::FocusOut) { - bool isOK = false; - int k = myLabelNumber->text().toInt(&isOK); - if (isOK && k > 25) myLabelNumber->setText("25"); - } - return false; -} - //======================================================================= // name : SVTK_AxisWidget::onNameChecked // Purpose : @@ -296,8 +286,8 @@ bool SVTK_AxisWidget::ReadData(vtkAxisActor2D* theActor) } myIsLabelsVisible->setChecked(useLabels); - myLabelNumber->setText(QString("%1").arg(nbLabels)); - myLabelOffset->setText(QString("%1").arg(anOffset)); + myLabelNumber->setValue(nbLabels); + myLabelOffset->setValue(anOffset); myLabelsFont->SetData(aLabelsColor, aLabelsFontFamily, isLabelsBold, isLabelsItalic, isLabelsShadow); // Tick marks @@ -305,7 +295,7 @@ bool SVTK_AxisWidget::ReadData(vtkAxisActor2D* theActor) int aTickLength = theActor->GetTickLength(); myIsTicksVisible->setChecked(useTickMarks); - myTickLength->setText(QString("%1").arg(aTickLength)); + myTickLength->setValue(aTickLength); return true; } @@ -350,14 +340,11 @@ bool SVTK_AxisWidget::Apply(vtkAxisActor2D* theActor) theActor->SetLabelVisibility(myIsLabelsVisible->isChecked() ? 1 : 0); - bool isOk = false; - int nbLabels = myLabelNumber->text().toInt(&isOk); - if (isOk) - theActor->SetNumberOfLabels(nbLabels); + int nbLabels = myLabelNumber->value(); + theActor->SetNumberOfLabels(nbLabels); - int anOffset = myLabelOffset->text().toInt(&isOk); - if (isOk) - theActor->SetTickOffset(anOffset); + int anOffset = myLabelOffset->value(); + theActor->SetTickOffset(anOffset); QColor aLabelsColor(255, 255, 255); int aLabelsFontFamily = VTK_ARIAL; @@ -385,9 +372,8 @@ bool SVTK_AxisWidget::Apply(vtkAxisActor2D* theActor) // Tick marks theActor->SetTickVisibility(myIsTicksVisible->isChecked()); - int aTickLength = myTickLength->text().toInt(&isOk); - if (isOk) - theActor->SetTickLength(aTickLength); + int aTickLength = myTickLength->value(); + theActor->SetTickLength(aTickLength); return true; } @@ -518,6 +504,10 @@ bool SVTK_CubeAxesDlg::onApply() try { + QWidget *aCurrWid = this->focusWidget(); + aCurrWid->clearFocus(); + aCurrWid->setFocus(); + isOk = isOk && myAxes[ 0 ]->Apply(myActor->GetXAxisActor2D()); isOk = isOk && myAxes[ 1 ]->Apply(myActor->GetYAxisActor2D()); isOk = isOk && myAxes[ 2 ]->Apply(myActor->GetZAxisActor2D()); diff --git a/src/SVTK/SVTK_CubeAxesDlg.h b/src/SVTK/SVTK_CubeAxesDlg.h index bd7e5254c..642306084 100644 --- a/src/SVTK/SVTK_CubeAxesDlg.h +++ b/src/SVTK/SVTK_CubeAxesDlg.h @@ -39,6 +39,7 @@ class QLineEdit; class QGroupBox; class QtxAction; +class QtxIntSpinBox; class vtkAxisActor2D; class SVTK_CubeAxesActor2D; @@ -107,9 +108,6 @@ public: bool ReadData( vtkAxisActor2D* ); bool Apply( vtkAxisActor2D* ); -protected: - bool eventFilter(QObject*, QEvent*); - private slots: void onNameChecked(); void onLabelsChecked(); @@ -129,14 +127,14 @@ private: // labels QGroupBox* myLabelsGrp; QCheckBox* myIsLabelsVisible; - QLineEdit* myLabelNumber; - QLineEdit* myLabelOffset; + QtxIntSpinBox* myLabelNumber; + QtxIntSpinBox* myLabelOffset; SVTK_FontWidget* myLabelsFont; // tick marks QGroupBox* myTicksGrp; QCheckBox* myIsTicksVisible; - QLineEdit* myTickLength; + QtxIntSpinBox* myTickLength; friend class SVTK_CubeAxesDlg; }; diff --git a/src/SVTK/SVTK_MainWindow.cxx b/src/SVTK/SVTK_MainWindow.cxx index ad01609bc..145aa9aa5 100644 --- a/src/SVTK/SVTK_MainWindow.cxx +++ b/src/SVTK/SVTK_MainWindow.cxx @@ -265,9 +265,9 @@ SVTK_MainWindow //---------------------------------------------------------------------------- void SVTK_MainWindow -::SetTrihedronSize( const int theSize ) +::SetTrihedronSize( const int theSize, const bool theRelative ) { - GetRenderer()->SetTrihedronSize(theSize); + GetRenderer()->SetTrihedronSize(theSize, theRelative); Repaint(); } diff --git a/src/SVTK/SVTK_MainWindow.h b/src/SVTK/SVTK_MainWindow.h index 758093797..45f525f28 100644 --- a/src/SVTK/SVTK_MainWindow.h +++ b/src/SVTK/SVTK_MainWindow.h @@ -150,7 +150,7 @@ public: //! Redirect the request to #SVTK_Renderer::SetTrihedronSize void - SetTrihedronSize(const int theSize); + SetTrihedronSize(const int theSize, const bool theRelative = true); //! Redirect the request to #SVTK_Renderer::AdjustActors void diff --git a/src/SVTK/SVTK_RenderWindowInteractor.cxx b/src/SVTK/SVTK_RenderWindowInteractor.cxx index a2b8aa176..0d4142995 100644 --- a/src/SVTK/SVTK_RenderWindowInteractor.cxx +++ b/src/SVTK/SVTK_RenderWindowInteractor.cxx @@ -162,7 +162,7 @@ void QVTK_RenderWindowInteractor ::paintEvent( QPaintEvent* theEvent ) { - GetDevice()->Render(); + GetDevice()->CreateTimer(VTKI_TIMER_FIRST); } diff --git a/src/SVTK/SVTK_Renderer.cxx b/src/SVTK/SVTK_Renderer.cxx index cad43a139..8302903a3 100644 --- a/src/SVTK/SVTK_Renderer.cxx +++ b/src/SVTK/SVTK_Renderer.cxx @@ -74,7 +74,8 @@ SVTK_Renderer myTransform(VTKViewer_Transform::New()), myCubeAxes(SVTK_CubeAxesActor2D::New()), myTrihedron(SVTK_Trihedron::New()), - myTrihedronSize(105) + myTrihedronSize(105), + myIsTrihedronRelative(true) { myDevice->Delete(); myTransform->Delete(); @@ -363,8 +364,13 @@ SVTK_Renderer // if the new trihedron size have sufficient difference, then apply the value double aSize = myTrihedron->GetSize(); - ComputeTrihedronSize(GetDevice(),aSize,aSize,myTrihedronSize); - myTrihedron->SetSize(aSize); + if ( IsTrihedronRelative() ) + { + ComputeTrihedronSize(GetDevice(),aSize,aSize,myTrihedronSize); + myTrihedron->SetSize(aSize); + } + else + myTrihedron->SetSize( myTrihedronSize ); // iterate through displayed objects and set size if necessary vtkActorCollection* anActors = GetDevice()->GetActors(); @@ -418,10 +424,11 @@ SVTK_Renderer void SVTK_Renderer -::SetTrihedronSize(int theSize) +::SetTrihedronSize(int theSize, const bool theRelative) { - if(myTrihedronSize != theSize){ + if(myTrihedronSize != theSize || myIsTrihedronRelative != theRelative){ myTrihedronSize = theSize; + myIsTrihedronRelative = theRelative; AdjustActors(); } } @@ -433,6 +440,12 @@ SVTK_Renderer return myTrihedronSize; } +bool +SVTK_Renderer +::IsTrihedronRelative() const +{ + return myIsTrihedronRelative; +} //---------------------------------------------------------------------------- VTKViewer_Trihedron* diff --git a/src/SVTK/SVTK_Renderer.h b/src/SVTK/SVTK_Renderer.h index 5f486543c..5532ea852 100644 --- a/src/SVTK/SVTK_Renderer.h +++ b/src/SVTK/SVTK_Renderer.h @@ -127,12 +127,16 @@ class SVTK_EXPORT SVTK_Renderer : public vtkObject //! Set size of the trihedron in percents from bounding box of the scene void - SetTrihedronSize(int theSize); + SetTrihedronSize(int theSize, const bool theRelative = true); //! Get size of the trihedron in percents from bounding box of the scene int GetTrihedronSize() const; + //! Shows if the size of the trihedron is relative + bool + IsTrihedronRelative() const; + //---------------------------------------------------------------------------- //! Get trihedron control VTKViewer_Trihedron* @@ -238,7 +242,8 @@ class SVTK_EXPORT SVTK_Renderer : public vtkObject //---------------------------------------------------------------------------- vtkSmartPointer myCubeAxes; vtkSmartPointer myTrihedron; - int myTrihedronSize; + int myTrihedronSize; + bool myIsTrihedronRelative; float myBndBox[6]; }; diff --git a/src/SVTK/SVTK_ViewModel.cxx b/src/SVTK/SVTK_ViewModel.cxx index 08c2169d5..03b8ca4a1 100644 --- a/src/SVTK/SVTK_ViewModel.cxx +++ b/src/SVTK/SVTK_ViewModel.cxx @@ -63,6 +63,7 @@ SVTK_Viewer::SVTK_Viewer() { myTrihedronSize = 105; + myTrihedronRelative = true; } //========================================================== @@ -88,7 +89,7 @@ SVTK_Viewer for(int i = 0, iEnd = aViews.size(); i < iEnd; i++){ if(SUIT_ViewWindow* aViewWindow = aViews.at(i)){ if(TViewWindow* aView = dynamic_cast(aViewWindow)){ - aView->getMainWindow()->SetBackgroundColor(theColor); + aView->setBackgroundColor(theColor); } } } @@ -97,15 +98,15 @@ SVTK_Viewer } //========================================================== -SUIT_ViewWindow* +SUIT_ViewWindow* SVTK_Viewer:: createView( SUIT_Desktop* theDesktop ) { - SVTK_ViewWindow* aViewWindow = new SVTK_ViewWindow(theDesktop); + TViewWindow* aViewWindow = new TViewWindow(theDesktop); aViewWindow->Initialize(this); - + aViewWindow->setBackgroundColor( backgroundColor() ); - aViewWindow->SetTrihedronSize( trihedronSize() ); + aViewWindow->SetTrihedronSize( trihedronSize(), trihedronRelative() ); return aViewWindow; } @@ -115,23 +116,23 @@ int SVTK_Viewer::trihedronSize() const return myTrihedronSize; } -void SVTK_Viewer::setTrihedronSize( const int sz ) +bool SVTK_Viewer::trihedronRelative() const { - myTrihedronSize = sz; - - SUIT_ViewManager* vm = getViewManager(); - if ( !vm ) - return; - - QPtrVector vec = vm->getViews(); - for ( int i = 0; i < vec.count(); i++ ) - { - SUIT_ViewWindow* win = vec.at( i ); - if ( !win || !win->inherits( "SVTK_ViewWindow" ) ) - continue; + return myTrihedronRelative; +} - SVTK_ViewWindow* vw = (SVTK_ViewWindow*)win; - vw->SetTrihedronSize( sz ); +void SVTK_Viewer::setTrihedronSize( const int theSize, const bool theRelative ) +{ + myTrihedronSize = theSize; + myTrihedronRelative = theRelative; + + if (SUIT_ViewManager* aViewManager = getViewManager()) { + QPtrVector aViews = aViewManager->getViews(); + for (int i = 0; i < aViews.count(); i++) { + if (TViewWindow* aView = dynamic_cast(aViews.at(i))) { + aView->SetTrihedronSize(theSize, theRelative); + } + } } } @@ -164,7 +165,7 @@ SVTK_Viewer thePopup->insertSeparator(); if(TViewWindow* aView = dynamic_cast(myViewManager->getActiveView())){ - if ( !aView->getView()->GetMainWindow()->getToolBar()->isVisible() ){ + if ( !aView->getMainWindow()->getToolBar()->isVisible() ){ thePopup->insertItem( VTKViewer_Viewer::tr( "MEN_SHOW_TOOLBAR" ), this, SLOT( onShowToolbar() ) ); } } @@ -233,7 +234,7 @@ SVTK_Viewer QPtrVector aViews = myViewManager->getViews(); for(int i = 0, iEnd = aViews.size(); i < iEnd; i++){ if(TViewWindow* aView = dynamic_cast(aViews.at(i))){ - aView->getView()->GetMainWindow()->getToolBar()->show(); + aView->getMainWindow()->getToolBar()->show(); } } } @@ -415,10 +416,11 @@ SVTK_Viewer { QPtrVector aViews = myViewManager->getViews(); for(int i = 0, iEnd = aViews.size(); i < iEnd; i++) - if(SVTK_ViewWindow* aViewWindow = dynamic_cast(aViews.at(i))) - if(SVTK_View* aView = aViewWindow->getView()) - if(!aView->isVisible( io )) - return false; + if(SUIT_ViewWindow* aViewWindow = aViews.at(i)) + if(TViewWindow* aViewWnd = dynamic_cast(aViewWindow)) + if(SVTK_View* aView = aViewWnd->getView()) + if(!aView->isVisible( io )) + return false; return true; } @@ -431,7 +433,7 @@ SVTK_Viewer // if (theUpdateTrihedron) onAdjustTrihedron(); QPtrVector aViews = myViewManager->getViews(); for(int i = 0, iEnd = aViews.size(); i < iEnd; i++) - if(SVTK_ViewWindow* aViewWindow = dynamic_cast(aViews.at(i))) + if(TViewWindow* aViewWindow = dynamic_cast(aViews.at(i))) if(SVTK_View* aView = aViewWindow->getView()) aView->Repaint(); } diff --git a/src/SVTK/SVTK_ViewModel.h b/src/SVTK/SVTK_ViewModel.h index 5875d465e..21ca80007 100644 --- a/src/SVTK/SVTK_ViewModel.h +++ b/src/SVTK/SVTK_ViewModel.h @@ -65,8 +65,11 @@ public: //! Get size of trihedron of the viewer (see #SVTK_Renderer::SetTrihedronSize) int trihedronSize() const; + //! Shows if the size of trihedron relative (see #SVTK_Renderer::SetTrihedronSize) + bool trihedronRelative() const; + //! Set size of trihedron of the viewer (see #SVTK_Renderer::SetTrihedronSize) - void setTrihedronSize( const int ); + void setTrihedronSize( const int, const bool = true ); public: void enableSelection(bool isEnabled); @@ -115,6 +118,7 @@ protected slots: private: QColor myBgColor; int myTrihedronSize; + bool myTrihedronRelative; bool mySelectionEnabled; bool myMultiSelectionEnabled; }; diff --git a/src/SVTK/SVTK_ViewWindow.cxx b/src/SVTK/SVTK_ViewWindow.cxx index b95a23d20..69e5eae4a 100755 --- a/src/SVTK/SVTK_ViewWindow.cxx +++ b/src/SVTK/SVTK_ViewWindow.cxx @@ -432,9 +432,9 @@ SVTK_ViewWindow void SVTK_ViewWindow -::SetTrihedronSize(const int theSize) +::SetTrihedronSize(const int theSize, const bool theRelative) { - myMainWindow->SetTrihedronSize(theSize); + myMainWindow->SetTrihedronSize(theSize, theRelative); } /*! If parameter theIsForcedUpdate is true, recalculate parameters for @@ -597,3 +597,99 @@ SVTK_ViewWindow myMainWindow->InvokeEvent( anEvent, 0 ); } } + +/*! The method returns the visual parameters of this view as a formated string + */ +QString +SVTK_ViewWindow +::getVisualParameters() +{ + double pos[3], focalPnt[3], viewUp[3], parScale, scale[3]; + + vtkCamera* camera = getRenderer()->GetActiveCamera(); + camera->GetPosition( pos ); + camera->GetFocalPoint( focalPnt ); + camera->GetViewUp( viewUp ); + parScale = camera->GetParallelScale(); + GetScale( scale ); + + QString retStr; + retStr.sprintf( "%.12e*%.12e*%.12e*%.12e*%.12e*%.12e*%.12e*%.12e*%.12e*%.12e*%.12e*%.12e*%.12e", + pos[0], pos[1], pos[2], focalPnt[0], focalPnt[1], focalPnt[2], viewUp[0], viewUp[1], + viewUp[2], parScale, scale[0], scale[1], scale[2] ); + return retStr; +} + +/* The method restores visual parameters of this view or postpones it untill the view is shown + */ +void +SVTK_ViewWindow +::setVisualParameters( const QString& parameters ) +{ + SVTK_RenderWindowInteractor* anInteractor = getMainWindow()->GetInteractor(); + if ( anInteractor->isVisible() ) { + doSetVisualParameters( parameters ); + } + else { + myVisualParams = parameters; + anInteractor->installEventFilter(this); + } +} + +/* The method restores visual parameters of this view from a formated string + */ +void +SVTK_ViewWindow +::doSetVisualParameters( const QString& parameters ) +{ + QStringList paramsLst = QStringList::split( '*', parameters, true ); + if ( paramsLst.size() == 13 ) { + // 'reading' list of parameters + double pos[3], focalPnt[3], viewUp[3], parScale, scale[3]; + pos[0] = paramsLst[0].toDouble(); + pos[1] = paramsLst[1].toDouble(); + pos[2] = paramsLst[2].toDouble(); + focalPnt[0] = paramsLst[3].toDouble(); + focalPnt[1] = paramsLst[4].toDouble(); + focalPnt[2] = paramsLst[5].toDouble(); + viewUp[0] = paramsLst[6].toDouble(); + viewUp[1] = paramsLst[7].toDouble(); + viewUp[2] = paramsLst[8].toDouble(); + parScale = paramsLst[9].toDouble(); + scale[0] = paramsLst[10].toDouble(); + scale[1] = paramsLst[11].toDouble(); + scale[2] = paramsLst[12].toDouble(); + + // applying parameters + vtkCamera* camera = getRenderer()->GetActiveCamera(); + camera->SetPosition( pos ); + camera->SetFocalPoint( focalPnt ); + camera->SetViewUp( viewUp ); + camera->SetParallelScale( parScale ); + SetScale( scale ); + + // resize( size() ); + + // getRenderer()->ResetCameraClippingRange(); + // Repaint(); + // getMainWindow()->GetRenderer()->GetTransform()->SetMatrixScale( scale[0], scale[1], scale[2] ); + } +} + + +//================================================================ +// Function : eventFilter +/*! Purpose : delayed setVisualParameters +*/ +//================================================================ +bool SVTK_ViewWindow::eventFilter( QObject* theWatched, QEvent* theEvent ) +{ + if ( theEvent->type() == QEvent::Show && theWatched->inherits( "SVTK_RenderWindowInteractor" ) ) { + SVTK_RenderWindowInteractor* anInteractor = (SVTK_RenderWindowInteractor*)theWatched; + if ( anInteractor->isVisible() ) { + doSetVisualParameters( myVisualParams ); + anInteractor->removeEventFilter( this ); // theWatched = RenderWindowInteractor + } + } + return SUIT_ViewWindow::eventFilter( theWatched, theEvent ); +} diff --git a/src/SVTK/SVTK_ViewWindow.h b/src/SVTK/SVTK_ViewWindow.h index 1fc559c78..51e50ac45 100755 --- a/src/SVTK/SVTK_ViewWindow.h +++ b/src/SVTK/SVTK_ViewWindow.h @@ -219,7 +219,7 @@ class SVTK_EXPORT SVTK_ViewWindow : public SUIT_ViewWindow //! Redirect the request to #SVTK_Renderer::SetTrihedronSize virtual void - SetTrihedronSize( const int ); + SetTrihedronSize( const int, const bool = true ); //! Redirect the request to #SVTK_Renderer::SetSelectionProp virtual @@ -242,6 +242,19 @@ class SVTK_EXPORT SVTK_ViewWindow : public SUIT_ViewWindow void SetSelectionTolerance(const double& theTolNodes = 0.025, const double& theTolCell = 0.001); + + //! Methods to save/restore visual parameters of a view (pan, zoom, etc.) + virtual + QString + getVisualParameters(); + + virtual + void + setVisualParameters( const QString& parameters ); + + virtual + bool + eventFilter( QObject*, QEvent* ); public slots: virtual @@ -326,12 +339,17 @@ protected: Initialize(SVTK_View* theView, SVTK_ViewModelBase* theModel); + void + doSetVisualParameters( const QString& ); + QImage dumpView(); virtual void action( const int ); SVTK_View* myView; SVTK_MainWindow* myMainWindow; SVTK_ViewModelBase* myModel; + + QString myVisualParams; // used for delayed setting of view parameters }; #ifdef WIN32 diff --git a/src/SalomeApp/Makefile.in b/src/SalomeApp/Makefile.in index 308e5126b..8913a2b44 100755 --- a/src/SalomeApp/Makefile.in +++ b/src/SalomeApp/Makefile.in @@ -25,7 +25,8 @@ EXPORT_HEADERS= SalomeApp.h \ SalomeApp_Filter.h \ SalomeApp_TypeFilter.h \ SalomeApp_StudyPropertiesDlg.h \ - SalomeApp_CheckFileDlg.h + SalomeApp_CheckFileDlg.h \ + SalomeApp_VisualState.h # .po files to transform in .qm PO_FILES = SalomeApp_images.po \ @@ -48,7 +49,8 @@ LIB_SRC= SalomeApp_Module.cxx \ SalomeApp_TypeFilter.cxx \ SalomeApp_StudyPropertiesDlg.cxx \ SalomeApp_ListView.cxx \ - SalomeApp_CheckFileDlg.cxx + SalomeApp_CheckFileDlg.cxx \ + SalomeApp_VisualState.cxx LIB_MOC = SalomeApp_Application.h \ SalomeApp_DataModel.h \ @@ -68,7 +70,7 @@ RESOURCES_FILES = SalomeApp.ini \ CPPFLAGS+=$(PYTHON_INCLUDES) $(QT_INCLUDES) $(QWT_INCLUDES) $(OCC_INCLUDES) $(VTK_INCLUDES) $(BOOST_CPPFLAGS) -I${KERNEL_ROOT_DIR}/include/salome LDFLAGS+=$(PYTHON_LIBS) $(QT_MT_LIBS) -LIBS+= -lsuit -lstd -lCAM -lObjBrowser -lSalomePrs -L$(KERNEL_ROOT_DIR)/lib/salome -lOpUtil -lSALOMELocalTrace $(CAS_KERNEL) -lSPlot2d -lGLViewer -lOCCViewer -lVTKViewer -lSalomeObject -lSVTK -lSOCC -lPyInterp -lPythonConsole -lLogWindow -lLightApp -lSalomeContainer -lToolsGUI +LIBS+= -lsuit -lstd -lCAM -lObjBrowser -lSalomePrs -L$(KERNEL_ROOT_DIR)/lib/salome -lOpUtil -lSALOMELocalTrace -lSalomeDSClient $(CAS_KERNEL) -lSPlot2d -lGLViewer -lOCCViewer -lVTKViewer -lSalomeObject -lSVTK -lSOCC -lPyInterp -lPythonConsole -lLogWindow -lLightApp -lSalomeContainer -lToolsGUI @CONCLUDE@ diff --git a/src/SalomeApp/SalomeApp_Application.cxx b/src/SalomeApp/SalomeApp_Application.cxx index 5139ce4f2..9d17c32e6 100644 --- a/src/SalomeApp/SalomeApp_Application.cxx +++ b/src/SalomeApp/SalomeApp_Application.cxx @@ -11,15 +11,15 @@ #include "SalomeApp_DataModel.h" #include "SalomeApp_DataObject.h" #include "SalomeApp_EventFilter.h" +#include "SalomeApp_VisualState.h" #include "SalomeApp_StudyPropertiesDlg.h" -#include "SalomeApp_CheckFileDlg.h" - #include "LightApp_Application.h" #include "LightApp_Preferences.h" #include "LightApp_WidgetContainer.h" #include "LightApp_SelectionMgr.h" +#include "LightApp_NameDlg.h" #include "STD_LoadStudiesDlg.h" @@ -48,9 +48,13 @@ #include #include #include +#include +#include +#include #include "SALOMEDS_StudyManager.hxx" #include "SALOMEDS_SObject.hxx" +#include "SALOMEDS_IParameters.hxx" #include "SALOME_ListIteratorOfListIO.hxx" #include "SALOME_ListIO.hxx" @@ -58,6 +62,8 @@ #include "ToolsGUI_CatalogGeneratorDlg.h" #include "ToolsGUI_RegWidget.h" +#include + /*!Create new instance of SalomeApp_Application.*/ extern "C" SALOMEAPP_EXPORT SUIT_Application* createApplication() { @@ -99,6 +105,11 @@ void SalomeApp_Application::createActions() SUIT_Desktop* desk = desktop(); + //! Save GUI state + createAction( SaveGUIStateId, tr( "TOT_DESK_FILE_SAVE_GUI_STATE" ), QIconSet(), + tr( "MEN_DESK_FILE_SAVE_GUI_STATE" ), tr( "PRP_DESK_FILE_SAVE_GUI_STATE" ), + 0, desk, false, this, SLOT( onSaveGUIState() ) ); + //! Dump study createAction( DumpStudyId, tr( "TOT_DESK_FILE_DUMP_STUDY" ), QIconSet(), tr( "MEN_DESK_FILE_DUMP_STUDY" ), tr( "PRP_DESK_FILE_DUMP_STUDY" ), @@ -126,6 +137,7 @@ void SalomeApp_Application::createActions() int fileMenu = createMenu( tr( "MEN_DESK_FILE" ), -1 ); + createMenu( SaveGUIStateId, fileMenu, 10, -1 ); createMenu( DumpStudyId, fileMenu, 10, -1 ); createMenu( separator(), fileMenu, -1, 15, -1 ); createMenu( LoadScriptId, fileMenu, 10, -1 ); @@ -133,7 +145,7 @@ void SalomeApp_Application::createActions() createMenu( PropertiesId, fileMenu, 10, -1 ); createMenu( separator(), fileMenu, -1, 15, -1 ); - int toolsMenu = createMenu( tr( "MEN_DESK_TOOLS" ), -1, -1, 50 ); + int toolsMenu = createMenu( tr( "MEN_DESK_TOOLS" ), -1, MenuToolsId, 50 ); createMenu( CatalogGenId, toolsMenu, 10, -1 ); createMenu( RegDisplayId, toolsMenu, 10, -1 ); createMenu( separator(), toolsMenu, -1, 15, -1 ); @@ -459,14 +471,41 @@ void SalomeApp_Application::updateCommandsStatus() if ( a ) a->setEnabled( activeStudy() ); + // Properties menu a = action( PropertiesId ); if( a ) a->setEnabled( activeStudy() ); + // Save GUI state menu + a = action( SaveGUIStateId ); + if( a ) + a->setEnabled( activeStudy() ); + // update state of Copy/Paste menu items onSelectionChanged(); } +/* + Class : DumpStudyFileDlg + Description : Private class used in Dump Study operation. Consists 2 check boxes: + "Publish in study" and "Save GUI parameters" +*/ +class DumpStudyFileDlg : public SUIT_FileDlg +{ +public: + DumpStudyFileDlg( QWidget* parent ) : SUIT_FileDlg( parent, false, true, true ) + { + QHBox* hB = new QHBox( this ); + myPublishChk = new QCheckBox( tr("PUBLISH_IN_STUDY"), hB ); + mySaveGUIChk = new QCheckBox( tr("SAVE_GUI_STATE"), hB ); + QPushButton* pb = new QPushButton(this); + addWidgets( new QLabel("", this), hB, pb ); + pb->hide(); + } + QCheckBox* myPublishChk; + QCheckBox* mySaveGUIChk; +}; + /*!Private SLOT. On dump study.*/ void SalomeApp_Application::onDumpStudy( ) { @@ -477,23 +516,34 @@ void SalomeApp_Application::onDumpStudy( ) QStringList aFilters; aFilters.append( tr( "PYTHON_FILES_FILTER" ) ); - SalomeApp_CheckFileDlg* fd = new SalomeApp_CheckFileDlg( desktop(), false, tr("PUBLISH_IN_STUDY"), true, true); + DumpStudyFileDlg* fd = new DumpStudyFileDlg( desktop() ); fd->setCaption( tr( "TOT_DESK_FILE_DUMP_STUDY" ) ); fd->setFilters( aFilters ); - fd->SetChecked(true); + fd->myPublishChk->setChecked( true ); + fd->mySaveGUIChk->setChecked( true ); fd->exec(); QString aFileName = fd->selectedFile(); - bool toPublish = fd->IsChecked(); + bool toPublish = fd->myPublishChk->isChecked(); + bool toSaveGUI = fd->mySaveGUIChk->isChecked(); delete fd; - if(!aFileName.isEmpty()) { + if ( !aFileName.isEmpty() ) { QFileInfo aFileInfo(aFileName); - bool res = aStudy->DumpStudy( aFileInfo.dirPath( true ).latin1(), aFileInfo.baseName().latin1(), toPublish ); + int savePoint; + if ( toSaveGUI ) { //SRN: Store a visual state of the study at the save point for DumpStudy method + SALOMEDS_IParameters::setDumpPython(appStudy->studyDS()); + savePoint = SalomeApp_VisualState( this ).storeState(); //SRN: create a temporary save point + //prefix = SALOMEDS_IParameters::getStudyScript(appStudy->studyDS(), appStudy->getVisualComponentName(), savePoint); + + } + bool res = aStudy->DumpStudy( aFileInfo.dirPath( true ).latin1(), aFileInfo.baseName().latin1(), toPublish); + if ( toSaveGUI ) + appStudy->removeSavePoint(savePoint); //SRN: remove the created temporary save point. if ( !res ) - SUIT_MessageBox::warn1 ( desktop(), - QObject::tr("WRN_WARNING"), - tr("WRN_DUMP_STUDY_FAILED"), - QObject::tr("BUT_OK") ); + SUIT_MessageBox::warn1 ( desktop(), + QObject::tr("WRN_WARNING"), + tr("WRN_DUMP_STUDY_FAILED"), + QObject::tr("BUT_OK") ); } } @@ -529,6 +579,17 @@ void SalomeApp_Application::onLoadScript( ) } } +/*!Private SLOT. On save GUI state.*/ +void SalomeApp_Application::onSaveGUIState() +{ + SalomeApp_Study* study = dynamic_cast( activeStudy() ); + if ( study ) { + SalomeApp_VisualState( this ).storeState(); + updateSavePointDataObjects( study ); + objectBrowser()->updateTree( study->root() ); + } +} + /*!Gets file filter. *\retval QString "(*.hdf)" */ @@ -589,6 +650,11 @@ void SalomeApp_Application::createPreferences( LightApp_Preferences* pref ) LightApp_Preferences::Bool, "ObjectBrowser", QString().sprintf( "visibility_column_%d", i ) ); } pref->setItemProperty( defCols, "columns", 1 ); + + // adding preference to LightApp_Application handled preferences.. a bit of hacking with resources.. + int genTab = pref->addPreference( LightApp_Application::tr( "PREF_TAB_GENERAL" ), salomeCat ); + int studyGroup = pref->addPreference( LightApp_Application::tr( "PREF_GROUP_STUDY" ), genTab ); + pref->addPreference( tr( "PREF_STORE_VISUAL_STATE" ), studyGroup, LightApp_Preferences::Bool, "Study", "store_visual_state" ); } /*!Update desktop title.*/ @@ -630,8 +696,9 @@ CORBA::ORB_var SalomeApp_Application::orb() /*!Create and return SALOMEDS_StudyManager.*/ SALOMEDSClient_StudyManager* SalomeApp_Application::studyMgr() { - static SALOMEDSClient_StudyManager* _sm = new SALOMEDS_StudyManager(); - return _sm; + static _PTR(StudyManager) _sm; + if(!_sm) _sm = ClientFactory::StudyManager(); + return _sm.get(); } /*!Create and return SALOME_NamingService.*/ @@ -695,6 +762,15 @@ void SalomeApp_Application::contextMenuPopup( const QString& type, QPopupMenu* t LightApp_SelectionMgr* mgr = selectionMgr(); mgr->selectedObjects( aList, QString::null, false ); + // add GUI state commands: restore, rename + if ( aList.Extent() == 1 && aList.First()->hasEntry() && + QString( aList.First()->getEntry() ).startsWith( tr( "SAVE_POINT_DEF_NAME" ) ) ) { + thePopup->insertSeparator(); + thePopup->insertItem( tr( "MEN_RESTORE_VS" ), this, SLOT( onRestoreGUIState() ) ); + thePopup->insertItem( tr( "MEN_RENAME_VS" ), this, SLOT( onRenameGUIState() ) ); + thePopup->insertItem( tr( "MEN_DELETE_VS" ), this, SLOT( onDeleteGUIState() ) ); + } + // "Delete reference" item should appear only for invalid references // isInvalidRefs will be true, if at least one of selected objects is invalid reference @@ -729,6 +805,10 @@ void SalomeApp_Application::contextMenuPopup( const QString& type, QPopupMenu* t if (aList.Extent() != 1) return; Handle(SALOME_InteractiveObject) aIObj = aList.First(); + // check if item is a "GUI state" item (also a first level object) + QString entry( aIObj->getEntry() ); + if ( entry.startsWith( tr( "SAVE_POINT_DEF_NAME" ) ) ) + return; QString aModuleName(aIObj->getComponentDataType()); QString aModuleTitle = moduleTitle(aModuleName); CAM_Module* currentModule = activeModule(); @@ -740,7 +820,7 @@ void SalomeApp_Application::contextMenuPopup( const QString& type, QPopupMenu* t /*!Update obect browser: 1.if 'updateModels' true, update existing data models; 2. update "non-existing" (not loaded yet) data models; - 3. update object browser if it existing */ + 3. update object browser if it exists */ void SalomeApp_Application::updateObjectBrowser( const bool updateModels ) { // update "non-existing" (not loaded yet) data models @@ -765,16 +845,16 @@ void SalomeApp_Application::updateObjectBrowser( const bool updateModels ) //SalomeApp_DataModel::BuildTree( aComponent, study->root(), study, /*skipExisitng=*/true ); } } + // create data objects that correspond to GUI state save points + updateSavePointDataObjects( study ); } // update existing data models (already loaded SComponents) LightApp_Application::updateObjectBrowser( updateModels ); -/* if ( objectBrowser() ) - { - objectBrowser()->updateGeometry(); - objectBrowser()->updateTree(); - }*/ + // -- debug -- + // if ( study && study->root() ) + // study->root()->dump(); } /*!Display Catalog Genenerator dialog */ @@ -836,3 +916,173 @@ void SalomeApp_Application::onDblClick( QListViewItem* it ) } } } + +SUIT_ViewManager* SalomeApp_Application::newViewManager(const QString& type) +{ + return createViewManager(type); +} + + +/*!Global utility funciton, returns selected GUI Save point object's ID */ +int getSelectedSavePoint( const LightApp_SelectionMgr* selMgr ) +{ + SALOME_ListIO aList; + selMgr->selectedObjects( aList ); + Handle(SALOME_InteractiveObject) aIObj = aList.First(); + QString entry( aIObj->getEntry() ); + QString startStr = QObject::tr( "SAVE_POINT_DEF_NAME" ); + if ( !entry.startsWith( startStr ) ) // it's a "GUI state" object + return -1; + bool ok; // conversion to integer is ok? + int savePoint = entry.right( entry.length() - startStr.length() ).toInt( &ok ); + return ok ? savePoint : -1; +} + +/*!Called on Restore GUI State popup command*/ +void SalomeApp_Application::onRestoreGUIState() +{ + int savePoint = ::getSelectedSavePoint( selectionMgr() ); + if ( savePoint == -1 ) + return; + SalomeApp_VisualState( this ).restoreState( savePoint ); +} + +/*!Called on Rename GUI State popup command*/ +void SalomeApp_Application::onRenameGUIState() +{ + int savePoint = ::getSelectedSavePoint( selectionMgr() ); + if ( savePoint == -1 ) + return; + SalomeApp_Study* study = dynamic_cast( activeStudy() ); + if ( !study ) + return; + + QString newName = LightApp_NameDlg::getName( desktop(), study->getNameOfSavePoint( savePoint ) ); + if ( !newName.isNull() && !newName.isEmpty() ) { + study->setNameOfSavePoint( savePoint, newName ); + updateSavePointDataObjects( study ); + } +} + + +/*!Called on Delete GUI State popup command*/ +void SalomeApp_Application::onDeleteGUIState() +{ + int savePoint = ::getSelectedSavePoint( selectionMgr() ); + if ( savePoint == -1 ) + return; + SalomeApp_Study* study = dynamic_cast( activeStudy() ); + if ( !study ) + return; + + study->removeSavePoint( savePoint ); + updateSavePointDataObjects( study ); +} + +/*!Called on Save study operation*/ +void SalomeApp_Application::onStudySaved( SUIT_Study* study ) +{ + LightApp_Application::onStudySaved( study ); + + if ( objectBrowser() ) { + updateSavePointDataObjects( dynamic_cast( study ) ); + objectBrowser()->updateTree( study->root() ); + } +} + +/*!Called on Open study operation*/ +void SalomeApp_Application::onStudyOpened( SUIT_Study* study ) +{ + LightApp_Application::onStudyOpened( study ); + + if ( objectBrowser() ) { + updateSavePointDataObjects( dynamic_cast( study ) ); + objectBrowser()->updateTree( study->root() ); + } +} + +/*! utility function. returns true if list view item that correspond to given SUIT_DataObject is open. + only first level items are traversed */ +bool isListViewItemOpen( QListView* lv, const SUIT_DataObject* dobj ) +{ + if ( !lv || !dobj ) + return false; + + QListViewItem* item = lv->firstChild(); + while ( item ) { + OB_ListItem* ob_item = dynamic_cast( item ); + if ( ob_item && ob_item->dataObject() == dobj ) + return ob_item->isOpen(); + item = item->nextSibling(); + } + return false; +} + +/*! updateSavePointDataObjects: syncronize data objects that correspond to save points (gui states)*/ +void SalomeApp_Application::updateSavePointDataObjects( SalomeApp_Study* study ) +{ + OB_Browser* ob = objectBrowser(); + + if ( !study || !ob ) + return; + + // find GUI states root object + SUIT_DataObject* guiRootObj = 0; + DataObjectList ch; + study->root()->children( ch ); + DataObjectList::const_iterator it = ch.begin(), last = ch.end(); + for ( ; it != last ; ++it ) { + if ( dynamic_cast( *it ) ) { + guiRootObj = *it; + break; + } + } + std::vector savePoints = study->getSavePoints(); + // case 1: no more save points but they existed in study's tree + if ( savePoints.empty() && guiRootObj ) { + delete guiRootObj; + return; + } + // case 2: no more save points but root does not exist either + if ( savePoints.empty() && !guiRootObj ) + return; + // case 3: save points but no root for them - create it + if ( !savePoints.empty() && !guiRootObj ) + guiRootObj = new SalomeApp_SavePointRootObject( study->root() ); + // case 4: everything already exists.. here may be a problem: we want "GUI states" root object + // to be always the last one in the tree. Here we check - if it is not the last one - remove and + // re-create it. + bool isOpen( false ); + if ( guiRootObj->nextBrother() ) { + isOpen = isListViewItemOpen( ob->listView(), guiRootObj ); + delete guiRootObj; + guiRootObj = new SalomeApp_SavePointRootObject( study->root() ); + } + + // store data objects in a map id-to-DataObject + QMap mapDO; + ch.clear(); + guiRootObj->children( ch ); + for( it = ch.begin(), last = ch.end(); it != last ; ++it ) { + SalomeApp_SavePointObject* dobj = dynamic_cast( *it ); + if ( dobj ) + mapDO[dobj->getId()] = dobj; + } + + // iterate new save points. if DataObject with such ID not found in map - create DataObject + // if in the map - remove it from map. + for ( int i = 0; i < savePoints.size(); i++ ) + if ( !mapDO.contains( savePoints[i] ) ) + new SalomeApp_SavePointObject( guiRootObj, savePoints[i], study ); + else { + ob->updateTree( mapDO[ savePoints[i] ] ); + mapDO.remove( savePoints[i] ); + } + // delete DataObjects that are still in the map -- their IDs were not found in data model + for ( QMap::Iterator it = mapDO.begin(); it != mapDO.end(); ++it ) + delete it.data(); + + if ( isOpen ) // set open if we recreated guiRootObj and it was previously open.. + guiRootObj->setOpen( true ); +} + diff --git a/src/SalomeApp/SalomeApp_Application.h b/src/SalomeApp/SalomeApp_Application.h index 2462e557b..e8ba1d4b4 100644 --- a/src/SalomeApp/SalomeApp_Application.h +++ b/src/SalomeApp/SalomeApp_Application.h @@ -27,6 +27,7 @@ class QDockWindow; class LightApp_Preferences; class SalomeApp_Module; +class SalomeApp_Study; class SALOME_LifeCycleCORBA; @@ -45,8 +46,9 @@ class SALOMEAPP_EXPORT SalomeApp_Application : public LightApp_Application Q_OBJECT public: + enum { MenuToolsId = 5 }; enum { DumpStudyId = LightApp_Application::UserID, LoadScriptId, PropertiesId, - CatalogGenId, RegDisplayId, UserID }; + CatalogGenId, RegDisplayId, SaveGUIStateId, UserID }; public: SalomeApp_Application(); @@ -66,6 +68,9 @@ public: static SALOME_LifeCycleCORBA* lcc(); static QString defaultEngineIOR(); + SUIT_ViewManager* newViewManager(const QString&); + void updateSavePointDataObjects( SalomeApp_Study* ); + public slots: virtual bool onOpenDoc( const QString& ); virtual void onLoadDoc(); @@ -73,6 +78,10 @@ public slots: virtual void onCopy(); virtual void onPaste(); +protected slots: + void onStudySaved( SUIT_Study* ); + void onStudyOpened( SUIT_Study* ); + protected: virtual void createActions(); virtual SUIT_Study* createNewStudy(); @@ -90,10 +99,14 @@ private slots: void onProperties(); void onDumpStudy(); void onLoadScript(); + void onSaveGUIState(); + void onDeleteGUIState(); void onCatalogGen(); void onRegDisplay(); void onOpenWith(); + void onRestoreGUIState(); + void onRenameGUIState(); }; #ifdef WIN32 diff --git a/src/SalomeApp/SalomeApp_DataModel.cxx b/src/SalomeApp/SalomeApp_DataModel.cxx index 5fcae7b7b..2a043ff19 100644 --- a/src/SalomeApp/SalomeApp_DataModel.cxx +++ b/src/SalomeApp/SalomeApp_DataModel.cxx @@ -72,7 +72,7 @@ bool SalomeApp_DataModelSync::isCorrect( const kerPtr& so ) const suitPtr SalomeApp_DataModelSync::createItem( const kerPtr& so, const suitPtr& parent, const suitPtr& after, - const bool asFirst ) const + const bool prepend ) const { if( !isCorrect( so ) ) return 0; @@ -91,9 +91,9 @@ suitPtr SalomeApp_DataModelSync::createItem( const kerPtr& so, else parent->appendChild( nitem ); } - else if( asFirst ) + else if( prepend ) parent->insertChild( nitem, 0 ); - else + else // append parent->appendChild( nitem ); else if( myRoot ) myRoot->appendChild( nitem ); @@ -285,31 +285,7 @@ SUIT_DataObject* SalomeApp_DataModel::synchronize( const _PTR( SComponent )& sob SalomeApp_DataModelSync sync( study->studyDS(), study->root() ); - // QString srcName = sobj ? sobj->GetName().c_str() : ""; - // QString trgName = ( suitObj && !suitObj->name().isNull() ) ? suitObj->name() : ""; - // printf( "--- SalomeApp_DataModel::syncronize() calls synchronize()_1: src = %s, trg = %s ---\n", srcName.latin1(), trgName.latin1() ); - - SUIT_DataObject* o = ::synchronize( sobj, suitObj, sync ); -// showTree( o ); - return o; -} - -//================================================================ -// Function : synchronize -/*! Purpose : synchronizes kernel tree and suit data tree starting from 'sobj' and 'obj' correspondly */ -//================================================================ -SUIT_DataObject* SalomeApp_DataModel::synchronize( const _PTR( SObject )& sobj, SUIT_DataObject* obj, - SalomeApp_Study* study ) -{ - if( !study ) - return 0; - SalomeApp_DataModelSync sync( study->studyDS(), study->root() ); - - // QString srcName = sobj ? sobj->GetName().c_str() : ""; - // QString trgName = ( obj && !obj->name().isNull() ) ? obj->name() : ""; - // printf( "--- SalomeApp_DataModel::syncronize() calls synchronize()_2: src = s, trg = %s ---\n", srcName.latin1(), trgName.latin1() ); - - return ::synchronize( sobj, obj, sync ); + return ::synchronize( sobj, suitObj, sync ); } //================================================================ diff --git a/src/SalomeApp/SalomeApp_DataModel.h b/src/SalomeApp/SalomeApp_DataModel.h index 62e649bc3..7452cd366 100644 --- a/src/SalomeApp/SalomeApp_DataModel.h +++ b/src/SalomeApp/SalomeApp_DataModel.h @@ -27,10 +27,9 @@ class SALOMEAPP_EXPORT SalomeApp_DataModel : public LightApp_DataModel public: static SUIT_DataObject* synchronize( const _PTR( SComponent )&, SalomeApp_Study* ); - static SUIT_DataObject* synchronize( const _PTR( SObject )&, SUIT_DataObject*, SalomeApp_Study* ); - SalomeApp_DataModel ( CAM_Module* theModule ); - virtual ~SalomeApp_DataModel(); + SalomeApp_DataModel ( CAM_Module* theModule ); + virtual ~SalomeApp_DataModel(); virtual bool open( const QString&, CAM_Study*, QStringList ); virtual bool create( CAM_Study* ); diff --git a/src/SalomeApp/SalomeApp_DataObject.cxx b/src/SalomeApp/SalomeApp_DataObject.cxx index ef7b8df7b..5bb857865 100644 --- a/src/SalomeApp/SalomeApp_DataObject.cxx +++ b/src/SalomeApp/SalomeApp_DataObject.cxx @@ -21,6 +21,8 @@ #include "SalomeApp_Study.h" #include "LightApp_RootObject.h" +#include + #include #include #include @@ -371,3 +373,50 @@ QString SalomeApp_ModuleObject::name() const return SalomeApp_DataObject::name(); } +/* + Class: SalomeApp_SavePointObject + Level: Public +*/ + +/*!Constructor.Initialize by \a parent.*/ +SalomeApp_SavePointObject::SalomeApp_SavePointObject( SUIT_DataObject* _parent, const int id, SalomeApp_Study* study ) + : LightApp_DataObject( _parent ), CAM_DataObject( _parent ), // IMPORTANT TO CALL ALL VIRTUAL CONSTRUCTORS! + myId( id ), + myStudy( study ) +{ +} + +/*!Destructor. Do nothing.*/ +SalomeApp_SavePointObject::~SalomeApp_SavePointObject() +{ +} + +/*!Returns save points ID */ +int SalomeApp_SavePointObject::getId() const +{ + return myId; +} + +/*!Returns "invalid" entry, which does not correspond to any object in data structure + but indicates that it is a save point object */ +QString SalomeApp_SavePointObject::entry() const +{ + return QObject::tr( "SAVE_POINT_DEF_NAME" ) + QString::number( myId ); +} + +/*!Returns displayed name of object */ +QString SalomeApp_SavePointObject::name() const +{ + return myStudy->getNameOfSavePoint( myId ); +} + +QPixmap SalomeApp_SavePointObject::icon() const +{ + return QPixmap(); +} + +QString SalomeApp_SavePointObject::toolTip() const +{ + return QObject::tr( "SAVE_POINT_OBJECT_TOOLTIP" ).arg( name() ); +} + diff --git a/src/SalomeApp/SalomeApp_DataObject.h b/src/SalomeApp/SalomeApp_DataObject.h index 15a1d96bf..33cf78d67 100644 --- a/src/SalomeApp/SalomeApp_DataObject.h +++ b/src/SalomeApp/SalomeApp_DataObject.h @@ -82,7 +82,45 @@ public: SalomeApp_ModuleObject( CAM_DataModel*, const _PTR(SObject)&, SUIT_DataObject* = 0 ); virtual ~SalomeApp_ModuleObject(); - virtual QString name() const; + virtual QString name() const; +}; + +/*! + * SalomeApp_SavePointObject - class that represents persistent visual_state object + * these objects are stored in data model, but NOT in SObjects structure, so we + * must handle them separately using this special class for them + */ + +class SALOMEAPP_EXPORT SalomeApp_SavePointObject : public virtual LightApp_DataObject +{ +public: + SalomeApp_SavePointObject( SUIT_DataObject* parent, const int, SalomeApp_Study* study ); + virtual ~SalomeApp_SavePointObject(); + + virtual QString entry() const; + + virtual QString name() const; + virtual QPixmap icon() const; + virtual QString toolTip() const; + + int getId() const; + +private: + int myId; + SalomeApp_Study* myStudy; +}; + +/*! + * SalomeApp_SavePointRootObject - class that represents parent object for visual_state objects + */ + +class SALOMEAPP_EXPORT SalomeApp_SavePointRootObject : public SUIT_DataObject +{ +public: + SalomeApp_SavePointRootObject( SUIT_DataObject* parent ) : SUIT_DataObject( parent ) {} + + virtual QString name() const { return QObject::tr( "SAVE_POINT_ROOT_NAME" ); } + virtual QString toolTip() const{ return QObject::tr( "SAVE_POINT_ROOT_TOOLTIP" ); } }; #endif diff --git a/src/SalomeApp/SalomeApp_ExceptionHandler.cxx b/src/SalomeApp/SalomeApp_ExceptionHandler.cxx index 3791d4d98..16b5004ce 100644 --- a/src/SalomeApp/SalomeApp_ExceptionHandler.cxx +++ b/src/SalomeApp/SalomeApp_ExceptionHandler.cxx @@ -17,22 +17,15 @@ // See http://www.salome-platform.org/ // #include "SalomeApp_ExceptionHandler.h" +#include "CASCatch.hxx" #include -#include -#include - #include #include #include -#include -#include -#include - - /*!Constructor. Initialize by \a floatSignal.*/ SalomeApp_ExceptionHandler::SalomeApp_ExceptionHandler( const bool floatSignal ) : SUIT_ExceptionHandler() @@ -43,32 +36,17 @@ SalomeApp_ExceptionHandler::SalomeApp_ExceptionHandler( const bool floatSignal ) /*!Try to call SUIT_ExceptionHandler::internalHandle(o, e), catch if failure.*/ bool SalomeApp_ExceptionHandler::handleSignals( QObject* o, QEvent* e ) { - - CASCatch_CatchSignals aCatchSignals; - aCatchSignals.Activate(); - - CASCatch_TRY { SUIT_ExceptionHandler::internalHandle( o, e ); } - CASCatch_CATCH(CASCatch_Failure) { - aCatchSignals.Deactivate(); - Handle(CASCatch_Failure) aFail = CASCatch_Failure::Caught(); - throw std::runtime_error( aFail->GetError() ); + CASCatch_CATCH(Standard_Failure) { + Handle(Standard_Failure) aFail = Standard_Failure::Caught(); + throw Standard_Failure( aFail->GetMessageString() ); } - aCatchSignals.Deactivate(); return true; } -#ifdef try -#undef try -#endif - -#ifdef catch -#undef catch -#endif - /*!Try to call handleSignals( o, e ), catch and show error message.*/ bool SalomeApp_ExceptionHandler::handle( QObject* o, QEvent* e ) { diff --git a/src/SalomeApp/SalomeApp_Module.cxx b/src/SalomeApp/SalomeApp_Module.cxx index 9284a5792..b22992cf4 100644 --- a/src/SalomeApp/SalomeApp_Module.cxx +++ b/src/SalomeApp/SalomeApp_Module.cxx @@ -11,6 +11,7 @@ #include "LightApp_Selection.h" #include "LightApp_Operation.h" #include "LightApp_Preferences.h" +//#include "LightApp_Displayer.h" #include "CAM_DataModel.h" @@ -19,12 +20,24 @@ #include #include #include +//#include + +//#include "SALOMEDS_IParameters.hxx" #include +#include + +#include +//#include +//#include +//#include #include #include +//#include +//#include + /*!Constructor.*/ SalomeApp_Module::SalomeApp_Module( const QString& name ) : LightApp_Module( name ) @@ -97,3 +110,24 @@ void SalomeApp_Module::extractContainers( const SALOME_ListIO& source, SALOME_Li dest.Append( obj ); } } + +/*! + * \brief Virtual public + * + * This method is called just before the study document is saved, so the module has a possibility + * to store visual parameters in AttributeParameter attribue(s) + */ +void SalomeApp_Module::storeVisualParameters(int savePoint) +{ +} + +/*! + * \brief Virtual public + * + * This method is called after the study document is opened, so the module has a possibility to restore + * visual parameters + */ +void SalomeApp_Module::restoreVisualParameters(int savePoint) +{ +} + diff --git a/src/SalomeApp/SalomeApp_Module.h b/src/SalomeApp/SalomeApp_Module.h index 433d918fd..7346e8537 100644 --- a/src/SalomeApp/SalomeApp_Module.h +++ b/src/SalomeApp/SalomeApp_Module.h @@ -10,8 +10,6 @@ #include -#include - class CAM_DataModel; class SalomeApp_Application; class LightApp_Operation; @@ -41,6 +39,9 @@ public: SalomeApp_Application* getApp() const; + virtual void storeVisualParameters(int savePoint); + virtual void restoreVisualParameters(int savePoint); + protected: virtual CAM_DataModel* createDataModel(); virtual LightApp_Selection* createSelection() const; diff --git a/src/SalomeApp/SalomeApp_Study.cxx b/src/SalomeApp/SalomeApp_Study.cxx index f3de08660..be3e37d11 100644 --- a/src/SalomeApp/SalomeApp_Study.cxx +++ b/src/SalomeApp/SalomeApp_Study.cxx @@ -23,6 +23,7 @@ #include "SalomeApp_DataObject.h" #include "SalomeApp_Application.h" #include "SalomeApp_Engine_i.hxx" +#include "SalomeApp_VisualState.h" #include "LightApp_RootObject.h" @@ -31,16 +32,25 @@ #include #include +#include +#include #include "utilities.h" -#include "string.h" -#include "vector.h" +#include +#include +#include + +#include #include "SALOMEDS_Tool.hxx" +#include "SALOMEDS_IParameters.hxx" + #include #include CORBA_SERVER_HEADER(SALOME_Exception) +using namespace std; + /*! Constructor. */ @@ -130,6 +140,14 @@ bool SalomeApp_Study::openDocument( const QString& theFileName ) emit opened( this ); study->IsSaved(true); + + bool restore = application()->resourceMgr()->booleanValue( "Study", "store_visual_state", true ); + if ( restore ) { + std::vector savePoints = getSavePoints(); + if ( savePoints.size() > 0 ) + SalomeApp_VisualState( (SalomeApp_Application*)application() ).restoreState( savePoints[savePoints.size()-1] ); + } + return res; } @@ -167,6 +185,13 @@ bool SalomeApp_Study::loadDocument( const QString& theStudyName ) bool res = CAM_Study::openDocument( theStudyName ); emit opened( this ); + bool restore = application()->resourceMgr()->booleanValue( "Study", "store_visual_state", true ); + if ( restore ) { + std::vector savePoints = getSavePoints(); + if ( savePoints.size() > 0 ) + SalomeApp_VisualState( (SalomeApp_Application*)application() ).restoreState( savePoints[savePoints.size()-1] ); + } + //SRN: BugID IPAL9021: End return res; @@ -178,6 +203,10 @@ bool SalomeApp_Study::loadDocument( const QString& theStudyName ) //======================================================================= bool SalomeApp_Study::saveDocumentAs( const QString& theFileName ) { + bool store = application()->resourceMgr()->booleanValue( "Study", "store_visual_state", true ); + if ( store ) + SalomeApp_VisualState( (SalomeApp_Application*)application() ).storeState(); + ModelList list; dataModels( list ); SalomeApp_DataModel* aModel = (SalomeApp_DataModel*)list.first(); @@ -214,6 +243,10 @@ bool SalomeApp_Study::saveDocumentAs( const QString& theFileName ) //======================================================================= bool SalomeApp_Study::saveDocument() { + bool store = application()->resourceMgr()->booleanValue( "Study", "store_visual_state", true ); + if ( store ) + SalomeApp_VisualState( (SalomeApp_Application*)application() ).storeState(); + ModelList list; dataModels( list ); SalomeApp_DataModel* aModel = (SalomeApp_DataModel*)list.first(); @@ -221,7 +254,7 @@ bool SalomeApp_Study::saveDocument() for ( ; aModel; aModel = (SalomeApp_DataModel*)list.next() ) { listOfFiles.clear(); aModel->save(listOfFiles); - if ( !listOfFiles.isEmpty() ) + if ( !listOfFiles.isEmpty() ) saveModuleData(aModel->module()->name(), listOfFiles); } @@ -629,3 +662,89 @@ void SalomeApp_Study::components( QStringList& comps ) const comps.append( aComponent->ComponentDataType().c_str() ); } } + +//================================================================ +// Function : getSavePoints +/*! Purpose : returns a list of saved points' IDs +*/ +//================================================================ +std::vector SalomeApp_Study::getSavePoints() +{ + std::vector v; + + _PTR(SObject) so = studyDS()->FindComponent("Interface Applicative"); + if(!so) return v; + + _PTR(StudyBuilder) builder = studyDS()->NewBuilder(); + _PTR(ChildIterator) anIter ( studyDS()->NewChildIterator( so ) ); + for(; anIter->More(); anIter->Next()) + { + _PTR(SObject) val( anIter->Value() ); + _PTR(GenericAttribute) genAttr; + if(builder->FindAttribute(val, genAttr, "AttributeParameter")) v.push_back(val->Tag()); + } + + return v; +} + +//================================================================ +// Function :removeSavePoint +/*! Purpose : remove a given save point +*/ +//================================================================ +void SalomeApp_Study::removeSavePoint(int savePoint) +{ + if(savePoint <= 0) return; + _PTR(AttributeParameter) AP = studyDS()->GetCommonParameters(getVisualComponentName(), savePoint); + _PTR(SObject) so = AP->GetSObject(); + _PTR(StudyBuilder) builder = studyDS()->NewBuilder(); + builder->RemoveObjectWithChildren(so); +} + +//================================================================ +// Function : getNameOfSavePoint +/*! Purpose : returns a name of save point +*/ +//================================================================ +QString SalomeApp_Study::getNameOfSavePoint(int savePoint) +{ + _PTR(AttributeParameter) AP = studyDS()->GetCommonParameters(getVisualComponentName(), savePoint); + SALOMEDS_IParameters ip(AP); + return ip.getProperty("AP_SAVEPOINT_NAME"); +} + +//================================================================ +// Function : setNameOfSavePoint +/*! Purpose : sets a name of save point +*/ +//================================================================ +void SalomeApp_Study::setNameOfSavePoint(int savePoint, const QString& nameOfSavePoint) +{ + _PTR(AttributeParameter) AP = studyDS()->GetCommonParameters(getVisualComponentName(), savePoint); + SALOMEDS_IParameters ip(AP); + ip.setProperty("AP_SAVEPOINT_NAME", nameOfSavePoint.latin1()); +} + +//================================================================ +// Function : getVisualComponentName +/*! Purpose : returns a name of the component where visual + * parameters are stored +*/ +//================================================================ +std::string SalomeApp_Study::getVisualComponentName() +{ + return "Interface Applicative"; +} + +//================================================================ +// Function : updateModelRoot +/*! Purpose : slot called on change of a root of a data model. redefined from CAM_Study*/ +//================================================================ +void SalomeApp_Study::updateModelRoot( const CAM_DataModel* dm ) +{ + LightApp_Study::updateModelRoot( dm ); + + // calling updateSavePointDataObjects in order to set correct order of "Gui states" object + // it must always be the last one. + ((SalomeApp_Application*)application())->updateSavePointDataObjects( this ); +} diff --git a/src/SalomeApp/SalomeApp_Study.h b/src/SalomeApp/SalomeApp_Study.h index c07d20528..9034b1333 100644 --- a/src/SalomeApp/SalomeApp_Study.h +++ b/src/SalomeApp/SalomeApp_Study.h @@ -22,6 +22,7 @@ #include "SalomeApp.h" #include +#include #ifdef WIN32 #pragma warning( disable:4251 ) @@ -66,6 +67,12 @@ public: virtual void children( const QString&, QStringList& ) const; virtual void components( QStringList& ) const; + std::vector getSavePoints(); + void removeSavePoint(int savePoint); + QString getNameOfSavePoint(int savePoint); + void setNameOfSavePoint(int savePoint, const QString& nameOfSavePoint); + virtual std::string getVisualComponentName(); + protected: virtual void saveModuleData ( QString theModuleName, QStringList theListOfFiles ); virtual void openModuleData ( QString theModuleName, QStringList& theListOfFiles ); @@ -82,6 +89,9 @@ protected: virtual bool openDataModel( const QString&, CAM_DataModel* ); void setStudyDS(const _PTR(Study)& s ); +protected slots: + virtual void updateModelRoot( const CAM_DataModel* ); + private: QString newStudyName() const; diff --git a/src/SalomeApp/SalomeApp_TypeFilter.cxx b/src/SalomeApp/SalomeApp_TypeFilter.cxx index 58ab6bb57..5cedb609c 100644 --- a/src/SalomeApp/SalomeApp_TypeFilter.cxx +++ b/src/SalomeApp/SalomeApp_TypeFilter.cxx @@ -21,8 +21,6 @@ #include "LightApp_DataOwner.h" #include "SalomeApp_Study.h" -#include - /*! Constructor. */ diff --git a/src/SalomeApp/SalomeApp_VisualState.cxx b/src/SalomeApp/SalomeApp_VisualState.cxx new file mode 100644 index 000000000..ff00dbc88 --- /dev/null +++ b/src/SalomeApp/SalomeApp_VisualState.cxx @@ -0,0 +1,295 @@ +// Copyright (C) 2005 OPEN CASCADE, CEA/DEN, EDF R&D, PRINCIPIA R&D +// +// 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/ +// +#include "SalomeApp_VisualState.h" + +#include "SalomeApp_Module.h" +#include "SalomeApp_Study.h" +#include "SalomeApp_Application.h" + +#include +#include + +#include + +#include +#include +#include + +#include + +#include +#include + +/*! + Constructor. +*/ +SalomeApp_VisualState::SalomeApp_VisualState( SalomeApp_Application* app ) + : myApp( app ) +{ +} + +/*! + Destructor. +*/ +SalomeApp_VisualState::~SalomeApp_VisualState() +{ +} + +//================================================================ +// Function : nameViewWindows +/*! Purpose : set names of all view windows in given list. This is used +// in order to apply the same naming algorithm when saving and restoring +// view windows. Names of view windows must be the same before saving +// workstack (splitters) information, and before its restoring! +// Naming rule: ViewerType_IndexOfViewerOfThisType_IndexOfViewInThisViewer +// VTKViewer_0_0 +// OCCViewer_0_0 OCCViewer_0_1 OCCViewer_0_2 +// VTKViewer_1_0 +*/ +//================================================================ +void nameViewWindows( const ViewManagerList& lst ) +{ + QDict viewersCounter; // map viewerType - to - index_of_this_viewer_type + viewersCounter.setAutoDelete( true ); + for ( QPtrListIterator it(lst); it.current(); ++it) { + int view_count = it.current()->getViewsCount(); + QString vType = it.current()->getType(); + if ( !view_count ) + continue; //No views is opened in the viewer + + int* viewerID = viewersCounter[ vType ]; + if ( !viewerID ) { + viewerID = new int( 0 ); + viewersCounter.insert( vType, viewerID ); + } + else + ++(*viewerID); + + QPtrVector views = it.current()->getViews(); + for ( int i = 0; i < view_count; i++ ) { + QString vName = QString( "%1_%2_%3" ).arg( vType ).arg( *viewerID ).arg( i ); + views[i]->setName( vName ); + } + } +} + +//================================================================ +// Function : storeState +/*! Purpose : store the visual parameters of the viewers +*/ +//================================================================ +int SalomeApp_VisualState::storeState() +{ + SalomeApp_Study* study = dynamic_cast( myApp->activeStudy() ); + if ( !study ) + return -1; + + int savePoint = 1; + std::vector savePoints = study->getSavePoints(); + //Calculate a new savePoint number = the last save point number + 1 + if ( savePoints.size() > 0) + savePoint = savePoints[savePoints.size()-1] + 1; + + _PTR(AttributeParameter) ap = study->studyDS()->GetCommonParameters( study->getVisualComponentName(), savePoint ); + SALOMEDS_IParameters ip( ap ); + + ViewManagerList lst; + myApp->viewManagers( lst ); + + // setting unique names for view windows in order to save this view inside + // workstack's structure (see below). On restore the views with the same names will + // be placed to the same place inside the workstack's splitters. + nameViewWindows( lst ); + + // store active window's name + SUIT_ViewWindow* win = myApp->desktop()->activeWindow(); + if ( win ) + ip.setProperty("AP_ACTIVE_VIEW", win->name() ); + + int viewerID = 0; + SUIT_ViewManager* vm = 0; + for (QPtrListIterator it( lst ); it.current(); ++it ) { + vm = it.current(); + int view_count = vm->getViewsCount(); + if ( !view_count ) + continue; //No views is opened in the viewer + + std::string viewerEntry = QString( "%1_%2" ).arg( vm->getType() ).arg( ++viewerID ).latin1(); + ip.append("AP_VIEWERS_LIST", viewerEntry); + + QPtrVector views = vm->getViews(); + for(int i = 0; icaption() ); + ip.append( viewerEntry, views[i]->getVisualParameters().latin1() ); + } + } + + //Save information about split areas + if ( myApp->desktop()->inherits( "STD_TabDesktop" ) ) { + QtxWorkstack* workstack = ((STD_TabDesktop*)myApp->desktop())->workstack(); + QString workstackInfo; + (*workstack) >> workstackInfo; + ip.setProperty( "AP_WORKSTACK_INFO", workstackInfo.latin1() ); + } + + //Save a name of the active module + if ( CAM_Module* activeModule = myApp->activeModule() ) + ip.setProperty( "AP_ACTIVE_MODULE", activeModule->moduleName().latin1() ); + + //Store visual parameters of the modules + QPtrList mlist; + myApp->modules( mlist ); + CAM_Module* module = 0; + for ( module = mlist.first(); module; module = mlist.next() ) { + if ( SalomeApp_Module* sModule = dynamic_cast( module ) ) { + ip.append( "AP_MODULES_LIST", sModule->moduleName().latin1() ); + sModule->storeVisualParameters( savePoint ); + } + } + + // set default name of new savePoint + study->setNameOfSavePoint( savePoint, QObject::tr( "SAVE_POINT_DEF_NAME" ) + QString::number( savePoint ) ); + + return savePoint; +} + +//================================================================ +// Function : restoreState +/*! Purpose : restore the visual parameters of the viewers +*/ +//================================================================ +void SalomeApp_VisualState::restoreState(int savePoint) +{ + SalomeApp_Study* study = dynamic_cast( myApp->activeStudy() ); + if ( !study ) + return; + + _PTR(AttributeParameter) ap = study->studyDS()->GetCommonParameters( study->getVisualComponentName(), savePoint ); + SALOMEDS_IParameters ip(ap); + + //Remove all already existent veiwers and their views + ViewManagerList lst; + myApp->viewManagers( lst ); + for ( QPtrListIterator it(lst); it.current(); ++it ) + myApp->removeViewManager( it.current() ); + + //Restore the viewers and view windows + int nbViewers = ip.nbValues( "AP_VIEWERS_LIST" ); + SUIT_ViewWindow* viewWin = 0; + + for ( int i = 0; i < nbViewers; i++ ) { + std::string viewerEntry = ip.getValue( "AP_VIEWERS_LIST", i ); + std::vector veiewerParams = ip.parseValue(viewerEntry,'_'); + std::string type = veiewerParams[0]; + std::string viewerID = veiewerParams[1]; + SUIT_ViewManager* vm = myApp->newViewManager( type.c_str() ); + if ( !vm ) + continue; //Unknown viewer + + int nbViews = (ip.nbValues(viewerEntry))/2; + + //Create nbViews-1 view (-1 because 1 view is created by createViewManager) + for ( int i = 1; i< nbViews; i++ ) { + SUIT_ViewWindow* aView = vm->createViewWindow(); + aView->show(); + } + + int viewCount = vm->getViewsCount(); + if (viewCount != nbViews) { + printf( "\nRestore visual state: Unknow error, Can't create a view!\n" ); + continue; + } + + //Resize the views, set their captions and apply visual parameters. + QPtrVector views = vm->getViews(); + for (int i = 0, j = 0; iisVisible() ) + qApp->processEvents(); + + viewWin->setCaption(ip.getValue(viewerEntry, j).c_str()); + viewWin->setVisualParameters(ip.getValue(viewerEntry, j+1).c_str()); + } + } + + // restore modules' visual parameters + std::vector v = ip.getValues("AP_MODULES_LIST"); + for ( int i = 0; i < v.size(); i++ ) { + myApp->activateModule( v[i].c_str() ); + if ( SalomeApp_Module* module = dynamic_cast( myApp->activeModule() ) ) + module->restoreVisualParameters( savePoint ); + } + + // activate module that was active on save + QString activeModuleName( ip.getProperty("AP_ACTIVE_MODULE" ).c_str() ); + if ( !activeModuleName.isEmpty() ) + myApp->activateModule( activeModuleName ); + + // setting unique names for view windows in order to restore positions of view windows inside + // workstack's structure (see below). During save the same naming algorithm was used, + // so the same views will get the same names. + lst.clear(); + myApp->viewManagers(lst); + nameViewWindows( lst ); + + // work-around to bug of setting visual parameters of views: all view windows now have + // correct visual parameters, bug after restoring the workstack the visual parameters + // are messted, and must be re-set again. So here we store them in a map and set them + // later back again. why we don't store these parameters in a map on views creation? + // because 1) names of view windows are not set at that time 2) some view windows + // are created by modules' restoreVisualParameters (like Gauss Viewers), which is NOT here.. + QMap viewersParameters; + QPtrListIterator it( lst ); + for ( ; it.current(); ++it ) { + int view_count = it.current()->getViewsCount(); + QPtrVector views = it.current()->getViews(); + for ( int i = 0; i < view_count; i++ ) + viewersParameters[ views[i]->name() ] = views[i]->getVisualParameters(); + } + + // restore workstack parameters. should be done after module's restoreVisualParameters(), because + // some modules can create their own viewers (like VISU creates GaussViewers) + if ( myApp->desktop()->inherits( "STD_TabDesktop" ) ) { + QtxWorkstack* workstack = ((STD_TabDesktop*)myApp->desktop())->workstack(); + (*workstack) << ip.getProperty( "AP_WORKSTACK_INFO" ).c_str(); + } + + // restore visual parameters of view windows. it must be done AFTER restoring workstack. + for ( it.toFirst(); it.current(); ++it ) { + int view_count = it.current()->getViewsCount(); + QPtrVector views = it.current()->getViews(); + for ( int i = 0; i < view_count; i++ ) + views[i]->setVisualParameters( viewersParameters[ views[i]->name() ] ); + } + + // set focus to previously saved active view window + std::string activeViewName = ip.getProperty("AP_ACTIVE_VIEW"); + for ( it.toFirst(); it.current(); ++it ) { + int view_count = it.current()->getViewsCount(); + QPtrVector views = it.current()->getViews(); + for ( int i = 0; i < view_count; i++ ) { + if ( activeViewName == views[i]->name() ) + views[i]->setFocus(); + } + } +} diff --git a/src/OBJECT/SALOME_GLOwner.h b/src/SalomeApp/SalomeApp_VisualState.h similarity index 63% rename from src/OBJECT/SALOME_GLOwner.h rename to src/SalomeApp/SalomeApp_VisualState.h index 770911392..aa96a8383 100644 --- a/src/OBJECT/SALOME_GLOwner.h +++ b/src/SalomeApp/SalomeApp_VisualState.h @@ -16,30 +16,32 @@ // // See http://www.salome-platform.org/ // -#ifndef SALOME_GLOWNER_H -#define SALOME_GLOWNER_H +#ifndef SALOMEAPP_VISUALSTATE_H +#define SALOMEAPP_VISUALSTATE_H -#include -//#include -#include - -#ifdef WNT -#define SALOME_OBJECT_EXPORT __declspec (dllexport) -#else -#define SALOME_OBJECT_EXPORT +#ifdef WIN32 +#pragma warning( disable:4251 ) #endif -class SALOME_OBJECT_EXPORT SALOME_GLOwner : public GLViewer_Owner +#include "SalomeApp.h" + +class SalomeApp_Application; + +class SALOMEAPP_EXPORT SalomeApp_VisualState { public: - SALOME_GLOwner( const char* ); - ~SALOME_GLOwner(); + SalomeApp_VisualState( SalomeApp_Application* ); + virtual ~SalomeApp_VisualState(); - const char* entry() const; - void setEntry( const char* ); + virtual int storeState(); + virtual void restoreState( int savePoint ); -private: - std::string myEntry; +protected: + SalomeApp_Application* myApp; }; +#ifdef WIN32 +#pragma warning( default:4251 ) #endif + +#endif diff --git a/src/SalomeApp/Test/Makefile.in b/src/SalomeApp/Test/Makefile.in new file mode 100644 index 000000000..93e6b8dcd --- /dev/null +++ b/src/SalomeApp/Test/Makefile.in @@ -0,0 +1,65 @@ +# SALOMELocalTrace : log on local machine +# +# Copyright (C) 2003 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.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org +# +# +# +# File : Makefile.in +# Author : Sergey RUIN +# Module : SALOME + +top_srcdir=@top_srcdir@ +top_builddir=../../.. +srcdir=@srcdir@ +VPATH=.:@srcdir@:@top_srcdir@/idl + + +@COMMENCE@ + +# header files +EXPORT_HEADERS= SalomeAppTest.hxx + +EXPORT_PYSCRIPTS = TestSalomeApp.py + +# Libraries targets + +LIB = libSalomeAppTest.la +LIB_SRC = SalomeAppTest.cxx +LIB_CLIENT_IDL = + +# Executables targets + +BIN = TestSalomeApp +BIN_SRC = +BIN_CLIENT_IDL = + + +CXXFLAGS += $ @CPPUNIT_INCLUDES@ -I${KERNEL_ROOT_DIR}/include/salome +CPPFLAGS += $ @CPPUNIT_INCLUDES@ -I${KERNEL_ROOT_DIR}/include/salome + +LIBS= @LIBS@ @CPPUNIT_LIBS@ + +LDFLAGS+= + +LDFLAGSFORBIN+= $(LDFLAGS) -lSalomeAppTest + +UNIT_TEST_PROG = TestSalomeApp + +@CONCLUDE@ diff --git a/src/SalomeApp/Test/SalomeAppTest.cxx b/src/SalomeApp/Test/SalomeAppTest.cxx new file mode 100644 index 000000000..f34ab8b32 --- /dev/null +++ b/src/SalomeApp/Test/SalomeAppTest.cxx @@ -0,0 +1,56 @@ +// Copyright (C) 2006 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/ +// + +#include "SalomeAppTest.hxx" + +using namespace std; + +// ============================================================================ +/*! + * Set up the environment + */ +// ============================================================================ + +void SalomeAppTest::setUp() +{ +} + +// ============================================================================ +/*! + * - delete + */ +// ============================================================================ + +void SalomeAppTest::tearDown() +{ +} + +// ============================================================================ +/*! + * Check SalomeApp functionality + */ +// ============================================================================ +void SalomeAppTest::testSalomeApp() +{ +} + + + + diff --git a/src/SalomeApp/Test/SalomeAppTest.hxx b/src/SalomeApp/Test/SalomeAppTest.hxx new file mode 100644 index 000000000..0f5a3f959 --- /dev/null +++ b/src/SalomeApp/Test/SalomeAppTest.hxx @@ -0,0 +1,39 @@ +// Copyright (C) 2006 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/ +// + +#ifndef _SalomeAppTEST_HXX_ +#define _SalomeAppTEST_HXX_ + +#include + +class SalomeAppTest : public CppUnit::TestFixture +{ + CPPUNIT_TEST_SUITE( SalomeAppTest ); + CPPUNIT_TEST( testSalomeApp ); + CPPUNIT_TEST_SUITE_END(); + +public: + + void setUp(); + void tearDown(); + void testSalomeApp(); +}; + +#endif diff --git a/src/OBJECT/SALOME_GLOwner.cxx b/src/SalomeApp/Test/TestSalomeApp.cxx similarity index 65% rename from src/OBJECT/SALOME_GLOwner.cxx rename to src/SalomeApp/Test/TestSalomeApp.cxx index ed88afb38..5168f98af 100644 --- a/src/OBJECT/SALOME_GLOwner.cxx +++ b/src/SalomeApp/Test/TestSalomeApp.cxx @@ -1,4 +1,5 @@ -// Copyright (C) 2005 OPEN CASCADE, CEA/DEN, EDF R&D, PRINCIPIA R&D +// Copyright (C) 2005 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 @@ -17,24 +18,14 @@ // See http://www.salome-platform.org/ // -#include +// --- include all SalomeApp Test from basics until the present directory -SALOME_GLOwner::SALOME_GLOwner( const char* entry ) -: GLViewer_Owner() -{ - setEntry( entry ); -} +#include "SalomeAppTest.hxx" -SALOME_GLOwner::~SALOME_GLOwner() -{ -} +// --- Registers the fixture into the 'registry' -const char* SALOME_GLOwner::entry() const -{ - return myEntry.c_str(); -} +CPPUNIT_TEST_SUITE_REGISTRATION( SalomeAppTest ); -void SALOME_GLOwner::setEntry( const char* entry ) -{ - myEntry = entry; -} +// --- generic Main program from Basic/Test + +#include "BasicMainTest.hxx" diff --git a/src/SalomeApp/Test/TestSalomeApp.py b/src/SalomeApp/Test/TestSalomeApp.py new file mode 100644 index 000000000..03daaf27b --- /dev/null +++ b/src/SalomeApp/Test/TestSalomeApp.py @@ -0,0 +1,29 @@ + +import sys, os,signal,string,commands +import runSalome +import orbmodule +import TestKiller + +# get SALOME environment : + +args, modules_list, modules_root_dir = runSalome.get_config() +runSalome.set_env(args, modules_list, modules_root_dir) + +# launch CORBA naming server + +clt=orbmodule.client() + +# launch CORBA logger server + +myServer=runSalome.LoggerServer(args) +myServer.run() +clt.waitLogger("Logger") + +# execute Unit Test + +command = ['TestSalomeApp'] +ret = os.spawnvp(os.P_WAIT, command[0], command) + +# kill Test process + +TestKiller.killProcess(runSalome.process_id) diff --git a/src/SalomeApp/resources/SalomeApp.xml b/src/SalomeApp/resources/SalomeApp.xml index 4c290584a..3fa77b587 100644 --- a/src/SalomeApp/resources/SalomeApp.xml +++ b/src/SalomeApp/resources/SalomeApp.xml @@ -1,10 +1,10 @@
- - - - - + + + + +
@@ -59,7 +59,8 @@
- + +
@@ -179,6 +180,7 @@
+ diff --git a/src/SalomeApp/resources/SalomeApp_msg_en.po b/src/SalomeApp/resources/SalomeApp_msg_en.po index a739779d2..0e484c4e9 100644 --- a/src/SalomeApp/resources/SalomeApp_msg_en.po +++ b/src/SalomeApp/resources/SalomeApp_msg_en.po @@ -42,6 +42,15 @@ msgstr "&Dump study..." msgid "SalomeApp_Application::PRP_DESK_FILE_DUMP_STUDY" msgstr "Dumps study to the python script" +msgid "SalomeApp_Application::TOT_DESK_FILE_SAVE_GUI_STATE" +msgstr "Save GUI state" + +msgid "SalomeApp_Application::MEN_DESK_FILE_SAVE_GUI_STATE" +msgstr "Save GUI state..." + +msgid "SalomeApp_Application::PRP_DESK_FILE_SAVE_GUI_STATE" +msgstr "Saves current state of viewers, displayed objects, etc." + msgid "SalomeApp_Application::TOT_DESK_FILE_LOAD_SCRIPT" msgstr "Load python script" @@ -102,6 +111,17 @@ msgstr "Activate Module" msgid "SalomeApp_Application::MEN_DELETE_INVALID_REFERENCE" msgstr "Delete Invalid Reference" +msgid "SalomeApp_Application::PREF_STORE_VISUAL_STATE" +msgstr "Store/restore last GUI state" + +//======================================================================================= + +msgid "PUBLISH_IN_STUDY" +msgstr "Publish in study" + +msgid "SAVE_GUI_STATE" +msgstr "Save GUI state" + //======================================================================================= msgid "SalomeApp_Application::MEN_WINDOWS_NEW" @@ -190,3 +210,25 @@ msgstr "Publish in study" msgid "SalomeApp_Application::WRN_DUMP_STUDY_FAILED" msgstr "Dump study failed" +msgid "SAVE_POINT_OBJECT_TOOLTIP" +msgstr "Saved GUI state: %1" + +msgid "SAVE_POINT_DEF_NAME" +msgstr "GUI state: " + +msgid "SAVE_POINT_ROOT_TOOLTIP" +msgstr "Persistent GUI states" + +msgid "SAVE_POINT_ROOT_NAME" +msgstr "GUI states" + +//======================================================================================= + +msgid "SalomeApp_Application::MEN_RESTORE_VS" +msgstr "Restore" + +msgid "SalomeApp_Application::MEN_RENAME_VS" +msgstr "Rename" + +msgid "SalomeApp_Application::MEN_DELETE_VS" +msgstr "Delete" diff --git a/src/Session/Makefile.in b/src/Session/Makefile.in index 226711e2b..22837fbc8 100755 --- a/src/Session/Makefile.in +++ b/src/Session/Makefile.in @@ -46,7 +46,6 @@ LIB = libSalomeSession.la LIB_SRC=Session_Session_i.cxx \ Session_ServerThread.cxx \ Session_ServerLauncher.cxx \ - Session_SignalsHandler.cxx \ SalomeApp_Engine_i.cxx \ InquireServersQThread.cxx @@ -61,7 +60,7 @@ BIN_CLIENT_IDL = SALOMEDS.idl SALOMEDS_Attributes.idl SALOME_Component.idl SALOM CPPFLAGS += $(QT_MT_INCLUDES) $(PYTHON_INCLUDES) $(HDF5_INCLUDES) $(BOOST_CPPFLAGS) -I$(KERNEL_ROOT_DIR)/include/salome -I$(OCC_INCLUDES) CXXFLAGS += $(OCC_CXXFLAGS) $(BOOST_CPPFLAGS) -LDFLAGS += $(QT_MT_LIBS) -L$(KERNEL_ROOT_DIR)/lib/salome -lSalomeNS -lsuit -lSalomeLifeCycleCORBA -lOpUtil -lSALOMELocalTrace -lwith_loggerTraceCollector -lEvent -lCASCatch -lSalomeCatalog -lSalomeDS $(CAS_KERNEL) +LDFLAGS += $(QT_MT_LIBS) -L$(KERNEL_ROOT_DIR)/lib/salome -lSalomeNS -lsuit -lSalomeLifeCycleCORBA -lOpUtil -lSALOMELocalTrace -lwith_loggerTraceCollector -lEvent -lSalomeCatalog -lSalomeDSClient $(CAS_KERNEL) LDFLAGSFORBIN= $(LDFLAGS) $(OMNIORB_LIBS) $(HDF5_LIBS) -lqtx -lSalomeContainer -lSalomeResourcesManager -lTOOLSDS -lSalomeHDFPersist -lSalomeDSImpl -lSalomeGenericObj -lRegistry -lSalomeNotification -lSALOMEBasics diff --git a/src/Session/SALOME_Session_Server.cxx b/src/Session/SALOME_Session_Server.cxx index ac7738582..dbc9e1633 100755 --- a/src/Session/SALOME_Session_Server.cxx +++ b/src/Session/SALOME_Session_Server.cxx @@ -63,8 +63,6 @@ #include "SUIT_ExceptionHandler.h" -extern "C" int HandleSignals( QApplication *theQApplication ); - /*! - read arguments, define list of server to launch with their arguments. * - wait for naming service * - create and run a thread for launch of all servers diff --git a/src/Session/Session_ServerThread.cxx b/src/Session/Session_ServerThread.cxx index 7e3714518..a0d00d9ea 100755 --- a/src/Session/Session_ServerThread.cxx +++ b/src/Session/Session_ServerThread.cxx @@ -34,7 +34,8 @@ #include "SALOME_Container_i.hxx" #include "SALOME_ContainerManager.hxx" -#include "SALOMEDS_StudyManager_i.hxx" +#include +#include #include "SALOME_ModuleCatalog_impl.hxx" #include "RegistryService.hxx" #include "Session_Session_i.hxx" @@ -246,15 +247,7 @@ void Session_ServerThread::ActivateSALOMEDS(int argc, // counted objects, they will be deleted by the POA when they are no // longer needed. - SALOMEDS_StudyManager_i * myStudyManager_i - = new SALOMEDS_StudyManager_i(_orb,_root_poa); - - // Activate the objects. This tells the POA that the objects are - // ready to accept requests. - - PortableServer::ObjectId_var myStudyManager_iid - = _root_poa->activate_object(myStudyManager_i); - myStudyManager_i->register_name("/myStudyManager"); + ClientFactory::createStudyManager(_orb,_root_poa); } catch(CORBA::SystemException&) { diff --git a/src/Session/Session_Session_i.cxx b/src/Session/Session_Session_i.cxx index 41869b4d3..1a9662eea 100755 --- a/src/Session/Session_Session_i.cxx +++ b/src/Session/Session_Session_i.cxx @@ -213,3 +213,27 @@ CORBA::Long SALOME_Session_i::GetActiveStudyId() } return aStudyId; } + +bool SALOME_Session_i::restoreVisualState(CORBA::Long theSavePoint) +{ + class TEvent: public SALOME_Event { + int _savePoint; + public: + TEvent(int savePoint) { _savePoint = savePoint; } + virtual void Execute() { + SUIT_Study* study = SUIT_Session::session()->activeApplication()->activeStudy(); + if ( study ) { + study->restoreState(_savePoint); + } + } + }; + + if(SUIT_Session::session() && SUIT_Session::session()->activeApplication() ) { + SUIT_Study* study = SUIT_Session::session()->activeApplication()->activeStudy(); + if(!study) SUIT_Session::session()->activeApplication()->createEmptyStudy(); + ProcessVoidEvent( new TEvent(theSavePoint) ); + return true; + } + + return false; +} diff --git a/src/Session/Session_Session_i.hxx b/src/Session/Session_Session_i.hxx index c9815a42d..6a7f40361 100755 --- a/src/Session/Session_Session_i.hxx +++ b/src/Session/Session_Session_i.hxx @@ -67,6 +67,9 @@ public: void ping(){}; + //! Restors a visual state of the study at theSavePoint + bool restoreVisualState(CORBA::Long theSavePoint); + protected: //! Naming service interface diff --git a/src/Session/Session_SignalsHandler.cxx b/src/Session/Session_SignalsHandler.cxx deleted file mode 100755 index 4eeface46..000000000 --- a/src/Session/Session_SignalsHandler.cxx +++ /dev/null @@ -1,45 +0,0 @@ -// Copyright (C) 2003 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.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org - - -#include -#include - -#include -#include -#include - -extern "C" int HandleSignals(QApplication *theQApplication) -{ - int aRet = -1; - CASCatch_CatchSignals aCatchSignals; - aCatchSignals.Activate(); - - CASCatch_TRY { - aRet = theQApplication->exec(); - } - CASCatch_CATCH(CASCatch_Failure) { - aCatchSignals.Deactivate(); - Handle(CASCatch_Failure) aFail = CASCatch_Failure::Caught(); - throw std::runtime_error( aFail->GetError() ); - } - - aCatchSignals.Deactivate(); - return aRet; -} diff --git a/src/VTKViewer/VTKViewer_Actor.cxx b/src/VTKViewer/VTKViewer_Actor.cxx index da05fc98d..d2f72e2b8 100755 --- a/src/VTKViewer/VTKViewer_Actor.cxx +++ b/src/VTKViewer/VTKViewer_Actor.cxx @@ -408,7 +408,12 @@ bool VTKViewer_Actor ::IsInfinitive() { - return myIsInfinite; + static float MIN_DISTANCE = 1.0 / VTK_LARGE_FLOAT; + + if(myIsInfinite || GetLength() < MIN_DISTANCE) + return true; + else + return false; } diff --git a/src/VTKViewer/VTKViewer_AppendFilter.cxx b/src/VTKViewer/VTKViewer_AppendFilter.cxx index dce05c44e..222d2f1ab 100644 --- a/src/VTKViewer/VTKViewer_AppendFilter.cxx +++ b/src/VTKViewer/VTKViewer_AppendFilter.cxx @@ -28,38 +28,15 @@ #include "VTKViewer_AppendFilter.h" -#include "VTKViewer_ConvexTool.h" - -#include -#include +#include #include -#include -#include -#include +#include +#include #include #include -#include -#include -#include -#include -#include #include -#include -#include -#include - -#include -#include -using namespace std; - -#ifdef _DEBUG_ -//static int MYDEBUG = 0; -//static int MYDEBUGWITHFILES = 0; -#else -//static int MYDEBUG = 0; -//static int MYDEBUGWITHFILES = 0; -#endif +#include #if defined __GNUC__ #if __GNUC__ == 2 @@ -73,7 +50,7 @@ vtkStandardNewMacro(VTKViewer_AppendFilter); VTKViewer_AppendFilter ::VTKViewer_AppendFilter() { - myDoMappingFlag=false; + myDoMappingFlag = false; } VTKViewer_AppendFilter @@ -84,7 +61,12 @@ void VTKViewer_AppendFilter ::SetDoMappingFlag(const bool theFlag) { - myDoMappingFlag=theFlag; + if(myDoMappingFlag == theFlag) + return; + + myDoMappingFlag = theFlag; + + this->Modified(); } bool @@ -98,7 +80,12 @@ void VTKViewer_AppendFilter ::SetPoints(vtkPoints* thePoints) { + if(GetPoints() == thePoints) + return; + myPoints = thePoints; + + this->Modified(); } vtkPoints* @@ -112,28 +99,16 @@ void VTKViewer_AppendFilter ::Execute() { - if (myPoints.GetPointer()) { + if(myPoints.GetPointer()) MakeOutput(); - } - else { - vtkAppendFilter::Execute(); - } - if (myDoMappingFlag){ + else + Superclass::Execute(); + + if(myDoMappingFlag) DoMapping(); - } } -void -VTKViewer_AppendFilter -::Reset() -{ - myNodeIds.clear(); - myCellIds.clear(); - myNodeRanges.clear(); - myCellRanges.clear(); - myNodeMapObjIDVtkID.clear(); - myCellMapObjIDVtkID.clear(); -} + //================================================================== // function: DoMapping // purpose : @@ -142,165 +117,140 @@ void VTKViewer_AppendFilter ::DoMapping() { - int i, j, i1, i2, iNodeCnt, iCellCnt; - IteratorOfDataMapOfIntegerInteger aMapIt; - vtkIdType aNbPnts, aNbCells, aId; - vtkDataSet *pDS; - // - Reset(); - // - iNodeCnt=0; - iCellCnt=0; - for (i=0; iGetNumberOfPoints(); - i1=myNodeIds.size(); - i2=i1+aNbPnts-1; - myNodeRanges.push_back(i1); - myNodeRanges.push_back(i2); - // - for(j=0; jGetNumberOfCells(); - i1=myCellIds.size(); - i2=i1+aNbCells-1; - myCellRanges.push_back(i1); - myCellRanges.push_back(i2); - for(j=0; jNumberOfInputs; ++aDataSetId){ + vtkDataSet* aDataSet = (vtkDataSet *)(this->Inputs[aDataSetId]); + // Do mapping of the nodes + if(!myPoints.GetPointer()){ + vtkIdType aNbPnts = aDataSet->GetNumberOfPoints(); + myNodeRanges.push_back(aPntStartId + aNbPnts); + aPntStartId += aNbPnts; } + // Do mapping of the cells + vtkIdType aNbCells = aDataSet->GetNumberOfCells(); + myCellRanges.push_back(aCellStartId + aNbCells); + aCellStartId += aNbCells; } } //--------------------------------------------------------------- +namespace +{ + inline + vtkIdType + GetOutputID(vtkIdType theInputID, + vtkIdType theInputDataSetID, + const VTKViewer_AppendFilter::TVectorIds& theRanges) + { + theInputID = theInputDataSetID = -1; + + vtkIdType aNbInputs = theRanges.size(); + if(theInputDataSetID < 0 || theInputDataSetID >= aNbInputs) + return -1; + + vtkIdType aStartId = theRanges[theInputDataSetID]; + return aStartId + theInputID; + } +} + vtkIdType VTKViewer_AppendFilter -::GetPointOutputID(vtkIdType theInputID) +::GetPointOutputID(vtkIdType theInputID, + vtkIdType theInputDataSetID) { - if (myPoints.GetPointer()) { + if(myPoints.GetPointer()) return theInputID; - } - // - int aVtkID=-1; - IteratorOfDataMapOfIntegerInteger aMapIt; - // - aMapIt=myNodeMapObjIDVtkID.find(theInputID); - if (aMapIt!=myNodeMapObjIDVtkID.end()) { - // found - PairOfDataMapOfIntegerInteger& aPair=(*aMapIt); - aVtkID=aPair.second; - } - return aVtkID; + + return GetOutputID(theInputID,theInputDataSetID,myNodeRanges); } //--------------------------------------------------------------- vtkIdType VTKViewer_AppendFilter -::GetCellOutputID(vtkIdType theInputID) +::GetCellOutputID(vtkIdType theInputID, + vtkIdType theInputDataSetID) { - int aVtkID=-1; - IteratorOfDataMapOfIntegerInteger aMapIt; - // - aMapIt=myCellMapObjIDVtkID.find(theInputID); - if (aMapIt!=myCellMapObjIDVtkID.end()) { - // found - PairOfDataMapOfIntegerInteger& aPair=(*aMapIt); - aVtkID=aPair.second; - } - return aVtkID; + if(myPoints.GetPointer()) + return theInputID; + + return GetOutputID(theInputID,theInputDataSetID,myCellRanges); } //--------------------------------------------------------------- -vtkIdType +namespace +{ + void + GetInputID(vtkIdType theOutputID, + vtkIdType& theInputID, + vtkIdType& theStartID, + vtkIdType& theInputDataSetID, + const VTKViewer_AppendFilter::TVectorIds& theRanges) + { + theInputID = theStartID = theInputDataSetID = -1; + + if(theRanges.empty()) + return; + + const vtkIdType& aRangeEnd = theRanges.back(); + if(theOutputID < 0 || theOutputID >= aRangeEnd) + return; + + vtkIdType aStartId = 0; + vtkIdType aNbInputs = theRanges.size(); + for(vtkIdType aDataSetId = 0; aDataSetId < aNbInputs; ++aDataSetId){ + vtkIdType aRange = theRanges[aDataSetId]; + if(aRange > theOutputID){ + theInputID = theOutputID - aStartId; + theInputDataSetID = aDataSetId; + theStartID = aStartId; + break; + } + aStartId = aRange; + } + } +} + +void VTKViewer_AppendFilter -::GetPointInputID(vtkIdType theOutputID, +::GetPointInputID(vtkIdType theOutputID, + vtkIdType& theInputID, + vtkIdType& theStartID, vtkIdType& theInputDataSetID) { - if (myPoints.GetPointer()) { - theInputDataSetID=0; - return theOutputID; - } - // - int aNb, aNbRanges, aRetID, i, i1, i2, j; - // - aRetID=-1; - theInputDataSetID=-1; - // - aNb=myNodeIds.size(); - if (theOutputID<0 || theOutputID>=aNb) { - return aRetID; - } - // - aRetID=(int)myNodeIds[theOutputID]; - // - aNbRanges=myNodeRanges.size()/2; - for (i=0; i=i1 && theOutputID<=i2) { - theInputDataSetID=i; - } + if(myPoints.GetPointer()) { + theStartID = theInputDataSetID = 0; + theInputID = theOutputID; + return; } - // - return aRetID; + + ::GetInputID(theOutputID, + theInputID, + theStartID, + theInputDataSetID, + myNodeRanges); } //--------------------------------------------------------------- -vtkIdType +void VTKViewer_AppendFilter -::GetCellInputID(vtkIdType theOutputID, +::GetCellInputID(vtkIdType theOutputID, + vtkIdType& theInputID, + vtkIdType& theStartID, vtkIdType& theInputDataSetID) { - int aNb, aNbRanges, aRetID, i, i1, i2, j; - // - aRetID=-1; - theInputDataSetID=-1; - // - aNb=myCellIds.size(); - if (theOutputID<0 || theOutputID>=aNb) { - return aRetID; - } - // - aRetID=(int)myCellIds[theOutputID]; - // - aNbRanges=myCellRanges.size()/2; - for (i=0; i=i1 && theOutputID<=i2) { - theInputDataSetID=i; - } - } - // - return aRetID; + ::GetInputID(theOutputID, + theInputID, + theStartID, + theInputDataSetID, + myCellRanges); } diff --git a/src/VTKViewer/VTKViewer_AppendFilter.h b/src/VTKViewer/VTKViewer_AppendFilter.h index f9c6b245a..ceaa3d323 100644 --- a/src/VTKViewer/VTKViewer_AppendFilter.h +++ b/src/VTKViewer/VTKViewer_AppendFilter.h @@ -36,19 +36,27 @@ public: GetPoints(); vtkIdType - GetPointOutputID(vtkIdType theInputID); + GetPointOutputID(vtkIdType theInputID, + vtkIdType theInputDataSetID); vtkIdType - GetCellOutputID(vtkIdType theInputID); + GetCellOutputID(vtkIdType theInputID, + vtkIdType theInputDataSetID); - vtkIdType - GetPointInputID(vtkIdType theOutputID, - vtkIdType& theInputDataSetID); + void + GetPointInputID(vtkIdType theOutputID, + vtkIdType& theInputID, + vtkIdType& theStartID, + vtkIdType& theInputDataSetID); - vtkIdType - GetCellInputID(vtkIdType theOutputID, + void + GetCellInputID(vtkIdType theOutputID, + vtkIdType& theInputID, + vtkIdType& theStartID, vtkIdType& theInputDataSetID); + typedef std::vector TVectorIds; + protected: /*! \fn VTKViewer_AppendFilter(); * \brief Constructor @@ -69,23 +77,10 @@ protected: void MakeOutput(); - // + bool myDoMappingFlag; + TVectorIds myNodeRanges; + TVectorIds myCellRanges; vtkSmartPointer myPoints; - -private: - typedef std::vector TVectorId; - typedef std::vector VectorInt; - typedef std::map DataMapOfIntegerInteger; - typedef DataMapOfIntegerInteger::iterator IteratorOfDataMapOfIntegerInteger; - typedef DataMapOfIntegerInteger::value_type PairOfDataMapOfIntegerInteger; -private: - bool myDoMappingFlag; - TVectorId myNodeIds; - TVectorId myCellIds; - VectorInt myNodeRanges; - VectorInt myCellRanges; - DataMapOfIntegerInteger myNodeMapObjIDVtkID; - DataMapOfIntegerInteger myCellMapObjIDVtkID; }; #endif diff --git a/src/VTKViewer/VTKViewer_Utilities.cxx b/src/VTKViewer/VTKViewer_Utilities.cxx index a05b0a36f..723eea3fc 100755 --- a/src/VTKViewer/VTKViewer_Utilities.cxx +++ b/src/VTKViewer/VTKViewer_Utilities.cxx @@ -29,56 +29,70 @@ /*!@see vtkRenderer::ResetCamera(float bounds[6]) method*/ void ResetCamera(vtkRenderer* theRenderer, int theUsingZeroFocalPoint) { - if(!theRenderer) return; - float bounds[6]; - int aCount = ComputeVisiblePropBounds(theRenderer,bounds); + if(!theRenderer) + return; + + vtkCamera* aCamera = theRenderer->GetActiveCamera(); + if(!aCamera) + return; + + float aBounds[6]; + int aCount = ComputeVisiblePropBounds(theRenderer,aBounds); + if(theUsingZeroFocalPoint || aCount){ - float aLength = bounds[1]-bounds[0]; - aLength = max((bounds[3]-bounds[2]),aLength); - aLength = max((bounds[5]-bounds[4]),aLength); + static float MIN_DISTANCE = 1.0 / VTK_LARGE_FLOAT; + + float aLength = aBounds[1]-aBounds[0]; + aLength = max((aBounds[3]-aBounds[2]),aLength); + aLength = max((aBounds[5]-aBounds[4]),aLength); - double vn[3]; - if ( theRenderer->GetActiveCamera() != NULL ) - theRenderer->GetActiveCamera()->GetViewPlaneNormal(vn); - else{ + if(aLength < MIN_DISTANCE) return; - } + + float aWidth = + sqrt((aBounds[1]-aBounds[0])*(aBounds[1]-aBounds[0]) + + (aBounds[3]-aBounds[2])*(aBounds[3]-aBounds[2]) + + (aBounds[5]-aBounds[4])*(aBounds[5]-aBounds[4])); + + if(aWidth < MIN_DISTANCE) + return; + + double aViewPlaneNormal[3]; + aCamera->GetViewPlaneNormal(aViewPlaneNormal); - float center[3] = {0.0, 0.0, 0.0}; + float aCenter[3] = {0.0, 0.0, 0.0}; if(!theUsingZeroFocalPoint){ - center[0] = (bounds[0] + bounds[1])/2.0; - center[1] = (bounds[2] + bounds[3])/2.0; - center[2] = (bounds[4] + bounds[5])/2.0; + aCenter[0] = (aBounds[0] + aBounds[1])/2.0; + aCenter[1] = (aBounds[2] + aBounds[3])/2.0; + aCenter[2] = (aBounds[4] + aBounds[5])/2.0; } - theRenderer->GetActiveCamera()->SetFocalPoint(center[0],center[1],center[2]); + aCamera->SetFocalPoint(aCenter[0],aCenter[1],aCenter[2]); - float width = sqrt((bounds[1]-bounds[0])*(bounds[1]-bounds[0]) + - (bounds[3]-bounds[2])*(bounds[3]-bounds[2]) + - (bounds[5]-bounds[4])*(bounds[5]-bounds[4])); - - double ang = theRenderer->GetActiveCamera()->GetViewAngle(); - float distance = 2.0*width/tan(ang*vtkMath::Pi()/360.0); + double aViewAngle = aCamera->GetViewAngle(); + float aDistance = 2.0*aWidth/tan(aViewAngle*vtkMath::Pi()/360.0); // check view-up vector against view plane normal - double *vup = theRenderer->GetActiveCamera()->GetViewUp(); - if ( fabs(vtkMath::Dot(vup,vn)) > 0.999 ){ - theRenderer->GetActiveCamera()->SetViewUp(-vup[2], vup[0], vup[1]); - } + double aViewUp[3]; + aCamera->GetViewUp(aViewUp); + if(fabs(vtkMath::Dot(aViewUp,aViewPlaneNormal)) > 0.999) + aCamera->SetViewUp(-aViewUp[2], aViewUp[0], aViewUp[1]); // update the camera - theRenderer->GetActiveCamera()->SetPosition(center[0]+distance*vn[0], - center[1]+distance*vn[1], - center[2]+distance*vn[2]); + aCamera->SetPosition(aCenter[0]+aDistance*aViewPlaneNormal[0], + aCenter[1]+aDistance*aViewPlaneNormal[1], + aCenter[2]+aDistance*aViewPlaneNormal[2]); + // find size of the window - int* winsize = theRenderer->GetSize(); - if(winsize[0] < winsize[1]) width *= float(winsize[1])/float(winsize[0]); + int* aWinSize = theRenderer->GetSize(); + if(aWinSize[0] < aWinSize[1]) + aWidth *= float(aWinSize[1])/float(aWinSize[0]); - if(theUsingZeroFocalPoint) width *= sqrt(2.0); + if(theUsingZeroFocalPoint) + aWidth *= sqrt(2.0); - theRenderer->GetActiveCamera()->SetParallelScale(width/2.0); + aCamera->SetParallelScale(aWidth/2.0); } - //workaround on VTK - //theRenderer->ResetCameraClippingRange(bounds); + ResetCameraClippingRange(theRenderer); } diff --git a/src/VTKViewer/VTKViewer_ViewWindow.cxx b/src/VTKViewer/VTKViewer_ViewWindow.cxx index d4500095a..144590803 100755 --- a/src/VTKViewer/VTKViewer_ViewWindow.cxx +++ b/src/VTKViewer/VTKViewer_ViewWindow.cxx @@ -559,3 +559,54 @@ QImage VTKViewer_ViewWindow::dumpView() QPixmap px = QPixmap::grabWindow( myRenderWindow->winId() ); return px.convertToImage(); } + +/*! The method returns the visual parameters of this view as a formated string + */ +QString VTKViewer_ViewWindow::getVisualParameters() +{ + double pos[3], focalPnt[3], viewUp[3], parScale, scale[3]; + + vtkCamera* camera = myRenderer->GetActiveCamera(); + camera->GetPosition( pos ); + camera->GetFocalPoint( focalPnt ); + camera->GetViewUp( viewUp ); + parScale = camera->GetParallelScale(); + GetScale( scale ); + + QString retStr; + retStr.sprintf( "%.12e*%.12e*%.12e*%.12e*%.12e*%.12e*%.12e*%.12e*%.12e*%.12e*%.12e*%.12e*%.12e", + pos[0], pos[1], pos[2], focalPnt[0], focalPnt[1], focalPnt[2], viewUp[0], viewUp[1], + viewUp[2], parScale, scale[0], scale[1], scale[2] ); + return retStr; +} + +/* The method restors visual parameters of this view from a formated string + */ +void VTKViewer_ViewWindow::setVisualParameters( const QString& parameters ) +{ + QStringList paramsLst = QStringList::split( '*', parameters, true ); + if ( paramsLst.size() == 13 ) { + double pos[3], focalPnt[3], viewUp[3], parScale, scale[3]; + pos[0] = paramsLst[0].toDouble(); + pos[1] = paramsLst[1].toDouble(); + pos[2] = paramsLst[2].toDouble(); + focalPnt[0] = paramsLst[3].toDouble(); + focalPnt[1] = paramsLst[4].toDouble(); + focalPnt[2] = paramsLst[5].toDouble(); + viewUp[0] = paramsLst[6].toDouble(); + viewUp[1] = paramsLst[7].toDouble(); + viewUp[2] = paramsLst[8].toDouble(); + parScale = paramsLst[9].toDouble(); + scale[0] = paramsLst[10].toDouble(); + scale[1] = paramsLst[11].toDouble(); + scale[2] = paramsLst[12].toDouble(); + + vtkCamera* camera = myRenderer->GetActiveCamera(); + camera->SetPosition( pos ); + camera->SetFocalPoint( focalPnt ); + camera->SetViewUp( viewUp ); + camera->SetParallelScale( parScale ); + myTransform->SetMatrixScale( scale[0], scale[1], scale[2] ); + myRWInteractor->Render(); + } +} diff --git a/src/VTKViewer/VTKViewer_ViewWindow.h b/src/VTKViewer/VTKViewer_ViewWindow.h index 951d96d4c..5c02b79a6 100755 --- a/src/VTKViewer/VTKViewer_ViewWindow.h +++ b/src/VTKViewer/VTKViewer_ViewWindow.h @@ -70,6 +70,9 @@ public: void AddActor( VTKViewer_Actor*, bool update = false ); void RemoveActor( VTKViewer_Actor*, bool update = false); + virtual QString getVisualParameters(); + virtual void setVisualParameters( const QString& parameters ); + public slots: void onFrontView(); void onBackView(); diff --git a/src/VTKViewer/resources/VTKViewerM_msg_en.po b/src/VTKViewer/resources/VTKViewerM_msg_en.po index 7f2c72c31..d5e8cc22d 100644 --- a/src/VTKViewer/resources/VTKViewerM_msg_en.po +++ b/src/VTKViewer/resources/VTKViewerM_msg_en.po @@ -6,7 +6,6 @@ msgstr "" "Last-Translator: FULLNAME \n" "Content-Type: text/plain; charset=iso-8859-1\n" - #: SVTK_NonIsometricDlg.cxx msgid "SVTK_NonIsometricDlg::MEN_SCALING" -- 2.39.2