From: admin Date: Wed, 4 Feb 2009 21:29:45 +0000 (+0000) Subject: This commit was generated by cvs2git to create tag 'V5_1_0_for_TC1'. X-Git-Tag: V5_1_0_for_TC1 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=d548c549d3ce3b81ae9e9c13f900bbd7401b8101;p=modules%2Fgui.git This commit was generated by cvs2git to create tag 'V5_1_0_for_TC1'. Sprout from BR_V5_DEV 2008-11-01 11:07:41 UTC vsr 'Improve SALOME style handling' Cherrypick from BR_V5_DEV 2009-02-04 21:29:44 UTC prascle 'PR: add a mecanism to control the view closing': adm_local/cmake_files/FindCAS.cmake adm_local/cmake_files/FindGUI.cmake adm_local/cmake_files/FindOPENGL.cmake adm_local/cmake_files/FindQT4.cmake adm_local/cmake_files/FindQWT.cmake adm_local/cmake_files/FindSIPPYQT.cmake adm_local/cmake_files/FindVTK.cmake adm_local/cmake_files/Makefile.am build_cmake build_cmake.bat doc/salome/gui/images/directorypage.png doc/salome/gui/images/featureedgesprops.png doc/salome/gui/images/graduateaxes1.png doc/salome/gui/images/image100.png doc/salome/gui/images/image103.png doc/salome/gui/images/image106.png doc/salome/gui/images/image108.png doc/salome/gui/images/image72.png doc/salome/gui/images/image77.png doc/salome/gui/images/image86.png doc/salome/gui/images/image89.png doc/salome/gui/images/image91.png doc/salome/gui/images/image96.png doc/salome/gui/images/image97.png doc/salome/gui/images/image98.png doc/salome/gui/images/image99.png doc/salome/gui/images/installtypepage.png doc/salome/gui/images/mainmenu.png doc/salome/gui/images/notebook1.png doc/salome/gui/images/platformpage.png doc/salome/gui/images/plot2d_clone.png doc/salome/gui/images/plot2d_legend.png doc/salome/gui/images/plot2d_lines.png doc/salome/gui/images/plot2d_logarithmic_horizontal.png doc/salome/gui/images/plot2d_logarithmic_vertical.png doc/salome/gui/images/plot2d_points.png doc/salome/gui/images/plot2d_settings.png doc/salome/gui/images/plot2d_splines.png doc/salome/gui/images/productpage3.png doc/salome/gui/images/productpage4.png doc/salome/gui/images/progresspage2.png doc/salome/gui/images/studymanagement.png doc/salome/gui/images/theme1.png doc/salome/gui/images/theme2.png doc/salome/gui/images/viewmenu.png doc/salome/gui/images/windowmenu.png doc/salome/gui/input/text_user_interface.doc doc/salome/gui/input/themes.doc doc/salome/gui/input/using_notebook.doc src/Event/SALOME_EventFilter.cxx src/Event/SALOME_EventFilter.h src/QxScene/DebTrace.hxx src/QxScene/Makefile.am src/QxScene/QxScene.h src/QxScene/QxScene_Def.h src/QxScene/QxScene_ViewManager.cxx src/QxScene/QxScene_ViewManager.h src/QxScene/QxScene_ViewModel.cxx src/QxScene/QxScene_ViewModel.h src/QxScene/QxScene_ViewWindow.cxx src/QxScene/QxScene_ViewWindow.h src/QxScene/resources/QxSceneViewer_images.ts src/QxScene/resources/QxSceneViewer_msg_en.ts src/QxScene/resources/QxScene_images.po src/QxScene/resources/QxScene_msg_en.po src/QxScene/resources/qx_view_fitall.png src/QxScene/resources/qx_view_fitarea.png src/QxScene/resources/qx_view_glpan.png src/QxScene/resources/qx_view_pan.png src/QxScene/resources/qx_view_reset.png src/QxScene/resources/qx_view_zoom.png src/SalomeApp/SalomeApp_DoubleSpinBox.cxx src/SalomeApp/SalomeApp_DoubleSpinBox.h src/SalomeApp/SalomeApp_IntSpinBox.cxx src/SalomeApp/SalomeApp_IntSpinBox.h src/SalomeApp/SalomeApp_NoteBookDlg.cxx src/SalomeApp/SalomeApp_NoteBookDlg.h --- diff --git a/adm_local/cmake_files/FindCAS.cmake b/adm_local/cmake_files/FindCAS.cmake new file mode 100644 index 000000000..8490c7c66 --- /dev/null +++ b/adm_local/cmake_files/FindCAS.cmake @@ -0,0 +1,160 @@ +# Copyright (C) 2007-2008 CEA/DEN, EDF R&D, OPEN CASCADE +# +# Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, +# CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +# +# This library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public +# License as published by the Free Software Foundation; either +# version 2.1 of the License. +# +# This library is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public +# License along with this library; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +# +# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +# + +SET(CASROOT $ENV{CASROOT}) + +SET(OCC_VERSION_MAJOR 6) +SET(OCC_VERSION_MINOR 3) +SET(OCC_VERSION_MAINTENANCE 0) + +SET(CAS_CPPFLAGS) +SET(CAS_CPPFLAGS ${CAS_CPPFLAGS} -DOCC_VERSION_MAJOR=${OCC_VERSION_MAJOR}) +SET(CAS_CPPFLAGS ${CAS_CPPFLAGS} -DOCC_VERSION_MINOR=${OCC_VERSION_MINOR}) +SET(CAS_CPPFLAGS ${CAS_CPPFLAGS} -DOCC_VERSION_MAINTENANCE=${OCC_VERSION_MAINTENANCE}) +SET(CAS_CPPFLAGS ${CAS_CPPFLAGS} -DLIN -DLINTEL -DCSFDB) +SET(CAS_CPPFLAGS ${CAS_CPPFLAGS} -DNo_exception) +SET(CAS_CPPFLAGS ${CAS_CPPFLAGS} -DHAVE_CONFIG_H) +SET(CAS_CPPFLAGS ${CAS_CPPFLAGS} -DHAVE_LIMITS_H) +SET(CAS_CPPFLAGS ${CAS_CPPFLAGS} -I${CASROOT}/inc) + +IF(WINDOWS) + SET(CASROOT_LIBDIR ${CASROOT}/win32/libd) +ELSE(WINDOWS) + SET(CASROOT_LIBDIR ${CASROOT}/lib) +ENDIF(WINDOWS) + +FIND_LIBRARY(BinLPlugin BinLPlugin PATHS ${CASROOT_LIBDIR}) +FIND_LIBRARY(BinPlugin BinPlugin PATHS ${CASROOT_LIBDIR}) +FIND_LIBRARY(BinTObjPlugin BinTObjPlugin PATHS ${CASROOT_LIBDIR}) +FIND_LIBRARY(BinXCAFPlugin BinXCAFPlugin PATHS ${CASROOT_LIBDIR}) +FIND_LIBRARY(FWOSPlugin FWOSPlugin PATHS ${CASROOT_LIBDIR}) +# FIND_LIBRARY(mscmd mscmd PATHS ${CASROOT_LIBDIR}) +FIND_LIBRARY(PTKernel PTKernel PATHS ${CASROOT_LIBDIR}) +FIND_LIBRARY(StdLPlugin StdLPlugin PATHS ${CASROOT_LIBDIR}) +FIND_LIBRARY(StdPlugin StdPlugin PATHS ${CASROOT_LIBDIR}) +FIND_LIBRARY(TKAdvTools TKAdvTools PATHS ${CASROOT_LIBDIR}) +FIND_LIBRARY(TKBin TKBin PATHS ${CASROOT_LIBDIR}) +FIND_LIBRARY(TKBinL TKBinL PATHS ${CASROOT_LIBDIR}) +FIND_LIBRARY(TKBinTObj TKBinTObj PATHS ${CASROOT_LIBDIR}) +FIND_LIBRARY(TKBinXCAF TKBinXCAF PATHS ${CASROOT_LIBDIR}) +FIND_LIBRARY(TKBO TKBO PATHS ${CASROOT_LIBDIR}) +FIND_LIBRARY(TKBool TKBool PATHS ${CASROOT_LIBDIR}) +FIND_LIBRARY(TKBRep TKBRep PATHS ${CASROOT_LIBDIR}) +FIND_LIBRARY(TKCAF TKCAF PATHS ${CASROOT_LIBDIR}) +FIND_LIBRARY(TKCDF TKCDF PATHS ${CASROOT_LIBDIR}) +# FIND_LIBRARY(TKCDLFront TKCDLFront PATHS ${CASROOT_LIBDIR}) +# FIND_LIBRARY(TKCPPClient TKCPPClient PATHS ${CASROOT_LIBDIR}) +# FIND_LIBRARY(TKCPPExt TKCPPExt PATHS ${CASROOT_LIBDIR}) +# FIND_LIBRARY(TKCPPIntExt TKCPPIntExt PATHS ${CASROOT_LIBDIR}) +# FIND_LIBRARY(TKCPPJini TKCPPJini PATHS ${CASROOT_LIBDIR}) +# FIND_LIBRARY(TKCSFDBSchema TKCSFDBSchema PATHS ${CASROOT_LIBDIR}) +# FIND_LIBRARY(TKDCAF TKDCAF PATHS ${CASROOT_LIBDIR}) +# FIND_LIBRARY(TKDraw TKDraw PATHS ${CASROOT_LIBDIR}) +FIND_LIBRARY(TKernel TKernel PATHS ${CASROOT_LIBDIR}) +FIND_LIBRARY(TKFeat TKFeat PATHS ${CASROOT_LIBDIR}) +FIND_LIBRARY(TKFillet TKFillet PATHS ${CASROOT_LIBDIR}) +FIND_LIBRARY(TKG2d TKG2d PATHS ${CASROOT_LIBDIR}) +FIND_LIBRARY(TKG3d TKG3d PATHS ${CASROOT_LIBDIR}) +FIND_LIBRARY(TKGeomAlgo TKGeomAlgo PATHS ${CASROOT_LIBDIR}) +FIND_LIBRARY(TKGeomBase TKGeomBase PATHS ${CASROOT_LIBDIR}) +FIND_LIBRARY(TKHLR TKHLR PATHS ${CASROOT_LIBDIR}) +# FIND_LIBRARY(TKIDLFront TKIDLFront PATHS ${CASROOT_LIBDIR}) +FIND_LIBRARY(TKIGES TKIGES PATHS ${CASROOT_LIBDIR}) +FIND_LIBRARY(TKLCAF TKLCAF PATHS ${CASROOT_LIBDIR}) +FIND_LIBRARY(TKMath TKMath PATHS ${CASROOT_LIBDIR}) +FIND_LIBRARY(TKMesh TKMesh PATHS ${CASROOT_LIBDIR}) +FIND_LIBRARY(TKMeshVS TKMeshVS PATHS ${CASROOT_LIBDIR}) +FIND_LIBRARY(TKNIS TKNIS PATHS ${CASROOT_LIBDIR}) +FIND_LIBRARY(TKOffset TKOffset PATHS ${CASROOT_LIBDIR}) +FIND_LIBRARY(TKOpenGl TKOpenGl PATHS ${CASROOT_LIBDIR}) +FIND_LIBRARY(TKPCAF TKPCAF PATHS ${CASROOT_LIBDIR}) +FIND_LIBRARY(TKPLCAF TKPLCAF PATHS ${CASROOT_LIBDIR}) +FIND_LIBRARY(TKPrim TKPrim PATHS ${CASROOT_LIBDIR}) +FIND_LIBRARY(TKPShape TKPShape PATHS ${CASROOT_LIBDIR}) +FIND_LIBRARY(TKService TKService PATHS ${CASROOT_LIBDIR}) +FIND_LIBRARY(TKShapeSchema TKShapeSchema PATHS ${CASROOT_LIBDIR}) +FIND_LIBRARY(TKShHealing TKShHealing PATHS ${CASROOT_LIBDIR}) +FIND_LIBRARY(TKStdLSchema TKStdLSchema PATHS ${CASROOT_LIBDIR}) +FIND_LIBRARY(TKStdSchema TKStdSchema PATHS ${CASROOT_LIBDIR}) +FIND_LIBRARY(TKSTEP TKSTEP PATHS ${CASROOT_LIBDIR}) +FIND_LIBRARY(TKSTEP209 TKSTEP209 PATHS ${CASROOT_LIBDIR}) +FIND_LIBRARY(TKSTEPAttr TKSTEPAttr PATHS ${CASROOT_LIBDIR}) +FIND_LIBRARY(TKSTEPBase TKSTEPBase PATHS ${CASROOT_LIBDIR}) +FIND_LIBRARY(TKSTL TKSTL PATHS ${CASROOT_LIBDIR}) +# FIND_LIBRARY(TKTCPPExt TKTCPPExt PATHS ${CASROOT_LIBDIR}) +FIND_LIBRARY(TKTObj TKTObj PATHS ${CASROOT_LIBDIR}) +# FIND_LIBRARY(TKTObjDRAW TKTObjDRAW PATHS ${CASROOT_LIBDIR}) +FIND_LIBRARY(TKTopAlgo TKTopAlgo PATHS ${CASROOT_LIBDIR}) +# FIND_LIBRARY(TKTopTest TKTopTest PATHS ${CASROOT_LIBDIR}) +FIND_LIBRARY(TKV2d TKV2d PATHS ${CASROOT_LIBDIR}) +FIND_LIBRARY(TKV3d TKV3d PATHS ${CASROOT_LIBDIR}) +# FIND_LIBRARY(TKViewerTest TKViewerTest PATHS ${CASROOT_LIBDIR}) +FIND_LIBRARY(TKVRML TKVRML PATHS ${CASROOT_LIBDIR}) +# FIND_LIBRARY(TKWOK TKWOK PATHS ${CASROOT_LIBDIR}) +# FIND_LIBRARY(TKWOKTcl TKWOKTcl PATHS ${CASROOT_LIBDIR}) +FIND_LIBRARY(TKXCAF TKXCAF PATHS ${CASROOT_LIBDIR}) +FIND_LIBRARY(TKXCAFSchema TKXCAFSchema PATHS ${CASROOT_LIBDIR}) +# FIND_LIBRARY(TKXDEDRAW TKXDEDRAW PATHS ${CASROOT_LIBDIR}) +FIND_LIBRARY(TKXDEIGES TKXDEIGES PATHS ${CASROOT_LIBDIR}) +FIND_LIBRARY(TKXDESTEP TKXDESTEP PATHS ${CASROOT_LIBDIR}) +FIND_LIBRARY(TKXMesh TKXMesh PATHS ${CASROOT_LIBDIR}) +FIND_LIBRARY(TKXml TKXml PATHS ${CASROOT_LIBDIR}) +FIND_LIBRARY(TKXmlL TKXmlL PATHS ${CASROOT_LIBDIR}) +FIND_LIBRARY(TKXmlTObj TKXmlTObj PATHS ${CASROOT_LIBDIR}) +FIND_LIBRARY(TKXmlXCAF TKXmlXCAF PATHS ${CASROOT_LIBDIR}) +FIND_LIBRARY(TKXSBase TKXSBase PATHS ${CASROOT_LIBDIR}) +# FIND_LIBRARY(TKXSDRAW TKXSDRAW PATHS ${CASROOT_LIBDIR}) +# FIND_LIBRARY(wokcmd wokcmd PATHS ${CASROOT_LIBDIR}) +# FIND_LIBRARY(wokdeliverysteps wokdeliverysteps PATHS ${CASROOT_LIBDIR}) +# FIND_LIBRARY(wokdfltsteps wokdfltsteps PATHS ${CASROOT_LIBDIR}) +# FIND_LIBRARY(wokobjssteps wokobjssteps PATHS ${CASROOT_LIBDIR}) +# FIND_LIBRARY(wokorbixsteps wokorbixsteps PATHS ${CASROOT_LIBDIR}) +# FIND_LIBRARY(woksteps woksteps PATHS ${CASROOT_LIBDIR}) +# FIND_LIBRARY(woktoolscmd woktoolscmd PATHS ${CASROOT_LIBDIR}) +# FIND_LIBRARY(wokutilscmd wokutilscmd PATHS ${CASROOT_LIBDIR}) +FIND_LIBRARY(XCAFPlugin XCAFPlugin PATHS ${CASROOT_LIBDIR}) +FIND_LIBRARY(XmlLPlugin XmlLPlugin PATHS ${CASROOT_LIBDIR}) +FIND_LIBRARY(XmlPlugin XmlPlugin PATHS ${CASROOT_LIBDIR}) +FIND_LIBRARY(XmlTObjPlugin XmlTObjPlugin PATHS ${CASROOT_LIBDIR}) +FIND_LIBRARY(XmlXCAFPlugin XmlXCAFPlugin PATHS ${CASROOT_LIBDIR}) + +SET(CAS_KERNEL ${TKernel} ${TKMath}) +SET(CAS_OCAF ${TKernel} ${TKMath} ${TKCDF} ${TKLCAF}) +SET(CAS_VIEWER ${TKService} ${TKV3d} ${TKG3d} ${TKGeomBase} ${TKBRep}) +SET(CAS_OCAFVIS ${TKCAF} ${TKBRep} ${TKG2d}) +SET(CAS_MODELER ${TKG3d} ${TKGeomBase} ${TKGeomAlgo} ${TKBRep} ${TKTopAlgo} ${TKG2d}) + +SET(TKV3d_EA ${TKernel} ${TKMath} ${TKV3d}) +SET(TKBool_EA ${TKernel} ${TKMath} ${TKBRep} ${TKG2d} ${TKG3d} ${TKGeomBase} ${TKGeomAlgo} ${TKTopAlgo} ${TKBool}) +SET(TKBRep_EA ${TKernel} ${TKMath} ${TKBRep}) +SET(TKIGES_EA ${TKernel} ${TKMath} ${TKXSBase} ${TKBRep} ${TKIGES}) +SET(TKSTEP_EA ${TKernel} ${TKMath} ${TKXSBase} ${TKBRep} ${TKSTEP}) +SET(TKSTL_EA ${TKernel} ${TKMath} ${TKSTL}) +SET(TKCAF_EA ${TKPrim} ${TKCAF}) + +SET(TKV3d ${TKV3d_EA}) +SET(TKBool ${TKBool_EA}) +SET(TKBRep ${TKBRep_EA}) +SET(TKIGES ${TKIGES_EA}) +SET(TKSTEP ${TKSTEP_EA}) +SET(TKSTL ${TKSTL_EA}) +SET(TKCAF ${TKCAF_EA}) diff --git a/adm_local/cmake_files/FindGUI.cmake b/adm_local/cmake_files/FindGUI.cmake new file mode 100644 index 000000000..14ca37915 --- /dev/null +++ b/adm_local/cmake_files/FindGUI.cmake @@ -0,0 +1,55 @@ +# Copyright (C) 2007-2008 CEA/DEN, EDF R&D, OPEN CASCADE +# +# Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, +# CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +# +# This library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public +# License as published by the Free Software Foundation; either +# version 2.1 of the License. +# +# This library is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public +# License along with this library; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +# +# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +# + +SET(GUI_CXXFLAGS -I${GUI_ROOT_DIR}/include/salome) + +FIND_LIBRARY(caf caf ${GUI_ROOT_DIR}/lib/salome) +FIND_LIBRARY(CAM CAM ${GUI_ROOT_DIR}/lib/salome) +FIND_LIBRARY(CASCatch CASCatch ${GUI_ROOT_DIR}/lib/salome) +FIND_LIBRARY(DDS DDS ${GUI_ROOT_DIR}/lib/salome) +FIND_LIBRARY(Event Event ${GUI_ROOT_DIR}/lib/salome) +FIND_LIBRARY(GLViewer GLViewer ${GUI_ROOT_DIR}/lib/salome) +FIND_LIBRARY(LightApp LightApp ${GUI_ROOT_DIR}/lib/salome) +FIND_LIBRARY(LogWindow LogWindow ${GUI_ROOT_DIR}/lib/salome) +FIND_LIBRARY(ObjBrowser ObjBrowser ${GUI_ROOT_DIR}/lib/salome) +FIND_LIBRARY(OCCViewer OCCViewer ${GUI_ROOT_DIR}/lib/salome) +FIND_LIBRARY(Plot2d Plot2d ${GUI_ROOT_DIR}/lib/salome) +FIND_LIBRARY(PyConsole PyConsole ${GUI_ROOT_DIR}/lib/salome) +FIND_LIBRARY(PyInterp PyInterp ${GUI_ROOT_DIR}/lib/salome) +FIND_LIBRARY(QDS QDS ${GUI_ROOT_DIR}/lib/salome) +FIND_LIBRARY(qtx qtx ${GUI_ROOT_DIR}/lib/salome) +FIND_LIBRARY(QxScene QxScene ${GUI_ROOT_DIR}/lib/salome) +FIND_LIBRARY(SalomeApp SalomeApp ${GUI_ROOT_DIR}/lib/salome) +FIND_LIBRARY(SalomeIDLGUI SalomeIDLGUI ${GUI_ROOT_DIR}/lib/salome) +FIND_LIBRARY(SalomeObject SalomeObject ${GUI_ROOT_DIR}/lib/salome) +FIND_LIBRARY(SalomePrs SalomePrs ${GUI_ROOT_DIR}/lib/salome) +FIND_LIBRARY(SalomeSession SalomeSession ${GUI_ROOT_DIR}/lib/salome) +FIND_LIBRARY(SalomeStyle SalomeStyle ${GUI_ROOT_DIR}/lib/salome) +FIND_LIBRARY(SOCC SOCC ${GUI_ROOT_DIR}/lib/salome) +FIND_LIBRARY(SPlot2d SPlot2d ${GUI_ROOT_DIR}/lib/salome) +FIND_LIBRARY(std std ${GUI_ROOT_DIR}/lib/salome) +FIND_LIBRARY(SUITApp SUITApp ${GUI_ROOT_DIR}/lib/salome) +FIND_LIBRARY(suit suit ${GUI_ROOT_DIR}/lib/salome) +FIND_LIBRARY(SUPERVGraph SUPERVGraph ${GUI_ROOT_DIR}/lib/salome) +FIND_LIBRARY(SVTK SVTK ${GUI_ROOT_DIR}/lib/salome) +FIND_LIBRARY(ToolsGUI ToolsGUI ${GUI_ROOT_DIR}/lib/salome) +FIND_LIBRARY(VTKViewer VTKViewer ${GUI_ROOT_DIR}/lib/salome) diff --git a/adm_local/cmake_files/FindOPENGL.cmake b/adm_local/cmake_files/FindOPENGL.cmake new file mode 100644 index 000000000..14584056e --- /dev/null +++ b/adm_local/cmake_files/FindOPENGL.cmake @@ -0,0 +1,27 @@ +# Copyright (C) 2007-2008 CEA/DEN, EDF R&D, OPEN CASCADE +# +# Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, +# CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +# +# This library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public +# License as published by the Free Software Foundation; either +# version 2.1 of the License. +# +# This library is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public +# License along with this library; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +# +# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +# + +IF(${WINDOWS}) + FIND_LIBRARY(OpenGL_LIB OpenGL32 "C:/Program Files/Microsoft SDKs/Windows/v6.0A/lib") + FIND_LIBRARY(GlU_LIB GlU32 "C:/Program Files/Microsoft SDKs/Windows/v6.0A/lib") + SET(OGL_LIBS ${OpenGL_LIB} ${GlU_LIB}) +ENDIF(${WINDOWS}) diff --git a/adm_local/cmake_files/FindQT4.cmake b/adm_local/cmake_files/FindQT4.cmake new file mode 100644 index 000000000..6b98c5f31 --- /dev/null +++ b/adm_local/cmake_files/FindQT4.cmake @@ -0,0 +1,33 @@ +# Copyright (C) 2007-2008 CEA/DEN, EDF R&D, OPEN CASCADE +# +# Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, +# CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +# +# This library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public +# License as published by the Free Software Foundation; either +# version 2.1 of the License. +# +# This library is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public +# License along with this library; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +# +# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +# + +INCLUDE(FindQt4) +INCLUDE(UseQt4) +SET(DIRS) +FOREACH(D ${QT_INCLUDES}) +SET(DIRS ${DIRS} -I${D}) +ENDFOREACH(D ${QT_INCLUDES}) +SET(QT_INCLUDES ${DIRS}) +SET(QT_INCLUDES ${QT_INCLUDES} -DQT_THREAD_SUPPORT) +SET(QT_MT_LIBS ${QT_LIBRARIES} ${QT_QTXML_LIBRARY} ${QT_QTOPENGL_LIBRARY}) + +FIND_PROGRAM(QT_LRELEASE_EXECUTABLE lrelease) diff --git a/adm_local/cmake_files/FindQWT.cmake b/adm_local/cmake_files/FindQWT.cmake new file mode 100644 index 000000000..ea5f11dd8 --- /dev/null +++ b/adm_local/cmake_files/FindQWT.cmake @@ -0,0 +1,33 @@ +# Copyright (C) 2007-2008 CEA/DEN, EDF R&D, OPEN CASCADE +# +# Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, +# CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +# +# This library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public +# License as published by the Free Software Foundation; either +# version 2.1 of the License. +# +# This library is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public +# License along with this library; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +# +# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +# + +SET(QWTHOME $ENV{QWTHOME}) +FIND_PATH(QWT_INCLUDE_DIR qwt_plot.h ${QWTHOME}/include) +SET(QWT_INCLUDES -I${QWT_INCLUDE_DIR}) +IF(WINDOWS) +SET(QWT_INCLUDES ${QWT_INCLUDES} -DQWT_DLL) +ENDIF(WINDOWS) +IF(WINDOWS) +FIND_LIBRARY(QWT_LIBS qwt5 ${QWTHOME}/lib) +ELSE(WINDOWS) +FIND_LIBRARY(QWT_LIBS qwt ${QWTHOME}/lib) +ENDIF(WINDOWS) diff --git a/adm_local/cmake_files/FindSIPPYQT.cmake b/adm_local/cmake_files/FindSIPPYQT.cmake new file mode 100644 index 000000000..1f4ff9503 --- /dev/null +++ b/adm_local/cmake_files/FindSIPPYQT.cmake @@ -0,0 +1,55 @@ +# Copyright (C) 2007-2008 CEA/DEN, EDF R&D, OPEN CASCADE +# +# Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, +# CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +# +# This library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public +# License as published by the Free Software Foundation; either +# version 2.1 of the License. +# +# This library is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public +# License along with this library; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +# +# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +# + +FIND_PROGRAM(SIP_EXECUTABLE sip) + +SET(SIP_ROOT ${SIP_EXECUTABLE}) +IF(SIP_ROOT) +GET_FILENAME_COMPONENT(SIP_ROOT ${SIP_ROOT} PATH) +GET_FILENAME_COMPONENT(SIP_ROOT ${SIP_ROOT} PATH) +ENDIF(SIP_ROOT) + +SET(SIP_INCLUDES -I${SIP_ROOT}/include/python${PYTHON_VERSION}) + +FIND_PROGRAM(PYUIC_EXECUTABLE pyuic4) + +SET(PYUIC_ROOT ${PYUIC_EXECUTABLE}) +IF(PYUIC_ROOT) +GET_FILENAME_COMPONENT(PYUIC_ROOT ${PYUIC_ROOT} PATH) +GET_FILENAME_COMPONENT(PYUIC_ROOT ${PYUIC_ROOT} PATH) +ENDIF(PYUIC_ROOT) + +IF(WINDOWS) + SET(PYQT_SIPS ${PYUIC_ROOT}/sip) +ELSE(WINDOWS) + SET(PYQT_SIPS ${PYUIC_ROOT}/share/sip) +ENDIF(WINDOWS) + +SET(PYQT_INCLUDES -I${PYQT_SIPS}) +SET(PYQT_INCLUDES ${PYQT_INCLUDES} -I${PYQT_SIPS}/QtCore -I${PYQT_SIPS}/QtGui) +SET(PYQT_INCLUDES ${PYQT_INCLUDES} -I${PYQT_SIPS}/QtXml -I${PYQT_SIPS}/QtOpenGL) +SET(PYQT_INCLUDES ${PYQT_INCLUDES} -I${PYQT_SIPS}/QtAssistant -I${PYQT_SIPS}/QtDesigner) +SET(PYQT_INCLUDES ${PYQT_INCLUDES} -I${PYQT_SIPS}/QtNetwork -I${PYQT_SIPS}/QtSql) +SET(PYQT_INCLUDES ${PYQT_INCLUDES} -I${PYQT_SIPS}/QtSvg -I${PYQT_SIPS}/QtTest) + +SET(PYQT_SIPFLAGS -x VendorID -x PyQt_NoPrintRangeBug -t WS_X11 -t Qt_4_4_1 -g -s .cc -c .) +SET(PYQT_SIPFLAGS ${PYQT_SIPFLAGS} ${PYQT_INCLUDES}) diff --git a/adm_local/cmake_files/FindVTK.cmake b/adm_local/cmake_files/FindVTK.cmake new file mode 100644 index 000000000..550256c72 --- /dev/null +++ b/adm_local/cmake_files/FindVTK.cmake @@ -0,0 +1,48 @@ +# Copyright (C) 2007-2008 CEA/DEN, EDF R&D, OPEN CASCADE +# +# Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, +# CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +# +# This library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public +# License as published by the Free Software Foundation; either +# version 2.1 of the License. +# +# This library is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public +# License along with this library; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +# +# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +# + +INCLUDE(FindVTK) + +SET(VTK_INCLUDES) +FOREACH(dir ${VTK_INCLUDE_DIRS}) + SET(VTK_INCLUDES ${VTK_INCLUDES} -I${dir}) +ENDFOREACH(dir ${VTK_INCLUDE_DIRS}) + +SET(VTK_LIBS) +FIND_LIBRARY(VTK_COMMON vtkCommon ${VTK_LIBRARY_DIRS}) +SET(VTK_LIBS ${VTK_LIBS} ${VTK_COMMON}) +FIND_LIBRARY(VTK_GRAPHICS vtkGraphics ${VTK_LIBRARY_DIRS}) +SET(VTK_LIBS ${VTK_LIBS} ${VTK_GRAPHICS}) +FIND_LIBRARY(VTK_IMAGING vtkImaging ${VTK_LIBRARY_DIRS}) +SET(VTK_LIBS ${VTK_LIBS} ${VTK_IMAGING}) +FIND_LIBRARY(VTK_FILTERING vtkFiltering ${VTK_LIBRARY_DIRS}) +SET(VTK_LIBS ${VTK_LIBS} ${VTK_FILTERING}) +FIND_LIBRARY(VTK_IO vtkIO ${VTK_LIBRARY_DIRS}) +SET(VTK_LIBS ${VTK_LIBS} ${VTK_IO}) +FIND_LIBRARY(VTK_RENDERING vtkRendering ${VTK_LIBRARY_DIRS}) +SET(VTK_LIBS ${VTK_LIBS} ${VTK_RENDERING}) +FIND_LIBRARY(VTK_HYBRID vtkHybrid ${VTK_LIBRARY_DIRS}) +SET(VTK_LIBS ${VTK_LIBS} ${VTK_HYBRID}) +FIND_LIBRARY(VTK_PARALLEL vtkParallel ${VTK_LIBRARY_DIRS}) +SET(VTK_LIBS ${VTK_LIBS} ${VTK_PARALLEL}) +FIND_LIBRARY(VTK_WIDGETS vtkWidgets ${VTK_LIBRARY_DIRS}) +SET(VTK_LIBS ${VTK_LIBS} ${VTK_WIDGETS}) diff --git a/adm_local/cmake_files/Makefile.am b/adm_local/cmake_files/Makefile.am new file mode 100644 index 000000000..d94ed4ebf --- /dev/null +++ b/adm_local/cmake_files/Makefile.am @@ -0,0 +1,32 @@ +# Copyright (C) 2007-2008 CEA/DEN, EDF R&D, OPEN CASCADE +# +# Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, +# CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +# +# This library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public +# License as published by the Free Software Foundation; either +# version 2.1 of the License. +# +# This library is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public +# License along with this library; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +# +# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +# +include $(top_srcdir)/adm_local/unix/make_common_starter.am + +dist_admlocal_cmake_DATA = \ +FindCAS.cmake \ +FindOPENGL.cmake \ +FindQT4.cmake \ +FindQWT.cmake \ +FindSIPPYQT.cmake \ +FindVTK.cmake \ +FindGUI.cmake + diff --git a/build_cmake b/build_cmake new file mode 100755 index 000000000..844a4f2c4 --- /dev/null +++ b/build_cmake @@ -0,0 +1,30 @@ +#!/bin/sh +# Copyright (C) 2007-2008 CEA/DEN, EDF R&D, OPEN CASCADE +# +# Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, +# CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +# +# This library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public +# License as published by the Free Software Foundation; either +# version 2.1 of the License. +# +# This library is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public +# License along with this library; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +# +# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +# + +CURRENT_DIR=`pwd` +CONF_DIR=`echo $0 | sed -e "s,[^/]*$,,;s,/$,,;s,^$,.,"` +cd ${CONF_DIR} +python $KERNEL_ROOT_DIR/salome_adm/cmake_files/am2cmake.py --gui +status=$? +cd ${CURRENT_DIR} +exit $status diff --git a/build_cmake.bat b/build_cmake.bat new file mode 100644 index 000000000..58a10b0a3 --- /dev/null +++ b/build_cmake.bat @@ -0,0 +1,2 @@ + +%PYTHONBIN% %KERNEL_ROOT_DIR%\salome_adm\cmake_files\am2cmake.py --gui diff --git a/doc/salome/gui/images/directorypage.png b/doc/salome/gui/images/directorypage.png new file mode 100755 index 000000000..fafc98936 Binary files /dev/null and b/doc/salome/gui/images/directorypage.png differ diff --git a/doc/salome/gui/images/featureedgesprops.png b/doc/salome/gui/images/featureedgesprops.png new file mode 100755 index 000000000..4a41a1aac Binary files /dev/null and b/doc/salome/gui/images/featureedgesprops.png differ diff --git a/doc/salome/gui/images/graduateaxes1.png b/doc/salome/gui/images/graduateaxes1.png new file mode 100755 index 000000000..9d2b1975a Binary files /dev/null and b/doc/salome/gui/images/graduateaxes1.png differ diff --git a/doc/salome/gui/images/image100.png b/doc/salome/gui/images/image100.png new file mode 100755 index 000000000..ec56cacc7 Binary files /dev/null and b/doc/salome/gui/images/image100.png differ diff --git a/doc/salome/gui/images/image103.png b/doc/salome/gui/images/image103.png new file mode 100755 index 000000000..b02616f29 Binary files /dev/null and b/doc/salome/gui/images/image103.png differ diff --git a/doc/salome/gui/images/image106.png b/doc/salome/gui/images/image106.png new file mode 100755 index 000000000..0356a9a31 Binary files /dev/null and b/doc/salome/gui/images/image106.png differ diff --git a/doc/salome/gui/images/image108.png b/doc/salome/gui/images/image108.png new file mode 100755 index 000000000..fa8cbbc71 Binary files /dev/null and b/doc/salome/gui/images/image108.png differ diff --git a/doc/salome/gui/images/image72.png b/doc/salome/gui/images/image72.png new file mode 100755 index 000000000..4364ce7fe Binary files /dev/null and b/doc/salome/gui/images/image72.png differ diff --git a/doc/salome/gui/images/image77.png b/doc/salome/gui/images/image77.png new file mode 100755 index 000000000..441482d20 Binary files /dev/null and b/doc/salome/gui/images/image77.png differ diff --git a/doc/salome/gui/images/image86.png b/doc/salome/gui/images/image86.png new file mode 100755 index 000000000..441482d20 Binary files /dev/null and b/doc/salome/gui/images/image86.png differ diff --git a/doc/salome/gui/images/image89.png b/doc/salome/gui/images/image89.png new file mode 100755 index 000000000..28ec89f03 Binary files /dev/null and b/doc/salome/gui/images/image89.png differ diff --git a/doc/salome/gui/images/image91.png b/doc/salome/gui/images/image91.png new file mode 100755 index 000000000..66f81e604 Binary files /dev/null and b/doc/salome/gui/images/image91.png differ diff --git a/doc/salome/gui/images/image96.png b/doc/salome/gui/images/image96.png new file mode 100755 index 000000000..87e001dd8 Binary files /dev/null and b/doc/salome/gui/images/image96.png differ diff --git a/doc/salome/gui/images/image97.png b/doc/salome/gui/images/image97.png new file mode 100755 index 000000000..450dc56c6 Binary files /dev/null and b/doc/salome/gui/images/image97.png differ diff --git a/doc/salome/gui/images/image98.png b/doc/salome/gui/images/image98.png new file mode 100755 index 000000000..87e001dd8 Binary files /dev/null and b/doc/salome/gui/images/image98.png differ diff --git a/doc/salome/gui/images/image99.png b/doc/salome/gui/images/image99.png new file mode 100755 index 000000000..ec56cacc7 Binary files /dev/null and b/doc/salome/gui/images/image99.png differ diff --git a/doc/salome/gui/images/installtypepage.png b/doc/salome/gui/images/installtypepage.png new file mode 100755 index 000000000..8359d54c0 Binary files /dev/null and b/doc/salome/gui/images/installtypepage.png differ diff --git a/doc/salome/gui/images/mainmenu.png b/doc/salome/gui/images/mainmenu.png new file mode 100755 index 000000000..5ee5a3ef5 Binary files /dev/null and b/doc/salome/gui/images/mainmenu.png differ diff --git a/doc/salome/gui/images/notebook1.png b/doc/salome/gui/images/notebook1.png new file mode 100644 index 000000000..a984085cc Binary files /dev/null and b/doc/salome/gui/images/notebook1.png differ diff --git a/doc/salome/gui/images/platformpage.png b/doc/salome/gui/images/platformpage.png new file mode 100755 index 000000000..cfbf60c3c Binary files /dev/null and b/doc/salome/gui/images/platformpage.png differ diff --git a/doc/salome/gui/images/plot2d_clone.png b/doc/salome/gui/images/plot2d_clone.png new file mode 100755 index 000000000..441482d20 Binary files /dev/null and b/doc/salome/gui/images/plot2d_clone.png differ diff --git a/doc/salome/gui/images/plot2d_legend.png b/doc/salome/gui/images/plot2d_legend.png new file mode 100755 index 000000000..81c06277b Binary files /dev/null and b/doc/salome/gui/images/plot2d_legend.png differ diff --git a/doc/salome/gui/images/plot2d_lines.png b/doc/salome/gui/images/plot2d_lines.png new file mode 100755 index 000000000..978945284 Binary files /dev/null and b/doc/salome/gui/images/plot2d_lines.png differ diff --git a/doc/salome/gui/images/plot2d_logarithmic_horizontal.png b/doc/salome/gui/images/plot2d_logarithmic_horizontal.png new file mode 100755 index 000000000..fb62cd772 Binary files /dev/null and b/doc/salome/gui/images/plot2d_logarithmic_horizontal.png differ diff --git a/doc/salome/gui/images/plot2d_logarithmic_vertical.png b/doc/salome/gui/images/plot2d_logarithmic_vertical.png new file mode 100755 index 000000000..825d59edb Binary files /dev/null and b/doc/salome/gui/images/plot2d_logarithmic_vertical.png differ diff --git a/doc/salome/gui/images/plot2d_points.png b/doc/salome/gui/images/plot2d_points.png new file mode 100755 index 000000000..3cdea33dd Binary files /dev/null and b/doc/salome/gui/images/plot2d_points.png differ diff --git a/doc/salome/gui/images/plot2d_settings.png b/doc/salome/gui/images/plot2d_settings.png new file mode 100755 index 000000000..64df2460b Binary files /dev/null and b/doc/salome/gui/images/plot2d_settings.png differ diff --git a/doc/salome/gui/images/plot2d_splines.png b/doc/salome/gui/images/plot2d_splines.png new file mode 100755 index 000000000..06a95572d Binary files /dev/null and b/doc/salome/gui/images/plot2d_splines.png differ diff --git a/doc/salome/gui/images/productpage3.png b/doc/salome/gui/images/productpage3.png new file mode 100755 index 000000000..7c2db8b20 Binary files /dev/null and b/doc/salome/gui/images/productpage3.png differ diff --git a/doc/salome/gui/images/productpage4.png b/doc/salome/gui/images/productpage4.png new file mode 100755 index 000000000..9f0de3675 Binary files /dev/null and b/doc/salome/gui/images/productpage4.png differ diff --git a/doc/salome/gui/images/progresspage2.png b/doc/salome/gui/images/progresspage2.png new file mode 100755 index 000000000..c2aad1f87 Binary files /dev/null and b/doc/salome/gui/images/progresspage2.png differ diff --git a/doc/salome/gui/images/studymanagement.png b/doc/salome/gui/images/studymanagement.png new file mode 100755 index 000000000..f6b20973d Binary files /dev/null and b/doc/salome/gui/images/studymanagement.png differ diff --git a/doc/salome/gui/images/theme1.png b/doc/salome/gui/images/theme1.png new file mode 100755 index 000000000..91d4d303f Binary files /dev/null and b/doc/salome/gui/images/theme1.png differ diff --git a/doc/salome/gui/images/theme2.png b/doc/salome/gui/images/theme2.png new file mode 100755 index 000000000..92190937f Binary files /dev/null and b/doc/salome/gui/images/theme2.png differ diff --git a/doc/salome/gui/images/viewmenu.png b/doc/salome/gui/images/viewmenu.png new file mode 100755 index 000000000..a188e6de1 Binary files /dev/null and b/doc/salome/gui/images/viewmenu.png differ diff --git a/doc/salome/gui/images/windowmenu.png b/doc/salome/gui/images/windowmenu.png new file mode 100755 index 000000000..6e47ee86a Binary files /dev/null and b/doc/salome/gui/images/windowmenu.png differ diff --git a/doc/salome/gui/input/text_user_interface.doc b/doc/salome/gui/input/text_user_interface.doc new file mode 100644 index 000000000..ac0bc5614 --- /dev/null +++ b/doc/salome/gui/input/text_user_interface.doc @@ -0,0 +1,370 @@ +/*! + +\page tui_page Using salome.py module + +The Python module salome.py provides a functionality to access main +SALOME features from the Python console (either embedded in GUI +desktop or external one). + +To use salome.py module, import it into the Python interpreter and +initialize it by calling \c salome_init() function: + +\code +import salome +salome.salome_init() +\endcode + +The salome.py Python module provides a set of variables and functions +allowing access to different elements of the current SALOME +session (this Python interpreter is connected to). +This page gives a short description of most useful variables and +functions. + +\li \b orb Reference to the CORBA::ORB instance + +This variable can be used to initialize different CORBA-related +elements of the SALOME session (for example, naming service, etc). +For example, to get an access to the SALOME naming service, you can +use the following commands: +\code +import SALOME_NamingServicePy +NS = SALOME_NamingServicePy.SALOME_NamingServicePy_i(salome.orb) +\endcode + +The \b orb variable is also useful when it is necessary to convert +CORBA reference object to its string representation (IOR) and vice +versa: +\code +studyIOR = salome.orb.object_to_string(salome.myStudy) +study = salome.orb.string_to_object(studyIOR) +is_same = salome.myStudy._is_equivalent(study) # is_same = True +\endcode + +\li \b naming_service SALOME naming service instance + +This variable can be used to register/find objects created in a +distributed environment. For example, to get access to the SALOME +Module Catalog server, use \c Resolve() method: +\code +import SALOME_ModuleCatalog +mc = salome.naming_service.Resolve('/Kernel/ModulCatalog') +\endcode + +Similarly, method \c Register() can be used to register objects +in the naming service: +\code +salome.naming_service.Register(myObject,'/My/Object/Path') +o = salome.naming_service.Resolve('/My/Object/Path') +is_same = myObject._is_equivalent(o) # is_same = True +\endcode + +\li \b lcc Life Cycle CORBA class instance + +This object can be used to get access to CORBA engine part of some +SALOME module, available in the current SALOME session. The following +code returns a reference to the Geometry module engine, loading it if +necessary: +\code +import GEOM +geom = salome.lcc.FindOrLoadComponent('FactoryServer', 'GEOM') +\endcode +\b Note, that in the above example, \e "FactoryServer" is a name of the +SALOME container, where Geometry module engine should be loaded. + +\li \b myStudyManager Reference to the study manager + +SALOMEDS Study manager is used to manipulate with the studies: create, +open, save, close. It also can be used to find the study by its +numerical ID or name. The code below demonstrates main +functionalities of a study manager: +\code +# create new study with the name "MyStudy" +new_study = salome.myStudyManager.NewStudy("MyStudy") + +# open study from file /home/user/MyStudy.hdf +study = salome.myStudyManager.OpenStudy("/home/user/MyStudy.hdf") + +# save study +salome.myStudyManager.Save(study, False) # not using multifile save mode + +# save study in ASCII format +salome.myStudyManager.SaveASCII(study, True) # using multifile save mode + +# save study with the new file path +salome.myStudyManager.SaveAs("/home/user/MyStudy.hdf", study, False) + +# save study with the new file path in ASCII format +salome.myStudyManager.SaveAsASCII("/home/user/MyStudy.hdf", study, False) + +# close study +salome.myStudyManager.Close(study) + +# get list of all opened studies +studies = salome.myStudyManager.GetOpenStudies() + +# find study by its numerical ID (integer value starting from 1) +study = salome.myStudyManager.GetStudyByID(studyID) + +# find study by its name +study = salome.myStudyManager.GetStudyByName("/home/user/MyStudy.hdf") + +# ... +\endcode + +\li \b myStudy Reference to the current (active) study + +This variable can be used to manipulate with the date of the study: +create data tree, assign attributes of different types to the objects +in a data tree, create references between objects, etc. + +\b Note, that the term "active" or "current" study does not make much +sense outise the GUI Python console. When working in GUI, user always +deals with one only top-level study, which desktop is currently on the +top if the windows stack. This is what is called \e "active study". +In TUI mode (without GUI or outside GUI), user has to manipulate with +studies manually; no any special control for the life cycle of the +study is done. In TUI mode, \c salome.muStudy variable is an instance +of the first study created when you call salome_init() function. + +The following code demonstrates some examples of \c salome.myStudy +variable usage. For more details please refer to the SALOMEDS.idl file +documentation. + +\code +# get study name +studyName = salome.myStudy._get_Name() + +# get study numerical ID +studyID = salome.myStudy._get_StudyId() + +# find SALOMEDS component by its type +scomponent = FindComponent("MyComponent") + +# find SALOMEDS component by its entry ID +scomponent = FindComponentID("0:1:1") # "0:1:1" is a component ID + +# find SALOMEDS object by its name (first found object is returned) +sobject = salome.myStudy.FindObject("MyObject") + +# find SALOMEDS object by its entry ID +sobject = salome.myStudy.FindObjectID() # "0:1:1:1" is an object ID + +# find SALOMEDS object by its IOR attribute +sobject = salome.myStudy.FindObjectIOR(IOR) + +# find SALOMEDS object by its path in the data tree +sobject = salome.myStudy.FindObjectByPath("/MyComponent/MyObject/MySubObject") + +# get SALOMEDS object's path in a study data tree +sobject_path = salome.myStudy.GetObjectPath(sobject) + +# get study properties +prop = salome.myStudy.GetProperties() +prop.GetCreationDate() # get creation date +prop.IsModified() # check if study has been modified (and not yet saved) +prop.SetLocked(True) # lock the study (prohibit modifications) +prop.IsLocked() # check if study is locked + +# create objects with study builder +builder = salome.myStudy.NewBuilder() # create builder +comp = builder.NewComponent("MyComponent") # create a component of the "MyComponent" type +attrName = builder.FindOrCreateAttribute(comp, "AttributeName") +attrName.SetValue("MyComponent") # set name to the component +object = builder.NewObject(comp) # create new object, a child of the component +attrName = builder.FindOrCreateAttribute(object, "AttributeName") +attrName.SetValue("MyObject") # set name to the object +attrInt = builder.FindOrCreateAttribute(object, "AttributeInteger") +attrInt.SetValue(123) # assign integer attribute to the object +attrIOR = builder.FindOrCreateAttribute(object, "AttributeIOR") +attrIOR.SetValue(IOR) # assign IOR attribute to the object (to point to some CORBA object) + +# iterate through objects of the data tree with child iterator +iter = salome.myStudy.NewChildIterator(comp) # initialize from the component +iter.InitEx(True) # init recursive mode +while iter.More(): + c = iter.Value() + print c.GetID() + iter.Next() + pass + +# ... +\endcode + +\li \b myStudyId Identifier of the current (active) study + +This variable contains the numerical identifier of the current +(active) study. It is an equivalent of \c +salome.myStudy._get_StudyId() code. + +\li \b myStudyName Name of the current (active) study + +This variable contains the name of the current (active) study. It is +an equivalent of \c salome.myStudy._get_Name() code. + +\li \b DumpStudy() Print study contents + +This function prints the study data object tree to the terminal +window. The output for each object includes its entry ID, name, IOR +(if there is one) and referenced object ID (for references). I.e. +this is the same data the user can see in the Object Browser columns. +\code +salome.DumpStudy(salome.myStudy) +\endcode + +\li \b IDToSObject() Get SALOMEDS object by its entry ID. + +This function checks if the SObject with the specified entry ID exists +in the current study and returns it. Otherwise \c None is returned. +\code +sobject = salome.IDToSObject("0:1:1:1") # "0:1:1:1" is an object ID +\endcode +Actually this function is just a shortcut to the following code: +\code +sobject = salome.myStudy.FindObjectID("0:1:1:1") +\endcode + +\li \b IDToObject() Get CORBA object by its entry ID. + +This function checks if the SObject with the specified entry ID exists +in the current study, then retrieves IOR attribute from it and, +finally, if IOR is not empty, returns CORBA object corresponding to +the found SObject: +\code +object = salome.IDToObject("0:1:1:1") # "0:1:1:1" is an object ID +\endcode +Actually this function is just a shortcut to the following code: +\code +sobject = salome.myStudy.FindObjectID("0:1:1:1") +if sobject: + object = sobject.GetObject() +else: + object = None +\endcode + +\li \b ObjectToSObject() Get SALOMEDS object corresponding to the +CORBA object. + +This function finds an object in the current study which corresponds +to the specified CORBA object (i.e. it has IOR attribute, pointing to +the CORBA object). If there is no corresponding SALOMEDS object in the +study, \c None is returned: +\code +sobject = salome.ObjectToSObject(object) +\endcode +Actually this function is just a shortcut to the following code: +\code +ior = salome.orb.object_to_string(object) +sobject = salome.myStudy.FindObjectIOR(ior) +\endcode + +\li \b ObjectToID() Get SALOMEDS object entry ID corresponding to the +CORBA object. + +This function finds an object in the current study which corresponds +to the specified CORBA object (i.e. it has IOR attribute, pointing to +the CORBA object). If the object is found, its entry ID is returned, +otherwise empty string is returned: +\code +entry = salome.ObjectToID(object) +\endcode +Actually this function is just a shortcut to the following code: +\code +ior = salome.orb.object_to_string(object) +sobject = salome.myStudy.FindObjectIOR(ior) +if sobject: + entry = sobject.GetID() +else: + entry = "" +\endcode + +\li \b createNewStudy() Create new study + +This function can be used to create new SALOME study. Returns an ID of +the created study. +\code +studyId = salome.createNewStudy() +study = salome.myStudyManager.GetStudyByID(s) +\endcode + +\li \b generateName() Generate unique name + +This function adds random numerical suffix to the passed string +parameter ("Study" by default) and returns the resulting string: +\code +name_1 = salome.generateName() # name_1 is something like "Study682" +name_1 = salome.generateName("Obj") # name_1 is something like "Obj32" +\endcode + +\li \b sg SWIG interface to the SALOME GUI + +This variable provides an access to some GUI functions. + +\b Note, that this variable is not available if you use salome.py +Python module outside the GUI desktop, i.e. not in the embedded Python +console (since SWIG library is linked directly to the GUI library). + +The example of usage: +\code +# update Object browser contents +salome.sg.updateObjBrowser(True) + +# get active study ID +studyId = salome.sg.getActiveStudyId() + +# get active study name +studyName = salome.sg.getActiveStudyName() + +# get selected objects +selCount = salome.sg.SelectedCount() # total number of selected items +for i in range(selCount): + print salome.sg.getSelected(i) # print entry ID of i-th selected item + +# get list of all selected objects' IDs +selected = salome.sg.getAllSelected() + +# add object to the selection +salome.sg.AddIObject("0:1:1:1") # "0:1:1:1" is an object ID + +# remove object from the selection (make it unselected) +salome.sg.RemoveIObject("0:1:1:1") # "0:1:1:1" is an object ID + +# clear selection (set all objects unselected) +salome.sg.ClearIObjects() + +# display object in the current view (if possible) +salome.sg.Display("0:1:1:1") # "0:1:1:1" is an object ID +salome.sg.UpdateView() # update view + +# erase object from the current view +salome.sg.Erase("0:1:1:1") # "0:1:1:1" is an object ID +salome.sg.UpdateView() # update view + +# display all objects in the current view (if possible) +salome.sg.DisplayAll() +salome.sg.UpdateView() # update view + +# erase all objects from the current view +salome.sg.EraseAll() +salome.sg.UpdateView() # update view + +# set top, bottom, front, rear, left, right view +salome.sg.ViewTop() # top view +salome.sg.ViewBottom() # bottom view +salome.sg.ViewFront() # front view +salome.sg.ViewTop() # back view +salome.sg.ViewLeft() # left view +salome.sg.ViewRight() # right view + +# reset current view +salome.sg.ResetView() + +# get component symbolic name by its user name +compName = salome.sg.getComponentName("Geometry") # compoName = "GEOM" + +# get component user name by its symbolic name +compName = salome.sg.getComponentUserName("SMESH") # compoName = "Mesh" + +# ... +\endcode + +*/ diff --git a/doc/salome/gui/input/themes.doc b/doc/salome/gui/input/themes.doc new file mode 100755 index 000000000..9fff17ae3 --- /dev/null +++ b/doc/salome/gui/input/themes.doc @@ -0,0 +1,27 @@ +/*! + +\page themes_page Theme + +\b Theme dialog is used for customization of the look and feel of +Salome. To open it, select in the Main menu View -> Theme . + +\image html theme1.png + +It is possible to choose a predefined color scheme in the list to the left +or to edit your custom color scheme using the controls to the right. + +\b Quick button allows to apply color change made in one position to all +other positions using this color. + +\image html theme2.png + +
    +
  • \b Font group allows to edit the default font used in Salome menus.
  • +
  • \b Lines group allows to apply dashing to Salome elements.
  • +
  • Widgets rounding allows to round corners of Salome dialog +boxes and define their parameters.
  • +
  • \b Handle allows to define parameters of the handle.
  • +
  • Widget effect allows to apply special effects to Salome +dialog boxes.
  • +
+*/ \ No newline at end of file diff --git a/doc/salome/gui/input/using_notebook.doc b/doc/salome/gui/input/using_notebook.doc new file mode 100644 index 000000000..d48fe8fcb --- /dev/null +++ b/doc/salome/gui/input/using_notebook.doc @@ -0,0 +1,26 @@ +/*! + +\page using_notebook Using NoteBook + +SALOME NoteBook is destined for managing numerical and boolean +parameters (variables) which are used to create and modify objects in +different components. + +To open the NoteBook choose File > Notebook, the following +dialog box will appear: + +\image html notebook1.png + +Here you can add new variables, remove and rename existing variables and +change their values. + +If you have modified some variables, which are already used in the current +study, you should click Update Study button to apply your changes +to the study. + +\note The dialog will not be validated until at least one of variables in +the table has invalid name or value (marked by red color). Names of +variables should be unique and their values should be numerical (integer or +double) or boolean ("True" / "False"). + +*/ \ No newline at end of file diff --git a/src/Event/SALOME_EventFilter.cxx b/src/Event/SALOME_EventFilter.cxx new file mode 100755 index 000000000..074213c9a --- /dev/null +++ b/src/Event/SALOME_EventFilter.cxx @@ -0,0 +1,80 @@ +// Copyright (C) 2007-2008 CEA/DEN, EDF R&D, OPEN CASCADE +// +// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, +// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// +#include "SALOME_EventFilter.h" +#include "SALOME_Event.h" + +#include + +SALOME_EventFilter* SALOME_EventFilter::myFilter = NULL; + +/*!Constructor.*/ +SALOME_EventFilter::SALOME_EventFilter() +: QObject() +{ + /* VSR 13/01/03 : installing global event filter for the application */ + qApp->installEventFilter( this ); +} + +/*!Destructor.*/ +SALOME_EventFilter::~SALOME_EventFilter() +{ + qApp->removeEventFilter( this ); +} + +/*! + Custom event filter +*/ +bool SALOME_EventFilter::eventFilter( QObject* o, QEvent* e ) +{ + if ( e->type() == SALOME_EVENT ) + { + SALOME_Event* aSE = (SALOME_Event*)((SALOME_CustomEvent*)e)->data(); + processEvent(aSE); + ((SALOME_CustomEvent*)e)->setData( 0 ); + return true; + } + return QObject::eventFilter( o, e ); +} + +/*!Process event.*/ +void SALOME_EventFilter::processEvent( SALOME_Event* theEvent ) +{ + if(theEvent) + theEvent->ExecutePostedEvent(); +} + +/*!Create new instance of SALOME_EventFilter*/ +void SALOME_EventFilter::Init() +{ + if( myFilter==NULL ) + myFilter = new SALOME_EventFilter(); +} + +/*!Destroy filter.*/ +void SALOME_EventFilter::Destroy() +{ + if( myFilter ) + { + delete myFilter; + myFilter = NULL; + } +} diff --git a/src/Event/SALOME_EventFilter.h b/src/Event/SALOME_EventFilter.h new file mode 100755 index 000000000..3881d6ac1 --- /dev/null +++ b/src/Event/SALOME_EventFilter.h @@ -0,0 +1,63 @@ +// Copyright (C) 2007-2008 CEA/DEN, EDF R&D, OPEN CASCADE +// +// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, +// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// +#ifndef SALOME_EVENTFILTER_H +#define SALOME_EVENTFILTER_H + +#include "Event.h" +#include + +#if defined WIN32 +#pragma warning( disable: 4251 ) +#endif + +class SALOME_Event; + +/*! + Event filter class for QApplication object that handles custom events posted by SALOME_Event objects. + It assumes that such custom events are alwys posted, not sent. + This event filter can be installed by any application that intends to use SALOME_Event mechanism asynchronously. + This class replaced SalomeApp_EventFilter. +*/ +class EVENT_EXPORT SALOME_EventFilter: public QObject +{ +public: + static void Init(); + static void Destroy(); + +protected: + SALOME_EventFilter(); + virtual ~SALOME_EventFilter(); + +private: + /*! global event filter for qapplication */ + virtual bool eventFilter( QObject* o, QEvent* e ); + void processEvent( SALOME_Event* ); + +private: + static SALOME_EventFilter* myFilter; +}; + +#if defined WIN32 +#pragma warning( default: 4251 ) +#endif + +#endif diff --git a/src/QxScene/DebTrace.hxx b/src/QxScene/DebTrace.hxx new file mode 100644 index 000000000..6350ae559 --- /dev/null +++ b/src/QxScene/DebTrace.hxx @@ -0,0 +1,33 @@ +// Copyright (C) 2007-2008 CEA/DEN, EDF R&D, OPEN CASCADE +// +// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, +// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// +#ifndef __DEBTRACE_HXX__ +#define __DEBTRACE_HXX__ + +#include + +#ifdef _DEVDEBUG_ +#define DEBTRACE(msg) {std::cerr<(theView); + bool OKToClose = true; + if (!qxview) + OKToClose = true; + else + OKToClose = qxview->closeRequested(); + if (OKToClose) + { + DEBTRACE("SUIT View to close"); + SUIT_ViewManager::closeView(theView); + DEBTRACE("SUIT View closed"); + } +} diff --git a/src/QxScene/QxScene_ViewManager.h b/src/QxScene/QxScene_ViewManager.h new file mode 100644 index 000000000..924084c74 --- /dev/null +++ b/src/QxScene/QxScene_ViewManager.h @@ -0,0 +1,48 @@ +// Copyright (C) 2007-2008 CEA/DEN, EDF R&D, OPEN CASCADE +// +// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, +// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// +#ifndef QXSCENE_VIEWMANAGER_H +#define QXSCENE_VIEWMANAGER_H + +#include "QxScene.h" + +#include "QxScene_ViewModel.h" +#include "SUIT_ViewManager.h" + +class SUIT_Desktop; + +class QXSCENE_EXPORT QxScene_ViewManager : public SUIT_ViewManager +{ + Q_OBJECT + +public: + QxScene_ViewManager( SUIT_Study* theStudy, SUIT_Desktop* theDesktop, SUIT_ViewModel* theViewModel = 0 ); + ~QxScene_ViewManager(); + +protected: + bool insertView(SUIT_ViewWindow* theView); + virtual void closeView(SUIT_ViewWindow* theView); +public slots: + void createView(); + +}; + +#endif diff --git a/src/QxScene/QxScene_ViewModel.cxx b/src/QxScene/QxScene_ViewModel.cxx new file mode 100644 index 000000000..5d2e6755d --- /dev/null +++ b/src/QxScene/QxScene_ViewModel.cxx @@ -0,0 +1,117 @@ +// Copyright (C) 2007-2008 CEA/DEN, EDF R&D, OPEN CASCADE +// +// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, +// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// +#include "QxScene_ViewModel.h" +#include "QxScene_ViewWindow.h" +#include "QxScene_ViewManager.h" +#include "QxScene_Def.h" + +#include "SUIT_Desktop.h" +#include "SUIT_ViewWindow.h" +#include "SUIT_Session.h" + +#include +#include +#include + +//#define _DEVDEBUG_ +#include "DebTrace.hxx" + +/*! + Constructor +*/ +QxScene_Viewer::QxScene_Viewer() + :SUIT_ViewModel() +{ + DEBTRACE("QxScene_Viewer::QxScene_Viewer"); +} + +/*! + Destructor +*/ +QxScene_Viewer::~QxScene_Viewer() +{ + DEBTRACE("QxScene_Viewer::~QxScene_Viewer"); +} + +void QxScene_Viewer::setViewManager( SUIT_ViewManager* mgr) +{ + DEBTRACE("QxScene_Viewer::setViewManager"); + SUIT_ViewModel::setViewManager( mgr ); +} + +/*! + Start initialization of view window + \param view - view window to be initialized +*/ +void QxScene_Viewer::initView( QxScene_ViewWindow* view ) +{ + DEBTRACE("QxScene_Viewer::initView"); + if ( view ) + { + view->initLayout(); + } +} + +/*! + Creates new view window + \param theDesktop - main window of application +*/ +SUIT_ViewWindow* QxScene_Viewer::createView(SUIT_Desktop* theDesktop) +{ + DEBTRACE("QxScene_Viewer::createView"); + QxScene_ViewWindow* aRes = new QxScene_ViewWindow( theDesktop, this ); + initView( aRes ); + return aRes; +} + +/*! + Builds popup for QxScene viewer +*/ +void QxScene_Viewer::contextMenuPopup(QMenu* thePopup) +{ + DEBTRACE("QxScene_Viewer::contextMenuPopup"); +} + +/*! + SLOT: called if background color is to be changed changed, passes new color to current canvas view +*/ +void QxScene_Viewer::onChangeBgColor() +{ + QxScene_ViewWindow* aView = (QxScene_ViewWindow*)(myViewManager->getActiveView()); + if( !aView ) + return; + QColor aColorActive = aView->backgroundColor(); + + QColor selColor = QColorDialog::getColor( aColorActive, aView); + if ( selColor.isValid() ) + aView->setBackgroundColor(selColor); +} + +/*! + SLOT: called when popup item "Show toolbar" is activated, shows toolbar of active view window +*/ +void QxScene_Viewer::onShowToolbar() +{ + QxScene_ViewWindow* aView = (QxScene_ViewWindow*)(myViewManager->getActiveView()); + if ( aView ) + aView->getToolBar()->show(); +} diff --git a/src/QxScene/QxScene_ViewModel.h b/src/QxScene/QxScene_ViewModel.h new file mode 100644 index 000000000..565532c2b --- /dev/null +++ b/src/QxScene/QxScene_ViewModel.h @@ -0,0 +1,57 @@ +// Copyright (C) 2007-2008 CEA/DEN, EDF R&D, OPEN CASCADE +// +// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, +// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// +#ifndef QXSCENE_VIEWMODEL_H +#define QXSCENE_VIEWMODEL_H + +#include "QxScene.h" + +#include "SUIT_ViewModel.h" + +class QxScene_ViewWindow; + +class QXSCENE_EXPORT QxScene_Viewer: public SUIT_ViewModel +{ + Q_OBJECT + + public: + static QString Type() { return "QxSceneViewer"; } + + QxScene_Viewer(); + virtual ~QxScene_Viewer(); + + virtual void setViewManager( SUIT_ViewManager* ); + virtual SUIT_ViewWindow* createView(SUIT_Desktop* theDesktop); + virtual QString getType() const { return Type(); } + + virtual void contextMenuPopup(QMenu*); + + protected: + void initView(QxScene_ViewWindow* view); + + protected slots: + void onShowToolbar(); + void onChangeBgColor(); + + private: +}; + +#endif diff --git a/src/QxScene/QxScene_ViewWindow.cxx b/src/QxScene/QxScene_ViewWindow.cxx new file mode 100644 index 000000000..169694bb2 --- /dev/null +++ b/src/QxScene/QxScene_ViewWindow.cxx @@ -0,0 +1,283 @@ +// Copyright (C) 2007-2008 CEA/DEN, EDF R&D, OPEN CASCADE +// +// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, +// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// +// SALOME QxScene : build Supervisor viewer into desktop +// +#include "QxScene_ViewWindow.h" +#include "QxScene_Def.h" + +#include +#include +#include + +#include +#include +#include + +//QT Include +#include +#include + +//#define _DEVDEBUG_ +#include "DebTrace.hxx" + +using namespace std; + +/*! + Constructor +*/ +QxScene_ViewWindow::QxScene_ViewWindow( SUIT_Desktop* theDesktop, QxScene_Viewer* theModel) + : SUIT_ViewWindow( theDesktop ) +{ + DEBTRACE("Construct QxScene_ViewWindow"); + myViewModel = theModel; + _scene = 0; + _sceneView = 0; +} + +/*! + Initialization +*/ +void QxScene_ViewWindow::initLayout() +{ + DEBTRACE("QxScene_ViewWindow::initLayout"); + createActions(); + createToolBar(); + + // --- QGraphics test + +// _scene = new QGraphicsScene(); +// _sceneView = new QGraphicsView(this); +// setCentralWidget(_sceneView); +// _sceneView->setScene(_scene); +// QGraphicsRectItem *rect = _scene->addRect(QRectF(0, 0, 100, 100)); +// _sceneView->show(); +} + +/*! + Creates actions of QxScene view window +*/ +void QxScene_ViewWindow::createActions() +{ + DEBTRACE("QxScene_ViewWindow::createActions"); + QtxActionToolMgr* mgr = toolMgr(); + QtxAction* aAction; + SUIT_ResourceMgr* aResMgr = SUIT_Session::session()->resourceMgr(); + + // 2. Scaling operations + + // 2.1. Fit All + aAction = new QtxAction( tr( "MNU_FITALL" ), + aResMgr->loadPixmap( "QxSceneViewer", tr( "ICON_QXSCENE_FITALL" ) ), + tr( "MNU_FITALL" ), + 0, this); + aAction->setStatusTip( tr( "DSC_FITALL" ) ); + connect( aAction, SIGNAL( triggered( bool ) ), this, SLOT( onViewFitAll() ) ); + mgr->registerAction( aAction, FitAllId ); + + // 2.2. Fit Rect + aAction = new QtxAction( tr( "MNU_FITRECT" ), + aResMgr->loadPixmap( "QxSceneViewer", tr( "ICON_QXSCENE_FITAREA" ) ), + tr( "MNU_FITRECT" ), + 0, this); + aAction->setStatusTip( tr( "DSC_FITRECT" ) ); + connect( aAction, SIGNAL( triggered( bool ) ), this, SLOT( onViewFitArea() ) ); + mgr->registerAction( aAction, FitRectId ); + + // 2.3. Zoom + aAction = new QtxAction( tr( "MNU_ZOOM_VIEW" ), + aResMgr->loadPixmap( "QxSceneViewer", tr( "ICON_QXSCENE_ZOOM" ) ), + tr( "MNU_ZOOM_VIEW" ), + 0, this); + aAction->setStatusTip( tr( "DSC_ZOOM_VIEW" ) ); + connect( aAction, SIGNAL( triggered( bool ) ), this, SLOT( onViewZoom() ) ); + mgr->registerAction( aAction, ZoomId ); + + // 2.4. Create multi-action for scaling operations + QtxMultiAction* aScaleAction = new QtxMultiAction( this ); + aScaleAction->insertAction( mgr->action( FitAllId ) ); + aScaleAction->insertAction( mgr->action( FitRectId ) ); + aScaleAction->insertAction( mgr->action( ZoomId ) ); + mgr->registerAction( aScaleAction, ScaleOpId ); + + // 3. Moving operations + + // 3.1. Panning + aAction = new QtxAction( tr( "MNU_PAN_VIEW" ), + aResMgr->loadPixmap( "QxSceneViewer", tr( "ICON_QXSCENE_PAN" ) ), + tr( "MNU_PAN_VIEW" ), + 0, this); + aAction->setStatusTip( tr( "DSC_PAN_VIEW" ) ); + connect( aAction, SIGNAL( triggered( bool ) ), this, SLOT( onViewPan() ) ); + mgr->registerAction( aAction, PanId ); + + // 3.2. Global Panning + aAction = new QtxAction( tr( "MNU_GLOBALPAN_VIEW" ), + aResMgr->loadPixmap( "QxSceneViewer", tr( "ICON_QXSCENE_GLOBALPAN" ) ), + tr( "MNU_GLOBALPAN_VIEW" ), + 0, this); + aAction->setStatusTip( tr( "DSC_GLOBALPAN_VIEW" ) ); + connect( aAction, SIGNAL( triggered( bool ) ), this, SLOT( onViewGlobalPan() ) ); + mgr->registerAction( aAction, GlobalPanId ); + + // 3.3. Create multi-action for moving operations + QtxMultiAction* aPanAction = new QtxMultiAction( this ); + aPanAction->insertAction( mgr->action( PanId ) ); + aPanAction->insertAction( mgr->action( GlobalPanId ) ); + mgr->registerAction( aPanAction, MoveOpId ); + + // reset + aAction = new QtxAction( tr( "MNU_RESET_VIEW" ), + aResMgr->loadPixmap( "QxSceneViewer", tr( "ICON_QXSCENE_RESET" ) ), + tr( "MNU_RESET_VIEW" ), + 0, this); + aAction->setStatusTip( tr( "DSC_RESET_VIEW" ) ); + connect( aAction, SIGNAL( triggered( bool ) ), this, SLOT( onViewReset() ) ); + mgr->registerAction( aAction, ResetId ); +} + +/*! + Creates toolbar of QxScene view window +*/ +void QxScene_ViewWindow::createToolBar() +{ + DEBTRACE("QxScene_ViewWindow::createToolBar"); + QtxActionToolMgr* mgr = toolMgr(); + myToolBar = mgr->createToolBar( tr( "LBL_TOOLBAR_LABEL" ) ); + mgr->append( ScaleOpId, myToolBar ); + mgr->append( MoveOpId, myToolBar ); + mgr->append( ResetId, myToolBar ); +} + +/*! + \brief Get view window's toolbar. + \return toolbar +*/ +QToolBar* QxScene_ViewWindow::getToolBar() +{ + DEBTRACE("QxScene_ViewWindow::getToolBar"); + return toolMgr()->toolBar( myToolBar ); +} + +/*! + Destructor +*/ +QxScene_ViewWindow::~QxScene_ViewWindow() +{ + DEBTRACE("destructor QxScene_ViewWindow"); + +} + +/*! + Reset the active view +*/ +void QxScene_ViewWindow::onViewReset() +{ + DEBTRACE( "QxScene_ViewWindow::onViewReset" ); +} + +/*! + Sets a new center of the active view +*/ +void QxScene_ViewWindow::onViewGlobalPan() +{ + DEBTRACE( "QxScene_ViewWindow::onViewGlobalPan" ); +} + +/*! + Zooms the active view +*/ +void QxScene_ViewWindow::onViewZoom() +{ + DEBTRACE( "QxScene_ViewWindow::onViewZoom" ); +} + +/*! + Moves the active view +*/ +void QxScene_ViewWindow::onViewPan() +{ + DEBTRACE( "QxScene_ViewWindow::onViewPan" ); +} + +/*! + Fits all obejcts within a rectangular area of the active view +*/ +void QxScene_ViewWindow::onViewFitArea() +{ + DEBTRACE( "QxScene_ViewWindow::onViewFitArea" ); +} + +/*! + Fits all objects in the active view +*/ +void QxScene_ViewWindow::onViewFitAll() +{ + DEBTRACE( "QxScene_ViewWindow::onViewFitAll" ); +} + +/*! + Set background of the viewport +*/ +void QxScene_ViewWindow::setBackgroundColor( const QColor& color ) +{ + DEBTRACE("QxScene_ViewWindow::setBackgroundColor"); +} + +/*! + Returns background of the viewport +*/ +QColor QxScene_ViewWindow::backgroundColor() const +{ + DEBTRACE("QxScene_ViewWindow::backgroundColor"); + QColor col; + return col; +} + +/*! + Custom resize event handler +*/ +void QxScene_ViewWindow::resizeEvent( QResizeEvent* theEvent ) +{ + DEBTRACE("QxScene_ViewWindow::resizeEvent"); +} + +/*! + Get resource manager +*/ +SUIT_ResourceMgr* QxScene_ViewWindow::resMgr() const +{ + DEBTRACE("QxScene_ViewWindow::resMgr"); + return SUIT_Session::session()->resourceMgr(); +} + +/*! + * emits a signal to ask to close the schema associated to the window. + * A boolean in return indicates if it is OK to close. + */ +bool QxScene_ViewWindow::closeRequested() +{ + DEBTRACE("QxScene_ViewWindow::closeRequested"); + bool isClosed = false; + emit tryClose(isClosed, this); + DEBTRACE("isClosed=" << isClosed); + return isClosed; +} diff --git a/src/QxScene/QxScene_ViewWindow.h b/src/QxScene/QxScene_ViewWindow.h new file mode 100644 index 000000000..dd1f8aa4e --- /dev/null +++ b/src/QxScene/QxScene_ViewWindow.h @@ -0,0 +1,105 @@ +// Copyright (C) 2007-2008 CEA/DEN, EDF R&D, OPEN CASCADE +// +// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, +// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// +// SALOME QxScene : build Supervisor viewer into desktop +// +#ifndef QXSCENE_VIEWWINDOW_H +#define QXSCENE_VIEWWINDOW_H + +#include "QxScene.h" +#include "QxScene_ViewModel.h" + +#include "SUIT_ViewWindow.h" + +#include "QtxAction.h" + +#include + +#include +#include + +#ifdef WIN32 +#pragma warning ( disable:4251 ) +#endif + +class SUIT_ResourceMgr; + +class QXSCENE_EXPORT QxScene_ViewWindow : public SUIT_ViewWindow { + Q_OBJECT + + public: + //! Actions ID + enum { FitAllId, FitRectId, ZoomId, ScaleOpId, PanId, GlobalPanId, MoveOpId, ResetId }; + + QxScene_ViewWindow(SUIT_Desktop* theDesktop, QxScene_Viewer* theModel); + virtual ~QxScene_ViewWindow(); + + void setBackgroundColor( const QColor& ); + QColor backgroundColor() const; + + QToolBar* getToolBar(); + + SUIT_ResourceMgr* resMgr() const; + + QxScene_Viewer* getViewModel() const { return myViewModel; } + void setViewModel(QxScene_Viewer* theViewModel) { myViewModel = theViewModel; } + + virtual void initLayout(); + + void contextPopupEvent(QContextMenuEvent* theEvent) { emit contextMenuRequested( theEvent); } + + void setScene(QGraphicsScene* scene) { _scene = scene; } + QGraphicsScene* getScene() { return _scene; } + void setSceneView(QGraphicsView* sceneView){ _sceneView = sceneView; } + QGraphicsView* getSceneView() { return _sceneView; } + virtual bool closeRequested(); + + signals: + void tryClose(bool &isClosed, QxScene_ViewWindow* window); + + public slots: + void onViewFitAll(); + void onViewFitArea(); + void onViewZoom(); + void onViewPan(); + void onViewGlobalPan(); + void onViewReset(); + + protected: + void resizeEvent( QResizeEvent* theEvent ); + + QGraphicsScene* _scene; + QGraphicsView* _sceneView; + + private: + void createActions(); + void createToolBar(); + + int myToolBar; + + QxScene_Viewer* myViewModel; +}; + +#ifdef WIN32 +#pragma warning ( default:4251 ) +#endif + +#endif diff --git a/src/QxScene/resources/QxSceneViewer_images.ts b/src/QxScene/resources/QxSceneViewer_images.ts new file mode 100644 index 000000000..755bb16b0 --- /dev/null +++ b/src/QxScene/resources/QxSceneViewer_images.ts @@ -0,0 +1,52 @@ + + + + @default + + ICON_QXSCENE_RESET + qx_view_reset.png + + + ICON_QXSCENE_ZOOM + qx_view_zoom.png + + + ICON_QXSCENE_GLOBALPAN + qx_view_glpan.png + + + ICON_QXSCENE_PAN + qx_view_pan.png + + + ICON_QXSCENE_FITALL + qx_view_fitall.png + + + ICON_QXSCENE_FITAREA + qx_view_fitarea.png + + + diff --git a/src/QxScene/resources/QxSceneViewer_msg_en.ts b/src/QxScene/resources/QxSceneViewer_msg_en.ts new file mode 100644 index 000000000..e8188cd71 --- /dev/null +++ b/src/QxScene/resources/QxSceneViewer_msg_en.ts @@ -0,0 +1,59 @@ + + + + @default + + MEN_CHANGE_BACKGROUND + Change Background... + + + MNU_PAN_VIEW + Panning + + + DSC_PAN_VIEW + Panning the view + + + MNU_RESET_VIEW + Reset + + + DSC_RESET_VIEW + Reset View Point + + + LBL_TOOLBAR_LABEL + View Operations + + + + QxScene_ViewManager + + QXSCENE_VIEW_TITLE + QGraphics scene:%M - viewer:%V + + + diff --git a/src/QxScene/resources/QxScene_images.po b/src/QxScene/resources/QxScene_images.po new file mode 100644 index 000000000..3ea39eb01 --- /dev/null +++ b/src/QxScene/resources/QxScene_images.po @@ -0,0 +1,44 @@ +# Copyright (C) 2007-2008 CEA/DEN, EDF R&D, OPEN CASCADE +# +# Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, +# CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +# +# This library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public +# License as published by the Free Software Foundation; either +# version 2.1 of the License. +# +# This library is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public +# License along with this library; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +# +# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +# +# File: QxScene_images.po +# Created: 03/02/2007 +# Author: Margarita Karpunina + + +msgid "ICON_QXSCENE_FITALL" +msgstr "qx_view_fitall.png" + +msgid "ICON_QXSCENE_FITAREA" +msgstr "qx_view_fitarea.png" + +msgid "ICON_QXSCENE_ZOOM" +msgstr "qx_view_zoom.png" + +msgid "ICON_QXSCENE_PAN" +msgstr "qx_view_pan.png" + +msgid "ICON_QXSCENE_GLOBALPAN" +msgstr "qx_view_glpan.png" + +msgid "ICON_QXSCENE_RESET" +msgstr "qx_view_reset.png" + diff --git a/src/QxScene/resources/QxScene_msg_en.po b/src/QxScene/resources/QxScene_msg_en.po new file mode 100644 index 000000000..44fba1f77 --- /dev/null +++ b/src/QxScene/resources/QxScene_msg_en.po @@ -0,0 +1,42 @@ +# Copyright (C) 2007-2008 CEA/DEN, EDF R&D, OPEN CASCADE +# +# Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, +# CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +# +# This library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public +# License as published by the Free Software Foundation; either +# version 2.1 of the License. +# +# This library is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public +# License along with this library; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +# +# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +# +# File: QxScene_msg_en.po +# Created: 03/02/2007 +# Author: Margarita Karpunina + +msgid "LBL_TOOLBAR_LABEL" +msgstr "View Operations" + +msgid "DSC_RESET_VIEW" +msgstr "Reset View Point" + +msgid "MNU_RESET_VIEW" +msgstr "Reset" + +msgid "DSC_PAN_VIEW" +msgstr "Panning the view" + +msgid "MNU_PAN_VIEW" +msgstr "Panning" + +msgid "MEN_CHANGE_BACKGROUND" +msgstr "Change background..." diff --git a/src/QxScene/resources/qx_view_fitall.png b/src/QxScene/resources/qx_view_fitall.png new file mode 100755 index 000000000..87e001dd8 Binary files /dev/null and b/src/QxScene/resources/qx_view_fitall.png differ diff --git a/src/QxScene/resources/qx_view_fitarea.png b/src/QxScene/resources/qx_view_fitarea.png new file mode 100755 index 000000000..450dc56c6 Binary files /dev/null and b/src/QxScene/resources/qx_view_fitarea.png differ diff --git a/src/QxScene/resources/qx_view_glpan.png b/src/QxScene/resources/qx_view_glpan.png new file mode 100644 index 000000000..28ab547ea Binary files /dev/null and b/src/QxScene/resources/qx_view_glpan.png differ diff --git a/src/QxScene/resources/qx_view_pan.png b/src/QxScene/resources/qx_view_pan.png new file mode 100755 index 000000000..ec56cacc7 Binary files /dev/null and b/src/QxScene/resources/qx_view_pan.png differ diff --git a/src/QxScene/resources/qx_view_reset.png b/src/QxScene/resources/qx_view_reset.png new file mode 100755 index 000000000..66f81e604 Binary files /dev/null and b/src/QxScene/resources/qx_view_reset.png differ diff --git a/src/QxScene/resources/qx_view_zoom.png b/src/QxScene/resources/qx_view_zoom.png new file mode 100755 index 000000000..386c966d1 Binary files /dev/null and b/src/QxScene/resources/qx_view_zoom.png differ diff --git a/src/SalomeApp/SalomeApp_DoubleSpinBox.cxx b/src/SalomeApp/SalomeApp_DoubleSpinBox.cxx new file mode 100644 index 000000000..42cf9e48d --- /dev/null +++ b/src/SalomeApp/SalomeApp_DoubleSpinBox.cxx @@ -0,0 +1,352 @@ +// 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/ or email : webmaster.salome@opencascade.com +// +// File: SalomeApp_DoubleSpinBox.cxx +// Author: Oleg UVAROV + +#include "SalomeApp_DoubleSpinBox.h" +#include "SalomeApp_Application.h" +#include "SalomeApp_Study.h" + +#include + +#include "SALOMEDSClient_ClientFactory.hxx" +#include CORBA_SERVER_HEADER(SALOMEDS) + +#include +#include + +/*! + \class SalomeApp_DoubleSpinBox +*/ + +/*! + \brief Constructor. + + Constructs a spin box with 0.0 as minimum value and 99.99 as maximum value, + a step value of 1.0 and a precision of 2 decimal places. + The value is initially set to 0.00. + + \param parent parent object +*/ +SalomeApp_DoubleSpinBox::SalomeApp_DoubleSpinBox( QWidget* parent ) +: QtxDoubleSpinBox( parent ), + myDefaultValue( 0.0 ), + myIsRangeSet( false ), + myMinimum( 0.0 ), + myMaximum( 99.99 ) +{ + connectSignalsAndSlots(); +} + +/*! + \brief Constructor. + + Constructs a spin box with specified minimum, maximum and step value. + The precision is set to 2 decimal places. + The value is initially set to the minimum value. + + \param min spin box minimum possible value + \param max spin box maximum possible value + \param step spin box increment/decrement value + \param parent parent object +*/ +SalomeApp_DoubleSpinBox::SalomeApp_DoubleSpinBox( double min, double max, double step, QWidget* parent ) +: QtxDoubleSpinBox( min, max, step, parent ), + myDefaultValue( 0.0 ), + myIsRangeSet( false ), + myMinimum( min ), + myMaximum( max ) +{ + connectSignalsAndSlots(); +} + +/*! + \brief Constructor. + + Constructs a spin box with specified minimum, maximum and step value. + The precision is set to 2 decimal places. + The value is initially set to the minimum value. + + \param min spin box minimum possible value + \param max spin box maximum possible value + \param step spin box increment/decrement value + \param parent parent object +*/ +SalomeApp_DoubleSpinBox::SalomeApp_DoubleSpinBox( double min, double max, double step, int prec, int dec, QWidget* parent ) +: QtxDoubleSpinBox( min, max, step, prec, dec, parent ), + myDefaultValue( 0.0 ), + myIsRangeSet( false ), + myMinimum( min ), + myMaximum( max ) +{ + connectSignalsAndSlots(); +} + +/*! + \brief Destructor. +*/ +SalomeApp_DoubleSpinBox::~SalomeApp_DoubleSpinBox() +{ +} + +/*! + \brief Connect signals and slots. +*/ +void SalomeApp_DoubleSpinBox::connectSignalsAndSlots() +{ + connect( this, SIGNAL( editingFinished() ), + this, SLOT( onEditingFinished() ) ); + + connect( this, SIGNAL( valueChanged( const QString& ) ), + this, SLOT( onTextChanged( const QString& ) ) ); + + connect( lineEdit(), SIGNAL( textChanged( const QString& ) ), + this, SLOT( onTextChanged( const QString& ) ) ); + + connect( lineEdit(), SIGNAL( textChanged( const QString& )), + this, SIGNAL( textChanged( const QString& ) ) ); +} + +/*! + \brief This function is called when editing is finished. +*/ +void SalomeApp_DoubleSpinBox::onEditingFinished() +{ + if( myTextValue.isNull() ) + myTextValue = text(); + + setText( myTextValue ); +} + +/*! + \brief This function is called when value is changed. +*/ +void SalomeApp_DoubleSpinBox::onTextChanged( const QString& text ) +{ + myTextValue = text; + + double value = 0; + if( isValid( text, value ) == Acceptable ) + myCorrectValue = text; +} + +/*! + \brief Interpret text entered by the user as a value. + \param text text entered by the user + \return mapped value + \sa textFromValue() +*/ +double SalomeApp_DoubleSpinBox::valueFromText( const QString& text ) const +{ + double value = 0; + if( isValid( text, value ) == Acceptable ) + return value; + + return defaultValue(); +} + +/*! + \brief This function is used by the spin box whenever it needs to display + the given value. + + \param val spin box value + \return text representation of the value + \sa valueFromText() +*/ +QString SalomeApp_DoubleSpinBox::textFromValue( double val ) const +{ + return QtxDoubleSpinBox::textFromValue( val ); +} + +/*! + \brief This function is used to determine whether input is valid. + \param str currently entered value + \param pos cursor position in the string + \return validating operation result +*/ +QValidator::State SalomeApp_DoubleSpinBox::validate( QString& str, int& pos ) const +{ + return QValidator::Acceptable; +} + +/*! + \brief This function is used to determine whether input is valid. + \return validating operation result +*/ +bool SalomeApp_DoubleSpinBox::isValid( QString& msg, bool toCorrect ) +{ + double value; + State aState = isValid( text(), value ); + + if( aState != Acceptable ) + { + if( toCorrect ) + { + if( aState == Incompatible ) + msg += tr( "ERR_INCOMPATIBLE_TYPE" ).arg( text() ) + "\n"; + else if( aState == NoVariable ) + msg += tr( "ERR_NO_VARIABLE" ).arg( text() ) + "\n"; + else if( aState == Invalid ) + msg += tr( "ERR_INVALID_VALUE" ) + "\n"; + + setText( myCorrectValue ); + } + return false; + } + + return true; +} + +/*! + \brief This function is used to set a default value for this spinbox. + \param value default value +*/ +void SalomeApp_DoubleSpinBox::setDefaultValue( const double value ) +{ + myDefaultValue = value; +} + +/*! + \brief This function is used to set minimum and maximum values for this spinbox. + \param min minimum value + \param max maximum value +*/ +void SalomeApp_DoubleSpinBox::setRange( const double min, const double max ) +{ + QtxDoubleSpinBox::setRange( min, max ); + + myIsRangeSet = true; + myMinimum = min; + myMaximum = max; +} + +/*! + \brief This function is used to set a current value for this spinbox. + \param value current value +*/ +void SalomeApp_DoubleSpinBox::setValue( const double value ) +{ + QtxDoubleSpinBox::setValue( value ); + + myCorrectValue = QString::number( value ); + myTextValue = myCorrectValue; +} + +/*! + \brief This function is used to set a text for this spinbox. + \param value current value +*/ +void SalomeApp_DoubleSpinBox::setText( const QString& value ) +{ + lineEdit()->setText(value); +} + +/*! + \brief This function is used to determine whether input is valid. + \return validating operation result +*/ +SalomeApp_DoubleSpinBox::State SalomeApp_DoubleSpinBox::isValid( const QString& text, double& value ) const +{ + SearchState aSearchState = findVariable( text, value ); + if( aSearchState == NotFound ) + { + bool ok = false; + value = text.toDouble( &ok ); + if( !ok ) + return NoVariable; + } + else if( aSearchState == IncorrectType ) + return Incompatible; + + if( !checkRange( value ) ) + return Invalid; + + return Acceptable; +} + +/*! + \brief This function return a default acceptable value (commonly, 0.0). + \return default acceptable value +*/ +double SalomeApp_DoubleSpinBox::defaultValue() const +{ + if( myMinimum > myDefaultValue || myMaximum < myDefaultValue ) + return myMinimum; + + return myDefaultValue; +} + +/*! + \brief This function is used to check that string value lies within predefined range. + \return check status +*/ +bool SalomeApp_DoubleSpinBox::checkRange( const double value ) const +{ + if( !myIsRangeSet ) + return true; + + return value >= myMinimum && value <= myMaximum; +} + +/*! + \brief This function is used to determine whether input is a variable name and to get its value. + \return status of search operation +*/ +SalomeApp_DoubleSpinBox::SearchState SalomeApp_DoubleSpinBox::findVariable( const QString& name, double& value ) const +{ + value = 0; + if( SalomeApp_Application* app = dynamic_cast( SUIT_Session::session()->activeApplication() ) ) + { + if( SalomeApp_Study* study = dynamic_cast( app->activeStudy() ) ) + { + _PTR(Study) studyDS = study->studyDS(); + + std::string aName = name.toStdString(); + if( studyDS->IsVariable( aName ) ) + { + if( studyDS->IsReal( aName ) || studyDS->IsInteger( aName ) ) + { + value = studyDS->GetReal( aName ); + return Found; + } + return IncorrectType; + } + } + } + return NotFound; +} + +/*! + \brief This function is called when the spinbox recieves key press event. +*/ +void SalomeApp_DoubleSpinBox::keyPressEvent( QKeyEvent* e ) +{ + if ( e->key() == Qt::Key_Return || e->key() == Qt::Key_Enter ) + QWidget::keyPressEvent( e ); + else + QtxDoubleSpinBox::keyPressEvent( e ); +} + +/*! + \brief This function is called when the spinbox recieves show event. +*/ +void SalomeApp_DoubleSpinBox::showEvent( QShowEvent* ) +{ + setText( myTextValue ); +} diff --git a/src/SalomeApp/SalomeApp_DoubleSpinBox.h b/src/SalomeApp/SalomeApp_DoubleSpinBox.h new file mode 100644 index 000000000..c5b6539ca --- /dev/null +++ b/src/SalomeApp/SalomeApp_DoubleSpinBox.h @@ -0,0 +1,91 @@ +// 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/ or email : webmaster.salome@opencascade.com +// +// File: SalomeApp_DoubleSpinBox.h +// Author: Oleg UVAROV + +#ifndef SALOMEAPP_DOUBLESPINBOX_H +#define SALOMEAPP_DOUBLESPINBOX_H + +#include "SalomeApp.h" + +#include + +#include + +class SALOMEAPP_EXPORT SalomeApp_DoubleSpinBox : public QtxDoubleSpinBox +{ + Q_OBJECT + + enum State { Invalid = 0, NoVariable, Incompatible, Acceptable }; + enum SearchState { NotFound = 0, IncorrectType, Found }; + +public: + SalomeApp_DoubleSpinBox( QWidget* = 0 ); + SalomeApp_DoubleSpinBox( double, double, double = 1, QWidget* = 0 ); + SalomeApp_DoubleSpinBox( double, double, double, int, int, QWidget* = 0 ); + virtual ~SalomeApp_DoubleSpinBox(); + + virtual double valueFromText( const QString& ) const; + virtual QString textFromValue( double ) const; + + virtual QValidator::State validate( QString&, int& ) const; + + virtual bool isValid( QString& msg, bool = false ); + + virtual void setDefaultValue( const double ); + + virtual void setRange( double, double ); + virtual void setValue( double ); + + virtual void setText(const QString& ); + +signals: + void textChanged( const QString& ); + +protected: + State isValid( const QString&, double& ) const; + + double defaultValue() const; + bool checkRange( const double ) const; + + SearchState findVariable( const QString&, double& ) const; + +protected: + virtual void keyPressEvent( QKeyEvent* ); + virtual void showEvent( QShowEvent* ); + +protected slots: + void onEditingFinished(); + void onTextChanged( const QString& ); + +private: + void connectSignalsAndSlots(); + +private: + double myDefaultValue; + + bool myIsRangeSet; + double myMinimum; + double myMaximum; + + QString myCorrectValue; + QString myTextValue; +}; + +#endif diff --git a/src/SalomeApp/SalomeApp_IntSpinBox.cxx b/src/SalomeApp/SalomeApp_IntSpinBox.cxx new file mode 100644 index 000000000..4d3460a3b --- /dev/null +++ b/src/SalomeApp/SalomeApp_IntSpinBox.cxx @@ -0,0 +1,310 @@ +// 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/ or email : webmaster.salome@opencascade.com +// +// File: SalomeApp_IntSpinBox.cxx +// Author: Oleg UVAROV + +#include "SalomeApp_IntSpinBox.h" +#include "SalomeApp_Application.h" +#include "SalomeApp_Study.h" + +#include + +#include "SALOMEDSClient_ClientFactory.hxx" +#include CORBA_SERVER_HEADER(SALOMEDS) + +#include +#include + +/*! + \class SalomeApp_IntSpinBox +*/ + +/*! + \brief Constructor. + + Constructs a spin box with 0 as minimum value and 99 as maximum value, + a step value of 1. The value is initially set to 0. + + \param parent parent object +*/ +SalomeApp_IntSpinBox::SalomeApp_IntSpinBox( QWidget* parent ) +: QtxIntSpinBox( parent ), + myDefaultValue( 0 ) +{ + connectSignalsAndSlots(); +} + +/*! + \brief Constructor. + + Constructs a spin box with specified minimum, maximum and step value. + The value is initially set to the minimum value. + + \param min spin box minimum possible value + \param max spin box maximum possible value + \param step spin box increment/decrement value + \param parent parent object +*/ +SalomeApp_IntSpinBox::SalomeApp_IntSpinBox( int min, int max, int step, QWidget* parent ) +: QtxIntSpinBox( min, max, step, parent ), + myDefaultValue( 0 ) +{ + connectSignalsAndSlots(); +} + +/*! + \brief Destructor. +*/ +SalomeApp_IntSpinBox::~SalomeApp_IntSpinBox() +{ +} + +/*! + \brief Connect signals and slots. +*/ +void SalomeApp_IntSpinBox::connectSignalsAndSlots() +{ + connect( this, SIGNAL( editingFinished() ), + this, SLOT( onEditingFinished() ) ); + + connect( this, SIGNAL( valueChanged( const QString& ) ), + this, SLOT( onTextChanged( const QString& ) ) ); + + connect( lineEdit(), SIGNAL( textChanged( const QString& ) ), + this, SLOT( onTextChanged( const QString& ) ) ); + + connect( lineEdit(), SIGNAL( textChanged( const QString& )), + this, SIGNAL( textChanged( const QString& ) ) ); +} + +/*! + \brief This function is called when editing is finished. +*/ +void SalomeApp_IntSpinBox::onEditingFinished() +{ + if( myTextValue.isNull() ) + myTextValue = text(); + + setText( myTextValue ); +} + +/*! + \brief This function is called when value is changed. +*/ +void SalomeApp_IntSpinBox::onTextChanged( const QString& text ) +{ + myTextValue = text; + + int value = 0; + if( isValid( text, value ) == Acceptable ) + myCorrectValue = text; +} + +/*! + \brief Interpret text entered by the user as a value. + \param text text entered by the user + \return mapped value + \sa textFromValue() +*/ +int SalomeApp_IntSpinBox::valueFromText( const QString& text ) const +{ + int value = 0; + if( isValid( text, value ) == Acceptable ) + return value; + + return defaultValue(); +} + +/*! + \brief This function is used by the spin box whenever it needs to display + the given value. + + \param val spin box value + \return text representation of the value + \sa valueFromText() +*/ +QString SalomeApp_IntSpinBox::textFromValue( int val ) const +{ + return QtxIntSpinBox::textFromValue( val ); +} + +/*! + \brief This function is used to determine whether input is valid. + \param str currently entered value + \param pos cursor position in the string + \return validating operation result +*/ +QValidator::State SalomeApp_IntSpinBox::validate( QString& str, int& pos ) const +{ + return QValidator::Acceptable; +} + +/*! + \brief This function is used to determine whether input is valid. + \return validating operation result +*/ +bool SalomeApp_IntSpinBox::isValid( QString& msg, bool toCorrect ) +{ + int value; + State aState = isValid( text(), value ); + + if( aState != Acceptable ) + { + if( toCorrect ) + { + if( aState == Incompatible ) + msg += tr( "ERR_INCOMPATIBLE_TYPE" ).arg( text() ) + "\n"; + else if( aState == NoVariable ) + msg += tr( "ERR_NO_VARIABLE" ).arg( text() ) + "\n"; + else if( aState == Invalid ) + msg += tr( "ERR_INVALID_VALUE" ) + "\n"; + + setText( myCorrectValue ); + } + return false; + } + + return true; +} + +/*! + \brief This function is used to set a default value for this spinbox. + \param value default value +*/ +void SalomeApp_IntSpinBox::setDefaultValue( const int value ) +{ + myDefaultValue = value; +} + +/*! + \brief This function is used to set a current value for this spinbox. + \param value current value +*/ +void SalomeApp_IntSpinBox::setValue( const int value ) +{ + QtxIntSpinBox::setValue( value ); + + myCorrectValue = QString::number( value ); + myTextValue = myCorrectValue; +} + +/*! + \brief This function is used to set a text for this spinbox. + \param value current value +*/ +void SalomeApp_IntSpinBox::setText( const QString& value ) +{ + lineEdit()->setText(value); +} + +/*! + \brief This function is used to determine whether input is valid. + \return validating operation result +*/ +SalomeApp_IntSpinBox::State SalomeApp_IntSpinBox::isValid( const QString& text, int& value ) const +{ + SearchState aSearchState = findVariable( text, value ); + if( aSearchState == NotFound ) + { + bool ok = false; + value = text.toInt( &ok ); + if( !ok ) + { + text.toDouble( &ok ); + if( ok ) + return Invalid; + return NoVariable; + } + } + else if( aSearchState == IncorrectType ) + return Incompatible; + + if( !checkRange( value ) ) + return Invalid; + + return Acceptable; +} + +/*! + \brief This function return a default acceptable value (commonly, 0). + \return default acceptable value +*/ +int SalomeApp_IntSpinBox::defaultValue() const +{ + if( minimum() > myDefaultValue || maximum() < myDefaultValue ) + return minimum(); + + return myDefaultValue; +} + +/*! + \brief This function is used to check that string value lies within predefined range. + \return check status +*/ +bool SalomeApp_IntSpinBox::checkRange( const int value ) const +{ + return value >= minimum() && value <= maximum(); +} + +/*! + \brief This function is used to determine whether input is a variable name and to get its value. + \return status of search operation +*/ +SalomeApp_IntSpinBox::SearchState SalomeApp_IntSpinBox::findVariable( const QString& name, int& value ) const +{ + value = 0; + if( SalomeApp_Application* app = dynamic_cast( SUIT_Session::session()->activeApplication() ) ) + { + if( SalomeApp_Study* study = dynamic_cast( app->activeStudy() ) ) + { + _PTR(Study) studyDS = study->studyDS(); + + std::string aName = name.toStdString(); + if( studyDS->IsVariable( aName ) ) + { + if( studyDS->IsInteger( aName ) ) + { + value = studyDS->GetInteger( aName ); + return Found; + } + return IncorrectType; + } + } + } + return NotFound; +} + +/*! + \brief This function is called when the spinbox recieves key press event. +*/ +void SalomeApp_IntSpinBox::keyPressEvent( QKeyEvent* e ) +{ + if ( e->key() == Qt::Key_Return || e->key() == Qt::Key_Enter ) + QWidget::keyPressEvent( e ); + else + QtxIntSpinBox::keyPressEvent( e ); +} + +/*! + \brief This function is called when the spinbox recieves show event. +*/ +void SalomeApp_IntSpinBox::showEvent( QShowEvent* ) +{ + setText( myTextValue ); +} diff --git a/src/SalomeApp/SalomeApp_IntSpinBox.h b/src/SalomeApp/SalomeApp_IntSpinBox.h new file mode 100644 index 000000000..d15fe99c1 --- /dev/null +++ b/src/SalomeApp/SalomeApp_IntSpinBox.h @@ -0,0 +1,85 @@ +// 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/ or email : webmaster.salome@opencascade.com +// +// File: SalomeApp_IntSpinBox.h +// Author: Oleg UVAROV + +#ifndef SALOMEAPP_INTSPINBOX_H +#define SALOMEAPP_INTSPINBOX_H + +#include "SalomeApp.h" + +#include + +#include + +class SALOMEAPP_EXPORT SalomeApp_IntSpinBox : public QtxIntSpinBox +{ + Q_OBJECT + + enum State { Invalid = 0, NoVariable, Incompatible, Acceptable }; + enum SearchState { NotFound = 0, IncorrectType, Found }; + +public: + SalomeApp_IntSpinBox( QWidget* = 0 ); + SalomeApp_IntSpinBox( int, int, int = 1, QWidget* = 0 ); + virtual ~SalomeApp_IntSpinBox(); + + virtual int valueFromText( const QString& ) const; + virtual QString textFromValue( int ) const; + + virtual QValidator::State validate( QString&, int& ) const; + + virtual bool isValid( QString& msg, bool = false ); + + virtual void setDefaultValue( const int ); + + virtual void setValue( int ); + + virtual void setText(const QString& ); + +signals: + void textChanged( const QString& ); + +protected: + State isValid( const QString&, int& ) const; + + int defaultValue() const; + bool checkRange( const int ) const; + + SearchState findVariable( const QString&, int& ) const; + +protected: + virtual void keyPressEvent( QKeyEvent* ); + virtual void showEvent( QShowEvent* ); + +protected slots: + void onEditingFinished(); + void onTextChanged( const QString& ); + +private: + void connectSignalsAndSlots(); + +private: + int myDefaultValue; + + QString myCorrectValue; + QString myTextValue; +}; + +#endif diff --git a/src/SalomeApp/SalomeApp_NoteBookDlg.cxx b/src/SalomeApp/SalomeApp_NoteBookDlg.cxx new file mode 100644 index 000000000..6005d889a --- /dev/null +++ b/src/SalomeApp/SalomeApp_NoteBookDlg.cxx @@ -0,0 +1,1082 @@ +// Copyright (C) 2008 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/ or email : webmaster.salome@opencascade.com +// +// File: SalomeApp_NoteBookDlg.cxx +// Author : Roman NIKOLAEV, Open CASCADE S.A.S. +// Module : GUI + +#include "SalomeApp_NoteBookDlg.h" +#include "SalomeApp_Application.h" +#include "SalomeApp_Study.h" +#include "SalomeApp_VisualState.h" + +#include + +#include + +#include +#include +#include +#include + +#include + +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include + +using namespace std; + +#define DEFAULT_MARGIN 11 +#define DEFAULT_SPACING 6 +#define SPACER_SIZE 120 +#define COLUMN_SIZE 180 + +#define NAME_COLUMN 0 +#define VALUE_COLUMN 1 + + +/////////////////////////////////////////////////////////////////////////// +// NoteBook_TableRow class // +/////////////////////////////////////////////////////////////////////////// +//============================================================================ +/*! Function : NoteBook_TableRow + * Purpose : Constructor + */ +//============================================================================ +NoteBook_TableRow::NoteBook_TableRow(int index, QWidget* parent): + QWidget(parent), + myIndex(index), + myRowHeader(new QTableWidgetItem()), + myVariableName(new QTableWidgetItem()), + myVariableValue(new QTableWidgetItem()) +{ +} + +//============================================================================ +/*! Function : ~NoteBook_TableRow + * Purpose : Destructor + */ +//============================================================================ +NoteBook_TableRow::~NoteBook_TableRow() +{ +} + +//============================================================================ +/*! Function : AddToTable + * Purpose : Add this row to the table theTable + */ +//============================================================================ +void NoteBook_TableRow::AddToTable(QTableWidget *theTable) +{ + int aPosition = theTable->rowCount(); + int aRowCount = aPosition+1; + theTable->setRowCount(aRowCount); + myRowHeader->setText(QString::number(aRowCount)); + + theTable->setVerticalHeaderItem(aPosition,myRowHeader); + theTable->setItem(aPosition, NAME_COLUMN, myVariableName); + theTable->setItem(aPosition, VALUE_COLUMN, myVariableValue); +} + +//============================================================================ +/*! Function : SetName + * Purpose : + */ +//============================================================================ +void NoteBook_TableRow::SetName(const QString theName) +{ + myVariableName->setText(theName); +} + +//============================================================================ +/*! Function : SetValue + * Purpose : + */ +//============================================================================ +void NoteBook_TableRow::SetValue(const QString theValue) +{ + myVariableValue->setText(theValue); +} + +//============================================================================ +/*! Function : GetName + * Purpose : Return variable name + */ +//============================================================================ +QString NoteBook_TableRow::GetName() const +{ + return myVariableName->text(); +} + +//============================================================================ +/*! Function : GetValue + * Purpose : Return variable value + */ +//============================================================================ +QString NoteBook_TableRow::GetValue() const +{ + return myVariableValue->text(); +} + +//============================================================================ +/*! Function : CheckName + * Purpose : Return true if variable name correct, otherwise return false + */ +//============================================================================ +bool NoteBook_TableRow::CheckName() +{ + QString aName = GetName(); + int aPos = 0; + QRegExpValidator aValidator( QRegExp("^([a-zA-Z]+)([a-zA-Z0-9_]*)$"), 0 ); + if( aName.isEmpty() || !aValidator.validate( aName, aPos ) ) + return false; + return true; +} + +//============================================================================ +/*! Function : CheckValue + * Purpose : Return true if variable value correct, otherwise return false + */ +//============================================================================ +bool NoteBook_TableRow::CheckValue() +{ + bool aResult = false; + QString aValue = GetValue(); + if( (!aValue.isEmpty()) && + (IsRealValue(aValue)) || + IsIntegerValue(aValue)|| + IsBooleanValue(aValue)) + aResult = true; + + return aResult; +} + +//============================================================================ +/*! Function : GetVariableItem + * Purpose : + */ +//============================================================================ +QTableWidgetItem* NoteBook_TableRow::GetVariableItem() +{ + return myVariableValue; +} + +//============================================================================ +/*! Function : GetNameItem + * Purpose : + */ +//============================================================================ +QTableWidgetItem* NoteBook_TableRow::GetNameItem() +{ + return myVariableName; +} + +//============================================================================ +/*! Function : GetHeaderItem + * Purpose : + */ +//============================================================================ +QTableWidgetItem* NoteBook_TableRow::GetHeaderItem() +{ + return myRowHeader; +} + +//============================================================================ +/*! Function : IsRealValue + * Purpose : Return true if theValue string is real value, otherwise return + * false + */ +//============================================================================ +bool NoteBook_TableRow::IsRealValue(const QString theValue, double* theResult) +{ + bool aResult = false; + double aDResult = theValue.toDouble(&aResult); + if(theResult) + *theResult = aDResult; + + return aResult; +} + +//============================================================================ +/*! Function : IsBooleanValue + * Purpose : Return true if theValue String is boolean value, otherwise return + * false + */ +//============================================================================ +bool NoteBook_TableRow::IsBooleanValue(const QString theValue, bool* theResult){ + bool aResult = false; + bool aBResult; + if(theValue.compare("True") == 0) { + aBResult = true; + aResult = true; + } + else if(theValue.compare("False") == 0) { + aBResult = false; + aResult = true; + } + if(theResult) + *theResult = aBResult; + + return aResult; +} + +//============================================================================ +/*! Function : IsIntegerValue + * Purpose : Return true if theValue string is integer value, otherwise return + * false + */ +//============================================================================ +bool NoteBook_TableRow::IsIntegerValue(const QString theValue, int* theResult) +{ + bool aResult = false; + int anIResult; + anIResult = theValue.toInt(&aResult); + + if(theResult) + *theResult = anIResult; + + return aResult; +} + + +/////////////////////////////////////////////////////////////////////////// +// NoteBook_Table class // +/////////////////////////////////////////////////////////////////////////// +//============================================================================ +/*! Function : NoteBook_Table + * Purpose : Constructor + */ +//============================================================================ +NoteBook_Table::NoteBook_Table(QWidget * parent) + :QTableWidget(parent), + isProcessItemChangedSignal(false), + myIsModified(false) +{ + setColumnCount(2); + setSelectionMode(QAbstractItemView::SingleSelection); + + //Add Headers Columns + QFont aFont = QFont(); + aFont.setBold(true); + aFont.setPointSize(10); + + //"Name" column + QTableWidgetItem * aNameHeader = new QTableWidgetItem(); + aNameHeader->setText(tr("VARNAME_COLUMN")); + aNameHeader->setFont(aFont); + setHorizontalHeaderItem(0,aNameHeader); + setColumnWidth ( 0, COLUMN_SIZE); + + //"Value" Column + QTableWidgetItem * aValueHeader = new QTableWidgetItem(); + aValueHeader->setText(tr("VARVALUE_COLUMN")); + aValueHeader->setFont(aFont); + setHorizontalHeaderItem(1,aValueHeader); + setColumnWidth ( 1, COLUMN_SIZE); + setSortingEnabled(false); + + connect(this,SIGNAL(itemChanged(QTableWidgetItem*)),this,SLOT(onItemChanged(QTableWidgetItem*))); +} + +//============================================================================ +/*! Function : ~NoteBook_Table + * Purpose : Destructor + */ +//============================================================================ +NoteBook_Table::~NoteBook_Table(){} + +//============================================================================ +/*! Function : getUniqueIndex + * Purpose : Get a unique index for the new row + */ +//============================================================================ +int NoteBook_Table::getUniqueIndex() const +{ + int anIndex = 0; + if( !myRows.isEmpty() ) + if( NoteBook_TableRow* aRow = myRows.last() ) + anIndex = aRow->GetIndex(); + + int aMaxRemovedRow = 0; + for( QListIterator anIter( myRemovedRows ); anIter.hasNext(); ) + { + int aRemovedRow = anIter.next(); + aMaxRemovedRow = qMax( aRemovedRow, aMaxRemovedRow ); + } + + anIndex = qMax( anIndex, aMaxRemovedRow ) + 1; + return anIndex; +} + +//============================================================================ +/*! Function : Init + * Purpose : Add variables in the table from theStudy + */ +//============================================================================ +void NoteBook_Table::Init(_PTR(Study) theStudy) +{ + isProcessItemChangedSignal = false; + + int aNumRows = myRows.count(); + if( aNumRows > 0 ) + { + for( int i = 0; i < myRows.size(); i++ ) + { + NoteBook_TableRow* aRow = myRows[ i ]; + if( aRow ) + { + delete aRow; + aRow = 0; + } + } + myRows.clear(); + } + setRowCount( 0 ); + + myRemovedRows.clear(); + myVariableMapRef.clear(); + myVariableMap.clear(); + + //Add all variables into the table + vector aVariables = theStudy->GetVariableNames(); + for(int iVar = 0; iVar < aVariables.size(); iVar++ ) { + AddRow(QString(aVariables[iVar].c_str()), + Variable2String(aVariables[iVar],theStudy)); + } + + //Add empty row + AddEmptyRow(); + isProcessItemChangedSignal = true; + + ResetMaps(); + + myStudy = theStudy; +} + +//============================================================================ +/*! Function : Variable2String + * Purpose : Convert variable values to QString + */ +//============================================================================ +QString NoteBook_Table::Variable2String(const string& theVarName, + _PTR(Study) theStudy) +{ + QString aResult; + if( theStudy->IsReal(theVarName) ) + aResult = QString::number(theStudy->GetReal(theVarName)); + else if( theStudy->IsInteger(theVarName) ) + aResult = QString::number(theStudy->GetInteger(theVarName)); + else if( theStudy->IsBoolean(theVarName) ) + aResult = theStudy->GetBoolean(theVarName) ? QString("True") : QString("False"); + + return aResult; +} + +//============================================================================ +/*! Function : IsValid + * Purpose : Check validity of the table data + */ +//============================================================================ +bool NoteBook_Table::IsValid() const +{ + int aNumRows = myRows.count(); + if( aNumRows == 0 ) + return true; + + bool aLastRowIsEmpty = myRows[ aNumRows - 1 ]->GetName().isEmpty() && + myRows[ aNumRows - 1 ]->GetValue().isEmpty(); + + for( int i = 0, n = aLastRowIsEmpty ? aNumRows - 1 : aNumRows; i < n; i++ ) + if( !myRows[i]->CheckName() || !IsUniqueName( myRows[i] ) || !myRows[i]->CheckValue() ) + return false; + + return true; +} + +//============================================================================ +/*! Function : RenamberRowItems + * Purpose : renumber row items + */ +//============================================================================ +void NoteBook_Table::RenamberRowItems(){ + for(int i=0; iGetHeaderItem()->setText(QString::number(i+1)); + } +} + +//============================================================================ +/*! Function : AddRow + * Purpose : Add a row into the table + */ +//============================================================================ +void NoteBook_Table::AddRow(const QString& theName, const QString& theValue) +{ + int anIndex = getUniqueIndex(); + NoteBook_TableRow* aRow = new NoteBook_TableRow(anIndex, this); + aRow->SetName(theName); + aRow->SetValue(theValue); + aRow->AddToTable(this); + myRows.append(aRow); + + myVariableMap.insert( anIndex, NoteBoox_Variable( theName, theValue ) ); +} + +//============================================================================ +/*! Function : AddEmptyRow + * Purpose : Add an empty row into the end of the table + */ +//============================================================================ +void NoteBook_Table::AddEmptyRow() +{ + isProcessItemChangedSignal = false; + AddRow(); + isProcessItemChangedSignal = true; +} + +//============================================================================ +/*! Function : GetRowByItem + * Purpose : + */ +//============================================================================ +NoteBook_TableRow* NoteBook_Table::GetRowByItem(const QTableWidgetItem* theItem) const +{ + int aCurrentRow = row(theItem); + + if( (myRows.size() <= aCurrentRow ) && (aCurrentRow < 0)) + return NULL; + else + return myRows.at(aCurrentRow); +} + +//============================================================================ +/*! Function : IsLastRow + * Purpose : Return true if theRow is last row in the table + */ +//============================================================================ +bool NoteBook_Table::IsLastRow(const NoteBook_TableRow* theRow) const +{ + return (myRows.last() == theRow); +} + +//============================================================================ +/*! Function : onItemChanged + * Purpose : [slot] called then table item changed + */ +//============================================================================ +void NoteBook_Table::onItemChanged(QTableWidgetItem* theItem) +{ + if(isProcessItemChangedSignal) { + bool isModified = true; + NoteBook_TableRow* aRow = GetRowByItem(theItem); + if(aRow) { + int aCurrentColumn = column(theItem); + bool IsCorrect = true, IsVariableComplited = false; + QString aMsg; + + if(aCurrentColumn == NAME_COLUMN) { + int anIndex = aRow->GetIndex(); + if( myVariableMap.contains( anIndex ) ) + { + const NoteBoox_Variable& aVariable = myVariableMap[ anIndex ]; + if( !aVariable.Name.isEmpty() && myStudy->IsVariableUsed( string( aVariable.Name.toLatin1().constData() ) ) ) + { + if( QMessageBox::warning( parentWidget(), tr( "WARNING" ), + tr( "RENAME_VARIABLE_IS_USED" ).arg( aVariable.Name ), + QMessageBox::Yes, QMessageBox::No ) == QMessageBox::No ) + { + bool isBlocked = blockSignals( true ); + aRow->SetName( aVariable.Name ); + blockSignals( isBlocked ); + return; + } + } + } + } + + //Case then varible name changed. + if(aCurrentColumn == NAME_COLUMN) { + if(!aRow->CheckName()) { + IsCorrect = false; + aMsg = tr( "VARNAME_INCORRECT" ).arg(aRow->GetName()); + } + else if(!IsUniqueName(aRow)) { + IsCorrect = false; + aMsg = tr( "VARNAME_EXISTS" ).arg(aRow->GetName()); + } + else + IsVariableComplited = aRow->CheckValue(); + } + + //Case then varible value changed. + else if(aCurrentColumn == VALUE_COLUMN){ + if(!aRow->CheckValue()) { + IsCorrect = false; + aMsg = tr( "VARVALUE_INCORRECT" ).arg(aRow->GetName()); + } + else + IsVariableComplited = aRow->CheckName() && IsUniqueName(aRow); + } + + if(!IsCorrect && !aMsg.isEmpty()) + SUIT_MessageBox::warning( parentWidget(), tr( "WARNING" ), aMsg ); + + bool isBlocked = blockSignals( true ); + theItem->setForeground( QBrush( IsCorrect ? Qt::black : Qt::red ) ); + blockSignals( isBlocked ); + + int anIndex = aRow->GetIndex(); + if( myVariableMap.contains( anIndex ) ) + { + NoteBoox_Variable& aVariable = myVariableMap[ anIndex ]; + if( aVariable.Name.compare( aRow->GetName() ) != 0 || + aVariable.Value.compare( aRow->GetValue() ) != 0 ) + { + aVariable.Name = aRow->GetName(); + aVariable.Value = aRow->GetValue(); + } + else + isModified = false; + } + + if(IsCorrect && IsVariableComplited && IsLastRow(aRow)) + AddEmptyRow(); + } + + if( !myIsModified ) + myIsModified = isModified; + } +} + +//============================================================================ +/*! Function : IsUniqueName + * Purpose : Return true if theName is unique name of the Variable + */ +//============================================================================ +bool NoteBook_Table::IsUniqueName(const NoteBook_TableRow* theRow) const +{ + for(int i=0; iGetName().compare(theRow->GetName()) == 0) + return false; + } + return true; +} + +//============================================================================ +/*! Function : RemoveSelected + * Purpose : Remove selected rows in the table + */ +//============================================================================ +void NoteBook_Table::RemoveSelected() +{ + isProcessItemChangedSignal = false; + QList aSelectedItems = selectedItems(); + if( !(aSelectedItems.size() > 0)) { + isProcessItemChangedSignal = true; + return; + } + bool removedFromStudy = false; + for(int i=0; i < aSelectedItems.size(); i++ ) { + NoteBook_TableRow* aRow = GetRowByItem(aSelectedItems[i]); + if(aRow) { + if(IsLastRow(aRow)) { + aRow->SetName(QString()); + aRow->SetValue(QString()); + } + else { + int nRow = row(aSelectedItems[i]); + + if( myStudy->IsVariableUsed( string( aRow->GetName().toLatin1().constData() ) ) ) + { + if( QMessageBox::warning( parentWidget(), tr( "WARNING" ), + tr( "REMOVE_VARIABLE_IS_USED" ).arg( aRow->GetName() ), + QMessageBox::Yes, QMessageBox::No ) == QMessageBox::No ) + { + isProcessItemChangedSignal = true; + return; + } + } + + int index = aRow->GetIndex(); + QString aVarName = aRow->GetName(); + myRemovedRows.append( index ); + if( myVariableMap.contains( index ) ) + myVariableMap.remove( index ); + removeRow(nRow); + myRows.removeAt(nRow); + if(myStudy->IsVariable(aVarName.toLatin1().constData())) + removedFromStudy = true; + } + } + } + if(removedFromStudy) + myIsModified = true; + RenamberRowItems(); + isProcessItemChangedSignal = true; +} + +//============================================================================ +/*! Function : SetProcessItemChangedSignalFlag + * Purpose : + */ +//============================================================================ +void NoteBook_Table::SetProcessItemChangedSignalFlag(const bool enable) +{ + isProcessItemChangedSignal = enable; +} + +//============================================================================ +/*! Function : GetProcessItemChangedSignalFlag + * Purpose : + */ +//============================================================================ +bool NoteBook_Table::GetProcessItemChangedSignalFlag() const +{ + return isProcessItemChangedSignal; +} + +//============================================================================ +/*! Function : GetRows + * Purpose : + */ +//============================================================================ +QList NoteBook_Table::GetRows() const +{ + return myRows; +} + +//============================================================================ +/*! Function : ResetMaps + * Purpose : Reset variable maps + */ +//============================================================================ +void NoteBook_Table::ResetMaps() +{ + myIsModified = false; + myVariableMapRef = myVariableMap; + myRemovedRows.clear(); +} + +/////////////////////////////////////////////////////////////////////////// +// SalomeApp_NoteBookDlg class // +/////////////////////////////////////////////////////////////////////////// +//============================================================================ +/*! Function : SalomeApp_NoteBookDlg + * Purpose : Constructor + */ +//============================================================================ +SalomeApp_NoteBookDlg::SalomeApp_NoteBookDlg(QWidget * parent, _PTR(Study) theStudy): + QDialog(parent, Qt::WindowTitleHint | Qt::WindowSystemMenuHint), + myStudy(theStudy) +{ + setModal(false); + setObjectName("SalomeApp_NoteBookDlg"); + setWindowTitle(tr("NOTEBOOK_TITLE")); + QGridLayout* aLayout = new QGridLayout(this); + aLayout->setMargin(DEFAULT_MARGIN); + aLayout->setSpacing(DEFAULT_SPACING); + + //Table + myTable = new NoteBook_Table(this); + aLayout->addWidget(myTable, 0, 0, 1, 3); + + //Buttons + myRemoveButton = new QPushButton(tr("BUT_REMOVE")); + aLayout->addWidget(myRemoveButton, 1, 0, 1, 1); + + QSpacerItem* spacer = + new QSpacerItem(DEFAULT_SPACING, 5 , QSizePolicy::Expanding, QSizePolicy::Minimum); + aLayout->addItem(spacer, 1, 1, 2, 1); + + myUpdateStudyBtn = new QPushButton(tr("BUT_UPDATE_STUDY")); + aLayout->addWidget(myUpdateStudyBtn, 1, 2, 1, 1); + + QGroupBox* groupBox = new QGroupBox(this); + + QGridLayout* aLayout1 = new QGridLayout(groupBox); + + aLayout1->setMargin(DEFAULT_MARGIN); + aLayout1->setSpacing(DEFAULT_SPACING); + + myOkBtn = new QPushButton(tr("BUT_APPLY_AND_CLOSE")); + aLayout1->addWidget(myOkBtn, 0, 0, 1, 1); + + myApplyBtn = new QPushButton(tr("BUT_APPLY")); + aLayout1->addWidget(myApplyBtn, 0, 1, 1, 1); + + QSpacerItem* spacer1 = + new QSpacerItem(DEFAULT_SPACING, 5, QSizePolicy::Expanding, QSizePolicy::Minimum); + aLayout1->addItem(spacer1, 0, 2, 1, 1); + + myCancelBtn = new QPushButton(tr("BUT_CLOSE")); + aLayout1->addWidget(myCancelBtn, 0, 3, 1, 1); + + myHelpBtn = new QPushButton(tr("BUT_HELP")); + aLayout1->addWidget(myHelpBtn, 0, 4, 1, 1); + + aLayout->addWidget(groupBox, 2, 0, 1, 3); + + QWidgetList aWidgetList; + aWidgetList.append( myTable ); + aWidgetList.append( myOkBtn ); + aWidgetList.append( myApplyBtn ); + aWidgetList.append( myCancelBtn ); + aWidgetList.append( myHelpBtn ); + aWidgetList.append( myUpdateStudyBtn ); + aWidgetList.append( myRemoveButton ); + Qtx::setTabOrder( aWidgetList ); + + connect( myOkBtn, SIGNAL(clicked()), this, SLOT(onOK()) ); + connect( myApplyBtn, SIGNAL(clicked()), this, SLOT(onApply()) ); + connect( myCancelBtn, SIGNAL(clicked()), this, SLOT(onCancel()) ); + connect( myUpdateStudyBtn, SIGNAL(clicked()), this, SLOT(onUpdateStudy()) ); + connect( myRemoveButton, SIGNAL(clicked()), this, SLOT(onRemove())); + connect( myHelpBtn, SIGNAL(clicked()), this, SLOT(onHelp())); + + myTable->Init(myStudy); +} + +//============================================================================ +/*! Function : ~SalomeApp_NoteBookDlg + * Purpose : Destructor + */ +//============================================================================ +SalomeApp_NoteBookDlg::~SalomeApp_NoteBookDlg(){} + + +//============================================================================ +/*! Function : Init() + * Purpose : init variable table + */ +//============================================================================ +void SalomeApp_NoteBookDlg::Init(_PTR(Study) theStudy){ + if(myStudy!= theStudy) + myStudy = theStudy; + myTable->Init(myStudy); +} + + +//============================================================================ +/*! Function : onOK + * Purpose : [slot] + */ +//============================================================================ +void SalomeApp_NoteBookDlg::onOK() +{ + onApply(); + if( myTable->IsValid() ) + accept(); +} + +//============================================================================ +/*! Function : onHelp + * Purpose : [slot] + */ +//============================================================================ +void SalomeApp_NoteBookDlg::onHelp() +{ + QString aHelpFileName("using_notebook.html"); + LightApp_Application* app = (LightApp_Application*)(SUIT_Session::session()->activeApplication()); + if (app) + app->onHelpContextModule("GUI",aHelpFileName); + else { + QString platform; +#ifdef WIN32 + platform = "winapplication"; +#else + platform = "application"; +#endif + SUIT_MessageBox::warning(this, tr("WRN_WARNING"), + tr("EXTERNAL_BROWSER_CANNOT_SHOW_PAGE"). + arg(app->resourceMgr()->stringValue("ExternalBrowser", + platform)). + arg(aHelpFileName)); + } + +} +//============================================================================ +/*! Function : onApply + * Purpose : [slot] + */ +//============================================================================ +void SalomeApp_NoteBookDlg::onApply() +{ + if( !myTable->IsValid() ) + { + SUIT_MessageBox::warning( this, tr( "WARNING" ), tr( "INCORRECT_DATA" ) ); + return; + } + + double aDVal; + int anIVal; + bool aBVal; + + const QList& aRemovedRows = myTable->GetRemovedRows(); + const VariableMap& aVariableMap = myTable->GetVariableMap(); + const VariableMap& aVariableMapRef = myTable->GetVariableMapRef(); + + for( QListIterator anIter( aRemovedRows ); anIter.hasNext(); ) + { + int anIndex = anIter.next(); + if( aVariableMapRef.contains( anIndex ) ) + { + QString aRemovedVariable = aVariableMapRef[ anIndex ].Name; + myStudy->RemoveVariable( string( aRemovedVariable.toLatin1().constData() ) ); + } + } + + VariableMap::const_iterator it = aVariableMap.constBegin(), itEnd = aVariableMap.constEnd(); + for( ; it != itEnd; ++it ) + { + int anIndex = it.key(); + const NoteBoox_Variable& aVariable = it.value(); + QString aName = aVariable.Name; + QString aValue = aVariable.Value; + + if( !aName.isEmpty() && !aValue.isEmpty() ) + { + if( aVariableMapRef.contains( anIndex ) ) + { + const NoteBoox_Variable& aVariableRef = aVariableMapRef[ anIndex ]; + QString aNameRef = aVariableRef.Name; + QString aValueRef = aVariableRef.Value; + + if( !aNameRef.isEmpty() && !aValueRef.isEmpty() && aNameRef != aName ) + { + myStudy->RenameVariable( string( aNameRef.toLatin1().constData() ), + string( aName.toLatin1().constData() ) ); + } + } + + if( NoteBook_TableRow::IsIntegerValue(aValue,&anIVal) ) + myStudy->SetInteger(string(aName.toLatin1().constData()),anIVal); + + else if( NoteBook_TableRow::IsRealValue(aValue,&aDVal) ) + myStudy->SetReal(string(aName.toLatin1().constData()),aDVal); + + else if( NoteBook_TableRow::IsBooleanValue(aValue,&aBVal) ) + myStudy->SetBoolean(string(aName.toLatin1().constData()),aBVal); + } + } + myTable->ResetMaps(); + + SalomeApp_Application* app = dynamic_cast( SUIT_Session::session()->activeApplication() ); + if(app) + app->updateActions(); + +} + +//============================================================================ +/*! Function : onCancel + * Purpose : [slot] + */ +//============================================================================ +void SalomeApp_NoteBookDlg::onCancel() +{ + if( myTable->IsModified() ) + { + int answer = QMessageBox::question( this, tr( "CLOSE_CAPTION" ), tr( "CLOSE_DESCRIPTION" ), + QMessageBox::Yes, QMessageBox::No, QMessageBox::Cancel ); + switch( answer ) + { + case QMessageBox::Yes : onOK(); return; + case QMessageBox::No : break; + case QMessageBox::Cancel : return; + default : break; + } + } + reject(); +} + +//============================================================================ +/*! Function : onRemove + * Purpose : [slot] + */ +//============================================================================ +void SalomeApp_NoteBookDlg::onRemove() +{ + myTable->RemoveSelected(); +} + +//============================================================================ +/*! Function : onUpdateStudy + * Purpose : [slot] + */ +//============================================================================ +void SalomeApp_NoteBookDlg::onUpdateStudy() +{ + onApply(); + if( !myTable->IsValid() ) + return; + + QApplication::setOverrideCursor( Qt::WaitCursor ); + + if( !updateStudy() ) + SUIT_MessageBox::warning( this, tr( "ERROR" ), tr( "ERR_UPDATE_STUDY_FAILED" ) ); + + QApplication::restoreOverrideCursor(); +} + +//============================================================================ +/*! Function : updateStudy + * Purpose : + */ +//============================================================================ +bool SalomeApp_NoteBookDlg::updateStudy() +{ + SalomeApp_Application* app = dynamic_cast( SUIT_Session::session()->activeApplication() ); + if( !app ) + return false; + + SalomeApp_Study* study = dynamic_cast( app->activeStudy() ); + if( !study ) + return false; + + bool isStudySaved = study->isSaved(); + QString aStudyName = study->studyName(); + + _PTR(Study) studyDS = study->studyDS(); + + // get unique temporary directory name + QString aTmpDir = QString::fromStdString( SALOMEDS_Tool::GetTmpDir() ); + if( aTmpDir.isEmpty() ) + return false; + + if( aTmpDir.right( 1 ).compare( QDir::separator() ) == 0 ) + aTmpDir.remove( aTmpDir.length() - 1, 1 ); + + // dump study to the temporary directory + QString aFileName( "notebook" ); + bool toPublish = true; + bool toSaveGUI = true; + + int savePoint; + _PTR(AttributeParameter) ap; + _PTR(IParameters) ip = ClientFactory::getIParameters(ap); + if(ip->isDumpPython(studyDS)) ip->setDumpPython(studyDS); //Unset DumpPython flag. + if ( toSaveGUI ) { //SRN: Store a visual state of the study at the save point for DumpStudy method + ip->setDumpPython(studyDS); + savePoint = SalomeApp_VisualState( app ).storeState(); //SRN: create a temporary save point + } + bool ok = studyDS->DumpStudy( aTmpDir.toStdString(), aFileName.toStdString(), toPublish ); + if ( toSaveGUI ) + study->removeSavePoint(savePoint); //SRN: remove the created temporary save point. + + if( !ok ) + return false; + + // clear a study (delete all objects) + clearStudy(); + + // get active application + app = dynamic_cast( SUIT_Session::session()->activeApplication() ); + + // load study from the temporary directory + QString command = QString( "execfile(\"%1\")" ).arg( aTmpDir + QDir::separator() + aFileName + ".py" ); + + PyConsole_Console* pyConsole = app->pythonConsole(); + if ( pyConsole ) + pyConsole->execAndWait( command ); + + // remove temporary directory + QDir aDir( aTmpDir ); + QStringList aFiles = aDir.entryList( QStringList( "*.py*" ) ); + for( QStringList::iterator it = aFiles.begin(), itEnd = aFiles.end(); it != itEnd; ++it ) + ok = aDir.remove( *it ) && ok; + if( ok ) + ok = aDir.rmdir( aTmpDir ); + + if( SalomeApp_Study* newStudy = dynamic_cast( app->activeStudy() ) ) + { + myStudy = newStudy->studyDS(); + myTable->Init(myStudy); + if(isStudySaved) { + newStudy->markAsSavedIn(aStudyName); + } + } + else + ok = false; + + return ok; +} + +//============================================================================ +/*! Function : clearStudy + * Purpose : + */ +//============================================================================ +void SalomeApp_NoteBookDlg::clearStudy() +{ + SalomeApp_Application* app = dynamic_cast( SUIT_Session::session()->activeApplication() ); + if( !app ) + return; + + QList aList = SUIT_Session::session()->applications(); + int anIndex = aList.indexOf( app ); + + //Store position and size of the this dialog + int aW = width(); + int aH = height(); + int aX = x(); + int aY = y(); + + // Disconnect dialog from application desktop in case if: + // 1) Application is not the first application in the session + // 2) Application is the first application in session but not the only. + bool changeDesktop = ((anIndex > 0) || (anIndex == 0 && aList.count() > 1)); + + if( changeDesktop ) + setParent( 0 ); + + app->onCloseDoc( false ); + + if( anIndex > 0 && anIndex < aList.count() ) + app = dynamic_cast( aList[ anIndex - 1 ] ); + else if(anIndex == 0 && aList.count() > 1) + app = dynamic_cast( aList[ 1 ] ); + + if( !app ) + return; + + app->onNewDoc(); + + app = dynamic_cast( SUIT_Session::session()->activeApplication() ); + if( changeDesktop && app ) { + setParent( app->desktop(), Qt::Dialog ); + app->setNoteBook(this); + } + //Set position and size of the this dialog + resize( aW, aH ); + move( aX, aY ); + show(); +} diff --git a/src/SalomeApp/SalomeApp_NoteBookDlg.h b/src/SalomeApp/SalomeApp_NoteBookDlg.h new file mode 100644 index 000000000..431b50ced --- /dev/null +++ b/src/SalomeApp/SalomeApp_NoteBookDlg.h @@ -0,0 +1,172 @@ +// Copyright (C) 2008 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/ or email : webmaster.salome@opencascade.com +// +// File: SalomeApp_NoteBookDlg.h +// Author : Roman NIKOLAEV, Open CASCADE S.A.S. +// Module : GUI + +#ifndef SALOMEAPP_NOTEBOOKDLG_H +#define SALOMEAPP_NOTEBOOKDLG_H + +#include "SalomeApp.h" + +#include "SALOMEDSClient_ClientFactory.hxx" +#include CORBA_SERVER_HEADER(SALOMEDS) + +#include +#include +#include + +class QWidget; +class QPushButton; +class QTableWidgetItem; + +struct NoteBoox_Variable +{ + NoteBoox_Variable() {} + NoteBoox_Variable( const QString& theName, const QString& theValue ) + { + Name = theName; + Value = theValue; + } + QString Name; + QString Value; +}; + +typedef QMap< int, NoteBoox_Variable > VariableMap; + +class SALOMEAPP_EXPORT NoteBook_TableRow : public QWidget +{ + public: + NoteBook_TableRow(int, QWidget* parent=0); + virtual ~NoteBook_TableRow(); + + int GetIndex() const { return myIndex; } + + void AddToTable(QTableWidget *theTable); + + void SetName(const QString theName); + void SetValue(const QString theValue); + + QString GetValue() const; + QString GetName() const; + + bool CheckName(); + bool CheckValue(); + + QTableWidgetItem* GetVariableItem(); + QTableWidgetItem* GetNameItem(); + QTableWidgetItem* GetHeaderItem(); + + static bool IsRealValue(const QString theValue, double* theResult = 0); + static bool IsIntegerValue(const QString theValue, int* theResult = 0); + static bool IsBooleanValue(const QString theValue, bool* theResult = 0); + + private: + int myIndex; + QTableWidgetItem* myRowHeader; + QTableWidgetItem* myVariableName; + QTableWidgetItem* myVariableValue; +}; + +class SALOMEAPP_EXPORT NoteBook_Table : public QTableWidget +{ + Q_OBJECT + public: + NoteBook_Table(QWidget * parent = 0); + virtual ~NoteBook_Table(); + + void Init(_PTR(Study) theStudy); + static QString Variable2String(const std::string& theVarName, + _PTR(Study) theStudy); + + bool IsValid() const; + + void AddRow( const QString& theName = QString::null, const QString& theValue = QString::null ); + void AddEmptyRow(); + NoteBook_TableRow* GetRowByItem(const QTableWidgetItem* theItem) const; + bool IsLastRow(const NoteBook_TableRow* aRow) const; + + void RemoveSelected(); + + void SetProcessItemChangedSignalFlag(const bool enable); + bool GetProcessItemChangedSignalFlag()const; + + bool IsUniqueName(const NoteBook_TableRow* theRow) const; + QList GetRows() const; + + const bool IsModified() const { return myIsModified; } + const QList& GetRemovedRows() const { return myRemovedRows; } + const VariableMap& GetVariableMap() const { return myVariableMap; } + const VariableMap& GetVariableMapRef() const { return myVariableMapRef; } + void RenamberRowItems(); + + void ResetMaps(); + + public slots: + void onItemChanged(QTableWidgetItem* theItem); + + private: + int getUniqueIndex() const; + + private: + bool isProcessItemChangedSignal; + QList myRows; + + bool myIsModified; + QList myRemovedRows; + VariableMap myVariableMapRef; + VariableMap myVariableMap; + + _PTR(Study) myStudy; +}; + +class SALOMEAPP_EXPORT SalomeApp_NoteBookDlg : public QDialog +{ + Q_OBJECT + public: + SalomeApp_NoteBookDlg(QWidget * parent , _PTR(Study) theStudy); + virtual ~SalomeApp_NoteBookDlg(); + + void Init(_PTR(Study) theStudy); + + public slots: + void onOK(); + void onApply(); + void onCancel(); + void onRemove(); + void onUpdateStudy(); + void onHelp(); + + protected: + bool updateStudy(); + void clearStudy(); + + private: + NoteBook_Table* myTable; + QPushButton* myRemoveButton; + QPushButton* myUpdateStudyBtn; + QPushButton* myOkBtn; + QPushButton* myApplyBtn; + QPushButton* myCancelBtn; + QPushButton* myHelpBtn; + + _PTR(Study) myStudy; +}; + +#endif //SALOMEAPP_NOTEBOOKDLG_H